many small fixes and documentation improvements,

this should be alpha5.
This commit is contained in:
Benoit Jacob
2008-05-29 03:12:30 +00:00
parent c1559d3079
commit 486fdb26a1
24 changed files with 165 additions and 169 deletions

View File

@@ -0,0 +1,8 @@
Matrix3i m = Matrix3i::random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the upper-triangular matrix extracted from m:" << endl
<< m.extract<Eigen::Upper>() << endl;
cout << "Here is the strictly-upper-triangular matrix extracted from m:" << endl
<< m.extract<Eigen::StrictlyUpper>() << endl;
cout << "Here is the unit-lower-triangular matrix extracted from m:" << endl
<< m.extract<Eigen::UnitLower>() << endl;

View File

@@ -0,0 +1,7 @@
Matrix2d m = Matrix2d::random();
cout << "Here is the matrix m:" << endl << m << endl;
Matrix2d::InverseType m_inv = m.inverse();
if(m_inv.exists())
cout << "m is invertible, and its inverse is:" << endl << m_inv << endl;
else
cout << "m is not invertible." << endl;

View File

@@ -0,0 +1,10 @@
Matrix2d m; m << 1,2,3,4;
Matrix2d n;
n = (m*m).lazy(); // if we did "n = m*m;" then m*m would first be evaluated into
// a temporary, because the Product expression has the EvalBeforeAssigningBit.
// This temporary would then be copied into n. Introducing this temporary is
// useless here and wastes time. Doing "n = (m*m).lazy();" evaluates m*m directly
// into n, which is faster. But, beware! This is only correct because m and n
// are two distinct matrices. Doing "m = (m*m).lazy();" would not produce the
// expected result.
cout << n << endl;

View File

@@ -0,0 +1,9 @@
Matrix3d m = Matrix3d::zero();
m.part<Eigen::Upper>().setOnes();
cout << "Here is the matrix m:" << endl << m << endl;
Matrix3d n = Matrix3d::ones();
n.part<Eigen::Lower>() *= 2;
cout << "Here is the matrix n:" << endl << n << endl;
cout << "And now here is m.inverse()*n, taking advantage of the fact that"
" m is upper-triangular:" << endl
<< m.marked<Eigen::Upper>().inverseProduct(n);

View File

@@ -0,0 +1,8 @@
Matrix3d m = Matrix3i::zero();
m.part<Eigen::StrictlyUpper>().setOnes();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "And let us now compute m*m.adjoint() in a very optimized way" << endl
<< "taking advantage of the symmetry." << endl;
Matrix3d n;
n.part<Eigen::SelfAdjoint>() = (m*m.adjoint()).lazy();
cout << "The result is:" << endl << n << endl;

View File

@@ -0,0 +1,5 @@
Matrix4d m = Matrix4d::zero();
m.part<Eigen::Upper>().setOnes();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "We know for sure that it is invertible." << endl;
cout << "Here is its inverse:" << m.quickInverse() << endl;

View File

@@ -0,0 +1,5 @@
RowVector4i v = RowVector4i::random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.end(2):" << endl << v.end<2>() << endl;
v.end<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;

View File

@@ -0,0 +1,6 @@
Matrix4i m = Matrix4i::random();
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the bottom-right 2x3 corner in m:" << endl
<< m.corner<2,3>(Eigen::BottomRight) << endl;
m.corner<2,3>(Eigen::BottomRight).setZero();
cout << "Now the matrix m is:" << endl << m << endl;

View File

@@ -0,0 +1,5 @@
RowVector4i v = RowVector4i::random();
cout << "Here is the vector v:" << endl << v << endl;
cout << "Here is v.start(2):" << endl << v.start<2>() << endl;
v.start<2>().setZero();
cout << "Now the vector v is:" << endl << v << endl;

View File

@@ -1,4 +1,5 @@
#include <Eigen/Core>
#include <Eigen/LU>
USING_PART_OF_NAMESPACE_EIGEN
using namespace std;
int main(int, char**)