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

A class that behaves like a vector of vectors, providing automatic row range checking. More...

#include <crs_map.hpp>

Public Member Functions

 CrsMapUncompressed ()=default
 CrsMapUncompressed (std::initializer_list< SmallVector< DataType, N > > init_list)
 Constructs a CrsMapUncompressed object with an initializer list of SmallVector objects.
constexpr auto begin ()
 Returns an iterator to the beginning of the map.
constexpr auto end ()
 Returns an iterator to the end of the map.
constexpr auto begin () const
 Returns a constant iterator to the beginning of the map.
constexpr auto end () const
 Returns a constant iterator to the end of the map.
constexpr const auto & back () const
 Returns a constant reference to the last row of the map.
constexpr auto & back ()
 Returns a reference to the last row of the map.
constexpr void resize (std::size_t new_size)
 Resizes the map to contain the specified number of SmallVector objects.
constexpr const SmallVector< DataType, N > & operator[] (std::size_t idx) const
 Accesses a SmallVector at the given index.
constexpr SmallVector< DataType, N > & operator[] (std::size_t idx)
 Accesses a SmallVector at the given index.
constexpr void push_back (const SmallVector< DataType, N > &value)
 Appends a copy of a SmallVector to the map.
constexpr void push_back (SmallVector< DataType, N > &&value)
 Appends an rvalue SmallVector to the map.
template<class... Args>
constexpr void emplace_back (Args &&... args)
SmallVector< DataType, N > & getRow (std::size_t row_idx)
 Access a row of the matrix as a mutable reference.
template<typename IndexType>
CrsMap< DataType, IndexType > compress () const
 Compresses the uncompressed CrsMap into a compressed format.
std::size_t size () const
 Returns the number of rows in the matrix.

Protected Attributes

std::vector< SmallVector< DataType, N > > m_data
 The internal data structure representing the rows of the matrix.

Detailed Description

template<typename DataType, std::size_t N = 16>
class vulpes::datastructure::CrsMapUncompressed< DataType, N >

A class that behaves like a vector of vectors, providing automatic row range checking.

This class is designed to store (staggered) 2D data efficiently using a vector of SmallVector objects. It provides automatic range checking of the rows, ensuring valid access to the elements. A key performance improvement over a standard vector of vectors is the usage of coalescent memory for rows, up to a threshold specified by template parameter N. Each row is implemented as a SmallVector, which can dynamically switch between static and dynamic storage based on the size of the row.

Template Parameters
DataTypeThe type of data to be stored in the 2D structure.
NThe size threshold after which rows are stored dynamically. Defaults to 16.
Note
: if the number of columns is fixed, it is better to use another datastucture.

Constructor & Destructor Documentation

◆ CrsMapUncompressed() [1/2]

template<typename DataType, std::size_t N = 16>
vulpes::datastructure::CrsMapUncompressed< DataType, N >::CrsMapUncompressed ( )
default

◆ CrsMapUncompressed() [2/2]

template<typename DataType, std::size_t N = 16>
vulpes::datastructure::CrsMapUncompressed< DataType, N >::CrsMapUncompressed ( std::initializer_list< SmallVector< DataType, N > > init_list)
inline

Constructs a CrsMapUncompressed object with an initializer list of SmallVector objects.

Parameters
init_listAn initializer list containing SmallVector objects to initialize the map.

Member Function Documentation

◆ back() [1/2]

template<typename DataType, std::size_t N = 16>
auto & vulpes::datastructure::CrsMapUncompressed< DataType, N >::back ( )
inlineconstexpr

Returns a reference to the last row of the map.

Returns
A reference to the last row.

◆ back() [2/2]

template<typename DataType, std::size_t N = 16>
const auto & vulpes::datastructure::CrsMapUncompressed< DataType, N >::back ( ) const
inlineconstexpr

Returns a constant reference to the last row of the map.

Returns
A constant reference to the last row.

◆ begin() [1/2]

template<typename DataType, std::size_t N = 16>
auto vulpes::datastructure::CrsMapUncompressed< DataType, N >::begin ( )
inlineconstexpr

Returns an iterator to the beginning of the map.

Returns
An iterator to the first SmallVector in the map.

◆ begin() [2/2]

template<typename DataType, std::size_t N = 16>
auto vulpes::datastructure::CrsMapUncompressed< DataType, N >::begin ( ) const
inlineconstexpr

Returns a constant iterator to the beginning of the map.

Returns
A constant iterator to the first SmallVector in the map.

◆ compress()

template<typename DataType, std::size_t N = 16>
template<typename IndexType>
CrsMap< DataType, IndexType > vulpes::datastructure::CrsMapUncompressed< DataType, N >::compress ( ) const
inline

Compresses the uncompressed CrsMap into a compressed format.

Converts the uncompressed representation of the matrix (stored as a vector of SmallVector rows) into a compressed row storage (CRS) format. The resulting CrsMap contains the data and indices vectors, which represent the compressed matrix structure.

Returns
CrsMap<DataType> A compressed representation of the matrix in CRS format.

◆ emplace_back()

template<typename DataType, std::size_t N = 16>
template<class... Args>
void vulpes::datastructure::CrsMapUncompressed< DataType, N >::emplace_back ( Args &&... args)
inlineconstexpr

◆ end() [1/2]

template<typename DataType, std::size_t N = 16>
auto vulpes::datastructure::CrsMapUncompressed< DataType, N >::end ( )
inlineconstexpr

Returns an iterator to the end of the map.

Returns
An iterator to one past the last SmallVector in the map.

◆ end() [2/2]

template<typename DataType, std::size_t N = 16>
auto vulpes::datastructure::CrsMapUncompressed< DataType, N >::end ( ) const
inlineconstexpr

Returns a constant iterator to the end of the map.

Returns
A constant iterator to one past the last SmallVector in the map.

◆ getRow()

template<typename DataType, std::size_t N = 16>
SmallVector< DataType, N > & vulpes::datastructure::CrsMapUncompressed< DataType, N >::getRow ( std::size_t row_idx)
inline

Access a row of the matrix as a mutable reference.

Retrieves a mutable reference to the row at the given index. If the index exceeds the current size of the row data, the matrix will resize to accommodate the new index.

Parameters
row_idxThe index of the row to access.
Returns
SmallVector<DataType, N>& A mutable reference to the SmallVector representing the row at the specified index.

◆ operator[]() [1/2]

template<typename DataType, std::size_t N = 16>
SmallVector< DataType, N > & vulpes::datastructure::CrsMapUncompressed< DataType, N >::operator[] ( std::size_t idx)
inlineconstexpr

Accesses a SmallVector at the given index.

Parameters
idxThe index of the SmallVector to access.
Returns
A reference to the SmallVector at the specified index.

◆ operator[]() [2/2]

template<typename DataType, std::size_t N = 16>
const SmallVector< DataType, N > & vulpes::datastructure::CrsMapUncompressed< DataType, N >::operator[] ( std::size_t idx) const
inlineconstexpr

Accesses a SmallVector at the given index.

Parameters
idxThe index of the SmallVector to access.
Returns
A reference to the SmallVector at the specified index.
Note
This method is constant.

◆ push_back() [1/2]

template<typename DataType, std::size_t N = 16>
void vulpes::datastructure::CrsMapUncompressed< DataType, N >::push_back ( const SmallVector< DataType, N > & value)
inlineconstexpr

Appends a copy of a SmallVector to the map.

Parameters
valueThe SmallVector to append.

◆ push_back() [2/2]

template<typename DataType, std::size_t N = 16>
void vulpes::datastructure::CrsMapUncompressed< DataType, N >::push_back ( SmallVector< DataType, N > && value)
inlineconstexpr

Appends an rvalue SmallVector to the map.

Parameters
valueAn rvalue reference to the SmallVector to append.

◆ resize()

template<typename DataType, std::size_t N = 16>
void vulpes::datastructure::CrsMapUncompressed< DataType, N >::resize ( std::size_t new_size)
inlineconstexpr

Resizes the map to contain the specified number of SmallVector objects.

Parameters
new_sizeThe new size of the map.

◆ size()

template<typename DataType, std::size_t N = 16>
std::size_t vulpes::datastructure::CrsMapUncompressed< DataType, N >::size ( ) const
inline

Returns the number of rows in the matrix.

Returns
std::size_t The number of rows currently stored in the matrix.

Member Data Documentation

◆ m_data

template<typename DataType, std::size_t N = 16>
std::vector<SmallVector<DataType, N> > vulpes::datastructure::CrsMapUncompressed< DataType, N >::m_data
protected

The internal data structure representing the rows of the matrix.

Each row is stored as a SmallVector, which optimizes memory usage by switching between static and dynamic storage as necessary, based on the number of elements in each row.


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