06-04-2015, 05:10 PM (This post was last modified: 06-05-2015 09:52 AM by salvomic.)
Post: #21
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
(06-04-2015 04:57 PM)Werner Wrote:  ...
Crout factorisation alternatingly computes a row and a column...
Cheers, Werner

hi Werner,
both methods have goods and issues...
Maybe Parisse and Tim could tell us more about the Prime and LU...

However for matrices operations perhaps it could be better to have also some little commands or helps, like a command to extract pivots, to get cofactors, adjoint, minors, and also factorizations LDU (LDV) and LDLt. As they are missing, I'm trying to make some programs, but for pivots I'm getting these troubles...
Some other calculators have those commands, if I well remember (i.e., TI 89/Voyage had adj / cofactor function)...
For example I use a lot a little program to get minor of a matrix:
Code:
 #cas  matrixminor(m,r,c):= BEGIN   m:= delrows(m,r);   m:= delcols(m,c); END; #end
Simple but useful, it helps to don't use delrows() and delcols() more and more. It's alternative to the subMat() command (syntax: subMat(m, r1, c1, r2,c2), and perhaps more short

I made a program to calculate Cofactor matrix and adjoint matrix (see here)...

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
06-05-2015, 08:15 PM
Post: #22
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
Given the permutation matrix (by LU), like [1,3,2] is there a way to obtain the actual permutation matrix (like P21 = [[0,1,0], [1,0,0], [0,0,1]] ?
I need to make a routine with that matrix for the program to calculate LDU factorization as, sometime, L*D*U returns the matrix A with some swap of rows (indicated by the permutation matrix by LU).

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
06-05-2015, 08:38 PM
Post: #23
 Claudio L. Senior Member Posts: 1,840 Joined: Dec 2013
(06-05-2015 08:15 PM)salvomic Wrote:  Given the permutation matrix (by LU), like [1,3,2] is there a way to obtain the actual permutation matrix (like P21 = [[0,1,0], [1,0,0], [0,0,1]] ?
I need to make a routine with that matrix for the program to calculate LDU factorization as, sometime, L*D*U returns the matrix A with some swap of rows (indicated by the permutation matrix by LU).

Salvo

To get the permutation matrix, simply create an NxN matrix with all zeros, and for each row, take a number off the list, and put a 1 in the corresponding column.
For example:
[ 1 , 3 , 2 ] --> Put a 1 in the 1st column on row 1, on row 2 put it in the 3rd column, and on the 3rd row put it in the 2nd column.
You'll get [[ 1 0 0 ] [0 0 1] [0 1 0]], which is what you are looking for.
06-05-2015, 09:00 PM
Post: #24
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
(06-05-2015 08:38 PM)Claudio L. Wrote:  To get the permutation matrix, simply create an NxN matrix with all zeros, and for each row, take a number off the list, and put a 1 in the corresponding column.
For example:
[ 1 , 3 , 2 ] --> Put a 1 in the 1st column on row 1, on row 2 put it in the 3rd column, and on the 3rd row put it in the 2nd column.
You'll get [[ 1 0 0 ] [0 0 1] [0 1 0]], which is what you are looking for.

thank you Claudio!

something like this?
Code:
 EXPORT permMatrix(lst) // given a permutation list (like {1,3,2}) and the matrix dimension, returns a permutation matrix BEGIN local j, k, mat, dimen; dimen:= length(lst); mat:= MAKEMAT(0, dimen, dimen); FOR j FROM 1 TO dimen DO mat(j,lst(j)):= 1; END; // for RETURN mat; END;

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
06-07-2015, 06:42 PM
Post: #25
 parisse Senior Member Posts: 1,222 Joined: Dec 2013
(06-05-2015 08:15 PM)salvomic Wrote:  Given the permutation matrix (by LU), like [1,3,2] is there a way to obtain the actual permutation matrix (like P21 = [[0,1,0], [1,0,0], [0,0,1]] ?
permu2mat in Xcas, not available on the Prime.
06-07-2015, 07:20 PM
Post: #26
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
(06-07-2015 06:42 PM)parisse Wrote:  permu2mat in Xcas, not available on the Prime.

thank you, Parisse, I hope this command could be included in the Prime in a next firmware also

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
06-08-2015, 01:12 PM (This post was last modified: 06-08-2015 01:16 PM by Claudio L..)
Post: #27
 Claudio L. Senior Member Posts: 1,840 Joined: Dec 2013
(06-05-2015 09:00 PM)salvomic Wrote:  something like this?
Code:
 EXPORT permMatrix(lst) // given a permutation list (like {1,3,2}) and the matrix dimension, returns a permutation matrix BEGIN local j, k, mat, dimen; dimen:= length(lst); mat:= MAKEMAT(0, dimen, dimen); FOR j FROM 1 TO dimen DO mat(j,lst(j)):= 1; END; // for RETURN mat; END;

I don't have a Prime but looks correct to me, you can test easily that permMatrix(P)*A will swap the rows in any matrix A to the order you specified in the vector P.
EDIT: I mean correct in the algorithm, I think your function is missing the size as argument?: permMatrix(P,3)
EDIT AGAIN: Nevermind... I was misled by your comment in the code, but you fot the size automatically.
06-08-2015, 01:15 PM
Post: #28
 salvomic Senior Member Posts: 1,394 Joined: Jan 2015
(06-08-2015 01:12 PM)Claudio L. Wrote:  I don't have a Prime but looks correct to me, you can test easily that permMatrix(P)*A will swap the rows in any matrix A to the order you specified in the vector P.
EDIT: I mean correct in the algorithm, I think your function is missing the size as argument?: permMatrix(P,3)

it seems to be good, almost for the 10-20 matrices I tried
thanks!

Salvo

∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib
 « Next Oldest | Next Newest »