std::random_device rd; //I don't know if this is a generator or not, I have not dug into how all the parts interact under the hood, I just use the <random> thing in very basic ways.
std::mt19937_64 gen(rd());
i also see re-seed examples that would be
_mt.seed(value); //just put the chrono equation in here?
each number in the sequence is generated like this x_0 = seed
x_n = f(x_{n-1})
y_n = g(x_n)y_n is the number that your obtain, x_n is an internal register used in the generation
so each time you ask for another number, the generator changes its state, for that reason `_mt' may not be constant.
> Maybe I needed to post the function in which it is used further:
in general, the error message will point to the line number on your code that causes the error
so that's kind of relevant
also, you need to show the definition of the variables used
Except for @jonnin it is evident that nowhere else in the whole history of human civilization and endeavour has such a meal been made out of generating 6 random numbers.
Why is there a class - why have member _mt? Why floats?
And now, FFS, we're into 'mutable' as this silliness continues.
@againtry pls try hold yourself out from unproductive comments, which brings only negative value - nothing more, as you have no idea about the whole code and how these inputs go to the certain sections and why it must be as they are.
The rest, thank you very much for your insights. It must be with const, so @seeplus thank you very much for your information how to do this with mutable. Thanks again,
A CERN-inspired camel, now with 3 humps (1 mutable of course for a vitally important mersenne twister generator, go figure) complete with a pile of spag-code and all it is there for is to generate 6 random numbers. ROFL
@again, one more time - please keep the no-use comments to yourself. Like I said, you have no idea why is done as it is done, and you are naive enough to think only about 6 random numers. Good luck to you and please don't comment under my posts - I come here to learn, not to discuss some trivial things with toxic, obnoxious people. If it calms you down, believe me, I know how to generate random numbers with three code rows as well.
I'll comment where I like especially when I see through your no-use bad recipes posing as any sort of programming.
You're the one with 6 random numbers and your camel solution, not me.
if you had any ability and came here to learn you would have cottoned on to what @jonnin commented and left it at that instead of going down a rabbit hole with the others.
Toxic and obnoxious? is that your best shot to cover up when you can't program, don't understand classes, use floats, make a const member _mt. All you're doing is adding to your self-made joke of yourself as a totally immutable dope.
And how it goes further? You insult me, I will insult you, and so on, will you get a pleasure from this or what? Ok, let's try another way.
Dear Mr, yes, you are right, as you kindly noticed, I am a beginner in C++. Kindly please share your experience how would you rewrite this piece of code that it would serve the purpose in more efficient way? Note that this class is intended to generate the special geometrical structure using the random numbers. The _mt should be within the constructor, and it goes to the function of random_number, then output goes to the function of random_rotation, and this output goes to the actual construction of the specially rotated chain. The constructor has more functions as well, but these are not related to the random numbers.
Most of variables should be const as it speeds up the computing in the supercluster. I am not sure yet which way is better - remove const or use mutable. I need to check with my supervisor if I can remove const, for now I used mutable and it works - works well as intended.
With all above stated, and in the best spirit of learning instead of insulting and flaming, kindly please enlighten me, as I am using this first time ever and don't have a deep understanding: 1) why is bad to use mutable ? 2) what would be more preferable way? Also please note that I am not familiar with expert terminology ( I sincerely have no Idea what is camel in this context, humps, or why we are talking about CERN), so it would nice that you could just illustrate this in the example. Thank you very much, and sorry if I insulted you as your way of expressing your expert opinion in your posts above was not understandable for me(probably due my lack of experience).
then output goes to the function of random_rotation, and this output goes to the actual construction of the specially rotated chain. The constructor has more functions as well, but these are not related to the random numbers.
That functionality can be added to the relevant class - SpecialGeometricStructure - by the sound of it. All by way of the other (SomeUnknownClassToMe) class member _m_SGS or separately under its own steam as a completely independent SpecialGeometricStructure object.
Thanks. So you propose to put the generator into the separate class, if I understand correctly. Respecting your work, I will try to do this and revert if it works as intended. Could you also please explain why it is better? Is it like so called good programming to use the separate classes for different things, I suppose? Or it should work more efficiently?
You obviously don't have to do it this way but it separates out into two classes what I am guessing you are trying to do without seeing the full picture.
It also enables you to isolate problems that may occur which if you look at the record here in this thread that is where it starts off.
Classes encapsulate objects (nouns) and objects have methods (c.f functions). Generating a vector (random or otherwise), a verb phrase, is a function or something an 'SGM' object does. That's the way OOP works.
If you think about it carefully, you'll see why the vector is an class/object member and generating it is something the object does to that member. The class encapsulates those two aspects. Keeping the classes simple and self-contained means they are easier to debug and can be shared jobs for a team.
Of course you can do all this with a single class but for all I know there may be other types of objects having SpecialGraphicStructures so there is greater reusability. That's up to your design.
Note also there is no need to have the twister as a data member . Why would you is my question? Only you know. All I see is that I make a couple of (su_1, su_2) objects by declaring them and telling them to go to work.
It's not the only way but there are lots of benefits with OOP ... same for C++ I suppose.
Thanks. I guess intuitively I am more into the functional programming as I tend to put everything in one place according their functionality, and OOP is counterintuitive for me however I recognize the benefits of it especially when everything grows and I accept that this is a way to go.
To sump up, after learning about more about the topic, it seems that mutable type could be possibly thread-unsafe, so the separation of random generator in to the other class is the way to go indeed.