Skip to content

Instantly share code, notes, and snippets.

@Adenilson
Created October 30, 2014 17:20
Show Gist options
  • Save Adenilson/96354ee274d2864cdcae to your computer and use it in GitHub Desktop.
Save Adenilson/96354ee274d2864cdcae to your computer and use it in GitHub Desktop.
M = matrix(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1), ncol=4, nrow=9)
a = M
a.svd = svd(a)
ds = diag(1/a.svd$d[1:3])
u = a.svd$u
v = a.svd$v
us = as.matrix(u[, 1:3])
vs = as.matrix(v[, 1:3])
svd_inverse = (a.ginv = vs %*% ds %*% t(us))
gen_inv = ginv(M)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment