gko::matrix::Permutation#
Row/column permutation operator. Stores a permutation array;
apply(b, x) permutes the rows of b into x. Used to apply
reorderings (RCM, AMD, MC64, nested dissection) and as the
permutation half of ScaledPermutation.
-
template<typename IndexType = int32>
class Permutation # Inherits from
public gko::EnableLinOp<Permutation<int32>>
public gko::WritableToMatrixData<default_precision, int32>
Permutation is a matrix format that represents a permutation matrix, i.e. a matrix where each row and column has exactly one entry. The matrix can only be applied to Dense inputs, where it represents a row permutation: \(A' = PA\) means \(A'(i, j) = A(p[i], j)\).
- Template Parameters:
IndexType – precision of permutation array indices.
Public Functions
-
inline index_type *get_permutation() noexcept#
Returns a pointer to the array of permutation.
- Returns:
the pointer to the row permutation array.
-
inline const index_type *get_const_permutation() const noexcept#
Returns a pointer to the array of permutation.
Note
This is the constant version of the function, which can be significantly more memory efficient than the non-constant version, so always prefer this version.
- Returns:
the pointer to the row permutation array.
-
size_type get_permutation_size() const noexcept#
Returns the number of elements explicitly stored in the permutation array.
- Returns:
the number of elements explicitly stored in the permutation array.
-
std::unique_ptr<Permutation> compute_inverse() const#
Returns the inverse permutation.
- Returns:
a newly created Permutation object storing the inverse permutation of this Permutation.
- std::unique_ptr<Permutation> compose(
- ptr_param<const Permutation> other,
Composes this permutation with another permutation. The resulting permutation fulfills
result[i] = this[other[i]]orresult = other * thisfrom the matrix perspective, which is equivalent to first permuting bythisand then byother: Combining permutations \(P_1\) and \(P_2\) withP = P_1.combine(P_2)performs the operation permute(A, P) = permute(permute(A, P_1), P_2).- Parameters:
other – the other permutation
- Returns:
the combined permutation
Public Static Functions
- std::shared_ptr<const Executor> exec,
- size_type size = 0,
Creates an uninitialized Permutation arrays on the specified executor.
- Parameters:
exec – Executor associated to the LinOp
- Returns:
A smart pointer to the newly created matrix.
-
)#
Creates a Permutation matrix from an already allocated (and initialized) row and column permutation arrays.
Note
If
permutation_indicesis not an rvalue, not an array of IndexType, or is on the wrong executor, an internal copy will be created, and the original array data will not be used in the matrix.- Parameters:
exec – Executor associated to the matrix
size – size of the permutation array.
permutation_indices – array of permutation array
enabled_permute – mask for the type of permutation to apply.
- Returns:
A smart pointer to the newly created matrix.
- std::shared_ptr<const Executor> exec,
- size_type size,
- gko::detail::const_array_view<IndexType> &&perm_idxs,
- mask_type enabled_permute = row_permute,
Creates a constant (immutable) Permutation matrix from a constant array.
- Parameters:
exec – the executor to create the matrix on
size – the size of the square matrix
perm_idxs – the permutation index array of the matrix
enabled_permute – the mask describing the type of permutation
- Returns:
A smart pointer to the constant matrix wrapping the input array (if it resides on the same executor as the matrix) or a copy of the array on the correct executor.
-
)#
Creates a constant (immutable) Permutation matrix from a constant array.
- Parameters:
exec – the executor to create the matrix on
size – the size of the square matrix
perm_idxs – the permutation index array of the matrix
enabled_permute – the mask describing the type of permutation
- Returns:
A smart pointer to the constant matrix wrapping the input array (if it resides on the same executor as the matrix) or a copy of the array on the correct executor.