Polymake Template Library (PTL): pm::SparseMatrix< E, symmetric > Class Template Reference
pm::SparseMatrix< E, symmetric > Class Template Reference

A two-dimensional associative array with row and column indices as keys. More...

Inheritance diagram for pm::SparseMatrix< E, symmetric >:
Collaboration diagram for pm::SparseMatrix< E, symmetric >:

Public Member Functions

 SparseMatrix ()
 create as empty
 
 SparseMatrix (int r, int c)
 Create a matrix with r rows and c columns, (implicitly) initialize all elements to 0.
 
template<typename Iterator >
 SparseMatrix (int r, int c, Iterator &&src)
 
 SparseMatrix (const GenericMatrix< SparseMatrix > &M)
 Copy of a disguised Matrix object.
 
template<typename TMatrix2 >
 SparseMatrix (const GenericMatrix< TMatrix2, E > &M, typename std::enable_if< SparseMatrix::template compatible_symmetry_types< TMatrix2 >(), void ** >::type=nullptr)
 Copy of an abstract matrix of the same element type.
 
template<typename TMatrix2 , typename E2 >
 SparseMatrix (const GenericMatrix< TMatrix2, E2 > &M, typename std::enable_if<(SparseMatrix::template compatible_symmetry_types< TMatrix2 >()&& can_initialize< E2, E >::value), void ** >::type=nullptr)
 Copy of an abstract matrix with element conversion.
 
SparseMatrixoperator= (const SparseMatrix &other)
 
void swap (SparseMatrix &M)
 
void resize (int r, int c)
 Resize to new dimensions, added elements initialized with default constructor.
 
void clear ()
 Truncate to 0x0 matrix.
 
void remove0s ()
 Physically remove all zero elements that might have creeped in by some previous operation.
 
void squeeze ()
 Remove all empty (i.e., consisting entirely of implicit zeroes,) rows, renumber the rest, and reduce the dimensions.
 
void squeeze_cols ()
 Remove all empty (i.e., consisting entirely of implicit zeroes,) columns, renumber the rest, and reduce the dimensions.
 
template<typename TPerm >
std::enable_if< isomorphic_to_container_of< TPerm, int >::value >::type permute_rows (const TPerm &perm)
 
template<typename TPerm >
std::enable_if< isomorphic_to_container_of< TPerm, int >::value >::type permute_cols (const TPerm &perm)
 
void swap (GenericMatrix< TMatrix2, E > &m)
 
void fill (const E2 &x)
 
std::enable_if< compatible_symmetry_types< TMatrix2 >), top_type & >::type operator+= (const GenericMatrix< TMatrix2 > &m)
 adding a GenericMatrix
 
std::enable_if< compatible_symmetry_types< TMatrix2 >), top_type & >::type operator-= (const GenericMatrix< TMatrix2, E > &m)
 subtracting a GenericMatrix
 
top_type & operator*= (const Right &r)
 multiply with an element
 
std::enable_if< is_expandable_by< TMatrix2 >), top_type & >::type operator/= (const GenericMatrix< TMatrix2 > &m)
 append the rows of a GenericMatrix
 
std::enable_if< is_expandable_by< TVector >), top_type & >::type operator/= (const GenericVector< TVector > &v)
 append a GenericVector as a row
 
std::enable_if< isomorphic_types< E, Right >::value, top_type & >::type div_exact (const Right &r)
 divide by an element
 
std::enable_if< is_expandable_by< TMatrix2 >), top_type & >::type operator|= (const GenericMatrix< TMatrix2 > &m)
 append the columns of a GenericMatrix
 
std::enable_if< is_expandable_by< TVector >), top_type & >::type operator|= (const GenericVector< TVector > &v)
 append a GenericVector as a column
 
IndexedSlice< ConcatRows< unwary_t< SparseMatrix< E, symmetric > > > &, series > diagonal (int i=0)
 
IndexedSlice< ConcatRows< unwary_t< SparseMatrix< E, symmetric > > > &, series > anti_diagonal (int i=0)
 

Detailed Description

template<typename E, typename symmetric>
class pm::SparseMatrix< E, symmetric >

A two-dimensional associative array with row and column indices as keys.

A two-dimensional associative array with row and column indices as keys; elements equal to the default value (ElementType(), which is 0 for most numerical types) are not stored, but implicitly encoded by the gaps in the key set. Each row and column is organized as a balanced binary search (AVL) tree.

Constructor & Destructor Documentation

template<typename E, typename symmetric>
template<typename Iterator >
pm::SparseMatrix< E, symmetric >::SparseMatrix ( int  r,
int  c,
Iterator &&  src 
)
inline

Create a matrix with r rows and c columns, initialize the elements from a data sequence. src should iterate either over r*c scalar values, corresponding to the elements in the row order (the column index changes first,) or over r vectors of dimension c, corresponding to the matrix rows. Zero input elements are filtered out.

Member Function Documentation

IndexedSlice<ConcatRows<unwary_t<SparseMatrix< E, symmetric > > >&, series> pm::GenericMatrix< SparseMatrix< E, symmetric > , E >::anti_diagonal ( int  i = 0)
inlineinherited
Parameters
i==0main anti-diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main
IndexedSlice<ConcatRows<unwary_t<SparseMatrix< E, symmetric > > >&, series> pm::GenericMatrix< SparseMatrix< E, symmetric > , E >::diagonal ( int  i = 0)
inlineinherited
Parameters
i==0main diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main
void pm::GenericMatrix< SparseMatrix< E, symmetric > , E >::fill ( const E2 &  x)
inlineinherited

Fill with given value without changing the dimensions. x can be of arbitrary type assignable to the type E2.

template<typename E, typename symmetric>
SparseMatrix& pm::SparseMatrix< E, symmetric >::operator= ( const SparseMatrix< E, symmetric > &  other)
inline

Persistent matrix objects have after the assignment the same dimensions as the right hand side operand. Alias objects, such as matrix minor or block matrix, cannot be resized, thus must have the same dimensions as on the right hand side.

template<typename E, typename symmetric>
template<typename TPerm >
std::enable_if<isomorphic_to_container_of<TPerm, int>::value>::type pm::SparseMatrix< E, symmetric >::permute_cols ( const TPerm &  perm)
inline

Permute the columns of the matrix without copying the elements. These operations are nevetherless expensive, as they need to visit each element and adjust its indices.

template<typename E, typename symmetric>
template<typename TPerm >
std::enable_if<isomorphic_to_container_of<TPerm, int>::value>::type pm::SparseMatrix< E, symmetric >::permute_rows ( const TPerm &  perm)
inline

Permute the rows of the matrix without copying the elements. These operations are nevertheless expensive, as they need to visit each element and adjust its indices.

void pm::GenericMatrix< SparseMatrix< E, symmetric > , E >::swap ( GenericMatrix< TMatrix2, E > &  m)
inlineinherited

Exchange the contents of two matrices in a most efficient way. If at least one non-persistent object is involved, the operands must have equal dimensions.

template<typename E, typename symmetric>
void pm::SparseMatrix< E, symmetric >::swap ( SparseMatrix< E, symmetric > &  M)
inline

Exchange the contents of two matrices in a most efficient way. If at least one non-persistent object is involved, the operands must have equal dimensions.


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