eigen/doc/examples/class_Row.cpp
2008-03-04 17:08:23 +00:00

27 lines
648 B
C++

#include <Eigen/Core>
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
Eigen::Row<Derived>
firstRow(MatrixBase<Scalar, Derived>& m)
{
return Eigen::Row<Derived>(m.asArg(), 0);
}
template<typename Scalar, typename Derived>
const Eigen::Row<Derived>
firstRow(const MatrixBase<Scalar, Derived>& m)
{
return Eigen::Row<Derived>(m.asArg(), 0);
}
int main(int, char**)
{
Matrix4d m = Matrix4d::identity();
cout << firstRow(2*m) << endl; // calls the const version
firstRow(m) *= 5; // calls the non-const version
cout << "Now the matrix m is:" << endl << m << endl;
return 0;
}