Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::datastructure::CrsMap< DataType, IndexType, RowSize > Class Template Reference

#include <crs_map.hpp>

Classes

class  RowView

Public Types

using ConstRowView = RowView<false>
 View for constant rows.
using MutableRowView = RowView<true>
 View for mutable rows.

Public Member Functions

 CrsMap (const std::vector< std::vector< DataType > > &data)
 CrsMap (const std::vector< DataType > &data, const std::vector< IndexType > &indices)
 Construct a CrsMap with the provided data and index arrays.
template<class Archive>
void serialize (Archive &ar, const unsigned int)
 CrsMap (std::vector< DataType > &&data, std::vector< IndexType > &&indices)
 Constructor that initializes a CrsMap by moving the provided data and indices.
 CrsMap ()=default
 Default constructor.
MutableRowView getRow (IndexType row_idx)
 Get a mutable view over a row.
ConstRowView getRow (IndexType row_idx) const
 Get a constant view over a row.
ConstRowView operator[] (IndexType row_idx) const
 Access a row using the subscript operator (constant version).
MutableRowView operator[] (IndexType row_idx)
 Access a row using the subscript operator (mutable version).
const DataType & operator() (IndexType row_idx, IndexType col_idx) const
 Access an element in the CRS map by row and column index (constant version).
DataType & operator() (IndexType row_idx, IndexType col_idx)
 Access an element in the CRS map by row and column index (mutable version).
IndexType size () const
 Get the number of rows in the CRS map.
auto slice (const std::vector< IndexType > &subindices) const
 Get a CrsMap with the rows of the passed indexes.
auto permute (const std::vector< IndexType > &perm, const std::vector< IndexType > &perm_inv) const
 Get a CrsMap obtained by applying a permutation to this instance.
void remove (const DataType &value_to_remove)
 Remove in-place all entries with a certain value.
void pushBack (const std::vector< DataType > &row)
const auto & data () const
 Constant accessor to the data buffer.
const auto & indices () const
 Constant accessor to the indices buffer.
auto & data ()
 Accessor to the data buffer.
auto & indices ()
 Accessor to the indices buffer.

Protected Attributes

std::vector< DataType > m_data
 Vector storing the data.
std::vector< IndexType > m_indices
 Vector storing the indices.

Friends

bool operator== (const CrsMap &lhs, const CrsMap &rhs)

Detailed Description

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
class vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >
Template Parameters
DataTypeThe type of data to be stored in the CRS map.
IndexTypeThe type used for indices in the CRS map.
RowSizeSize of each row. If set to -1, the row size is dynamic.

This class represents a Compressed Row Storage (CRS) structure, which works like a vector of vectors for efficient storage. If DataType is a std::pair<IndexType, double>, it models a CRS matrix. The row size can either be fixed or dynamic based on the RowSize template argument.

Member Typedef Documentation

◆ ConstRowView

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
using vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::ConstRowView = RowView<false>

View for constant rows.

◆ MutableRowView

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
using vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::MutableRowView = RowView<true>

View for mutable rows.

Constructor & Destructor Documentation

◆ CrsMap() [1/4]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::CrsMap ( const std::vector< std::vector< DataType > > & data)
inlineexplicit

◆ CrsMap() [2/4]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::CrsMap ( const std::vector< DataType > & data,
const std::vector< IndexType > & indices )
inlineexplicit

Construct a CrsMap with the provided data and index arrays.

Parameters
dataVector containing the data.
indicesVector containing the indices.

◆ CrsMap() [3/4]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::CrsMap ( std::vector< DataType > && data,
std::vector< IndexType > && indices )
inlineexplicit

Constructor that initializes a CrsMap by moving the provided data and indices.

This constructor takes ownership of the provided data and indices vectors by moving them into the internal storage. This allows efficient initialization without copying the vectors, especially when compressing a CrsMapUncompressed

Parameters
dataA rvalue reference to a vector containing the data elements, typically representing non-zero values in a compressed row storage (CRS) format. The vector will be moved into the internal storage.
indicesA rvalue reference to a vector containing the row indices in the CRS format. The vector will be moved into the internal storage.
Note
After calling this constructor, the passed data and indices vectors will be in a valid but unspecified state, as their contents will have been moved into the CrsMap instance.

◆ CrsMap() [4/4]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::CrsMap ( )
explicitdefault

Default constructor.

Member Function Documentation

◆ data() [1/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
auto & vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::data ( )
inline

Accessor to the data buffer.

◆ data() [2/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
const auto & vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::data ( ) const
inline

Constant accessor to the data buffer.

◆ getRow() [1/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
MutableRowView vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::getRow ( IndexType row_idx)
inline

Get a mutable view over a row.

Parameters
row_idxIndex of the row to access.
Returns
Mutable view of the row.

◆ getRow() [2/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
ConstRowView vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::getRow ( IndexType row_idx) const
inline

Get a constant view over a row.

Parameters
row_idxIndex of the row to access.
Returns
Constant view of the row.

◆ indices() [1/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
auto & vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::indices ( )
inline

Accessor to the indices buffer.

◆ indices() [2/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
const auto & vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::indices ( ) const
inline

Constant accessor to the indices buffer.

◆ operator()() [1/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
DataType & vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::operator() ( IndexType row_idx,
IndexType col_idx )
inline

Access an element in the CRS map by row and column index (mutable version).

This method allows mutable access to an element in the compressed row storage (CRS) matrix using both row and column indices. The access pattern differs based on whether the row size is fixed or dynamic.

Parameters
row_idxThe index of the row.
col_idxThe index of the column within the specified row.
Returns
Mutable reference to the element at the specified row and column.

◆ operator()() [2/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
const DataType & vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::operator() ( IndexType row_idx,
IndexType col_idx ) const
inline

Access an element in the CRS map by row and column index (constant version).

This method allows access to an element in the compressed row storage (CRS) matrix using both row and column indices. The access pattern differs based on whether the row size is fixed or dynamic.

Parameters
row_idxThe index of the row.
col_idxThe index of the column within the specified row.
Returns
Constant reference to the element at the specified row and column.

◆ operator[]() [1/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
MutableRowView vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::operator[] ( IndexType row_idx)
inline

Access a row using the subscript operator (mutable version).

Parameters
row_idxIndex of the row.
Returns
Mutable view of the row.

◆ operator[]() [2/2]

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
ConstRowView vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::operator[] ( IndexType row_idx) const
inline

Access a row using the subscript operator (constant version).

Parameters
row_idxIndex of the row.
Returns
Constant view of the row.

◆ permute()

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
auto vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::permute ( const std::vector< IndexType > & perm,
const std::vector< IndexType > & perm_inv ) const
inline

Get a CrsMap obtained by applying a permutation to this instance.

Parameters
permThe new permutation of the elements.
perm_invThe inverse of perm
Returns
A CrsMap.

◆ pushBack()

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
void vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::pushBack ( const std::vector< DataType > & row)
inline

◆ remove()

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
void vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::remove ( const DataType & value_to_remove)
inline

Remove in-place all entries with a certain value.

Parameters
value_to_removeThe value to remove.

◆ serialize()

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
template<class Archive>
void vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::serialize ( Archive & ar,
const unsigned int  )
inline

◆ size()

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
IndexType vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::size ( ) const
inline

Get the number of rows in the CRS map.

Returns
The number of rows.

◆ slice()

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
auto vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::slice ( const std::vector< IndexType > & subindices) const
inline

Get a CrsMap with the rows of the passed indexes.

Parameters
subindicesThe indexes of the rows to keep.
Returns
A CrsMap.

◆ operator==

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
bool operator== ( const CrsMap< DataType, IndexType, RowSize > & lhs,
const CrsMap< DataType, IndexType, RowSize > & rhs )
friend

Member Data Documentation

◆ m_data

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
std::vector<DataType> vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::m_data
protected

Vector storing the data.

◆ m_indices

template<typename DataType, typename IndexType, IndexType RowSize = IndexType(-1)>
std::vector<IndexType> vulpes::datastructure::CrsMap< DataType, IndexType, RowSize >::m_indices
protected

Vector storing the indices.


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