Use of lpNorm in Eigen
Asked Answered
Z

1

5

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?

Zink answered 18/2, 2015 at 14:9 Comment(0)
A
8

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

return matrix.template lpNorm<1>();

See the details.

Arbil answered 18/2, 2015 at 14:45 Comment(1)
Me neither! Discovering new stuffs in C++ every day!Zink

© 2022 - 2024 — McMap. All rights reserved.