I want to define two 2d matrices: f and f_transpose for the type: std::array <std::array <float, 3>, dim> and std::array <std::array <float, dim>, 3> . The value of dim is 23 .
I want the elements f[0][0] , f[1][1] , f[2][2] , f_transpose[0][0] , f_transpose[1][1] and f_transpose[2][2] were 1 , and the remaining elements were 0 .
These arrays are global variables, and I tried the following:
static array <array <float, 3>, dim> f = {{{{1}}, {{0, 1}}, {{0, 0, 1}}}}; static array <array <float, dim>, 3> f_transpose = {{{{1, 0, 0}}, {{0, 1, 0}}, {{0, 0, 1}}}};
This gives me 1 in the necessary places, but some of the values ββthat should be 0 are 1 or -1 . I understand that everything that is not defined will be considered 0 , but it is clear that not what is happening. How do I solve this problem?
Edit:
I had to remove the github link provided here earlier. But for the answer (and comment) to make sense, I added the appropriate function below:
void print_ffamily(){ cout << "F Matrix" << endl; for (int i = 0; i < 3; i++){ for (int j = 0; j < dim; j++){ printf("%0.2f ", f[i][j]); } cout << endl; } cout << "F transposed Matrix" << endl; for (int i = 0; i < dim; i++){ for (int j = 0; j < 3; j++){ printf("%0.2f ", f_transpose[i][j]); } cout << endl; } }