FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Adjacency::Permutation Class Reference

Permutation class. More...

#include <permutation.hpp>

Public Types

enum class  ConstrType {
  none , identity , perm , swap ,
  inv_perm , inv_swap
}
 Construction type enumeration. More...
 
using IndexVector = std::vector< Index >
 

Public Member Functions

 Permutation ()
 default CTOR More...
 
 Permutation (Index num_entries, ConstrType constr_type=ConstrType::none, const Index *v=nullptr)
 Constructor. More...
 
 Permutation (Index num_entries, Random &random)
 Random constructor. More...
 
 Permutation (Permutation &&other)
 move ctor More...
 
virtual ~Permutation ()
 virtual destructor More...
 
template<typename Tx_ >
void apply (Tx_ *x, bool invert=false) const
 Applies In-Situ permutation. More...
 
template<typename Ty_ , typename Tx_ >
void apply (Ty_ *y, const Tx_ *x, bool invert=false) const
 Applies permutation. More...
 
void calc_perm_from_swap ()
 Computes the permutation-position vector from the swap-position vector. More...
 
void calc_swap_from_perm ()
 Computes the swap-position vector from the permutation-position vector. More...
 
Permutation clone () const
 Clones this permutation. More...
 
void concat (const Permutation &p)
 concatenates two permutations More...
 
bool empty () const
 Checks whether the permutation is empty. More...
 
Indexget_perm_pos ()
 returns the permute-position array More...
 
const Indexget_perm_pos () const
 returns the permute-position array More...
 
Indexget_swap_pos ()
 returns the swap-position array More...
 
const Indexget_swap_pos () const
 returns the swap-position array More...
 
Permutation inverse () const
 Computes the inverse permutation. More...
 
template<typename IT_ >
IT_ map (IT_ i) const
 
Permutationoperator= (Permutation &&)
 move-assign operator More...
 
Index size () const
 returns the size of the permutation More...
 

Private Attributes

IndexVector _perm_pos
 the permute-position vector More...
 
IndexVector _swap_pos
 the swap-position vector More...
 

Detailed Description

Permutation class.

Author
Peter Zajac

Definition at line 24 of file permutation.hpp.

Member Typedef Documentation

◆ IndexVector

using FEAT::Adjacency::Permutation::IndexVector = std::vector < Index>

Definition at line 27 of file permutation.hpp.

Member Enumeration Documentation

◆ ConstrType

Construction type enumeration.

Enumerator
none 

create uninitialized permutation

identity 

create identity permutation

perm 

create from permutation array

swap 

create from swap array

inv_perm 

create from inverse permutation array

inv_swap 

create from inverse swap array

Definition at line 30 of file permutation.hpp.

Constructor & Destructor Documentation

◆ Permutation() [1/4]

FEAT::Adjacency::Permutation::Permutation ( )
inline

default CTOR

Definition at line 54 of file permutation.hpp.

Referenced by clone(), and inverse().

◆ Permutation() [2/4]

FEAT::Adjacency::Permutation::Permutation ( Index  num_entries,
ConstrType  constr_type = ConstrType::none,
const Index v = nullptr 
)
explicit

Constructor.

Parameters
[in]num_entriesThe size of the permutation to be created.
[in]constr_typeSpecifies the construction type:
  • ConstrType::none
    Create an uninitialized permutation.
    The permutation array has to be set up after the object is created.
    The input array v is ignored.
  • ConstrType::identity
    Create an identity permutation.
    The input array v is ignored.
  • ConstrType::perm
    Interpret the input vector as a permute-position vector.
  • ConstrType::swap
    Interpret the input vector as a swap-position vector.
  • ConstrType::inv_perm
    Interpret the input array as an inverse permute-position array.
  • ConstrType::inv_swap
    Interpret the input array as an inverse swap-position array.
[in]vThe transient input array for the initialization. The interpretation of the array's content depends on the constr_type parameter.

Definition at line 14 of file permutation.cpp.

References _perm_pos, _swap_pos, calc_perm_from_swap(), calc_swap_from_perm(), identity, inv_perm, inv_swap, none, perm, swap, and XASSERTM.

◆ Permutation() [3/4]

FEAT::Adjacency::Permutation::Permutation ( Index  num_entries,
Random random 
)
explicit

Random constructor.

This constructor creates a random permutation using a random number generator.

Parameters
[in]num_entriesThe size of the permutation to be created.
[in]randomThe transient random number generator to be used.

Definition at line 93 of file permutation.cpp.

References _swap_pos, calc_perm_from_swap(), and XASSERTM.

◆ Permutation() [4/4]

FEAT::Adjacency::Permutation::Permutation ( Permutation &&  other)

move ctor

Definition at line 106 of file permutation.cpp.

◆ ~Permutation()

FEAT::Adjacency::Permutation::~Permutation ( )
virtual

virtual destructor

Definition at line 123 of file permutation.cpp.

Member Function Documentation

◆ apply() [1/2]

template<typename Tx_ >
void FEAT::Adjacency::Permutation::apply ( Tx_ *  x,
bool  invert = false 
) const
inline

Applies In-Situ permutation.

This member function applies the permutation in-situ.

Parameters
[in,out]xThe transient array that is to be permuted.
[in]invertSpecifies whether to apply the forward (false) or inverse (true) permutation.
Warning
The function does not check, whether the referenced array x is large enough!

Definition at line 198 of file permutation.hpp.

References _swap_pos, ASSERTM, size(), and XASSERT.

Referenced by calc_perm_from_swap(), FEAT::LAFEM::DenseVector< DT_, IT_ >::permute(), FEAT::LAFEM::DenseVectorBlocked< DT_, IT_, BlockSize_ >::permute(), FEAT::Geometry::VertexSet< num_coords_, Coord_ >::permute(), and FEAT::Geometry::IndexSet< num_indices_ >::permute().

◆ apply() [2/2]

template<typename Ty_ , typename Tx_ >
void FEAT::Adjacency::Permutation::apply ( Ty_ *  y,
const Tx_ *  x,
bool  invert = false 
) const
inline

Applies permutation.

This function applies the permutation on an array.

Parameters
[out]yThe transient array that shall receive the permuted array.
[in]xThe transient array that is to be permuted.
[in]invertSpecifies whether to apply the forward (false) or inverse (true) permutation.
Warning
The function does not check, whether the referenced arrays x and y are large enough!

Definition at line 252 of file permutation.hpp.

References _perm_pos, size(), and XASSERT.

◆ calc_perm_from_swap()

void FEAT::Adjacency::Permutation::calc_perm_from_swap ( )

Computes the permutation-position vector from the swap-position vector.

Definition at line 140 of file permutation.cpp.

References _perm_pos, apply(), and size().

Referenced by Permutation().

◆ calc_swap_from_perm()

void FEAT::Adjacency::Permutation::calc_swap_from_perm ( )

Computes the swap-position vector from the permutation-position vector.

Definition at line 126 of file permutation.cpp.

References _perm_pos, _swap_pos, and size().

Referenced by Permutation(), FEAT::Adjacency::CuthillMcKee::compute(), and concat().

◆ clone()

Permutation FEAT::Adjacency::Permutation::clone ( ) const
inline

Clones this permutation.

Returns
A deep-copy of this permutation

Definition at line 114 of file permutation.hpp.

References Permutation(), _perm_pos, perm, and size().

Referenced by FEAT::Geometry::AdaptiveVertexSet< AdaptiveMeshType_ >::permute(), and FEAT::Geometry::AdaptiveIndexTuple< AdaptiveMeshType_, cell_dim_, face_dim_ >::permute_map().

◆ concat()

void FEAT::Adjacency::Permutation::concat ( const Permutation p)

concatenates two permutations

Let P1 be the permutation denoted by this permutation and let P2 denote the permutation p, then this function computes the contatenation P3 := P1 * P2, such that P3(x) = P1(P2(x)).

Parameters
[in,out]pThe concatenated permutation of the current permutation and p

Definition at line 152 of file permutation.cpp.

References calc_swap_from_perm(), get_perm_pos(), size(), and XASSERT.

Referenced by FEAT::Geometry::AdaptiveVertexSet< AdaptiveMeshType_ >::permute().

◆ empty()

◆ get_perm_pos() [1/2]

Index * FEAT::Adjacency::Permutation::get_perm_pos ( )
inline

◆ get_perm_pos() [2/2]

const Index * FEAT::Adjacency::Permutation::get_perm_pos ( ) const
inline

returns the permute-position array

Definition at line 155 of file permutation.hpp.

References _perm_pos.

◆ get_swap_pos() [1/2]

Index * FEAT::Adjacency::Permutation::get_swap_pos ( )
inline

returns the swap-position array

Definition at line 161 of file permutation.hpp.

References _swap_pos.

◆ get_swap_pos() [2/2]

const Index * FEAT::Adjacency::Permutation::get_swap_pos ( ) const
inline

returns the swap-position array

Definition at line 167 of file permutation.hpp.

References _swap_pos.

◆ inverse()

◆ map()

template<typename IT_ >
IT_ FEAT::Adjacency::Permutation::map ( IT_  i) const
inline

Definition at line 173 of file permutation.hpp.

◆ operator=()

Permutation & FEAT::Adjacency::Permutation::operator= ( Permutation &&  other)

move-assign operator

Definition at line 111 of file permutation.cpp.

References _perm_pos, and _swap_pos.

◆ size()

Member Data Documentation

◆ _perm_pos

IndexVector FEAT::Adjacency::Permutation::_perm_pos
private

the permute-position vector

Definition at line 48 of file permutation.hpp.

Referenced by Permutation(), apply(), calc_perm_from_swap(), calc_swap_from_perm(), clone(), empty(), get_perm_pos(), inverse(), operator=(), and size().

◆ _swap_pos

IndexVector FEAT::Adjacency::Permutation::_swap_pos
private

the swap-position vector

Definition at line 50 of file permutation.hpp.

Referenced by Permutation(), apply(), calc_swap_from_perm(), get_swap_pos(), operator=(), and size().


The documentation for this class was generated from the following files: