11 #ifndef EIGEN_GENERAL_PRODUCT_H 12 #define EIGEN_GENERAL_PRODUCT_H 27 enum { is_large = MaxSize ==
Dynamic ||
28 Size >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ||
29 (Size==
Dynamic && MaxSize>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD),
30 value = is_large ? Large
63 value = selector::ret,
66 #ifdef EIGEN_DEBUG_PRODUCT 69 EIGEN_DEBUG_VAR(Rows);
70 EIGEN_DEBUG_VAR(Cols);
71 EIGEN_DEBUG_VAR(Depth);
72 EIGEN_DEBUG_VAR(rows_select);
73 EIGEN_DEBUG_VAR(cols_select);
74 EIGEN_DEBUG_VAR(depth_select);
75 EIGEN_DEBUG_VAR(value);
139 template<
int S
ide,
int StorageOrder,
bool BlasCompatible>
148 template<
typename Scalar,
int Size,
int MaxSize>
151 EIGEN_STRONG_INLINE Scalar* data() { eigen_internal_assert(
false &&
"should never be called");
return 0; }
154 template<
typename Scalar,
int Size>
157 EIGEN_STRONG_INLINE Scalar* data() {
return 0; }
160 template<
typename Scalar,
int Size,
int MaxSize>
167 #if EIGEN_MAX_STATIC_ALIGN_BYTES!=0 169 EIGEN_STRONG_INLINE Scalar* data() {
return m_data.array; }
174 EIGEN_STRONG_INLINE Scalar* data() {
175 return ForceAlignment
176 ?
reinterpret_cast<Scalar*
>((internal::UIntPtr(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES-1))) + EIGEN_MAX_ALIGN_BYTES)
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;
237 ei_declare_aligned_stack_constructed_variable(ResScalar,actualDestPtr,dest.size(),
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
304 ei_declare_aligned_stack_constructed_variable(RhsScalar,actualRhsPtr,actualRhs.size(),
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(
320 actualLhs.rows(), actualLhs.cols(),
321 LhsMapper(actualLhs.data(), actualLhs.outerStride()),
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,
383 SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived)
388 EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
389 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
390 EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
391 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
392 EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
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,
423 SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived,OtherDerived)
428 EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
429 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
430 EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
431 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
432 EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
439 #endif // EIGEN_PRODUCT_H Definition: BlasUtil.h:269
Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:320
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
Apply transformation on the right.
Definition: Constants.h:335
Definition: GeneralProduct.h:25
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:88
Expression of the transpose of a matrix.
Definition: Transpose.h:52
Definition: BlasUtil.h:126
Definition: GeneralProduct.h:23
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
Holds information about the various numeric (i.e.
Definition: NumTraits.h:150
Definition: XprHelper.h:437
Definition: GenericPacketMath.h:96
Definition: GeneralProduct.h:36
const Product< Derived, OtherDerived > operator*(const MatrixBase< OtherDerived > &other) const
Definition: GeneralProduct.h:372
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Apply transformation on the left.
Definition: Constants.h:333
Definition: BlasUtil.h:256
Definition: GeneralProduct.h:146
Definition: BlasUtil.h:40
Definition: BandTriangularSolver.h:13
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:322
Definition: GeneralProduct.h:140
Definition: DenseStorage.h:44
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time, and that instead the value is stored in some runtime variable.
Definition: Constants.h:21
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17