DenseMatrix
-
template<typename T, Int ROWS, Int COLS = ROWS>
class DenseMatrix Dense matrix with
ROWSrows andCOLScolumns.Entries are stored in row-major format
- Template Parameters:
T – Data type of matrix entries
ROWS – Number of rows
COLS – Number of columns
Subclassed by godzilla::DenseVector< Real, DIM >
Public Functions
-
inline int get_num_rows() const
Get the number of rows.
- Returns:
The number of rows
-
inline int get_num_cols() const
Get the number of columns.
- Returns:
The number of columns
-
inline const T &get(Int row, Int col) const
Get entry at specified location for reading.
- Parameters:
row – Row number
col – Column number
- Returns:
Entry at the specified location
-
inline DenseMatrix<T, ROWS, 1> column(Int idx) const
Obtain a column from the matrix.
- Parameters:
idx – Index of the column
- Returns:
Column as a DenseVector
-
inline DenseMatrix<T, 1, COLS> row(Int idx) const
Obtain a column from the matrix.
- Parameters:
idx – Index of the column
- Returns:
Column as a DenseVector
-
inline T &set(Int row, Int col)
Get entry at specified location for writing.
- Parameters:
row – Row number
col – Column number
- Returns:
Entry at the specified location
-
inline void set(Int row, Int col, const T &val)
Set value at a specified location.
- Parameters:
row – Row number
col – Column number
val – Value to set at position (row, col)
-
inline void set_row(Int row, const std::vector<T> &vals)
Set a matrix row at once.
This is a convenience method
- Parameters:
row – Row number
vals – Values of the row.
valsmust haveCOLSvalues.
-
inline void set_row(Int row, const DenseVector<T, COLS> &vals)
Set a matrix row at once.
This is a convenience method
- Parameters:
row – Row number
vals – Values of the row
-
inline void set_col(Int col, const DenseVector<T, ROWS> &vals)
Set a matrix column at once.
This is a convenience method
- Parameters:
col – Column number
vals – Values of the column
-
inline void zero()
Set all matrix entries to zero, i.e. mat[i,j] = 0.
-
inline void set_values(const T &alpha)
Set
alphainto all matrix entries, i.e.mat[i, j] = alpha
- Parameters:
alpha – Value to set into matrix entries
-
inline void scale(Real alpha)
Multiply all entries by a scalar value.
- Parameters:
alpha – Value to multiple the matrix entries with
-
inline void add(const DenseMatrix<T, ROWS, COLS> &x)
Add matrix
xto this matrix.- Parameters:
x – Matrix to add
-
inline void add(const DenseMatrixSymm<T, ROWS> &x)
Add matrix
xto this matrix.- Parameters:
x – Matrix to add
-
inline void subtract(const DenseMatrix<T, ROWS, COLS> &x)
Subtract matrix
xfrom this matrix.- Parameters:
x – Matrix to subtract
-
inline void subtract(const DenseMatrixSymm<T, ROWS> &x)
Subtract matrix
xfrom this matrix.- Parameters:
x – Matrix to subtract
-
inline DenseVector<T, ROWS> mult(const DenseVector<T, COLS> &x) const
Multiply the matrix by a vector.
Vector size must be equal to the number of columns
- Parameters:
x – Vector to multiply by
- Returns:
Resulting vector
-
inline DenseMatrix<T, COLS, ROWS> transpose() const
Compute transpose.
- Returns:
Transposed matrix
-
inline DenseVector<T, COLS> diagonal() const
Get diagonal of the matrix as a DenseVector.
- Returns:
Matrix diagonal as a vector
-
inline const T &operator()(Int row, Int col) const
Get a value at position (row, col) for reading.
- Parameters:
row – Row number
col – Col number
- Returns:
Value at the position (row, col)
-
inline T &operator()(Int row, Int col)
Get a value at position (row, col) for writing.
- Parameters:
row – Row number
col – Col number
- Returns:
Value at position (row, col)
-
inline DenseMatrix<T, ROWS, COLS> operator+(const DenseMatrix<T, ROWS, COLS> &a) const
Add matrix
ato this matrix and return the result.- Parameters:
a – Matrix to add
- Returns:
Resulting matrix
-
inline DenseMatrix<T, ROWS> operator+(const DenseMatrixSymm<T, ROWS> &a) const
Add matrix
ato this matrix and return the result.This matrix must be a square matrix
- Parameters:
a – Matrix to add
- Returns:
Resulting matrix
-
inline DenseMatrix<T, ROWS, COLS> &operator+=(const DenseMatrix<T, ROWS, COLS> &a)
Add matrix to this matrix.
- Parameters:
a – Matrix to add
- Returns:
Resulting matrix, i.e.
this + a
-
inline DenseMatrix<T, ROWS, COLS> operator-(const DenseMatrix<T, ROWS, COLS> &a) const
Subtract matrix
afrom this matrix and return the result.- Parameters:
a – Matrix to subtract
- Returns:
Resulting matrix
-
inline DenseMatrix<T, ROWS> operator-(const DenseMatrixSymm<T, ROWS> &a) const
Subtract matrix
afrom this matrix and return the result.This matrix must be a square matrix
- Parameters:
a – Matrix to subtract
- Returns:
Resulting matrix
-
inline DenseMatrix<T, ROWS, COLS> operator*(Real alpha) const
Multiply this matrix with a scalar value.
- Parameters:
alpha – Value to multiply with
- Returns:
Resulting matrix
-
inline DenseVector<T, ROWS> operator*(const DenseVector<T, COLS> &rhs) const
Multiply this matrix with a vector.
- Parameters:
rhs – Vector to multiply with
- Returns:
Resulting vector
DynDenseMatrix
Warning
doxygenclass: Cannot find class “godzilla::DynDenseMatrix” in doxygen xml output for project “godzilla” from directory: /home/runner/work/godzilla/godzilla/build/docs/xml/