Representation of dense matrices of arbitrary size in a template field T
.
More...
Public Member Functions | |
NPMatrix (size_t n=0, size_t p=0) | |
Construct a \( n \times p \) matrix initialized with NVector(size_t dim) constructor. More... | |
NPMatrix (const vector< vector< T > > &data) | |
Construct a matrix using a bi-dimensional std::vector . \( Aij \) represents data[i][j] . More... | |
NPMatrix (const NPMatrix< T > &m) | |
Construct a matrix by using copy() method. More... | |
NPMatrix (initializer_list< initializer_list< T >> list) | |
Construct a \( n \times p \) matrix using a bi-dimensional initializer list {{}} . More... | |
NPMatrix (const NVector< T > &u, size_t n=1) | |
Construct a \( n \) rows matrix using a std::vector . More... | |
NPMatrix (const vector< NVector< T > > &vectors) | |
Construct a \( n \times p \) matrix using a vector<NVector<T>> .` All the vectors must have the same dimension. More... | |
~NPMatrix () | |
string | str () const override |
Create a string representing the matrix. More... | |
bool | isSquare () const |
bool | isUpper () const |
bool | isLower () const |
bool | isDiagonal () const |
NPMatrix< T > & | operator= (const NPMatrix< T > &m) |
Getters | |
size_t | n () const |
Number of rows \( n \). More... | |
size_t | p () const |
Number of columns \( p \). More... | |
NVector< T > | row (size_t i) const |
\( i^{th} \) row of the matrix as a NVector<T> . More... | |
NVector< T > | col (size_t j) const |
\( j^{th} \) column the matrix as a NVector<T> . More... | |
vector< NVector< T > > | rows (size_t i1=0, size_t i2=MAX_SIZE) const |
Create an array containing the rows of the matrix. More... | |
vector< NVector< T > > | cols (size_t j1=0, size_t j2=MAX_SIZE) const |
Create an array containing the columns of the matrix in the form of std::vector<NVector<T>> . More... | |
NPMatrix< T > | upper () const |
Create a new matrix containing upper part of this matrix. More... | |
NPMatrix< T > | lower () const |
Create a new matrix containing lower part of this matrix. More... | |
NPMatrix< T > | lupL () const |
\( L \) matrix of \( LU \) decomposition of the matrix. More... | |
NPMatrix< T > | lupU () const |
\( U \) matrix of \( LU \) decomposition of the matrix. More... | |
Setters | |
NPMatrix< T > & | setRow (const NVector< T > &u, size_t i1) |
Set row with given vector. More... | |
NPMatrix< T > & | setCol (const NVector< T > &u, size_t j1) |
Set column with given vector. More... | |
NPMatrix< T > & | setRows (const vector< NVector< T >> &vectors, size_t i1=0) |
Replace the components of the matrix with the array of vectors. More... | |
NPMatrix< T > & | setCols (const vector< NVector< T >> &vectors, size_t j1=0) |
Replace the components of the matrix with the array of vectors. More... | |
Manipulators | |
Manipulators such as swap, shift... Manipulators allow cascade calls. The behavior is the same as Setters. | |
NPMatrix< T > & | swap (size_t i1, size_t j1, size_t i2, size_t j2) |
Swap \( A_{i_1j_1} \) and \( A_{i_2j_2} \). More... | |
NPMatrix< T > & | swapRow (size_t i1, size_t i2) |
Swap \( R_{i_1} \) and \( R_{i_2} \). More... | |
NPMatrix< T > & | swapCol (size_t j1, size_t j2) |
Swap \( C_{j_1} \) and \( C_{j_2} \). More... | |
NPMatrix< T > & | shiftRow (size_t i, long iterations=1) |
shift the \( i^{th} \) row iterations times. More... | |
NPMatrix< T > & | shiftCol (size_t j, long iterations=1) |
shift the \( j^{th} \) column iterations times. More... | |
Algebra | |
Matrix algebraical operations. Algebraical operations consists on method specific to matrices algebra such as inversion, determinant... | |
NPMatrix< T > | transposed () const |
Transposed matrix. More... | |
T | trace () const |
Trace of this matrix \( A_{00} + A_{11} + ... + A_{(n-1)(n-1)} \). More... | |
NPMatrix< T > | shifted (const NPMatrix< T > &m) const |
Concatenate matrix m to this matrix. More... | |
NPMatrix< T > & | reduce () |
Apply Gauss Jordan elimination on matrix to calculate inverse without using \( LU \) decomposition. More... | |
T | det () const |
determinant of this matrix \( det(A) \). Using the \( LU \) decomposition \( O(n) \). More... | |
Function Operator | |
Access to components and sub-matrix C++ function operator are here used to give intuitive access to the matrix. | |
T & | operator() (size_t i, size_t j) |
Bi-dimensional access operator. More... | |
T | operator() (size_t i, size_t j) const |
NPMatrix< T > | operator() (size_t i1, size_t j1, size_t i2, size_t j2) const |
Manipulate sub-matrix. More... | |
NPMatrix< T > & | operator() (size_t i1, size_t j1, size_t i2, size_t j2) |
Manipulate sub-matrix. More... | |
![]() | |
NVector (const std::vector< T > &data) | |
Construct a vector using a std::vector . \( x_k \) represents data[k] . More... | |
NVector (std::initializer_list< T > list) | |
Construct a vector using an initializer list {} . More... | |
NVector (size_t dim=0) | |
Construct a vector of a given size. More... | |
NVector (const NVector< T > &u) | |
Construct a vector by using copy() method. More... | |
virtual | ~NVector ()=default |
size_t | dim () const |
Dimension of the vector. More... | |
std::vector< T > | array () const |
Creates an array with this vector. More... | |
NVector< T > & | operator+= (const NVector< T > &u) |
NVector< T > & | operator-= (const NVector< T > &u) |
NVector< T > & | operator= (const NVector< T > &u) |
Copy source object on this object using copy() . More... | |
T | max () const |
Maximum of the coordinates of the vector \( (x_0, x_1, .. x_{(n-1)}) \). More... | |
T | min () const |
Minimum of the coordinates of the vector \( (x_0, x_1, .. x_{(n-1)}) \). More... | |
size_t | maxIndex () const |
Index of maximum of the coordinates of vector \( (x_0, x_1, ..., x_{(n-1)}) \). More... | |
size_t | minIndex () const |
Index of minimum of the coordinates of vector \( (x_0, x_1, ..., x_{(n-1)}) \). More... | |
T | maxAbs () const |
Maximum of the coordinates of the vector \( (|x_0|, |x_1|, ..., |x_{(n-1)}|) \). More... | |
T | minAbs () const |
Minimum of the coordinates of the vector \( (|x_0|, |x_1|, ..., |x_{(n-1)}|) \). More... | |
size_t | maxAbsIndex () const |
Index of maximum of the coordinates of vector \( (|x_0|, |x_1|, ..., |x_{(n-1)}|) \). More... | |
size_t | minAbsIndex () const |
Index of minimum of the coordinates of vector \( (|x_0|, |x_1|, ..., |x_{(n-1)}|) \). More... | |
NVector< T > & | swap (size_t k1, size_t k2) |
Permutation of two elements. More... | |
NVector< T > & | shift (long iterations) |
Shifts this vector iterations times. More... | |
NVector< T > & | fill (T s) |
Fill vector with a scalar. For example fill(3) will set \( (3, 3, 3, ..., 3) \). More... | |
T & | operator() (long k) |
Simple access operator. More... | |
T | operator() (long k) const |
NVector< T > | operator() (size_t k1, size_t k2) const |
Manipulate sub-vector. More... | |
NVector< T > & | operator() (size_t k1, size_t k2) |
Manipulate sub-vector. More... | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
Static Public Member Functions | |
static NPMatrix< T > | zeros (size_t n, size_t p=0) |
\( n \times p \) matrix filled with 0 . More... | |
static NPMatrix< T > | ones (size_t n, size_t p=0) |
\( n \times p \) matrix filled with 1 . More... | |
static NPMatrix< T > | cano (size_t i, size_t j, size_t n, size_t p=0) |
\( n \times p \) canonical matrix More... | |
static NPMatrix< T > | eye (size_t n) |
\( n^{th} \) order identity matrix More... | |
static NPMatrix< T > | diag (const vector< T > &data, size_t n) |
diagonal \( n^{th} \) order diagonal matrix filled with data array. More... | |
static NPMatrix< T > | scalar (T s, size_t n) |
a scalar \( n^{th} \) order matrix with s value More... | |
static NPMatrix< T > | ndiag (const vector< NVector< T > > &data) |
Fills a square matrix matrix by giving diagonal data. More... | |
static NPMatrix< T > | nscalar (const vector< T > &scalars, size_t n) |
Generalization of scalar matrix with multiple diagonal. More... | |
![]() | |
static NVector< T > | zeros (size_t dim) |
static NVector< T > | ones (size_t dim) |
static NVector< T > | scalar (T s, size_t dim) |
static NVector< T > | cano (size_t k, size_t dim) |
static NVector< T > | sum (const std::vector< NVector > &vectors) |
Sum of multiples vectors. More... | |
static NVector< T > | sumProd (const std::vector< T > &scalars, const std::vector< NVector > &vectors) |
Linear combination of scalars and vectors . More... | |
Protected Member Functions | |
NPMatrix (const NVector< T > &u, size_t n, size_t p, size_t i1=0, size_t j1=0, size_t i2=0, size_t j2=0) | |
NPMatrix< T > & | swap (Parts element, size_t k1, size_t k2) |
NPMatrix< T > & | shift (Parts element, size_t k, long iterations) |
size_t | maxAbsIndex (Parts element, size_t k, size_t r) const |
size_t | maxAbsIndexRow (size_t i, size_t r=0) const |
size_t | maxAbsIndexCol (size_t j, size_t r=0) const |
NVector< T > & | vectorProduct (NVector< T > &u) const |
NPMatrix< T > & | matrixProduct (const NPMatrix< T > &m) |
NPMatrix< T > & | add (const NPMatrix< T > &m) |
NPMatrix< T > & | sub (const NPMatrix< T > &m) |
NPMatrix< T > & | opp () override |
NPMatrix< T > & | prod (T s) override |
NPMatrix< T > & | div (T s) override |
NPMatrix< T > & | pow (long exp) |
void | rPow (long exp) |
NPMatrix< T > & | inv () |
NVector< T > & | solve (NVector< T > &u) const |
void | lupClear () const |
void | lupReset () const |
void | lupCopy (const NPMatrix &m) const |
void | lupSelfCopy () const |
void | lupUpdate () const |
NPMatrix< T > & | clean () const |
NPMatrix< T > & | cleanBoth (const NPMatrix< T > &m) const |
bool | isValidRowIndex (size_t i) const |
bool | isValidColIndex (size_t j) const |
bool | isValidIndex (size_t i, size_t j) const |
bool | isBetweenI12 (size_t i) const |
bool | isBetweenJ12 (size_t j) const |
bool | matchSizeForProduct (const NVector< T > &u) const |
bool | matchSizeForProduct (const NPMatrix< T > &m) const |
bool | hasSameSize (const NPMatrix< T > &m) const |
bool | hasDefaultBrowseIndices () const override |
void | setDefaultBrowseIndices () const override |
NPMatrix< T > & | copy (const NPMatrix< T > &m) |
NPMatrix< T > & | copy (const vector< vector< T >> &data) |
size_t | vectorIndex (size_t i, size_t j) const |
size_t | getRowFromVectorIndex (size_t k) const |
size_t | getColFromVectorIndex (size_t k) const |
NPMatrix< T > | subMatrix (size_t i1=0, size_t j1=MAX_SIZE, size_t i2=0, size_t j2=MAX_SIZE) const |
NPMatrix< T > & | setSubMatrix (const NPMatrix< T > &m) |
NPMatrix< T > & | forEach (const NPMatrix< T > &m, const function< void(T &, const T &)> &binary_op) |
NPMatrix< T > & | forEach (T s, const function< void(T &, T)> &binary_op) override |
![]() | |
NVector (const std::vector< T > &data, size_t k1, size_t k2) | |
Vector with regularly spaced components. More... | |
NVector< T > & | add (const NVector< T > &u) |
NVector< T > & | sub (const NVector< T > &u) |
T | dotProduct (const NVector< T > &u) const |
T | norm () const |
T | distance (const NVector< T > &u) const |
bool | isValidIndex (size_t k) const |
bool | isBetweenK12 (size_t k) const |
bool | isNull () const |
bool | isEqual (const NVector< T > &u) const |
bool | hasSameSize (const NVector< T > &u) const |
NVector< T > & | forEach (const NVector< T > &u, const std::function< void(T &, const T &)> &binary_op) |
virtual NVector< T > & | forEach (T s, const std::function< void(T &, T)> &binary_op) |
NVector< T > & | copy (const NVector< T > &u) |
NVector< T > | subVector (size_t k1, size_t k2) const |
void | setSubVector (const NVector< T > &u) |
Static Protected Member Functions | |
static size_t | pIfNotNull (size_t n, size_t p) |
Protected Attributes | |
size_t | _n {} |
size_t | _p {} |
size_t | _i1 {} |
size_t | _j1 {} |
size_t | _i2 {} |
size_t | _j2 {} |
unique_ptr< NPMatrix< T > > | _a {} |
Matrix \( A = LU \) where \( PA = LU \) = this. More... | |
unique_ptr< vector< size_t > > | _perm {} |
permutation vector \( P \) such as \( PA = LU \). More... | |
![]() | |
size_t | _k1 {} |
size_t | _k2 {} |
Friends | |
bool | operator== (const NPMatrix< T > &a, const NPMatrix< T > &b) |
bool | operator!= (const NPMatrix< T > &a, const NPMatrix< T > &b) |
Algebraical Operators | |
Commons algebraical operations for matrix New algebraical operations are documented here. the operations that already exist in | |
NPMatrix< T > & | operator+= (const NPMatrix< T > &m) |
NPMatrix< T > & | operator-= (const NPMatrix< T > &m) |
NPMatrix< T > & | operator*= (const NPMatrix< T > &m) |
NPMatrix< T > & | operator*= (T s) override |
NPMatrix< T > & | operator/= (T s) override |
NPMatrix< T > & | operator^= (long exp) |
NPMatrix< T > | operator+ (NPMatrix< T > a, const NPMatrix< T > &b) |
NPMatrix< T > | operator- (NPMatrix< T > a, const NPMatrix< T > &b) |
NPMatrix< T > | operator- (NPMatrix< T > m) |
NPMatrix< T > | operator* (T s, NPMatrix< T > m) |
NPMatrix< T > | operator* (NPMatrix< T > m, T s) |
NPMatrix< T > | operator* (NPMatrix< T > a, const NPMatrix< T > &b) |
Usual matrix multiplication. More... | |
NVector< T > | operator* (const NPMatrix< T > &m, NVector< T > v) |
Usual matrix vector product (linear mapping). More... | |
NPMatrix< T > | operator/ (NPMatrix< T > m, T s) |
NPMatrix< T > | operator^ (NPMatrix< T > m, long exp) |
Exponantiate matrix \( M \) using given exponent. More... | |
NVector< T > | operator% (const NPMatrix< T > &m, NVector< T > v) |
Solve the linear system formed by \( M \) and \( v \). More... | |
T | operator| (const NPMatrix< T > &a, const NPMatrix< T > &b) |
T | operator! (const NPMatrix< T > &m) |
T | operator/ (const NPMatrix< T > &a, const NPMatrix< T > &b) |
NVector< T > & | operator*= (NVector< T > &u, const NPMatrix< T > &m) |
NVector< T > & | operator%= (NVector< T > &u, const NPMatrix< T > &m) |
Representation of dense matrices of arbitrary size in a template field T
.
The matrix components are stored in a linear form using the index transformation \( k = p i + j \). The underlying std::vector<T>
is represented as t[p * i + j]
. The underlying NVector<T>
is \( (A_{00}, A_{01}, ..., A_{0(P - 1)}, A_{10}, ..., A_{1(P - 1)}, ..., A_{(N-1)0}, ...) \).
Featuring algebraical operations such as matrix product, linear map, Gauss Jordan elimination. setters & getters, swappers and classic matrix generators such as ones, zeros...
The \form#3 decomposition is stored as a property if the matrix is inversible. It is auto-updated only when needed. It allow to compute inverse, determinant and other inversion related operations more efficiently.
The `NPMatrix` class provides a function operator similar to @ref FuncOpVec
All along this page we will use the following definitions : - `a`/`b`/`m`: A given `NPMatrix`. The components are noted are noted \form#4. By default, \form#5 denote `this` matrix. - `R` : Row of a matrix - `C` : Col of a matrix - `n ` : Number of rows - `p ` : Number of Columns - `i ` : Row Index between \form#6 - `j ` : Column Index \form#7 - `k`, `l` : either compound index or underlying `std::vector` array index.
Construct a \( n \times p \) matrix initialized with NVector(size_t dim)
constructor.
Construct a matrix using a bi-dimensional std::vector
. \( Aij \) represents data[i][j]
.
data | bi-dimensional std::vector source. |
All the data[i]
must have the same length. They are seen as the rows of the matrix. data
is copied into this
matrix using copy()
.
|
inline |
Construct a \( n \times p \) matrix using a bi-dimensional initializer list {{}}
.
list | bi-dimensional std::initializer_list source. |
Convert list
and uses bi-dimensional array constructor.
|
inlineexplicit |
Construct a \( n \) rows matrix using a std::vector
.
u | NVector source of size \( q \) |
n | number of rows formed by u |
The matrix is of size \( n \times p = q \) with \( p = q / n \). Resulting p
is computed using integer division so if reminder is not null a part of u
will be truncated.
|
inlineexplicit |
Construct a \( n \times p \) matrix using a vector<NVector<T>>
.` All the vectors must have the same dimension.
vectors | bi-dimensional std::vector source. |
Convert vectors
and uses bi-dimensional array constructor.
|
explicitprotected |
|
overridevirtual |
Create a string representing the matrix.
The returned string has the following form :
```commandline "(m(0,0), m(0,1), ..., m(0,(P-1))) (m(1,0), m(1,1), ..., m(1,(P-1))) (m(i,0), ..., a(i,j, Ai(P-1))) (m((N-1),0), ..., ..., ...)" `` Where
mis
thismatrix. Each row of
mis formatted using
NVector::str()`.
Reimplemented from NVector< T >.
|
inline |
bool NPMatrix< T >::isUpper | ( | ) | const |
bool NPMatrix< T >::isLower | ( | ) | const |
bool NPMatrix< T >::isDiagonal | ( | ) | const |
|
inline |
Number of rows \( n \).
|
inline |
Number of columns \( p \).
\( i^{th} \) row of the matrix as a NVector<T>
.
\( j^{th} \) column the matrix as a NVector<T>
.
vector< NVector< T > > NPMatrix< T >::rows | ( | size_t | i1 = 0 , |
size_t | i2 = MAX_SIZE |
||
) | const |
Create an array containing the rows of the matrix.
i1 | First row to be taken. |
i2 | Last row to be taken \( i_1 \leq i_2 \). |
The behavior of rows()
is the following :
rows()
returns all the rows.rows(i1)
returns the rows \( [R_{i1}, R_{(i1+1)},..., R_{(n-1)}] \)rows(i1, i2)
returns the rows \( [R_{i1}, R_{(i1+1)},..., R_{i2}] \)NVector
. Create a new matrix containing upper part of this matrix.
0
. Create a new matrix containing lower part of this matrix.
0
. \( L \) matrix of \( LU \) decomposition of the matrix.
\( U \) matrix of \( LU \) decomposition of the matrix.
Set row with given vector.
u | source NVector . |
i1 | index of row to set. |
The dimension of the vector must be inferior or equal to the number of columns.
NPMatrix< T > & NPMatrix< T >::setRows | ( | const vector< NVector< T >> & | vectors, |
size_t | i1 = 0 |
||
) |
Replace the components of the matrix with the array of vectors.
vectors | Rows to set on the matrix. std::vector of NVector<T> . |
i1 | First row to set. |
The input vectors
must verify the following conditions :
NVector<T>
must be inferior or equal to the number of columns.If i1 + vectors.size()
is greater than n
Then the algorithm truncate the array of NVector<T>
.
If the size of vectors
is \( n \times q \) than the setRows(vectors)
will return :
\[ \begin{bmatrix} v_{00} & ... & ... & ... & v_{0(p-1)} \\ v_{10} & ... & ... & ... & v_{1(p-1)} \\ ... & ... & ... & ... & ... \\ v_{(q-1)0} & ... & ... & ... & v_{(q-1)(p-1)} \\ A_{q0} & ... & ... & ... & A_{q(p-1)} \\ ... & ... & ... & ... & ... \\ A_{(n-1)0} & ... & ... & ... & A_{(n-1)(j1 - 1)} \\ \end{bmatrix} \]
Where \( v_{ij} \) represents vectors[i](j)
.
|
inline |
Swap \( A_{i_1j_1} \) and \( A_{i_2j_2} \).
i1 | first row indices to swap |
j1 | first col indices to swap |
i2 | second row indices to swap |
j2 | second col indices to swap |
Swap \( R_{i_1} \) and \( R_{i_2} \).
i1 | first row indices to swap |
i2 | second row indices to swap |
Swap \( C_{j_1} \) and \( C_{j_2} \).
j1 | first col indices to swap |
j2 | second col indices to swap |
shift the \( i^{th} \) row iterations
times.
i | index of row to shift |
iterations | number of times to shift. |
If iterations
is positive, shift is powered to the left, else to the right. For example shiftRow(0, 2)
will set the matrix to :
\[ \begin{bmatrix} A_{20} & A_{30} & ... & A_{(n-1)0} & A_{00} & A_{10} \\ ... & ... & ... & ... & ... & ... \\ ... & ... & ... & ... & ... & ... \\ A_{(n-1)0} & A_{(n-1)1} & ... & ... & ... & A_{(n-1)(p-1)}\\ \end{bmatrix} \]
shift the \( j^{th} \) column iterations
times.
j | index of column to shift |
iterations | number of times to shift. |
The behavior is analog to shiftRow()
. If iterations
is positive, shift is powered to the up, else to the bottom.
Transposed matrix.
T NPMatrix< T >::trace | ( | ) | const |
Trace of this matrix \( A_{00} + A_{11} + ... + A_{(n-1)(n-1)} \).
Concatenate matrix m
to this
matrix.
m | Matrix to concatenate. |
The shifted matrix is the matrix obtained after concatenation of \( A \) and \( M \) columns. \( A \) and \( M \) must have the same number of rows.
Apply Gauss Jordan elimination on matrix to calculate inverse without using \( LU \) decomposition.
To perform inverse computation, shift the matrix you want to invert than apply this function. If the matrix is inversible, than the inverse of the matrix is on the right part of the matrix. \( O(n^3) \).
*this
the shifted matrix. T NPMatrix< T >::det | ( | ) | const |
determinant of this matrix \( det(A) \). Using the \( LU \) decomposition \( O(n) \).
Reimplemented from NVector< T >.
Reimplemented from NVector< T >.
|
inline |
Bi-dimensional access operator.
Access operator equivalent to [i][j]
on bi-dimensional arrays. The behavior is analog to NVector::operator()(long)
except that negatives values are disallowed. For example, A(0, 0)
return the element located at first row and first column.
|
inline |
|
inline |
Manipulate sub-matrix.
i1 | first row to take |
j1 | first col to take |
i2 | last row to take \( n \gt i_2 \geq i_1 \geq 0 \) |
j2 | last row to take \( p \gt j_2 \geq j_1 \geq 0 \) of columns |
This operator is similar to NVector<T>::operator()(size_t, size_t) const "vector sub-range operator". It allows operations on a restricted range of the matrix :
\[ \begin{bmatrix} A_{i_1j_1} & ... & A_{i_2j_1} \\ ... & ... & ... \\ A_{i_2j_1} & ... & A_{i_2j_2} \\ \end{bmatrix} \]
For example, a(0, 0, 1, 1)
will return the value of the \( 2 \times 2 \) upper-left matrix :
\[ \begin{bmatrix} A_{00} & A_{01} \\ A_{10} & A_{11} \\ \end{bmatrix} \]
NPMatrix< T > & NPMatrix< T >::operator() | ( | size_t | i1, |
size_t | j1, | ||
size_t | i2, | ||
size_t | j2 | ||
) |
Manipulate sub-matrix.
This operator is similar to previous operator()(size_t, size_t, size_t, size_t) const "operator" except that it sets browse indices. See NVector
operator for more details.
*this
.
|
inlinestatic |
\( n \times p \) matrix filled with 0
.
\( n \times p \) matrix filled with 1
.
|
inlinestatic |
\( n \times p \) canonical matrix
i | Row where to put 1. |
j | Col where to put 1. |
canonical matrices \( E_{ij} \) of \( M_{np}(K) \) which contains 1
in position \( ij \) and 0
elsewhere. This matrix is eviqualent to \( \delta_{ij} \) Kronecker's delta symbol.
\( n^{th} \) order identity matrix
n | Size of the matrix |
|
static |
diagonal \( n^{th} \) order diagonal matrix filled with data array.
data | values of diagonal [ \( d_0, d_1, ..., d_{(n-1)} \)] . |
n | size of the matrix. |
a scalar \( n^{th} \) order matrix with s
value
n | size of the matrix |
s | scalar value |
Scalar matrices are a diagonal matrix filled a unique value.
|
static |
Fills a square matrix matrix by giving diagonal data.
data | values of diagonals as std::vector of NVector . |
This method is a generalization of diag()
method. The resulting matrix looks like :
\[ \begin{bmatrix} d_{(mid)0} & d_{(mid+1)0} & ... & d_{(2 mid-1)0} \\ d_{(mid-1)0} & d_{(mid)1} & ... & d_{(2 mid-2)1} \\ ... & ... & ... & ...\\ d_{(0)0} & d_{(1)1} & ... & d_{(mid)(n-1)} \\ \end{bmatrix} \]
Where \form#62 is the representation of `data[l](k)`. The `data` array should be as following : - `data[l]` is the values of coefficients of the \form#63 sub-diagonal from the left/up. - `data[middle]` is the values of coefficients on the diagonal. The input data must be ordered such as `d[0]` has size equal to `1`, `d[1]` to `2`, ..., `d[middle]` to `n`, `d[middle+1]` to `n-1`, ..., `d[2 * middle - 1]` to `1`.
data
.
|
static |
Generalization of scalar matrix with multiple diagonal.
scalars | array of scalars values to fill diagonals [ \( s_0, s_1, ..., s_{q-1} \) ] . |
n | size of the matrix. |
The behavior is a restriction of ndiag()
method, the matrix is filled using diagonals containing the same value all along.
For example if nscalar({2, 1}, 3)
will return :
\[ \begin{bmatrix} 1 & 2 & 0 \\ 2 & 1 & 2 \\ 0 & 2 & 1 \\ \end{bmatrix} \]
Center diagonal is filled with s1 and the other diagonal are filled with s0.
scalars
.
|
protected |
|
protected |
|
protected |
|
inlineprotected |
|
inlineprotected |
|
protected |
|
protected |
Reimplemented from NVector< T >.
Reimplemented from NVector< T >.
Reimplemented from NVector< T >.
|
protected |
|
protected |
|
protected |
|
inlineprotected |
|
protected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlinestaticprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
overrideprotectedvirtual |
Reimplemented from NVector< T >.
|
overrideprotectedvirtual |
Reimplemented from NVector< T >.
|
protected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
protected |
|
protected |
|
protected |
|
overrideprotected |
Usual matrix multiplication.
The matrices must have the length. Natural \( O(n^3) \) matrix product is used.
Usual matrix vector product (linear mapping).
The number of rows of m must be equal to the dimension of \( v \). Natural \( O(n^2) \) linear mapping is used.
Exponantiate matrix \( M \) using given exponent.
m | matrix to exponentiate. |
exp | exponent. |
Fast exponentiation implementation. If \( exp < 0 \) we calculate the power of the inverse matrix using inv()
method.
Solve the linear system formed by \( M \) and \( v \).
m | matrix of the equation system. |
v | second member of the equation system. |
The linear system is \( MX = v \) where \( X \) is unknown. This algorithm uses \( LU \) decomposition.
|
friend |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
mutableprotected |
|
mutableprotected |
Matrix \( A = LU \) where \( PA = LU \) = this.
_a
points to the \( A \) NMatrix or to nullptr
if the matrix don't have \( LU \) decomposition.
|
mutableprotected |
permutation vector \( P \) such as \( PA = LU \).
Represented as unsigned long
array.