OGS
LisVector.cpp
Go to the documentation of this file.
1
15#include "LisVector.h"
16
17#include "LisCheck.h"
18
19namespace MathLib
20{
21LisVector::LisVector(std::size_t length)
22{
23 lis_vector_create(0, &vec_);
24 lis_vector_set_size(vec_, 0, length);
25}
26
27LisVector::LisVector(std::size_t length, double* data)
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}
34
36{
37 lis_vector_duplicate(src.vec_, &vec_);
38 lis_vector_copy(src.vec_, vec_);
39}
40
42{
43 lis_vector_destroy(vec_);
44}
45
46std::size_t LisVector::size() const
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}
55
56void LisVector::write(const std::string& filename) const
57{
58 lis_output_vector(vec_, LIS_FMT_PLAIN, const_cast<char*>(filename.c_str()));
59}
60
61} // namespace MathLib
Definition of the LisVector class.
Lis vector wrapper class.
Definition LisVector.h:29
LisVector(std::size_t length)
Definition LisVector.cpp:21
void write(const std::string &filename) const
printout this equation for debugging
Definition LisVector.cpp:56
virtual ~LisVector()
Definition LisVector.cpp:41
std::size_t size() const
return a vector length
Definition LisVector.cpp:46
LIS_VECTOR vec_
Definition LisVector.h:123
bool checkLisError(int err)
Definition LisCheck.h:31