DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testProfile.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "ConfigTest.h"
34
#include "DGtalCatch.h"
35
#include "DGtal/helpers/StdDefs.h"
36
#include "DGtal/math/Profile.h"
38
39
using namespace
std
;
40
using namespace
DGtal
;
41
43
// Functions for testing class Profile.
45
46
struct
LogFct
{
47
double
operator()
(
const
double
&a)
const
{
48
return
log(a);
49
}
50
};
51
52
TEST_CASE
(
"Testing Profile"
)
53
{
54
55
Profile<LogFct>
sp(
Profile<LogFct>::MEAN
);
56
sp.
init
(5);
57
58
SECTION
(
"Testing basic add of Profile"
)
59
{
60
sp.
addValue
(0, 10.0);
61
sp.
addValue
(1, 10.0);
62
sp.
addValue
(2, 10.0);
63
sp.
addValue
(3, 10.0);
64
sp.
addValue
(4, 10.0);
65
std::vector<double> x;
66
std::vector<double> y;
67
sp.
getProfile
(x, y);
68
REQUIRE
( x[3] == Approx(log(4)) );
69
REQUIRE
( y[3] == Approx(log(10.0)) );
70
}
71
72
Profile<>
sp2(
Profile<>::MAX
);
73
sp2.
init
(3,
true
);
74
75
SECTION
(
"Testing Profile (with max/median)"
)
76
{
77
sp2.
addValue
(0, 1);
78
sp2.
addValue
(0, 3);
79
sp2.
addValue
(0, 2);
80
sp2.
addValue
(1, 13);
81
sp2.
addValue
(1, 2);
82
sp2.
addValue
(1, 1);
83
sp2.
addValue
(2, 4);
84
std::vector<double> x;
85
std::vector<double> y;
86
sp2.
getProfile
(x, y);
87
REQUIRE
( x[0] == 1 );
88
REQUIRE
( y[0] == 3);
89
sp2.
setType
(
Profile<>::MIN
);
90
x.clear();
91
y.clear();
92
sp2.
getProfile
(x, y);
93
REQUIRE
( x[1] == 2 );
94
REQUIRE
( y[1] == 1);
95
sp2.
setType
(
Profile<>::MEDIAN
);
96
x.clear();
97
y.clear();
98
sp2.
getProfile
(x, y);
99
REQUIRE
( x[0] == 1 );
100
REQUIRE
( y[0] == 2);
101
}
102
103
}
104
DGtal::Profile
Aim: This class can be used to represent a profile (PX, PY) defined from an input set of samples (Xi,...
Definition
Profile.h:137
DGtal::Profile::getProfile
void getProfile(std::vector< Value > &x, std::vector< Value > &y) const
DGtal::Profile::addValue
void addValue(const unsigned int indexX, const TValue value)
DGtal::Profile::init
void init(Iterator beginXvalues, Iterator endXvalues, const bool storeValsInStats=false)
DGtal::Profile::MAX
@ MAX
Definition
Profile.h:146
DGtal::Profile::MEDIAN
@ MEDIAN
Definition
Profile.h:146
DGtal::Profile::MEAN
@ MEAN
Definition
Profile.h:146
DGtal::Profile::MIN
@ MIN
Definition
Profile.h:146
DGtal::Profile::setType
void setType(const ProfileType type)
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
LogFct
Definition
testMeaningfulScaleAnalysis.cpp:51
LogFct::operator()
double operator()(const double &a) const
Definition
testProfile.cpp:47
TEST_CASE
TEST_CASE("int container traits", "[int][traits]")
Definition
testContainerTraits.cpp:53
SECTION
SECTION("Testing constant forward iterators")
Definition
testSimpleRandomAccessRangeFromPoint.cpp:66
REQUIRE
REQUIRE(domain.isInside(aPoint))
tests
math
testProfile.cpp
Generated on
for DGtal by
1.18.0