proc iml; a = {1 2, 3 4}; c= {1 0, 0 1}; b = a || c; d = echelon(b); x1 = d[1,3]; x2= d[1,4] ; x3 = d[2,3]; x4 = d[2,4]; e = {0 0, 0 0}; e[1,1] = x1; e[1,2] = x2; e[2,1]= x3; e[2,2]= x4; print d, e; Is the and easier way to put grab the take the 2x2 matrix out of the 2 by 4 matrix?
... View more
I am suppose only be able to put in 2x2 matrices and find the determinate if the matrices is a 2x2 if it is a 1x1 or a 3x3 I am suppose to print an error and if it is singular i am suppose to print another error. What am I doing wrong? Proc IML; a = {1 2, 3 4}; b = {1 1, 1 1}; c = {1 2 3, 4 5 6, 7 8 9}; d = {5}; start invers(a); nr = nrow(a); nc = ncol(a) ; if nr=2 & nc=2 then do; i = det(a); b = INV(a); if i ^= 0 then return(b); else if i = 0 then print("Singular"); end; else print("error"); finish; w = invers(a); x = invers(b); y = invers(c); z = invers(d); print w, x, y, z;
... View more
so instead of: i = ( det(a) || det(b) || det(c) )[<:>]; I should use: i = loc(d=max(d)); This would give me the max det value or would this give me the matrix with max determinate? I want the print out the matrix (just the matrix) with the max determinate. Every thing is fine after the then do statement.
... View more
I am trying to figure that out. I think I would want to print both of them if they were tied to show that they had a tie. how would I do that? also how would I make the matrix or matrices show up in the output log.
... View more
How would I write a function module that will input 3 identical sized matrices (not knowing the size) and retunr the one that has the largest determinant. The function should check that the matrices are square and all the same size.
... View more
How would I write a subrountine that takes 2 parameters (a constant and a square matrix). Then adds that constant to the every element of the diagonal of the matrix, and passes the results back in a new parameter? Then out puts the new matrix after the subtracted constant I have the general idea but getting stuck on the diagonal part.
... View more