DGtal
1.4.0
Loading...
Searching...
No Matches
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
{
56
Signal<double>
Gauss =
Signal<double>::G2n
( n );
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
{
65
Signal<double>
Gauss =
Signal<double>::G2n
( n );
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
// //
DGtal::Signal
Aim: Represents a discrete signal, periodic or not. The signal can be passed by value since it is onl...
Definition
Signal.h:162
DGtal::Signal::G2n
static Signal< TValue > G2n(unsigned int n)
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
Definition
Common.h:153
std
STL namespace.
main
int main()
Definition
testBits.cpp:56
testSignal
bool testSignal()
Definition
testSignal.cpp:46
tests
math
testSignal.cpp
Generated on Mon Jun 10 2024 17:36:13 for DGtal by
1.11.0