class_FixedVectorBlock.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, 2>(v.derived(), 0);
11 }
12 
13 template<typename Derived>
16 {
17  return Eigen::VectorBlock<const Derived, 2>(v.derived(), 0);
18 }
19 
20 int main(int, char**)
21 {
22  Matrix<int,1,6> v; v << 1,2,3,4,5,6;
23  cout << firstTwo(4*v) << endl; // calls the const version
24  firstTwo(v) *= 2; // calls the non-const version
25  cout << "Now the vector v is:" << endl << v << endl;
26  return 0;
27 }
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Definition: BFloat16.h:88
int main(int, char **)
Eigen::VectorBlock< Derived, 2 > firstTwo(MatrixBase< Derived > &v)
Expression of a fixed-size or dynamic-size sub-vector.
Array< int, Dynamic, 1 > v
The matrix class, also used for vectors and row-vectors.
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:01