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_VECTORgetRawVector ()
 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{
24 lis_vector_set_size(vec_, 0, length);
25}
void set(IndexType rowId, double v)
set entry
Definition LisVector.h:75
LIS_VECTOR vec_
Definition LisVector.h:122

References set(), and 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{
30 lis_vector_set_size(vec_, 0, length);
31 for (std::size_t i = 0; i < length; i++)
33}

References set(), and vec_.

◆ LisVector() [3/3]

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

copy constructor

Definition at line 35 of file LisVector.cpp.

36{
39}

References set(), and vec_.

◆ ~LisVector()

MathLib::LisVector::~LisVector ( )
virtual

Definition at line 41 of file LisVector.cpp.

42{
44}

References set(), and 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 104 of file LisVector.h.

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

References add(), and set().

◆ add() [2/2]

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

add entry

Definition at line 81 of file LisVector.h.

82 {
84 }
static const double v

References set(), 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 115 of file LisVector.h.

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

References set(), size(), MathLib::u, 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;
71 return v;
72 }

References set(), 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 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::EigenLisLinearSolver::solve().

◆ operator[]()

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(), and set().

◆ 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 94 of file LisVector.h.

95 {
96 for (std::size_t i = 0; i < pos.size(); ++i)
97 {
98 set(pos[i], sub_vec[i]);
99 }
100 }

References set().

◆ set() [2/2]

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

set entry

Definition at line 75 of file LisVector.h.

References set(), MathLib::v, and vec_.

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

◆ setZero()

void MathLib::LisVector::setZero ( )
inline

Definition at line 62 of file LisVector.h.

62{ lis_vector_set_all(0.0, vec_); }

References set(), and vec_.

◆ size()

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

return a vector length

Definition at line 46 of file LisVector.cpp.

47{
50 int const ierr = lis_vector_get_size(vec_, &dummy, &size);
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(), set(), 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 set(), and vec_.

Member Data Documentation

◆ vec_

LIS_VECTOR MathLib::LisVector::vec_
private

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