$darkmode
Eigen  5.0.1-dev
GeneralProduct.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2008-2011 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_GENERAL_PRODUCT_H
12 #define EIGEN_GENERAL_PRODUCT_H
13 
14 // IWYU pragma: private
15 #include "./InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
19 enum { Large = 2, Small = 3 };
20 
21 // Define the threshold value to fallback from the generic matrix-matrix product
22 // implementation (heavy) to the lightweight coeff-based product one.
23 // See generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct>
24 // in products/GeneralMatrixMatrix.h for more details.
25 // TODO This threshold should also be used in the compile-time selector below.
26 #ifndef EIGEN_GEMM_TO_COEFFBASED_THRESHOLD
27 // This default value has been obtained on a Haswell architecture.
28 #define EIGEN_GEMM_TO_COEFFBASED_THRESHOLD 20
29 #endif
30 
31 namespace internal {
32 
33 template <int Rows, int Cols, int Depth>
34 struct product_type_selector;
35 
36 template <int Size, int MaxSize>
37 struct product_size_category {
38  enum {
39 #ifndef EIGEN_GPU_COMPILE_PHASE
40  is_large = MaxSize == Dynamic || Size >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD ||
41  (Size == Dynamic && MaxSize >= EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD),
42 #else
43  is_large = 0,
44 #endif
45  value = is_large ? Large
46  : Size == 1 ? 1
47  : Small
48  };
49 };
50 
51 template <typename Lhs, typename Rhs>
52 struct product_type {
53  typedef remove_all_t<Lhs> Lhs_;
54  typedef remove_all_t<Rhs> Rhs_;
55  enum {
56  MaxRows = traits<Lhs_>::MaxRowsAtCompileTime,
57  Rows = traits<Lhs_>::RowsAtCompileTime,
58  MaxCols = traits<Rhs_>::MaxColsAtCompileTime,
59  Cols = traits<Rhs_>::ColsAtCompileTime,
60  MaxDepth = min_size_prefer_fixed(traits<Lhs_>::MaxColsAtCompileTime, traits<Rhs_>::MaxRowsAtCompileTime),
61  Depth = min_size_prefer_fixed(traits<Lhs_>::ColsAtCompileTime, traits<Rhs_>::RowsAtCompileTime)
62  };
63 
64  // the splitting into different lines of code here, introducing the _select enums and the typedef below,
65  // is to work around an internal compiler error with gcc 4.1 and 4.2.
66  private:
67  enum {
68  rows_select = product_size_category<Rows, MaxRows>::value,
69  cols_select = product_size_category<Cols, MaxCols>::value,
70  depth_select = product_size_category<Depth, MaxDepth>::value
71  };
72  typedef product_type_selector<rows_select, cols_select, depth_select> selector;
73 
74  public:
75  enum { value = selector::ret, ret = selector::ret };
76 #ifdef EIGEN_DEBUG_PRODUCT
77  static void debug() {
78  EIGEN_DEBUG_VAR(Rows);
79  EIGEN_DEBUG_VAR(Cols);
80  EIGEN_DEBUG_VAR(Depth);
81  EIGEN_DEBUG_VAR(rows_select);
82  EIGEN_DEBUG_VAR(cols_select);
83  EIGEN_DEBUG_VAR(depth_select);
84  EIGEN_DEBUG_VAR(value);
85  }
86 #endif
87 };
88 
89 /* The following allows to select the kind of product at compile time
90  * based on the three dimensions of the product.
91  * This is a compile time mapping from {1,Small,Large}^3 -> {product types} */
92 // FIXME I'm not sure the current mapping is the ideal one.
93 template <int M, int N>
94 struct product_type_selector<M, N, 1> {
95  enum { ret = OuterProduct };
96 };
97 template <int M>
98 struct product_type_selector<M, 1, 1> {
99  enum { ret = LazyCoeffBasedProductMode };
100 };
101 template <int N>
102 struct product_type_selector<1, N, 1> {
103  enum { ret = LazyCoeffBasedProductMode };
104 };
105 template <int Depth>
106 struct product_type_selector<1, 1, Depth> {
107  enum { ret = InnerProduct };
108 };
109 template <>
110 struct product_type_selector<1, 1, 1> {
111  enum { ret = InnerProduct };
112 };
113 template <>
114 struct product_type_selector<Small, 1, Small> {
115  enum { ret = CoeffBasedProductMode };
116 };
117 template <>
118 struct product_type_selector<1, Small, Small> {
119  enum { ret = CoeffBasedProductMode };
120 };
121 template <>
122 struct product_type_selector<Small, Small, Small> {
123  enum { ret = CoeffBasedProductMode };
124 };
125 template <>
126 struct product_type_selector<Small, Small, 1> {
127  enum { ret = LazyCoeffBasedProductMode };
128 };
129 template <>
130 struct product_type_selector<Small, Large, 1> {
131  enum { ret = LazyCoeffBasedProductMode };
132 };
133 template <>
134 struct product_type_selector<Large, Small, 1> {
135  enum { ret = LazyCoeffBasedProductMode };
136 };
137 template <>
138 struct product_type_selector<1, Large, Small> {
139  enum { ret = CoeffBasedProductMode };
140 };
141 template <>
142 struct product_type_selector<1, Large, Large> {
143  enum { ret = GemvProduct };
144 };
145 template <>
146 struct product_type_selector<1, Small, Large> {
147  enum { ret = CoeffBasedProductMode };
148 };
149 template <>
150 struct product_type_selector<Large, 1, Small> {
151  enum { ret = CoeffBasedProductMode };
152 };
153 template <>
154 struct product_type_selector<Large, 1, Large> {
155  enum { ret = GemvProduct };
156 };
157 template <>
158 struct product_type_selector<Small, 1, Large> {
159  enum { ret = CoeffBasedProductMode };
160 };
161 template <>
162 struct product_type_selector<Small, Small, Large> {
163  enum { ret = GemmProduct };
164 };
165 template <>
166 struct product_type_selector<Large, Small, Large> {
167  enum { ret = GemmProduct };
168 };
169 template <>
170 struct product_type_selector<Small, Large, Large> {
171  enum { ret = GemmProduct };
172 };
173 template <>
174 struct product_type_selector<Large, Large, Large> {
175  enum { ret = GemmProduct };
176 };
177 template <>
178 struct product_type_selector<Large, Small, Small> {
179  enum { ret = CoeffBasedProductMode };
180 };
181 template <>
182 struct product_type_selector<Small, Large, Small> {
183  enum { ret = CoeffBasedProductMode };
184 };
185 template <>
186 struct product_type_selector<Large, Large, Small> {
187  enum { ret = GemmProduct };
188 };
189 
190 } // end namespace internal
191 
192 /***********************************************************************
193  * Implementation of Inner Vector Vector Product
194  ***********************************************************************/
195 
196 // FIXME : maybe the "inner product" could return a Scalar
197 // instead of a 1x1 matrix ??
198 // Pro: more natural for the user
199 // Cons: this could be a problem if in a meta unrolled algorithm a matrix-matrix
200 // product ends up to a row-vector times col-vector product... To tackle this use
201 // case, we could have a specialization for Block<MatrixType,1,1> with: operator=(Scalar x);
202 
203 /***********************************************************************
204  * Implementation of Outer Vector Vector Product
205  ***********************************************************************/
206 
207 /***********************************************************************
208  * Implementation of General Matrix Vector Product
209  ***********************************************************************/
210 
211 /* According to the shape/flags of the matrix we have to distinghish 3 different cases:
212  * 1 - the matrix is col-major, BLAS compatible and M is large => call fast BLAS-like colmajor routine
213  * 2 - the matrix is row-major, BLAS compatible and N is large => call fast BLAS-like rowmajor routine
214  * 3 - all other cases are handled using a simple loop along the outer-storage direction.
215  * Therefore we need a lower level meta selector.
216  * Furthermore, if the matrix is the rhs, then the product has to be transposed.
217  */
218 namespace internal {
219 
220 template <int Side, int StorageOrder, bool BlasCompatible>
221 struct gemv_dense_selector;
222 
223 } // end namespace internal
224 
225 namespace internal {
226 
227 template <typename Scalar, int Size, int MaxSize, bool Cond>
228 struct gemv_static_vector_if;
229 
230 template <typename Scalar, int Size, int MaxSize>
231 struct gemv_static_vector_if<Scalar, Size, MaxSize, false> {
232  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr Scalar* data() {
233  eigen_internal_assert(false && "should never be called");
234  return 0;
235  }
236 };
237 
238 template <typename Scalar, int Size>
239 struct gemv_static_vector_if<Scalar, Size, Dynamic, true> {
240  EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC constexpr Scalar* data() { return 0; }
241 };
242 
243 template <typename Scalar, int Size, int MaxSize>
244 struct gemv_static_vector_if<Scalar, Size, MaxSize, true> {
245 #if EIGEN_MAX_STATIC_ALIGN_BYTES != 0
246  internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize), 0, AlignedMax> m_data;
247  EIGEN_STRONG_INLINE constexpr Scalar* data() { return m_data.array; }
248 #else
249  // Some architectures cannot align on the stack,
250  // => let's manually enforce alignment by allocating more data and return the address of the first aligned element.
251  internal::plain_array<Scalar, internal::min_size_prefer_fixed(Size, MaxSize) + EIGEN_MAX_ALIGN_BYTES, 0> m_data;
252  EIGEN_STRONG_INLINE constexpr Scalar* data() {
253  return reinterpret_cast<Scalar*>((std::uintptr_t(m_data.array) & ~(std::size_t(EIGEN_MAX_ALIGN_BYTES - 1))) +
254  EIGEN_MAX_ALIGN_BYTES);
255  }
256 #endif
257 };
258 
259 // The vector is on the left => transposition
260 template <int StorageOrder, bool BlasCompatible>
261 struct gemv_dense_selector<OnTheLeft, StorageOrder, BlasCompatible> {
262  template <typename Lhs, typename Rhs, typename Dest>
263  static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
264  Transpose<Dest> destT(dest);
265  enum { OtherStorageOrder = StorageOrder == RowMajor ? ColMajor : RowMajor };
266  gemv_dense_selector<OnTheRight, OtherStorageOrder, BlasCompatible>::run(rhs.transpose(), lhs.transpose(), destT,
267  alpha);
268  }
269 };
270 
271 template <>
272 struct gemv_dense_selector<OnTheRight, ColMajor, true> {
273  template <typename Lhs, typename Rhs, typename Dest>
274  static inline void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
275  typedef typename Lhs::Scalar LhsScalar;
276  typedef typename Rhs::Scalar RhsScalar;
277  typedef typename Dest::Scalar ResScalar;
278 
279  typedef internal::blas_traits<Lhs> LhsBlasTraits;
280  typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
281  typedef internal::blas_traits<Rhs> RhsBlasTraits;
282  typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
283 
284  typedef Map<Matrix<ResScalar, Dynamic, 1>, plain_enum_min(AlignedMax, internal::packet_traits<ResScalar>::size)>
285  MappedDest;
286 
287  ActualLhsType actualLhs = LhsBlasTraits::extract(lhs);
288  ActualRhsType actualRhs = RhsBlasTraits::extract(rhs);
289 
290  ResScalar actualAlpha = combine_scalar_factors(alpha, lhs, rhs);
291 
292  // make sure Dest is a compile-time vector type (bug 1166)
293  typedef std::conditional_t<Dest::IsVectorAtCompileTime, Dest, typename Dest::ColXpr> ActualDest;
294 
295  enum {
296  // FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1
297  // on, the other hand it is good for the cache to pack the vector anyways...
298  EvalToDestAtCompileTime = (ActualDest::InnerStrideAtCompileTime == 1),
299  ComplexByReal = (NumTraits<LhsScalar>::IsComplex) && (!NumTraits<RhsScalar>::IsComplex),
300  MightCannotUseDest = ((!EvalToDestAtCompileTime) || ComplexByReal) && (ActualDest::MaxSizeAtCompileTime != 0)
301  };
302 
303  typedef const_blas_data_mapper<LhsScalar, Index, ColMajor> LhsMapper;
304  typedef const_blas_data_mapper<RhsScalar, Index, RowMajor> RhsMapper;
305  RhsScalar compatibleAlpha = get_factor<ResScalar, RhsScalar>::run(actualAlpha);
306 
307  if (!MightCannotUseDest) {
308  // shortcut if we are sure to be able to use dest directly,
309  // this ease the compiler to generate cleaner and more optimzized code for most common cases
310  general_matrix_vector_product<Index, LhsScalar, LhsMapper, ColMajor, LhsBlasTraits::NeedToConjugate, RhsScalar,
311  RhsMapper, RhsBlasTraits::NeedToConjugate>::run(actualLhs.rows(), actualLhs.cols(),
312  LhsMapper(actualLhs.data(),
313  actualLhs.outerStride()),
314  RhsMapper(actualRhs.data(),
315  actualRhs.innerStride()),
316  dest.data(), 1, compatibleAlpha);
317  } else {
318  gemv_static_vector_if<ResScalar, ActualDest::SizeAtCompileTime, ActualDest::MaxSizeAtCompileTime,
319  MightCannotUseDest>
320  static_dest;
321 
322  const bool alphaIsCompatible = (!ComplexByReal) || (numext::is_exactly_zero(numext::imag(actualAlpha)));
323  const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible;
324 
325  ei_declare_aligned_stack_constructed_variable(ResScalar, actualDestPtr, dest.size(),
326  evalToDest ? dest.data() : static_dest.data());
327 
328  if (!evalToDest) {
329 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
330  constexpr int Size = Dest::SizeAtCompileTime;
331  Index size = dest.size();
332  EIGEN_DENSE_STORAGE_CTOR_PLUGIN
333 #endif
334  if (!alphaIsCompatible) {
335  MappedDest(actualDestPtr, dest.size()).setZero();
336  compatibleAlpha = RhsScalar(1);
337  } else
338  MappedDest(actualDestPtr, dest.size()) = dest;
339  }
340 
341  general_matrix_vector_product<Index, LhsScalar, LhsMapper, ColMajor, LhsBlasTraits::NeedToConjugate, RhsScalar,
342  RhsMapper, RhsBlasTraits::NeedToConjugate>::run(actualLhs.rows(), actualLhs.cols(),
343  LhsMapper(actualLhs.data(),
344  actualLhs.outerStride()),
345  RhsMapper(actualRhs.data(),
346  actualRhs.innerStride()),
347  actualDestPtr, 1, compatibleAlpha);
348 
349  if (!evalToDest) {
350  if (!alphaIsCompatible)
351  dest.matrix() += actualAlpha * MappedDest(actualDestPtr, dest.size());
352  else
353  dest = MappedDest(actualDestPtr, dest.size());
354  }
355  }
356  }
357 };
358 
359 template <>
360 struct gemv_dense_selector<OnTheRight, RowMajor, true> {
361  template <typename Lhs, typename Rhs, typename Dest>
362  static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
363  typedef typename Lhs::Scalar LhsScalar;
364  typedef typename Rhs::Scalar RhsScalar;
365  typedef typename Dest::Scalar ResScalar;
366 
367  typedef internal::blas_traits<Lhs> LhsBlasTraits;
368  typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType;
369  typedef internal::blas_traits<Rhs> RhsBlasTraits;
370  typedef typename RhsBlasTraits::DirectLinearAccessType ActualRhsType;
371  typedef internal::remove_all_t<ActualRhsType> ActualRhsTypeCleaned;
372 
373  std::add_const_t<ActualLhsType> actualLhs = LhsBlasTraits::extract(lhs);
374  std::add_const_t<ActualRhsType> actualRhs = RhsBlasTraits::extract(rhs);
375 
376  ResScalar actualAlpha = combine_scalar_factors(alpha, lhs, rhs);
377 
378  enum {
379  // FIXME find a way to allow an inner stride on the result if packet_traits<Scalar>::size==1
380  // on, the other hand it is good for the cache to pack the vector anyways...
381  DirectlyUseRhs =
382  ActualRhsTypeCleaned::InnerStrideAtCompileTime == 1 || ActualRhsTypeCleaned::MaxSizeAtCompileTime == 0
383  };
384 
385  gemv_static_vector_if<RhsScalar, ActualRhsTypeCleaned::SizeAtCompileTime,
386  ActualRhsTypeCleaned::MaxSizeAtCompileTime, !DirectlyUseRhs>
387  static_rhs;
388 
389  ei_declare_aligned_stack_constructed_variable(
390  RhsScalar, actualRhsPtr, actualRhs.size(),
391  DirectlyUseRhs ? const_cast<RhsScalar*>(actualRhs.data()) : static_rhs.data());
392 
393  if (!DirectlyUseRhs) {
394 #ifdef EIGEN_DENSE_STORAGE_CTOR_PLUGIN
395  constexpr int Size = ActualRhsTypeCleaned::SizeAtCompileTime;
396  Index size = actualRhs.size();
397  EIGEN_DENSE_STORAGE_CTOR_PLUGIN
398 #endif
399  Map<typename ActualRhsTypeCleaned::PlainObject>(actualRhsPtr, actualRhs.size()) = actualRhs;
400  }
401 
402  typedef const_blas_data_mapper<LhsScalar, Index, RowMajor> LhsMapper;
403  typedef const_blas_data_mapper<RhsScalar, Index, ColMajor> RhsMapper;
404  general_matrix_vector_product<Index, LhsScalar, LhsMapper, RowMajor, LhsBlasTraits::NeedToConjugate, RhsScalar,
405  RhsMapper, RhsBlasTraits::NeedToConjugate>::
406  run(actualLhs.rows(), actualLhs.cols(), LhsMapper(actualLhs.data(), actualLhs.outerStride()),
407  RhsMapper(actualRhsPtr, 1), dest.data(),
408  dest.col(0).innerStride(), // NOTE if dest is not a vector at compile-time, then dest.innerStride() might
409  // be wrong. (bug 1166)
410  actualAlpha);
411  }
412 };
413 
414 template <>
415 struct gemv_dense_selector<OnTheRight, ColMajor, false> {
416  template <typename Lhs, typename Rhs, typename Dest>
417  static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
418  EIGEN_STATIC_ASSERT((!nested_eval<Lhs, 1>::Evaluate),
419  EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
420  // TODO if rhs is large enough it might be beneficial to make sure that dest is sequentially stored in memory,
421  // otherwise use a temp
422  typename nested_eval<Rhs, 1>::type actual_rhs(rhs);
423  const Index size = rhs.rows();
424  for (Index k = 0; k < size; ++k) dest += (alpha * actual_rhs.coeff(k)) * lhs.col(k);
425  }
426 };
427 
428 template <>
429 struct gemv_dense_selector<OnTheRight, RowMajor, false> {
430  template <typename Lhs, typename Rhs, typename Dest>
431  static void run(const Lhs& lhs, const Rhs& rhs, Dest& dest, const typename Dest::Scalar& alpha) {
432  EIGEN_STATIC_ASSERT((!nested_eval<Lhs, 1>::Evaluate),
433  EIGEN_INTERNAL_COMPILATION_ERROR_OR_YOU_MADE_A_PROGRAMMING_MISTAKE);
434  typename nested_eval<Rhs, Lhs::RowsAtCompileTime>::type actual_rhs(rhs);
435  const Index rows = dest.rows();
436  for (Index i = 0; i < rows; ++i)
437  dest.coeffRef(i) += alpha * (lhs.row(i).cwiseProduct(actual_rhs.transpose())).sum();
438  }
439 };
440 
441 } // end namespace internal
442 
443 /***************************************************************************
444  * Implementation of matrix base methods
445  ***************************************************************************/
446 
453 template <typename Derived>
454 template <typename OtherDerived>
455 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Product<Derived, OtherDerived> MatrixBase<Derived>::operator*(
456  const MatrixBase<OtherDerived>& other) const {
457  // A note regarding the function declaration: In MSVC, this function will sometimes
458  // not be inlined since DenseStorage is an unwindable object for dynamic
459  // matrices and product types are holding a member to store the result.
460  // Thus it does not help tagging this function with EIGEN_STRONG_INLINE.
461  enum {
462  ProductIsValid = Derived::ColsAtCompileTime == Dynamic || OtherDerived::RowsAtCompileTime == Dynamic ||
463  int(Derived::ColsAtCompileTime) == int(OtherDerived::RowsAtCompileTime),
464  AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
465  SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived, OtherDerived)
466  };
467  // note to the lost user:
468  // * for a dot product use: v1.dot(v2)
469  // * for a coeff-wise product use: v1.cwiseProduct(v2)
470  EIGEN_STATIC_ASSERT(
471  ProductIsValid || !(AreVectors && SameSizes),
472  INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
473  EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
474  INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
475  EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
476 #ifdef EIGEN_DEBUG_PRODUCT
477  internal::product_type<Derived, OtherDerived>::debug();
478 #endif
479 
480  return Product<Derived, OtherDerived>(derived(), other.derived());
481 }
482 
494 template <typename Derived>
495 template <typename OtherDerived>
496 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Product<Derived, OtherDerived, LazyProduct>
498  enum {
499  ProductIsValid = Derived::ColsAtCompileTime == Dynamic || OtherDerived::RowsAtCompileTime == Dynamic ||
500  int(Derived::ColsAtCompileTime) == int(OtherDerived::RowsAtCompileTime),
501  AreVectors = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime,
502  SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(Derived, OtherDerived)
503  };
504  // note to the lost user:
505  // * for a dot product use: v1.dot(v2)
506  // * for a coeff-wise product use: v1.cwiseProduct(v2)
507  EIGEN_STATIC_ASSERT(
508  ProductIsValid || !(AreVectors && SameSizes),
509  INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
510  EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
511  INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
512  EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
513 
514  return Product<Derived, OtherDerived, LazyProduct>(derived(), other.derived());
515 }
516 
517 } // end namespace Eigen
518 
519 #endif // EIGEN_PRODUCT_H
constexpr Derived & derived()
Definition: EigenBase.h:49
Definition: Constants.h:318
Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:198
Definition: Constants.h:333
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
const Product< Derived, OtherDerived > operator*(const MatrixBase< OtherDerived > &other) const
Definition: GeneralProduct.h:455
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
Definition: Constants.h:331
Definition: Constants.h:320
const int Dynamic
Definition: Constants.h:25
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const Product< Derived, OtherDerived, LazyProduct > lazyProduct(const MatrixBase< OtherDerived > &other) const
Definition: GeneralProduct.h:497