10 #ifndef EIGEN_SKYLINEPRODUCT_H 11 #define EIGEN_SKYLINEPRODUCT_H 15 template<
typename Lhs,
typename Rhs,
int ProductMode>
23 template<
typename LhsNested,
typename RhsNested,
int ProductMode>
28 typedef typename _LhsNested::Scalar Scalar;
31 LhsCoeffReadCost = _LhsNested::CoeffReadCost,
32 RhsCoeffReadCost = _RhsNested::CoeffReadCost,
33 LhsFlags = _LhsNested::Flags,
34 RhsFlags = _RhsNested::Flags,
36 RowsAtCompileTime = _LhsNested::RowsAtCompileTime,
37 ColsAtCompileTime = _RhsNested::ColsAtCompileTime,
38 InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(_LhsNested::ColsAtCompileTime, _RhsNested::RowsAtCompileTime),
40 MaxRowsAtCompileTime = _LhsNested::MaxRowsAtCompileTime,
41 MaxColsAtCompileTime = _RhsNested::MaxColsAtCompileTime,
43 EvalToRowMajor = (RhsFlags & LhsFlags &
RowMajorBit),
44 ResultIsSkyline = ProductMode == SkylineTimeSkylineProduct,
46 RemovedBits = ~((EvalToRowMajor ? 0 :
RowMajorBit) | (ResultIsSkyline ? 0 : SkylineBit)),
48 Flags = (int(LhsFlags | RhsFlags) & HereditaryBits & RemovedBits)
61 template<
typename LhsNested,
typename RhsNested,
int ProductMode>
63 public traits<SkylineProduct<LhsNested, RhsNested, ProductMode> >::Base {
75 template<
typename Lhs,
typename Rhs>
77 : m_lhs(lhs), m_rhs(rhs) {
78 eigen_assert(lhs.cols() == rhs.rows());
81 ProductIsValid = _LhsNested::ColsAtCompileTime ==
Dynamic 82 || _RhsNested::RowsAtCompileTime ==
Dynamic 83 || int(_LhsNested::ColsAtCompileTime) == int(_RhsNested::RowsAtCompileTime),
84 AreVectors = _LhsNested::IsVectorAtCompileTime && _RhsNested::IsVectorAtCompileTime,
85 SameSizes = EIGEN_PREDICATE_SAME_MATRIX_SIZE(_LhsNested, _RhsNested)
90 EIGEN_STATIC_ASSERT(ProductIsValid || !(AreVectors && SameSizes),
91 INVALID_VECTOR_VECTOR_PRODUCT__IF_YOU_WANTED_A_DOT_OR_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTIONS)
92 EIGEN_STATIC_ASSERT(ProductIsValid || !(SameSizes && !AreVectors),
93 INVALID_MATRIX_PRODUCT__IF_YOU_WANTED_A_COEFF_WISE_PRODUCT_YOU_MUST_USE_THE_EXPLICIT_FUNCTION)
94 EIGEN_STATIC_ASSERT(ProductIsValid || SameSizes, INVALID_MATRIX_PRODUCT)
97 EIGEN_STRONG_INLINE
Index rows()
const {
101 EIGEN_STRONG_INLINE
Index cols()
const {
105 EIGEN_STRONG_INLINE
const _LhsNested& lhs()
const {
109 EIGEN_STRONG_INLINE
const _RhsNested& rhs()
const {
121 template<
typename Lhs,
typename Rhs,
typename Dest>
122 EIGEN_DONT_INLINE
void skyline_row_major_time_dense_product(
const Lhs& lhs,
const Rhs& rhs, Dest& dst) {
129 LhsIsSelfAdjoint = (_Lhs::Flags & SelfAdjointBit) == SelfAdjointBit,
130 ProcessFirstHalf = LhsIsSelfAdjoint
131 && (((_Lhs::Flags & (UpperTriangularBit | LowerTriangularBit)) == 0)
132 || ((_Lhs::Flags & UpperTriangularBit) && !LhsIsRowMajor)
133 || ((_Lhs::Flags & LowerTriangularBit) && LhsIsRowMajor)),
134 ProcessSecondHalf = LhsIsSelfAdjoint && (!ProcessFirstHalf)
138 for (
Index col = 0; col < rhs.cols(); col++) {
139 for (
Index row = 0; row < lhs.rows(); row++) {
140 dst(row, col) = lhs.coeffDiag(row) * rhs(row, col);
144 for (
Index row = 0; row < lhs.rows(); row++) {
145 typename _Lhs::InnerLowerIterator lIt(lhs, row);
146 const Index stop = lIt.col() + lIt.size();
147 for (
Index col = 0; col < rhs.cols(); col++) {
157 dst(row, col) += tmp;
164 for (
Index lhscol = 0; lhscol < lhs.cols(); lhscol++) {
165 typename _Lhs::InnerUpperIterator uIt(lhs, lhscol);
166 const Index stop = uIt.size() + uIt.row();
167 for (
Index rhscol = 0; rhscol < rhs.cols(); rhscol++) {
170 const Scalar rhsCoeff = rhs.coeff(lhscol, rhscol);
184 template<
typename Lhs,
typename Rhs,
typename Dest>
185 EIGEN_DONT_INLINE
void skyline_col_major_time_dense_product(
const Lhs& lhs,
const Rhs& rhs, Dest& dst) {
192 LhsIsSelfAdjoint = (_Lhs::Flags & SelfAdjointBit) == SelfAdjointBit,
193 ProcessFirstHalf = LhsIsSelfAdjoint
194 && (((_Lhs::Flags & (UpperTriangularBit | LowerTriangularBit)) == 0)
195 || ((_Lhs::Flags & UpperTriangularBit) && !LhsIsRowMajor)
196 || ((_Lhs::Flags & LowerTriangularBit) && LhsIsRowMajor)),
197 ProcessSecondHalf = LhsIsSelfAdjoint && (!ProcessFirstHalf)
201 for (
Index col = 0; col < rhs.cols(); col++) {
202 for (
Index row = 0; row < lhs.rows(); row++) {
203 dst(row, col) = lhs.coeffDiag(row) * rhs(row, col);
208 for (
Index row = 0; row < lhs.rows(); row++) {
209 typename _Lhs::InnerUpperIterator uIt(lhs, row);
210 const Index stop = uIt.col() + uIt.size();
211 for (
Index col = 0; col < rhs.cols(); col++) {
223 dst(row, col) += tmp;
229 for (
Index lhscol = 0; lhscol < lhs.cols(); lhscol++) {
230 typename _Lhs::InnerLowerIterator lIt(lhs, lhscol);
231 const Index stop = lIt.size() + lIt.row();
232 for (
Index rhscol = 0; rhscol < rhs.cols(); rhscol++) {
234 const Scalar rhsCoeff = rhs.coeff(lhscol, rhscol);
248 template<
typename Lhs,
typename Rhs,
typename ResultType,
252 template<
typename Lhs,
typename Rhs,
typename ResultType>
256 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType & res) {
257 skyline_row_major_time_dense_product<Lhs, Rhs, ResultType > (lhs, rhs, res);
261 template<
typename Lhs,
typename Rhs,
typename ResultType>
265 static void run(
const Lhs& lhs,
const Rhs& rhs, ResultType & res) {
266 skyline_col_major_time_dense_product<Lhs, Rhs, ResultType > (lhs, rhs, res);
285 template<
typename Derived>
286 template<
typename OtherDerived >
295 #endif // EIGEN_SKYLINEPRODUCT_H Storage order is column major (see TopicStorageOrders).
Definition: Constants.h:320
const int HugeCost
This value means that the cost to evaluate an expression coefficient is either very expensive or cann...
Definition: Constants.h:39
EIGEN_DEPRECATED const unsigned int EvalBeforeAssigningBit
Definition: Constants.h:71
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:61
Definition: XprHelper.h:89
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Definition: SkylineUtil.h:22
Definition: BandTriangularSolver.h:13
Definition: SkylineProduct.h:250
Storage order is row major (see TopicStorageOrders).
Definition: Constants.h:322
Definition: SkylineProduct.h:62
Definition: SkylineProduct.h:16
Base class of any skyline matrices or skyline expressions.
Definition: SkylineMatrixBase.h:26
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:65
Generic expression where a coefficient-wise unary operator is applied to an expression.
Definition: CwiseUnaryOp.h:55
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: ForwardDeclarations.h:17