15 #ifndef EIGEN_LMQRSOLV_H 16 #define EIGEN_LMQRSOLV_H 22 template <
typename Scalar,
int Rows,
int Cols,
typename PermIndex>
48 s.topLeftCorner(n,n).template triangularView<StrictlyLower>() = s.topLeftCorner(n,n).transpose();
50 for (j = 0; j < n; ++j) {
54 const PermIndex l = iPerm.
indices()(j);
64 for (k = j; k < n; ++k) {
71 s(k,k) = givens.
c() * s(k,k) + givens.
s() * sdiag[k];
72 temp = givens.
c() * wa[k] + givens.
s() * qtbpj;
73 qtbpj = -givens.
s() * wa[k] + givens.
c() * qtbpj;
77 for (i = k+1; i<n; ++i) {
78 temp = givens.
c() * s(i,k) + givens.
s() * sdiag[i];
79 sdiag[i] = -givens.
s() * s(i,k) + givens.
c() * sdiag[i];
88 for(nsing=0; nsing<n && sdiag[nsing]!=0; nsing++) {}
91 s.topLeftCorner(nsing, nsing).transpose().template triangularView<Upper>().solveInPlace(wa.head(nsing));
101 template <
typename Scalar,
int _Options,
typename Index>
126 for (j = 0; j < n; ++j)
131 if (diag(l) == Scalar(0))
141 for (k = j; k < n; ++k)
143 typename FactorType::InnerIterator itk(R,k);
145 if (itk.index() < k)
continue;
155 itk.valueRef() = givens.
c() * itk.value() + givens.
s() * sdiag(k);
156 temp = givens.
c() * wa(k) + givens.
s() * qtbpj;
157 qtbpj = -givens.
s() * wa(k) + givens.
c() * qtbpj;
161 for (++itk; itk; ++itk)
164 temp = givens.
c() * itk.value() + givens.
s() * sdiag(i);
165 sdiag(i) = -givens.
s() * itk.value() + givens.
c() * sdiag(i);
166 itk.valueRef() = temp;
174 for(nsing = 0; nsing<n && sdiag(nsing) !=0; nsing++) {}
178 wa.head(nsing) = R.topLeftCorner(nsing,nsing).template triangularView<Upper>().solve(wa.head(nsing));
180 sdiag = R.diagonal();
188 #endif // EIGEN_LMQRSOLV_H EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index cols() const
EIGEN_DEVICE_FUNC Derived & setZero(Index size)
A versatible sparse matrix representation.
void makeGivens(const Scalar &p, const Scalar &q, Scalar *z=0)
Rotation given by a cosine-sine pair.
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
void lmqrsolv(Matrix< Scalar, Rows, Cols > &s, const PermutationMatrix< Dynamic, Dynamic, PermIndex > &iPerm, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, Matrix< Scalar, Dynamic, 1 > &x, Matrix< Scalar, Dynamic, 1 > &sdiag)
const IndicesType & indices() const
The matrix class, also used for vectors and row-vectors.