class_FixedVectorBlock.cpp File Reference

Go to the source code of this file.

Functions

template<typename Derived >
const Eigen::VectorBlock< const Derived, 2 > firstTwo (const Eigen::MatrixBase< Derived > &v)
 
template<typename Derived >
Eigen::VectorBlock< Derived, 2 > firstTwo (Eigen::MatrixBase< Derived > &v)
 
int main (int, char **)
 

Function Documentation

◆ firstTwo() [1/2]

template<typename Derived >
const Eigen::VectorBlock<const Derived, 2> firstTwo ( const Eigen::MatrixBase< Derived > &  v)

Definition at line 13 of file class_FixedVectorBlock.cpp.

14 {
15  return Eigen::VectorBlock<const Derived, 2>(v.derived(), 0);
16 }
Array< int, Dynamic, 1 > v
Expression of a fixed-size or dynamic-size sub-vector.
Definition: VectorBlock.h:62

◆ firstTwo() [2/2]

template<typename Derived >
Eigen::VectorBlock<Derived, 2> firstTwo ( Eigen::MatrixBase< Derived > &  v)

Definition at line 6 of file class_FixedVectorBlock.cpp.

7 {
8  return Eigen::VectorBlock<Derived, 2>(v.derived(), 0);
9 }

◆ main()

int main ( int  ,
char **   
)

Definition at line 18 of file class_FixedVectorBlock.cpp.

19 {
20  Eigen::Matrix<int,1,6> v; v << 1,2,3,4,5,6;
21  std::cout << firstTwo(4*v) << std::endl; // calls the const version
22  firstTwo(v) *= 2; // calls the non-const version
23  std::cout << "Now the vector v is:" << std::endl << v << std::endl;
24  return 0;
25 }
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Eigen::VectorBlock< Derived, 2 > firstTwo(Eigen::MatrixBase< Derived > &v)