简体   繁体   English

特征值:将浮点矩阵乘以布尔向量

[英]Eigen: multiply a float matrix by a bool vector

I need to perform A*v in Eigen where v is a vector of size p with t ones in random positions and pt zeros, for more details look this question. 我需要在Eigen中执行A*v ,其中v是大小为p的向量,在随机位置上有t个,而pt为零,有关更多详细信息,请看问题。

My first question is: there is any way to do it in Eigen ? 我的第一个问题是:在Eigen有什么方法可以做到? If you know how to do it, please answer this question. 如果您知道该怎么做,请回答问题。

My second question is: in the first linked question I found a time and memory efficient method via std::vector<bool> , then it would be pretty easy to use it through Eigen::Map . 我的第二个问题是:在第一个链接的问题中,我通过std::vector<bool>找到了一种节省时间和内存的方法,然后通过Eigen::Map可以很容易地使用它。

The problem is that I tried to do the following (just for testing purpose): 问题是我尝试执行以下操作(仅出于测试目的):

Eigen::Matrix<bool,2,1> v;
Eigen::Matrix<float,2,2> A;
v<<1,0;
A<<1,2,3,4;
A*v;

But I get a compile error (find it at the end of the question). 但是我遇到了一个编译错误(在问题末尾找到它)。 How can I do it? 我该怎么做? A simple workaround could be declaring Eigen::Matrix<float,2,1> v; 一个简单的解决方法是声明Eigen::Matrix<float,2,1> v; but this could be really memory inefficient (especially considering that v could be big). 但这实际上可能会使内存效率低下(尤其是考虑到v可能很大)。

/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h: In instantiation of ‘struct Eigen::internal::traits<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >’:
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:41:34:   required from ‘class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >’
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:48:34:   required from ‘class Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >’
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:114:7:   required from ‘class Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>’
../Math.hpp:83:7:   required from ‘static void Math::createHashTable(const cv::Mat&, cv::Mat&, cv::Mat&, int, int) [with T = float]’
../CloudCache.cpp:155:58:   required from here
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:43:112: error: no type named ‘ReturnType’ in ‘struct Eigen::internal::scalar_product_traits<float, bool>’
   typedef typename scalar_product_traits<typename _LhsNested::Scalar, typename _RhsNested::Scalar>::ReturnType Scalar;
                                                                                                                ^
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:69:51: error: no type named ‘ReturnType’ in ‘struct Eigen::internal::scalar_product_traits<float, bool>’
                           || ( (ColsAtCompileTime % packet_traits<Scalar>::size) == 0
                                                   ^
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:76:51: error: no type named ‘ReturnType’ in ‘struct Eigen::internal::scalar_product_traits<float, bool>’
                           || ( (RowsAtCompileTime % packet_traits<Scalar>::size) == 0
                                                   ^
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:94:63: error: no type named ‘ReturnType’ in ‘struct Eigen::internal::scalar_product_traits<float, bool>’
                     : InnerSize * (NumTraits<Scalar>::MulCost + LhsCoeffReadCost + RhsCoeffReadCost)
                                                               ^
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:95:41: error: no type named ‘ReturnType’ in ‘struct Eigen::internal::scalar_product_traits<float, bool>’
                       + (InnerSize - 1) * NumTraits<Scalar>::AddCost,
                                         ^
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:107:41: error: no type named ‘ReturnType’ in ‘struct Eigen::internal::scalar_product_traits<float, bool>’
                           && (InnerSize % packet_traits<Scalar>::size == 0)
                                         ^
In file included from /usr/local/include/eigen3/Eigen/Core:278:0,
                 from ../Math.hpp:13,
                 from ../CloudCache.cpp:15:
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h: In instantiation of ‘class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >’:
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:48:34:   required from ‘class Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >’
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:114:7:   required from ‘class Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>’
../Math.hpp:83:7:   required from ‘static void Math::createHashTable(const cv::Mat&, cv::Mat&, cv::Mat&, int, int) [with T = float]’
../CloudCache.cpp:155:58:   required from here
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:67:25: error: using-declaration for non-member at class scope
     using Base::operator*;
                         ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:68:17: error: using-declaration for non-member at class scope
     using Base::derived;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:69:17: error: using-declaration for non-member at class scope
     using Base::const_cast_derived;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:70:17: error: using-declaration for non-member at class scope
     using Base::rows;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:71:17: error: using-declaration for non-member at class scope
     using Base::cols;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:72:17: error: using-declaration for non-member at class scope
     using Base::size;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:73:17: error: using-declaration for non-member at class scope
     using Base::rowIndexByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:74:17: error: using-declaration for non-member at class scope
     using Base::colIndexByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:75:17: error: using-declaration for non-member at class scope
     using Base::coeff;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:76:17: error: using-declaration for non-member at class scope
     using Base::coeffByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:77:17: error: using-declaration for non-member at class scope
     using Base::packet;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:78:17: error: using-declaration for non-member at class scope
     using Base::packetByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:79:17: error: using-declaration for non-member at class scope
     using Base::writePacket;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:80:17: error: using-declaration for non-member at class scope
     using Base::writePacketByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:81:17: error: using-declaration for non-member at class scope
     using Base::coeffRef;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:82:17: error: using-declaration for non-member at class scope
     using Base::coeffRefByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:83:17: error: using-declaration for non-member at class scope
     using Base::copyCoeff;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:84:17: error: using-declaration for non-member at class scope
     using Base::copyCoeffByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:85:17: error: using-declaration for non-member at class scope
     using Base::copyPacket;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:86:17: error: using-declaration for non-member at class scope
     using Base::copyPacketByOuterInner;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:87:26: error: using-declaration for non-member at class scope
     using Base::operator();
                          ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:88:26: error: using-declaration for non-member at class scope
     using Base::operator[];
                          ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:89:17: error: using-declaration for non-member at class scope
     using Base::x;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:90:17: error: using-declaration for non-member at class scope
     using Base::y;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:91:17: error: using-declaration for non-member at class scope
     using Base::z;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:92:17: error: using-declaration for non-member at class scope
     using Base::w;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:93:17: error: using-declaration for non-member at class scope
     using Base::stride;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:94:17: error: using-declaration for non-member at class scope
     using Base::innerStride;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:95:17: error: using-declaration for non-member at class scope
     using Base::outerStride;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:96:17: error: using-declaration for non-member at class scope
     using Base::rowStride;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/DenseBase.h:97:17: error: using-declaration for non-member at class scope
     using Base::colStride;
                 ^
In file included from /usr/local/include/eigen3/Eigen/Core:279:0,
                 from ../Math.hpp:13,
                 from ../CloudCache.cpp:15:
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h: In instantiation of ‘class Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >’:
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:114:7:   required from ‘class Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>’
../Math.hpp:83:7:   required from ‘static void Math::createHashTable(const cv::Mat&, cv::Mat&, cv::Mat&, int, int) [with T = float]’
../CloudCache.cpp:155:58:   required from here
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:71:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::derived’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::derived;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:72:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::const_cast_derived’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::const_cast_derived;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:73:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::rows’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::rows;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:74:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::cols’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::cols;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:75:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::size’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::size;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:76:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::coeff’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::coeff;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:77:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::coeffRef’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::coeffRef;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:79:17: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::eval’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::eval;
                 ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:82:25: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::operator*=’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::operator*=;
                         ^
/usr/local/include/eigen3/Eigen/src/Core/MatrixBase.h:83:25: error: no members matching ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::operator/=’ in ‘Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >::Base {aka class Eigen::DenseBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     using Base::operator/=;
                         ^
In file included from /usr/local/include/eigen3/Eigen/Core:20:0,
                 from ../Math.hpp:13,
                 from ../CloudCache.cpp:15:
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h: In instantiation of ‘class Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>’:
../Math.hpp:83:7:   required from ‘static void Math::createHashTable(const cv::Mat&, cv::Mat&, cv::Mat&, int, int) [with T = float]’
../CloudCache.cpp:155:58:   required from here
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:121:5: error: no members matching ‘Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>::Base {aka Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::derived’ in ‘Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>::Base {aka class Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     EIGEN_DENSE_PUBLIC_INTERFACE(CoeffBasedProduct)
     ^
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:121:5: error: no members matching ‘Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>::Base {aka Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}::const_cast_derived’ in ‘Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>::Base {aka class Eigen::MatrixBase<Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6> >}’
     EIGEN_DENSE_PUBLIC_INTERFACE(CoeffBasedProduct)
     ^
In file included from /usr/local/include/eigen3/Eigen/Core:254:0,
                 from ../Math.hpp:13,
                 from ../CloudCache.cpp:15:
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h: In instantiation of ‘Eigen::CoeffBasedProduct<Lhs, Rhs, NestingFlags>::CoeffBasedProduct(const Lhs&, const Rhs&) [with Lhs = Eigen::Matrix<float, 2, 2>; Rhs = Eigen::Matrix<bool, 2, 1>; LhsNested = const Eigen::Matrix<float, 2, 2>&; RhsNested = const Eigen::Matrix<bool, 2, 1>&; int NestingFlags = 6]’:
/usr/local/include/eigen3/Eigen/src/Core/GeneralProduct.h:598:91:   required from ‘const typename Eigen::ProductReturnType<Derived, OtherDerived>::Type Eigen::MatrixBase<Derived>::operator*(const Eigen::MatrixBase<OtherDerived>&) const [with OtherDerived = Eigen::Matrix<bool, 2, 1>; Derived = Eigen::Matrix<float, 2, 2>; typename Eigen::ProductReturnType<Derived, OtherDerived>::Type = Eigen::CoeffBasedProduct<const Eigen::Matrix<float, 2, 2>&, const Eigen::Matrix<bool, 2, 1>&, 6>]’
../Math.hpp:83:7:   required from ‘static void Math::createHashTable(const cv::Mat&, cv::Mat&, cv::Mat&, int, int) [with T = float]’
../CloudCache.cpp:155:58:   required from here
/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:154:7: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
       EIGEN_STATIC_ASSERT((internal::scalar_product_traits<typename Lhs::RealScalar, typename Rhs::RealScalar>::Defined),
       ^
subdir.mk:30: recipe for target 'CloudCache.o' failed
make: *** [CloudCache.o] Error 1

You need to cast to the relevant type. 您需要强制转换为相关类型。 Eigen doesn't support implicit type casting so you'd have to write: Eigen不支持隐式类型转换,因此您必须编写:

A*v.cast<float>();

There was a hint to this in the error output: 错误输出中对此有一个提示:

/usr/local/include/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h:154:7: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM