7 template <
typename Scalar>
44 for (
j = 0;
j <
n; ++
j) {
45 if (r(
j,
j) == 0. && nsing ==
n-1)
50 for (
j = nsing;
j>=0; --
j) {
53 for (
i = 0;
i <
j ; ++
i)
54 wa1[
i] -= r(
i,
j) * temp;
57 for (
j = 0;
j <
n; ++
j)
64 wa2 = diag.cwiseProduct(
x);
65 dxnorm = wa2.blueNorm();
67 if (fp <= Scalar(0.1) * delta) {
77 for (
j = 0;
j <
n; ++
j) {
79 wa1[
j] = diag[l] * (wa2[l] / dxnorm);
83 for (
j = 0;
j <
n; ++
j) {
85 for (
i = 0;
i <
j; ++
i)
86 sum += r(
i,
j) * wa1[
i];
87 wa1[
j] = (wa1[
j] - sum) / r(
j,
j);
89 temp = wa1.blueNorm();
90 parl = fp / delta / temp / temp;
94 for (
j = 0;
j <
n; ++
j)
95 wa1[
j] = r.col(
j).head(
j+1).dot(qtb.head(
j+1)) / diag[ipvt[
j]];
97 gnorm = wa1.stableNorm();
100 paru = dwarf / (
std::min)(delta,Scalar(0.1));
107 par = gnorm / dxnorm;
115 par = (
std::max)(dwarf,Scalar(.001) * paru);
116 wa1 =
sqrt(par)* diag;
119 qrsolv<Scalar>(r, ipvt, wa1, qtb,
x, sdiag);
121 wa2 = diag.cwiseProduct(
x);
122 dxnorm = wa2.blueNorm();
129 if (
abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
133 for (
j = 0;
j <
n; ++
j) {
135 wa1[
j] = diag[l] * (wa2[l] / dxnorm);
137 for (
j = 0;
j <
n; ++
j) {
140 for (
i =
j+1;
i <
n; ++
i)
141 wa1[
i] -= r(
i,
j) * temp;
143 temp = wa1.blueNorm();
144 parc = fp / delta / temp / temp;
165 template <
typename Scalar>
191 const Index n =
qr.matrixQR().cols();
204 qr.matrixQR().topLeftCorner(rank, rank).template triangularView<Upper>().solveInPlace(wa1.head(rank));
206 x =
qr.colsPermutation()*wa1;
212 wa2 = diag.cwiseProduct(
x);
213 dxnorm = wa2.blueNorm();
215 if (fp <= Scalar(0.1) * delta) {
225 wa1 =
qr.colsPermutation().inverse() * diag.cwiseProduct(wa2)/dxnorm;
226 qr.matrixQR().topLeftCorner(
n,
n).transpose().template triangularView<Lower>().solveInPlace(wa1);
227 temp = wa1.blueNorm();
228 parl = fp / delta / temp / temp;
232 for (
j = 0;
j <
n; ++
j)
233 wa1[
j] =
qr.matrixQR().col(
j).head(
j+1).dot(qtb.head(
j+1)) / diag[
qr.colsPermutation().indices()(
j)];
235 gnorm = wa1.stableNorm();
236 paru = gnorm / delta;
238 paru = dwarf / (
std::min)(delta,Scalar(0.1));
245 par = gnorm / dxnorm;
254 par = (
std::max)(dwarf,Scalar(.001) * paru);
255 wa1 =
sqrt(par)* diag;
258 qrsolv<Scalar>(s,
qr.colsPermutation().indices(), wa1, qtb,
x, sdiag);
260 wa2 = diag.cwiseProduct(
x);
261 dxnorm = wa2.blueNorm();
268 if (
abs(fp) <= Scalar(0.1) * delta || (parl == 0. && fp <= temp && temp < 0.) || iter == 10)
272 wa1 =
qr.colsPermutation().inverse() * diag.cwiseProduct(wa2/dxnorm);
275 for (
j = 0;
j <
n; ++
j) {
279 wa1[
i] -= s(
i,
j) * temp;
281 temp = wa1.blueNorm();
282 parc = fp / delta / temp / temp;
HouseholderQR< MatrixXf > qr(A)
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Derived & setZero(Index rows, Index cols)
void lmpar2(const QRSolver &qr, const VectorType &diag, const VectorType &qtb, typename VectorType::Scalar m_delta, typename VectorType::Scalar &par, VectorType &x)
void lmpar(Matrix< Scalar, Dynamic, Dynamic > &r, const VectorXi &ipvt, const Matrix< Scalar, Dynamic, 1 > &diag, const Matrix< Scalar, Dynamic, 1 > &qtb, Scalar delta, Scalar &par, 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)
CleanedUpDerType< DerType >::type() max(const AutoDiffScalar< DerType > &x, const T &y)
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_abs_op< typename Derived::Scalar >, const Derived > abs(const Eigen::ArrayBase< Derived > &x)
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
adouble abs(const adouble &x)