SkylineUtil.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2009 Guillaume Saupin <guillaume.saupin@cea.fr>
00005 //
00006 // Eigen is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 3 of the License, or (at your option) any later version.
00010 //
00011 // Alternatively, you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License as
00013 // published by the Free Software Foundation; either version 2 of
00014 // the License, or (at your option) any later version.
00015 //
00016 // Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
00017 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00018 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
00019 // GNU General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License and a copy of the GNU General Public License along with
00023 // Eigen. If not, see <http://www.gnu.org/licenses/>.
00024 
00025 #ifndef EIGEN_SKYLINEUTIL_H
00026 #define EIGEN_SKYLINEUTIL_H
00027 
00028 namespace Eigen { 
00029 
00030 #ifdef NDEBUG
00031 #define EIGEN_DBG_SKYLINE(X)
00032 #else
00033 #define EIGEN_DBG_SKYLINE(X) X
00034 #endif
00035 
00036 const unsigned int SkylineBit = 0x1200;
00037 template<typename Lhs, typename Rhs, int ProductMode> class SkylineProduct;
00038 enum AdditionalProductEvaluationMode {SkylineTimeDenseProduct, SkylineTimeSkylineProduct, DenseTimeSkylineProduct};
00039 enum {IsSkyline = SkylineBit};
00040 
00041 
00042 #define EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
00043 template<typename OtherDerived> \
00044 EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SkylineMatrixBase<OtherDerived>& other) \
00045 { \
00046   return Base::operator Op(other.derived()); \
00047 } \
00048 EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
00049 { \
00050   return Base::operator Op(other); \
00051 }
00052 
00053 #define EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
00054 template<typename Other> \
00055 EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
00056 { \
00057   return Base::operator Op(scalar); \
00058 }
00059 
00060 #define EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
00061   EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
00062   EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
00063   EIGEN_SKYLINE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
00064   EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
00065   EIGEN_SKYLINE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
00066 
00067 #define _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \
00068   typedef BaseClass Base; \
00069   typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; \
00070   typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
00071   typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
00072   typedef typename Eigen::internal::index<StorageKind>::type Index; \
00073   enum {  Flags = Eigen::internal::traits<Derived>::Flags, };
00074 
00075 #define EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived) \
00076   _EIGEN_SKYLINE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SkylineMatrixBase<Derived>)
00077 
00078 template<typename Derived> class SkylineMatrixBase;
00079 template<typename _Scalar, int _Flags = 0> class SkylineMatrix;
00080 template<typename _Scalar, int _Flags = 0> class DynamicSkylineMatrix;
00081 template<typename _Scalar, int _Flags = 0> class SkylineVector;
00082 template<typename _Scalar, int _Flags = 0> class MappedSkylineMatrix;
00083 
00084 namespace internal {
00085 
00086 template<typename Lhs, typename Rhs> struct skyline_product_mode;
00087 template<typename Lhs, typename Rhs, int ProductMode = skyline_product_mode<Lhs,Rhs>::value> struct SkylineProductReturnType;
00088 
00089 template<typename T> class eval<T,IsSkyline>
00090 {
00091     typedef typename traits<T>::Scalar _Scalar;
00092     enum {
00093           _Flags = traits<T>::Flags
00094     };
00095 
00096   public:
00097     typedef SkylineMatrix<_Scalar, _Flags> type;
00098 };
00099 
00100 } // end namespace internal
00101 
00102 } // end namespace Eigen
00103 
00104 #endif // EIGEN_SKYLINEUTIL_H