Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
22b4e047
Commit
22b4e047
authored
Jul 18, 2012
by
Sebastian Eichelbaum
Browse files
[MERGE]
parents
66e2231e
3b811d56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
12 deletions
+27
-12
src/core/common/WHistogramBasic.cpp
src/core/common/WHistogramBasic.cpp
+6
-4
src/core/common/test/WHistogramBasic_test.h
src/core/common/test/WHistogramBasic_test.h
+16
-3
src/core/dataHandler/WValueSet.h
src/core/dataHandler/WValueSet.h
+4
-4
src/modules/histogramView/WMHistogramView.cpp
src/modules/histogramView/WMHistogramView.cpp
+1
-1
No files found.
src/core/common/WHistogramBasic.cpp
View file @
22b4e047
...
...
@@ -87,12 +87,14 @@ void WHistogramBasic::insert( double value )
return
;
// value = ( value > m_maximum ? m_maximum : m_minimum );
}
if
(
value
==
m_maximum
)
if
(
std
::
abs
(
m_minimum
-
m_maximum
)
<=
2.0
*
wlimits
::
DBL_EPS
)
{
value
=
m_maximum
-
wlimits
::
DBL_EPS
;
m_bins
.
at
(
m_nbBuckets
-
1
)
++
;
}
else
{
m_bins
.
at
(
static_cast
<
size_t
>
(
(
value
-
m_minimum
)
/
std
::
abs
(
m_maximum
-
m_minimum
)
*
(
m_nbBuckets
-
1
)
)
)
++
;
}
m_bins
.
at
(
static_cast
<
size_t
>
(
std
::
abs
(
value
-
m_minimum
)
/
m_intervalWidth
)
)
++
;
}
size_t
WHistogramBasic
::
valuesSize
()
const
...
...
src/core/common/test/WHistogramBasic_test.h
View file @
22b4e047
...
...
@@ -64,7 +64,7 @@ public:
h
.
insert
(
0.7234
);
TS_ASSERT_EQUALS
(
h
.
size
(),
1000
);
TS_ASSERT_EQUALS
(
h
.
valuesSize
(),
1
);
TS_ASSERT_EQUALS
(
h
[
72
3
],
1
);
TS_ASSERT_EQUALS
(
h
[
72
2
],
1
);
}
/**
...
...
@@ -74,11 +74,11 @@ public:
{
WHistogramBasic
h
(
0.0
,
1.0
);
h
.
insert
(
0.001
);
TS_ASSERT_EQUALS
(
h
[
1
],
1
);
TS_ASSERT_EQUALS
(
h
[
0
],
1
);
h
.
insert
(
0.0039999
);
TS_ASSERT_EQUALS
(
h
[
3
],
1
);
h
.
insert
(
0.0070001
);
TS_ASSERT_EQUALS
(
h
[
7
],
1
);
TS_ASSERT_EQUALS
(
h
[
6
],
1
);
}
/**
...
...
@@ -132,6 +132,19 @@ public:
h
.
insert
(
0.0
);
TS_ASSERT_EQUALS
(
h
.
valuesSize
(),
2
);
}
/**
* Also for values near the maxium. You may also see #186 for further details.
*/
void
testInsertAlmostMax
(
void
)
{
double
max
=
10000.000000010001
;
WHistogramBasic
h
(
-
2147483648
,
max
);
h
.
insert
(
10000
);
h
.
insert
(
max
-
2.0
*
wlimits
::
FLT_EPS
);
TS_ASSERT_EQUALS
(
h
[
999
],
2
);
}
};
#endif // WHISTOGRAMBASIC_TEST_H
src/core/dataHandler/WValueSet.h
View file @
22b4e047
...
...
@@ -123,8 +123,8 @@ public:
{
// calculate min and max
// Calculating this once simply ensures that it does not need to be recalculated in textures, histograms ...
m_minimum
=
wlimits
::
MAX_DOUBLE
;
m_maximum
=
wlimits
::
MIN_DOUBLE
;
m_minimum
=
std
::
numeric_limits
<
T
>::
max
()
;
m_maximum
=
std
::
numeric_limits
<
T
>::
min
()
;
for
(
typename
std
::
vector
<
T
>::
const_iterator
iter
=
data
->
begin
();
iter
!=
data
->
end
();
++
iter
)
{
m_minimum
=
m_minimum
>
*
iter
?
*
iter
:
m_minimum
;
...
...
@@ -145,8 +145,8 @@ public:
{
// calculate min and max
// Calculating this once simply ensures that it does not need to be recalculated in textures, histograms ...
m_minimum
=
wlimits
::
MAX_DOUBLE
;
m_maximum
=
wlimits
::
MIN_DOUBLE
;
m_minimum
=
std
::
numeric_limits
<
T
>::
max
()
;
m_maximum
=
std
::
numeric_limits
<
T
>::
min
()
;
for
(
typename
std
::
vector
<
T
>::
const_iterator
iter
=
data
->
begin
();
iter
!=
data
->
end
();
++
iter
)
{
m_minimum
=
m_minimum
>
*
iter
?
*
iter
:
m_minimum
;
...
...
src/modules/histogramView/WMHistogramView.cpp
View file @
22b4e047
...
...
@@ -398,7 +398,7 @@ void WMHistogramView::calculateHistograms()
{
// create new histogram
// we do not use WDataSetScalar's getHistogram here as we want to set the min and max of the histogram ourselves
m_histograms
[
k
]
=
boost
::
shared_ptr
<
WHistogramBasic
>
(
new
WHistogramBasic
(
min
,
max
+
0.00000001
,
histoBins
)
);
m_histograms
[
k
]
=
boost
::
shared_ptr
<
WHistogramBasic
>
(
new
WHistogramBasic
(
min
,
max
,
histoBins
)
);
if
(
m_data
[
k
]
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment