sablib
Loading...
Searching...
No Matches
diff.h File Reference

MATLAB-like diff() function. More...

#include <Eigen/Eigen>

Go to the source code of this file.

Enumerations

enum class  sablib::Dir { RowWise , ColumnWise }
 Direction for difference calculation. More...

Functions

template<typename Derived>
const Derived::PlainObject sablib::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.
template<typename Derived>
const Derived::PlainObject sablib::Diff (const Eigen::SparseMatrixBase< Derived > &m0, const int n=1, const Dir dir=Dir::RowWise)
 Calculates the n-th discrete difference for sparse matrices along the given axis.

Detailed Description

MATLAB-like diff() function.

Author
Izadori

Definition in file diff.h.

Enumeration Type Documentation

◆ Dir

enum class sablib::Dir
strong

Direction for difference calculation.

Enumerator
RowWise 

Calculates the difference along the rows (MATLAB-like).

ColumnWise 

Calculates the difference along the columns (Python-like).

Definition at line 17 of file diff.h.

Function Documentation

◆ Diff() [1/2]

template<typename Derived>
const Derived::PlainObject sablib::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.

Parameters
m0The input matrix or vector.
nThe order of difference (default is 1).
dirThe direction to calculate the difference (RowWise or ColumnWise).
Returns
The n-th discrete difference.

Definition at line 32 of file diff.h.

◆ Diff() [2/2]

template<typename Derived>
const Derived::PlainObject sablib::Diff ( const Eigen::SparseMatrixBase< Derived > & m0,
const int n = 1,
const Dir dir = Dir::RowWise )

Calculates the n-th discrete difference for sparse matrices along the given axis.

Parameters
m0The input sparse matrix or vector.
nThe order of difference (default is 1).
dirThe direction to calculate the difference (RowWise or ColumnWise).
Returns
The n-th discrete difference.

Definition at line 65 of file diff.h.