mirror of
https://github.com/boostorg/histogram.git
synced 2025-05-10 07:14:05 +00:00
faster for identical axes (#121)
This commit is contained in:
parent
7f4cb204de
commit
1be4c4b3f2
@ -429,6 +429,11 @@ public:
|
|||||||
/** Add values of another histogram.
|
/** Add values of another histogram.
|
||||||
|
|
||||||
This operator is only available if the value_type supports operator+=.
|
This operator is only available if the value_type supports operator+=.
|
||||||
|
|
||||||
|
Both histograms must be compatible to be addable. The histograms are compatible, if
|
||||||
|
the axes are either all identical. If the axes only differ in the states of their
|
||||||
|
discrete growing axis types, then they are also compatible. The discrete growing
|
||||||
|
axes are merged in this case.
|
||||||
*/
|
*/
|
||||||
template <class A, class S>
|
template <class A, class S>
|
||||||
#ifdef BOOST_HISTOGRAM_DOXYGEN_INVOKED
|
#ifdef BOOST_HISTOGRAM_DOXYGEN_INVOKED
|
||||||
@ -457,6 +462,12 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
operator+=(const histogram<axes_type, S>& rhs) {
|
operator+=(const histogram<axes_type, S>& rhs) {
|
||||||
const auto& raxes = unsafe_access::axes(rhs);
|
const auto& raxes = unsafe_access::axes(rhs);
|
||||||
|
if (detail::axes_equal(axes_, unsafe_access::axes(rhs))) {
|
||||||
|
auto rit = unsafe_access::storage(rhs).begin();
|
||||||
|
for (auto&& x : storage_) x += *rit++;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
if (rank() != detail::axes_rank(raxes))
|
if (rank() != detail::axes_rank(raxes))
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("axes have different length"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("axes have different length"));
|
||||||
auto h = histogram<axes_type, storage_type>(
|
auto h = histogram<axes_type, storage_type>(
|
||||||
@ -691,8 +702,7 @@ histogram(Iterable)->histogram<std::vector<typename Iterable::value_type>>;
|
|||||||
template <class Iterable, class S, class = detail::requires_iterable<Iterable>,
|
template <class Iterable, class S, class = detail::requires_iterable<Iterable>,
|
||||||
class = detail::requires_any_axis<typename Iterable::value_type>,
|
class = detail::requires_any_axis<typename Iterable::value_type>,
|
||||||
class = detail::requires_storage_or_adaptible<S>>
|
class = detail::requires_storage_or_adaptible<S>>
|
||||||
histogram(Iterable, S)
|
histogram(Iterable, S) -> histogram<
|
||||||
->histogram<
|
|
||||||
std::vector<typename Iterable::value_type>,
|
std::vector<typename Iterable::value_type>,
|
||||||
std::conditional_t<detail::is_adaptible<S>::value, storage_adaptor<S>, S>>;
|
std::conditional_t<detail::is_adaptible<S>::value, storage_adaptor<S>, S>>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user