24 #ifndef BLOCK_PRODUCT_HPP_INCLUDED
25 #define BLOCK_PRODUCT_HPP_INCLUDED
38 template <
class leftDerived,
class mat,
class rightDerived,
39 bool isEigen = is_eigen<mat>::value>
40 class block_product_impl;
43 template <
class leftDerived,
class Scalar,
class rightDerived>
44 class block_product_impl<leftDerived, Scalar, rightDerived, false>
47 typedef typename plain_type<
48 typename product_type<
51 typename product_type<leftDerived, Eigen::Transpose<rightDerived> >::type
56 static result_type eval(
57 Eigen::MatrixBase<leftDerived>
const &v1,
59 Eigen::MatrixBase<rightDerived>
const &v2
62 return m * (v1 * v2.transpose());
67 template <
class leftDerived,
class matDerived,
class rightDerived>
68 class block_product_impl<leftDerived, matDerived, rightDerived, true>
70 typedef typename leftDerived::Scalar scalar1;
71 typedef typename matDerived::Scalar scalar2;
72 typedef typename rightDerived::Scalar scalar3;
74 N1 = leftDerived::RowsAtCompileTime,
75 N21 = matDerived::RowsAtCompileTime, N22 = matDerived::ColsAtCompileTime,
76 N3 = rightDerived::RowsAtCompileTime
78 typedef typename product_type<
84 typedef Eigen::Matrix<scalar, N1*N21, N22*N3> result_type;
86 static result_type eval(
87 Eigen::MatrixBase<leftDerived>
const &v1,
88 Eigen::MatrixBase<matDerived>
const &m,
89 Eigen::MatrixBase<rightDerived>
const &v2)
92 for (
size_t row = 0; row < N1; ++row)
93 for (
size_t col = 0; col < N3; ++col)
94 result.template block<N21, N22>(row*N21, col*N22) =
95 m *
static_cast<scalar
>(v1(row, 0) * v2(col, 0));
101 template <
class mat,
class rightDerived,
102 bool isEigen = is_eigen<mat>::value>
103 class semi_block_product_impl;
105 template <
class mat,
class rightDerived>
106 class semi_block_product_impl<mat, rightDerived, false>
109 typedef typename plain_type<
110 typename product_type<
112 Eigen::Transpose<rightDerived>
116 static result_type eval(mat
const &m, Eigen::MatrixBase<rightDerived>
const &v2)
118 return m * v2.transpose();
123 template <
class mat,
class rightDerived>
124 class semi_block_product_impl<mat, rightDerived, true>
126 typedef typename mat::Scalar scalar2;
127 typedef typename rightDerived::Scalar scalar3;
129 N21 = mat::RowsAtCompileTime,
130 N22 = mat::ColsAtCompileTime,
131 N3 = rightDerived::RowsAtCompileTime
135 typedef Eigen::Matrix<scalar, N21, N22*N3> result_type;
137 static result_type eval(
138 Eigen::MatrixBase<Eigen::Matrix<scalar2, N21, N22> >
const &m,
139 Eigen::MatrixBase<rightDerived>
const &v2)
142 for (
int col = 0; col < N3; ++col)
143 result.template block<N21, N22>(0, col*N22) = m * v2(col, 0);
153 template <
class leftDerived,
class mat,
class rightDerived>
156 typedef typename internal::block_product_impl<leftDerived, mat, rightDerived>::result_type type;
168 template <
class leftDerived,
class mat,
class rightDerived>
169 typename block_product_result_type<leftDerived, mat, rightDerived>::type
171 Eigen::MatrixBase<leftDerived>
const &l,
173 Eigen::MatrixBase<rightDerived>
const &r)
175 return internal::block_product_impl<leftDerived, mat, rightDerived>::eval(l, m, r);
179 template <
class mat,
class rightDerived>
182 typedef typename internal::semi_block_product_impl<mat, rightDerived>::result_type type;
192 template <
class mat,
class rightDerived>
193 typename semi_block_product_result_type<mat, rightDerived>::type
196 Eigen::MatrixBase<rightDerived>
const &r)
198 return internal::semi_block_product_impl<mat, rightDerived>::eval(m, r);
203 #endif // BLOCK_PRODUCT_HPP_INCLUDED