How expensive is it to compute the eigenvalues of a matrix?

后端 未结 8 947
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 22:51

How expensive is it to compute the eigenvalues of a matrix?

What is the complexity of the best algorithms?

How long might it take in practice if I have a 1

相关标签:
8条回答
  • 2020-12-07 23:30

    You can use the GuessCompx package from CRAN to estimate the empirical complexity of your eigenvalues computation and predict the full running time (although it's still small in your example). You need a little helper function because the fitting process only subsets the rows, so you must make the matrix square:

    library(GuessCompx)
    m = matrix(rnorm(1e6), ncol=1000, nrow=1000)
    # custom function  to subset the increasing-size matrix to a square one:
    eigen. = function(m) eigen(as.matrix(m[, 1:nrow(m)]))
    CompEst(m, eigen.)
    #### $`TIME COMPLEXITY RESULTS`
    #### $`TIME COMPLEXITY RESULTS`$best.model
    #### [1] "CUBIC"
    #### $`TIME COMPLEXITY RESULTS`$computation.time.on.full.dataset
    #### [1] "5.23S"
    #### $`TIME COMPLEXITY RESULTS`$p.value.model.significance
    #### [1] 1.784406e-34
    

    You get a cubic complexity for time, and a Nlog(N) complexity for memory usage of the R base eigen() function. It takes 5.2 secs and 37Mb to run the whole computation.

    0 讨论(0)
  • 2020-12-07 23:30

    It uses the QR algo. See Wilkinson, J. H. (1965) The Algebraic Eigenvalue Problem. Clarendon Press, Oxford. It does not exploit sparsity.

    0 讨论(0)
提交回复
热议问题