OGS
MathLib::LisVector Class Reference

Detailed Description

Lis vector wrapper class.

Definition at line 28 of file LisVector.h.

#include <LisVector.h>

Public Types

using IndexType = LIS_INT
 

Public Member Functions

 LisVector (std::size_t length)
 
 LisVector (std::size_t length, double *data)
 
 LisVector (LisVector const &src)
 copy constructor
 
virtual ~LisVector ()
 
std::size_t size () const
 return a vector length
 
std::size_t getRangeBegin () const
 return a start index of the active data range
 
std::size_t getRangeEnd () const
 return an end index of the active data range
 
void setZero ()
 
double operator[] (IndexType rowId) const
 access entry
 
double get (IndexType rowId) const
 get entry
 
void set (IndexType rowId, double v)
 set entry
 
void add (IndexType rowId, double v)
 add entry
 
void write (const std::string &filename) const
 printout this equation for debugging
 
LIS_VECTOR & getRawVector ()
 return a raw Lis vector object
 
template<class T_SUBVEC >
void set (const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
 set entries
 
template<class T_SUBVEC >
void add (const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
 add entries
 
void copyValues (std::vector< double > &u) const
 

Private Attributes

LIS_VECTOR vec_
 

Member Typedef Documentation

◆ IndexType

Definition at line 31 of file LisVector.h.

Constructor & Destructor Documentation

◆ LisVector() [1/3]

MathLib::LisVector::LisVector ( std::size_t length)
explicit

Constructor for initialization of the number of rows

Parameters
lengthnumber of rows

Definition at line 21 of file LisVector.cpp.

22{
23 lis_vector_create(0, &vec_);
24 lis_vector_set_size(vec_, 0, length);
25}
LIS_VECTOR vec_
Definition LisVector.h:123

References vec_.

◆ LisVector() [2/3]

MathLib::LisVector::LisVector ( std::size_t length,
double * data )

Constructor using the given raw data

Parameters
lengththe length of the vector
datathe raw data

Definition at line 27 of file LisVector.cpp.

28{
29 lis_vector_create(0, &vec_);
30 lis_vector_set_size(vec_, 0, length);
31 for (std::size_t i = 0; i < length; i++)
32 lis_vector_set_value(LIS_INS_VALUE, i, data[i], vec_);
33}

References vec_.

◆ LisVector() [3/3]

MathLib::LisVector::LisVector ( LisVector const & src)

copy constructor

Definition at line 35 of file LisVector.cpp.

36{
37 lis_vector_duplicate(src.vec_, &vec_);
38 lis_vector_copy(src.vec_, vec_);
39}

References vec_.

◆ ~LisVector()

MathLib::LisVector::~LisVector ( )
virtual

Definition at line 41 of file LisVector.cpp.

42{
43 lis_vector_destroy(vec_);
44}

References vec_.

Member Function Documentation

◆ add() [1/2]

template<class T_SUBVEC >
void MathLib::LisVector::add ( const std::vector< IndexType > & pos,
const T_SUBVEC & sub_vec )
inline

add entries

Definition at line 105 of file LisVector.h.

106 {
107 for (std::size_t i = 0; i < pos.size(); ++i)
108 {
109 add(pos[i], sub_vec[i]);
110 }
111 }
void add(IndexType rowId, double v)
add entry
Definition LisVector.h:82

References add().

◆ add() [2/2]

void MathLib::LisVector::add ( IndexType rowId,
double v )
inline

add entry

Definition at line 82 of file LisVector.h.

83 {
84 lis_vector_set_value(LIS_ADD_VALUE, rowId, v, vec_);
85 }
static const double v

References MathLib::v, and vec_.

Referenced by add().

◆ copyValues()

void MathLib::LisVector::copyValues ( std::vector< double > & u) const
inline

Copy local entries to a vector.

Parameters
ua vector for the values of local entries. It will be resized to hold the current vector data.

Definition at line 116 of file LisVector.h.

117 {
118 u.resize(size());
119 lis_vector_get_values(vec_, 0, size(), u.data());
120 }
std::size_t size() const
return a vector length
Definition LisVector.cpp:46
static const double u

References size(), MathLib::u, and vec_.

◆ get()

double MathLib::LisVector::get ( IndexType rowId) const
inline

get entry

Definition at line 68 of file LisVector.h.

69 {
70 double v = .0;
71 lis_vector_get_value(vec_, rowId, &v);
72 return v;
73 }

References MathLib::v, and vec_.

Referenced by operator[]().

◆ getRangeBegin()

std::size_t MathLib::LisVector::getRangeBegin ( ) const
inline

return a start index of the active data range

Definition at line 58 of file LisVector.h.

58{ return 0; }

◆ getRangeEnd()

std::size_t MathLib::LisVector::getRangeEnd ( ) const
inline

return an end index of the active data range

Definition at line 60 of file LisVector.h.

60{ return this->size(); }

References size().

◆ getRawVector()

LIS_VECTOR & MathLib::LisVector::getRawVector ( )
inline

return a raw Lis vector object

Definition at line 91 of file LisVector.h.

91{ return vec_; }

References vec_.

Referenced by MathLib::EigenLisLinearSolver::solve().

◆ operator[]()

double MathLib::LisVector::operator[] ( IndexType rowId) const
inline

access entry

Definition at line 66 of file LisVector.h.

66{ return get(rowId); }
double get(IndexType rowId) const
get entry
Definition LisVector.h:68

References get().

◆ set() [1/2]

template<class T_SUBVEC >
void MathLib::LisVector::set ( const std::vector< IndexType > & pos,
const T_SUBVEC & sub_vec )
inline

set entries

Definition at line 95 of file LisVector.h.

96 {
97 for (std::size_t i = 0; i < pos.size(); ++i)
98 {
99 set(pos[i], sub_vec[i]);
100 }
101 }
void set(IndexType rowId, double v)
set entry
Definition LisVector.h:76

References set().

◆ set() [2/2]

void MathLib::LisVector::set ( IndexType rowId,
double v )
inline

set entry

Definition at line 76 of file LisVector.h.

77 {
78 lis_vector_set_value(LIS_INS_VALUE, rowId, v, vec_);
79 }

References MathLib::v, and vec_.

Referenced by set().

◆ setZero()

void MathLib::LisVector::setZero ( )
inline

Definition at line 63 of file LisVector.h.

63{ lis_vector_set_all(0.0, vec_); }

References vec_.

◆ size()

std::size_t MathLib::LisVector::size ( ) const

return a vector length

Definition at line 46 of file LisVector.cpp.

47{
48 IndexType dummy;
50 int const ierr = lis_vector_get_size(vec_, &dummy, &size);
51 checkLisError(ierr);
52 assert(size >= 0); // For safe implicit conversion to std::size_t.
53 return size;
54}
bool checkLisError(int err)
Definition LisCheck.h:31

References MathLib::checkLisError(), size(), and vec_.

Referenced by copyValues(), getRangeEnd(), size(), and MathLib::EigenLisLinearSolver::solve().

◆ write()

void MathLib::LisVector::write ( const std::string & filename) const

printout this equation for debugging

Definition at line 56 of file LisVector.cpp.

57{
58 lis_output_vector(vec_, LIS_FMT_PLAIN, const_cast<char*>(filename.c_str()));
59}

References vec_.

Member Data Documentation

◆ vec_

LIS_VECTOR MathLib::LisVector::vec_
private

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