Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef EIGEN_PRODUCT_H
00026 #define EIGEN_PRODUCT_H
00027
00028 template<typename Lhs, typename Rhs> class Product;
00029 template<typename Lhs, typename Rhs, typename StorageKind> class ProductImpl;
00030
00043 namespace internal {
00044 template<typename Lhs, typename Rhs>
00045 struct traits<Product<Lhs, Rhs> >
00046 {
00047 typedef MatrixXpr XprKind;
00048 typedef typename remove_all<Lhs>::type LhsCleaned;
00049 typedef typename remove_all<Rhs>::type RhsCleaned;
00050 typedef typename scalar_product_traits<typename traits<LhsCleaned>::Scalar, typename traits<RhsCleaned>::Scalar>::ReturnType Scalar;
00051 typedef typename promote_storage_type<typename traits<LhsCleaned>::StorageKind,
00052 typename traits<RhsCleaned>::StorageKind>::ret StorageKind;
00053 typedef typename promote_index_type<typename traits<LhsCleaned>::Index,
00054 typename traits<RhsCleaned>::Index>::type Index;
00055 enum {
00056 RowsAtCompileTime = LhsCleaned::RowsAtCompileTime,
00057 ColsAtCompileTime = RhsCleaned::ColsAtCompileTime,
00058 MaxRowsAtCompileTime = LhsCleaned::MaxRowsAtCompileTime,
00059 MaxColsAtCompileTime = RhsCleaned::MaxColsAtCompileTime,
00060 Flags = (MaxRowsAtCompileTime==1 ? RowMajorBit : 0),
00061 CoeffReadCost = 0
00062 };
00063 };
00064 }
00065
00066
00067 template<typename Lhs, typename Rhs>
00068 class Product : public ProductImpl<Lhs,Rhs,typename internal::promote_storage_type<typename internal::traits<Lhs>::StorageKind,
00069 typename internal::traits<Rhs>::StorageKind>::ret>
00070 {
00071 public:
00072
00073 typedef typename ProductImpl<
00074 Lhs, Rhs,
00075 typename internal::promote_storage_type<typename Lhs::StorageKind,
00076 typename Rhs::StorageKind>::ret>::Base Base;
00077 EIGEN_GENERIC_PUBLIC_INTERFACE(Product)
00078
00079 typedef typename Lhs::Nested LhsNested;
00080 typedef typename Rhs::Nested RhsNested;
00081 typedef typename internal::remove_all<LhsNested>::type LhsNestedCleaned;
00082 typedef typename internal::remove_all<RhsNested>::type RhsNestedCleaned;
00083
00084 Product(const Lhs& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs)
00085 {
00086 eigen_assert(lhs.cols() == rhs.rows()
00087 && "invalid matrix product"
00088 && "if you wanted a coeff-wise or a dot product use the respective explicit functions");
00089 }
00090
00091 inline Index rows() const { return m_lhs.rows(); }
00092 inline Index cols() const { return m_rhs.cols(); }
00093
00094 const LhsNestedCleaned& lhs() const { return m_lhs; }
00095 const RhsNestedCleaned& rhs() const { return m_rhs; }
00096
00097 protected:
00098
00099 const LhsNested m_lhs;
00100 const RhsNested m_rhs;
00101 };
00102
00103 template<typename Lhs, typename Rhs>
00104 class ProductImpl<Lhs,Rhs,Dense> : public internal::dense_xpr_base<Product<Lhs,Rhs> >::type
00105 {
00106 typedef Product<Lhs, Rhs> Derived;
00107 public:
00108
00109 typedef typename internal::dense_xpr_base<Product<Lhs, Rhs> >::type Base;
00110 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
00111 };
00112
00113 #endif // EIGEN_PRODUCT_H