35 void setInput(
const T*,
int sz);
38 bool setWindow(
const char* nm,
float param,
49 static const char*
sKeyWinFunc() {
return "Window function"; }
51 static const char*
sKeyWinLen() {
return "Window length"; }
54 inline bool doPrepare(
int);
70 template <
class T>
inline 74 , windowparam_(
mUdf(float) )
81 template <
class T>
inline 94 template <
class T>
inline 102 template <
class T>
inline 109 template <
class T>
inline 118 template <
class T>
inline 132 const double step = 2.0/(length-1);
133 for (
int idx=0; idx<length; idx++ )
143 template <
class T>
inline 153 template <
class T>
inline 161 float var =
mUdf(
float);
168 template <
class T>
inline 176 for (
int idx=0; idx<
size_; idx++ )
187 for (
int idx=
mCast(
int,size_-1); idx>=0; idx-- )
201 template <
class T>
inline 204 const float* window =
window_.arr();
205 const int windowsize =
window_.size();
206 const int hwinsize = windowsize/2;
216 int sumstart = outidx-hwinsize;
217 int sumstop = outidx+windowsize-hwinsize-1;
221 winstart = -sumstart;
225 if ( sumstop>=
size_ )
229 double weightsum = 0;
230 for (
int sumidx=sumstart, winidx=winstart;
231 sumidx<=sumstop; sumidx++, winidx++ )
233 double val =
input_[sumidx];
237 sum += val * window[winidx];
238 weightsum += window[winidx];
241 output_[outidx] = (T) (weightsum ? sum/weightsum :
mUdf(
float));
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:285
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
bool setWindow(const char *nm, float param, int lenght)
Definition: smoother1d.h:119
#define mCast(tp, v)
Definition: commondefs.h:120
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:200
#define od_int64
Definition: plftypes.h:34
T * output_
Definition: smoother1d.h:62
int getWindowLength() const
Definition: smoother1d.h:40
int lastdefined_
Definition: smoother1d.h:66
virtual bool hasVariable() const
Definition: windowfunction.h:29
bool get(const char *, int &) const
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:64
float getWindowParam() const
Definition: smoother1d.h:42
#define mIsEqual(x, y, eps)
Definition: commondefs.h:56
void setOutput(T *)
Definition: smoother1d.h:103
void setInput(const T *, int sz)
Definition: smoother1d.h:95
Set of (small) copyable elements.
Definition: commontypes.h:26
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
Smoother1D()
Definition: smoother1d.h:71
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:270
BufferString windowname_
Definition: smoother1d.h:58
const char * find(const char *) const
returns null if not found
const T * input_
Definition: smoother1d.h:61
od_int64 nrIterations() const
Definition: smoother1d.h:53
void fillPar(IOPar &) const
Definition: smoother1d.h:144
virtual bool setVariable(float)
Definition: windowfunction.h:31
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:187
Smoothes a 1d signal with an operator.
Definition: smoother1d.h:26
float windowparam_
Definition: smoother1d.h:59
static const char * sKeyWinLen()
Definition: smoother1d.h:51
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
const char * getWindowName() const
Definition: smoother1d.h:41
TypeSet< T > window_
Definition: smoother1d.h:57
bool doWork(od_int64 start, od_int64 stop, int)
Definition: smoother1d.h:202
int firstdefined_
Definition: smoother1d.h:65
#define mClass(module)
Definition: commondefs.h:161
void set(const char *ky, const char *val)
bool doPrepare(int)
Definition: smoother1d.h:169
virtual RT getValue(PT) const =0
void addToNrDone(int64_t increment)
bool operator==(const Smoother1D< T > &) const
Definition: smoother1d.h:110
bool usePar(const IOPar &)
Definition: smoother1d.h:154
static const char * sKeyWinParam()
Definition: smoother1d.h:50
od_int64 size_
Definition: smoother1d.h:63
static const char * sKeyWinFunc()
Definition: smoother1d.h:49