10 #ifndef EIGEN_PRODUCTBASE_H 11 #define EIGEN_PRODUCTBASE_H 21 template<
typename Derived,
typename _Lhs,
typename _Rhs>
46 #define EIGEN_PRODUCT_PUBLIC_INTERFACE(Derived) \ 47 typedef ProductBase<Derived, Lhs, Rhs > Base; \ 48 EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ 49 typedef typename Base::LhsNested LhsNested; \ 50 typedef typename Base::_LhsNested _LhsNested; \ 51 typedef typename Base::LhsBlasTraits LhsBlasTraits; \ 52 typedef typename Base::ActualLhsType ActualLhsType; \ 53 typedef typename Base::_ActualLhsType _ActualLhsType; \ 54 typedef typename Base::RhsNested RhsNested; \ 55 typedef typename Base::_RhsNested _RhsNested; \ 56 typedef typename Base::RhsBlasTraits RhsBlasTraits; \ 57 typedef typename Base::ActualRhsType ActualRhsType; \ 58 typedef typename Base::_ActualRhsType _ActualRhsType; \ 62 template<
typename Derived,
typename Lhs,
typename Rhs>
69 typedef typename Lhs::Nested LhsNested;
76 typedef typename Rhs::Nested RhsNested;
88 #ifndef EIGEN_NO_MALLOC 89 typedef typename Base::PlainObject BasePlainObject;
91 typedef typename internal::conditional<(BasePlainObject::SizeAtCompileTime==
Dynamic) || (BasePlainObject::SizeAtCompileTime*
int(
sizeof(Scalar)) < int(EIGEN_STACK_ALLOCATION_LIMIT)),
98 : m_lhs(a_lhs), m_rhs(a_rhs)
100 eigen_assert(a_lhs.cols() == a_rhs.rows()
101 &&
"invalid matrix product" 102 &&
"if you wanted a coeff-wise or a dot product use the respective explicit functions");
105 inline Index rows()
const {
return m_lhs.rows(); }
106 inline Index cols()
const {
return m_rhs.cols(); }
108 template<
typename Dest>
109 inline void evalTo(Dest& dst)
const { dst.setZero(); scaleAndAddTo(dst,
Scalar(1)); }
111 template<
typename Dest>
112 inline void addTo(Dest& dst)
const { scaleAndAddTo(dst,
Scalar(1)); }
114 template<
typename Dest>
115 inline void subTo(Dest& dst)
const { scaleAndAddTo(dst,
Scalar(-1)); }
117 template<
typename Dest>
118 inline void scaleAndAddTo(Dest& dst,
const Scalar& alpha)
const { derived().scaleAndAddTo(dst,alpha); }
120 const _LhsNested& lhs()
const {
return m_lhs; }
121 const _RhsNested& rhs()
const {
return m_rhs; }
124 operator const PlainObject& ()
const 126 m_result.resize(m_lhs.rows(), m_rhs.cols());
127 derived().evalTo(m_result);
132 {
return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
136 {
return FullyLazyCoeffBaseProductType(m_lhs, m_rhs); }
139 {
return FullyLazyCoeffBaseProductType(m_lhs, m_rhs).diagonal(index); }
142 typename Base::CoeffReturnType coeff(
Index row,
Index col)
const 144 #ifdef EIGEN2_SUPPORT 145 return lhs().row(row).cwiseProduct(rhs().col(col).transpose()).sum();
147 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
148 eigen_assert(this->rows() == 1 && this->cols() == 1);
150 return result.coeff(row,col);
154 typename Base::CoeffReturnType coeff(
Index i)
const 156 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
157 eigen_assert(this->rows() == 1 && this->cols() == 1);
159 return result.coeff(i);
162 const Scalar& coeffRef(
Index row,
Index col)
const 164 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
165 eigen_assert(this->rows() == 1 && this->cols() == 1);
166 return derived().coeffRef(row,col);
169 const Scalar& coeffRef(
Index i)
const 171 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
172 eigen_assert(this->rows() == 1 && this->cols() == 1);
173 return derived().coeffRef(i);
181 mutable PlainObject m_result;
187 template<
typename Lhs,
typename Rhs,
int Mode,
int N,
typename PlainObject>
192 template<
typename Lhs,
typename Rhs,
int Mode,
int N,
typename PlainObject>
199 template<
typename NestedProduct>
208 template<
typename Derived,
typename Lhs,
typename Rhs>
213 template<
typename Derived,
typename Lhs,
typename Rhs>
220 template<
typename Derived,
typename Lhs,
typename Rhs>
225 template<
typename Derived,
typename Lhs,
typename Rhs>
226 typename internal::enable_if<!internal::is_same<typename Derived::Scalar,typename Derived::RealScalar>::value,
232 template<
typename NestedProduct>
234 :
traits<ProductBase<ScaledProduct<NestedProduct>,
235 typename NestedProduct::_LhsNested,
236 typename NestedProduct::_RhsNested> >
242 template<
typename NestedProduct>
245 typename NestedProduct::_LhsNested,
246 typename NestedProduct::_RhsNested>
250 typename NestedProduct::_LhsNested,
251 typename NestedProduct::_RhsNested>
Base;
253 typedef typename Base::PlainObject PlainObject;
257 : Base(prod.lhs(),prod.rhs()), m_prod(prod), m_alpha(x) {}
259 template<
typename Dest>
260 inline void evalTo(Dest& dst)
const { dst.setZero(); scaleAndAddTo(dst,
Scalar(1)); }
262 template<
typename Dest>
263 inline void addTo(Dest& dst)
const { scaleAndAddTo(dst,
Scalar(1)); }
265 template<
typename Dest>
266 inline void subTo(Dest& dst)
const { scaleAndAddTo(dst,
Scalar(-1)); }
268 template<
typename Dest>
269 inline void scaleAndAddTo(Dest& dst,
const Scalar& a_alpha)
const { m_prod.derived().scaleAndAddTo(dst,a_alpha * m_alpha); }
271 const Scalar& alpha()
const {
return m_alpha; }
274 const NestedProduct& m_prod;
280 template<
typename Derived>
281 template<
typename ProductDerived,
typename Lhs,
typename Rhs>
284 other.derived().evalTo(derived());
290 #endif // EIGEN_PRODUCTBASE_H Expression of the product of two general matrices or vectors.
Definition: GeneralProduct.h:36
Definition: gtest_unittest.cc:5031
Definition: BlasUtil.h:151
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:60
Definition: ProductBase.h:63
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:539
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:53
The type used to identify a matrix expression.
Definition: Constants.h:431
Definition: XprHelper.h:371
const unsigned int EvalBeforeAssigningBit
means the expression should be evaluated before any assignment
Definition: Constants.h:63
Definition: CoeffBasedProduct.h:114
Definition: ProductBase.h:200
Definition: BandTriangularSolver.h:13
Definition: XprHelper.h:316
Expression of a diagonal/subdiagonal/superdiagonal in a matrix.
Definition: Diagonal.h:64
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
const unsigned int EvalBeforeNestingBit
means the expression should be evaluated by the calling expression
Definition: Constants.h:58
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48