可能获得类型Eigen :: MatrixBase< T> & [英] Possible to get type of Eigen::MatrixBase<T> &
本文介绍了可能获得类型Eigen :: MatrixBase< T> &的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
具有Eigen :: MatrixBase&数据,有什么办法得到如果它是一个浮点数或双矩阵?
我需要创建一个与MatrixBase相同大小和类型的新的复杂矩阵。
having a Eigen::MatrixBase & data, are there any way to get if it is a float or double matrix? I need to create an new complex matrix of the same size and type as the MatrixBase.
如果是MatrixXf,那么我需要创建MatrixXcf,如果MatrixXd我需要MatrixXcD。
If it is MatrixXf then i need to create MatrixXcf, and if MatrixXd i need MatrixXcD.?
template <typename A>
int dowork(const Eigen::MatrixBase<A>& data)
推荐答案
这很简单,只需使用A :: RealScalar typedef来构建你的复杂类型:
That's pretty simple, just use the A::RealScalar typedef to build your complex type:
template <typename A>
int dowork(const Eigen::MatrixBase<A>& data) {
typedef Matrix<std::complex<typename A::RealScalar, Dynamic, Dynamic> MatCplx;
...
这篇关于可能获得类型Eigen :: MatrixBase< T> &的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文