Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 /** \class VectorBlock 00017 * \ingroup Core_Module 00018 * 00019 * \brief Expression of a fixed-size or dynamic-size sub-vector 00020 * 00021 * \param VectorType the type of the object in which we are taking a sub-vector 00022 * \param Size size of the sub-vector we are taking at compile time (optional) 00023 * 00024 * This class represents an expression of either a fixed-size or dynamic-size sub-vector. 00025 * It is the return type of DenseBase::segment(Index,Index) and DenseBase::segment<int>(Index) and 00026 * most of the time this is the only way it is used. 00027 * 00028 * However, if you want to directly maniputate sub-vector expressions, 00029 * for instance if you want to write a function returning such an expression, you 00030 * will need to use this class. 00031 * 00032 * Here is an example illustrating the dynamic case: 00033 * \include class_VectorBlock.cpp 00034 * Output: \verbinclude class_VectorBlock.out 00035 * 00036 * \note Even though this expression has dynamic size, in the case where \a VectorType 00037 * has fixed size, this expression inherits a fixed maximal size which means that evaluating 00038 * it does not cause a dynamic memory allocation. 00039 * 00040 * Here is an example illustrating the fixed-size case: 00041 * \include class_FixedVectorBlock.cpp 00042 * Output: \verbinclude class_FixedVectorBlock.out 00043 * 00044 * \sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index) 00045 */ 00046 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 00073 /** Dynamic-size constructor 00074 */ 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 00083 /** Fixed-size constructor 00084 */ 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 00093 } // end namespace Eigen 00094 00095 #endif // EIGEN_VECTORBLOCK_H
Generated on Thu Nov 17 2022 22:01:30 by
1.7.2