[Bug?] `ComplexEigenSolver` should allow user defined complex types

Summary

On line 73 of ComplexEigenSolver the ComplexScalar type is defined as std::complex<RealScalar>

https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Eigenvalues/ComplexEigenSolver.h#L73

  /** \brief Complex scalar type for #MatrixType.
   *
   * This is \c std::complex<Scalar> if #Scalar is real (e.g.,
   * \c float or \c double) and just \c Scalar if #Scalar is
   * complex.
   */
  typedef std::complex<RealScalar> ComplexScalar;

The comment above it seems to suggest that if the type of the input matrix is complex then it should be the same type as the Scalar of the complex matrix.

Should that line be changed so that if the matrice's scalar type is complex then ComplexScalar is the same as Scalar, and else use std::complex?

using ComplexScalar = std::conditional_t<Eigen::is_complex<Scalar>, Scalar, std::complex<RealScalar>>;

In the above, Eigen::is_complex would check the scalars IsComplex enum value in NumTraits.

What is the current bug behavior?

After computing with ComplexEigenSolver the return type is Eigen::Matrix<std::complex> which then requires casting to a users custom scalar type.

What is the expected correct behavior?

If ComplexEigenSolver is given a matrix consisting of user defined complex types, then the eigenvalues etc should should be the custom scalar type.

  • Have a plan to fix this issue.
    • See above