Skip to content

Instantly share code, notes, and snippets.

@tony91782
Created July 18, 2011 12:47
Show Gist options
  • Save tony91782/1089413 to your computer and use it in GitHub Desktop.
Save tony91782/1089413 to your computer and use it in GitHub Desktop.
A Better Way to Compute All Diagonal Principal Minors
library(gregmisc)
minor2 = function(mat, idx){
little_mat = mat[idx,idx]
return(det(little_mat))
}
index_vec = combinations(nrow(mat),2)
minors = apply(index_vec, MARGIN=1, FUN=function(ix){ minor2(mat,ix)})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment