mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
many small fixes and documentation improvements,
this should be alpha5.
This commit is contained in:
8
doc/snippets/MatrixBase_extract.cpp
Normal file
8
doc/snippets/MatrixBase_extract.cpp
Normal 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;
|
||||
7
doc/snippets/MatrixBase_inverse.cpp
Normal file
7
doc/snippets/MatrixBase_inverse.cpp
Normal 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;
|
||||
10
doc/snippets/MatrixBase_lazy.cpp
Normal file
10
doc/snippets/MatrixBase_lazy.cpp
Normal 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;
|
||||
9
doc/snippets/MatrixBase_marked.cpp
Normal file
9
doc/snippets/MatrixBase_marked.cpp
Normal 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);
|
||||
8
doc/snippets/MatrixBase_part.cpp
Normal file
8
doc/snippets/MatrixBase_part.cpp
Normal 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;
|
||||
5
doc/snippets/MatrixBase_quickInverse.cpp
Normal file
5
doc/snippets/MatrixBase_quickInverse.cpp
Normal 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;
|
||||
5
doc/snippets/MatrixBase_template_int_end.cpp
Normal file
5
doc/snippets/MatrixBase_template_int_end.cpp
Normal 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;
|
||||
6
doc/snippets/MatrixBase_template_int_int_corner_enum.cpp
Normal file
6
doc/snippets/MatrixBase_template_int_int_corner_enum.cpp
Normal 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;
|
||||
5
doc/snippets/MatrixBase_template_int_start.cpp
Normal file
5
doc/snippets/MatrixBase_template_int_start.cpp
Normal 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;
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/LU>
|
||||
USING_PART_OF_NAMESPACE_EIGEN
|
||||
using namespace std;
|
||||
int main(int, char**)
|
||||
|
||||
Reference in New Issue
Block a user