tables::column::xbar

template <is_valid_primitive P>
column<P> column<P>::xbar(const prim_t val) const

Rounds down elements to nearest multiple of val.

Complexity

Linear

Example

Code

#include <cpptables/table.hh>

using namespace tables;
using namespace std;

void column_xbar()
{
  vector<unsigned> v(20);
  iota(v.begin(), v.end(), 0);

  const column<unsigned> xs(v);
  cout << xs.xbar(3) << "\n";
  cout << xs.cast_to<double>().xbar(1.5) << "\n";
}

Output

0 0 0 3 3 3 6 6 6 9 9 9 12 12 12 15 15 15 18 18

0 0 1.5 3 3 4.5 6 6 7.5 9 9 10.5 12 12 13.5 15 15 16.5 18 18