mat
Dense()
A dense matrix implementation.
Creation
Dense(r, c, data)Parameters
rNumberrowscNumbercolumnsdataNumber[]matrix elements
Creates a new Dense matrix of size r × c.
Usage example
| |
dims()
Returns the matrix dimensions (rows, columns).
Usage example
| |
at()
Returns the value at the specified (row, col).
Usage example
| |
set()
Sets the value at the specified position.
Usage example
| |
t()
Creates a transposed matrix.
| |
add()
Performs matrix addition.
| |
sub()
Performs matrix subtraction.
| |
mul()
Performs matrix multiplication.
| |
mulElem()
Performs element-wise multiplication.
| |
divElem()
Performs element-wise division.
| |
inverse()
Calculates the inverse matrix.
| |
solve()
Solves the linear equation A * X = B and returns the solution.
exp()
Computes the matrix exponential.
pow()
Performs matrix exponentiation.
scale()
Scales the matrix by a scalar value.
VecDense
A dense vector type.
Creation
VecDense(n, data)Parameters
nNumbervector length (must be greater than 0)dataNumber[]element array (filled with zeros if omitted)
cap()
Returns the internal buffer capacity.
len()
Returns the vector length.
atVec()
Returns the value at the specified index.
setVec()
Sets the value at the specified index.
addVec()
Adds two vectors and stores the result.
subVec()
Performs vector subtraction.
mulVec()
Computes matrix-vector multiplication.
mulElemVec()
Computes element-wise multiplication.
scaleVec()
Scales the vector by a scalar.
solveVec()
Solves a linear system and returns the vector solution.
QR
QR factorization is a decomposition of a matrix A into a product A = QR of an orthonormal matrix Q and an upper triangular matrix R.
QR decomposition is often used to solve the linear least squares (LLS) problem and is the basis for a particular eigenvalue algorithm, the QR algorithm.
Any real matrix A may be decomposed as
A = QRwhere Q is an orthogonal matrix and R is an upper triangular matrix. If A is invertible, then the factorization is unique if we require the diagonal elements of R to be positive.
Usage example
| |
format()
| |