17 template <
typename Real>
27 inline std::vector<Real>&
GetDBand();
28 inline std::vector<Real>
const&
GetDBand()
const;
29 inline std::vector<std::vector<Real>>&
GetLBands();
30 inline std::vector<std::vector<Real>>
const&
GetLBands()
const;
31 inline std::vector<std::vector<Real>>&
GetUBands();
32 inline std::vector<std::vector<Real>>
const&
GetUBands()
const;
64 template <
bool RowMajor>
75 template <
bool RowMajor>
93 template <
bool RowMajor>
94 bool SolveLower(Real* dataMatrix,
int numColumns)
const;
100 template <
bool RowMajor>
101 bool SolveUpper(Real* dataMatrix,
int numColumns)
const;
113 template <
typename Real>
118 template <
typename Real>
125 && 0 <= numLBands && numLBands < size
126 && 0 <= numUBands && numUBands < size)
134 int numElements = size - 1;
137 band.resize(numElements--);
138 std::fill(band.begin(), band.end(), (Real)0);
145 int numElements = size - 1;
148 band.resize(numElements--);
149 std::fill(band.begin(), band.end(), (Real)0);
160 template <
typename Real>
inline 166 template <
typename Real>
inline 172 template <
typename Real>
inline 178 template <
typename Real>
inline 184 template <
typename Real>
inline 190 template <
typename Real>
inline 196 template <
typename Real>
inline 202 template <
typename Real>
205 if (0 <= r && r <
mSize && 0 <= c && c <
mSize)
210 int const numUBands =
static_cast<int>(
mUBands.size());
211 if (--band < numUBands && r <
mSize - 1 - band)
219 int const numLBands =
static_cast<int>(
mLBands.size());
220 if (--band < numLBands && c <
mSize - 1 - band)
239 template <
typename Real>
242 if (0 <= r && r <
mSize && 0 <= c && c <
mSize)
247 int const numUBands =
static_cast<int>(
mUBands.size());
248 if (--band < numUBands && r <
mSize - 1 - band)
256 int const numLBands =
static_cast<int>(
mLBands.size());
257 if (--band < numLBands && c <
mSize - 1 - band)
276 template <
typename Real>
285 int const sizeM1 =
mSize - 1;
286 int const numBands =
static_cast<int>(
mLBands.size());
289 for (
int i = 0; i <
mSize; ++i)
291 int jMin = i - numBands;
298 for (j = jMin; j < i; ++j)
306 for (k = i; k <= kMax; ++k)
318 for (k = 0; k < i; ++k)
324 if (diagonal <= (Real)0)
328 Real invSqrt = ((Real)1) / sqrt(diagonal);
329 for (k = i; k <= kMax; ++k)
338 template <
typename Real>
346 template <
typename Real>
347 template <
bool RowMajor>
351 && SolveLower<RowMajor>(bMatrix, numBColumns)
352 && SolveUpper<RowMajor>(bMatrix, numBColumns);
355 template <
typename Real>
356 template <
bool RowMajor>
364 for (
int col = 0; col <
mSize; ++col)
368 invA(
row, col) = (Real)0;
381 Real diag = tmpA(
row,
row);
387 Real invDiag = ((Real)1) / diag;
391 int colMin =
row + 1;
392 int colMax = colMin +
static_cast<int>(
mUBands.size());
399 for (c = colMin; c < colMax; ++
c)
401 tmpA(
row, c) *= invDiag;
403 for (c = 0; c <=
row; ++
c)
405 invA(
row, c) *= invDiag;
409 int rowMin =
row + 1;
410 int rowMax = rowMin +
static_cast<int>(
mLBands.size());
416 for (
int r = rowMin;
r < rowMax; ++
r)
418 Real mult = tmpA(
r,
row);
419 tmpA(
r,
row) = (Real)0;
420 for (c = colMin; c < colMax; ++
c)
422 tmpA(
r, c) -= mult*tmpA(
row, c);
424 for (c = 0; c <=
row; ++
c)
426 invA(
r, c) -= mult*invA(
row, c);
432 for (
int row = mSize - 1;
row >= 1; --
row)
434 int rowMax =
row - 1;
435 int rowMin =
row -
static_cast<int>(
mUBands.size());
441 for (
int r = rowMax;
r >= rowMin; --
r)
443 Real mult = tmpA(
r,
row);
444 tmpA(
r,
row) = (Real)0;
447 invA(
r,
c) -= mult*invA(
row,
c);
455 template <
typename Real>
458 int const size =
static_cast<int>(
mDBand.size());
462 if (lowerRR >(Real)0)
464 for (
int c = 0;
c <
r; ++
c)
467 dataVector[
r] -= lowerRC * dataVector[
c];
469 dataVector[
r] /= lowerRR;
479 template <
typename Real>
482 int const size =
static_cast<int>(
mDBand.size());
483 for (
int r = size - 1;
r >= 0; --
r)
486 if (upperRR > (Real)0)
491 dataVector[
r] -= upperRC * dataVector[
c];
494 dataVector[
r] /= upperRR;
504 template <
typename Real>
505 template <
bool RowMajor>
513 if (lowerRR >(Real)0)
515 for (
int c = 0;
c <
r; ++
c)
518 for (
int bCol = 0; bCol < numColumns; ++bCol)
520 data(r, bCol) -= lowerRC *
data(
c, bCol);
524 Real inverse = ((Real)1) / lowerRR;
525 for (
int bCol = 0; bCol < numColumns; ++bCol)
527 data(r, bCol) *= inverse;
538 template <
typename Real>
539 template <
bool RowMajor>
544 for (
int r =
mSize - 1;
r >= 0; --
r)
547 if (upperRR > (Real)0)
552 for (
int bCol = 0; bCol < numColumns; ++bCol)
558 Real inverse = ((Real)1) / upperRR;
559 for (
int bCol = 0; bCol < numColumns; ++bCol)
561 data(
r, bCol) *= inverse;
std::vector< std::vector< Real > > mLBands
std::vector< Real > & GetDBand()
std::vector< Real > mDBand
BandedMatrix(int size, int numLBands, int numUBands)
std::vector< std::vector< Real > > & GetLBands()
Real & operator()(int r, int c)
std::vector< std::vector< Real > > mUBands
GLenum GLenum GLsizei void * row
bool SolveUpper(Real *dataVector) const
bool SolveLower(Real *dataVector) const
bool SolveSystem(Real *bVector)
std::vector< std::vector< Real > > & GetUBands()
bool ComputeInverse(Real *inverse) const