19 #define REPORT { static ExeCounter ExeCount(__LINE__,14); ++ExeCount; } 37 for (
int i=0; i<nr; i++)
40 for (
int j=0; j<i; j++)
42 Real* tk = ti; sum = 0.0; k = j;
43 while (k--) { sum += *tj++ * *tk++; }
44 *tk = (*s++ - sum) / *tj++;
47 while (k--) { sum +=
square(*ti++); }
58 Tracer trace(
"Band-Cholesky");
63 for (
int i=0; i<nr; i++)
66 if (i<m) {
REPORT l = m-i; s += l; ti += l; l = i; }
67 else {
REPORT t += (m+1); l = m; }
69 for (
int j=0; j<l; j++)
71 Real* tk = ti; sum = 0.0;
int k = j; tj += (m-j);
72 while (k--) { sum += *tj++ * *tk++; }
73 *tk = (*s++ - sum) / *tj++;
76 while (l--) { sum +=
square(*ti++); }
98 int ncols = chol.
Nrows();
102 for(
int j = 1; j <= ncols; ++j)
105 for(
int k = 1; k < j; ++k)
106 GivensRotation(cGivens(k), sGivens(k), chol(k,j), r1Modification(j));
109 pythag(chol(j,j), r1Modification(j), cGivens(j), sGivens(j));
113 Real tmp0 = cGivens(j) * chol(j,j) + sGivens(j) * r1Modification(j);
114 chol(j,j) = tmp0; r1Modification(j) = 0.0;
125 int nRC = chol.
Nrows();
132 for (i = 1; i <= nRC; ++i)
136 for(
int k = 1; k < i; ++k) subtrsum += a(k) * L(i,k);
138 a(i) = (
x(i) - subtrsum) / L(i,i);
143 if (squareNormA >= 1.0)
146 Real alpha = std::sqrt(1.0 - squareNormA);
151 for(i = nRC; i >= 1; i--)
152 alpha =
pythag(alpha, a(i), cGivens(i), sGivens(i));
156 for(j = nRC; j >= 1; j--)
159 for(
int k = j; k >= 1; k--)
172 int nRC = chol.
Nrows();
180 for(j = l-1; j >= k; --j)
184 for(i = 1; i < k; ++i) cholCopy(i,k) = columnL(i);
190 for(i = l; i > k; i--)
192 int givensIndex = l-i+1;
193 columnL(i-1) =
pythag(columnL(i-1), columnL(i),
194 cGivens(givensIndex), sGivens(givensIndex));
198 cholCopy(k,k) = columnL(k);
202 for(j = k+1; j <= nRC; ++j)
205 int imin = nGivens - (j-k) + 1;
if (imin < 1) imin = 1;
206 for(
int gIndex = imin; gIndex <= nGivens; ++gIndex)
209 int topRowIndex = k + nGivens - gIndex;
211 columnJ(topRowIndex), columnJ(topRowIndex+1));
213 cholCopy.
Column(j) = columnJ;
227 int nRC = chol.
Nrows();
235 for(j = k+1; j <= l; ++j)
239 for(i = 1; i <= k; ++i)
240 cholCopy(i,l) = columnK(i);
246 for(j = k; j <= nRC; ++j)
251 int imax = j - k;
if (imax > nGivens) imax = nGivens;
252 for(
int i = 1; i <= imax; ++i)
255 int topRowIndex = k + i - 1;
257 columnJ(topRowIndex), columnJ(topRowIndex+1));
264 columnJ(j) =
pythag(columnJ(j), columnJ(j+1), cGivens(gIndex), sGivens(gIndex));
268 cholCopy.
Column(j) = columnJ;
GetSubMatrix Column(int) const
void GivensRotation(Real cGivens, Real sGivens, Real &x, Real &y)
void GivensRotationR(Real cGivens, Real sGivens, Real &x, Real &y)
ReturnMatrix ForReturn() const
Real pythag(Real f, Real g, Real &c, Real &s)
void DowndateCholesky(UpperTriangularMatrix &chol, RowVector x)
ReturnMatrix Cholesky(const SymmetricMatrix &S)
void RightCircularUpdateCholesky(UpperTriangularMatrix &chol, int k, int l)
void LeftCircularUpdateCholesky(UpperTriangularMatrix &chol, int k, int l)
TransposedMatrix t() const
void UpdateCholesky(UpperTriangularMatrix &chol, RowVector r1Modification)