blob: bab6eaedca256c3e350847525f467f7ebe902aa7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include <Eigen/Core>
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
Eigen::Column<Derived>
firstColumn(MatrixBase<Scalar, Derived>& m)
{
return Eigen::Column<Derived>(m.ref(), 0);
}
template<typename Scalar, typename Derived>
const Eigen::Column<Derived>
firstColumn(const MatrixBase<Scalar, Derived>& m)
{
return Eigen::Column<Derived>(m.ref(), 0);
}
int main(int, char**)
{
Matrix4d m = Matrix4d::identity();
cout << firstColumn(2*m) << endl; // calls the const version
firstColumn(m) *= 5; // calls the non-const version
cout << "Now the matrix m is:" << endl << m << endl;
return 0;
}
|