![]() |
Eigen-unsupported
3.3.3
|
00001 namespace Eigen { 00002 00003 namespace internal { 00004 00005 template <typename Scalar> 00006 void rwupdt( 00007 Matrix< Scalar, Dynamic, Dynamic > &r, 00008 const Matrix< Scalar, Dynamic, 1> &w, 00009 Matrix< Scalar, Dynamic, 1> &b, 00010 Scalar alpha) 00011 { 00012 typedef DenseIndex Index; 00013 00014 const Index n = r.cols(); 00015 eigen_assert(r.rows()>=n); 00016 std::vector<JacobiRotation<Scalar> > givens(n); 00017 00018 /* Local variables */ 00019 Scalar temp, rowj; 00020 00021 /* Function Body */ 00022 for (Index j = 0; j < n; ++j) { 00023 rowj = w[j]; 00024 00025 /* apply the previous transformations to */ 00026 /* r(i,j), i=0,1,...,j-1, and to w(j). */ 00027 for (Index i = 0; i < j; ++i) { 00028 temp = givens[i].c() * r(i,j) + givens[i].s() * rowj; 00029 rowj = -givens[i].s() * r(i,j) + givens[i].c() * rowj; 00030 r(i,j) = temp; 00031 } 00032 00033 /* determine a givens rotation which eliminates w(j). */ 00034 givens[j].makeGivens(-r(j,j), rowj); 00035 00036 if (rowj == 0.) 00037 continue; // givens[j] is identity 00038 00039 /* apply the current transformation to r(j,j), b(j), and alpha. */ 00040 r(j,j) = givens[j].c() * r(j,j) + givens[j].s() * rowj; 00041 temp = givens[j].c() * b[j] + givens[j].s() * alpha; 00042 alpha = -givens[j].s() * b[j] + givens[j].c() * alpha; 00043 b[j] = temp; 00044 } 00045 } 00046 00047 } // end namespace internal 00048 00049 } // end namespace Eigen