Output from imlmat2.sas |
Source
0 Graphs |
---|
NOTE: Capture of log output started.
NOTE: %INCLUDE (level 1) file n:\psy6140\examples\iml\imlmat2.sas is file n:\psy6140\examples\iml\imlmat2.sas.
721 +title 'IMLMAT2: Matrix arithmetic: +, -, #'; 722 +options nodate; 723 +proc iml;
IML Ready
724 + reset print log; 725 + 726 + *--(1) matrix addition and subtraction; 727 + a = {1 2 3, 4 5 6};
A 2 rows 3 cols (numeric) 1 2 3 4 5 6
728 + b = {5 1 0, 3 -2 1};
B 2 rows 3 cols (numeric) 5 1 0 3 -2 1
729 + c = {2 2 2, 1 1 1};
C 2 rows 3 cols (numeric) 2 2 2 1 1 1
730 + *-- matrices are added elementwise (must be same order); 731 + d = a + b;
D 2 rows 3 cols (numeric) 6 3 3 7 3 7
732 + d = a + {1 3, 3 10};
ERROR: (execution) Matrices do not conform to the operation.
operation : + at line 732 column 10 operands : A, *LIT1004 A 2 rows 3 cols (numeric) 1 2 3 4 5 6 *LIT1004 2 rows 2 cols (numeric) 1 3 3 10 statement : ASSIGN at line 732 column 4
733 + *-- matrices are subtracted elementwise; 734 + d = a - b;
D 2 rows 3 cols (numeric) -4 1 3 1 7 5
735 + *-- negation is also elementwise; 736 + d = -a;
D 2 rows 3 cols (numeric) -1 -2 -3 -4 -5 -6
737 + 738 + *--(2) properties of matrix addition, subtraction; 739 + * a. commutative: A + B = B + A; 740 + print ( A + B ) ( B + A );
#TEM1001 #TEM1002 6 3 3 6 3 3 7 3 7 7 3 7
741 + equal = all( (A + B) = (B + A) );
EQUAL 1 row 1 col (numeric) 1
742 + * b. associative: A + (B+C) = (A+B) + C; 743 + print ( (A+B) + C ) ( A + (B+C) );
#TEM1002 #TEM1004 8 5 5 8 5 5 8 4 8 8 4 8
744 + * c. - A is additive inverse of A; 745 + d = A - A;
D 2 rows 3 cols (numeric) 0 0 0 0 0 0
746 + 747 + *--(3) Product of a matrix and a scalar: elementwise; 748 + d = 3 # A;
D 2 rows 3 cols (numeric) 3 6 9 12 15 18
749 + * this product is also commutative: 750 + d = A # 3; 751 + * ...and distributive over addition: 752 + print ( 3 # (A + B) ) ( (3#A) + (3#B) ); 753 + * multiplication by 1 and 0; 754 + d = 1 # A;
D 2 rows 3 cols (numeric) 1 2 3 4 5 6
755 + d = 0 # A;
D 2 rows 3 cols (numeric) 0 0 0 0 0 0
756 + 757 + *--(4) Elementwise product and division; 758 + d = A # B;
D 2 rows 3 cols (numeric) 5 2 0 12 -10 6
759 + *-- division is NOT actually part of matrix algebra, 760 + but elementwise division is a natural extension; 761 + d = A / 2;
D 2 rows 3 cols (numeric) 0.5 1 1.5 2 2.5 3
762 +quit;
Exiting IML.
NOTE: The PROCEDURE IML used 0.16 seconds.
763 +
NOTE: %INCLUDE (level 1) ending.