-
Notifications
You must be signed in to change notification settings - Fork 9
/
LiBandedDirectSolver.cpp
99 lines (86 loc) · 2.25 KB
/
LiBandedDirectSolver.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "LiBandedDirectSolver.h"
namespace Daetk
{
LiBandedDirectSolver::LiBandedDirectSolver():
neq(0),
kl(0),
ku(0),
LEAD_DIM_STORAGE(0),
errorFlag(true),
arrayptr(0),
pivotptr(0),
x(this),
BCM(0)
{
Tracer tr("LiBandedDirectSolver::LiBandedDirectSolver()");
}
LiBandedDirectSolver::LiBandedDirectSolver(BandColMat& BCMin):
neq(BCMin.getNeq()),
kl(BCMin.getLowerBandWidth()),
ku(BCMin.getUpperBandWidth()),
LEAD_DIM_STORAGE(2*kl+ku+1),
arrayptr(0),
x(this,BCMin.getNeq()),
BCM(&BCMin)
{
Tracer tr("LiBandedDirectSolver::LiBandedDirectSolver(BandColMat& BCMin)");
arrayptr=BCMin.castToArray();
pivotptr=new int[neq];
}
LiBandedDirectSolver::~LiBandedDirectSolver()
{
Tracer tr("LiBandedDirectSolver::~LiBandedDirectSolver()");
delete [] pivotptr;
}
bool LiBandedDirectSolver::prepare()
{
errorFlag = 0;
/*void dgbfa(double* abd,const int& lda,const int& n,
const int& ml,const int& mu,int* ipvt, int& info)*/
#ifndef CRAYCC
#ifndef USE_SINGLE_PRECISION
F77NAME(dgbfa)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,errorFlag);
#else
F77NAME(sgbfa)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,errorFlag);
#endif
#else
#ifndef USE_SINGLE_PRECISION
F77NAME(DGBFA)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,errorFlag);
#else
F77NAME(SGBFA)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,errorFlag);
#endif
#endif
return errorFlag;
}
bool LiBandedDirectSolver::solve(const Vec& bIn,Vec& xIn)
{
errorFlag = 0;
#ifndef USE_BLAS
xIn=bIn;
#else
copy(bIn,xIn);
#endif
x.attachToTarget(xIn);
/*void dgbsl(double* abd,const int& lda,const int& n,const int& ml,
const int& mu,int* ipvt,double* b,int& job);*/
#ifndef CRAYCC
#ifndef USE_SINGLE_PRECISION
F77NAME(dgbsl)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,x.v_.castToArray(),
errorFlag);
#else
F77NAME(sgbsl)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,x.v_.castToArray(),
errorFlag);
#endif
#else
#ifndef USE_SINGLE_PRECISION
F77NAME(DGBSL)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,x.v_.castToArray(),
errorFlag);
#else
F77NAME(SGBSL)(arrayptr,LEAD_DIM_STORAGE,neq,kl,ku,pivotptr,x.v_.castToArray(),
errorFlag);
#endif
#endif
x.restoreToTarget();
return errorFlag;
}
}//Daetk