VectorBlock.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_VECTORBLOCK_H
12 #define EIGEN_VECTORBLOCK_H
13 
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 namespace internal {
19 template<typename VectorType, int Size>
20 struct traits<VectorBlock<VectorType, Size> >
21  : public traits<Block<VectorType,
22  traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
23  traits<VectorType>::Flags & RowMajorBit ? Size : 1> >
24 {
25 };
26 }
27 
58 template<typename VectorType, int Size> class VectorBlock
59  : public Block<VectorType,
60  internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
61  internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>
62 {
63  typedef Block<VectorType,
64  internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
65  internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base;
66  enum {
67  IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit)
68  };
69  public:
73 
74 
76  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
77  VectorBlock(VectorType& vector, Index start, Index size)
78  : Base(vector,
79  IsColVector ? start : 0, IsColVector ? 0 : start,
80  IsColVector ? size : 1, IsColVector ? 1 : size)
81  { }
82 
85  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
86  VectorBlock(VectorType& vector, Index start)
87  : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
88  { }
89 };
90 
91 
92 } // end namespace Eigen
93 
94 #endif // EIGEN_VECTORBLOCK_H
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1168
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Definition: Macros.h:1122
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:107
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:62
VectorBlock(VectorType &vector, Index start, Index size)
Definition: VectorBlock.h:77
VectorBlock(VectorType &vector, Index start)
Definition: VectorBlock.h:86
Block< VectorType, internal::traits< VectorType >::Flags &RowMajorBit ? 1 :Size, internal::traits< VectorType >::Flags &RowMajorBit ? Size :1 > Base
Definition: VectorBlock.h:65
const unsigned int RowMajorBit
Definition: Constants.h:68
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82