|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
Implicit permutation matrix – stores only perm vector, O(n) storage. More...
#include <permutation_matrix.hpp>
Public Types | |
| using | value_type = Value |
| using | size_type = std::size_t |
| using | const_reference = Value |
| using | reference = Value |
Public Member Functions | |
| permutation_matrix (std::vector< size_type > perm) | |
| Construct from permutation vector: perm[i] = column of the 1 in row i. | |
| permutation_matrix (std::initializer_list< size_type > perm) | |
| Construct from a braced list of entries: P({2, 0, 1}), and P({0}) is the 1x1 permutation. | |
| permutation_matrix (size_type n) | |
| Construct identity permutation of size n. | |
| value_type | operator() (size_type r, size_type c) const |
| size_type | num_rows () const |
| size_type | num_cols () const |
| size_type | size () const |
| const std::vector< size_type > & | permutation () const |
| Direct access to the permutation vector. | |
| void | swap_rows (size_type i, size_type j) |
| Swap rows i and j (elementary row transposition). | |
| permutation_matrix | inverse () const |
| Return the inverse permutation matrix (transpose). | |
Implicit permutation matrix – stores only perm vector, O(n) storage.
Row i maps to column perm[i]: P(i, j) = (perm[i] == j) ? 1 : 0
| using mtl::mat::permutation_matrix< Value >::const_reference = Value |
| using mtl::mat::permutation_matrix< Value >::reference = Value |
| using mtl::mat::permutation_matrix< Value >::size_type = std::size_t |
| using mtl::mat::permutation_matrix< Value >::value_type = Value |
|
inlineexplicit |
Construct from permutation vector: perm[i] = column of the 1 in row i.
It must be a permutation of 0..n-1, checked once, in every build (#826): a duplicate or out-of-range entry made inverse() and P * x index out of bounds. Throws std::invalid_argument (throw_or_abort).
|
inline |
Construct from a braced list of entries: P({2, 0, 1}), and P({0}) is the 1x1 permutation.
Without it, {0} picked the size constructor and gave a 0x0 matrix, and {2} the 2x2 identity (#826). For the identity of size n, use P(n) with parentheses.
|
inlineexplicit |
Construct identity permutation of size n.
|
inline |
Return the inverse permutation matrix (transpose).
|
inline |
|
inline |
|
inline |
|
inline |
Direct access to the permutation vector.
|
inline |
|
inline |
Swap rows i and j (elementary row transposition).