2017-01-19 2 views
0

次のコードに問題があるようです。私はpose_l名前を変更し、M_inv1 ...Eigenクラスの未修飾ID

をエラーメッセージ私は私のテンプレートを使用していないサンプルMatrixXfで

error: expected unqualified-id before numeric constant

Eigen::Matrix M_inv1_abc = pose_l.block<3, 3>(0, 0).inverse(); This is a code sample:

template<typename T> 
Eigen::Matrix<T, 4, 1> Function(Eigen::Matrix<T, 3, 4> pose_l) 
{ 

// fails here 
Eigen::Matrix<T, 3, 3> M_inv1 = pose_l.block<3, 3>(0, 0).inverse(); 

// this works, sample is from https://eigen.tuxfamily.org/dox/group__TutorialMatrixClass.html 
Eigen::MatrixXf m(4,4); 
Eigen::MatrixXf y(2,2); 
m << 1, 2, 3, 4, 
     5, 6, 7, 8, 
     9,10,11,12, 
    13,14,15,16; 
y = m.block<2,2>(1,1); 

} 

を取得します。他の投稿では Expected unqualified-id before numeric constant for defining a number のような再定義が助けになりましたが、私の場合はそうではありません。

私には何が欠けていますか?

ベスト ManuKlause

+1

この[ページ](http://eigen.tuxfamily.org/dox/TopicTemplateKeywordを参照してください。 html)の場合は、ブロックの前に 'pose_l.template block <3, 3>(0、0)'というテンプレートキーワードを追加する必要があります。 – ggael

+0

これは助けになりました。あなたの投稿を解決策にしたいのですが、どうすればいいですか(このフォーラムでは新しい...) – ManuKlause

答えて

0

(ブロック部分式の周りに括弧を追加する)、これを試してみてください:

template<typename T> 
Eigen::Matrix<T, 4, 1> Function(Eigen::Matrix<T, 3, 4> pose_l) 
{ 
    Eigen::Matrix<T, 3, 3> M_inv1 = (pose_l.block<3, 3>(0, 0)).inverse(); 
    // ... 
}