2009-08-22 06:40:22 +02:00
|
|
|
|
2010-01-26 17:40:55 +01:00
|
|
|
template <typename Scalar>
|
|
|
|
|
void ei_rwupdt(int n, Scalar *r__, int ldr, const Scalar *w, Scalar *b, Scalar alpha)
|
2009-08-22 06:40:22 +02:00
|
|
|
{
|
2010-01-26 17:40:55 +01:00
|
|
|
std::vector<PlanarRotation<Scalar> > givens(n);
|
2009-08-22 06:40:22 +02:00
|
|
|
/* System generated locals */
|
2009-08-22 07:14:17 +02:00
|
|
|
int r_dim1, r_offset;
|
2009-08-22 06:40:22 +02:00
|
|
|
|
|
|
|
|
/* Local variables */
|
2010-01-26 17:40:55 +01:00
|
|
|
Scalar temp, rowj;
|
2009-08-22 06:40:22 +02:00
|
|
|
|
|
|
|
|
/* Parameter adjustments */
|
|
|
|
|
--b;
|
|
|
|
|
--w;
|
|
|
|
|
r_dim1 = ldr;
|
|
|
|
|
r_offset = 1 + r_dim1 * 1;
|
|
|
|
|
r__ -= r_offset;
|
|
|
|
|
|
|
|
|
|
/* Function Body */
|
2010-01-26 13:20:24 +01:00
|
|
|
for (int j = 1; j <= n; ++j) {
|
|
|
|
|
rowj = w[j];
|
|
|
|
|
|
2010-01-26 17:40:55 +01:00
|
|
|
/* apply the previous transformations to */
|
|
|
|
|
/* r(i,j), i=1,2,...,j-1, and to w(j). */
|
2010-01-26 13:20:24 +01:00
|
|
|
if (j-1>=1)
|
|
|
|
|
for (int i = 1; i <= j-1; ++i) {
|
2010-01-26 17:40:55 +01:00
|
|
|
temp = givens[i-1].c() * r__[i + j * r_dim1] + givens[i-1].s() * rowj;
|
|
|
|
|
rowj = -givens[i-1].s() * r__[i + j * r_dim1] + givens[i-1].c() * rowj;
|
2010-01-26 13:20:24 +01:00
|
|
|
r__[i + j * r_dim1] = temp;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-26 17:40:55 +01:00
|
|
|
/* determine a givens rotation which eliminates w(j). */
|
2010-01-26 13:20:24 +01:00
|
|
|
if (rowj != 0.) {
|
2010-01-26 17:40:55 +01:00
|
|
|
givens[j-1].makeGivens(-r__[j + j * r_dim1], rowj);
|
2010-01-26 13:20:24 +01:00
|
|
|
|
2010-01-26 17:40:55 +01:00
|
|
|
/* apply the current transformation to r(j,j), b(j), and alpha. */
|
|
|
|
|
r__[j + j * r_dim1] = givens[j-1].c() * r__[j + j * r_dim1] + givens[j-1].s() * rowj;
|
|
|
|
|
temp = givens[j-1].c() * b[j] + givens[j-1].s() * alpha;
|
|
|
|
|
alpha = -givens[j-1].s() * b[j] + givens[j-1].c() * alpha;
|
2010-01-26 13:20:24 +01:00
|
|
|
b[j] = temp;
|
|
|
|
|
}
|
2009-08-22 06:40:22 +02:00
|
|
|
}
|
|
|
|
|
return;
|
2010-01-26 13:20:24 +01:00
|
|
|
}
|
2009-08-22 06:40:22 +02:00
|
|
|
|