Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of lpNorm in Eigen

Tags:

c++

eigen

I am trying to do some L_p norm calculations within a template function something of the sort

template<typename Number>
Number foo(const Eigen::MatrixBase<Number>& matrix)
{
  return matrix.lpNorm<1>(); 
}

However, CLang throws an error "expected expression" at the end of the line if I try to call foo(matrix). If I work with concretely defined (double) matrices, lpNorm works just fine. How do I go about with this case?

like image 988
Jon Gan Avatar asked Mar 16 '23 23:03

Jon Gan


1 Answers

Classical C++ mistake. The solution is to use the template keyword as follow:

return matrix.template lpNorm<1>();

See the details.

like image 180
ggael Avatar answered Mar 28 '23 03:03

ggael