Ask Your Question
0

How to find a generalized inverse of a vector in sagemath?

asked 2016-10-25 19:31:14 +0100

daviddgl gravatar image

Given a vector $u$ of size $n\times 1 $. How to find the g-inverse of $u$?

Is there any specific command like

u.ginv()

to find the ginverse or we have define it?? If so, how to do that?

Any hint will help me lot.

Defn:

for a vector $u_{n\times 1} $ a vector $v_{1\times n}$ is said to be generalized inverse of $u$ if $$uvu=u.$$

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-10-26 02:41:33 +0100

This is sufficient for vectors:

V = matrix(4,1,[1,2,2,1])
V.transpose() / V.norm()^2
edit flag offensive delete link more
0

answered 2016-10-26 00:22:41 +0100

ndomes gravatar image

Scipy provides methods to calculate a generalized inverse (linalg.pinv , linalg.pinv2, linalg.pinvh)

from scipy import linalg
M = matrix(4,1,(1,2,2,1))
matrix(linalg.pinv2(M))
edit flag offensive delete link more

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: 2016-10-25 19:31:14 +0100

Seen: 1,104 times

Last updated: Oct 26 '16