11 #ifndef EIGEN_GENERAL_PRODUCT_H
12 #define EIGEN_GENERAL_PRODUCT_H
28 #ifndef EIGEN_CUDA_ARCH
29 is_large = MaxSize ==
Dynamic ||
35 value = is_large ?
Large
71 #ifdef EIGEN_DEBUG_PRODUCT
144 template<
int S
ide,
int StorageOrder,
bool BlasCompatible>
145 struct gemv_dense_selector;
153 template<
typename Scalar,
int Size,
int MaxSize>
159 template<
typename Scalar,
int Size>
165 template<
typename Scalar,
int Size,
int MaxSize>
172 #if EIGEN_MAX_STATIC_ALIGN_BYTES!=0
180 return ForceAlignment
188 template<
int StorageOrder,
bool BlasCompatible>
191 template<
typename Lhs,
typename Rhs,
typename Dest>
197 ::run(rhs.transpose(), lhs.transpose(), destT,
alpha);
203 template<
typename Lhs,
typename Rhs,
typename Dest>
212 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
214 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
218 ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
219 ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
221 ResScalar actualAlpha =
alpha * LhsBlasTraits::extractScalarFactor(lhs)
222 * RhsBlasTraits::extractScalarFactor(rhs);
230 EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime==1),
232 MightCannotUseDest = (!EvalToDestAtCompileTime) || ComplexByReal
239 if(!MightCannotUseDest)
244 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
245 actualLhs.rows(), actualLhs.cols(),
246 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
247 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
256 const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
259 evalToDest ? dest.data() : static_dest.data());
263 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
265 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
267 if(!alphaIsCompatible)
269 MappedDest(actualDestPtr, dest.size()).setZero();
270 compatibleAlpha = RhsScalar(1);
273 MappedDest(actualDestPtr, dest.size()) = dest;
277 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
278 actualLhs.rows(), actualLhs.cols(),
279 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
280 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
286 if(!alphaIsCompatible)
287 dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
289 dest = MappedDest(actualDestPtr, dest.size());
297 template<
typename Lhs,
typename Rhs,
typename Dest>
305 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
307 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
313 ResScalar actualAlpha =
alpha * LhsBlasTraits::extractScalarFactor(lhs)
314 * RhsBlasTraits::extractScalarFactor(rhs);
319 DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1
325 DirectlyUseRhs ?
const_cast<RhsScalar*
>(actualRhs.data()) : static_rhs.data());
329 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
331 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
339 <
Index,LhsScalar,LhsMapper,
RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
340 actualLhs.rows(), actualLhs.cols(),
341 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
342 RhsMapper(actualRhsPtr, 1),
343 dest.data(), dest.col(0).innerStride(),
350 template<
typename Lhs,
typename Rhs,
typename Dest>
358 dest += (
alpha*actual_rhs.coeff(k)) * lhs.col(k);
364 template<
typename Lhs,
typename Rhs,
typename Dest>
369 const Index rows = dest.rows();
370 for(
Index i=0; i<rows; ++i)
371 dest.coeffRef(i) +=
alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
387 template<
typename Derived>
388 template<
typename OtherDerived>
389 inline const Product<Derived, OtherDerived>
397 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic
398 || OtherDerived::RowsAtCompileTime==
Dynamic
399 ||
int(Derived::ColsAtCompileTime)==
int(OtherDerived::RowsAtCompileTime),
400 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
407 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
409 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
411 #ifdef EIGEN_DEBUG_PRODUCT
429 template<
typename Derived>
430 template<
typename OtherDerived>
435 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic
436 || OtherDerived::RowsAtCompileTime==
Dynamic
437 ||
int(Derived::ColsAtCompileTime)==
int(OtherDerived::RowsAtCompileTime),
438 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
445 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
447 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
455 #endif // EIGEN_PRODUCT_H