-
Notifications
You must be signed in to change notification settings - Fork 298
/
LinearAlgLoopDefaultImplementation.cpp
77 lines (65 loc) · 1.72 KB
/
LinearAlgLoopDefaultImplementation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/** @addtogroup coreSystem
*
* @{
*/
#include <Core/ModelicaDefine.h>
#include <Core/Modelica.h>
#include <Core/System/FactoryExport.h>
#include <Core/System/LinearAlgLoopDefaultImplementation.h>
LinearAlgLoopDefaultImplementation::LinearAlgLoopDefaultImplementation()
: _dimAEq (0)
,_b(NULL)
,_AData(NULL)
,_Ax(NULL)
,_x0(NULL)
, _firstcall(true)
{
}
LinearAlgLoopDefaultImplementation::~LinearAlgLoopDefaultImplementation()
{
if(_b)
delete [] _b;
if (_x0)
delete [] _x0;
}
/// Provide number (dimension) of variables according to data type
int LinearAlgLoopDefaultImplementation::getDimReal() const
{
return _dimAEq;
}
int LinearAlgLoopDefaultImplementation::getDimZeroFunc() const
{
return _dimZeroFunc;
}
/// (Re-) initialize the system of equations
void LinearAlgLoopDefaultImplementation::initialize()
{
if ( _dimAEq == 0 )
throw ModelicaSimulationError(ALGLOOP_EQ_SYSTEM,"AlgLoop::initialize(): No constraint defined.");
if(_b)
delete [] _b;
_b = new double[_dimAEq];
memset(_b,0,_dimAEq*sizeof(double));
if(_x0)
delete [] _x0;
_x0 = new double[_dimAEq];
};
void LinearAlgLoopDefaultImplementation::getb(double* res) const
{
memcpy(res, _b, sizeof(double) * _dimAEq);
}
bool LinearAlgLoopDefaultImplementation::getUseSparseFormat(){
return _useSparseFormat;
}
void LinearAlgLoopDefaultImplementation::setUseSparseFormat(bool value){
_useSparseFormat = value;
}
void LinearAlgLoopDefaultImplementation::getRealStartValues(double* vars) const
{
memcpy(vars, _x0, sizeof(double) * _dimAEq);
}
//void LinearAlgLoopDefaultImplementation::getSparseAdata(double* data, int nonzeros)
//{
// memcpy(data, _AData, sizeof(double) * nonzeros);
//}
/** @} */ // end of coreSystem