mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Various documentation updates:
- update the tutorial - update doc of deprecated cwise function - update cwise doc snippets
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,-2,-3);
|
||||
cout << v.cwise().abs() << endl;
|
||||
Array3d v(1,-2,-3);
|
||||
cout << v.abs() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,-2,-3);
|
||||
cout << v.cwise().abs2() << endl;
|
||||
Array3d v(1,-2,-3);
|
||||
cout << v.abs2() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(M_PI, M_PI/2, M_PI/3);
|
||||
cout << v.cwise().cos() << endl;
|
||||
Array3d v(M_PI, M_PI/2, M_PI/3);
|
||||
cout << v.cos() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(2,3,4);
|
||||
cout << v.cwise().cube() << endl;
|
||||
Array3d v(2,3,4);
|
||||
cout << v.cube() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3), w(3,2,1);
|
||||
cout << (v.cwise()==w) << endl;
|
||||
Array3d v(1,2,3), w(3,2,1);
|
||||
cout << (v==w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3);
|
||||
cout << v.cwise().exp() << endl;
|
||||
Array3d v(1,2,3);
|
||||
cout << v.exp() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3), w(3,2,1);
|
||||
cout << (v.cwise()>w) << endl;
|
||||
Array3d v(1,2,3), w(3,2,1);
|
||||
cout << (v>w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3), w(3,2,1);
|
||||
cout << (v.cwise()>=w) << endl;
|
||||
Array3d v(1,2,3), w(3,2,1);
|
||||
cout << (v>=w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(2,3,4);
|
||||
cout << v.cwise().inverse() << endl;
|
||||
Array3d v(2,3,4);
|
||||
cout << v.inverse() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3), w(3,2,1);
|
||||
cout << (v.cwise()<w) << endl;
|
||||
Array3d v(1,2,3), w(3,2,1);
|
||||
cout << (v<w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3), w(3,2,1);
|
||||
cout << (v.cwise()<=w) << endl;
|
||||
Array3d v(1,2,3), w(3,2,1);
|
||||
cout << (v<=w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3);
|
||||
cout << v.cwise().log() << endl;
|
||||
Array3d v(1,2,3);
|
||||
cout << v.log() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(2,3,4), w(4,2,3);
|
||||
cout << v.cwise().max(w) << endl;
|
||||
Array3d v(2,3,4), w(4,2,3);
|
||||
cout << v.max(w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(2,3,4), w(4,2,3);
|
||||
cout << v.cwise().min(w) << endl;
|
||||
Array3d v(2,3,4), w(4,2,3);
|
||||
cout << v.min(w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3);
|
||||
cout << v.cwise()-5 << endl;
|
||||
Array3d v(1,2,3);
|
||||
cout << v-5 << endl;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Vector3d v(1,2,3);
|
||||
v.cwise() -= 5;
|
||||
Array3d v(1,2,3);
|
||||
v -= 5;
|
||||
cout << v << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3), w(3,2,1);
|
||||
cout << (v.cwise()!=w) << endl;
|
||||
Array3d v(1,2,3), w(3,2,1);
|
||||
cout << (v!=w) << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,3);
|
||||
cout << v.cwise()+5 << endl;
|
||||
Array3d v(1,2,3);
|
||||
cout << v+5 << endl;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Vector3d v(1,2,3);
|
||||
v.cwise() += 5;
|
||||
Array3d v(1,2,3);
|
||||
v += 5;
|
||||
cout << v << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(8,27,64);
|
||||
cout << v.cwise().pow(0.333333) << endl;
|
||||
Array3d v(8,27,64);
|
||||
cout << v.pow(0.333333) << endl;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Matrix3i a = Matrix3i::Random(), b = Matrix3i::Random();
|
||||
Matrix3i c = a.cwise() * b;
|
||||
Array33i a = Array33i::Random(), b = Array33i::Random();
|
||||
Array33i c = a * b;
|
||||
cout << "a:\n" << a << "\nb:\n" << b << "\nc:\n" << c << endl;
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(2,3,4), w(4,2,3);
|
||||
cout << v.cwise()/w << endl;
|
||||
Array3d v(2,3,4), w(4,2,3);
|
||||
cout << v/w << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(M_PI, M_PI/2, M_PI/3);
|
||||
cout << v.cwise().sin() << endl;
|
||||
Array3d v(M_PI, M_PI/2, M_PI/3);
|
||||
cout << v.sin() << endl;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
Vector3d v(3,2,4);
|
||||
Vector3d w(5,4,2);
|
||||
v.cwise() /= w;
|
||||
Array3d v(3,2,4), w(5,4,2);
|
||||
v /= w;
|
||||
cout << v << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(1,2,4);
|
||||
cout << v.cwise().sqrt() << endl;
|
||||
Array3d v(1,2,4);
|
||||
cout << v.sqrt() << endl;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
Vector3d v(2,3,4);
|
||||
cout << v.cwise().square() << endl;
|
||||
Array3d v(2,3,4);
|
||||
cout << v.square() << endl;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
Vector3d v(1,2,3);
|
||||
Vector3d w(2,3,0);
|
||||
v.cwise() *= w;
|
||||
Array3d v(1,2,3), w(2,3,0);
|
||||
v *= w;
|
||||
cout << v << endl;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Vector3f boxMin(Vector3f::Zero()), boxMax(Vector3f::Ones());
|
||||
Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwise().abs();
|
||||
Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwiseAbs();
|
||||
// let's check if p0 and p1 are inside the axis aligned box defined by the corners boxMin,boxMax:
|
||||
cout << "Is (" << p0.transpose() << ") inside the box: "
|
||||
<< ((boxMin.cwise()<p0).all() && (boxMax.cwise()>p0).all()) << endl;
|
||||
<< ((boxMin.array()<p0.array()).all() && (boxMax.array()>p0.array()).all()) << endl;
|
||||
cout << "Is (" << p1.transpose() << ") inside the box: "
|
||||
<< ((boxMin.cwise()<p1).all() && (boxMax.cwise()>p1).all()) << endl;
|
||||
<< ((boxMin.array()<p1.array()).all() && (boxMax.array()>p1.array()).all()) << endl;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Vector3d v(1,2,3);
|
||||
v.cwise() += 3;
|
||||
v.cwise() -= 2;
|
||||
v.array() += 3;
|
||||
v.array() -= 2;
|
||||
cout << v << endl;
|
||||
4
doc/snippets/MatrixBase_array_const.cpp
Normal file
4
doc/snippets/MatrixBase_array_const.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
Vector3d v(-1,2,-3);
|
||||
cout << "the absolute values:" << endl << v.array().abs() << endl;
|
||||
cout << "the absolute values plus one:" << endl << v.array().abs()+1 << endl;
|
||||
cout << "sum of the squares: " << v.array().square().sum() << endl;
|
||||
@@ -2,4 +2,4 @@ Matrix3d m = Matrix3d::Random();
|
||||
cout << "Here is the matrix m:" << endl << m << endl;
|
||||
cout << "Here is the sum of each column:" << endl << m.colwise().sum() << endl;
|
||||
cout << "Here is the maximum absolute value of each column:"
|
||||
<< endl << m.cwise().abs().colwise().maxCoeff() << endl;
|
||||
<< endl << m.cwiseAbs().colwise().maxCoeff() << endl;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
Vector3d v(-1,2,-3);
|
||||
cout << "the absolute values:" << endl << v.cwise().abs() << endl;
|
||||
cout << "the absolute values plus one:" << endl << v.cwise().abs().cwise()+1 << endl;
|
||||
cout << "sum of the squares: " << v.cwise().square().sum() << endl;
|
||||
@@ -1,5 +0,0 @@
|
||||
Matrix2d m; m << 1,2,3,4;
|
||||
cout << (m*m).lazy().row(0) << endl;
|
||||
// this computes only one row of the product. By contrast,
|
||||
// if we did "(m*m).row(0);" then m*m would first be evaluated into
|
||||
// a temporary, because the Product expression has the EvalBeforeNestingBit.
|
||||
3
doc/snippets/MatrixBase_noalias.cpp
Normal file
3
doc/snippets/MatrixBase_noalias.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
Matrix2d a, b, c; a << 1,2,3,4; b << 5,6,7,8;
|
||||
c.noalias() = a * b; // this computes the product directly to c
|
||||
cout << c << endl;
|
||||
@@ -2,4 +2,4 @@ Matrix3d m = Matrix3d::Random();
|
||||
cout << "Here is the matrix m:" << endl << m << endl;
|
||||
cout << "Here is the sum of each row:" << endl << m.rowwise().sum() << endl;
|
||||
cout << "Here is the maximum absolute value of each row:"
|
||||
<< endl << m.cwise().abs().rowwise().maxCoeff() << endl;
|
||||
<< endl << m.cwiseAbs().rowwise().maxCoeff() << endl;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MatrixXi m(3, 3);
|
||||
m << 1, 2, 3,
|
||||
4, 5, 6,
|
||||
m << 1, 2, 3,
|
||||
4, 5, 6,
|
||||
7, 8, 9;
|
||||
m = (m.cwise() >= 5).select(-m, m);
|
||||
m = (m.array() >= 5).select(-m, m);
|
||||
cout << m << endl;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Matrix3d m = Matrix3d::Random();
|
||||
cout << "Here is the matrix m:" << endl << m << endl;
|
||||
cout << "Here is the count of elements larger or equal than 0.5 of each row:" << endl << (m.cwise() >= 0.5).rowwise().count() << endl;
|
||||
cout << "Here is the count of elements larger or equal than 0.5 of each row:" << endl << (m.array() >= 0.5).rowwise().count() << endl;
|
||||
|
||||
Reference in New Issue
Block a user