Need suggestion about long matrix program
03-26-2021, 08:11 PM (This post was last modified: 03-26-2021 08:11 PM by Amer7.)
Post: #1
 Amer7 Junior Member Posts: 22 Joined: Dec 2020
Need suggestion about long matrix program
Hi,
I'm not sure what would be the best idea to make this program.

1.) Start i will always have three matrices witch size may vary from issue to issue.
I plan on using the calculator M1, M2, M3 matrix variables
2.) The rest of matrices M4,M5,M6,M7,M8, M9, A1, A2, A3, A4, A5, A6, A7 are different
calculations of matrices M1,M2,M3,M5... etc.
3.) Is there a way that I input into calculator memory M1, M2, M3 matrices, and run the program then have the program save all of the Matrices in Variables M4....A7 so I could view them.
( Because In past I have used the PRINT for Matrix and it's not really good for displaying them. The calculator option of displaying matrix in HOME is excellent for me).

This would be some operations between the matrices
Code:
/// A -M1 P-M2 W-M3 //N matrica M4 M4:=TRN(M1)*M2*M1; //u matrica M5 M5:=TRN(M1)*M2*M3; //QX M6 M6:=INV(M5); //M7 delta M7:=(-M6)*M5; /// M8 matrica V M8:=(M1*M7)+M3; //M9 omega M9:=TRN(M8)*M2*M8; //M0 vf M0:=(1/5)*M9; //S0 A1 A1:=SQRT(M0); //CX A2; A2:=M6*M0; //A3 CL A3:=M0*M2-1; //QL kappa  A4; A4:=M1*M6*TRN(M1); //CL Kapa A5 A5:=A4*M0; //QV A6 A6:=INV(M2)+(-A4); //CV A7; A7:=A6*M0;

Any help is really appreciated.
03-26-2021, 10:02 PM
Post: #2
 roadrunner Senior Member Posts: 359 Joined: Jun 2015
RE: Need suggestion about long matrix program
Are you looking for something like the EDITMAT() command?

EXPORT matrixdata()
BEGIN
EDITMAT(M1);
EDITMAT(M2);
EDITMAT(M3);
END;

03-27-2021, 04:39 AM
Post: #3
 rawi Member Posts: 74 Joined: Nov 2019
RE: Need suggestion about long matrix program
Hi Amer,
matrices M0 to M9 always are not local to a program (its the same with lists L0 to L9). That is you just put them in the computer outside of the program, you use them in the program as defined variables without defining them in the program, you modify them in the program and after the program ends you will have them as results and can look on them. So I think this is rather convenient.
I used this extensively for instance in the following thread:

Best Raimund
03-27-2021, 05:29 PM (This post was last modified: 03-27-2021 05:41 PM by Amer7.)
Post: #4
 Amer7 Junior Member Posts: 22 Joined: Dec 2020
RE: Need suggestion about long matrix program
I don't understand the code for these "clusters", i just want something simple.
No, I just want to utilize the HP primes stored M1, M2, M3 variables
Why - because from problem to problem the dimensions of the M1,M2,M3 matrix can change.

I want program to utilize M1, M2, M3 - matrices, products of program calculations will be new matrices M4,M5....A1...A7.
And I want to store these in calculator variables because I could view them. ( these will be large matrices with 9 decimal numbers, and print option is awful.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Can someone just tell me how to make this program.
M1 - Matrix that I input in ( Shift Matrix menu)
M2- Matrix that I input in ( Shift Matrix menu)
//// Program
When I run the program I want it to do Transpose M1*M2*TransposeM1 - And save it in user variable A1

So when the program finishes I press button VARS-USER And i get the matrix A1 with its values.
03-27-2021, 06:14 PM
Post: #5
 Didier Lachieze Senior Member Posts: 1,365 Joined: Dec 2013
RE: Need suggestion about long matrix program
(03-27-2021 05:29 PM)Amer7 Wrote:  I want program to utilize M1, M2, M3 - matrices, products of program calculations will be new matrices M4,M5....A1...A7.
And I want to store these in calculator variables because I could view them. ( these will be large matrices with 9 decimal numbers, and print option is awful.

The variables M1 to M9 are predefined as global matrix variables so you can use them as you want.
To have A1 to A7 defined as global matrix variables that you can view in the matrix editor you have to declare them before the beginning and outside of your program with:

EXPORT A1,A2,A3,A4,A5,A6,A7;

For example:
Code:
#pragma mode( separator(.,;) integer(h32) ) EXPORT A1,A2,A3,A4,A5,A6,A7; EXPORT TST() BEGIN  A1:=[[1,2],[3,4]]; END;

After executing TST() you'll find A1 in the matrix editor.
03-28-2021, 05:05 PM (This post was last modified: 03-28-2021 05:22 PM by Amer7.)
Post: #6
 Amer7 Junior Member Posts: 22 Joined: Dec 2020
RE: Need suggestion about long matrix program
(03-27-2021 06:14 PM)Didier Lachieze Wrote:
(03-27-2021 05:29 PM)Amer7 Wrote:  I want program to utilize M1, M2, M3 - matrices, products of program calculations will be new matrices M4,M5....A1...A7.
And I want to store these in calculator variables because I could view them. ( these will be large matrices with 9 decimal numbers, and print option is awful.

The variables M1 to M9 are predefined as global matrix variables so you can use them as you want.
To have A1 to A7 defined as global matrix variables that you can view in the matrix editor you have to declare them before the beginning and outside of your program with:

EXPORT A1,A2,A3,A4,A5,A6,A7;

For example:
Code:
#pragma mode( separator(.,;) integer(h32) ) EXPORT A1,A2,A3,A4,A5,A6,A7; EXPORT TST() BEGIN  A1:=[[1,2],[3,4]]; END;

After executing TST() you'll find A1 in the matrix editor.

When I try to run that i get syntax error, and when I try to run
Code:
 EXPORT A1; A1:=M0+M1; EXPORT TST(); I get Syntax Error at EXPORT

03-29-2021, 06:39 PM (This post was last modified: 03-29-2021 07:01 PM by Amer7.)
Post: #7
 Amer7 Junior Member Posts: 22 Joined: Dec 2020
RE: Need suggestion about long matrix program
@Didier Lachieze your program text worked for export, i just didn't know how to c/p hahah. But I don't know the values of matrix" A1:=[[1,2],[3,4]];" matrix A1 should be a calculation of a know Matrix M1..M2.. which values are stored in calculator variables.
This seems to work for export
Code:
 //PROGRAM START EXPORT A1,A2; EXPORT function1 () BEGIN A1:=M1+M1; A2:=M1-M1; END;

But it doesn't import values stored in M1 memory of calculator into the program sto the output variable A1 is 0, and A2 is also 0

Is there a simple code that will let me Use the values stored in M1,M2,M3 matrix memory, and when I execute the program let me see the new matrices values for viewing ?
03-29-2021, 07:02 PM
Post: #8
 Didier Lachieze Senior Member Posts: 1,365 Joined: Dec 2013
RE: Need suggestion about long matrix program
(03-29-2021 06:39 PM)Amer7 Wrote:  Is there a simple code that will let me Use the values stored in M1,M2,M3 matrix memory, and when I execute the program let me see the new matrices values for viewing ?

Your program works for me and does exactly that.
With M1 being [[1,−3],[−1,1],[2,−2]], after executing function1 I get for A1: [[2,−6],[−2,2],[4,−4]] and for A2: [[0,0],[0,0],[0,0]]

However one thing that can explain that you have 0 for A1 and for A2 is if you have the spreadsheet app active, in this case when you type A1 or A2 on the command line you're referring to the A1 and A2 cells of the spreadsheet, not to your global variables which should anyway be available in the Matrix editor.
03-29-2021, 07:27 PM
Post: #9
 Amer7 Junior Member Posts: 22 Joined: Dec 2020
RE: Need suggestion about long matrix program
(03-29-2021 07:02 PM)Didier Lachieze Wrote:
(03-29-2021 06:39 PM)Amer7 Wrote:  Is there a simple code that will let me Use the values stored in M1,M2,M3 matrix memory, and when I execute the program let me see the new matrices values for viewing ?

Your program works for me and does exactly that.
With M1 being [[1,−3],[−1,1],[2,−2]], after executing function1 I get for A1: [[2,−6],[−2,2],[4,−4]] and for A2: [[0,0],[0,0],[0,0]]

However one thing that can explain that you have 0 for A1 and for A2 is if you have the spreadsheet app active, in this case when you type A1 or A2 on the command line you're referring to the A1 and A2 cells of the spreadsheet, not to your global variables which should anyway be available in the Matrix editor.

Thank you, I've tested on a calculator and it works.
What is your view, how would you solve this program.
Is there any trick to print Matrices in Terminal an them staying the same style like when we view them in home screen?
Would like to label to each one, so I dont have to write on paper A1 - Standard deviation matrix... etc...
04-01-2021, 04:47 PM
Post: #10
 BERNARD MICHAUD Member Posts: 141 Joined: Aug 2015
RE: Need suggestion about long matrix program
Try M3:=M1+M2 M3:=M1*M2
As far as I know you cannot store a Matrix in a Variable like A or A1 etc
A Matrix can only be stored into another Matrix.
04-01-2021, 06:04 PM
Post: #11
 toml_12953 Senior Member Posts: 1,736 Joined: Dec 2013
RE: Need suggestion about long matrix program
(04-01-2021 04:47 PM)BERNARD MICHAUD Wrote:  Try M3:=M1+M2 M3:=M1*M2
As far as I know you cannot store a Matrix in a Variable like A or A1 etc
A Matrix can only be stored into another Matrix.

Other than in Matrix variables, you can only store matrices in LOCAL variables.

Tom L
Cui bono?
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)