Public Member Functions | Private Types | List of all members
Eigen::VectorBlock Class Reference

Expression of a fixed-size or dynamic-size sub-vector. More...

#include <ForwardDeclarations.h>

Public Member Functions

EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE VectorBlock (VectorType &vector, Index start)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE VectorBlock (VectorType &vector, Index start, Index size)
 

Private Types

enum  { IsColVector = !(internal::traits<VectorType>::Flags & RowMajorBit) }
 
typedef Block< VectorType, internal::traits< VectorType >::Flags &RowMajorBit ? 1 :Size, internal::traits< VectorType >::Flags &RowMajorBit ? Size :1 > Base
 

Detailed Description

Expression of a fixed-size or dynamic-size sub-vector.

Template Parameters
VectorTypethe type of the object in which we are taking a sub-vector
Sizesize of the sub-vector we are taking at compile time (optional)

This class represents an expression of either a fixed-size or dynamic-size sub-vector. It is the return type of DenseBase::segment(Index,Index) and DenseBase::segment<int>(Index) and most of the time this is the only way it is used.

However, if you want to directly manipulate sub-vector expressions, for instance if you want to write a function returning such an expression, you will need to use this class.

Here is an example illustrating the dynamic case:

#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
template<typename Derived>
{
return Eigen::VectorBlock<Derived>(v.derived(), start, end-start);
}
template<typename Derived>
segmentFromRange(const MatrixBase<Derived>& v, int start, int end)
{
return Eigen::VectorBlock<const Derived>(v.derived(), start, end-start);
}
int main(int, char**)
{
Matrix<int,1,6> v; v << 1,2,3,4,5,6;
cout << segmentFromRange(2*v, 2, 4) << endl; // calls the const version
segmentFromRange(v, 1, 3) *= 5; // calls the non-const version
cout << "Now the vector v is:" << endl << v << endl;
return 0;
}

Output:

Note
Even though this expression has dynamic size, in the case where VectorType has fixed size, this expression inherits a fixed maximal size which means that evaluating it does not cause a dynamic memory allocation.

Here is an example illustrating the fixed-size case:

#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
template<typename Derived>
{
return Eigen::VectorBlock<Derived, 2>(v.derived(), 0);
}
template<typename Derived>
{
}
int main(int, char**)
{
Matrix<int,1,6> v; v << 1,2,3,4,5,6;
cout << firstTwo(4*v) << endl; // calls the const version
firstTwo(v) *= 2; // calls the non-const version
cout << "Now the vector v is:" << endl << v << endl;
return 0;
}

Output:

See also
class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index)

Definition at line 85 of file ForwardDeclarations.h.

Member Typedef Documentation

◆ Base

Definition at line 63 of file VectorBlock.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
IsColVector 

Definition at line 64 of file VectorBlock.h.

Constructor & Destructor Documentation

◆ VectorBlock() [1/2]

EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::VectorBlock::VectorBlock ( VectorType vector,
Index  start,
Index  size 
)
inline

Dynamic-size constructor

Definition at line 75 of file VectorBlock.h.

◆ VectorBlock() [2/2]

EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::VectorBlock::VectorBlock ( VectorType vector,
Index  start 
)
inline

Fixed-size constructor

Definition at line 86 of file VectorBlock.h.


The documentation for this class was generated from the following files:
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
firstTwo
Eigen::VectorBlock< Derived, 2 > firstTwo(MatrixBase< Derived > &v)
Definition: class_FixedVectorBlock.cpp:8
segmentFromRange
Eigen::VectorBlock< Derived > segmentFromRange(MatrixBase< Derived > &v, int start, int end)
Definition: class_VectorBlock.cpp:8
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
std
Definition: BFloat16.h:88
Eigen::VectorBlock
Expression of a fixed-size or dynamic-size sub-vector.
Definition: ForwardDeclarations.h:85
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
Eigen::MatrixBase
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Eigen::placeholders::end
static const EIGEN_DEPRECATED end_t end
Definition: IndexedViewHelper.h:181


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:47:43