17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_BANDMATRIXSOLVER_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_BANDMATRIXSOLVER_H
54template <
int32_t BandW
idthT>
61 assert(N > 0 && Bdim > 0);
62 mA.resize(mN * BandWidthT, 0.);
63 mB.resize(mN * mBdim, 0.);
70 mA.assign(mA.size(), std::numeric_limits<double>::signaling_NaN());
71 mB.assign(mB.size(), std::numeric_limits<double>::signaling_NaN());
75 double&
A(int32_t
i, int32_t
j)
77 auto ij = std::minmax(
i,
j);
78 assert(ij.first >= 0 && ij.second < mN);
79 int32_t k = ij.second - ij.first;
80 assert(k < BandWidthT);
81 return mA[ij.first * BandWidthT + k];
85 double&
B(int32_t
i, int32_t
j)
87 assert(
i >= 0 && i < mN && j >= 0 &&
j < mBdim);
88 return mB[
i * mBdim +
j];
98 static int32_t
test(
bool prn = 0)
104 template <
int32_t nRows>
105 void triangulateBlock(
double AA[],
double bb[]);
107 template <
int32_t nCols>
108 void dioganalizeBlock(
double A[],
double b[]);
113 std::vector<double> mA;
114 std::vector<double> mB;
122template <
int32_t BandW
idthT>
123template <
int32_t nRows>
127 int32_t
m = BandWidthT;
130 double c = 1. /
A[0];
132 double* rowi =
A + BandWidthT - 1;
133 for (int32_t
i = 1;
i <
m;
i++) {
134 double ai =
c *
A[
i];
135 for (int32_t
j =
i;
j <
m;
j++) {
136 rowi[
j] -= ai *
A[
j];
139 rowi += BandWidthT - 1;
146 for (int32_t k = 0; k < mBdim; k++) {
147 int32_t
m = BandWidthT;
152 for (int32_t
i = 1;
i <
m;
i++) {
153 b[mBdim *
i + k] -=
A[
i] * bk;
163template <
int32_t BandW
idthT>
164template <
int32_t nCols>
165inline void BandMatrixSolver<BandWidthT>::dioganalizeBlock(
double AA[],
double bb[])
167 for (int32_t k = 0; k < mBdim; k++) {
168 int32_t
rows = BandWidthT;
173 for (int32_t
i = 1;
i <
rows;
i++) {
174 b[-
i * mBdim + k] -=
A[BandWidthT * (-
i) +
i] * bk;
183template <
int32_t BandW
idthT>
188 const int32_t stepA = BandWidthT;
189 const int32_t stepB = mBdim;
195 for (; k < mN - BandWidthT; k += 1, Ak += stepA, bk += stepB) {
196 triangulateBlock<1>(Ak, bk);
199 triangulateBlock<BandWidthT>(Ak, bk);
205 double* Ak = &mA[BandWidthT * k];
206 double* bk = &mB[mBdim * k];
207 for (; k > BandWidthT - 1; k -= 1, Ak -= stepA, bk -= stepB) {
208 dioganalizeBlock<1>(Ak, bk);
211 dioganalizeBlock<BandWidthT>(Ak, bk);
215template <
int32_t BandW
idthT>
233 const int32_t stepA = 2 * BandWidthT;
234 const int32_t stepB = 2 * mBdim;
240 for (; k < mN - BandWidthT; k += 2, Ak += stepA, bk += stepB) {
241 triangulateBlock<2>(Ak, bk);
244 triangulateBlock<BandWidthT>(Ak, bk);
250 double* Ak = &mA[BandWidthT * k];
251 double* bk = &mB[mBdim * k];
252 for (; k > BandWidthT - 1; k -= 2, Ak -= stepA, bk -= stepB) {
253 dioganalizeBlock<2>(Ak, bk);
256 dioganalizeBlock<BandWidthT>(Ak, bk);
double & A(int32_t i, int32_t j)
access to A elements
double & B(int32_t i, int32_t j)
access to B elements
static int32_t test(bool prn=0)
Test the class functionality. Returns 1 when ok, 0 when not ok.
void initWithNaN()
debug tool: init arrays with NaN's
BandMatrixSolver(int32_t N, int32_t Bdim)
Consructor.
void solve()
solve the equation
void solveType1()
solve an equation of a special type
GLboolean GLboolean GLboolean b
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< ReadoutWindowData > rows