cancel
Showing results for 
Search instead for 
Did you mean: 

Note on archived topics.

This topic has been archived. Information and links in this thread may no longer be available or relevant.
If you have a question create a new topic by clicking here and select the appropriate board.
gustavrsh
New member
2 0 0 0
Message 1 of 3
485
Flag Post
HP Recommended

HP Prime - Assigning to variables from a function that returns many values

Title says it all.

I'm new into programming the HP Prime and I need to assign like this:

EXPORT ANANUMLU(A)
BEGIN
LOCAL L, U, P;
LU(A)▶//Assign respectively to L, U and P;
PRINT L;
END;

LU(A) Receives a matrix and return three matrices.

 

Thanks in advance.

0 Kudos
2 REPLIES 2
Level 9
3,551 3,490 180 535
Message 2 of 3
463
Flag Post
HP Recommended

HP Prime - Assigning to variables from a function that returns many values

Hi!, gustavrsh:

 

Welcome, to Forum !.

 

LU - Decomposition. Factorizes a square matrix, into three matrices L, U, and P, where {[L[lowertriangular]],[U[uppertriangular]],[P[permutation]] }} and P*A=L*U. LU(matrix)

 

Example:

 

EXPORT ANANUMLU()
 BEGIN 
 M4:=[[3,6,−1,2],[-3,-2,12,0],[1,4,0,2]];  // Your matrix
 M5:=diag(M4); // This is a Diagonal Matrix
 RETURN M5; 
END;

 

UNANUMLU_1.pngUNANUMLU.png

 


  

 

 

 

Kind Regards !.
Have a nice day !.
@Maké (Technical Advisor Premium - HP Program Top Contributor).
Provost in HP Spanish Public Forum ... https://h30467.www3.hp.com/
0 Kudos
Fortin
Level 4
127 110 14 18
Message 3 of 3
447
Flag Post
HP Recommended

HP Prime - Assigning to variables from a function that returns many values

LU(A) returns a list where each element is a matrix.  One way to access this is to use a temporary list (L1 in the example below):

 

L1:=LU(A)

 

// M1 is L, M2 is U, and M3 is P

 

M1:=L1(1)

M2:=L1(2) 

M3:=L1(3)

 

 

 

0 Kudos

Note on archived topics.

This topic has been archived. Information and links in this thread may no longer be available or relevant.
If you have a question create a new topic by clicking here and select the appropriate board.
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation