cgv
Loading...
Searching...
No Matches
cgv::math::perm_mat Struct Reference

a permutation matrix type More...

#include <perm_mat.h>

Public Member Functions

 perm_mat ()
 standard constructor
 
 perm_mat (unsigned n)
 create an nxn identity permutation matrix (storage is only n)
 
 perm_mat (vec< unsigned > p)
 creates a permutation from a given permutation vector
 
unsigned size () const
 number of stored elements
 
unsigned nrows () const
 number of rows
 
unsigned ncols () const
 number of rows
 
void resize (unsigned n)
 resize the permutation matrix
 
void transpose ()
 compute the transpose permutation matrix (equal to inverse permutation)
 
template<typename T >
 operator const mat< T > () const
 
perm_mat operator* (const perm_mat &m)
 product with another permutation matrix
 
void identity ()
 set to identity matrix
 
void swap (unsigned i, unsigned j)
 
unsigned & operator() (unsigned i)
 
unsigned & operator[] (unsigned i)
 
unsigned operator() (unsigned i) const
 
unsigned operator[] (unsigned i) const
 

Public Attributes

vec< unsigned > _data
 internal storage of the permutation
 

Detailed Description

a permutation matrix type

Definition at line 12 of file perm_mat.h.

Constructor & Destructor Documentation

◆ perm_mat() [1/3]

cgv::math::perm_mat::perm_mat ( )
inline

standard constructor

Definition at line 18 of file perm_mat.h.

◆ perm_mat() [2/3]

cgv::math::perm_mat::perm_mat ( unsigned  n)
inlineexplicit

create an nxn identity permutation matrix (storage is only n)

Definition at line 21 of file perm_mat.h.

References identity(), and resize().

◆ perm_mat() [3/3]

cgv::math::perm_mat::perm_mat ( vec< unsigned >  p)
inline

creates a permutation from a given permutation vector

Definition at line 28 of file perm_mat.h.

References _data.

Member Function Documentation

◆ identity()

void cgv::math::perm_mat::identity ( )
inline

set to identity matrix

Definition at line 102 of file perm_mat.h.

References _data, and cgv::math::vec< T >::size().

Referenced by perm_mat().

◆ ncols()

unsigned cgv::math::perm_mat::ncols ( ) const
inline

number of rows

Definition at line 46 of file perm_mat.h.

References _data, and cgv::math::vec< T >::size().

◆ nrows()

unsigned cgv::math::perm_mat::nrows ( ) const
inline

number of rows

Definition at line 40 of file perm_mat.h.

References _data, and cgv::math::vec< T >::size().

◆ operator const mat< T >()

template<typename T >
cgv::math::perm_mat::operator const mat< T > ( ) const
inline

Definition at line 73 of file perm_mat.h.

◆ operator()() [1/2]

unsigned & cgv::math::perm_mat::operator() ( unsigned  i)
inline

Definition at line 115 of file perm_mat.h.

◆ operator()() [2/2]

unsigned cgv::math::perm_mat::operator() ( unsigned  i) const
inline

Definition at line 127 of file perm_mat.h.

◆ operator*()

perm_mat cgv::math::perm_mat::operator* ( const perm_mat m)
inline

product with another permutation matrix

Definition at line 85 of file perm_mat.h.

References size().

◆ operator[]() [1/2]

unsigned & cgv::math::perm_mat::operator[] ( unsigned  i)
inline

Definition at line 121 of file perm_mat.h.

◆ operator[]() [2/2]

unsigned cgv::math::perm_mat::operator[] ( unsigned  i) const
inline

Definition at line 133 of file perm_mat.h.

◆ resize()

void cgv::math::perm_mat::resize ( unsigned  n)
inline

resize the permutation matrix

Definition at line 55 of file perm_mat.h.

References _data, and cgv::math::vec< T >::resize().

Referenced by perm_mat().

◆ size()

unsigned cgv::math::perm_mat::size ( ) const
inline

number of stored elements

Definition at line 34 of file perm_mat.h.

References _data, and cgv::math::vec< T >::size().

Referenced by operator*(), and cgv::math::random::uniform().

◆ swap()

void cgv::math::perm_mat::swap ( unsigned  i,
unsigned  j 
)
inline

Definition at line 109 of file perm_mat.h.

◆ transpose()

void cgv::math::perm_mat::transpose ( )
inline

compute the transpose permutation matrix (equal to inverse permutation)

Definition at line 64 of file perm_mat.h.

References _data, and cgv::math::vec< T >::size().

Member Data Documentation

◆ _data

vec<unsigned> cgv::math::perm_mat::_data

internal storage of the permutation

Definition at line 15 of file perm_mat.h.

Referenced by identity(), ncols(), nrows(), perm_mat(), resize(), size(), and transpose().


The documentation for this struct was generated from the following file: