Output from imlmat4.sas

Source
0 Graphs

NOTE: Capture of log output started.
NOTE: %INCLUDE (level 1) file n:\psy6140\examples\iml\imlmat4.sas is file
      n:\psy6140\examples\iml\imlmat4.sas.
765  +title 'IMLMAT4: Properties of matrix multiplication';
766  +proc iml;
IML Ready
767  +   reset print log fuzz fw=4;
768  +* PROPERTIES OF MATRIX MULTIPLICATION;
769  +A = {1 2, 3 4};
                A             2 rows      2 cols    (numeric)

                                     1    2
                                     3    4

770  +B = {1 1 1, 2 2 2};
                B             2 rows      3 cols    (numeric)

                                   1    1    1
                                   2    2    2

771  +C = {5 5, 6 6, 7 7};
                C             3 rows      2 cols    (numeric)

                                     5    5
                                     6    6
                                     7    7

772  +*-- 1. Associative law: A(BC) = (AB)C = ABC;
773  +print (A) '*' (B * C) ' =' ( A*B*C);
                         A        #TEM1001     #TEM1003
                         1    2 *   18   18  =   90   90
                         3    4     36   36     198  198
774  +print (A * B) '*' (C) ' =' ( A*B*C);
                   #TEM1001            C         #TEM1003
                      5    5    5 *    5    5  =   90   90
                     11   11   11      6    6     198  198
                                       7    7
775  +*-- 2. Distributive laws:;
776  +*    (A+B)C = AC + BC;
777  +*    A(B+C) = AB + AC;
778  +B = {1 1, 2 2};
                B             2 rows      2 cols    (numeric)

                                     1    1
                                     2    2

779  +C = {5 10, 5 10};
                C             2 rows      2 cols    (numeric)

                                     5   10
                                     5   10

780  +print (A+B) '*' (C) ' =' ((A+B) * C);
                      #TEM1001       C         #TEM1003
                         2    3 *    5   10  =   25   50
                         5    6      5   10      55  110
781  +print (A * C) '+' (B * C) '=' ((A+B) * C);
                      #TEM1001    #TEM1002    #TEM1004
                        15   30 +   10   20 =   25   50
                        35   70     20   40     55  110
782  +*-- 3. Multiplication by IDENTITY: A I = I A = A;
783  +A = {1 2 3, 4 5 6};
                A             2 rows      3 cols    (numeric)

                                   1    2    3
                                   4    5    6

784  +print (A) ' * ' ( I(3) ) '=' (A  *  I(3));
                 A               #TEM1001         #TEM1003
                 1    2    3  *     1    0    0 =    1    2    3
                 4    5    6        0    1    0      4    5    6
                                    0    0    1
785  +print ( I(2) ) ' * ' (A) '=' (( I(2) )  *  A);
                #TEM1001         A             #TEM1003
                   1    0  *     1    2    3 =    1    2    3
                   0    1        4    5    6      4    5    6
786  +*-- 4. Multiplication by ZERO: A 0 = 0 A = 0;
787  +print (A) ' * ' ( J(3,3,0) ) '=' (A * J(3,3,0));
                 A               #TEM1001         #TEM1003
                 1    2    3  *     0    0    0 =    0    0    0
                 4    5    6        0    0    0      0    0    0
                                    0    0    0
788  +print ( J(2,2,0) ) ' * ' (A) '=' (( J(2,2,0) ) *  A);
                #TEM1001         A             #TEM1003
                   0    0  *     1    2    3 =    0    0    0
                   0    0        4    5    6      0    0    0
789  +*-- 5. Transpose of product: (AB)` = B` A';
790  +B = {1 1, 2 2, 3 3};
                B             3 rows      2 cols    (numeric)

                                     1    1
                                     2    2
                                     3    3

791  +print 't(' (A) '*' (B) ') = '  (t(A  *  B));
                       A                B           #TEM1002
                 t(    1    2    3 *    1    1 ) =    14   32
                       4    5    6      2    2        14   32
                                        3    3
792  +print (t(B)) '*' (t(A)) ' = ' (t(A  *  B));
                   #TEM1001         #TEM1002      #TEM1004
                      1    2    3 *    1    4  =    14   32
                      1    2    3      2    5       14   32
                                       3    6
793  +*   SAME RULE FOR 3 OR MORE: (ABC)' =Å C' B' A';
794  +print 't(' A '*' B '*' C ') = '  (t(A * B * C));
                 A                B           C           #TEM1003
           t(    1    2    3 *    1    1 *    5   10 ) =   140  320
                 4    5    6      2    2      5   10       280  640
                                  3    3
795  +print (t(C)) '*' (t(B)) '*' (t(A)) ' = ' (t(A * B * C)) ;
             #TEM1001    #TEM1002         #TEM1003      #TEM1006
                5    5 *    1    2    3 *    1    4  =   140  320
               10   10      1    2    3      2    5      280  640
                                             3    6
796  +*-- 6. Matrix multiplication is (generally) not COMMUTATIVE;
797  +*    A*B ^=B*A;
798  +print (A * B) '^=' (B * A);
                         #TEM1001     #TEM1002
                           14   14 ^=    5    7    9
                           32   32      10   14   18
                                        15   21   27
799  +quit;
Exiting IML.
NOTE: The PROCEDURE IML used 0.16 seconds.

800  +
NOTE: %INCLUDE (level 1) ending.