Eigen  3.3.3
Stride.h
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2010 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_STRIDE_H
00011 #define EIGEN_STRIDE_H
00012 
00013 namespace Eigen { 
00014 
00043 template<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime>
00044 class Stride
00045 {
00046   public:
00047     typedef Eigen::Index Index; 
00048     enum {
00049       InnerStrideAtCompileTime = _InnerStrideAtCompileTime,
00050       OuterStrideAtCompileTime = _OuterStrideAtCompileTime
00051     };
00052 
00054     EIGEN_DEVICE_FUNC
00055     Stride()
00056       : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime)
00057     {
00058       eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic);
00059     }
00060 
00062     EIGEN_DEVICE_FUNC
00063     Stride(Index outerStride, Index innerStride)
00064       : m_outer(outerStride), m_inner(innerStride)
00065     {
00066       eigen_assert(innerStride>=0 && outerStride>=0);
00067     }
00068 
00070     EIGEN_DEVICE_FUNC
00071     Stride(const Stride& other)
00072       : m_outer(other.outer()), m_inner(other.inner())
00073     {}
00074 
00076     EIGEN_DEVICE_FUNC
00077     inline Index outer() const { return m_outer.value(); }
00079     EIGEN_DEVICE_FUNC
00080     inline Index inner() const { return m_inner.value(); }
00081 
00082   protected:
00083     internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer;
00084     internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner;
00085 };
00086 
00089 template<int Value>
00090 class InnerStride : public Stride<0, Value>
00091 {
00092     typedef Stride<0, Value> Base;
00093   public:
00094     EIGEN_DEVICE_FUNC InnerStride() : Base() {}
00095     EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code
00096 };
00097 
00100 template<int Value>
00101 class OuterStride : public Stride<Value, 0>
00102 {
00103     typedef Stride<Value, 0> Base;
00104   public:
00105     EIGEN_DEVICE_FUNC OuterStride() : Base() {}
00106     EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code
00107 };
00108 
00109 } // end namespace Eigen
00110 
00111 #endif // EIGEN_STRIDE_H
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends