Registered Member
|
Hi there,
I would like to convert the following : Matrix<int, Dynamic, Dynamic> intMatrix; To the following : Matrix<float, Dynamic, Dynamic> floatMatrix; Can anyone suggest the best approach ? thanks Matt |
Registered Member
|
floatMatrix = intMatrix.cast<float>();
|
Registered Member
|
That was my original approach, however I think that it looses information.
My current approach is an element wise approach : floatMatrix(i)=(float)(((double)intMatrix(i)/numeric_limits<int>::max())*numeric_limits<int>::max()); There is probably a better approach then this ... I would prefer some vector approach which would be more efficient .... ? Matt |
Registered Member
|
Yes, converting int to float loses information for numbers above 2^24 (if I remember correctly). But I don't see how your more complicated conversion would help.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]