OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
pfc::core::SparseVector< BackendTag, T > Class Template Reference

Sparse vector for indexed data views. More...

#include <sparse_vector.hpp>

Public Member Functions

 SparseVector (size_t size)
 Construct empty SparseVector.
 
 SparseVector (const std::vector< size_t > &indices)
 Construct SparseVector with given indices.
 
 SparseVector (const std::vector< size_t > &indices, const std::vector< T > &data)
 Construct SparseVector with indices and initial data.
 
size_t size () const
 Get number of entries.
 
bool empty () const
 Check if empty.
 
const DataBuffer< BackendTag, size_t > & indices () const
 Get indices buffer (read-only)
 
DataBuffer< BackendTag, T > & data ()
 Get data buffer (read-write)
 
const DataBuffer< BackendTag, T > & data () const
 
bool is_sorted () const
 Check if indices are sorted.
 

Detailed Description

template<typename BackendTag, typename T>
class pfc::core::SparseVector< BackendTag, T >

Sparse vector for indexed data views.

Represents a sparse view into selected entries of a dense array. Indices are automatically sorted for optimal memory access.

Template Parameters
BackendTagBackend tag (CpuTag, CudaTag, HipTag)
TElement type (must be trivially copyable for GPU backends)

Constructor & Destructor Documentation

◆ SparseVector() [1/3]

template<typename BackendTag , typename T >
pfc::core::SparseVector< BackendTag, T >::SparseVector ( size_t  size)
inlineexplicit

Construct empty SparseVector.

Parameters
sizeNumber of entries

◆ SparseVector() [2/3]

template<typename BackendTag , typename T >
pfc::core::SparseVector< BackendTag, T >::SparseVector ( const std::vector< size_t > &  indices)
inlineexplicit

Construct SparseVector with given indices.

Parameters
indicesLinear indices into dense array (will be sorted)
Here is the call graph for this function:

◆ SparseVector() [3/3]

template<typename BackendTag , typename T >
pfc::core::SparseVector< BackendTag, T >::SparseVector ( const std::vector< size_t > &  indices,
const std::vector< T > &  data 
)
inline

Construct SparseVector with indices and initial data.

Parameters
indicesLinear indices (will be sorted)
dataInitial values
Here is the call graph for this function:

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