10 #ifndef EIGEN_PRODUCTBASE_H 11 #define EIGEN_PRODUCTBASE_H 21 template<
typename Derived,
typename _Lhs,
typename _Rhs>
46 #define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived) \ 47 typedef ProductBase<Derived, Lhs, Rhs > Base; \ 48 EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ 49 typedef typename Base::LhsNested LhsNested; \ 50 typedef typename Base::_LhsNested _LhsNested; \ 51 typedef typename Base::LhsBlasTraits LhsBlasTraits; \ 52 typedef typename Base::ActualLhsType ActualLhsType; \ 53 typedef typename Base::_ActualLhsType _ActualLhsType; \ 54 typedef typename Base::RhsNested RhsNested; \ 55 typedef typename Base::_RhsNested _RhsNested; \ 56 typedef typename Base::RhsBlasTraits RhsBlasTraits; \ 57 typedef typename Base::ActualRhsType ActualRhsType; \ 58 typedef typename Base::_ActualRhsType _ActualRhsType; \ 62 template<
typename Derived,
typename Lhs,
typename Rhs>
91 : m_lhs(a_lhs), m_rhs(a_rhs)
94 &&
"invalid matrix product" 95 &&
"if you wanted a coeff-wise or a dot product use the respective explicit functions");
101 template<
typename Dest>
102 inline void evalTo(Dest& dst)
const { dst.setZero(); scaleAndAddTo(dst,
Scalar(1)); }
104 template<
typename Dest>
105 inline void addTo(Dest& dst)
const { scaleAndAddTo(dst,
Scalar(1)); }
107 template<
typename Dest>
108 inline void subTo(Dest& dst)
const { scaleAndAddTo(dst,
Scalar(-1)); }
110 template<
typename Dest>
119 m_result.
resize(m_lhs.rows(), m_rhs.cols());
120 derived().evalTo(m_result);
137 #ifdef EIGEN2_SUPPORT 138 return lhs().row(row).cwiseProduct(rhs().
col(col).transpose()).sum();
143 return result.
coeff(row,col);
152 return result.
coeff(i);
159 return derived().coeffRef(row,col);
166 return derived().coeffRef(i);
180 template<
typename Lhs,
typename Rhs,
int Mode,
int N,
typename PlainObject>
183 typedef PlainObject
const&
type;
187 template<
typename NestedProduct>
196 template<
typename Derived,
typename Lhs,
typename Rhs>
201 template<
typename Derived,
typename Lhs,
typename Rhs>
208 template<
typename Derived,
typename Lhs,
typename Rhs>
213 template<
typename Derived,
typename Lhs,
typename Rhs>
214 typename internal::enable_if<!internal::is_same<typename Derived::Scalar,typename Derived::RealScalar>::value,
220 template<
typename NestedProduct>
222 :
traits<ProductBase<ScaledProduct<NestedProduct>,
223 typename NestedProduct::_LhsNested,
224 typename NestedProduct::_RhsNested> >
230 template<
typename NestedProduct>
233 typename NestedProduct::_LhsNested,
234 typename NestedProduct::_RhsNested>
238 typename NestedProduct::_LhsNested,
239 typename NestedProduct::_RhsNested>
Base;
245 : Base(prod.lhs(),prod.rhs()), m_prod(prod), m_alpha(x) {}
247 template<
typename Dest>
248 inline void evalTo(Dest& dst)
const { dst.setZero(); scaleAndAddTo(dst, Scalar(1)); }
250 template<
typename Dest>
251 inline void addTo(Dest& dst)
const { scaleAndAddTo(dst, Scalar(1)); }
253 template<
typename Dest>
254 inline void subTo(Dest& dst)
const { scaleAndAddTo(dst, Scalar(-1)); }
256 template<
typename Dest>
257 inline void scaleAndAddTo(Dest& dst,
const Scalar& a_alpha)
const { m_prod.derived().scaleAndAddTo(dst,a_alpha * m_alpha); }
259 const Scalar&
alpha()
const {
return m_alpha; }
268 template<
typename Derived>
269 template<
typename ProductDerived,
typename Lhs,
typename Rhs>
272 other.derived().
evalTo(derived());
278 #endif // EIGEN_PRODUCTBASE_H const Diagonal< FullyLazyCoeffBaseProductType, Index > diagonal() const
Expression of the product of two general matrices or vectors.
const NestedProduct & m_prod
#define EIGEN_STATIC_ASSERT_SIZE_1x1(TYPE)
internal::remove_all< ActualRhsType >::type _ActualRhsType
promote_index_type< typename traits< Lhs >::Index, typename traits< Rhs >::Index >::type Index
void addTo(Dest &dst) const
Base::CoeffReturnType coeff(Index i) const
internal::traits< Derived >::Scalar Scalar
scalar_product_traits< typename Lhs::Scalar, typename Rhs::Scalar >::ReturnType Scalar
internal::traits< Derived >::Index Index
The type of indices.
const Scalar & coeffRef(Index i) const
MatrixBase< Derived > Base
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
const unsigned int RowMajorBit
internal::remove_all< ActualLhsType >::type _ActualLhsType
void addTo(Dest &dst) const
void subTo(Dest &dst) const
const _RhsNested & rhs() const
ProductBase< ScaledProduct< NestedProduct >, typename NestedProduct::_LhsNested, typename NestedProduct::_RhsNested > Base
EIGEN_STRONG_INLINE const Scalar & coeff(Index rowId, Index colId) const
Base::CoeffReturnType coeff(Index row, Index col) const
remove_all< _Rhs >::type Rhs
EIGEN_STRONG_INLINE void resize(Index nbRows, Index nbCols)
remove_all< _Lhs >::type Lhs
const _LhsNested & lhs() const
void scaleAndAddTo(Dest &dst, const Scalar &a_alpha) const
internal::remove_all< RhsNested >::type _RhsNested
void evalTo(Dest &dst) const
const unsigned int EvalBeforeAssigningBit
promote_storage_type< typename traits< Lhs >::StorageKind, typename traits< Rhs >::StorageKind >::ret StorageKind
internal::traits< Lhs >::Scalar LhsScalar
const unsigned int NestByRefBit
void subTo(Dest &dst) const
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
internal::traits< Rhs >::Scalar RhsScalar
traits< NestedProduct >::StorageKind StorageKind
Base::PlainObject PlainObject
void evalTo(Dest &dst) const
internal::remove_all< LhsNested >::type _LhsNested
const Scalar & alpha() const
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
ScaledProduct(const NestedProduct &prod, const Scalar &x)
Derived & lazyAssign(const ProductBase< ProductDerived, Lhs, Rhs > &other)
void scaleAndAddTo(Dest &dst, const Scalar &alpha) const
const unsigned int EvalBeforeNestingBit
The matrix class, also used for vectors and row-vectors.
const Diagonal< FullyLazyCoeffBaseProductType, Dynamic > diagonal(Index index) const
const Diagonal< const LazyCoeffBasedProductType, 0 > diagonal() const
const Scalar & coeffRef(Index row, Index col) const
const Diagonal< const FullyLazyCoeffBaseProductType, 0 > diagonal() const
Base class for all dense matrices, vectors, and expressions.