47 const std::vector<unsigned int>* anIndex,
48 const std::vector<double>* aVector) {
50 for (
unsigned int i = 0;
i < anIndex->size(); ++
i) {
51 int iIndex = (*anIndex)[
i] - 1;
52 for (
unsigned int j = 0;
j <=
i; ++
j) {
53 int jIndex = (*anIndex)[
j] - 1;
54 if (iIndex < nBorder) {
55 theBorder(iIndex, jIndex) += (*aVector)[
i] * aWeight
57 }
else if (jIndex < nBorder) {
58 theMixed(jIndex, iIndex - nBorder) += (*aVector)[
i] * aWeight
61 unsigned int nBand = iIndex - jIndex;
62 theBand(nBand, jIndex - nBorder) += (*aVector)[
i] * aWeight
76 const std::vector<unsigned int> anIndex)
const {
78 TMatrixDSym aMatrix(anIndex.size());
80 for (
unsigned int i = 0;
i < anIndex.size(); ++
i) {
81 int iIndex = anIndex[
i] - 1;
82 for (
unsigned int j = 0;
j <=
i; ++
j) {
83 int jIndex = anIndex[
j] - 1;
84 if (iIndex < nBorder) {
86 }
else if (jIndex < nBorder) {
87 aMatrix(
i,
j) = -
theMixed(jIndex, iIndex - nBorder);
89 unsigned int nBand = iIndex - jIndex;
90 aMatrix(
i,
j) =
theBand(nBand, jIndex - nBorder);
92 aMatrix(
j,
i) = aMatrix(
i,
j);
141 const VVector borderSolution = inverseBorder * auxVec;
145 aSolution.
putVec(borderSolution);
159 std::cout <<
"Border part " << std::endl;
182 for (
int i = 0;
i < nCol; ++
i) {
185 for (
int i = 0;
i < nCol; ++
i) {
216 VVector aSolution(aRightHandSide);
217 for (
int i = 0;
i < nCol; ++
i)
223 for (
int i = nCol - 1;
i >= 0;
i--)
225 double rxw =
theBand(0,
i) * aSolution(
i);
245 VMatrix aSolution(aRightHandSide);
246 for (
unsigned int iBorder = 0; iBorder <
numBorder; iBorder++) {
247 for (
int i = 0;
i < nCol; ++
i)
251 * aSolution(iBorder,
i);
254 for (
int i = nCol - 1;
i >= 0;
i--)
256 double rxw =
theBand(0,
i) * aSolution(iBorder,
i);
260 aSolution(iBorder,
i) = rxw;
274 VMatrix inverseBand(nRow, nCol);
276 for (
int i = nCol - 1;
i >= 0;
i--) {
280 rxw -= inverseBand(
abs(
i -
k), std::min(
i,
k))
283 inverseBand(
i -
j,
j) = rxw;
300 VMatrix aBand((nBand + 1), nCol);
301 for (
int i = 0;
i < nCol; ++
i) {
304 for (
int l = 0;
l < nBorder; ++
l) {
305 sum += anArray(
i,
l) * aSymArray(
l,
l) * anArray(
j,
l);
306 for (
int k = 0;
k <
l; ++
k) {
307 sum += anArray(
i, l) * aSymArray(l,
k) * anArray(
j,
k)
308 + anArray(
i,
k) * aSymArray(l,
k) * anArray(
j, l);
311 aBand(
i -
j,
j) = sum;
void printMatrix() const
Print bordered band matrix.
VVector getVec(unsigned int len, unsigned int start=0) const
Get part of vector.
void addBlockMatrix(double aWeight, const std::vector< unsigned int > *anIndex, const std::vector< double > *aVector)
Add symmetric block matrix.
void print() const
Print matrix.
unsigned int getNumRows() const
Get number of rows.
Simple Matrix based on std::vector<double>
virtual ~BorderedBandMatrix()
unsigned int invert()
Matrix inversion.
BorderedBandMatrix()
Create bordered band matrix.
void putVec(const VVector &aVector, unsigned int start=0)
Put part of vector.
void resize(const unsigned int nRows, const unsigned int nCols)
Resize Matrix.
unsigned int numCol
Band matrix size.
void resize(const unsigned int nRows)
Resize symmetric matrix.
VMatrix transpose() const
Get transposed matrix.
VMatrix invertBand()
Invert band part.
VMatrix theMixed
Mixed part.
Abs< T >::type abs(const T &t)
void decomposeBand()
(root free) Cholesky decomposition of band part: C=LDL^T
Namespace for the general broken lines package.
unsigned int numBorder
Border size.
Simple symmetric Matrix based on std::vector<double>
VSymMatrix theBorder
Border part.
void print() const
Print matrix.
unsigned int getNumCols() const
Get number of columns.
void resize(unsigned int nSize, unsigned int nBorder=1, unsigned int nBand=5)
Resize bordered band matrix.
VMatrix theBand
Band part.
VMatrix bandOfAVAT(const VMatrix &anArray, const VSymMatrix &aSymArray) const
Calculate band part of: 'anArray * aSymArray * anArray.T'.
Simple Vector based on std::vector<double>
TMatrixDSym getBlockMatrix(const std::vector< unsigned int > anIndex) const
Retrieve symmetric block matrix.
unsigned int numSize
Matrix size.
VVector solveBand(const VVector &aRightHandSide) const
Solve for band part.
void solveAndInvertBorderedBand(const VVector &aRightHandSide, VVector &aSolution)
Solve linear equation system, partially calculate inverse.
unsigned int numBand
Band width.