My class contains some vector matrix of type:
typedef std::vector<double> MyArray;
typedef std::vector<MyArray> MyMatrix;
Class has an update() method, and on each call it should generate a new random matrix, and old place in std::map<double, MyMatrix, std::greater<double>> rankedMyMatrix_;.
Update method looks approximately like this:
void MyClass::update(...){
...
this->generateMyMatrix(); // Generates new random currentMyMatrix_
...
rankedMyMatrix_.insert({matrixRank_, currentMyMatrix_});
...
}
Method generateMyMatrix() looks like this:
void MyClass::generateMyMatrix(){
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_real_distribution<double> dist(-1, 1);
for (int i = 0; i < noMotors_; i++) {
MyArray array(MaxArraySamples, 0);
for (int j = 0; j < MaxArraySamples; j = j + steps) {
array[j] = dist(mt);
}
currentMyMatrix_.push_back(array);
}
}
Trouble is that on each push to rankedMyMatrix_ map, on new update() it generates same matrix. Or it does not write to it? Probably I am missing something here, so any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire