Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:36:37

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
0005 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
0006 //
0007 // This Source Code Form is subject to the terms of the Mozilla
0008 // Public License v. 2.0. If a copy of the MPL was not distributed
0009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0010 
0011 #ifndef EIGEN_VECTORBLOCK_H
0012 #define EIGEN_VECTORBLOCK_H
0013 
0014 namespace Eigen { 
0015 
0016 namespace internal {
0017 template<typename VectorType, int Size>
0018 struct traits<VectorBlock<VectorType, Size> >
0019   : public traits<Block<VectorType,
0020                      traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
0021                      traits<VectorType>::Flags & RowMajorBit ? Size : 1> >
0022 {
0023 };
0024 }
0025 
0026 /** \class VectorBlock
0027   * \ingroup Core_Module
0028   *
0029   * \brief Expression of a fixed-size or dynamic-size sub-vector
0030   *
0031   * \tparam VectorType the type of the object in which we are taking a sub-vector
0032   * \tparam Size size of the sub-vector we are taking at compile time (optional)
0033   *
0034   * This class represents an expression of either a fixed-size or dynamic-size sub-vector.
0035   * It is the return type of DenseBase::segment(Index,Index) and DenseBase::segment<int>(Index) and
0036   * most of the time this is the only way it is used.
0037   *
0038   * However, if you want to directly manipulate sub-vector expressions,
0039   * for instance if you want to write a function returning such an expression, you
0040   * will need to use this class.
0041   *
0042   * Here is an example illustrating the dynamic case:
0043   * \include class_VectorBlock.cpp
0044   * Output: \verbinclude class_VectorBlock.out
0045   *
0046   * \note Even though this expression has dynamic size, in the case where \a VectorType
0047   * has fixed size, this expression inherits a fixed maximal size which means that evaluating
0048   * it does not cause a dynamic memory allocation.
0049   *
0050   * Here is an example illustrating the fixed-size case:
0051   * \include class_FixedVectorBlock.cpp
0052   * Output: \verbinclude class_FixedVectorBlock.out
0053   *
0054   * \sa class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index)
0055   */
0056 template<typename VectorType, int Size> class VectorBlock
0057   : public Block<VectorType,
0058                      internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
0059                      internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1>
0060 {
0061     typedef Block<VectorType,
0062                      internal::traits<VectorType>::Flags & RowMajorBit ? 1 : Size,
0063                      internal::traits<VectorType>::Flags & RowMajorBit ? Size : 1> Base;
0064     enum {
0065       IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit)
0066     };
0067   public:
0068     EIGEN_DENSE_PUBLIC_INTERFACE(VectorBlock)
0069 
0070     using Base::operator=;
0071 
0072     /** Dynamic-size constructor
0073       */
0074     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0075     VectorBlock(VectorType& vector, Index start, Index size)
0076       : Base(vector,
0077              IsColVector ? start : 0, IsColVector ? 0 : start,
0078              IsColVector ? size  : 1, IsColVector ? 1 : size)
0079     {
0080       EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
0081     }
0082 
0083     /** Fixed-size constructor
0084       */
0085     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0086     VectorBlock(VectorType& vector, Index start)
0087       : Base(vector, IsColVector ? start : 0, IsColVector ? 0 : start)
0088     {
0089       EIGEN_STATIC_ASSERT_VECTOR_ONLY(VectorBlock);
0090     }
0091 };
0092 
0093 
0094 } // end namespace Eigen
0095 
0096 #endif // EIGEN_VECTORBLOCK_H