1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Guillaume Saupin <guillaume.saupin@cea.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_SKYLINEUTIL_H
11 #define EIGEN_SKYLINEUTIL_H
12 
13 namespace Eigen {
14 
15 #ifdef NDEBUG
16 #define EIGEN_DBG_SKYLINE(X)
17 #else
18 #define EIGEN_DBG_SKYLINE(X) X
19 #endif
20 
21 const unsigned int SkylineBit = 0x1200;
22 template<typename Lhs, typename Rhs, int ProductMode> class SkylineProduct;
23 enum AdditionalProductEvaluationMode {SkylineTimeDenseProduct, SkylineTimeSkylineProduct, DenseTimeSkylineProduct};
24 enum {IsSkyline = SkylineBit};
25 
26 
27 #define EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
28 template<typename OtherDerived> \
29 EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SkylineMatrixBase<OtherDerived>& other) \
30 { \
31   return Base::operator Op(other.derived()); \
32 } \
33 EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
34 { \
35   return Base::operator Op(other); \
36 }
37 
38 #define EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
39 template<typename Other> \
40 EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
41 { \
42   return Base::operator Op(scalar); \
43 }
44 
45 #define EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
46   EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
47   EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
48   EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
49   EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
50   EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
51 
52 #define _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
53   typedef BaseClass Base; \
54   typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
55   typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
56   typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
57   typedef typename Eigen::internal::index<StorageKind>::type Index; \
58   enum {  Flags = Eigen::internal::traits<Derived>::Flags, };
59 
60 #define EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived) \
61   _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SkylineMatrixBase<Derived>)
62 
63 template<typename Derived> class SkylineMatrixBase;
64 template<typename _Scalar, int _Flags = 0> class SkylineMatrix;
65 template<typename _Scalar, int _Flags = 0> class DynamicSkylineMatrix;
66 template<typename _Scalar, int _Flags = 0> class SkylineVector;
67 template<typename _Scalar, int _Flags = 0> class MappedSkylineMatrix;
68 
69 namespace internal {
70 
71 template<typename Lhs, typename Rhs> struct skyline_product_mode;
72 template<typename Lhs, typename Rhs, int ProductMode = skyline_product_mode<Lhs,Rhs>::value> struct SkylineProductReturnType;
73 
74 template<typename T> class eval<T,IsSkyline>
75 {
76     typedef typename traits<T>::Scalar _Scalar;
77     enum {
78           _Flags = traits<T>::Flags
79     };
80 
81   public:
82     typedef SkylineMatrix<_Scalar, _Flags> type;
83 };
84 
85 } // end namespace internal
86 
87 } // end namespace Eigen
88 
89 #endif // EIGEN_SKYLINEUTIL_H
90