13#include PONCA_MULTIARCH_INCLUDE_STD(iterator)
18#define BSKW typename BasketType::WeightFunction
19#define BSKP typename BasketType::DataPoint
21#ifndef PARSED_WITH_DOXYGEN
25 template <
class P,
class W,
27 template <
class,
class,
typename>
class Ext,
28 template <
class,
class,
typename>
class... Exts>
29 struct BasketAggregateImpl
31 using type =
typename BasketAggregateImpl<P, W, Ext<P, W, Aggregate>, Exts...>::type;
34 template <
class P,
class W,
36 template <
class,
class,
typename>
class Ext>
37 struct BasketAggregateImpl<P, W, Aggregate, Ext>
39 using type = Ext<P, W, Aggregate>;
43 template <
class P,
class W,
44 template <
class,
class,
typename>
class... Exts>
45 struct BasketAggregate : BasketAggregateImpl<P, W, PrimitiveBase<P, W>, Exts...>
49 template <
typename BasketType,
int Type,
51 template <
class,
class,
int,
typename>
class Ext,
52 template <
class,
class,
int,
typename>
class... Exts>
53 struct BasketDiffAggregateImpl
55 using type =
typename BasketDiffAggregateImpl<BasketType, Type, Ext<BSKP, BSKW, Type, Aggregate>, Exts...>::type;
58 template <
typename BasketType,
int Type,
60 template <
class,
class,
int,
typename>
class Ext>
61 struct BasketDiffAggregateImpl<BasketType, Type, Aggregate, Ext>
63 using type = Ext<BSKP, BSKW, Type, Aggregate>;
67 template <
typename BasketType,
int Type,
68 template <
class,
class,
int,
typename>
class... Exts>
69 struct BasketDiffAggregate : BasketDiffAggregateImpl<BasketType, Type, BasketType, PrimitiveDer, Exts...>
76# define WRITE_BASKET_SINGLE_HOST_FUNCTIONS \
78 template <typename Container> \
79 PONCA_MULTIARCH inline \
80 FIT_RESULT compute(const Container& c){ \
81 return Self::compute(std::begin(c), std::end(c)); \
84# define WRITE_BASKET_SINGLE_HOST_FUNCTIONS
87#define WRITE_BASKET_FUNCTIONS \
92 template <typename IteratorBegin, typename IteratorEnd> \
93 PONCA_MULTIARCH inline \
94 FIT_RESULT compute(const IteratorBegin& begin, const IteratorEnd& end){ \
95 FIT_RESULT res = UNDEFINED; \
97 Self::startNewPass(); \
98 for (auto it = begin; it != end; ++it){ \
99 Self::addNeighbor(*it); \
101 res = Base::finalize(); \
102 } while ( res == NEED_OTHER_PASS ); \
110 template <typename IndexRange, typename PointContainer> \
111 PONCA_MULTIARCH inline \
112 FIT_RESULT computeWithIds(IndexRange ids, const PointContainer& points){ \
113 FIT_RESULT res = UNDEFINED; \
115 Self::startNewPass(); \
116 for (const auto& i : ids){ \
117 this->addNeighbor(points[i]); \
119 res = this->finalize(); \
120 } while ( res == NEED_OTHER_PASS ); \
123 WRITE_BASKET_SINGLE_HOST_FUNCTIONS
150 template <
typename BasketType,
int Type,
151 template <
class,
class,
int,
typename>
class Ext0,
152 template <
class,
class,
int,
typename>
class... Exts>
153 class BasketDiff :
public internal::BasketDiffAggregate<BasketType, Type, Ext0, Exts...>::type {
158 using Base =
typename internal::BasketDiffAggregate<BasketType, Type, Ext0, Exts...>::type;
164 using Scalar =
typename DataPoint::Scalar;
166 WRITE_BASKET_FUNCTIONS
171 auto wres = Base::m_w.w(_nei.pos(), _nei);
172 typename Base::ScalarArray dw;
174 if (wres.first >
Scalar(0.)) {
175 Base::addLocalNeighbor(wres.first, wres.second, _nei, dw);
207 template <
class P,
class W,
208 template <
class,
class,
typename>
class Ext0,
209 template <
class,
class,
typename>
class... Exts>
210 class Basket :
public internal::BasketAggregate<P, W, Ext0, Exts...>::type
216 using Base =
typename internal::BasketAggregate<P, W, Ext0, Exts...>::type;
224 WRITE_BASKET_FUNCTIONS;
234 auto wres = Base::m_w.w(_nei.pos(), _nei);
236 if (wres.first >
Scalar(0.)) {
237 Base::addLocalNeighbor(wres.first, wres.second, _nei);
Aggregator class used to declare specialized structures with derivatives computations,...
typename BasketType::DataPoint DataPoint
Point type used for computation.
typename internal::BasketDiffAggregate< BasketType, Type, Ext0, Exts... >::type Base
Base type, which aggregates all the computational objects using the CRTP.
bool addNeighbor(const DataPoint &_nei)
Add a neighbor to perform the fit.
typename DataPoint::Scalar Scalar
Scalar type used for computation, as defined from Basket.
typename BasketType::WeightFunction WeightFunction
Weighting function.
Aggregator class used to declare specialized structures using CRTP.
W WeightFunction
Weighting function.
P DataPoint
Point type used for computation.
typename P::Scalar Scalar
Scalar type used for computation, as defined from template parameter P
bool addNeighbor(const DataPoint &_nei)
Add a neighbor to perform the fit.
typename internal::BasketAggregate< P, W, Ext0, Exts... >::type Base
Base type, which aggregates all the computational objects using the CRTP.
This Source Code Form is subject to the terms of the Mozilla Public License, v.