Eigen-Contrib  5.0.1
 
Loading...
Searching...
No Matches
rwupdt.h
1// IWYU pragma: private
2// SPDX-FileCopyrightText: The Eigen Authors
3// SPDX-License-Identifier: MPL-2.0
4
5#ifndef EIGEN_NONLINEAROPTIMIZATION_RWUPDT_H
6#define EIGEN_NONLINEAROPTIMIZATION_RWUPDT_H
7
8#include "./InternalHeaderCheck.h"
9
10namespace Eigen {
11
12namespace internal {
13
14template <typename Scalar>
15void rwupdt(Matrix<Scalar, Dynamic, Dynamic> &r, const Matrix<Scalar, Dynamic, 1> &w, Matrix<Scalar, Dynamic, 1> &b,
16 Scalar alpha) {
17 typedef DenseIndex Index;
18
19 const Index n = r.cols();
20 eigen_assert(r.rows() >= n);
21 std::vector<JacobiRotation<Scalar> > givens(n);
22
23 /* Local variables */
24 Scalar temp, rowj;
25
26 /* Function Body */
27 for (Index j = 0; j < n; ++j) {
28 rowj = w[j];
29
30 /* apply the previous transformations to */
31 /* r(i,j), i=0,1,...,j-1, and to w(j). */
32 for (Index i = 0; i < j; ++i) {
33 temp = givens[i].c() * r(i, j) + givens[i].s() * rowj;
34 rowj = -givens[i].s() * r(i, j) + givens[i].c() * rowj;
35 r(i, j) = temp;
36 }
37
38 /* determine a givens rotation which eliminates w(j). */
39 givens[j].makeGivens(-r(j, j), rowj);
40
41 if (rowj == 0.) continue; // givens[j] is identity
42
43 /* apply the current transformation to r(j,j), b(j), and alpha. */
44 r(j, j) = givens[j].c() * r(j, j) + givens[j].s() * rowj;
45 temp = givens[j].c() * b[j] + givens[j].s() * alpha;
46 alpha = -givens[j].s() * b[j] + givens[j].c() * alpha;
47 b[j] = temp;
48 }
49}
50
51} // end namespace internal
52
53} // end namespace Eigen
54
55#endif // EIGEN_NONLINEAROPTIMIZATION_RWUPDT_H
Namespace containing all symbols from the Eigen library.