5 template <
typename Scalar>
20 Scalar sum, temp, alpha, bnorm;
26 const Index n = qrfac.
cols();
33 for (j = n-1; j >=0; --j) {
36 temp = epsmch * qrfac.col(j).head(j+1).maxCoeff();
43 x[j] = (qtb[j] - qrfac.row(j).tail(n-j-1).dot(x.tail(n-j-1))) / temp;
47 qnorm = diag.cwiseProduct(x).stableNorm();
57 for (j = 0; j < n; ++j) {
58 wa1.tail(n-j) += qrfac.row(j).tail(n-j) * qtb[j];
64 gnorm = wa1.stableNorm();
66 alpha = delta / qnorm;
72 wa1.array() /= (diag*gnorm).array();
75 for (j = 0; j < n; ++j) {
77 for (i = j; i < n; ++i) {
78 sum += qrfac(j,i) * wa1[i];
82 temp = wa2.stableNorm();
83 sgnorm = gnorm / temp / temp;
93 bnorm = qtb.stableNorm();
94 temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta);
96 alpha = delta / qnorm * (1. -
numext::abs2(sgnorm / delta)) / temp;
101 temp = (1.-alpha) * (std::min)(sgnorm,delta);
102 x = temp * wa1 + alpha * x;
IntermediateState sqrt(const Expression &arg)
iterative scaling algorithm to equilibrate rows and column norms in matrices
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const Derived > abs2() const
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > abs() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
EIGEN_STRONG_INLINE Index cols() const
void dogleg(const Matrix< Scalar, Dynamic, Dynamic > &qrfac, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, Scalar delta, Matrix< Scalar, Dynamic, 1 > &x)