37 void setInput(
const T*,
int sz);
40 bool setWindow(
const char* nm,
float param,
51 static const char*
sKeyWinFunc() {
return "Window function"; }
53 static const char*
sKeyWinLen() {
return "Window length"; }
56 inline bool doPrepare(
int);
72 template <
class T>
inline 76 , windowparam_(
mUdf(float) )
83 template <
class T>
inline 96 template <
class T>
inline 104 template <
class T>
inline 111 template <
class T>
inline 120 template <
class T>
inline 134 const double step = 2.0/(length-1);
135 for (
int idx=0; idx<length; idx++ )
145 template <
class T>
inline 155 template <
class T>
inline 163 float var =
mUdf(
float);
170 template <
class T>
inline 178 for (
int idx=0; idx<
size_; idx++ )
189 for (
int idx=
mCast(
int,size_-1); idx>=0; idx-- )
203 template <
class T>
inline 206 const float* window =
window_.arr();
207 const int windowsize =
window_.size();
208 const int hwinsize = windowsize/2;
218 int sumstart = outidx-hwinsize;
219 int sumstop = outidx+windowsize-hwinsize-1;
223 winstart = -sumstart;
227 if ( sumstop>=
size_ )
231 double weightsum = 0;
232 for (
int sumidx=sumstart, winidx=winstart;
233 sumidx<=sumstop; sumidx++, winidx++ )
235 double val =
input_[sumidx];
239 sum += val * window[winidx];
240 weightsum += window[winidx];
243 output_[outidx] = (T) (weightsum ? sum/weightsum :
mUdf(
float));
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:287
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
bool setWindow(const char *nm, float param, int lenght)
Definition: smoother1d.h:121
#define mCast(tp, v)
Definition: commondefs.h:124
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
#define od_int64
Definition: plftypes.h:36
T * output_
Definition: smoother1d.h:64
int getWindowLength() const
Definition: smoother1d.h:42
int lastdefined_
Definition: smoother1d.h:68
virtual bool hasVariable() const
Definition: windowfunction.h:31
bool get(const char *, int &) const
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
float getWindowParam() const
Definition: smoother1d.h:44
#define mIsEqual(x, y, eps)
Definition: commondefs.h:54
void setOutput(T *)
Definition: smoother1d.h:105
void setInput(const T *, int sz)
Definition: smoother1d.h:97
Set of (small) copyable elements.
Definition: commontypes.h:30
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Smoother1D()
Definition: smoother1d.h:73
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
BufferString windowname_
Definition: smoother1d.h:60
const char * find(const char *) const
returns null if not found
const T * input_
Definition: smoother1d.h:63
od_int64 nrIterations() const
Definition: smoother1d.h:55
void fillPar(IOPar &) const
Definition: smoother1d.h:146
virtual bool setVariable(float)
Definition: windowfunction.h:33
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
Smoothes a 1d signal with an operator.
Definition: smoother1d.h:28
float windowparam_
Definition: smoother1d.h:61
static const char * sKeyWinLen()
Definition: smoother1d.h:53
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
const char * getWindowName() const
Definition: smoother1d.h:43
TypeSet< T > window_
Definition: smoother1d.h:59
bool doWork(od_int64 start, od_int64 stop, int)
Definition: smoother1d.h:204
int firstdefined_
Definition: smoother1d.h:67
#define mClass(module)
Definition: commondefs.h:164
void set(const char *ky, const char *val)
bool doPrepare(int)
Definition: smoother1d.h:171
virtual RT getValue(PT) const =0
void addToNrDone(int64_t increment)
bool operator==(const Smoother1D< T > &) const
Definition: smoother1d.h:112
bool usePar(const IOPar &)
Definition: smoother1d.h:156
static const char * sKeyWinParam()
Definition: smoother1d.h:52
od_int64 size_
Definition: smoother1d.h:65
static const char * sKeyWinFunc()
Definition: smoother1d.h:51