DGtal  0.9.2
testSignal.cpp
1 
30 #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  unsigned int nbok = 0;
49  unsigned int nb = 0;
50 
51  trace.beginBlock ( "Testing block ..." );
52  //double values[ 8 ] = { 1.0, 5.0, 3.0, 4.3, 6.2, 7.1, 5.7, 8.4 };
53  double values[ ] = { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
54  Signal<double> signal( values, 8, 2, false, 0.0 );
55  trace.info() << "Unperiodic signal" << endl;
56  trace.info() << signal << endl;
57  for ( unsigned int n = 1; n < 10; ++n )
58  {
60  Signal<double> conv_signal = signal * Gauss;
61  trace.info() << conv_signal << endl;
62  }
63  Signal<double> signal2( values, 8, 2, true, 0.0 );
64  trace.info() << "Periodic signal" << endl;
65  trace.info() << signal2 << endl;
66  for ( unsigned int n = 1; n < 10; ++n )
67  {
69  Signal<double> conv_signal = signal2 * Gauss;
70  trace.info() << conv_signal << endl;
71  }
72  nbok += true ? 1 : 0;
73  nb++;
74  trace.info() << "(" << nbok << "/" << nb << ") "
75  << "true == true" << std::endl;
76  trace.endBlock();
77 
78  return nbok == nb;
79 }
80 
81 
83 // Standard services - public :
84 
85 int main( int argc, char** argv )
86 {
87  trace.beginBlock ( "Testing class Signal" );
88  trace.info() << "Args:";
89  for ( int i = 0; i < argc; ++i )
90  trace.info() << " " << argv[ i ];
91  trace.info() << endl;
92 
93  bool res = testSignal();
94  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
95  trace.endBlock();
96  return res ? 0 : 1;
97 }
98 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:130
STL namespace.
double endBlock()
Aim: Represents a discrete signal, periodic or not. The signal can be passed by value since it is onl...
Definition: Signal.h:162
std::ostream & emphase()
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & info()