MatrixArith
gathers together a number of operations on matrices; in
most cases these operations are happy to accept a MatrixView
(see MatrixViews
) as argument.
When not specified argument is ConstMatrixView
.
There are two ways of multiplying two matrices together. The infix
operators return a DenseMatrix
; the procedural version may be
slightly faster than the infix operator.
void mul(matrix& lhs, M1, M2);
-- lhs
might be a SparseMatrix
(not yet implemented)
matrix operator*(Mleft, Mright);
matrix operator+(Mleft, Mright);
matrix operator-(Mleft, Mright);
matrix power(ConstMatrixView M, long n);
matrix power(ConstMatrixView M, const BigInt& N);
Here are some matrix norms. These require that the matrix be over an
ordered ring. Note that FrobeniusNorm2
gives the square of the
Frobenius norm (so that the value surely lies in the same ring).
RingElem FrobeniusNorm2(M);
RingElem OperatorNormInfinity(M);
RingElem OperatorNorm1(M);
Here are some fairly standard functions on matrices. I suspect that the pseudo inverse
det(M)
-- determinant of M (M must be square)
rank(M)
-- rank of M (the base ring must be an integral domain)
inverse(M)
-- inverse of M as a DenseMatrix
adjoint(M)
-- adjoint of M as a DenseMatrix
PseudoInverse(M)
-- PseudoInverse of M as a DenseMatrix
.
I suspect that it requires that the matrix be of full rank.
Here are some standard operations where the method used is specified explicitly. It would usually be better to use the generic operations above, as these should automatically select the most appropriate method for the given matrix.
void det2x2(RefRingElem d, M);
-- for 2x2 matrices
void det3x3(RefRingElem d, M);
-- for 2x2 matrices
void DetByGauss(RefRingElem d, M);
std::size_t RankByGauss(std::vector<std::size_t>& IndepRows, M);
matrix InverseByGauss(M);
-- some restrictions (needs gcd)
matrix AdjointByDetOfMinors(M);
matrix AdjointByInverse(M);
-- base ring must be integral domain
void GrammSchmidtRows(MatrixView& M);
-- NYI
void GrammSchmidtRows(MatrixView& M, std::size_t row);
-- NYI
I just cobbled together these few lines of documentation hastily, since I noticed that the file was completely missing. Clearly further work is needed (but it's late, and I have other things to do).