문제

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?

도움이 되었습니까?

해결책

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>();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top