Matrix functions in the Advantage Pac
The matrix functionality isn't a standalone program, with a menu, like CFIT and PLY.
It's a collection of individual programs that can be used for many matrix tasks. Each one has to be called individually as needed.
There are many commands, the most used are those for
MATDIMMEDITCMEDITMINVTRNPSMDETM*MMSYS
To make things easier it's best to use the DM41X CST custom command shortcut mechanism.
Start with a blank CST and add the commands you need. Then save this CST so that it's easy to switch to other CST setups, and then return to the Matrix setup later.
I have the following
| A | MATDIM | I | |
| B | MEDIT | J | |
| C | CMEDIT | K | |
| D | MINV | L | |
| E | M*M | M | ZK?YN |
| F | MDET | N | EMDIR |
| G | TRNPS | O | EMDIRX |
| H | MSYS | P | PURFL |
Matrices are saved in Extended Memory, and I put commands in CST to find and remove them once I'm finished: EMDIR, EMDIRX and PURFL and I have ZK?YN to quickly access DM41X 41z Module complex number functions (assuming the module is plugged-in).
All matrix addressing is done via the ALPHA register
name of the matrix in the ALPHA register.A, B, C etc. - these will create the matrix in Extended MemoryX registerr.ccc with 3 decimal places for the column3×3 : 3.003 (3 rows, 3 columns)4×2 : 4.002 (4 rows, 2 columns)3.003X register ready for MATDIM to assign to the matrix named in ALPHAMATDIM command from the CST menu AA in extended memoryMEDIT from the CST menu B
For a 3×3 matrix
| 1 1 -1 |
| 4 6 6 |
| 1 8 9 |
1:1= 1R/S1:2= 1R/S1:3= 1CHSR/S2:1= 4R/S2:2= 6R/S2:3= 6R/S3:1= 1R/S3:2= 8R/S3:3= 9R/S
With A still in the ALPHA register use the MDET command from the CST menu F
-50.000A will now be in LU Decomposition form.normal form by Inverting twice using MINV from CST menu DMEDIT again, but just cycling through each with R/S and not changing any values08 which prevents any changes to values
Using M*M
For matrix multiplication you need 3 matrix definitions:
A and Matrix B are the two matrices to be multipliedA and Matrix B are dimensioned with MATDIM and populated with MEDITC is the matrix to hold the resultC is simply dimensioned with MATDIM and will be filled automatically by the function M*MTo multiply two matrices together they must have the correct dimensions
A must equal Rows in BC will have the dimensions Rows of A x Columns of BFollow the same procedure as above.
Make sure ALPHA has only the letter A
A different numerical example
A will be a 3×2 matrix
MATDIM via CST menu3.002 CSTA
| 2 3 |
| 4 5 |
| 7 6 |
MEDIT via CST menu1:1= 2R/S1:2= 3R/S2:1= 4R/S2:2= 5R/S3:1= 7R/S3:2= 6R/S
B will be a 2×2 matrix
Make sure ALPHA only has B and then dimension B with MATDIM from CST menu A
2.002 CSTA
| 2 3 |
| 4 5 |
* Use MEDIT via CST menu
1:1= 2R/S1:2= 3R/S2:1= 4R/S2:2= 5R/SWe now have defined the matrices to be multiplied together.
We need a results matrix C
The dimensions of C will be rows of A and columns of B which is 3 rows and 2 columns : 3.002
Make sure ALPHA only has C and dimension C with MATDIM from CST menu A
3.002 CSTA
That's enough to create the results matrix
ALPHA in the form Matrix 1,Matrix2,Results MatrixALPHA = A,B,CM*M from the CST menuC will now hold the answerC in the ALPHA register MEDIT from the CST menu and cycle through the elements (it's a 3×2 matrix)1:1= 16.000? R/S1:2= 21.000? R/S2:1= 28.000? R/S2:2= 37.000? R/S3:1= 38.000? R/S3:2= 51.000? R/S
The result in C is
| 16 21 |
| 28 37 |
| 38 51 |
A simple example first
3 unknowns
3x + 4y + 6z = 39.7
2x - 4y - 3z = -7.0
y + 8z = 63.4
| 3 4 6 |
| 2 -4 -3 |
| 0 1 8 |
3.003
| 39.7 |
| -7.0 |
| 63.4 |
3.001Simultaneous Equations represented in Matrix Form
|A| x |C| = |B|
| 3 4 6 | | x | | 39.7 |
| 2 -4 -3 | x | y | = | -7.0 |
| 0 1 8 | | z | | 63.4 |
3.003 CST A (MATDIM)MEDIT)1:1= 3 R/S1:2= 4 R/S1:3= 6 R/S2:1= 2 R/S2:2= 4 CHS R/S2:3= 3 CHS R/S3:1= 0R/S3:2= 1R/S3:3= 8R/S3.001 CST A (MATDIM)MEDIT)1:1= 39.7 R/S2:1= 7 CHS R/S3:1= 63.4 R/SA,B in ALPHAMSYS - the solution matrix for x, y and z will be placed in Matrix BB in ALPHAMEDIT from CST menuMEDIT) 1:1= 1.500 'R/S/2:1= -3.800 R/S3:1= 8.400 'R/S
x = 1.5
y = -3.8
z = 8.4
A is now in LU-decomposed formatA in ALPHAMINV via CST menu twiceA is now back to normal and can be inspected and edited by MEDIT via the CST menu
Instead of the MSYS function you could do it manually by entering Matrix A and Matrix B, and define Matrix C such that
A X C = B
C = B / A
C = A* X B where A* is Inverse A
Create Matrix C with dimensions 3.001 in the usual way then and do:
A in ALPHAA using MINV from CST menu (A is replaced by its inverse)A,B,C in ALPHAM*M B by the inverse of A which is effectively dividing B by the original AC now contains the solutions for x, y and zC in ALPHAC with MEDIT1:1= 1.500 R/S2:1= -3.800 R/S3:1= 8.400 R/sB unlike the MSYS method.A can be reversed by repeating MINV with A in ALPHAM*M on A and C to re-create BA,C,B in ALPHAM*M from CST menuB will be re-createdIt is possible to define, edit and carry out operations with matrices containing Complex Numbers.
The matrix is defined with twice as many rows and columns as appears necessary, and edited with the function CMEDIT, in CST menu C
| 1+j2 5+j6 |
| 3+j4 7+j8 |
Two rows and two columns 2×2 containing complex numbers, so the definition/dimension is 4.004
The numbers are actually saved as if in a larger real matrix as
| 1 -2 5 -6 |
| 2 1 6 5 |
| 3 -4 7 -8 |
| 4 3 8 7 |
The entry is via CMEDIT via CST menu C, which asks for each Real and Imaginary part in turn
4.004 CST ARE. 1:1= 1 R/SIM. 1:1= 2 R/SRE. 1:2= 5 R/SIM. 1:2= 6 R/SRE. 2:1= 3 R/SIM. 2:1= 4 R/SRE. 2:2= 7 R/SIM. 2:2= 8 R/SB of size 2×1 which can be multiplied by A as A x B
| 3+j4 |
| 2+j6 |
This is dimensioned as double the basic size of 2×1 : 4.002 and then populated with CMEDIT
4.002 CST ARE. 1:1= 3 R/SIM. 1:1= 4 R/SRE. 2:1= 2 R/SIM. 2:1= 6 R/S
Matrix 'C' which will be also be a 2×1 complex with dimension :4.002
4.002 CST ARE. 1:1= -31.000 R/SIM. 1:1= 52.000 R/SRE. 2:1= -41.000 R/SIM. 2:1= 82.000 R/SThe result matrix is therefore
| -31+j52 |
| -41+j82 |
Which agrees with my long-hand calculation (thanks to DM41X 41z Module )
|(1+j2).(3+j4) + (5+j6).(2+j6)|
|(3+J4).(3+J4) + (7+J8).(2+J6)|
| (-5+j10) + (-26+j42) |
| (-7+j24) + (-34+j58) |
| -31+j52 |
| -41+j82 |
Once you can enter and manipulate Complex Matrices you can also use MSYS to solve systems with complex matrices in the same way as usual - the only difference is entering the matrices as Complex.
After creating and manipulating (and some finger trouble) there will be a bunch of files in Extended Memory.
Most will be simple matrix definitions with obvious names A, B, C etc. but occasionally you'll accidentally have run MATDIM with some nonsense in the ALPHA register and created a nonsensical filename in extended memory, which it's tricky to spell out correctly in ALPHA in order to run PURLF - this is where EMDIRX comes in.
To simplify clearing up I include EMDIR, EMDIRX and PURFL in the CST menu.
Assuming you have other files in Extended Memory, the quickest way is to find the number of files in EM with EMDIR.
EMDIR from CST menuMATDIM - i.e. the first one after your other EM filesxEMDIRX from CST menuname of the specified-numbered file in ALPHA and means you don't have to type it in yourselfPURFL from CST menu to delete this filenameEMDIRX again (with the same number in X)X returns as non-zero we've found another junk-matrix file in EM and ALPHA will have its namePURFL againEMDIRX returns 0.00 in X which means there are no more files to delete