maliput
|
A squared N-dimensional matrix.
N | Indicates the dimension of the matrix. Dimension must be 1x1 or greater. |
#include <include/maliput/math/matrix.h>
Public Member Functions | |
Matrix ()=default | |
Constructs a N x N matrix filled with zeros. More... | |
Matrix (const std::initializer_list< double > &values) | |
Constructs a N x N matrix from a list of double. More... | |
Matrix (const std::initializer_list< Vector< N >> &rows) | |
Constructs a N x N matrix from a list of Vector<N>. More... | |
Matrix (std::array< Vector< N >, N > rows) | |
Constructs a N x N matrix from an array of Vector<N>. More... | |
Matrix (const Matrix< N > &other)=default | |
Copy constructor. More... | |
Matrix (Matrix< N > &&other)=default | |
Move constructor. More... | |
const Vector< N > | row (std::size_t index) const |
Returns the index -th row of the matrix. More... | |
const Vector< N > | col (std::size_t index) const |
Returns the index -th column of the matrix. More... | |
Matrix< N > | transpose () const |
Matrix< N - 1 > | reduce (std::size_t row, std::size_t col) const |
Reduce the matrix's dimension. More... | |
double | cofactor (std::size_t row, std::size_t col) const |
Calculates the cofactor of the element at row and col . More... | |
double | determinant () const |
Computes the determinant. More... | |
bool | is_singular () const |
Determine the singularity. More... | |
Matrix< N > | cofactor () const |
Matrix< N > | adjoint () const |
Matrix< N > | inverse () const |
Matrix< N > & | operator= (const Matrix< N > &other) |
Assignment operator overload. More... | |
Matrix< N > & | operator= (const Matrix< N > &&other) |
Move assignment operator overload. More... | |
const Vector< N > & | operator[] (std::size_t index) const |
Constant subscripting array operator overload. More... | |
Vector< N > & | operator[] (std::size_t index) |
Subscripting array operator overload. More... | |
bool | operator== (const Matrix< N > &matrix) const |
Equality operator overload. More... | |
bool | operator!= (const Matrix< N > &matrix) const |
Inequality operator overload. More... | |
Matrix< N > | operator+ (const Matrix< N > &matrix) const |
Add operator overload. More... | |
Matrix< N > | operator- (const Matrix< N > &matrix) const |
Substract operator overload. More... | |
Matrix< N > | operator* (const Matrix< N > &matrix) const |
Product operator overload between Matrix<N>s. More... | |
Matrix< N > | operator/ (double k) const |
Divide operator overload between this and a scalar. More... | |
double | cofactor (std::size_t row, std::size_t col) const |
Static Public Member Functions | |
static Matrix< N > | Identity () |
Static Public Attributes | |
static constexpr double | kTolerance = 1e-15 |
Tolerance value to determine the singularity of the matrix. More... | |
Friends | |
template<std::size_t N_> | |
Matrix< N_ > | operator* (const Matrix< N_ > &matrix, double k) |
Product operator overload between a Matrix<N> and a scalar. More... | |
template<std::size_t N_> | |
Matrix< N_ > | operator* (double k, const Matrix< N_ > &matrix) |
Product operator overload between a scalar and a Matrix<N>. More... | |
template<std::size_t N_> | |
std::ostream & | operator<< (std::ostream &os, const Matrix< N_ > &matrix) |
Serialization operator overload. More... | |
|
default |
Constructs a N x N matrix filled with zeros.
Constructs a N x N matrix from a list of double.
values | Elements of the matrix. The size of values must match NxN. Elements will fill the matrix's rows from top to bottom. |
common::assertion_error | When N is not positive. |
common::assertion_error | When values size is not NxN. |
Constructs a N x N matrix from a list of Vector<N>.
rows | Rows of the matrix. The size of rows must be N. It fills the matrix from the 0-th to N-1-th. |
common::assertion_error | When rows size is not N. |
Constructs a N x N matrix from an array of Vector<N>.
rows | Rows of the matrix. The size of rows must match with N. It fills the matrix from top to bottom. |
Matrix< N > adjoint |
common::assertion_error | When N is one. |
Matrix< N > cofactor |
common::assertion_error | When N is one. |
double cofactor | ( | std::size_t | row, |
std::size_t | col | ||
) | const |
Calculates the cofactor of the element at row
and col
.
row | Index of the matrix's rows. It must be in [0, N). |
col | Index of the matrix's cols. It must be in [0, N). |
common::assertion_error | When row or col are not in [0, N). |
common::assertion_error | When N is one. |
double cofactor | ( | std::size_t | row, |
std::size_t | col | ||
) | const |
const Vector< N > col | ( | std::size_t | index | ) | const |
Returns the index
-th column of the matrix.
index | Column number. It must be in [0, N). |
common::assertion_error | When index is not in the range [0, N). |
double determinant |
Computes the determinant.
|
static |
Matrix< N > inverse |
common::assertion_error | When matrix is singular. |
bool is_singular |
Determine the singularity.
this
matrix is singular. bool operator!= | ( | const Matrix< N > & | matrix | ) | const |
Inequality operator overload.
Product operator overload between Matrix<N>s.
Move assignment operator overload.
other | Matrix<N> object. |
Assignment operator overload.
other | Matrix<N> object. |
bool operator== | ( | const Matrix< N > & | matrix | ) | const |
Equality operator overload.
Vector< N > & operator[] | ( | std::size_t | index | ) |
Subscripting array operator overload.
index | The index of the matrix row. It must be in [0, N). |
index
.common::assertion_error | When index is out of range. |
const Vector< N > & operator[] | ( | std::size_t | index | ) | const |
Constant subscripting array operator overload.
index | The index of the matrix row. It must be in [0, N). |
index
.common::assertion_error | When index is out of range. |
Matrix< N - 1 > reduce | ( | std::size_t | row, |
std::size_t | col | ||
) | const |
Reduce the matrix's dimension.
N must be at least 2 to be reducible.
row | Is the number of the row to be removed. It must be in [0, N). |
col | Is the number of the column to be removed. It must be in [0, N). |
row
-th row and col
-th column.common::assertion_error | When row or col are not in [0, N). |
common::assertion_error | When N is less than two. |
const Vector< N > row | ( | std::size_t | index | ) | const |
Returns the index
-th row of the matrix.
index | Row number. It must be in [0, N). |
common::assertion_error | When index is not in the range [0, N). |
Matrix< N > transpose |
this
transpose. Product operator overload between a Matrix<N> and a scalar.
Product operator overload between a scalar and a Matrix<N>.
|
friend |
Serialization operator overload.
|
staticconstexpr |
Tolerance value to determine the singularity of the matrix.