WPILibC++ 2023.4.3-108-ge5452e3
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
14namespace Eigen {
15
16namespace internal {
17template<typename VectorType, int Size>
18struct traits<VectorBlock<VectorType, Size> >
19 : public traits<Block<VectorType,
20 traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
21 traits<VectorType>::Flags & RowMajorBit ? Size : 1> >
22{
23};
24}
25
26/** \class VectorBlock
27 * \ingroup Core_Module
28 *
29 * \brief Expression of a fixed-size or dynamic-size sub-vector
30 *
31 * \tparam VectorType the type of the object in which we are taking a sub-vector
32 * \tparam Size size of the sub-vector we are taking at compile time (optional)
33 *
34 * This class represents an expression of either a fixed-size or dynamic-size sub-vector.
35 * It is the return type of DenseBase::segment(Index,Index) and DenseBase::segment<int>(Index) and
36 * most of the time this is the only way it is used.
37 *
38 * However, if you want to directly manipulate sub-vector expressions,
39 * for instance if you want to write a function returning such an expression, you
40 * will need to use this class.
41 *
42 * Here is an example illustrating the dynamic case:
43 * \include class_VectorBlock.cpp
44 * Output: \verbinclude class_VectorBlock.out
45 *
46 * \note Even though this expression has dynamic size, in the case where \a VectorType
47 * has fixed size, this expression inherits a fixed maximal size which means that evaluating
48 * it does not cause a dynamic memory allocation.
49 *
50 * Here is an example illustrating the fixed-size case:
51 * \include class_FixedVectorBlock.cpp
52 * Output: \verbinclude class_FixedVectorBlock.out
53 *
54 * \sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index)
55 */
56template<typename VectorType, int Size> class VectorBlock
57 : public Block<VectorType,
58 internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
59 internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>
60{
61 typedef Block<VectorType,
64 enum {
66 };
67 public:
69
70 using Base::operator=;
71
72 /** Dynamic-size constructor
73 */
75 VectorBlock(VectorType& vector, Index start, Index size)
76 : Base(vector,
77 IsColVector ? start : 0, IsColVector ? 0 : start,
78 IsColVector ? size : 1, IsColVector ? 1 : size)
79 {
81 }
82
83 /** Fixed-size constructor
84 */
86 VectorBlock(VectorType& vector, Index start)
87 : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
88 {
90 }
91};
92
93
94} // end namespace Eigen
95
96#endif // EIGEN_VECTORBLOCK_H
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:986
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
Definition: Macros.h:1293
#define EIGEN_STRONG_INLINE
Definition: Macros.h:927
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:142
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:105
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:60
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE VectorBlock(VectorType &vector, Index start, Index size)
Dynamic-size constructor.
Definition: VectorBlock.h:75
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE VectorBlock(VectorType &vector, Index start)
Fixed-size constructor.
Definition: VectorBlock.h:86
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition: Constants.h:66
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: Eigen_Colamd.h:50
Definition: ForwardDeclarations.h:17