CLA3P v0.3.1
Compact Linear Algebra Parallel Portable Package
Loading...
Searching...
No Matches
cla3p::prm::PxMatrix< T_Int > Class Template Reference

Permutation matrix utility. More...

Inheritance diagram for cla3p::prm::PxMatrix< T_Int >:

Constructors

 PxMatrix ()
 Default constructor.
 PxMatrix (int_t n)
 Size constructor.
 PxMatrix (int_t n, T_Int *vals, bool bind)
 Buffer binding constructor.
 PxMatrix (const PxMatrix< T_Int > &other)=default
 Copy constructor.
 PxMatrix (PxMatrix< T_Int > &&other)=default
 Move constructor.
 ~PxMatrix ()
 Destructor.

Operators

PxMatrixoperator= (const PxMatrix< T_Int > &other)=default
 Copy assignment operator.
PxMatrix< T_Int > & operator= (PxMatrix< T_Int > &&other)=default
 Move assignment operator.
void operator= (T_Int val)
 Value setter.

Public Member Functions

PxMatrix< T_Int > inverse () const
 Inverse permutation.
PxMatrix< T_Int > permuteLeft (const PxMatrix< T_Int > &P) const
 Left permutation composition.
void permuteLeft (const PxMatrix< T_Int > &P, PxMatrix< T_Int > &trg) const
 In-place left permutation composition.

Creators/Generators

static PxMatrix< T_Int > identity (int_t n)
 Identity permutation generator.
static PxMatrix< T_Int > random (int_t n)
 Random permutation generator.

Additional Inherited Members

Public Member Functions inherited from cla3p::dns::XiVector< T_Int >
T_Int & operator() (int_t i)
 Element access operator.
void clear ()
 Clear the vector.
void fill (T_Int val)
 Fill all elements with a value.
XiVector< T_Int > copy () const
 Create a deep copy of the vector.
XiVector< T_Int > rcopy ()
 Create a reference copy (shallow copy) of the vector.
XiVector< T_Int > move ()
 Move the vector's resources.
std::string info (const std::string &header="") const
 Get information about the vector.
void print (std::streamsize prec=0) const
 Print the vector to standard output.
void toStream (std::ostream &os, std::streamsize prec=0) const
 Output the vector to a stream.
Public Member Functions inherited from cla3p::Meta1D< int_t >
int_t size () const
 Vector size.
bool empty () const
 Tests whether the object has zero dimension.
 operator bool () const
 Boolean conversion operator.
Public Member Functions inherited from cla3p::dns::XxContainerBase< T_Int >
T_Int * values ()
 Access the data buffer.
Public Member Functions inherited from cla3p::Ownership
 Ownership ()
 Default constructor.
 Ownership (bool owner)
 Ownership constructor.
 ~Ownership ()
 Destructor.
bool owner () const
 Tests memory ownership.
void unbind ()
 Relinquishes memory ownership.
Static Public Member Functions inherited from cla3p::dns::XiVector< T_Int >
static Guard< XiVector< T_Int > > view (int_t n, const T_Int *vals)
 Create a view of existing memory.

Detailed Description

template<typename T_Int>
class cla3p::prm::PxMatrix< T_Int >

Permutation matrix utility.

Template Parameters
T_IntInteger type for permutation indices.

Permutation matrices are stored as a 1D array of (unsigned) integers and reorder indices based on a predefined mapping. For a size n matrix, each value lies in the range [0, n-1] using 0-based indexing.

Constructor & Destructor Documentation

◆ PxMatrix() [1/5]

template<typename T_Int>
cla3p::prm::PxMatrix< T_Int >::PxMatrix ( )
explicit

Default constructor.

Constructs an empty permutation matrix.

◆ PxMatrix() [2/5]

template<typename T_Int>
cla3p::prm::PxMatrix< T_Int >::PxMatrix ( int_t n)
explicit

Size constructor.

Constructs a permutation matrix of size n with uninitialized values.

Parameters
[in]nThe permutation matrix size.

◆ PxMatrix() [3/5]

template<typename T_Int>
cla3p::prm::PxMatrix< T_Int >::PxMatrix ( int_t n,
T_Int * vals,
bool bind )
explicit

Buffer binding constructor.

Creates a permutation matrix of size n bound to external storage or copies from provided values.

Parameters
[in]nThe permutation matrix size.
[in]valsPointer to n entries holding the permutation values.
[in]bindIf true, takes ownership of vals and manages its lifetime.

◆ PxMatrix() [4/5]

template<typename T_Int>
cla3p::prm::PxMatrix< T_Int >::PxMatrix ( const PxMatrix< T_Int > & other)
default

Copy constructor.

Constructs a permutation matrix with a copy of other; other remains unchanged.

◆ PxMatrix() [5/5]

template<typename T_Int>
cla3p::prm::PxMatrix< T_Int >::PxMatrix ( PxMatrix< T_Int > && other)
default

Move constructor.

Transfers the contents of other; other is left empty.

◆ ~PxMatrix()

template<typename T_Int>
cla3p::prm::PxMatrix< T_Int >::~PxMatrix ( )

Destructor.

Destroys the permutation matrix.

Member Function Documentation

◆ operator=() [1/3]

template<typename T_Int>
PxMatrix & cla3p::prm::PxMatrix< T_Int >::operator= ( const PxMatrix< T_Int > & other)
default

Copy assignment operator.

If (*this) is empty, copies the contents of other. If (*this) is not empty, performs a deep copy of other into (*this). The two matrices must have equal size.

◆ operator=() [2/3]

template<typename T_Int>
PxMatrix< T_Int > & cla3p::prm::PxMatrix< T_Int >::operator= ( PxMatrix< T_Int > && other)
default

Move assignment operator.

Replaces the contents with those of other; other is left empty.

◆ operator=() [3/3]

template<typename T_Int>
void cla3p::prm::PxMatrix< T_Int >::operator= ( T_Int val)

Value setter.

Sets all entries of (*this) to val.

Parameters
[in]valThe value to assign to all entries.

◆ inverse()

template<typename T_Int>
PxMatrix< T_Int > cla3p::prm::PxMatrix< T_Int >::inverse ( ) const

Inverse permutation.

Computes and returns the inverse (transpose) of the permutation matrix.

Returns
The inverse permutation matrix.

◆ permuteLeft() [1/2]

template<typename T_Int>
PxMatrix< T_Int > cla3p::prm::PxMatrix< T_Int >::permuteLeft ( const PxMatrix< T_Int > & P) const

Left permutation composition.

Computes and returns the composed permutation \( P \cdot (*this) \).

Parameters
[in]PThe left-side permutation matrix.
Returns
The composed permutation \( P \cdot (*this) \).

◆ permuteLeft() [2/2]

template<typename T_Int>
void cla3p::prm::PxMatrix< T_Int >::permuteLeft ( const PxMatrix< T_Int > & P,
PxMatrix< T_Int > & trg ) const

In-place left permutation composition.

Stores the composed permutation \( P \cdot (*this) \) into trg.

Parameters
[in]PThe left-side permutation matrix.
[out]trgOutput permutation matrix receiving \( P \cdot (*this) \); must match the size of (*this).

◆ identity()

template<typename T_Int>
PxMatrix< T_Int > cla3p::prm::PxMatrix< T_Int >::identity ( int_t n)
static

Identity permutation generator.

Creates an n-sized permutation matrix with \( P(i) = i \).

Parameters
[in]nThe permutation matrix size.
Returns
The identity permutation matrix.

◆ random()

template<typename T_Int>
PxMatrix< T_Int > cla3p::prm::PxMatrix< T_Int >::random ( int_t n)
static

Random permutation generator.

Creates an n-sized permutation matrix with randomly rearranged indices.

Parameters
[in]nThe permutation matrix size.
Returns
The random permutation matrix.