class_VectorBlock.cpp
Go to the documentation of this file.
1 #include <Eigen/Core>
2 #include <iostream>
3 using namespace Eigen;
4 using namespace std;
5 
6 template<typename Derived>
9 {
10  return Eigen::VectorBlock<Derived>(v.derived(), start, end-start);
11 }
12 
13 template<typename Derived>
15 segmentFromRange(const MatrixBase<Derived>& v, int start, int end)
16 {
17  return Eigen::VectorBlock<const Derived>(v.derived(), start, end-start);
18 }
19 
20 int main(int, char**)
21 {
22  Matrix<int,1,6> v; v << 1,2,3,4,5,6;
23  cout << segmentFromRange(2*v, 2, 4) << endl; // calls the const version
24  segmentFromRange(v, 1, 3) *= 5; // calls the non-const version
25  cout << "Now the vector v is:" << endl << v << endl;
26  return 0;
27 }
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
segmentFromRange
Eigen::VectorBlock< Derived > segmentFromRange(MatrixBase< Derived > &v, int start, int end)
Definition: class_VectorBlock.cpp:8
main
int main(int, char **)
Definition: class_VectorBlock.cpp:20
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 Sat Nov 16 2024 04:01:58