Polymake Template Library (PTL): pm::SparseMatrix Class Reference
Polymake Template Library (PTL)  4.2

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

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, std::enable_if_t< SparseMatrix::template compatible_symmetry_types< TMatrix2 >(), std::nullptr_t >=nullptr)
 Copy of an abstract matrix of the same element type.
 
template<typename TMatrix2 , typename E2 >
 SparseMatrix (const GenericMatrix< TMatrix2, E2 > &M, std::enable_if_t<(SparseMatrix::template compatible_symmetry_types< TMatrix2 >() &&can_initialize< E2, E >::value), std::nullptr_t >=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_t< isomorphic_to_container_of< TPerm, Int >::value > permute_rows (const TPerm &perm)
 
template<typename TPerm >
std::enable_if_t< isomorphic_to_container_of< TPerm, Int >::value > permute_cols (const TPerm &perm)
 

Detailed Description

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

◆ SparseMatrix()

template<typename Iterator >
pm::SparseMatrix::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

◆ operator=()

SparseMatrix& pm::SparseMatrix::operator= ( const SparseMatrix 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.

◆ permute_cols()

template<typename TPerm >
std::enable_if_t<isomorphic_to_container_of<TPerm, Int>::value> pm::SparseMatrix::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.

◆ permute_rows()

template<typename TPerm >
std::enable_if_t<isomorphic_to_container_of<TPerm, Int>::value> pm::SparseMatrix::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.

◆ swap()

void pm::SparseMatrix::swap ( SparseMatrix 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: