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::DynBlock<Derived>
|
||||
topLeftCorner(MatrixBase<Scalar, Derived>& m, int rows, int cols)
|
||||
{
|
||||
return m.dynBlock(0, 0, rows, cols);
|
||||
return Eigen::DynBlock<Derived>(m.ref(), 0, 0, rows, cols);
|
||||
}
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
const Eigen::DynBlock<Derived>
|
||||
topLeftCorner(const MatrixBase<Scalar, Derived>& m, int rows, int cols)
|
||||
{
|
||||
return Eigen::DynBlock<Derived>(m.ref(), 0, 0, rows, cols);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
Matrix4d m = Matrix4d::identity();
|
||||
cout << topLeftCorner(m, 2, 3) << endl;
|
||||
topLeftCorner(m, 2, 3) *= 5;
|
||||
cout << topLeftCorner(4*m, 2, 3) << endl; // calls the const version
|
||||
topLeftCorner(m, 2, 3) *= 5; // calls the non-const version
|
||||
cout << "Now the matrix m is:" << endl << m << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user