This bugzilla service is closed. All entries have been migrated to
Bug 1509 - Issue with computeInverseWithCheck on std::complex<double> type
Summary: Issue with computeInverseWithCheck on std::complex<double> type
Alias: None
Product: Eigen
Classification: Unclassified
Component: LU (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - 64-bit Linux
: Normal Unknown
Assignee: Nobody
Depends on:
Reported: 2018-01-26 08:56 UTC by Renaud Badina
Modified: 2019-12-04 17:25 UTC (History)
2 users (show)


Description Renaud Badina 2018-01-26 08:56:01 UTC

When using Eigen's Matrix on std::complex<double> scalar type I got compilation issue on computeInverseWithCheck function on Eigen 3.3.4.

Here is the compilation log:
    /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/Eigen/Eigen/src/LU/InverseImpl.h: In instantiation of ‘void Eigen::MatrixBase<Derived>::computeInverseWithCheck(ResultType&, bool&, const RealScalar&) const [with ResultType = Eigen::Matrix<std::complex<double>, 2, 2, 1>; Derived = Eigen::Matrix<std::complex<double>, 2, 2, 1>; Eigen::MatrixBase<Derived>::RealScalar = double]’:
    INTERNAL/MatrixForRF/TParameter.cpp:299:72:   required from here
    /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/Eigen/Eigen/src/LU/InverseImpl.h:410:87: error: no matching function for call to ‘Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 2, 2, 1> >::computeInverseAndDetWithCheck(Eigen::Matrix<std::complex<double>, 2, 2, 1>&, Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 2, 2, 1> >::RealScalar&, bool&, const RealScalar&) const’
    /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/Eigen/Eigen/src/LU/InverseImpl.h:410:87: note: candidate is:
    In file included from /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/Eigen/Eigen/LU:35:0,
                     from /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/Eigen/Eigen/Dense:2,
                     from /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/UnisonComplexMatrix.h:21,
                     from INTERNAL/MatrixForRF/TParameter.cpp:1:
    /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/Eigen/Eigen/src/LU/InverseImpl.h:362:13: note: void Eigen::MatrixBase<Derived>::computeInverseAndDetWithCheck(ResultType&, typename ResultType::Scalar&, bool&, const RealScalar&) const [with ResultType = Eigen::Matrix<std::complex<double>, 2, 2, 1>; Derived = Eigen::Matrix<std::complex<double>, 2, 2, 1>; typename ResultType::Scalar = std::complex<double>; Eigen::MatrixBase<Derived>::RealScalar = double]
     inline void MatrixBase<Derived>::computeInverseAndDetWithCheck(
    /home/localuser/PROJECTS/UNISON_GENERIC_MODULE/MatrixForRF/Eigen/Eigen/src/LU/InverseImpl.h:362:13: note:   no known conversion for argument 2 from ‘Eigen::MatrixBase<Eigen::Matrix<std::complex<double>, 2, 2, 1> >::RealScalar {aka double}’ to ‘Eigen::Matrix<std::complex<double>, 2, 2, 1>::Scalar& {aka std::complex<double>&}’

I guess the issue is coming from the file Eigen/src/LU/InverseImpl.h where the function is defined this way:
template<typename Derived>
template<typename ResultType>
inline void MatrixBase<Derived>::computeInverseWithCheck(
    ResultType& inverse,
    bool& invertible,
    const RealScalar& absDeterminantThreshold
  ) const
  RealScalar determinant;
  // i'd love to put some static assertions there, but SFINAE means that they have no effect...
  eigen_assert(rows() == cols());

My assumption is that the determinant variable shouldn't be defined as "RealScalar" type but more as "typename ResultType::Scalar".
For type like double, int, etc... it will make no difference, for std::complex<double> it doesn't work.

I hope my analysis is correct.
Comment 1 Gael Guennebaud 2018-04-04 13:37:23 UTC
Sorry for the delay. It is working well for me regardless of the compiler. I'm closing it as "worksforme". If you still has the issue, please re-open with a reproducible code snippet.
Comment 2 Gael Guennebaud 2018-04-04 13:49:57 UTC
Sorry, I've too fast reading our inverse.cpp unit test. You are perfectly right!  (default)  (3.3)
Comment 3 Nobody 2019-12-04 17:25:03 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance:

Note You need to log in before you can comment on or make changes to this bug.