DGtal  1.5.beta
testSignal.cpp
Go to the documentation of this file.
1 
31 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/math/Signal.h"
35 
36 using namespace std;
37 using namespace DGtal;
38 
40 // Functions for testing class Signal.
42 
46 bool testSignal()
47 {
48  trace.beginBlock ( "Testing block ..." );
49  //double values[ 8 ] = { 1.0, 5.0, 3.0, 4.3, 6.2, 7.1, 5.7, 8.4 };
50  double values[ ] = { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
51  Signal<double> signal( values, 8, 2, false, 0.0 );
52  trace.info() << "Unperiodic signal" << endl;
53  trace.info() << signal << endl;
54  for ( unsigned int n = 1; n < 10; ++n )
55  {
57  Signal<double> conv_signal = signal * Gauss;
58  trace.info() << conv_signal << endl;
59  }
60  Signal<double> signal2( values, 8, 2, true, 0.0 );
61  trace.info() << "Periodic signal" << endl;
62  trace.info() << signal2 << endl;
63  for ( unsigned int n = 1; n < 10; ++n )
64  {
66  Signal<double> conv_signal = signal2 * Gauss;
67  trace.info() << conv_signal << endl;
68  }
69  trace.endBlock();
70 
71  return true;
72 }
73 
74 
76 // Standard services - public :
77 
78 int main( int argc, char** argv )
79 {
80  trace.beginBlock ( "Testing class Signal" );
81  trace.info() << "Args:";
82  for ( int i = 0; i < argc; ++i )
83  trace.info() << " " << argv[ i ];
84  trace.info() << endl;
85 
86  bool res = testSignal();
87  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
88  trace.endBlock();
89  return res ? 0 : 1;
90 }
91 // //
Aim: Represents a discrete signal, periodic or not. The signal can be passed by value since it is onl...
Definition: Signal.h:162
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
int main(int argc, char **argv)
Definition: testSignal.cpp:78
bool testSignal()
Definition: testSignal.cpp:46