blob: cd928772df68702e42f7b03a072f948810534b5d [file] [log] [blame]
Benoit Jacob3cd2a122007-12-24 11:14:25 +00001#include <Eigen/Core.h>
2USING_PART_OF_NAMESPACE_EIGEN
3using namespace std;
4
5template<typename Scalar, typename Derived>
6Eigen::Row<Derived>
7firstRow(MatrixBase<Scalar, Derived>& m)
8{
Benoit Jacob6b9370e2007-12-26 09:25:00 +00009 return Eigen::Row<Derived>(m.ref(), 0);
10}
11
12template<typename Scalar, typename Derived>
13const Eigen::Row<Derived>
14firstRow(const MatrixBase<Scalar, Derived>& m)
15{
16 return Eigen::Row<Derived>(m.ref(), 0);
Benoit Jacob3cd2a122007-12-24 11:14:25 +000017}
18
19int main(int, char**)
20{
21 Matrix4d m = Matrix4d::identity();
Benoit Jacob6b9370e2007-12-26 09:25:00 +000022 cout << firstRow(2*m) << endl; // calls the const version
23 firstRow(m) *= 5; // calls the non-const version
Benoit Jacob3cd2a122007-12-24 11:14:25 +000024 cout << "Now the matrix m is:" << endl << m << endl;
25 return 0;
26}