armadillo c++ typecast double matrix mat to float matrix fmat
如何将 mat 类型转换为 fmat。我的功能之一是返回垫子。但是为了记忆,我想将其转换为 fmat。我怎样才能输入转换它?
您可以使用 conv_to:
在矩阵类型之间进行转换
1 2 3
|
mat A = my_function();
fmat B = conv_to<fmat>::from(A);
fmat C = conv_to<fmat>::from(my_function());
|
或者,您可以将函数更改为模板;例如:
1 2 3 4 5 6 7 8 9
|
template <typename T >
Mat < T > other_function () {
return Mat < T >(4, 4);
}
…
fmat D = other_function<float>();
mat F = other_function<double>();
|
- 向量呢?例如,双向量 vec 到浮点向量 fvec?上述解决方案也适用于矢量。谢谢!!!!
来源:https://www.codenong.com/21177094/
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9570.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57