File matrix_util.icn |
Provides utilities for creating and manipulating matrices
Author: Kevin Wampler (kevin@tapestry.tucson.az.us)
Minor adjustments (cosmetic) by Steve Wampler
(sbw@tapestry.tucson.az.us)
This file is in the public domain.
This file is part of the util package.
Source code.Details |
Procedures: |
M1 | first matrix |
M2 | second matrix |
M1+M2 |
M1 | first matrix |
M2 | second matrix |
op | binary operation to invoke |
M1 op M2, with op defaulting to
proc("+",2) |
Generic binary operation across two matrices.
M | matrix |
a | column to return from M |
column a of M |
M | matrix |
a | first column to swap |
b | second column to swap |
Swaps columns a and b of M
m | number of rows |
n | number of columns |
x | initial value of every element |
a m x n matrix with x everywhere |
M | a matrix |
a copy of matrix M |
m_divide(M1, M2, addfun, subfun, mulfun, divfun, addident, mulident, invertMetric)
a matrix X such that M2*X = M1 |
Additional optional arguments allow you to customize the operation by overriding various functions and constants used internally.
m_identity(m, n, zero:0, one:1)
m | number of rows |
n | number of columns |
zero | (optional) can be used in place of 0.0 |
one | (optional) can be used in place of 1.0 |
mXn identify matrix |
Creates a m x n matrix with ones on the diagonal and zeros everywhere else
m_inverse(M, addfun, subfun, mulfun, divfun, addident, mulident, invertMetric)
the (multiplicative) inverse of M |
Additional optional arguments allow you to customize the operation by overriding various functions and constants used internally.
m_linearSolve(A, b, addfun, subfun, mulfun, divfun, addident, mulident, invertMetric)
the solution x to A*x = b |
Additional optional arguments allow you to customize the operation by overriding various functions and constants used internally.
m_lupDecomposition(M, subfcn, mulfcn, divfcn, invertMetric, addident:0, mulident:1)
the LUP decomposition of M, fails if M is singular |
The result is returned as a list [L, U, p] of matrices such that P*M = L*U, and p is a list representing the permutation to create P.
Additional optional arguments allow you to customize the operation by overriding various functions and constants used internally.
m_lupSolve(L, U, p, b, addfun, subfun, mulfun, divfun, addident:0)
the solution x to A*x = b where the LUP
decomposition of A is [L,U,p] |
Additional optional arguments allow you to customize the operation by overriding various functions and constants used internally.
m_multiply(M1, M2, addident:0, addfcn, mulfcn)
M1 | first matrix |
M2 | second matrix |
addident | (optional) additive identify replacement |
addfcn | (optional) addition operation replacement |
mulfcn | (optional) multiplication operation replacement |
M1*M2 |
M | matrix |
-M |
M | matrix |
a | first row to swap |
b | second row to swap |
Swaps rows a and b of M
M1 | first matrix |
M2 | second matrix |
M1-M2 |
M | matrix |
the transpose of M |
M | matrix |
op | unary operation to invoke |
op M, with op defaulting to
proc("-",1) |
Generic unary operation across a matrix.
Output matrices.
A file argument changes output of subsequent arguments to that file (default is &output). String arguments are output as they appear. Matrices are output one row per line of output followed by a blank line.
Matrices and output files