Add examples for API documentation of MatrixBase::cwiseXxx() methods.

This commit is contained in:
Jitse Niesen 2010-07-23 20:32:33 +01:00
parent 072ee3c07d
commit 2b5a0060b4
10 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,4 @@
MatrixXd m(2,3);
m << 2, -4, 6,
-5, 1, 0;
cout << m.cwiseAbs() << endl;

View File

@ -0,0 +1,4 @@
MatrixXd m(2,3);
m << 2, -4, 6,
-5, 1, 0;
cout << m.cwiseAbs2() << endl;

View File

@ -0,0 +1,7 @@
MatrixXi m(2,2);
m << 1, 0,
1, 1;
cout << "Comparing m with identity matrix:" << endl;
cout << m.cwiseEqual(MatrixXi::Identity(2,2)) << endl;
int count = m.cwiseEqual(MatrixXi::Identity(2,2)).count();
cout << "Number of coefficients that are equal: " << count << endl;

View File

@ -0,0 +1,4 @@
MatrixXd m(2,3);
m << 2, 0.5, 1,
3, 0.25, 1;
cout << m.cwiseInverse() << endl;

View File

@ -0,0 +1,2 @@
Vector3d v(2,3,4), w(4,2,3);
cout << v.cwiseMax(w) << endl;

View File

@ -0,0 +1,2 @@
Vector3d v(2,3,4), w(4,2,3);
cout << v.cwiseMin(w) << endl;

View File

@ -0,0 +1,7 @@
MatrixXi m(2,2);
m << 1, 0,
1, 1;
cout << "Comparing m with identity matrix:" << endl;
cout << m.cwiseNotEqual(MatrixXi::Identity(2,2)) << endl;
int count = m.cwiseNotEqual(MatrixXi::Identity(2,2)).count();
cout << "Number of coefficients that are not equal: " << count << endl;

View File

@ -0,0 +1,4 @@
Matrix3i a = Matrix3i::Random(), b = Matrix3i::Random();
Matrix3i c = a.cwiseProduct(b);
cout << "a:\n" << a << "\nb:\n" << b << "\nc:\n" << c << endl;

View File

@ -0,0 +1,2 @@
Vector3d v(2,3,4), w(4,2,3);
cout << v.cwiseQuotient(w) << endl;

View File

@ -0,0 +1,2 @@
Vector3d v(1,2,4);
cout << v.cwiseSqrt() << endl;