7 #ifndef NIHU_KRON_IDENTITY_HPP_INCLUDED
8 #define NIHU_KRON_IDENTITY_HPP_INCLUDED
10 #include <Eigen/Dense>
12 #include <type_traits>
20 template <
class Lhs,
size_t Dim>
24 typedef typename std::decay<Lhs>::type lhs_t;
25 static unsigned const dimension = Dim;
26 typedef typename lhs_t::Scalar scalar_t;
27 static Eigen::Index
const lhs_rows_compile_time = lhs_t::RowsAtCompileTime;
28 static Eigen::Index
const result_rows_compile_time =
29 lhs_rows_compile_time == Eigen::Dynamic ? Eigen::Dynamic : dimension * lhs_rows_compile_time;
36 : m_lhs(std::forward<Lhs>(lhs))
40 template <
class RhsDerived>
41 Eigen::Matrix<scalar_t, result_rows_compile_time, RhsDerived::ColsAtCompileTime>
42 operator*(Eigen::MatrixBase<RhsDerived>
const &rhs)
const
45 Eigen::Matrix<scalar_t, result_rows_compile_time, RhsDerived::ColsAtCompileTime> res(m_lhs.rows() * dimension, rhs.cols());
47 for (Eigen::Index i = 0; i < m_lhs.rows(); ++i)
48 for (Eigen::Index j = 0; j < m_lhs.cols(); ++j)
49 res.block(i * dimension, 0, dimension, rhs.cols()) +=
50 m_lhs(i, j) * rhs.block(j * dimension, 0, dimension, rhs.cols());
58 template <
size_t Dim,
class Lhs>