2017-01-10 16 views
0

私は次のように定義されてoperator()でテンプレートクラスを定義します。コール.dot()のEigen no matching関数?私のコードでは

currentfe_.metric() 

Eigen::Matrix<double,2,2>を返すクラスFiniteElementの方法です

template<class Integrator, int ORDER> 
inline double operator() (FiniteElement<Integrator, ORDER,2,3>& currentfe_, 
          int i, int j, int iq, int ic = 0) 
{ 
    Real s = 0; 

    Eigen::Matrix<double,2,1> grad_phi_i; 
    Eigen::Matrix<double,2,1> grad_phi_j; 

    grad_phi_i(0) = ... 
    grad_phi_i(1) = ... 
    grad_phi_j(0) = ... 
    grad_phi_j(1) = ... 

    s = grad_phi_i.dot(currentfe_.metric().dot(grad_phi_j)); 

    return s; 
} 

私が手にエラーがある:

error: no matching function for call to ‘Eigen::Matrix<double, 2, 1>::dot(Eigen::internal::scalar_product_traits<double, double>::ReturnType)’ 
s = grad_phi_i.dot(currentfe_.metric().dot(grad_phi_j)); 

そして、私は理由を理解することはできません。

答えて

2

これは、マトリックス.dot()メソッドがベクトル間のスカラープロダクトのみのためです(documentation参照)。 Here行列とベクトルの乗算は*で実行されます。

可能な解決策である。

grad_phi_i*currentfe_.metric()*grad_phi_j.transpose() 
+0

正確には、それは '.DOT()'メソッドを持っているが、それだけで2つのベクトル間のスカラー積のためだと戻り型は、このようにスカラーです。 – ggael

+0

@ggaelが正しいです。私はこの点を明確にし、参考にするために答えを編集します。 – nickerx

関連する問題