I am beginner in C++ therefore I am facing problem in shuffling the rows of multidimensional array. I have looked in related solutions but did not helped me much. This is what I have tried so far:
int main(int argc, char **argv){
Array<float, 2, 2> f1;
f1 = allocate(4, 4);
f1[0][0] = 1.0;
f1[0][1] = 2.0;
f1[0][2] = 3.0;
f1[0][3] = 4.0;
f1[1][0] = 5.0;
f1[1][1] = 6.0;
f1[1][2] = 7.0;
f1[1][3] = 8.0;
f1[2][0] = 9.0;
f1[2][1] = 10.0;
f1[2][2] = 11.0;
f1[2][3] = 12.0;
f1[3][0] = 13.0;
f1[3][1] = 14.0;
f1[3][2] = 15.0;
f1[3][3] = 16.0;
Array<float,2,2> feature1shuffled = shufflePoints(f1);
cout<<feature1shuffled<<endl;
return 0;
}
Array<float,2,2> shufflePoints(Array<float,2,2> dataSet){
random_device rd;
mt19937 g(rd());
shuffle(begin(dataSet), end(dataSet), g);
return dataSet;
}
But it does not shuffles properly based on rows. Could anyone please help me with this?
Aucun commentaire:
Enregistrer un commentaire