58 if (!sources.size()) {
59 Warning(
"TKDEFGT::BuildModel",
"Bad input - zero size vector");
64 Warning(
"TKDEFGT::BuildModel",
"Number of dimensions is zero");
69 Warning(
"TKDEFGT::BuildModel",
"Order of truncation is zero, 8 will be used");
108 Warning(
"TKDEFGT::BuildModel",
"Bad input - zero size vector");
115 Warning(
"TKDEFGT::BuildModel",
"Order of truncation is zero, 8 will be used");
172 for (
UInt_t j = 0; j < nP; x_j +=
fDim, ++j) {
173 fDistC[j] = (j == ind) ? 0. : DDist(x_j , x_ind , fDim);
181 x_ind = &x[0] + ind *
fDim;
182 for (
UInt_t j = 0; j < nP; x_j +=
fDim, ++j) {
183 const Double_t temp = (j==ind) ? 0.0 : DDist(x_j, x_ind, fDim);
191 for (
UInt_t i = 0, nd = 0 ; i < nP; i++, nd +=
fDim) {
195 fXC[j + ibase] += x[j + nd];
198 for (
UInt_t i = 0, ibase = 0; i <
fK ; ++i, ibase +=
fDim) {
201 fXC[j + ibase] *= temp;
222 for (
UInt_t j = 0; j < nP; ++j) {
226 fDistC[j] = (j == 1) ? 0. : DDist(x_j, y_j, z_j, x_ind, y_ind, z_ind);
239 for (
UInt_t j = 0; j < nP; ++j) {
244 const Double_t temp = (j==ind) ? 0.0 : DDist(x_j, y_j, z_j, x_ind, y_ind, z_ind);
252 for (
UInt_t i = 0, nd = 0 ; i < nP; i++, nd +=
fDim) {
255 fXC[ibase] += sources->
V1(i);
256 fXC[ibase + 1] += sources->
V2(i);
257 fXC[ibase + 2] += sources->
V3(i);
260 for (
UInt_t i = 0, ibase = 0; i <
fK ; ++i, ibase +=
fDim) {
263 fXC[j + ibase] *= temp;
276 for (
UInt_t k = 1, t = 1, tail = 1; k <
fP; ++k, tail = t) {
280 for (
UInt_t j = head; j < tail; ++j, ++t) {
306 fDx[i] = (x[i + nbase] -
fXC[i + ix2cbase]) * ctesigma;
313 for (
UInt_t k = 1, t = 1, tail = 1; k <
fP; ++k, tail = t) {
318 for (
UInt_t j = head; j < tail; ++j, ++t)
344 UInt_t ix2cbase = ix2c * 3;
349 fDx[0] = (sources->
V1(
n) -
fXC[ix2cbase]) * ctesigma;
350 fDx[1] = (sources->
V2(
n) -
fXC[ix2cbase + 1]) * ctesigma;
351 fDx[2] = (sources->
V3(
n) -
fXC[ix2cbase + 2]) * ctesigma;
358 for (
UInt_t k = 1, t = 1, tail = 1; k <
fP; ++k, tail = t) {
359 for (
UInt_t i = 0; i < 3; ++i) {
363 for (
UInt_t j = head; j < tail; ++j, ++t)
391 Error(
"TKDEFGT::Predict",
"Call BuildModel first!");
396 Warning(
"TKDEFGT::Predict",
"Empty targets vector.");
400 v.assign(ts.size() /
fDim, 0.);
414 for (
UInt_t kn = 0 ; kn <
fK ; ++kn) {
419 fDx[i] = (ts[i + mbase] -
fXC[i + xbase]) * ctesigma;
424 if (sum2 > eval)
continue;
428 for (
UInt_t k = 1, t = 1, tail = 1; k < p; ++k, tail = t) {
433 for (
UInt_t j = head; j < tail; ++j, ++t)
446 for (
UInt_t i = 1; i < nP; ++i) {
451 const Double_t dRange = dMax - dMin;
452 for (
UInt_t i = 0; i < nP; ++i)
453 v[i] = (v[i] - dMin) / dRange;
455 dMin = v[0], dMax = dMin;
456 for (
UInt_t i = 1; i < nP; ++i) {
475 for (
UInt_t i = 1; i <= n_k; ++i) {
487 return (x1 - x2) * (x1 -
x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
496 for (
Int_t i = 0 ; i < d ; i++) {
510 for (
UInt_t i = 0; i <
n; ++i) {
525 for (
UInt_t i = 2 ; i <= d ; ++i)
528 const UInt_t cte = cnk * cted;
531 for (
UInt_t i = p + 1; i < p + d; ++i)
534 while (ctep != cte) {
535 ctep = ((p + d) * ctep) / p;
static long int sum(long int i)
std::vector< Double_t > fC_K
std::vector< UInt_t > fXboxsz
std::vector< Double_t > fProds
void Compute_C_k()
Coefficients C_K.
std::vector< Double_t > fWeights
void Kcenter(const std::vector< double > &x)
Solve kcenter task.
Short_t Min(Short_t a, Short_t b)
std::vector< UInt_t > fIndx
void Compute_A_k(const std::vector< Double_t > &x)
Coefficients A_K.
std::vector< Double_t > fXC
static const double x2[5]
std::vector< Double_t > fA_K
std::vector< Double_t > fDistC
Double_t V1(UInt_t ind) const
V1 from sub-range, converted to unit cube.
virtual ~TKDEFGT()
Destructor.
void Error(const char *location, const char *msgfmt,...)
std::vector< UInt_t > fXhead
std::vector< UInt_t > fCinds
Double_t V2(UInt_t ind) const
V2 from sub-range, converted to unit cube.
void Warning(const char *location, const char *msgfmt,...)
static const double x1[5]
std::vector< Double_t > fDx
void BuildModel(const std::vector< Double_t > &sources, Double_t sigma=1., UInt_t dim=3, UInt_t p=8, UInt_t k=0)
Calculate coefficients for FGT.
std::vector< UInt_t > fHeads
static constexpr double s
Short_t Max(Short_t a, Short_t b)
void Predict(const std::vector< Double_t > &targets, std::vector< Double_t > &densities, Double_t e) const
Calculate densities.
Double_t Sqrt(Double_t x)
std::vector< UInt_t > fIndxc
Double_t V3(UInt_t ind) const
V3 from sub-range, converted to unit cube.
UInt_t SelectedSize() const
Size of selected sub-range.