DGtal  0.9.3
Functions
testSignal.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/math/Signal.h"
Include dependency graph for testSignal.cpp:

Go to the source code of this file.

Functions

bool testSignal ()
 
int main (int argc, char **argv)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
Date
2011/07/06

Functions for testing class Signal.

This file is part of the DGtal library.

Definition in file testSignal.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 85 of file testSignal.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testSignal(), and DGtal::trace.

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 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
double endBlock()
bool testSignal()
Definition: testSignal.cpp:46
std::ostream & emphase()
std::ostream & info()

◆ testSignal()

bool testSignal ( )

Example of a test. To be completed.

Definition at line 46 of file testSignal.cpp.

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::info(), and DGtal::trace.

Referenced by main().

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 }
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
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 & info()