Output from imlmat1.sas |
Source
0 Graphs |
---|
NOTE: Capture of log output started.
NOTE: %INCLUDE (level 1) file n:\psy6140\examples\iml\imlmat1.sas is file n:\psy6140\examples\iml\imlmat1.sas.
675 +title 'IMLMAT1: Basic matrix definitions'; 676 +options nodate; 677 +proc iml;
IML Ready
678 + reset print log; 679 + 680 + *-- Matrix: a rectanglar array of numbers; 681 + X = {1 2 3, 4 0 6, 9 1 4, 6 2 4};
X 4 rows 3 cols (numeric) 1 2 3 4 0 6 9 1 4 6 2 4
682 + 683 + print (nrow(X)) (ncol(X));
#TEM1001 #TEM1002 4 3
684 + rowvec = { 1 2 3};
ROWVEC 1 row 3 cols (numeric) 1 2 3
685 + colvec = { 1, 4, 6};
COLVEC 3 rows 1 col (numeric) 1 4 6
686 + *-- transpose: interchanges rows and cols; 687 + xt = x`;
XT 3 rows 4 cols (numeric) 1 4 9 6 2 0 1 2 3 6 4 4
688 + xt = t(x);
XT 3 rows 4 cols (numeric) 1 4 9 6 2 0 1 2 3 6 4 4
689 + *-- square matrix: same number of rows and cols; 690 + A = {5 -1 3, -1 4 7, 3 3 -4};
A 3 rows 3 cols (numeric) 5 -1 3 -1 4 7 3 3 -4
691 + *-- main diagonal: entries A[i,i]; 692 + d = vecdiag(A);
D 3 rows 1 col (numeric) 5 4 -4
693 + *-- diagnonal matrix: all zero except for main diagonal; 694 + d = diag({1 4 9});
D 3 rows 3 cols (numeric) 1 0 0 0 4 0 0 0 9
695 + *-- trace: for square matrix, the sum of main diagonal; 696 + t = trace(A);
T 1 row 1 col (numeric) 5
697 + *-- symmetric matrix: square, and equal to its transpose 698 + i.e., A[i,j] = A[j,i]; 699 + sym = ( A = A` );
SYM 3 rows 3 cols (numeric) 1 1 1 1 1 0 1 0 1
700 + sym = all( A = A` );
SYM 1 row 1 col (numeric) 0
701 + *-- any square matrix may be made symmetric by averaging 702 + with its transpose; 703 + B = ( A + A` ) / 2;
B 3 rows 3 cols (numeric) 5 -1 3 -1 4 5 3 5 -4
704 + sym = all( B = B`);
SYM 1 row 1 col (numeric) 1
705 + *-- upper triangular matrix: all below main diag = 0; 706 + upper = {-5 2 7, 0 -2 4, 0 0 3};
UPPER 3 rows 3 cols (numeric) -5 2 7 0 -2 4 0 0 3
707 + *-- lower triangular matrix: all below main diag = 0; 708 + lower = upper`;
LOWER 3 rows 3 cols (numeric) -5 0 0 2 -2 0 7 4 3
709 + *-- identity matrix: diagonal matrix with 1s on main diag; 710 + I = I(3);
I 3 rows 3 cols (numeric) 1 0 0 0 1 0 0 0 1
711 + *-- scalar matrix: diagonal matrix with equal diagonal entries; 712 + S = diag({10 10 10});
S 3 rows 3 cols (numeric) 10 0 0 0 10 0 0 0 10
713 + *-- unit matrix: all elements = 1; 714 + J = J(2,5);
J 2 rows 5 cols (numeric) 1 1 1 1 1 1 1 1 1 1
715 + J = J(3,1);
J 3 rows 1 col (numeric) 1 1 1
716 + *-- zero matrix: all elements = 0; 717 + Z = J(2,5,0);
Z 2 rows 5 cols (numeric) 0 0 0 0 0 0 0 0 0 0
718 +quit;
Exiting IML.
NOTE: The PROCEDURE IML used 0.22 seconds.
719 +
NOTE: %INCLUDE (level 1) ending.