Cast Eigen :: MatrixXd到Eigen :: MatrixXf [英] Cast Eigen::MatrixXd to Eigen::MatrixXf

查看:2636
本文介绍了Cast Eigen :: MatrixXd到Eigen :: MatrixXf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++程式中使用 Eigen

I am using Eigen on a C++ program.

我想知道是否有一种方法从 Eigen :: MatrixXd Eigen :: MatrixXf

static_cast< Eigen :: MatrixXf> 似乎不起作用,也不是 A.cast< MatrixXf> (这是Eigen的cast方法)。

I wonder if there is a way to cast from Eigen::MatrixXd to Eigen::MatrixXf.
static_cast <Eigen::MatrixXf> doesn't seem to work and neither A.cast<MatrixXf> (this is the cast method from Eigen).

这种类型的转换的任何解决方案?

Any solution for this type of cast?

推荐答案

尝试:

Eigen::MatrixXd d;                       // Matrix of doubles.
Eigen::MatrixXf f = d.cast <float> ();   // Matrix of floats.

这篇关于Cast Eigen :: MatrixXd到Eigen :: MatrixXf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆