DGtal 1.3.0
Loading...
Searching...
No Matches
Signal.h
1
17#pragma once
18
31#if defined(Signal_RECURSES)
32#error Recursive header files inclusion detected in Signal.h
33#else // defined(Signal_RECURSES)
35#define Signal_RECURSES
36
37#if !defined Signal_h
39#define Signal_h
40
42// Inclusions
43#include <iostream>
44#include "DGtal/base/Common.h"
45#include "DGtal/base/CowPtr.h"
47
48namespace DGtal
49{
50
57 template <typename TValue>
58 struct SignalData {
59 typedef TValue Value;
60
64 unsigned int size;
66 int zero;
70
76
85 void init( unsigned int s, int z = 0, bool p = false,
86 const Value & def = Value( 0 ) );
87
97 void init( const Value* t, unsigned int size, int z = 0, bool p = false,
98 const Value & def = Value( 0 ) );
99
108 SignalData( unsigned int s, int z = 0, bool p = false,
109 const Value & def = Value( 0 ) );
110
119 SignalData( const Value* t, unsigned int size, int z = 0, bool p = false,
120 const Value & def = Value( 0 ) );
121
126
131 SignalData( const SignalData & other );
132
138 SignalData& operator=( const SignalData & other );
139
144 const Value& defaut() const;
145 };
146
147
149 // template class Signal
160 template <typename TValue>
161 class Signal
162 {
163
164 public:
165 typedef TValue Value;
173
178
183
188 static Signal<TValue> G2n( unsigned int n );
189
193 static Signal<TValue> H2n( unsigned int n );
194
198 static Signal<TValue> D2n( unsigned int n );
199
200 // ----------------------- Standard services ----------------------------
201 public:
202
207
212
213
221 Signal( unsigned int size, int z, bool periodic,
222 const TValue & def = TValue( 0 ) );
223
232 Signal( const TValue* t, unsigned int size, int z, bool periodic,
233 const TValue & def = TValue( 0 ) );
234
239 Signal( const Signal<TValue> & other );
240
247
248
257 void init( unsigned int s, int z = 0, bool p = false,
258 const TValue & def = TValue( 0 ) );
259
269 void init( const TValue* t, unsigned int size, int z = 0, bool p = false,
270 const TValue & def = TValue( 0 ) );
271
272
276 unsigned int size() const;
277
278 // ----------------------- Signal services ----------------------------
279 public:
280
289 TValue & operator[]( int i );
290
299 const TValue & operator[]( int i ) const;
300
306 void setAll( const TValue & val = TValue( 0 ) );
307
308
315 void multiply( const TValue & val );
316
327
328 // ----------------------- Interface --------------------------------------
329 public:
330
335 void selfDisplay ( std::ostream & out ) const;
336
341 bool isValid() const;
342
343
344 // ------------------------- Datas --------------------------------------
345 private:
346
351
352 // ------------------------- Hidden services ----------------------------
353 protected:
354
355
356 }; // end of class Signal
357
358
365 template <typename TValue>
366 std::ostream&
367 operator<< ( std::ostream & out, const Signal<TValue> & object );
368
369} // namespace DGtal
370
371
373// Includes inline functions.
374#include "DGtal/math/Signal.ih"
375
376// //
378
379#endif // !defined Signal_h
380
381#undef Signal_RECURSES
382#endif // else defined(Signal_RECURSES)
Aim: Copy on write shared pointer.
Definition: CowPtr.h:68
Aim: Represents a discrete signal, periodic or not. The signal can be passed by value since it is onl...
Definition: Signal.h:162
void init(const TValue *t, unsigned int size, int z=0, bool p=false, const TValue &def=TValue(0))
static Signal< TValue > H2n(unsigned int n)
static Signal< TValue > G2()
Signal< TValue > & operator=(const Signal< TValue > &other)
TValue & operator[](int i)
Signal< TValue > operator*(const Signal< TValue > &G)
static Signal< TValue > D2n(unsigned int n)
void init(unsigned int s, int z=0, bool p=false, const TValue &def=TValue(0))
unsigned int size() const
void setAll(const TValue &val=TValue(0))
CowPtr< SignalData< TValue > > m_data
Definition: Signal.h:350
Signal(unsigned int size, int z, bool periodic, const TValue &def=TValue(0))
static Signal< TValue > G2n(unsigned int n)
const TValue & operator[](int i) const
void selfDisplay(std::ostream &out) const
bool isValid() const
Signal(const Signal< TValue > &other)
TValue Value
Definition: Signal.h:165
static Signal< TValue > H2()
Signal(const TValue *t, unsigned int size, int z, bool periodic, const TValue &def=TValue(0))
static Signal< TValue > Delta()
void multiply(const TValue &val)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
unsigned int size
the size of the array data.
Definition: Signal.h:64
void init(unsigned int s, int z=0, bool p=false, const Value &def=Value(0))
SignalData(const SignalData &other)
const Value & defaut() const
Value * data
a dyn. array on Value s.
Definition: Signal.h:62
SignalData & operator=(const SignalData &other)
SignalData(const Value *t, unsigned int size, int z=0, bool p=false, const Value &def=Value(0))
SignalData(unsigned int s, int z=0, bool p=false, const Value &def=Value(0))
int zero
the true index of the zero abscissa.
Definition: Signal.h:66
TValue Value
Definition: Signal.h:59
void init(const Value *t, unsigned int size, int z=0, bool p=false, const Value &def=Value(0))