复杂稀疏矩阵A的犰狳eigs_symA,k

问题描述

要找到稀疏矩阵'A'的10个最小特征值,下面的最小代码效果很好:

g++ -std=c++17  -o test_sparse.o -c test_sparse.cpp
g++ -std=c++17  -o myapp test_sparse.o -larmadillo -larpack
#include <armadillo>
#include <iostream>
int main(){
    arma::SpMat<double> A = arma::sprandu(100,100,0.1) ;
    A = A.t()*A ;
    arma::dvec e = arma::eigs_sym(A,10,"sm") ;
    std::cout << e ; 
    return 0 ;
}

但是当我将A更改为复杂的稀疏矩阵时,例如:

#include <armadillo>
#include <iostream>
#include <complex>
int main(){
    arma::SpMat<arma::cx_double> A = arma::sprandu<arma::SpMat<arma::cx_double>>(100,1,"sm") ;
    std::cout << e ; 
    return 0 ;
}

使用相同的编译标志,出现以下不匹配的函数错误:

g++ -std=c++17  -o test_sparse.o -c test_sparse.cpp
test_sparse.cpp:8:43: error: no matching function for call to ‘eigs_sym(arma::SpMat<std::complex<double> >&,int,const char [3])’
    8 |     arma::dvec e = arma::eigs_sym(A,"sm") ;                    ^
make: *** [Makefile:47: test_sparse.o] Error 1

我从http://arma.sourceforge.net/docs.html#config_hpp知道

ARMA_USE_ARPACK启用ARPACK或ARPACK的高速替代品。 Armadillo需要ARPACK才能对复杂的稀疏矩阵进行本征分解。 eigs_gen(),eigs_sym()和svds()

所以我更改了config.hpp文件,这是我的config.hpp文件中的相应行:

#if !defined(ARMA_USE_NEWARP)
#define ARMA_USE_NEWARP
#endif
#if !defined(ARMA_USE_ARPACK)
#define ARMA_USE_ARPACK
#endif
#if !defined(ARMA_USE_SUPERLU)
#define ARMA_USE_SUPERLU
#endif

更多信息:我可以从gfortran运行arpack。

有什么主意怎么做? 谢谢您的提前帮助。

解决方法

这是库的固​​有限制。根据{{​​3}}(强调我的观点):

eigs_sym稀疏的特征值和特征向量的数量有限 对称 real 矩阵

eigs_gen个有限的特征值& 稀疏一般平方矩阵的特征向量

您应该使用documentation来处理复杂的矩阵。 或者,您应该将矩阵转换为密集矩阵,然后使用eigs_gen

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...