Skip to content

FAILED to compile with cwiseMax<PropagateNaN>(0.) under eigen-3.4.0

Summary

Environment

  • Operating System : Linux
  • Architecture : x64 ...
  • Eigen Version : 3.4.0
  • Compiler Version : Gcc11.1.0
  • Compile Flags : -O3 -march=native -stc=c++20
  • Vector Extension : SSE/AVX/NEON ...

Minimal Example

//show your code here
vector<double> v {1., 2., NAN, -100., 100., 0., 80, -9};
Map<VectorXd> ev(v.data(), v.size());
RowVectorXd p = ev.template cwiseMax<PropagateNaN>(0.);

Steps to reproduce

  1. first step
  2. second step
  3. ...

What is the current bug behavior?

What is the expected correct behavior?

Relevant logs

Warning Messages

Benchmark scripts and results

Anything else that might help

  • Have a plan to fix this issue.

I failed to compile the following code with g++-11.1.0 on Linux Mint 19

vector<double> v {1., 2., NAN, -100., 100., 0., 80, -9};
Map<VectorXd> ev(v.data(), v.size());
RowVectorXd p = ev.template cwiseMax<PropagateNaN>(0.);

the compile flag is -std=c++20, and the eigen version is 3.4.0. the error message is listed as below.

error: no matching function for call to ‘Eigen::Map<Eigen::Matrix<double, -1, 1> >::cwiseMaxEigen::PropagateNaN(double)’ 52 | RowVectorXd p = ev.template cwiseMax(0.); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~

/home/hnie/repo/eigen/Eigen/src/Core/../plugins/MatrixCwiseBinaryOps.h:104:1: note: candidate: ‘template const Eigen::CwiseBinaryOp<Eigen::internal::scalar_max_op<typename Eigen::internal::traits::Scalar, typename Eigen::internal::traits::Scalar>, const Derived, const OtherDerived> Eigen::MatrixBase::cwiseMax(const Eigen::MatrixBase&) const [with OtherDerived = OtherDerived; Derived = Eigen::Map<Eigen::Matrix<double, -1, 1> >]’ 104 | cwiseMax(const EIGEN_CURRENT_STORAGE_BASE_CLASS &other) const | ^~~~~~~~ /home/hnie/repo/eigen/Eigen/src/Core/../plugins/MatrixCwiseBinaryOps.h:104:1: note: template argument deduction/substitution failed: cwise.cpp:52:46: error: type/value mismatch at argument 1 in template parameter list for ‘template const Eigen::CwiseBinaryOp<Eigen::internal::scalar_max_op<typename Eigen::internal::traits::Scalar, typename Eigen::internal::traits::Scalar>, const Derived, const OtherDerived> Eigen::MatrixBase::cwiseMax(const Eigen::MatrixBase&) const [with OtherDerived = OtherDerived; Derived = Eigen::Map<Eigen::Matrix<double, -1, 1> >]’ 52 | RowVectorXd p = ev.template cwiseMax(0.); | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ cwise.cpp:52:46: note: expected a type, got ‘Eigen::PropagateNaN’

Edited by Huirao Nie