34 typename Derived::PlainObject m = m0;
35 int rows = m.rows(), columns = m.cols();
38 for(
int i = 0; i < n ; i++){
39 int col_counts = columns - i - 1;
40 m.leftCols(col_counts) = m.block(0, 1, rows, col_counts) - m.leftCols(col_counts);
43 return m.leftCols(columns - n);
46 for(
int i = 0; i < n ; i++){
47 int row_counts = rows - i - 1;
48 m.topRows(row_counts) = m.block(1, 0, row_counts, columns) - m.topRows(row_counts);
51 return m.topRows(rows - n);
const Derived::PlainObject Diff(const Eigen::MatrixBase< Derived > &m0, const int n=1, const Dir dir=Dir::RowWise)
Calculates the n-th discrete difference along the given axis.