Patch by Gael Guennebaud: unify fixed-size and dynamic-size Block

expressions, update documentation.
This commit is contained in:
Benoit Jacob
2008-02-29 13:56:40 +00:00
parent b3268a6e2f
commit f12e9c53ac
9 changed files with 96 additions and 45 deletions

View File

@@ -3,17 +3,17 @@ USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
template<typename Scalar, typename Derived>
Eigen::FixedBlock<Derived, 2, 2>
Eigen::Block<Derived, 2, 2>
topLeft2x2Corner(MatrixBase<Scalar, Derived>& m)
{
return Eigen::FixedBlock<Derived, 2, 2>(m.ref(), 0, 0);
return Eigen::Block<Derived, 2, 2>(m.ref(), 0, 0);
}
template<typename Scalar, typename Derived>
const Eigen::FixedBlock<Derived, 2, 2>
const Eigen::Block<Derived, 2, 2>
topLeft2x2Corner(const MatrixBase<Scalar, Derived>& m)
{
return Eigen::FixedBlock<Derived, 2, 2>(m.ref(), 0, 0);
return Eigen::Block<Derived, 2, 2>(m.ref(), 0, 0);
}
int main(int, char**)

View File

@@ -1,5 +1,5 @@
Matrix4d m = Vector4d(1,2,3,4).asDiagonal();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is m.fixedBlock<2, 2>(2, 2):" << endl << m.fixedBlock<2, 2>(2, 2) << endl;
m.fixedBlock<2, 2>(2, 0) = m.fixedBlock<2, 2>(2, 2);
cout << "Here is m.fixed<2, 2>(2, 2):" << endl << m.block<2, 2>(2, 2) << endl;
m.block<2, 2>(2, 0) = m.block<2, 2>(2, 2);
cout << "Now the matrix m is:" << endl << m << endl;

View File

@@ -1,3 +1,3 @@
Matrix4i m = Matrix4i::zero();
m.fixedBlock<3,3>(1,0).setIdentity();
m.block<3,3>(1,0).setIdentity();
cout << m << endl;

View File

@@ -18,13 +18,13 @@ int main(int, char **)
// notice how we are mixing fixed-size and dynamic-size types.
cout << "In the top-left block, we put the matrix m shown above." << endl;
m2.fixedBlock<2,2>(0,0) = m;
m2.block<2,2>(0,0) = m;
cout << "In the bottom-left block, we put the matrix m*m, which is:" << endl << m*m << endl;
m2.fixedBlock<2,2>(2,0) = m * m;
m2.block<2,2>(2,0) = m * m;
cout << "In the top-right block, we put the matrix m+m, which is:" << endl << m+m << endl;
m2.fixedBlock<2,2>(0,2) = m + m;
m2.block<2,2>(0,2) = m + m;
cout << "In the bottom-right block, we put the matrix m-m, which is:" << endl << m-m << endl;
m2.fixedBlock<2,2>(2,2) = m - m;
m2.block<2,2>(2,2) = m - m;
cout << "Now the 4x4 matrix m2 is:" << endl << m2 << endl;
cout << "Row 0 of m2 is:" << endl << m2.row(0) << endl;