Search code examples
rmatrixsparse-matrix

AMD(approximate minimum degree) algorithm in R


In matlab P = amd(A) returns the approximate minimum degree permutation vector for the sparse matrix A, in R does we have the same command?


Solution

  • Try the chol function in the Matrix package... not sure if this is exactly what you are looking for, but it's from the documentation for that package (" Returns (and stores) the Cholesky decomposition of x. If pivot is true, the Approximate Minimal Degree (AMD) algorithm is used to create a reordering of the rows and columns of x so as to reduce fill-in.")

    > library(Matrix)
    > M2 <- toeplitz(as(c(1,.5, rep(0,12), -.1), "sparseVector"))
    > C2 <- chol(M2, pivot=TRUE)
    > C2
    15 x 15 sparse Matrix of class "dtCMatrix"
    
    
     [1,] 1 0.5000000 .         .         .         .         .         .         .        
     [2,] . 0.8660254 0.5773503 .         .         .         .         .         .        
     [3,] . .         0.8164966 0.6123724 .         .         .         .         .        
     [4,] . .         .         0.7905694 0.6324555 .         .         .         .        
     [5,] . .         .         .         0.7745967 0.6454972 .         .         .        
     [6,] . .         .         .         .         0.7637626 0.6546537 .         .