Ask Your Question
0

singular value decomposition

asked 2013-11-07 11:13:41 +0100

gundamlh gravatar image

updated 2013-11-07 11:14:05 +0100

I want to use SVD directly in Sage, is it possible?

from http://wiki.sagemath.org/interact/lin..., I know that, we can...

sage: from scipy import linalg

sage: U,s,Vh = linalg.svd(A) # A is a fixed matrix, e.g., A = [1, 2; 3, 4]

Thanks in advance!

edit retag flag offensive close merge delete

Comments

Can you explain what you mean by use SVD directly? The commands you mentioned is the way to use SVD. Is there any other way you wish to do it?

Shashank gravatar imageShashank ( 2013-11-07 12:55:13 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-11-07 14:20:56 +0100

tmonteil gravatar image

updated 2013-11-07 14:24:54 +0100

It depends on the ring of the matrix. For example, it works for matrices over CDF:

sage: M = matrix(CDF, [[1,2,3],[1,4,6]])
sage: M.SVD()
(
[-0.455252372951 -0.890362441325]
[-0.890362441325  0.455252372951],

[ 8.17345734477            0.0            0.0]
[           0.0 0.441129270439            0.0],

[   -0.164632267291    -0.986355015482 -2.81388521797e-16]
[   -0.547131320636    0.0913215509714    -0.832050294338]
[   -0.820696980953     0.136982326457     0.554700196225]
)

but not for matrices over QQ:

sage: M = matrix(QQ, [[1,2,3],[1,4,6]])
sage: M.SVD()
AttributeError: 'sage.matrix.matrix_rational_dense.Matrix_rational_dense' object has no attribute 'SVD'

So, the method .SVD() is not implemented for every kind of matrices.

edit flag offensive delete link more

Comments

.SVD() works for CDF and RDF. Thanks!

gundamlh gravatar imagegundamlh ( 2013-11-08 08:19:42 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-11-07 11:13:41 +0100

Seen: 5,075 times

Last updated: Nov 07 '13