lowerTriangularMatrix.cc
Go to the documentation of this file.
3 
4 using namespace oBLAS;
5 
6 
8  ublas::triangular_matrix<double, ublas::lower>(i, i)
9 { }
10 
11 
12 lowerTriangularMatrix::lowerTriangularMatrix(const ublas::matrix<double>& r)
13  : ublas::triangular_matrix<double, ublas::lower>(r)
14 { }
15 
16 
18 {
19  delete fInverse;
20 }
21 
22 
23 void
24 lowerTriangularMatrix::operator=(const ublas::matrix<double>& r)
25 {
26  const unsigned int size = this->size1();
27  for (unsigned int i = 0; i < size; ++i)
28  for (unsigned int j = 0; j <= i; ++j)
29  (*this)(i, j) = r(i, j);
30 }
31 
32 
33 /* calculate and return inverse using recursive method from
34  V. Blobel and E. Lohrmann "Statistische und numerische
35  Methoden der Datenanalyse", Teubner Verlag, 1998 */
36 
39  const
40 {
41  const unsigned int size = this->size1();
42  if (!fInverse)
43  fInverse = new lowerTriangularMatrix(size);
44 
45  const double epsilon = std::numeric_limits<double>::epsilon();
46 
47  // some abbreviatons ...
48 
49  const lowerTriangularMatrix& t = *this;
51 
52  // first calculate diagonal elements ...
53  for (unsigned int i = 0; i < size; ++i) {
54  const double tmp = t(i, i);
55  if (fabs(tmp) > epsilon)
56  r(i, i) = 1/tmp;
57  else
59  }
60 
61  // ... then off diagonal
62  for (unsigned int i = 1; i < size; ++i) {
63  const double diag = t(i, i);
64  for (unsigned int k = 0; k < i; ++k) {
65  double sum = 0;
66  for (unsigned int j = k; j < i; ++j) {
67  sum += t(i, j) * r(j, k);
68  }
69  r(i, k) = -sum / diag;
70  }
71  }
72 
73  return fInverse;
74 }
void diag(const std::string &msg)
Definition: testlib.cc:59
lowerTriangularMatrix * fInverse
const lowerTriangularMatrix * GetInverse() const
void operator=(const ublas::matrix< double > &r)

, generated on Tue Sep 26 2023.