Function utilities::convolution_matrix

Function Documentation

Eigen::MatrixXd utilities::convolution_matrix(const Eigen::VectorXd &k, const Eigen::Index n)

Determines the convolution matrix C for impulse response (kernel) vector k.

convolution_matrix(k, n) * x is equivalent to conv(k, x)

C is a toeplitz matrix where the upper diagonal is entirely zero, the lower diagonal is zero for cases where

TODO sparse alternative. Large signals produce epically big, mostly empty, matrices.

Example:

Eigen::VectorXd k(5)
Eigen::VectorXd x(7)
k << 1, 2, 3, 2, 1;
x << 1, 2, 1, 2, 1, 2, 1;
Eigen::MatrixXd c = convolution_matrix(k, 7);
std::cout << "Convolved result c * x: " << c * x << std::endl

Parameters
  • k: Column vector input
  • n: Desired dimension of the output matrix. i.e. if convolving with vector x of length 8, n should be 8.
  • c: Convolution matrix