tags:

views:

12

answers:

0

Hi All,

I'm still a maxima newbie so bear with me. I am trying to write my own formula for calculating the adjoint of a matrix (I know maxima already has one built-in, but I was trying my own as a learning exercise). So far I have (for a 3x3 matrix):

/* cofactor of some submatrix of the matrix, by deleting row i and column j */
cof(i, j, M) := determinant(submatrix(i, M, j));

/* for 3 x 3 matrix */
C3(M) := matrix( [cof(1,1,M), cof(1,2,M), cof(1,3)],
                 [cof(2,1,M), cof(2,2,M), cof(2,3)],
                 [cof(3,1,M), cof(3,2,M), cof(3,3)] );

/* function for calculating adjoint sign for x at position i, j */
adj_f(i, j, x) := -1^(i+j) * x;

/* adjugate for a 3x3 matrix M */
adj3(M) := matrixmap(lambda([i,j,x], adj_f(i,j,x), transpose(C3(M))));

I know this probably isn't the best way of doing it; however, I was wondering if there was a way of accessing the i and j elements when using matrixmap or fullmapl?

(I'm using wxMaxima and I don't have a whole lot of lisp experience, I was trying to get away with this without touching any code).