mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-09 23:04:07 +00:00
faster axis integer value method (#220)
This commit is contained in:
parent
6b767cc2aa
commit
b4298d6857
@ -130,9 +130,10 @@ public:
|
||||
|
||||
/// Return value for index argument.
|
||||
value_type value(local_index_type i) const noexcept {
|
||||
if (!options_type::test(option::circular)) {
|
||||
if (!options_type::test(option::circular) &&
|
||||
std::is_floating_point<value_type>::value) {
|
||||
if (i < 0) return detail::lowest<value_type>();
|
||||
if (i > size()) { return detail::highest<value_type>(); }
|
||||
if (i > size()) return detail::highest<value_type>();
|
||||
}
|
||||
return min_ + i;
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ int main() {
|
||||
// axis::integer with int type
|
||||
{
|
||||
axis::integer<int> a{-1, 2};
|
||||
BOOST_TEST_EQ(a.bin(-2), (std::numeric_limits<int>::min)());
|
||||
BOOST_TEST_EQ(a.bin(4), (std::numeric_limits<int>::max)());
|
||||
BOOST_TEST_EQ(a.bin(-2), -3);
|
||||
BOOST_TEST_EQ(a.bin(4), 3);
|
||||
BOOST_TEST_EQ(a.index(-10), -1);
|
||||
BOOST_TEST_EQ(a.index(-2), -1);
|
||||
BOOST_TEST_EQ(a.index(-1), 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user