| Home | Libraries | People | FAQ | More

## Function template reduce

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

## Synopsis

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

    template<typename Histogram, typename Iterable>
      Histogram reduce(const Histogram & hist, const Iterable & options);

## 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. Trying to reducing a non-reducible axis triggers an`invalid_argument` exception. Histograms with non-reducible axes can still be reduced along the other axes that are reducible.

An overload allows one to pass reduce_command as positional arguments.

Parameters:

`hist` | original histogram.
`options` | iterable sequence of reduce commands: `shrink`,`slice`,`rebin`,`shrink_and_rebin`, or`slice_and_rebin`. The element type of the iterable should be`reduce_command`.