sqrt doesn't work with Eigen::Map
I would expect that this code compiles, but it doesn't.
void sqrt_map(const double* matrix, int height, int width, double* output) {
using eigen_matrix_double = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
const Eigen::Map<const eigen_matrix_double> input_map(matrix, height, width);
Eigen::Map<eigen_matrix_double> output_map(output, height, width);
output_map = input_map.sqrt();
}
Compilation fails with this lengthy message
In file included from lib/eigen-3.3.7/Eigen/Dense:7:
In file included from lib/eigen-3.3.7/Eigen/Eigenvalues:37:
lib/eigen-3.3.7/Eigen/src/Eigenvalues/./RealSchur.h(61,29): fatal error: no member named 'Options' in 'Eigen::Map<const Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >'
Options = MatrixType::Options,
~~~~~~~~~~~~^
lib/eigen-3.3.7/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h(262,33): note: in instantiation of template class 'Eigen::RealSchur<Eigen::Map<const Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > >' requested here
const RealSchur<MatrixType> schurOfA(arg);
^
lib/eigen-3.3.7/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h(339,60): note: in instantiation of function template specialization 'Eigen::internal::matrix_sqrt_compute<Eigen::Map<const Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> >, 0>::run<Eigen::Map<Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > >' requested here
internal::matrix_sqrt_compute<DerivedEvalTypeClean>::run(tmp, result);
^
lib/eigen-3.3.7/Eigen/src/Core/ReturnByValue.h(62,42): note: in instantiation of function template specialization 'Eigen::MatrixSquareRootReturnValue<Eigen::Map<const Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > >::evalTo<Eigen::Map<Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > >' requested here
{ static_cast<const Derived*>(this)->evalTo(dst); }
^
lib/eigen-3.3.7/Eigen/src/Core/Assign.h(84,19): note: in instantiation of function template specialization 'Eigen::ReturnByValue<Eigen::MatrixSquareRootReturnValue<Eigen::Map<const Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > > >::evalTo<Eigen::Map<Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > >' requested here
other.derived().evalTo(derived());
^
example.cpp(94,14): note: in instantiation of function template specialization 'Eigen::MatrixBase<Eigen::Map<Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > >::operator=<Eigen::MatrixSquareRootReturnValue<Eigen::Map<const Eigen::Matrix<double, -1, -1, 1, -1, -1>, 0, Eigen::Stride<0, 0> > > >' requested here
output_map = input_map.sqrt();
^