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

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:110

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

Definition at line 94 of file LisVector.h.

95  {
96  for (std::size_t i = 0; i < pos.size(); ++i)
97  {
98  this->add(pos[i], sub_vec[i]);
99  }
100  }
void add(IndexType rowId, double v)
add entry
Definition: LisVector.h:81

References add().

◆ add() [2/2]

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

add entry

Definition at line 81 of file LisVector.h.

82  {
83  lis_vector_set_value(LIS_ADD_VALUE, rowId, v, vec_);
84  }

References vec_.

Referenced by add().

◆ copyValues()

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

Copy vector values.

Definition at line 103 of file LisVector.h.

104  {
105  assert(u.size() == size());
106  lis_vector_get_values(vec_, 0, size(), u.data());
107  }
std::size_t size() const
return a vector length
Definition: LisVector.cpp:46

References size(), and vec_.

◆ get()

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

get entry

Definition at line 67 of file LisVector.h.

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

References 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 57 of file LisVector.h.

57 { return 0; }

◆ getRangeEnd()

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

return an end index of the active data range

Definition at line 59 of file LisVector.h.

59 { return this->size(); }

References size().

◆ getRawVector()

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

return a raw Lis vector object

Definition at line 90 of file LisVector.h.

90 { return vec_; }

References vec_.

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

◆ operator[]()

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

access entry

Definition at line 65 of file LisVector.h.

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

References get().

◆ set()

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

set entry

Definition at line 75 of file LisVector.h.

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

References vec_.

◆ setZero()

void MathLib::LisVector::setZero ( )
inline

Definition at line 62 of file LisVector.h.

62 { 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 }
LIS_INT IndexType
Definition: LisVector.h:31
bool checkLisError(int err)
Definition: LisCheck.h:32

References MathLib::checkLisError(), and vec_.

Referenced by copyValues(), getRangeEnd(), 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

Definition at line 110 of file LisVector.h.

Referenced by LisVector(), ~LisVector(), add(), copyValues(), get(), getRawVector(), set(), setZero(), size(), and write().


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