Manu - Nim Matrix library
The manu module provides the fundamental operations of numerical linear algebra. Various constructors create Matrices from two dimensional arrays of double precision floating point numbers. Various "gets" and "sets" provide access to submatrices and matrix elements. Several methods implement basic matrix arithmetic, including matrix addition and multiplication, matrix norms, and element-by-element array operations. Methods for reading and printing matrices are also included. All the operations in this version of the Matrix object involve real matrices. Complex matrices may be handled in a future version.
Five fundamental matrix decompositions, which consist of pairs or triples of matrices, permutation vectors, and the like, produce results in five decomposition classes. These decompositions are accessed by the manu module to compute solutions of simultaneous linear equations, determinants, inverses and other matrix functions. The five decompositions are:
- Cholesky Decomposition of symmetric, positive definite matrices.
- LU Decomposition of rectangular matrices.
- QR Decomposition of rectangular matrices.
- Singular Value Decomposition of rectangular matrices.
- Eigenvalue Decomposition of both symmetric and nonsymmetric square matrices.
Example:
import manu # Solve a linear system A x = b and compute the residual norm, ||b - A x||. let vals = @[@[1.0, 2, 3], @[4.0, 5, 6], @[7.0, 8, 10]] let A = matrix(vals) let b = randMatrix64(3, 1) let x = A.solve(b) let r = A * x - b let rnorm = r.normInf() echo("x =\n", x) echo("residual norm = ", rnorm)
Procs
proc solveTranspose[T](a, b: Matrix[T]): Matrix[T]
-
Solve X*A = B, which is also A'*X' = B'
- parameter b: the right hand side
- return: solution if A is square, least squares solution otherwise.
Exports
-
getArray, Matrix32, ColVector32, -, sqrt, cosh, *., randNMatrix, randMatrix32, columnDimension, randMatrix, *., /=, -, []=, -, /., [], /, $, -, *.=, +=, matrix, *., [], *., ones64, randNMatrix, +=, rowDimension, -, randMatrix, /., []=, [], matrix, -, randNMatrix32, /., sinh, log10, matrix, sumRows, zeros, lgamma, =dup, erf, +, cbrt, getColumnPacked, *., matrix, erfc, matrix, eye64, sin, norm1, []=, normF, tan, randNMatrix64, +, *, degToRad, ln, -, Matrix64, transpose, *, -=, radToDeg, m, +, []=, /, -, makeUniversalBinaryScalarInplace, eye, randMatrix, arccos, /., /., -=, randMatrix64, makeUniversalBinaryInplace, identity, +, dim, sum, /.=, gamma, exp, sumColumns, =copy, arcsin, RowVector, [], zeros64, RowVector32, *., =destroy, normInf, arctan, trace, [], +=, ceil, eye32, matrix, makeUniversalBinary, -=, +, +, *.=, *.=, /.=, +, ones, +=, +, /., floor, []=, Matrix, makeUniversal, /.=, []=, tanh, -=, trunc, makeUniversalBinaryInplaceImpl, -, [], /., *=, *., []=, -, *, makeUniversalBinaryImpl, matrixUninit, cos, RowVector64, ColVector64, [], zeros32, +, n, [], log2, ColVector, getRowPacked, ones32, [], [], solve, getL, chol, CholeskyDecomposition, isSpd, QRDecomposition, getQ, solve, getH, qr, isFullRank, getR, getPivot, det, getL, luGauss, LUDecomposition, getU, getFloatPivot, solve, lu, isNonsingular, cond, SingularValueDecomposition, rank, getV, getS, norm2, svd, getU, getSingularValues, getRealEigenvalues, getImagEigenvalues, getV, EigenvalueDecomposition, getD, eig