How To Interpret std::map Partnered with glm::ivec3 and Struct?

Hello Professionals,

Good day. I came across this programming troubleshooting problem wherein I am trying to print the value of the key of a certain std::map. However, it seems like I get so large float numbers (it seems like it's not the true number I am looking for). I was wondering if there's a proper way of calling it? I know how to call/print a certain key & value partner such as:

1
2
3
std::unordered_map<int, int> mp; //key and value
mp.insert(std::make_pair(3, 700));
std::cout<<mp[3]; //which in this case the print value is "700". 


On the other hand, if I have this kind of syntax:

1
2
3
4
5
6
7
8
9
struct CellInfo{
 float coeff[3][3][3];
}

glm::ivec3 indCell = glm::ivec3(iCell, jCell, kCell);
CellInfo cellinformation;
std::unordered_map<glm::ivec3, cellinformation> g_polCoeff; //key and value
g_polCoeff.insert(std::make_pair(indCell, cellinformation));
std::cout << "g_polCoeff[indCell]:" << g_polCoeff[indCell].coeff; //When I try to print it this way, I kind of get hexadecimal values such as 0132CA34, 013358AC, and so on... 


I think there's a problem of how I call/print it? Can you please help me how can I properly call/print the value of g_polCoeff?
Last edited on
The << has not been overloaded to work with arrays. If you want to print all the float values in coeff you can loop over the array and print them one by one.
you need to traverse the matrix and print element by element.
1
2
3
4
5
for (int K=0; K<3; ++K){
   for (int L=0; L<3; ++L)
      std::cout << g_polCoeff[indCell].coeff[K][L] << ' ';
   std::cout << '\n';
}
Is it also possible to print the values incorporated in glm::ivec3???
Thank you very much for all your help about the g_polCoeff.
I found the answer from this link of how to print the glm::ivec3...
https://stackoverflow.com/questions/11515469/how-do-i-print-vector-values-of-type-glmvec3-that-have-been-passed-by-referenc

Have a blessed day ahead! :)
Topic archived. No new replies allowed.