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 // 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_STRIDE_H 00026 #define EIGEN_STRIDE_H 00027 00028 /** \class Stride 00029 * \ingroup Core_Module 00030 * 00031 * \brief Holds strides information for Map 00032 * 00033 * This class holds the strides information for mapping arrays with strides with class Map. 00034 * 00035 * It holds two values: the inner stride and the outer stride. 00036 * 00037 * The inner stride is the pointer increment between two consecutive entries within a given row of a 00038 * row-major matrix or within a given column of a column-major matrix. 00039 * 00040 * The outer stride is the pointer increment between two consecutive rows of a row-major matrix or 00041 * between two consecutive columns of a column-major matrix. 00042 * 00043 * These two values can be passed either at compile-time as template parameters, or at runtime as 00044 * arguments to the constructor. 00045 * 00046 * Indeed, this class takes two template parameters: 00047 * \param _OuterStrideAtCompileTime the outer stride, or Dynamic if you want to specify it at runtime. 00048 * \param _InnerStrideAtCompileTime the inner stride, or Dynamic if you want to specify it at runtime. 00049 * 00050 * Here is an example: 00051 * \include Map_general_stride.cpp 00052 * Output: \verbinclude Map_general_stride.out 00053 * 00054 * \sa class InnerStride, class OuterStride 00055 */ 00056 template<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime> 00057 class Stride 00058 { 00059 public: 00060 typedef DenseIndex Index; 00061 enum { 00062 InnerStrideAtCompileTime = _InnerStrideAtCompileTime, 00063 OuterStrideAtCompileTime = _OuterStrideAtCompileTime 00064 }; 00065 00066 /** Default constructor, for use when strides are fixed at compile time */ 00067 Stride() 00068 : m_outer(OuterStrideAtCompileTime), m_inner(InnerStrideAtCompileTime) 00069 { 00070 eigen_assert(InnerStrideAtCompileTime != Dynamic && OuterStrideAtCompileTime != Dynamic); 00071 } 00072 00073 /** Constructor allowing to pass the strides at runtime */ 00074 Stride(Index outerStride, Index innerStride) 00075 : m_outer(outerStride), m_inner(innerStride) 00076 { 00077 eigen_assert(innerStride>=0 && outerStride>=0); 00078 } 00079 00080 /** Copy constructor */ 00081 Stride(const Stride& other) 00082 : m_outer(other.outer()), m_inner(other.inner()) 00083 {} 00084 00085 /** \returns the outer stride */ 00086 inline Index outer() const { return m_outer.value(); } 00087 /** \returns the inner stride */ 00088 inline Index inner() const { return m_inner.value(); } 00089 00090 protected: 00091 internal::variable_if_dynamic<Index, OuterStrideAtCompileTime> m_outer; 00092 internal::variable_if_dynamic<Index, InnerStrideAtCompileTime> m_inner; 00093 }; 00094 00095 /** \brief Convenience specialization of Stride to specify only an inner stride 00096 * See class Map for some examples */ 00097 template<int Value = Dynamic> 00098 class InnerStride : public Stride<0, Value> 00099 { 00100 typedef Stride<0, Value> Base; 00101 public: 00102 typedef DenseIndex Index; 00103 InnerStride() : Base() {} 00104 InnerStride(Index v) : Base(0, v) {} 00105 }; 00106 00107 /** \brief Convenience specialization of Stride to specify only an outer stride 00108 * See class Map for some examples */ 00109 template<int Value = Dynamic> 00110 class OuterStride : public Stride<Value, 0> 00111 { 00112 typedef Stride<Value, 0> Base; 00113 public: 00114 typedef DenseIndex Index; 00115 OuterStride() : Base() {} 00116 OuterStride(Index v) : Base(v,0) {} 00117 }; 00118 00119 #endif // EIGEN_STRIDE_H
Page generated by Doxygen 1.7.2 for MRPT 0.9.4 SVN: at Mon Jan 10 22:46:17 UTC 2011 |