template<typename VectorType, int Size>
class Eigen::VectorBlock< VectorType, Size >
Expression of a fixed-size or dynamic-size sub-vector.
- Template Parameters
-
VectorType | the type of the object in which we are taking a sub-vector |
Size | size 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 std;
template<typename Derived>
{
}
template<typename Derived>
{
}
int main(int, char**)
{
cout << segmentFromRange(2*v, 2, 4) << endl;
segmentFromRange(v, 1, 3) *= 5;
cout << "Now the vector v is:" << endl << v << endl;
return 0;
}
Derived & derived()
Definition: EigenBase.h:46
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:50
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:180
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:60
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Output:
6 8
Now the vector v is:
1 10 15 4 5 6
- 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 std;
template<typename Derived>
{
}
template<typename Derived>
{
}
int main(int, char**)
{
cout << firstTwo(4*v) << endl;
firstTwo(v) *= 2;
cout << "Now the vector v is:" << endl << v << endl;
return 0;
}
Output:
4 8
Now the vector v is:
2 4 3 4 5 6
- See also
- class Block, DenseBase::segment(Index,Index,Index,Index), DenseBase::segment(Index,Index)