Eigen  3.3.3
VectorBlock.h
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 
00016 namespace internal {
00017 template<typename VectorType, int Size>
00018 struct traits<VectorBlock<VectorType, Size> >
00019   : public traits<Block<VectorType,
00020                      traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
00021                      traits<VectorType>::Flags & RowMajorBit ? Size : 1> >
00022 {
00023 };
00024 }
00025 
00056 template<typename VectorType, int Size> class VectorBlock
00057   : public Block<VectorType,
00058                      internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
00059                      internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>
00060 {
00061     typedef Block<VectorType,
00062                      internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
00063                      internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base;
00064     enum {
00065       IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit)
00066     };
00067   public:
00068     EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock)
00069 
00070     using Base::operator=;
00071 
00074     EIGEN_DEVICE_FUNC
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     EIGEN_DEVICE_FUNC
00086     inline VectorBlock(VectorType& vector, Index start)
00087       : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
00088     {
00089       EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
00090     }
00091 };
00092 
00093 
00094 } // end namespace Eigen
00095 
00096 #endif // EIGEN_VECTORBLOCK_H
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends