10 #ifndef EIGEN_PRODUCT_H 11 #define EIGEN_PRODUCT_H 15 template<
typename Lhs,
typename Rhs,
int Option,
typename StorageKind>
class ProductImpl;
19 template<
typename Lhs,
typename Rhs,
int Option>
20 struct traits<Product<Lhs, Rhs, Option> >
22 typedef typename remove_all<Lhs>::type LhsCleaned;
23 typedef typename remove_all<Rhs>::type RhsCleaned;
24 typedef traits<LhsCleaned> LhsTraits;
25 typedef traits<RhsCleaned> RhsTraits;
27 typedef MatrixXpr XprKind;
29 typedef typename ScalarBinaryOpTraits<typename traits<LhsCleaned>::Scalar,
typename traits<RhsCleaned>::Scalar>::ReturnType Scalar;
30 typedef typename product_promote_storage_type<
typename LhsTraits::StorageKind,
31 typename RhsTraits::StorageKind,
32 internal::product_type<Lhs,Rhs>::ret>::ret StorageKind;
33 typedef typename promote_index_type<
typename LhsTraits::StorageIndex,
34 typename RhsTraits::StorageIndex>::type StorageIndex;
37 RowsAtCompileTime = LhsTraits::RowsAtCompileTime,
38 ColsAtCompileTime = RhsTraits::ColsAtCompileTime,
39 MaxRowsAtCompileTime = LhsTraits::MaxRowsAtCompileTime,
40 MaxColsAtCompileTime = RhsTraits::MaxColsAtCompileTime,
43 InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(LhsTraits::ColsAtCompileTime, RhsTraits::RowsAtCompileTime),
46 Flags = (MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1) ?
RowMajorBit 47 : (MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1) ? 0
50 : NoPreferredStorageOrderBit
70 template<
typename _Lhs,
typename _Rhs,
int Option>
71 class Product :
public ProductImpl<_Lhs,_Rhs,Option,
72 typename internal::product_promote_storage_type<typename internal::traits<_Lhs>::StorageKind,
73 typename internal::traits<_Rhs>::StorageKind,
74 internal::product_type<_Lhs,_Rhs>::ret>::ret>
81 typedef typename ProductImpl<
83 typename internal::product_promote_storage_type<typename internal::traits<Lhs>::StorageKind,
84 typename internal::traits<Rhs>::StorageKind,
85 internal::product_type<Lhs,Rhs>::ret>::ret>::Base Base;
86 EIGEN_GENERIC_PUBLIC_INTERFACE(
Product)
88 typedef typename internal::ref_selector<Lhs>::type LhsNested;
89 typedef typename internal::ref_selector<Rhs>::type RhsNested;
90 typedef typename internal::remove_all<LhsNested>::type LhsNestedCleaned;
91 typedef typename internal::remove_all<RhsNested>::type RhsNestedCleaned;
93 EIGEN_DEVICE_FUNC
Product(
const Lhs& lhs,
const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs)
95 eigen_assert(lhs.cols() == rhs.rows()
96 &&
"invalid matrix product" 97 &&
"if you wanted a coeff-wise or a dot product use the respective explicit functions");
100 EIGEN_DEVICE_FUNC
inline Index rows()
const {
return m_lhs.rows(); }
101 EIGEN_DEVICE_FUNC
inline Index cols()
const {
return m_rhs.cols(); }
103 EIGEN_DEVICE_FUNC
const LhsNestedCleaned& lhs()
const {
return m_lhs; }
104 EIGEN_DEVICE_FUNC
const RhsNestedCleaned& rhs()
const {
return m_rhs; }
114 template<typename Lhs, typename Rhs, int Option, int ProductTag = internal::product_type<Lhs,Rhs>::ret>
115 class dense_product_base
116 :
public internal::dense_xpr_base<Product<Lhs,Rhs,Option> >::type
120 template<
typename Lhs,
typename Rhs,
int Option>
121 class dense_product_base<Lhs, Rhs, Option, InnerProduct>
122 :
public internal::dense_xpr_base<Product<Lhs,Rhs,Option> >::type
125 typedef typename internal::dense_xpr_base<ProductXpr>::type Base;
128 typedef typename Base::Scalar Scalar;
130 operator const Scalar()
const 132 return internal::evaluator<ProductXpr>(derived()).coeff(0,0);
139 template<
typename Lhs,
typename Rhs,
int Option,
typename StorageKind>
140 class ProductImpl :
public internal::generic_xpr_base<Product<Lhs,Rhs,Option>, MatrixXpr, StorageKind>::type
143 typedef typename internal::generic_xpr_base<Product<Lhs,Rhs,Option>,
MatrixXpr, StorageKind>::type Base;
146 template<
typename Lhs,
typename Rhs,
int Option>
147 class ProductImpl<Lhs,Rhs,Option,Dense>
148 :
public internal::dense_product_base<Lhs,Rhs,Option>
154 typedef typename internal::dense_product_base<Lhs, Rhs, Option> Base;
155 EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
158 IsOneByOne = (RowsAtCompileTime == 1 || RowsAtCompileTime ==
Dynamic) &&
159 (ColsAtCompileTime == 1 || ColsAtCompileTime ==
Dynamic),
160 EnableCoeff = IsOneByOne || Option==LazyProduct
165 EIGEN_DEVICE_FUNC Scalar coeff(
Index row,
Index col)
const 167 EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);
168 eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );
170 return internal::evaluator<Derived>(derived()).coeff(row,col);
173 EIGEN_DEVICE_FUNC Scalar coeff(
Index i)
const 175 EIGEN_STATIC_ASSERT(EnableCoeff, THIS_METHOD_IS_ONLY_FOR_INNER_OR_LAZY_PRODUCTS);
176 eigen_assert( (Option==LazyProduct) || (this->rows() == 1 && this->cols() == 1) );
178 return internal::evaluator<Derived>(derived()).coeff(i);
186 #endif // EIGEN_PRODUCT_H Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
Namespace containing all symbols from the Eigen library.
Definition: Core:287
const unsigned int RowMajorBit
Definition: Constants.h:61
Definition: Constants.h:506
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: Eigen_Colamd.h:50
const int Dynamic
Definition: Constants.h:21
const unsigned int NoPreferredStorageOrderBit
Definition: Constants.h:173