function c = matmul9(a,b)
% Function to multiply two 3x3 matricies stored as 9-col arrays (lay matrix out by rows)
% I probably should have layed them in by columns - too late for this meeting!
% Created Oct 1, 2000 (Japan)
% a = first matrix as 9-col array (matrix stored by rows)
% b = second matrix
% c = product matrix (also 9-col)

c(:,1) = a(:,1).*b(:,1) + a(:,2).*b(:,4) + a(:,3).*b(:,7);
c(:,2) = a(:,1).*b(:,2) + a(:,2).*b(:,5) + a(:,3).*b(:,8);
c(:,3) = a(:,1).*b(:,3) + a(:,2).*b(:,6) + a(:,3).*b(:,9);

c(:,4) = a(:,4).*b(:,1) + a(:,5).*b(:,4) + a(:,6).*b(:,7);
c(:,5) = a(:,4).*b(:,2) + a(:,5).*b(:,5) + a(:,6).*b(:,8);
c(:,6) = a(:,4).*b(:,3) + a(:,5).*b(:,6) + a(:,6).*b(:,9);

c(:,7) = a(:,7).*b(:,1) + a(:,8).*b(:,4) + a(:,9).*b(:,7);
c(:,8) = a(:,7).*b(:,2) + a(:,8).*b(:,5) + a(:,9).*b(:,8);
c(:,9) = a(:,7).*b(:,3) + a(:,8).*b(:,6) + a(:,9).*b(:,9);

return