11 #ifndef EIGEN_GENERAL_PRODUCT_H    12 #define EIGEN_GENERAL_PRODUCT_H    27   enum { is_large = MaxSize == 
Dynamic ||
    30          value = is_large  ? 
Large    63     value = selector::ret,
    66 #ifdef EIGEN_DEBUG_PRODUCT   139 template<
int S
ide, 
int StorageOrder, 
bool BlasCompatible>
   148 template<
typename Scalar,
int Size,
int MaxSize>
   154 template<
typename Scalar,
int Size>
   160 template<
typename Scalar,
int Size,
int MaxSize>
   167   #if EIGEN_MAX_STATIC_ALIGN_BYTES!=0   175     return ForceAlignment
   183 template<
int StorageOrder, 
bool BlasCompatible>
   186   template<
typename Lhs, 
typename Rhs, 
typename Dest>
   187   static void run(
const Lhs &lhs, 
const Rhs &rhs, Dest& dest, 
const typename Dest::Scalar& alpha)
   192       ::run(rhs.transpose(), lhs.transpose(), destT, alpha);
   198   template<
typename Lhs, 
typename Rhs, 
typename Dest>
   199   static inline void run(
const Lhs &lhs, 
const Rhs &rhs, Dest& dest, 
const typename Dest::Scalar& alpha)
   201     typedef typename Lhs::Scalar   LhsScalar;
   202     typedef typename Rhs::Scalar   RhsScalar;
   203     typedef typename Dest::Scalar  ResScalar;
   204     typedef typename Dest::RealScalar  RealScalar;
   207     typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
   209     typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
   213     ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
   214     ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
   216     ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)
   217                                   * RhsBlasTraits::extractScalarFactor(rhs);
   225       EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime==1),
   227       MightCannotUseDest = (ActualDest::InnerStrideAtCompileTime!=1) || ComplexByReal
   232     const bool alphaIsCompatible = (!ComplexByReal) || (
numext::imag(actualAlpha)==RealScalar(0));
   233     const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
   238                                                   evalToDest ? dest.data() : static_dest.data());
   242       #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN   243       Index size = dest.size();
   244       EIGEN_DENSE_STORAGE_CTOR_PLUGIN
   246       if(!alphaIsCompatible)
   248         MappedDest(actualDestPtr, dest.size()).setZero();
   249         compatibleAlpha = RhsScalar(1);
   252         MappedDest(actualDestPtr, dest.size()) = dest;
   258         <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
   259         actualLhs.rows(), actualLhs.cols(),
   260         LhsMapper(actualLhs.data(), actualLhs.outerStride()),
   261         RhsMapper(actualRhs.data(), actualRhs.innerStride()),
   267       if(!alphaIsCompatible)
   268         dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
   270         dest = MappedDest(actualDestPtr, dest.size());
   277   template<
typename Lhs, 
typename Rhs, 
typename Dest>
   278   static void run(
const Lhs &lhs, 
const Rhs &rhs, Dest& dest, 
const typename Dest::Scalar& alpha)
   280     typedef typename Lhs::Scalar   LhsScalar;
   281     typedef typename Rhs::Scalar   RhsScalar;
   282     typedef typename Dest::Scalar  ResScalar;
   285     typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
   287     typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
   293     ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)
   294                                   * RhsBlasTraits::extractScalarFactor(rhs);
   299       DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1
   305         DirectlyUseRhs ? 
const_cast<RhsScalar*
>(actualRhs.
data()) : static_rhs.data());
   309       #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN   310       Index size = actualRhs.size();
   311       EIGEN_DENSE_STORAGE_CTOR_PLUGIN
   319         <
Index,LhsScalar,LhsMapper,
RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>::run(
   322         RhsMapper(actualRhsPtr, 1),
   323         dest.data(), dest.col(0).innerStride(), 
   330   template<
typename Lhs, 
typename Rhs, 
typename Dest>
   331   static void run(
const Lhs &lhs, 
const Rhs &rhs, Dest& dest, 
const typename Dest::Scalar& alpha)
   336     const Index size = rhs.rows();
   337     for(
Index k=0; k<size; ++k)
   338       dest += (alpha*actual_rhs.coeff(k)) * lhs.col(k);
   344   template<
typename Lhs, 
typename Rhs, 
typename Dest>
   345   static void run(
const Lhs &lhs, 
const Rhs &rhs, Dest& dest, 
const typename Dest::Scalar& alpha)
   349     const Index rows = dest.rows();
   350     for(
Index i=0; i<rows; ++i)
   351       dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
   369 template<
typename Derived>
   370 template<
typename OtherDerived>
   379     ProductIsValid =  Derived::ColsAtCompileTime==
Dynamic   380                    || OtherDerived::RowsAtCompileTime==
Dynamic   381                    || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
   382     AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
   389     INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
   391     INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
   393 #ifdef EIGEN_DEBUG_PRODUCT   413 template<
typename Derived>
   414 template<
typename OtherDerived>
   419     ProductIsValid =  Derived::ColsAtCompileTime==
Dynamic   420                    || OtherDerived::RowsAtCompileTime==
Dynamic   421                    || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
   422     AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
   429     INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
   431     INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
   439 #endif // EIGEN_PRODUCT_H EIGEN_DEVICE_FUNC Index rows() const
#define EIGEN_STRONG_INLINE
#define EIGEN_MAX_ALIGN_BYTES
Expression of the product of two arbitrary matrices or vectors. 
#define EIGEN_DEBUG_VAR(x)
#define EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
A matrix or vector expression mapping an existing array of data. 
Expression of the transpose of a matrix. 
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE To run(const From &x)
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
remove_all< Lhs >::type _Lhs
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvalue * data()
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_DEVICE_FUNC const Product< Derived, OtherDerived, LazyProduct > lazyProduct(const MatrixBase< OtherDerived > &other) const
#define EIGEN_SIZE_MIN_PREFER_FIXED(a, b)
internal::plain_array< Scalar, EIGEN_SIZE_MIN_PREFER_FIXED(Size, MaxSize)+(ForceAlignment?EIGEN_MAX_ALIGN_BYTES:0), 0 > m_data
const Product< Derived, OtherDerived > operator*(const MatrixBase< OtherDerived > &other) const
remove_all< Rhs >::type _Rhs
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API. 
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
EIGEN_DEVICE_FUNC Index outerStride() const
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
EIGEN_STRONG_INLINE Scalar * data()
EIGEN_DEVICE_FUNC Index cols() const
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
EIGEN_STRONG_INLINE Scalar * data()
#define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0, TYPE1)
#define EIGEN_PLAIN_ENUM_MIN(a, b)
EIGEN_DEVICE_FUNC const ImagReturnType imag() const
Expression of a diagonal/subdiagonal/superdiagonal in a matrix. 
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
#define eigen_internal_assert(x)
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
product_type_selector< rows_select, cols_select, depth_select > selector
Base class for all dense matrices, vectors, and expressions. 
EIGEN_STRONG_INLINE Scalar * data()
struct thread_data * data