Matrix Multiplication and Manipulation by Herb Jellinek I have added some functions to LLFLOAT that let you use Interlisp-D's high-speed matrix-multiply instructions, and I have written a LispLibrary package that lets you easily manipulate the contents of these matrices. The Library package is called MatrixUse, and is described first. MatrixUse (CREATE1BY3) [function] Returns an ARRAYP that appears to the matrix multiplication functions to be a 1 by 3 vector. The phrase "appears ... to be a 1 by 3 vector" is due to the fact that Interlisp-D arrays are currently one dimensional; the MatrixUse package transparently folds two dimensions into one. (CREATE1BY4) [function] Returns a 1 by 4 vector. (CREATE3BY1) [function] Returns a 3 by 1 vector. (CREATE3BY3) [function] Returns a 3 by 3 matrix. (CREATE4BY1) [function] Returns a 4 by 1 vector. (CREATE4BY4) [function] Returns a 4 by 4 matrix. (IDENTITY3BY3 M) [function] Returns a 3 by 3 identity matrix (a matrix with the elements of its main diagonal all set to unity). In this and all following MatrixUse functions, if M is supplied, sets it to be the identity matrix and returns it. (IDENTITY4BY4 M) [function] Returns a 4 by 4 identity matrix. (ROTATE3BY3 THETA RADIANSFLG M) [function] Returns a 3 by 3 matrix that, when multiplied by a vector, will rotate that vector an angle of THETA around the origin. THETA is measured in degrees or radians, depending on RADIANSFLG. (ROTATE4BY4.ABOUTX THETA RADIANSFLG M) [function] Returns a 4 by 4 matrix suitable for rotating a point in 3-space around the X-axis by THETA. (ROTATE4BY4.ABOUTY THETA RADIANSFLG M) [function] Returns a 4 by 4 matrix suitable for rotating a point in 3-space around the Y-axis by THETA. (ROTATE4BY4.ABOUTZ THETA RADIANSFLG M) [function] Returns a 4 by 4 matrix suitable for rotating a point in 3-space around the Z-axis by THETA. (SCALE3BY3 Sx Sy M) [function] Returns a 3 by 3 matrix that will scale by a factor of Sx in the X-axis and Sy in the Y-axis. (SCALE4BY4 Sx Sy Sz M) [function] Returns a 4 by 4 matrix that will scale by a factor of Sx in the X-axis, Sy in the Y-axis, and Sz in the Z-axis. (TRANSLATE3BY3 Tx Ty M) [function] Returns a 3 by 3 matrix that will translate by a distance of Tx in the X-axis and Ty in the Y-axis. (TRANSLATE4BY4 Tx Ty Tz M) [function] Returns a 4 by 4 matrix that will translate by a distance of Tx in the X-axis, Ty in the Y-axis, and Tz in the Z-axis. (SET.XCOORD VECTOR VALUE) [function] Given a vector VECTOR of length 3 or 4, sets the X component to be VALUE. (SET.YCOORD VECTOR VALUE) [function] Sets the Y component of VECTOR to be VALUE. (SET.ZCOORD VECTOR VALUE) [function] Sets the Z component of VECTOR to be VALUE. (GET.XCOORD VECTOR) [function] Returns the X component of VECTOR. (GET.YCOORD VECTOR) [function] Returns the Y component of VECTOR. (GET.ZCOORD VECTOR) [function] Returns the Z component of VECTOR. Other built-in matrix manipulators (SETELT ARRAY ROW COLUMN EltsPerRow VALUE) [function] Sets the element at (ROW, COLUMN) to be VALUE. EltsPerRow is the number of elements per row of ARRAY. ROW and COLUMN are indexed from 1. (GETELT ARRAY ROW COLUMN EltsPerRow) [function] Returns the value of the (ROW, COLUMN) element of ARRAY. The arguments treated as in SETELT. Matrix Multiplication (MATMULT A B Result K M N) [function] Multiplies A by B, placing the result in Result. A is a K row by M column matrix, B is M by N, and Result is K by N. This function does NOT use the matrix-multiplication instructions. (MATMULT133 A B Result) [function] Multiplies A by B, placing the result in Result. A is a 1 by 3 vector, B is a 3 by 3 matrix, and Result is a 1 by 3 vector (hence the "133" suffix - it refers to the values of K, M, and N.) This runs in microcode on the 1108X, and in macrocode on other machines. (MATMULT331 A B Result) [function] As above; A is 3 by 3, and B and Result are 3 by 1 matrices. (MATMULT333 A B Result) [function] A, B, and Result are all 3 by 3 matrices. (MATMULT144 A B Result) [function] A and Result are 1 by 4 vectors, and B is 4 by 4. (MATMULT441 A B Result) [function] B and Result are 1 by 4 vectors, and A is 4 by 4. (MATMULT444 A B Result) [function] A, B and Result are all 4 by 4 matrices. ``ÈÈÈÈÈGACHA  TIMESROMAN TIMESROMANGACHA TIMESROMAN TIMESROMAN1(DEFAULTFONT 1 (GACHA 10) (GACHA 8) (TERMINAL 8)) &Ñ     J½           € ?    _1  L  L  L   7   7  =   =                     #! &    F    &M                  ´z¹