1 #ifndef NPSTAT_KDEFILTERND_HH_
2 #define NPSTAT_KDEFILTERND_HH_
29 template <
unsigned MaxDeg>
33 enum {deg_size = MaxDeg};
89 template <
class Array>
93 bool mirrorData=
true,
bool mirrorWeight=
true,
94 bool manageSlot=
true);
100 inline unsigned dim()
const {
return dataShape_.size();}
101 inline unsigned maxDegree()
const {
return taper_.size() - 1U;}
103 double taper(
unsigned degree)
const;
104 inline bool mirrorsData()
const {
return mirrorData_;}
105 inline unsigned long engineSlotId()
const {
return slotId_;}
106 inline double filterAtTheCenter()
const {
return filterAtTheCenter_;}
116 unsigned indexLen)
const;
124 template <
class Array>
126 {
return in.isCompatible(dataShape_);}
129 template <
class ArrIn,
class ArrOut>
130 void filter(
const ArrIn& in, ArrOut* out)
const;
136 template <
class ArrIn,
class ArrOut>
137 inline void convolve(
const ArrIn& in, ArrOut* out)
const
140 static inline unsigned classMaxDegree() {
return MaxDeg;}
144 KDEFilterND(
const KDEFilterND&);
145 KDEFilterND& operator=(
const KDEFilterND&);
147 template <
class Array>
148 void initialize(
const double* itaper,
unsigned maxDegree,
149 const Array& inweight,
bool mirrorWeight);
151 void calculateSelfContribution(
const ArrayND<double>&
filter);
155 ConvolutionEngineND* engine_;
156 std::vector<double> taper_;
157 unsigned long slotId_;
158 ArrayND<double>* buf_;
159 double filterAtTheCenter_;
160 ArrayND<double>* selfContrib_;
166 inline KDEFilterND(
const std::vector<double>& itaper,
167 const ArrayND<double>& inweight,
168 ConvolutionEngineND& engine,
169 unsigned long id, ArrayND<double>& workBuffer,
170 bool mirrorData=
true,
bool mirrorWeight=
true,
171 bool manageSlot=
true)
173 idxBuffer_(inweight.shape()),
175 taper_(std::max(itaper.size(), static_cast<std::size_t>(1)), 1.0),
178 filterAtTheCenter_(0.0),
180 mirrorData_(mirrorData),
181 manageSlot_(manageSlot)
183 const double* tap = 0;
186 initialize(tap, taper_.size()-1, inweight, mirrorWeight);
192 #include "npstat/stat/KDEFilterND.icc"
Interface definition for multivariate smoothers that can be cross-validated.
Arbitrary-dimensional array template.
Fast multidimensional convolutions via Fourier transforms (FFTW interface)
Definition: ConvolutionEngineND.hh:31
Definition: KDEFilterND.hh:31
unsigned dim() const
Definition: KDEFilterND.hh:100
void filter(const ArrIn &in, ArrOut *out) const
bool selfContributionVaries() const
Definition: KDEFilterND.hh:121
double selfContribution(const unsigned *index, unsigned indexLen) const
double linearSelfContribution(unsigned long index) const
ArrayShape dataShape() const
Definition: KDEFilterND.hh:102
KDEFilterND(const double *taper, unsigned maxDegree, const Array &weight, ConvolutionEngineND &engine, unsigned long id, ArrayND< double > &workBuffer, bool mirrorData=true, bool mirrorWeight=true, bool manageSlot=true)
void convolve(const ArrIn &in, ArrOut *out) const
Definition: KDEFilterND.hh:137
bool isCompatible(const Array &in) const
Definition: KDEFilterND.hh:125
Definition: AbsArrayProjector.hh:14
ArrayShape halfShape(const ArrayShape &inputShape)
std::vector< unsigned > ArrayShape
Definition: ArrayShape.hh:21
Definition: AbsPolyFilterND.hh:27