OGS
LisVector.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <lis.h>
18
19#include <cassert>
20#include <string>
21#include <vector>
22
23namespace MathLib
24{
29{
30public:
32public:
37 explicit LisVector(std::size_t length);
38
44 LisVector(std::size_t length, double* data);
45
47 LisVector(LisVector const& src);
48
51 virtual ~LisVector();
52
54 std::size_t size() const;
55
57 std::size_t getRangeBegin() const { return 0; }
59 std::size_t getRangeEnd() const { return this->size(); }
60
61 // TODO preliminary
63
65 double operator[](IndexType rowId) const { return get(rowId); }
67 double get(IndexType rowId) const
68 {
69 double v = .0;
71 return v;
72 }
73
79
85
87 void write(const std::string& filename) const;
88
91
93 template <class T_SUBVEC>
94 void set(const std::vector<IndexType>& pos, const T_SUBVEC& sub_vec)
95 {
96 for (std::size_t i = 0; i < pos.size(); ++i)
97 {
98 set(pos[i], sub_vec[i]);
99 }
100 }
101
103 template <class T_SUBVEC>
104 void add(const std::vector<IndexType>& pos, const T_SUBVEC& sub_vec)
105 {
106 for (std::size_t i = 0; i < pos.size(); ++i)
107 {
108 add(pos[i], sub_vec[i]);
109 }
110 }
111
115 void copyValues(std::vector<double>& u) const
116 {
117 u.resize(size());
118 lis_vector_get_values(vec_, 0, size(), u.data());
119 }
120
121private:
123};
124
125} // MathLib
Lis vector wrapper class.
Definition LisVector.h:29
void add(IndexType rowId, double v)
add entry
Definition LisVector.h:81
LisVector(std::size_t length)
Definition LisVector.cpp:21
void add(const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
add entries
Definition LisVector.h:104
void copyValues(std::vector< double > &u) const
Definition LisVector.h:115
std::size_t getRangeEnd() const
return an end index of the active data range
Definition LisVector.h:59
void write(const std::string &filename) const
printout this equation for debugging
Definition LisVector.cpp:56
void set(const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
set entries
Definition LisVector.h:94
void set(IndexType rowId, double v)
set entry
Definition LisVector.h:75
virtual ~LisVector()
Definition LisVector.cpp:41
LIS_VECTOR & getRawVector()
return a raw Lis vector object
Definition LisVector.h:90
std::size_t size() const
return a vector length
Definition LisVector.cpp:46
double get(IndexType rowId) const
get entry
Definition LisVector.h:67
double operator[](IndexType rowId) const
access entry
Definition LisVector.h:65
LIS_VECTOR vec_
Definition LisVector.h:122
std::size_t getRangeBegin() const
return a start index of the active data range
Definition LisVector.h:57
static const double u
static const double v