23const typename Derived::PlainObject
ExpandBoundaries(
const Eigen::MatrixBase<Derived> & y,
const unsigned int n)
27 static_assert(Derived::IsVectorAtCompileTime,
"Error: y is not vector.");
29 typename Derived::PlainObject result(y.size() + 2 * n);
32 result.block(0, 0, n, 1).fill(y(0));
33 result.block(result.size() - n, 0, n, 1).fill(y(y.size() - 1));
34 result.block(n, 0, y.size(), 1) = y;
36 else if(y.rows() == 1) {
37 result.block(0, 0, 1, n).fill(y(0));
38 result.block(0, result.size() - n, 1, n).fill(y(y.size() - 1));
39 result.block(0, n, 1, y.size()) = y;
54const typename Derived::PlainObject
TrimBoundaries(
const Eigen::MatrixBase<Derived> & y,
const unsigned int n)
58 static_assert(Derived::IsVectorAtCompileTime,
"Error: y is not vector.");
60 if(y.size() < 2 * n) {
61 throw std::invalid_argument(
"TrimBoubdaries(): n is too large.");
65 return y.block(n, 0, y.size() - 2 * n, 1);
67 else if(y.rows() == 1) {
68 return y.block(0, n, 1, y.size() - 2 * n);
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.