VectorBlock.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00010 
00011 #ifndef EIGEN_VECTORBLOCK_H
00012 #define EIGEN_VECTORBLOCK_H
00013 
00014 namespace Eigen { 
00015 
00047 namespace internal {
00048 template<typename VectorType, int Size>
00049 struct traits<VectorBlock<VectorType, Size> >
00050   : public traits<Block<VectorType,
00051                      traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
00052                      traits<VectorType>::Flags & RowMajorBit ? Size : 1> >
00053 {
00054 };
00055 }
00056 
00057 template<typename VectorType, int Size> class VectorBlock
00058   : public Block<VectorType,
00059                      internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
00060                      internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>
00061 {
00062     typedef Block<VectorType,
00063                      internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
00064                      internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base;
00065     enum {
00066       IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit)
00067     };
00068   public:
00069     EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock)
00070 
00071     using Base::operator=;
00072 
00075     inline VectorBlock(VectorType& vector, Index start, Index size)
00076       : Base(vector,
00077              IsColVector ? start : 0, IsColVector ? 0 : start,
00078              IsColVector ? size  : 1, IsColVector ? 1 : size)
00079     {
00080       EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
00081     }
00082 
00085     inline VectorBlock(VectorType& vector, Index start)
00086       : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
00087     {
00088       EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
00089     }
00090 };
00091 
00092 
00109 template<typename Derived>
00110 inline typename DenseBase<Derived>::SegmentReturnType
00111 DenseBase<Derived>::segment(Index start, Index size)
00112 {
00113   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00114   return SegmentReturnType(derived(), start, size);
00115 }
00116 
00118 template<typename Derived>
00119 inline typename DenseBase<Derived>::ConstSegmentReturnType
00120 DenseBase<Derived>::segment(Index start, Index size) const
00121 {
00122   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00123   return ConstSegmentReturnType(derived(), start, size);
00124 }
00125 
00141 template<typename Derived>
00142 inline typename DenseBase<Derived>::SegmentReturnType
00143 DenseBase<Derived>::head(Index size)
00144 {
00145   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00146   return SegmentReturnType(derived(), 0, size);
00147 }
00148 
00150 template<typename Derived>
00151 inline typename DenseBase<Derived>::ConstSegmentReturnType
00152 DenseBase<Derived>::head(Index size) const
00153 {
00154   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00155   return ConstSegmentReturnType(derived(), 0, size);
00156 }
00157 
00173 template<typename Derived>
00174 inline typename DenseBase<Derived>::SegmentReturnType
00175 DenseBase<Derived>::tail(Index size)
00176 {
00177   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00178   return SegmentReturnType(derived(), this->size() - size, size);
00179 }
00180 
00182 template<typename Derived>
00183 inline typename DenseBase<Derived>::ConstSegmentReturnType
00184 DenseBase<Derived>::tail(Index size) const
00185 {
00186   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00187   return ConstSegmentReturnType(derived(), this->size() - size, size);
00188 }
00189 
00203 template<typename Derived>
00204 template<int Size>
00205 inline typename DenseBase<Derived>::template FixedSegmentReturnType<Size>::Type
00206 DenseBase<Derived>::segment(Index start)
00207 {
00208   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00209   return typename FixedSegmentReturnType<Size>::Type(derived(), start);
00210 }
00211 
00213 template<typename Derived>
00214 template<int Size>
00215 inline typename DenseBase<Derived>::template ConstFixedSegmentReturnType<Size>::Type
00216 DenseBase<Derived>::segment(Index start) const
00217 {
00218   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00219   return typename ConstFixedSegmentReturnType<Size>::Type(derived(), start);
00220 }
00221 
00233 template<typename Derived>
00234 template<int Size>
00235 inline typename DenseBase<Derived>::template FixedSegmentReturnType<Size>::Type
00236 DenseBase<Derived>::head()
00237 {
00238   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00239   return typename FixedSegmentReturnType<Size>::Type(derived(), 0);
00240 }
00241 
00243 template<typename Derived>
00244 template<int Size>
00245 inline typename DenseBase<Derived>::template ConstFixedSegmentReturnType<Size>::Type
00246 DenseBase<Derived>::head() const
00247 {
00248   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00249   return typename ConstFixedSegmentReturnType<Size>::Type(derived(), 0);
00250 }
00251 
00263 template<typename Derived>
00264 template<int Size>
00265 inline typename DenseBase<Derived>::template FixedSegmentReturnType<Size>::Type
00266 DenseBase<Derived>::tail()
00267 {
00268   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00269   return typename FixedSegmentReturnType<Size>::Type(derived(), size() - Size);
00270 }
00271 
00273 template<typename Derived>
00274 template<int Size>
00275 inline typename DenseBase<Derived>::template ConstFixedSegmentReturnType<Size>::Type
00276 DenseBase<Derived>::tail() const
00277 {
00278   EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
00279   return typename ConstFixedSegmentReturnType<Size>::Type(derived(), size() - Size);
00280 }
00281 
00282 } // end namespace Eigen
00283 
00284 #endif // EIGEN_VECTORBLOCK_H


win_eigen
Author(s): Daniel Stonier
autogenerated on Mon Oct 6 2014 12:26:57