Skip to content

Commit

Permalink
Doc fix
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Nov 16, 2024
1 parent d43f65c commit 3067e60
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions cpp/basix/precompute.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,48 @@ using scalar_value_type_t = typename scalar_value_type<T>::value_type;

/// @brief Prepare a permutation.
///
/// @param[in,out] perm 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:
///
/// \code{.pseudo}
/// FOR index, entry IN perm:
/// new_index = entry
/// WHILE new_index < index:
/// new_index = perm[new_index]
/// OUT[index] = new_index
/// \endcode
///
/// Example
/// -------
/// Consider the permutation `P = [1, 4, 0, 5, 2, 3]`.
///
/// -# First, we look at the 0th entry. `P[0]` is 1. This is greater
/// than 0, so the 0th entry of the output is 1.
///
/// -# Next, we look at the 1st entry. `P[1]` is 4. This is greater than
/// 1, so the 1st entry of the output is 4.
/// -# Next, we look at the 2nd entry. `P[2]` is 0. This is less than 2,
/// so we look at `P[0]`. `P[0]` is 1. This is less than 2, so we look at
/// `P[1]`. `P[1]` is 4. This is greater than 2, so the 2nd entry of the
/// output is 4.
/// -# Next, we look at the 3rd entry. `P[3]` is 5. This is greater than 3,
/// so the 3rd entry of the output is 5.
/// -# Next, we look at the 4th entry. `P[4]` is 2. This is less than 4, so
/// we look at `P[2]`. `P[2]` is 0. This is less than 4, so we look at
/// `P[0]`. `P[0]` is 1. This is less than 4, so we look at `P[1]`.
/// `P[1]` is 4. This is greater than (or equal to) 4, so the 4th entry
/// of the output is 4.
/// -# Next, we look at the 5th entry. `P[5]` is 3. This is less than 5,
/// so we look at `P[3]`. `P[3]` is 5. This is greater than (or equal
/// to) 5, so the 5th entry of the output is 5.
///
/// 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().
///
/// @param[in,out] perm A permutation.
void prepare_permutation(std::span<std::size_t> perm);

/// @brief Apply a (precomputed) permutation \f$v = P u\f$.
Expand All @@ -65,7 +106,8 @@ void prepare_permutation(std::span<std::size_t> perm);
/// 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]`.
///
/// - `P2[0]` is 1, so we swap `A[0]` and `A[1]`. After this, `A = [b,a, c, d, e, f]`.
/// - `P2[0]` is 1, so we swap `A[0]` and `A[1]`. After this,
/// `A = [b, a, c, d, e, f]`.
///
/// - `P2[1]` is 4, so we swap `A[1]` and `A[4]`. After this, `A = [b, e, c, d, a, f]`.
///
Expand Down

0 comments on commit 3067e60

Please sign in to comment.