From: bangerth Date: Fri, 31 Oct 2008 17:41:03 +0000 (+0000) Subject: Compute reverse and inverse permutations. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7943ff6c253c378bcd48f6de13df574c4a47e1ad;p=dealii-svn.git Compute reverse and inverse permutations. git-svn-id: https://svn.dealii.org/trunk@17431 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/utilities.h b/deal.II/base/include/base/utilities.h index 1b5a7ca497..330e5b9150 100644 --- a/deal.II/base/include/base/utilities.h +++ b/deal.II/base/include/base/utilities.h @@ -172,6 +172,27 @@ namespace Utilities template T fixed_power (const T t); + + /** + * Given a permutation vector (i.e. a + * vector $p_0\ldots p_{N-1}$ where each + * $p_i\in [0,N)$ and $p_i\neq p_j$ for + * $i\neq j$), produce the reverse + * permutation $q_i=N-1-p_i$. + */ + std::vector + reverse_permutation (const std::vector &permutation); + + /** + * Given a permutation vector (i.e. a + * vector $p_0\ldots p_{N-1}$ where each + * $p_i\in [0,N)$ and $p_i\neq p_j$ for + * $i\neq j$), produce the inverse + * permutation $q_0\ldots q_{N-1}$ so that + * $q_{p_i}=p_{q_i}=i$. + */ + std::vector + invert_permutation (const std::vector &permutation); /** * A namespace for utility functions that diff --git a/deal.II/base/source/utilities.cc b/deal.II/base/source/utilities.cc index 44b74d70dc..129f8ebcf9 100644 --- a/deal.II/base/source/utilities.cc +++ b/deal.II/base/source/utilities.cc @@ -345,6 +345,45 @@ namespace Utilities + std::vector + reverse_permutation (const std::vector &permutation) + { + const unsigned int n = permutation.size(); + + std::vector out (n); + for (unsigned int i=0; i + invert_permutation (const std::vector &permutation) + { + const unsigned int n = permutation.size(); + + std::vector out (n, numbers::invalid_unsigned_int); + + for (unsigned int i=0; ibase
    +
  1. +

    + New: The Utilities::reverse_permutation and Utilities::invert_permutation + compute the reverse and inverse of a given permutation of indices. +
    + (WB 2008/10/31) +

    +
  2. Fixed: The PolynomialsRaviartThomas class had a bug that led to random @@ -399,6 +407,15 @@ inconvenience this causes.

    deal.II

      +
    1. +

      + Fixed: The DoFRenumbering::Cuthill_McKee algorithm had a bug when applied + to MGDoFHandler objects and if the reverse flag was set. This + should now be fixed. +
      + (WB 2008/10/31) +

      +
    2. New: MatrixTools::apply_boundary_values() also for PETScWrappers::MPI::BlockSparseMatrix.