yixuan / spectra

A header-only C++ library for large scale eigenvalue problems
https://spectralib.org
Mozilla Public License 2.0
745 stars 131 forks source link

compilation issues with the 'Spectra::SymEigsSolver' constructor. The error message is... #157

Closed dsl2501 closed 1 year ago

dsl2501 commented 1 year ago

I'm currently using the Spectra library to solve sparse non-symmetric matrices in my C++ project. However, I'm running into compilation issues with the 'Spectra::SymEigsSolver' constructor. The error message I'm receiving is as follows:

Error C2665 'Spectra::SymEigsSolver<Spectra::SparseSymMatProd<double,1,0,int>>::SymEigsSolver': no overloaded function takes all the argument types. Project Path: C:\Users\user\Desktop\DSL2022\SparseEigen\SparseEigen.cpp Warning C4244 'initializing': conversion from 'Spectra::SymEigsBase<OpType,Spectra::IdentityBOp>::Index' to 'int', possible loss of data. Project Path: C:\Users\user\Desktop\DSL2022\SparseEigen\SparseEigen.cpp

It seems that there is no matching constructor for Spectra::SymEigsSolver::SymEigsSolver with OpType being Spectra::SparseSymMatProd<double, 1, 0, int>. Also, I'm getting a warning that there might be possible loss of data when initializing some variable, converting from type 'Spectra::SymEigsBase<OpType,Spectra::IdentityBOp>::Index' to 'int'. I'd appreciate if you could provide me with some insights on how to resolve this issue.

Thank you for advice in advance.

BangShiuh commented 1 year ago

What is your code? You should read the documentation [https://spectralib.org/doc/classspectra_1_1symeigssolver#a469d37e08be076e198c9e383236c5056] to make sure your implementation is correct. As for the warning, you might try using Use Eigen::Index instead of int.

dsl2501 commented 1 year ago

Compilation issues contained many problems which is now solved. Among them, interestingly, UTF-8 storage of the code was one of them on Visual Studio, and we could go forward with your comment regarding Eigen::Index instead of int. Thanks a lot. Now I have further questions which will be explained in a 'new issue' window.