| Home | Libraries | People | FAQ | More

## Function template reduce

boost::histogram::algorithm::reduce — Shrink, slice, and/or rebin axes of a histogram.

## Synopsis

    // In header: <boost/histogram/algorithm/reduce.hpp>

    template<typename Histogram, class... Ts>
      Histogram reduce(const Histogram & hist, const reduce_command & opt,
                       const Ts &... opts);

## Description

Returns a new reduced histogram and leaves the original histogram untouched.

The commands `rebin` and`shrink` or`slice` for the same axis are automatically combined, this is not an error. Passing a`shrink` and a`slice` command for the same axis or two`rebin` commands triggers an invalid_argument exception. It is safe to reduce histograms with some axis that are not reducible along the other axes. Trying to reducing a non-reducible axis triggers an invalid_argument exception.

An overload allows one to pass an iterable of reduce_command.

Parameters: |
`hist` | original histogram.
`opt` | first reduce command; one of `shrink`,`slice`,`rebin`,`shrink_and_rebin`, or`slice_or_rebin`.
`opts` | more reduce commands.