Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dsl2501 opened this issue Aug 19, 2023 · 3 comments

Comments

@dsl2501
Copy link

dsl2501 commented Aug 19, 2023

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

@yixuan
Copy link
Owner

yixuan commented Aug 19, 2023

Hi @dsl2501, currently Spectra does not support complex-valued matrices. The GenEigsComplexShiftSolver solver uses a complex-valued shift, but the matrix itself is real-valued.

@dsl2501
Copy link
Author

dsl2501 commented Aug 19, 2023

Yes, thank you for immediate notice.

I was trying to follow the Hermitian matrix job, Krylov-Schur Solver, by dotnotlock of 2021 Oct. After reviewing his approach in closed session #130 and files and lines of #132, I am aware of no completion of that job (symmetric complex-valued sparse Hermitian matrix) too.
As I am keenly interested in non-Hermitian sparse matrix exgendecomposition for the larger eigenvalues with huge matrices, I
wishes best for your and this community's implementation of this issue.

Thanks a lot and all the best.

@yixuan
Copy link
Owner

yixuan commented Aug 19, 2023

Spectra will consider complex-valued matrices in the future, but for now you can always use ARPACK as an existing solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants