|
Basix
|
Matrix and permutation pre-computation. More...
Functions | |
| void | prepare_permutation (std::span< std::size_t > perm) |
| Prepare a permutation. | |
| template<typename E> | |
| void | apply_permutation (std::span< const std::size_t > perm, std::span< E > data, std::size_t offset=0, std::size_t n=1) |
| Apply a (precomputed) permutation \(v = P u\). | |
| template<typename E> | |
| void | apply_permutation_mapped (std::span< const std::size_t > perm, std::span< E > data, std::span< const int > emap, std::size_t n=1) |
| Permutation of mapped data. | |
| template<typename E> | |
| void | apply_inv_permutation_right (std::span< const std::size_t > perm, std::span< E > data, std::size_t offset=0, std::size_t n=1) |
| Apply a (precomputed) permutation to some transposed data. | |
| template<std::floating_point T> | |
| std::vector< std::size_t > | prepare_matrix (std::pair< std::vector< T >, std::array< std::size_t, 2 > > &A) |
| Prepare a square matrix. | |
| template<typename T, typename E> | |
| void | apply_matrix (std::span< const std::size_t > v_size_t, md::mdspan< const T, md::dextents< std::size_t, 2 > > M, std::span< E > data, std::size_t offset=0, std::size_t n=1) |
| Apply a (precomputed) matrix. | |
| template<typename T, typename E> | |
| void | apply_tranpose_matrix_right (std::span< const std::size_t > v_size_t, md::mdspan< const T, md::dextents< std::size_t, 2 > > M, std::span< E > data, std::size_t offset=0, std::size_t n=1) |
| Apply a (precomputed) matrix to some transposed data. | |
Matrix and permutation pre-computation.
| void basix::precompute::prepare_permutation | ( | std::span< std::size_t > | perm | ) |
Prepare a permutation.
Computes representation of the permutation that allows the permutation to be applied without any temporary memory assignment. In pseudo code, this function does the following:
Consider the permutation P = [1, 4, 0, 5, 2, 3].
Hence, the output of this function in this case is [1, 4, 4, 5, 4, 5].
For an example of how the permutation in this form is applied, see apply_permutation().
| [in,out] | perm | A permutation. |
| void basix::precompute::apply_permutation | ( | std::span< const std::size_t > | perm, |
| std::span< E > | data, | ||
| std::size_t | offset = 0, | ||
| std::size_t | n = 1 ) |
Apply a (precomputed) permutation \(v = P u\).
This uses the representation returned by prepare_permutation() to apply a permutation without needing any temporary memory. In pseudo code, this function does the following:
If n is set, this will apply the permutation to every block. The offset is set, this will start applying the permutation at the offsetth block.
Consider the permutation P = [1, 4, 0, 5, 2, 3]. In the documentation of prepare_permutation(), we saw that the precomputed representation of this permutation is P2 = [1, 4, 4, 5, 4, 5]. In this example, we look at how this representation can be used to apply this permutation to the array A = [a, b, c, d, e, f].
Therefore the result of applying this permutation is [b, e, a, f, c, d] (which is what we get if we apply the permutation directly).
| [in] | perm | A permutation in precomputed form (as returned by prepare_permutation()). |
| [in,out] | data | The data to apply the permutation to. It has shape (m, n) (uses row-major storage), where the permutation matrix has shape (m, m). |
| [in] | offset | The position in the data to start applying the permutation. |
| [in] | n | The block size of the data. |
| void basix::precompute::apply_inv_permutation_right | ( | std::span< const std::size_t > | perm, |
| std::span< E > | data, | ||
| std::size_t | offset = 0, | ||
| std::size_t | n = 1 ) |
Apply a (precomputed) permutation to some transposed data.
Applies \(v = u P^{T}\).
See apply_permutation().
| std::vector< std::size_t > basix::precompute::prepare_matrix | ( | std::pair< std::vector< T >, std::array< std::size_t, 2 > > & | A | ) |
Prepare a square matrix.
Computes the LU decomposition of the transpose of the matrix.
This function returns the permutation \(P\)P in the representation \(PA^t=LU\) (precomputed as in prepare_permutation()). The LU decomposition of \(A^t\) is computed in-place
For an example of how the permutation in this form is applied, see apply_matrix().
| [in,out] | A | The matrix data. |
| void basix::precompute::apply_matrix | ( | std::span< const std::size_t > | v_size_t, |
| md::mdspan< const T, md::dextents< std::size_t, 2 > > | M, | ||
| std::span< E > | data, | ||
| std::size_t | offset = 0, | ||
| std::size_t | n = 1 ) |
Apply a (precomputed) matrix.
This uses the representation returned by prepare_matrix() to apply a matrix without needing any temporary memory. In pseudo code, this function does the following:
If n is set, this will apply the permutation to every block. The offset is set, this will start applying the permutation at the offsetth block.
| [in] | v_size_t | A permutation, as computed by prepare_matrix(). |
| [in] | M | The vector created by prepare_matrix(). |
| [in,out] | data | The data to apply the permutation to |
| [in] | offset | The position in the data to start applying the permutation |
| [in] | n | The block size of the data |
| void basix::precompute::apply_tranpose_matrix_right | ( | std::span< const std::size_t > | v_size_t, |
| md::mdspan< const T, md::dextents< std::size_t, 2 > > | M, | ||
| std::span< E > | data, | ||
| std::size_t | offset = 0, | ||
| std::size_t | n = 1 ) |
Apply a (precomputed) matrix to some transposed data.
Computes \(v^{T} = M u^{T}\) (or equivalently \(v = u M^{T}\)).
See apply_matrix().