I've added a number of matrix routines to the library/matrix.wp34s file. This along with Marcus's matrix editor is about half a flash region. We'd like to provide a full region of matrix functions if possible.
My question is then "What extra functions should go in?"
Suggestions are welcome, suggestions with code are better :-) These aren't going to be held to the same standard as the internal user code commands -- wreck the stack, use the lettered registers and flags and generally have fun.
I am aware of these functions but thought I'd see what people wanted before diving in and doing the ones I find interesting (and probably completely useless).
The existing functions in user code are:
- M.1 - Create an identity matrix from a descriptor in X. No stack damage, L changed.
- M.0 - Create an zero matrix from a descriptor in X. No stack damage, L changed.
- ATR - Return the sum of the absolute values of the matrix diagonal.
- TR - Return the trace of the matrix.
- M- - Matrix subtraction.
- M+ - Matrix addition.
- M.y - Multiply matrix by scalar.
- FNM - Frobenius norm.
- RNM - Row norm.
- CNM - Column norm.
- MFD - Find element in matrix.
- M^ - Find the maximum element in matrix.
- Mv - Find the minimum element in a matrix.
Yes, these need better documentation.
These are implemented internally and documented reasonably in doc/matrix.txt:
- M.TRN - Matrix transpose in-situ.
- M.times - Matrix multiply.
- M.+times - Matrix addition & scalar multiplication.
- M.R<-> - Matrix row swap.
- M.Rtimes - Multiply row by scalar.
- M.R+times - Multiply a row by a scalar and add to another row.
- M.IJ - Convert a register index to row/column indices.
- M.REG - Convert row/column indices to a register index.
- M.ALL - Return a loop index to iterate over the entire matrix.
- M.DIAG - Return a loop index to iterate over the diagonal of the matrix.
- M.ROW - Return a loop index to iterate over a row of the matrix.
- M.COL - Return a loop index to iterate over a column of the matrix.
- M.ROW? - Extract the row count from a matrix descriptor.
- M.COL? - Extract the column count from a matrix descriptor.
- M.SQR? - Check if a matrix descriptor is for a square matrix & execute the next step if not.
- M.COPY - Copy a matrix to another location.
- M.DET - Calculate the determinant of a matrix.
- M.LIN - Solve a system of linear equations.
- M.INV - Invert a matrix in-situ.
This seems like a fairly good selection of operations. Their names might change, but the functions are very unlikely to.
- Pauli