tables::column::sums

1)

template <is_primitive_type P>
column<P> column<P>::sums()

2)

template <is_primitive_type P>
column<P> column<P>::msum(const std::size_t m) const

  1. Returns the cumulative sum of items.

  2. Returns moving sum of the last m items.

Complexity

Linear

Example

Code

#include <cpptables/table.hh>

using namespace tables;
using namespace std;

void column_sums()
{
  vector<unsigned> v(5);
  iota(v.begin(), v.end(), 1);
  const column<unsigned> xs(v);

  cout << xs.sums() << "\n";
  cout << xs.msum(2) << "\n";
}

Output

1 2 6 10 15

1 3 5 7 9