SenK
SenK is a C++ library for high-performance linear solvers.
senk::sparse::SpVec< T1, T2 > Class Template Reference

Sparse vector class. More...

#include <senk_class.hpp>

Public Member Functions

 SpVec ()
 Constructor. More...
 
 ~SpVec ()
 Destructor. More...
 
void Append (T1 t_val, T2 t_lev, int t_idx)
 Append argument values to the arrays. More...
 
void Append (T1 *t_val, T2 *t_lev, int *t_idx, int t_len)
 Append argument values to the arrays. More...
 
int GetLen ()
 Return len. More...
 
T1 GetVal (int i)
 Return i-th value of val. More...
 
T2 GetLev (int i)
 Return i-th value of lev. More...
 
int GetIdx (int i)
 Return i-th value of idx. More...
 
std::tuple< T1, T2, int > Get (int i)
 Return the tuple of i-th values of val, lev, and idx. More...
 
void Clear ()
 Set the value of len to 0. More...
 

Private Attributes

T1 * val
 An array that stores the values of the nonzero elements. More...
 
T2 * lev
 An array that stores the supplemental values of the nonzero elements. More...
 
int * idx
 An array that stores the indices of the nonzero elements. More...
 
int len
 The number of the nonzero elements. More...
 
int mlen
 The size of allocated memories. More...
 

Detailed Description

template<typename T1, typename T2>
class senk::sparse::SpVec< T1, T2 >

Sparse vector class.

Template Parameters
T1Type of the val array.
T2Type of the lev array.

Definition at line 24 of file senk_class.hpp.

Constructor & Destructor Documentation

◆ SpVec()

template<typename T1 , typename T2 >
senk::sparse::SpVec< T1, T2 >::SpVec ( )
inline

Constructor.

Allocate memory of size SP_LEN.

Definition at line 41 of file senk_class.hpp.

◆ ~SpVec()

template<typename T1 , typename T2 >
senk::sparse::SpVec< T1, T2 >::~SpVec ( )
inline

Destructor.

Free all memories for the arrays.

Definition at line 52 of file senk_class.hpp.

Member Function Documentation

◆ Append() [1/2]

template<typename T1 , typename T2 >
void senk::sparse::SpVec< T1, T2 >::Append ( T1 *  t_val,
T2 *  t_lev,
int *  t_idx,
int  t_len 
)
inline

Append argument values to the arrays.

Parameters
t_valValues to be appended to val.
t_levValues to be appended to lev.
t_idxValues to be appended to idx.
t_lenLength of these argument values.

Definition at line 82 of file senk_class.hpp.

◆ Append() [2/2]

template<typename T1 , typename T2 >
void senk::sparse::SpVec< T1, T2 >::Append ( T1  t_val,
T2  t_lev,
int  t_idx 
)
inline

Append argument values to the arrays.

Parameters
t_valA value to be appended to val.
t_levA value to be appended to lev.
t_idxA value to be appended to idx.

Definition at line 63 of file senk_class.hpp.

◆ Clear()

template<typename T1 , typename T2 >
void senk::sparse::SpVec< T1, T2 >::Clear ( )
inline

Set the value of len to 0.

Definition at line 122 of file senk_class.hpp.

◆ Get()

template<typename T1 , typename T2 >
std::tuple< T1, T2, int > senk::sparse::SpVec< T1, T2 >::Get ( int  i)
inline

Return the tuple of i-th values of val, lev, and idx.

Definition at line 115 of file senk_class.hpp.

◆ GetIdx()

template<typename T1 , typename T2 >
int senk::sparse::SpVec< T1, T2 >::GetIdx ( int  i)
inline

Return i-th value of idx.

Definition at line 111 of file senk_class.hpp.

◆ GetLen()

template<typename T1 , typename T2 >
int senk::sparse::SpVec< T1, T2 >::GetLen ( )
inline

Return len.

Definition at line 99 of file senk_class.hpp.

◆ GetLev()

template<typename T1 , typename T2 >
T2 senk::sparse::SpVec< T1, T2 >::GetLev ( int  i)
inline

Return i-th value of lev.

Definition at line 107 of file senk_class.hpp.

◆ GetVal()

template<typename T1 , typename T2 >
T1 senk::sparse::SpVec< T1, T2 >::GetVal ( int  i)
inline

Return i-th value of val.

Definition at line 103 of file senk_class.hpp.

Member Data Documentation

◆ idx

template<typename T1 , typename T2 >
int* senk::sparse::SpVec< T1, T2 >::idx
private

An array that stores the indices of the nonzero elements.

Definition at line 31 of file senk_class.hpp.

◆ len

template<typename T1 , typename T2 >
int senk::sparse::SpVec< T1, T2 >::len
private

The number of the nonzero elements.

Definition at line 33 of file senk_class.hpp.

◆ lev

template<typename T1 , typename T2 >
T2* senk::sparse::SpVec< T1, T2 >::lev
private

An array that stores the supplemental values of the nonzero elements.

Definition at line 29 of file senk_class.hpp.

◆ mlen

template<typename T1 , typename T2 >
int senk::sparse::SpVec< T1, T2 >::mlen
private

The size of allocated memories.

Definition at line 35 of file senk_class.hpp.

◆ val

template<typename T1 , typename T2 >
T1* senk::sparse::SpVec< T1, T2 >::val
private

An array that stores the values of the nonzero elements.

Definition at line 27 of file senk_class.hpp.


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