mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
more changes in ScalarMultiple, reintroduce FloatingPoint in NumTraits, improve
examples
This commit is contained in:
@@ -6,14 +6,21 @@ template<typename Scalar, typename Derived>
|
||||
Eigen::Column<Derived>
|
||||
firstColumn(MatrixBase<Scalar, Derived>& m)
|
||||
{
|
||||
return m.col(0);
|
||||
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(m) << endl;
|
||||
firstColumn(m) *= 5;
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user