Ask Your Question
0

Is it possible to write down matrix with variable row.

asked 2018-01-20 07:52:53 +0100

debargha gravatar image

updated 2023-05-19 22:09:55 +0100

FrédéricC gravatar image

I wish to find out Moore Penrose psudo inverse of a matrix with variable row $4 \times k$ matrix with $k \in \mathbb{N}$ with entries a function of k. Is it possible to write down in SAGE?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-01-20 08:30:25 +0100

Emmanuel Charpentier gravatar image

Unless I'm misunderstanding your question (which is a bit ambiguous what does mean "with entries a function of k" ?), this should do :

sage: def myfunc(k): return floor(k*random())
sage: def make_4xk_matrix(k):
....:     return matrix(ZZ,[[myfunc(k) for t in (1..k)] for l in (1..4)])
....: 
sage: make_4xk_matrix(6)
[1 5 3 3 4 3]
[5 2 3 3 2 3]
[2 3 1 3 3 3]
[0 2 3 2 1 5]

Note that the entries belong to $\mathbb{Z}$ : $\mathbb{N}$ is not a ring and Sage's matrix refuses it.

edit flag offensive delete link more

Comments

Then,

sage: L = [0, 4, 4, 1, 5, 1, 3, 1, 3, 2, 2, 1, 0, 5, 3, 3, 3, 2, 3, 3, 1, 0, 5, 2]
sage: M = matrix(4, L)
sage: M
[0 4 4 1 5 1]
[3 1 3 2 2 1]
[0 5 3 3 3 2]
[3 3 1 0 5 2]
sage: M.pseudoinverse()
[-15573/108749  18903/108749  -3411/108749  12744/108749]
[ -7882/108749 -13917/108749  19684/108749   6513/108749]
[ 22998/108749  18697/108749 -11848/108749 -19721/108749]
[-15071/108749  11925/108749  19094/108749  -7925/108749]
[ 15869/108749  -5687/108749 -12781/108749  10163/108749]
[-15989/108749  -2610/108749  13467/108749   9942/108749]
Sébastien gravatar imageSébastien ( 2018-01-20 16:00:40 +0100 )edit

Sebastien : and your question is ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2018-01-20 17:33:32 +0100 )edit

I did not ask any question. I am just showing how the Moore Penrose Pseudo inverse can be obtained in Sage, which was the question.

Sébastien gravatar imageSébastien ( 2018-01-21 22:21:11 +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: 2018-01-20 07:52:53 +0100

Seen: 600 times

Last updated: Jan 20 '18