MatrixArith
gathers together a number of operations on matrices; in
most cases these operations are happy to accept a MatrixView
(see MatrixViews
) as argument.
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, ConstMatrixView M1, ConstMatrixView M2); matrix operator*(ConstMatrixView Mleft, ConstMatrixView Mright); matrix operator+(ConstMatrixView Mleft, ConstMatrixView Mright); matrix operator-(ConstMatrixView Mleft, ConstMatrixView Mright);
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(ConstMatrixView A); RingElem OperatorNormInfinity(ConstMatrixView M); RingElem OperatorNorm1(ConstMatrixView 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 DetByGauss(RefRingElem d, ConstMatrixView M); std::size_t RankByGauss(std::vector<std::size_t>& IndepRows, ConstMatrixView M); matrix InverseByGauss(ConstMatrixView M); matrix AdjointByDetOfMinors(ConstMatrixView M); matrix AdjointByInverse(ConstMatrixView M); // base ring must be integral domain
void GrammSchmidtRows(MatrixView& M); void GrammSchmidtRows(MatrixView& M, std::size_t row);
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).