37 const Eigen::MatrixBase<Derived> & y,
const Eigen::MatrixBase<Derived> & w
42 static_assert(Derived::IsVectorAtCompileTime,
"Error: y and w are not vector.");
44 if(y.size() == 0 || w.size() == 0) {
45 throw std::invalid_argument(
"WeightedMovingAverage(): the length of y or w is zero.");
48 using PlainObject =
typename Derived::PlainObject;
50 int points = w.size();
53 PlainObject result = PlainObject::Zero(y.size());
56 for(
int i = 0; i < y.size(); i++) {
57 result(i) = (yy.block(i, 0, points, 1).array() * w.array()).matrix().sum();
60 else if(y.rows() == 1) {
61 for(
int i = 0; i < y.size(); i++) {
62 result(i) = (yy.block(0, i, 1, points).array() * w.array()).matrix().sum();
const Derived::PlainObject ExpandBoundaries(const Eigen::MatrixBase< Derived > &y, const unsigned int n)
Expands the boundaries of a vector by padding with the first and last elements.