Pergunta

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?

Foi útil?

Solução

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>();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top