84 constexpr int DIM = DataPoint::Dim;
86 const int nb_points = std::distance(begin, end);
87 const int nb_hrbf_constraints = (DIM + 1) * nb_points;
88 const int nb_constraints = nb_hrbf_constraints;
89 const int nb_coeffs = (DIM + 1) * nb_points;
90 const WeightKernel wk;
97 DenseMatrix D(nb_constraints, nb_coeffs);
98 DenseVector f(nb_constraints);
102 for (
int i = 0; i < nb_points; ++i, ++it)
106 for (
int i = 0; i < nb_points; ++i, ++it)
108 const auto& p = (*it).pos();
109 const auto& n = (*it).normal();
111 const int io = (DIM + 1) * i;
113 f.template segment<DIM>(io + 1) = n;
115 for (
int j = 0; j < nb_points; ++j)
117 const int jo = (DIM + 1) * j;
119 const Scalar l = diff.norm();
123 D.template block<DIM + 1, DIM + 1>(io, jo).setZero();
127 const Scalar w = wk.f(l);
128 const Scalar dw_l = wk.df(l) / l;
129 const Scalar ddw = wk.ddf(l);
130 const VectorType g = diff * dw_l;
133 D.row(io).template segment<DIM>(jo + 1) = g.transpose();
134 D.col(jo).template segment<DIM>(io + 1) = g;
135 D.template block<DIM, DIM>(io + 1, jo + 1) = (ddw - dw_l) / (l * l) * (diff * diff.transpose());
136 D.template block<DIM, DIM>(io + 1, jo + 1).diagonal().array() += dw_l;
141 const DenseVector x = D.lu().solve(f);
142 Eigen::Map<const Eigen::Matrix<Scalar, DIM + 1, Eigen::Dynamic>> mx(x.data(), DIM + 1, nb_points);
145 m_betas = mx.template bottomRows<DIM>();
148 if (!x.allFinite() || (D * x - f).norm() > std::sqrt(eps) * f.norm())
151 return m_eCurrentState =
STABLE;