Reputation: 624
How can I typecast a mat to fmat. One of my function is returning mat. However in the interest of memory, I want to convert it to fmat. How can I type cast it?
Upvotes: 2
Views: 3755
Reputation: 1150
You can convert between matrix types using conv_to:
mat A = my_function();
fmat B = conv_to<fmat>::from(A);
fmat C = conv_to<fmat>::from(my_function());
Alternatively, you could change your function into a template; for example:
template <typename T>
Mat<T> other_function() {
return Mat<T>(4,4);
}
...
fmat D = other_function<float>();
mat F = other_function<double>();
Upvotes: 5