Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Function period_sums

boost::time_series::period_sums — Calculate the sums within fixed-width ranges in a series and store the results at the start of each range.

Synopsis

// In header: <boost/time_series/numeric/period_sums.hpp>


template<typename Series, typename Offset, typename Length, typename Out> 
  ordered_inserter< Out > 
  period_sums(Series const & series, Offset start, Length length, 
              ordered_inserter< Out > out);
template<typename Series, typename Offset, typename Length> 
  sparse_series< typename concepts::TimeSeries< Series const  >::value_type typename concepts::TimeSeries< Series const  >::discretization_type, Offset > 
  period_sums(Series const & series, Offset start, Length length);

Description

Calculate the sums within fixed-width ranges in a series and store the results at the start of each range.

This function assumes that zero value of the series does not contribute to the sums, that start is not -inf and that the series does not have a non-zero positive infinite run.

The input series is allowed to use floating point offsets, but the periods as specified by the start and length parameters must be integral. As a result, the output series will necessarily have integral offsets.

Parameters:
length

The length of the periods. Must be integral.

out

The ordered inserter to receive the adjacent difference result.

series

The input series.

start

The offset of the first period. Must be integral.

Requires:

Series is a model of the TimeSeries concept.

Out is a model of the OrderedInserter concept.

Offset is integral.

Length is integral.

For variaibles x and y of the series' value_type, and l of type Length, the expression (x+=y*l) must be convertible to value_type.

For a variable x of the series' value_type, x == (x + range_run_storage::zero(series)).

start != -inf

series[inf] == range_run_storage::zero(series)

Returns:

A sparse_series<> if no ordered inserter is specified; otherwise, the ordered inserter.

Notes:

If using the version that takes an OrderedInserter, you must call .commit() on the returned OrderedInserter when you are done with it.


PrevUpHomeNext