Table 6 List of functions implemented for the Matrix<M,N> class.

From: A new advance on dimensional-aware scalar, vector and matrix operations in C++

Operation

Method

Description

Note

\({\mathcal {A}}_{i-1,j-1}\)

a(i,j)

Element access (1-based)

 

\({\mathcal {A}}_{i,j}\)

a[i,j]

Element access (0-based)

 
 

a.rowMajor(x)

Element access (row-major)

 
 

a.colMajor(x)

Element access (column-major)

 

m

a.rows

Rows count

 

n

a.columns

Columns count

 

\({\mathcal {A}}_{i,*}\)

a.row()

Returns a specified row

 

\({\mathcal {A}}_{*,j}\)

a.col()

Returns a specified column

 

\(m=n\)

a.square

Check if square

 

\( {\mathcal {A}}_{i_2,*} \leftarrow {\mathcal {A}}_{i_2,*} + {\mathcal {A}}_{i_1,*}\)

a.rowAdd(i1, i2)

Row addition and store

\(*\)

\( {\mathcal {A}}_{i_2,*} \leftarrow {\mathcal {A}}_{i_2,*} - {\mathcal {A}}_{i_1,*}\)

a.rowSub(i1, i2)

Row subtraction and store

\(*\)

\( {\mathcal {A}}_{i,*} \leftarrow {\mathcal {A}}_{i,*} \cdot s\)

a.rowMul(i, s)

Row multiplication

\(*\)

\( {\mathcal {A}}_{i,*} \leftarrow {\mathcal {A}}_{i,*} / s\)

a.rowDiv(i, s)

Row division

\(*\)

\( {\mathcal {A}}_{i_1,*} \leftrightarrow {\mathcal {A}}_{i_2,*}\)

a.rowSwap(i1, i2)

Row swap

\(*\)

 

a.reverseRows()

Reverse the rows

\(*\)

 

a.shuffleRows()

Shuffles the rows

\(*\)

 

a.sortRows()

Sorts the rows

\(*\)

\( {\mathcal {A}}_{*,j_2} \leftarrow {\mathcal {A}}_{*,j_2} + {\mathcal {A}}_{*,j_1}\)

a.colAdd(j1, j2)

Column addition and store

\(*\)

\( {\mathcal {A}}_{*,j_2} \leftarrow {\mathcal {A}}_{*,j_2} - {\mathcal {A}}_{*,j_1}\)

a.colSub(j1, j2)

Column subtraction and store

\(*\)

\( {\mathcal {A}}_{*,j} \leftarrow {\mathcal {A}}_{*,j} \cdot s\)

a.colMul(j, s)

Column multiplication

\(*\)

\( {\mathcal {A}}_{*,j} \leftarrow {\mathcal {A}}_{*,j} / s\)

a.colDiv(j, s)

Column division

\(*\)

\( {\mathcal {A}}_{*,j_1} \leftrightarrow {\mathcal {A}}_{*,j_2}\)

a.colSwap(j1, j2)

Column swap

\(*\)

 

a.reverseCols()

Reverse the columns

\(*\)

 

a.shuffleCols()

Shuffle the columns

\(*\)

 

a.sortCols()

Sorts the columns

\(*\)

\(o({\mathcal {A}})\)

a.order()

Order

\(\dagger \)

\(O({\mathcal {A}})\)

a.orders()

Order (in \(m \times n \) form)

 

\(\text {adj}({\mathcal {A}})\)

a.adj()

Ajugate

\(\dagger \)

\(c_{m,n}\)

a.cofactor(m,n)

Cofactor element

\(\dagger \)

\(C_{m,n}\)

a.cofactors(m,n)

Cofactor matrix

\(\dagger \)

\(\det ({\mathcal {A}})\)

a.det()

Determinant

\(\dagger \)

\(\text {tr}({\mathcal {A}})\)

a.tr()

Trace

\(\dagger \)

\({\mathcal {A}}^T\)

a.t()

Transpose

\(*\)

\({\overline{A}}\)

a.conj()

Conjugate

\(*\)

\({\mathcal {A}}^H\)

a.conjT()

Conjugate transpose

\(*\)

\({\mathcal {A}}_{i,j} \leftarrow 0 \quad \text {if} |{A}_{i,j}| < t \)

a.zap(t)

Set to zero small elements

\(*\)

\({\mathcal {A}}^{-1}\)

a.inv()

Inverse

\(\dagger \)

\({\mathcal {A}}^{+}\)

a.pseudoInv()

Moore–Penrose inverse

 

\({\mathcal {A}}[m;n]\)

a.sub(n,m)

Submatrix

 

\(m_{m,n}\)

a.minor(m,n)

Minor element

\(\dagger \)

\(M_{m,n}\)

a.minors(m,n)

Minor matrix

\(\dagger \)

\(({\mathcal {A}}_{1,1},{\mathcal {A}}_{2,2}, \ldots , {\mathcal {A}}_{n,n})\)

a.diagonal()

Diagonal elements

\(\dagger \)

\({\mathcal {A}}_{1,1} \cdot {\mathcal {A}}_{2,2} \cdot \ldots \cdot {\mathcal {A}}_{n,n})\)

a.diagonalProduct()

Product of the diagonal elements

\(\dagger \)

\(\langle {\mathcal {A}}, {\mathcal {B}} \rangle _F\)

a.frobenius(b)

Frobenius inner product

 

\(\sum {\mathcal {A}}_{i,j}\)

a.grandSum()

Sum of all elements

 

\({\mathcal {A}} \oplus {\mathcal {B}}\)

a.directSum(b)

Direct sum

 

\({\mathcal {A}} \otimes {\mathcal {I}}_b + {\mathcal {I}}_a \otimes {\mathcal {B}}\)

a.kroneckerSum(b)

Kronecker sum

 

\({\mathcal {A}} \otimes {\mathcal {B}}\)

a.kroneckerProduct(b)

Kronecker product

 

\({\mathcal {A}}_{i,j} \cdot {\mathcal {B}}_{i,j}\)

a.elementwiseProduct()

Element-wise product

 

\({\mathcal {A}}_{i,j} / {\mathcal {B}}_{i,j}\)

a.elementwiseDivision()

Element-wise divisison

 
 

a.reduction(type)

Performs the reduction of the matrix

\(*\)

  1. The \(\dagger \) symbol marks operations available for square matrix only, while \(\ddagger \) symbols is available for row or column matrix only. The \(*\) marks the disponibility of an extra operation, which starts with do prefix (e.g. doColSwap), that works inplace on the matrix. Matrix indices are zero-based.