OGS
LisVector.cpp
Go to the documentation of this file.
1
15
#include "
LisVector.h
"
16
17
#include "
LisCheck.h
"
18
19
namespace
MathLib
20
{
21
LisVector::LisVector
(std::size_t length)
22
{
23
lis_vector_create(0, &
vec_
);
24
lis_vector_set_size(
vec_
, 0, length);
25
}
26
27
LisVector::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
35
LisVector::LisVector
(
LisVector
const
& src)
36
{
37
lis_vector_duplicate(src.
vec_
, &
vec_
);
38
lis_vector_copy(src.
vec_
,
vec_
);
39
}
40
41
LisVector::~LisVector
()
42
{
43
lis_vector_destroy(
vec_
);
44
}
45
46
std::size_t
LisVector::size
()
const
47
{
48
IndexType
dummy;
49
IndexType
size
;
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
56
void
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
LisCheck.h
LisVector.h
Definition of the LisVector class.
MathLib::LisVector
Lis vector wrapper class.
Definition
LisVector.h:29
MathLib::LisVector::LisVector
LisVector(std::size_t length)
Definition
LisVector.cpp:21
MathLib::LisVector::write
void write(const std::string &filename) const
printout this equation for debugging
Definition
LisVector.cpp:56
MathLib::LisVector::~LisVector
virtual ~LisVector()
Definition
LisVector.cpp:41
MathLib::LisVector::size
std::size_t size() const
return a vector length
Definition
LisVector.cpp:46
MathLib::LisVector::vec_
LIS_VECTOR vec_
Definition
LisVector.h:123
MathLib::LisVector::IndexType
LIS_INT IndexType
Definition
LisVector.h:31
MathLib
Definition
CreateComponent.h:32
MathLib::checkLisError
bool checkLisError(int err)
Definition
LisCheck.h:31
MathLib
LinAlg
Lis
LisVector.cpp
Generated by
1.11.0