11 #ifndef EIGEN_GENERAL_PRODUCT_H
12 #define EIGEN_GENERAL_PRODUCT_H
26 #ifndef EIGEN_GEMM_TO_COEFFBASED_THRESHOLD
28 #define EIGEN_GEMM_TO_COEFFBASED_THRESHOLD 20
38 #ifndef EIGEN_GPU_COMPILE_PHASE
39 is_large = MaxSize ==
Dynamic ||
81 #ifdef EIGEN_DEBUG_PRODUCT
154 template<
int S
ide,
int StorageOrder,
bool BlasCompatible>
155 struct gemv_dense_selector;
163 template<
typename Scalar,
int Size,
int MaxSize>
169 template<
typename Scalar,
int Size>
175 template<
typename Scalar,
int Size,
int MaxSize>
182 #if EIGEN_MAX_STATIC_ALIGN_BYTES!=0
190 return ForceAlignment
198 template<
int StorageOrder,
bool BlasCompatible>
201 template<
typename Lhs,
typename Rhs,
typename Dest>
207 ::run(rhs.transpose(), lhs.transpose(), destT,
alpha);
213 template<
typename Lhs,
typename Rhs,
typename Dest>
222 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
224 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
228 ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
229 ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
239 EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime==1),
241 MightCannotUseDest = ((!EvalToDestAtCompileTime) || ComplexByReal) && (ActualDest::MaxSizeAtCompileTime!=0)
248 if(!MightCannotUseDest)
253 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
254 actualLhs.rows(), actualLhs.cols(),
255 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
256 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
265 const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
268 evalToDest ? dest.data() : static_dest.data());
272 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
274 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
276 if(!alphaIsCompatible)
278 MappedDest(actualDestPtr, dest.size()).setZero();
279 compatibleAlpha = RhsScalar(1);
282 MappedDest(actualDestPtr, dest.size()) = dest;
286 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
287 actualLhs.rows(), actualLhs.cols(),
288 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
289 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
295 if(!alphaIsCompatible)
296 dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
298 dest = MappedDest(actualDestPtr, dest.size());
306 template<
typename Lhs,
typename Rhs,
typename Dest>
314 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
316 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
327 DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1 || ActualRhsTypeCleaned::MaxSizeAtCompileTime==0
333 DirectlyUseRhs ?
const_cast<RhsScalar*
>(actualRhs.data()) : static_rhs.data());
337 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
339 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
347 <
Index,LhsScalar,LhsMapper,
RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
348 actualLhs.rows(), actualLhs.cols(),
349 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
350 RhsMapper(actualRhsPtr, 1),
351 dest.data(), dest.col(0).innerStride(),
358 template<
typename Lhs,
typename Rhs,
typename Dest>
366 dest += (
alpha*actual_rhs.coeff(k)) * lhs.col(k);
372 template<
typename Lhs,
typename Rhs,
typename Dest>
379 dest.coeffRef(
i) +=
alpha * (lhs.row(
i).cwiseProduct(actual_rhs.transpose())).sum();
395 template<
typename Derived>
396 template<
typename OtherDerived>
406 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic
407 || OtherDerived::RowsAtCompileTime==
Dynamic
408 ||
int(Derived::ColsAtCompileTime)==
int(OtherDerived::RowsAtCompileTime),
409 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
416 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
418 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
420 #ifdef EIGEN_DEBUG_PRODUCT
438 template<
typename Derived>
439 template<
typename OtherDerived>
445 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic
446 || OtherDerived::RowsAtCompileTime==
Dynamic
447 ||
int(Derived::ColsAtCompileTime)==
int(OtherDerived::RowsAtCompileTime),
448 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
455 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
457 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
465 #endif // EIGEN_PRODUCT_H