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

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

#include <SparseMatrix.h>

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, 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)
 
void swap (GenericMatrix< TMatrix2, E > &m)
 
void fill (const E2 &x)
 
void fill (const E2 &x)
 
void fill (const E2 &x)
 
top_type & negate ()
 negate elements in place
 
top_type & negate ()
 negate elements in place
 
top_type & negate ()
 negate elements in place
 
std::enable_if< is_expandable_by< TMatrix2 >(), top_type & >::type operator/= (const GenericMatrix< TMatrix2 > &m)
 append rows of another matrix
 
std::enable_if< is_expandable_by< TVector >(), top_type & >::type operator/= (const GenericVector< TVector > &v)
 append a vector as a row
 
std::enable_if< is_expandable_by< TMatrix2 >(), top_type & >::type operator/= (const GenericMatrix< TMatrix2 > &m)
 append rows of another matrix
 
std::enable_if< is_expandable_by< TVector >(), top_type & >::type operator/= (const GenericVector< TVector > &v)
 append a vector as a row
 
std::enable_if< is_expandable_by< TMatrix2 >(), top_type & >::type operator/= (const GenericMatrix< TMatrix2 > &m)
 append rows of another matrix
 
std::enable_if< is_expandable_by< TVector >(), top_type & >::type operator/= (const GenericVector< TVector > &v)
 append a vector as a row
 
std::enable_if_t< is_expandable_by< TMatrix2 >(), top_type & > operator|= (const GenericMatrix< TMatrix2 > &m)
 append columns of another matrix
 
std::enable_if_t< is_expandable_by< TVector >(), top_type & > operator|= (const GenericVector< TVector > &v)
 append a vector as a column
 
std::enable_if_t< is_expandable_by< TMatrix2 >(), top_type & > operator|= (const GenericMatrix< TMatrix2 > &m)
 append columns of another matrix
 
std::enable_if_t< is_expandable_by< TVector >(), top_type & > operator|= (const GenericVector< TVector > &v)
 append a vector as a column
 
std::enable_if_t< is_expandable_by< TMatrix2 >(), top_type & > operator|= (const GenericMatrix< TMatrix2 > &m)
 append columns of another matrix
 
std::enable_if_t< is_expandable_by< TVector >(), top_type & > operator|= (const GenericVector< TVector > &v)
 append a vector as a column
 
IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > diagonal (Int i=0) const &
 
IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > diagonal (Int i=0) const &
 
IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > diagonal (Int i=0) const &
 
IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > anti_diagonal (Int i=0) const &
 
IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > anti_diagonal (Int i=0) const &
 
IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > anti_diagonal (Int i=0) const &
 

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

◆ SparseMatrix()

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

◆ anti_diagonal() [1/3]

IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > pm::GenericMatrix< SparseMatrix< E, symmetric >, E >::anti_diagonal ( Int i = 0) const &
inlineinherited
Parameters
i==0main anti-diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main

◆ anti_diagonal() [2/3]

IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > pm::GenericMatrix< SparseMatrix< E, symmetric >, E >::anti_diagonal ( Int i = 0) const &
inlineinherited
Parameters
i==0main anti-diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main

◆ anti_diagonal() [3/3]

IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > pm::GenericMatrix< SparseMatrix< E, symmetric >, E >::anti_diagonal ( Int i = 0) const &
inlineinherited
Parameters
i==0main anti-diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main

◆ diagonal() [1/3]

IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > pm::GenericMatrix< SparseMatrix< E, symmetric >, E >::diagonal ( Int i = 0) const &
inlineinherited
Parameters
i==0main diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main

◆ diagonal() [2/3]

IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > pm::GenericMatrix< SparseMatrix< E, symmetric >, E >::diagonal ( Int i = 0) const &
inlineinherited
Parameters
i==0main diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main

◆ diagonal() [3/3]

IndexedSlice< masquerade< ConcatRows, const typename Unwary< SparseMatrix< E, symmetric > >::type & >, const series > pm::GenericMatrix< SparseMatrix< E, symmetric >, E >::diagonal ( Int i = 0) const &
inlineinherited
Parameters
i==0main diagonal; i>0: i-th diagonal below the main; i<0: (-i)-th above the main

◆ fill() [1/3]

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.

◆ fill() [2/3]

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.

◆ fill() [3/3]

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.

◆ operator=()

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.

◆ permute_cols()

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

◆ permute_rows()

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

◆ swap() [1/2]

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.

◆ swap() [2/2]

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: