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 = (!EvalToDestAtCompileTime) || ComplexByReal
234 if(!MightCannotUseDest)
239 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
240 actualLhs.rows(), actualLhs.cols(),
241 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
242 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
250 const bool alphaIsCompatible = (!ComplexByReal) || (
numext::imag(actualAlpha)==RealScalar(0));
251 const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
254 evalToDest ? dest.data() : static_dest.data());
258 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 260 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
262 if(!alphaIsCompatible)
264 MappedDest(actualDestPtr, dest.size()).
setZero();
265 compatibleAlpha = RhsScalar(1);
268 MappedDest(actualDestPtr, dest.size()) = dest;
272 <
Index,LhsScalar,LhsMapper,
ColMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
273 actualLhs.rows(), actualLhs.cols(),
274 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
275 RhsMapper(actualRhs.data(), actualRhs.innerStride()),
281 if(!alphaIsCompatible)
282 dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
284 dest = MappedDest(actualDestPtr, dest.size());
292 template<
typename Lhs,
typename Rhs,
typename Dest>
293 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
295 typedef typename Lhs::Scalar LhsScalar;
296 typedef typename Rhs::Scalar RhsScalar;
297 typedef typename Dest::Scalar ResScalar;
300 typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
302 typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
308 ResScalar actualAlpha = alpha * LhsBlasTraits::extractScalarFactor(lhs)
309 * RhsBlasTraits::extractScalarFactor(rhs);
314 DirectlyUseRhs = ActualRhsTypeCleaned::InnerStrideAtCompileTime==1
320 DirectlyUseRhs ?
const_cast<RhsScalar*
>(actualRhs.
data()) : static_rhs.data());
324 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN 326 EIGEN_DENSE_STORAGE_CTOR_PLUGIN
334 <
Index,LhsScalar,LhsMapper,
RowMajor,LhsBlasTraits::NeedToConjugate,RhsScalar,RhsMapper,RhsBlasTraits::NeedToConjugate>
::run(
337 RhsMapper(actualRhsPtr, 1),
338 dest.data(), dest.col(0).innerStride(),
345 template<
typename Lhs,
typename Rhs,
typename Dest>
346 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
353 dest += (alpha*actual_rhs.coeff(k)) * lhs.col(k);
359 template<
typename Lhs,
typename Rhs,
typename Dest>
360 static void run(
const Lhs &lhs,
const Rhs &rhs, Dest& dest,
const typename Dest::Scalar& alpha)
364 const Index rows = dest.rows();
365 for(
Index i=0; i<rows; ++i)
366 dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
384 template<
typename Derived>
385 template<
typename OtherDerived>
394 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic 395 || OtherDerived::RowsAtCompileTime==
Dynamic 396 || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
397 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
404 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
406 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
408 #ifdef EIGEN_DEBUG_PRODUCT 428 template<
typename Derived>
429 template<
typename OtherDerived>
434 ProductIsValid = Derived::ColsAtCompileTime==
Dynamic 435 || OtherDerived::RowsAtCompileTime==
Dynamic 436 || int(Derived::ColsAtCompileTime)==int(OtherDerived::RowsAtCompileTime),
437 AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
444 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
446 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
454 #endif // EIGEN_PRODUCT_H #define EIGEN_STRONG_INLINE
#define EIGEN_MAX_ALIGN_BYTES
Expression of the product of two arbitrary matrices or vectors.
EIGEN_DEVICE_FUNC Index cols() const
#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
static constexpr size_t size(Tuple< Args... > &)
Provides access to the number of elements in a tuple as a compile-time constant expression.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
EIGEN_DEVICE_FUNC ScalarWithConstIfNotLvalue * data()
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
#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
EIGEN_DEVICE_FUNC Index outerStride() 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 const Product< Derived, OtherDerived, LazyProduct > lazyProduct(const MatrixBase< OtherDerived > &other) const
#define ei_declare_aligned_stack_constructed_variable(TYPE, NAME, SIZE, BUFFER)
EIGEN_STRONG_INLINE Scalar * data()
EIGEN_DEVICE_FUNC Index rows() 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)
const Product< Derived, OtherDerived > operator*(const MatrixBase< OtherDerived > &other) const
static void run(const Lhs &lhs, const Rhs &rhs, Dest &dest, const typename Dest::Scalar &alpha)
void run(Expr &expr, Dev &dev)
product_type_selector< rows_select, cols_select, depth_select > selector
Base class for all dense matrices, vectors, and expressions.
EIGEN_STRONG_INLINE Scalar * data()