Skip to content

GenEigsComplexShiftSolver compilation error; std::complex is being instantiated with std::complex<double>  #164

@dsl2501

Description

@dsl2501

I've encountered some compile errors while using the GenEigsComplexShiftSolver class in the Spectra library for complex eigenvalue analysis of complex matrices. The issues are as follows:

File: GenEigsComplexShiftSolver.h
Lines where the problem occurred: 81, 106, 107, 108, 116
Error: std::complex is being instantiated with std::complex types, which is recognized as an unsupported type according to the C++ standard.
It appears to me that the issue may be arising from certain parts of the complex matrix processing being handled as complex numbers when they should be treated as real numbers. In order to perform complex eigenvalue analysis for complex matrices, it might be necessary to correctly distinguish between real and complex numbers in these sections.

Here was the code I used and the error/warning messages in visual studio 2022 against success in building.

#include <Eigen/Core>
#include <Eigen/Dense>
#include <Spectra/GenEigsComplexShiftSolver.h>
#include <Spectra/MatOp/DenseGenComplexShiftSolve.h>
#include
#include

int main() {
const int size = 4096;
std::default_random_engine generator;
std::uniform_real_distribution distribution(0.0, 1.0);

Eigen::MatrixXcd A(size, size);
for (int i = 0; i < size; ++i) {
    for (int j = 0; j < size; ++j) {
        double realPart = distribution(generator);
        double imagPart = distribution(generator);
        A(i, j) = std::complex<double>(realPart, imagPart);
    }
}

Spectra::DenseGenComplexShiftSolve<std::complex<double>> op(A);
Spectra::GenEigsComplexShiftSolver<decltype(op)> eigs(op, 3, 6, 0.0, 0.0);

eigs.init();
int nconv = eigs.compute(Spectra::SortRule::LargestMagn); // SelectionRule 추가

if (eigs.info() == Spectra::CompInfo::Successful) { // 
    Eigen::VectorXcd evalues = eigs.eigenvalues();
    Eigen::MatrixXcd evectors = eigs.eigenvectors();

    std::cout << "Eigenvalues found:\n" << evalues << "\n";
    std::cout << "Eigenvectors found:\n" << evectors << "\n";
}
else {
    std::cout << "Eigenvalue computation failed." << std::endl;
}

return 0;

}

Error/warning messages

C2676 Binary '>': '_Ty' does not define this operator or a conversion to a type acceptable to the predefined operator.
\include\Spectra\GenEigsComplexShiftSolver.h Line: 116
C4996 'std::complex<std::complex>::complex': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. \include\Spectra\GenEigsComplexShiftSolver.h 81
C4996 'std::complex<std::complex>::complex': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. \include\Spectra\GenEigsComplexShiftSolver.h 106
C4996 'std::complex<std::complex>::complex': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. \include\Spectra\GenEigsComplexShiftSolver.h 107
C4996 'std::complex<std::complex>::complex': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. \include\Spectra\GenEigsComplexShiftSolver.h 108

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions