私は次のプログラムを持っています:
#include <Eigen/Core>
using namespace Eigen;
template <int _n, int _m>
void func(Matrix<double, _m, _n> A)
{
Matrix<double, 2, 3> AA;
AA << 1, 0, 5,
2, 0, 7;
MatrixXd KK = AA.triangularView<Lower>();
// if I uncomment this, the code won't compile
// MatrixXd K = A.triangularView<Lower>();
}
int main()
{
Matrix<double, 2, 4> AA;
AA << 1, 0, 5, 17,
2, 0, 7, -2;
func(AA);
return 0;
}
私はそれをコンパイルしますg++ $(pkg-config --cflags --libs eigen3) -o main main.cc
示されたコードがコメントアウトされている場合、次のエラーが発生します。
main.cc: In function ‘void func(Eigen::Matrix<double, _m, _n>)’:
main.cc:15:40: error: expected primary-expression before ‘)’ token
main.cc: In instantiation of ‘void func(Eigen::Matrix<double, _m, _n>) [with int _n = 4; int _m = 2]’:
main.cc:26:10: required from here
main.cc:15:40: error: no match for ‘operator<’ in ‘A.Eigen::MatrixBase<Eigen::Matrix<double, 2, 4> >::triangularView < (Eigen::._79)1u’
r
私はここで問題を理解していません。Lower
メンバー関数を呼び出したいだけなのに、g++は行列を列挙型定数と比較したくないと考えているようです。