7 template <
typename Scalar>
22 Scalar sum, temp, alpha, bnorm;
35 for (
j =
n-1;
j >=0; --
j) {
38 temp = epsmch * qrfac.col(
j).head(
j+1).maxCoeff();
45 x[
j] = (qtb[
j] - qrfac.row(
j).tail(
n-
j-1).dot(
x.tail(
n-
j-1))) / temp;
49 qnorm = diag.cwiseProduct(
x).stableNorm();
59 for (
j = 0;
j <
n; ++
j) {
60 wa1.tail(
n-
j) += qrfac.row(
j).tail(
n-
j) * qtb[
j];
66 gnorm = wa1.stableNorm();
68 alpha = delta / qnorm;
74 wa1.array() /= (diag*gnorm).
array();
77 for (
j = 0;
j <
n; ++
j) {
79 for (
i =
j;
i <
n; ++
i) {
80 sum += qrfac(
j,
i) * wa1[
i];
84 temp = wa2.stableNorm();
85 sgnorm = gnorm / temp / temp;
95 bnorm = qtb.stableNorm();
96 temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta);
98 alpha = delta / qnorm * (1. -
numext::abs2(sgnorm / delta)) / temp;
103 temp = (1.-alpha) * (
std::min)(sgnorm,delta);
104 x = temp * wa1 + alpha *
x;
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
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)
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > sqrt(const Eigen::AutoDiffScalar< DerType > &x)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
adouble abs(const adouble &x)