Eigne Matrix Class Library
Dependents: Eigen_test Odometry_test AttitudeEstimation_usingTicker MPU9250_Quaternion_Binary_Serial ... more
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 00015 /** \class Stride 00016 * \ingroup Core_Module 00017 * 00018 * \brief Holds strides information for Map 00019 * 00020 * This class holds the strides information for mapping arrays with strides with class Map. 00021 * 00022 * It holds two values: the inner stride and the outer stride. 00023 * 00024 * The inner stride is the pointer increment between two consecutive entries within a given row of a 00025 * row-major matrix or within a given column of a column-major matrix. 00026 * 00027 * The outer stride is the pointer increment between two consecutive rows of a row-major matrix or 00028 * between two consecutive columns of a column-major matrix. 00029 * 00030 * These two values can be passed either at compile-time as template parameters, or at runtime as 00031 * arguments to the constructor. 00032 * 00033 * Indeed, this class takes two template parameters: 00034 * \param _OuterStrideAtCompileTime the outer stride, or Dynamic if you want to specify it at runtime. 00035 * \param _InnerStrideAtCompileTime the inner stride, or Dynamic if you want to specify it at runtime. 00036 * 00037 * Here is an example: 00038 * \include Map_general_stride.cpp 00039 * Output: \verbinclude Map_general_stride.out 00040 * 00041 * \sa class InnerStride, class OuterStride, \ref TopicStorageOrders 00042 */ 00043 template<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime> 00044 class Stride 00045 { 00046 public: 00047 typedef DenseIndex Index; 00048 enum { 00049 InnerStrideAtCompileTime = _InnerStrideAtCompileTime, 00050 OuterStrideAtCompileTime = _OuterStrideAtCompileTime 00051 }; 00052 00053 /** Default constructor, for use when strides are fixed at compile time */ 00054 Stride() 00055 : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) 00056 { 00057 eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); 00058 } 00059 00060 /** Constructor allowing to pass the strides at runtime */ 00061 Stride(Index outerStride, Index innerStride) 00062 : m_outer(outerStride), m_inner(innerStride) 00063 { 00064 eigen_assert(innerStride>=0 && outerStride>=0); 00065 } 00066 00067 /** Copy constructor */ 00068 Stride(const Stride& other) 00069 : m_outer(other.outer ()), m_inner(other.inner ()) 00070 {} 00071 00072 /** \returns the outer stride */ 00073 inline Index outer () const { return m_outer.value(); } 00074 /** \returns the inner stride */ 00075 inline Index inner () const { return m_inner.value(); } 00076 00077 protected: 00078 internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer; 00079 internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner; 00080 }; 00081 00082 /** \brief Convenience specialization of Stride to specify only an inner stride 00083 * See class Map for some examples */ 00084 template<int Value = Dynamic> 00085 class InnerStride : public Stride<0, Value> 00086 { 00087 typedef Stride<0, Value> Base ; 00088 public: 00089 typedef DenseIndex Index; 00090 InnerStride() : Base () {} 00091 InnerStride(Index v) : Base (0, v) {} 00092 }; 00093 00094 /** \brief Convenience specialization of Stride to specify only an outer stride 00095 * See class Map for some examples */ 00096 template<int Value = Dynamic> 00097 class OuterStride : public Stride<Value, 0> 00098 { 00099 typedef Stride<Value, 0> Base ; 00100 public: 00101 typedef DenseIndex Index; 00102 OuterStride() : Base () {} 00103 OuterStride(Index v) : Base (v,0) {} 00104 }; 00105 00106 } // end namespace Eigen 00107 00108 #endif // EIGEN_STRIDE_H
Generated on Tue Jul 12 2022 17:47:00 by 1.7.2