0
Eigen::PermutationMatrix
のパブリックメソッドindices()
の戻り値を配列として保存したいとします(たとえば、後で関心のある値を抽出するなど)。Eigen :: PermutationMatrix.indices()を配列/ベクトルに変換する
どのように配列(Eigen::Array
またはC++ STLベクター)に変換する必要がありますか?ここで
は、私が試したものです:
Eigen::FullPivLU<Eigen::MatrixXf> lu(LU_A); //LU_A is of type Eigen::MatrixXf
Eigen::ArrayXXf lins;
lins = lu.permutationP().indices().cast<int>().array(); //trows an error
エラー:あなたがfloat
配列内部int
配列を格納しようとしている
In file included from /home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/Core:347:0,
from /home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/Dense:1,
from Matrice.hpp:5,
from Matrice.cpp:1:
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/AssignEvaluator.h: In instantiation of ‘void Eigen::internal::call_assignment_no_alias(Dst&, const Src&, const Func&) [with Dst = Eigen::Array<float, -1, -1>; Src = Eigen::ArrayWrapper<const Eigen::Matrix<int, -1, 1> >; Func = Eigen::internal::assign_op<float, int>]’:
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/AssignEvaluator.h:804:27: required from ‘void Eigen::internal::call_assignment(Dst&, const Src&, const Func&, typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type) [with Dst = Eigen::Array<float, -1, -1>; Src = Eigen::ArrayWrapper<const Eigen::Matrix<int, -1, 1> >; Func = Eigen::internal::assign_op<float, int>; typename Eigen::internal::enable_if<(! Eigen::internal::evaluator_assume_aliasing<Src>::value), void*>::type = void*]’
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/AssignEvaluator.h:782:18: required from ‘void Eigen::internal::call_assignment(Dst&, const Src&) [with Dst = Eigen::Array<float, -1, -1>; Src = Eigen::ArrayWrapper<const Eigen::Matrix<int, -1, 1> >]’
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/PlainObjectBase.h:710:32: required from ‘Derived& Eigen::PlainObjectBase<Derived>::_set(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::ArrayWrapper<const Eigen::Matrix<int, -1, 1> >; Derived = Eigen::Array<float, -1, -1>]’
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/Array.h:109:24: required from ‘Eigen::Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& Eigen::Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::operator=(const Eigen::DenseBase<OtherDerived>&) [with OtherDerived = Eigen::ArrayWrapper<const Eigen::Matrix<int, -1, 1> >; _Scalar = float; int _Rows = -1; int _Cols = -1; int _Options = 0; int _MaxRows = -1; int _MaxCols = -1]’
Matrice.cpp:380:58: required from here
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/util/StaticAssert.h:32:40: error: static assertion failed: YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY
#define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/util/XprHelper.h:816:3: note: in expansion of macro ‘EIGEN_STATIC_ASSERT’
EIGEN_STATIC_ASSERT((Eigen::internal::has_ReturnType<ScalarBinaryOpTraits<LHS, RHS,BINOP> >::value), \
^~~~~~~~~~~~~~~~~~~
/home/ldfzor/Documents/CodeBlocks_Projects/POO_Matrice_Eigen/eigen3_3_3/Eigen/src/Core/AssignEvaluator.h:834:3: note: in expansion of macro ‘EIGEN_CHECK_BINARY_COMPATIBILIY’
EIGEN_CHECK_BINARY_COMPATIBILIY(Func,typename ActualDstTypeCleaned::Scalar,typename Src::Scalar);