eigs MATLAB到R语言(复杂矩阵)

时间:2016-11-14 09:54:50

标签: r matlab

在R语言(RSpectra / rARPACK库)中,您可以找到一个函数 eigs() - 类似于MATLAB eigs() - 但不能在输入中运行复杂矩阵。我在哪里可以找到一个函数eigs()完全对应于带有广义选项的MATLAB?

> set.seed(123)  
> n = 100     # matrix size  
> k = 5       # number of eigenvalues to calculate  
> M = matrix(rnorm(n^2), n)  
> A = crossprod(M)      # Make it symmetric  
>   
> library(RSpectra)  
> res = eigs(A, k)   
> res$values  
[1] 391 367 354 323 315  
> head(res$vectors)  
        [,1]     [,2]      [,3]     [,4]    [,5]  
[1,] -0.1298  0.01131 -0.000102  0.08849  0.0504  
[2,]  0.0669 -0.00101  0.010345 -0.00941 -0.0799  
[3,]  0.0533  0.05726  0.099891 -0.17171  0.0133  
[4,] -0.1342  0.16530  0.007646 -0.00679  0.1025  
[5,]  0.1302  0.01915  0.042567 -0.16027 -0.0625  
[6,]  0.0663  0.05346  0.032320 -0.07483 -0.1637  
> A=as.complex(A)  
> res = eigs(A, k)   
Error in UseMethod("eigs") :   
  no applicable method for 'eigs' applied to an object of class "complex"  

0 个答案:

没有答案