7 #ifndef NIHU_CONVOLUTION_MATRIX_HPP_INCLUDED
8 #define NIHU_CONVOLUTION_MATRIX_HPP_INCLUDED
10 #include <Eigen/Dense>
23 template <
class Scalar>
30 typedef Eigen::Matrix<scalar_t, Eigen::Dynamic, 1>
vector_t;
45 , m_diag_coeffs(diag_coeffs)
56 if (rhs.rows() != Eigen::Index(2 * m_M + 1))
57 throw std::runtime_error(
"Invalid input size in convolution matrix");
59 vector_t res = vector_t::Zero(2 * m_N + 1, 1);
60 int L = int((m_diag_coeffs.rows() - 1) / 2);
62 for (
int n = -
int(m_N); n <= int(m_N); ++n)
64 for (
int m = -
int(m_M); m <= int(m_M); ++m)
67 if (c >= L || c <= -L)
69 res(n + m_N) += m_diag_coeffs(c + L) * rhs(m + m_M);