Matrix Example test 0b, Function tests

Description

GSB 0 runs whole program.
This program uses 1 as a random number seed so the same results are always obtained.
GSB 1 to 9 allows separate subroutines to be repeated for testing.

Tests MATRIX 0 to MATRIX 9 functions.
Scalar operations 2x, 1-, 2+ and 10/.
Matrix multiplication and division.

Results:
[A] contains [A] which is the intitial matrix containing random numbers in the range from 0 to 20.
[B] contains the result of the scalar operations, above, on [A].
[C] contains the LU from RCL MATRIX C, f MATRIX 9 on [C]. Running GSB 5 after GSB 0, [C] now contains the result from f MATRIX 5.
[D] contains the result from [A]x[B].
[E] contains the result from [A]/[A], which should be the identity matrix.

To read matrix [A] elements again, press GSB A.
To read matrix [B] elements again, press GSB B.
To read matrix [C] elements again, press GSB C.
To read matrix [D] elements again, press GSB D.
To read matrix [E] elements again, press GSB E.

R7 contains the result from f MATRIX 7 on [B].
R8 contains the result from f MATRIX 8 on [B].
R9 contains the result from f MATRIX 9 on [C].

Subroutines 1 to 9 can be run, some independently, to troubleshoot particular issues.

Matrix [A] should be square and the number of rows even. f MATRIX 2 and f MATRIX 3 will produce error 11 if the number of rows is odd.

USER mode during programming allows indexed STO and RCL of matrix elements. The f MATRIX 0 statement is also essential.
Once the STO and RCL loops reach the dimensioned size of the matrix the GOTO statement is skipped and the next part of the program runs.

Program Resources

Labels

Name Description Name Description Name Description
 A Read elements in [A]  2 GSB 1 Dimension [A], enter random elements into [A]  9 GSB 8 [C] f MATRIX 9, LU in [C] result stored in R9
 B Read elements in [B]  3 GSB 2 f MATRIX 2, 3, 4, 4 operations on [A] which is unchanged .1 RCL elements from [A] loop
 C Read elements in [C]  4 GSB 3 ((( [A]x2)-1)+2)/10 = [B] Scalar operations .2 RCL elements from [B] loop
 D Read elements in [D]  5 GSB 4 f MATRIX 5 operation on [A], [B] to create [C] .3 RCL elements from [C] loop
 E Read elements in [E]  6 GSB 5 Matrix multiplication [C]x[C] = [D] .4 RCL elements from [D] loop
 0 GSB 0 run program  7 GSB 6 Matrix division [C]/[C] = identity matrix .5 RCL elements from [E] loop
 1 CF8, Initialise matrices, enter default 4x4 matrix [A] dimensions  8 GSB 7 [B] f MATRIX 7, f MATRIX 8 results stored in R7 and R8 .6 Load random elements into [A] loop

Storage Registers

Name Description
 7 Contains the result from f MATRIX 7 on [B]
 8 Contains the result from f MATRIX 8 on [B]
 9 Contains the result from f MATRIX 9 on [C]

Flags

Number Description
8 gCF8 Clear complex number flag

Program

Line Display Key Sequence Line Display Key Sequence Line Display Key Sequence
000 049 42,26,12 f RESULT B 098 42 31 f PSE
001 42,21, 0 f LBL 0 050 45,16,11 RCL MATRIX A 099 42,16, 8 f MATRIX 8
002 1 1 051 2 2 100 44 8 STO 8
003 44 36 STO RAN # 052 20 × 101 42 31 f PSE
004 32 1 GSB 1 053 1 1 102 43 32 g RTN
005 32 2 GSB 2 054 30 103 42,21, 9 f LBL 9
006 32 3 GSB 3 055 2 2 104 42,26,13 f RESULT C
007 32 4 GSB 4 056 40 + 105 45,16,13 RCL MATRIX C
008 32 5 GSB 5 057 1 1 106 42 31 f PSE
009 32 6 GSB 6 058 0 0 107 42,16, 9 f MATRIX 9
010 32 7 GSB 7 059 10 ÷ 108 44 9 STO 9
011 32 8 GSB 8 060 45,16,12 RCL MATRIX B 109 43 32 g RTN
012 32 9 GSB 9 061 32 12 GSB B 110 42,21,11 f LBL A
013 43 32 g RTN 062 42 31 f PSE 111 42,16, 1 f MATRIX 1
014 42,21, 1 f LBL 1 063 43 32 g RTN 112 42,21, .1 f LBL . 1
015 43, 5, 8 g CF 8 064 42,21, 5 f LBL 5 113 42 31 f PSE
016 42,16, 0 f MATRIX 0 065 42,26,13 f RESULT C 114 u 45 11 USER RCL A
017 4 4 066 45,16,11 RCL MATRIX A 115 22 .1 GTO . 1
018 42 31 f PSE 067 45,16,12 RCL MATRIX B 116 43 32 g RTN
019 36 ENTER 068 42,16, 5 f MATRIX 5 117 42,21,12 f LBL B
020 4 4 069 45,16,13 RCL MATRIX C 118 42,16, 1 f MATRIX 1
021 43 32 g RTN 070 32 13 GSB C 119 42,21, .2 f LBL . 2
022 42,21, 2 f LBL 2 071 42 31 f PSE 120 42 31 f PSE
023 42,23,11 f DIM A 072 43 32 g RTN 121 u 45 12 USER RCL B
024 42,16, 1 f MATRIX 1 073 42,21, 6 f LBL 6 122 22 .2 GTO . 2
025 45,16,11 RCL MATRIX A 074 42,26,14 f RESULT D 123 43 32 g RTN
026 42,21, .6 f LBL . 6 075 45,16,11 RCL MATRIX A 124 42,21,13 f LBL C
027 42 31 f PSE 076 45,16,12 RCL MATRIX B 125 42,16, 1 f MATRIX 1
028 42 36 f RAN # 077 20 × 126 42,21, .3 f LBL . 3
029 2 2 078 45,16,14 RCL MATRIX D 127 42 31 f PSE
030 0 0 079 32 14 GSB D 128 u 45 13 USER RCL C
031 20 × 080 42 31 f PSE 129 22 .3 GTO . 3
032 u 44 11 USER STO A 081 43 32 g RTN 130 43 32 g RTN
033 22 .6 GTO . 6 082 42,21, 7 f LBL 7 131 42,21,14 f LBL D
034 42 31 f PSE 083 42,26,15 f RESULT E 132 42,16, 1 f MATRIX 1
035 43 32 g RTN 084 45,16,11 RCL MATRIX A 133 42,21, .4 f LBL . 4
036 42,21, 3 f LBL 3 085 45,16,11 RCL MATRIX A 134 42 31 f PSE
037 45,16,11 RCL MATRIX A 086 10 ÷ 135 u 45 14 USER RCL D
038 42 31 f PSE 087 45,16,15 RCL MATRIX E 136 22 .4 GTO . 4
039 42,16, 2 f MATRIX 2 088 32 15 GSB E 137 43 32 g RTN
040 42 31 f PSE 089 42 31 f PSE 138 42,21,15 f LBL E
041 42,16, 3 f MATRIX 3 090 43 32 g RTN 139 42,16, 1 f MATRIX 1
042 42 31 f PSE 091 42,21, 8 f LBL 8 140 42,21, .5 f LBL . 5
043 42,16, 4 f MATRIX 4 092 45,16,12 RCL MATRIX B 141 42 31 f PSE
044 42 31 f PSE 093 42 31 f PSE 142 u 45 15 USER RCL E
045 42,16, 4 f MATRIX 4 094 42,16, 7 f MATRIX 7 143 22 .5 GTO . 5
046 42 31 f PSE 095 44 7 STO 7 144 43 32 g RTN
047 43 32 g RTN 096 42 31 f PSE
048 42,21, 4 f LBL 4 097 45,16,12 RCL MATRIX B