diff options
author | 2010-06-28 13:30:10 +0200 | |
---|---|---|
committer | 2010-06-28 13:30:10 +0200 | |
commit | dbefd7aafbe1f245ac9edc3c88444a19ef2d7367 (patch) | |
tree | 6a999f898458f1d2a961260517dfc016d35fcd80 /doc | |
parent | 768bdd08c86bbdb7d577859bdf11687a6f57bbc3 (diff) |
* update redux section
* fix output precision to 3 for the snippets
Diffstat (limited to 'doc')
-rw-r--r-- | doc/C01_TutorialCore.dox | 2 | ||||
-rw-r--r-- | doc/C02_TutorialMatrixArithmetic.dox | 69 | ||||
-rw-r--r-- | doc/QuickReference.dox | 4 | ||||
-rw-r--r-- | doc/examples/tut_arithmetic_redux_basic.cpp | 16 | ||||
-rw-r--r-- | doc/snippets/compile_snippet.cpp.in | 1 | ||||
-rw-r--r-- | doc/snippets/tut_arithmetic_redux_minmax.cpp | 10 | ||||
-rw-r--r-- | doc/snippets/tut_arithmetic_transpose_aliasing.cpp | 5 | ||||
-rw-r--r-- | doc/snippets/tut_arithmetic_transpose_inplace.cpp | 2 |
8 files changed, 58 insertions, 51 deletions
diff --git a/doc/C01_TutorialCore.dox b/doc/C01_TutorialCore.dox index 79705aa9d..242a70ed3 100644 --- a/doc/C01_TutorialCore.dox +++ b/doc/C01_TutorialCore.dox @@ -3,6 +3,8 @@ namespace Eigen { /** \page TutorialCore Tutorial 1/4 - Core features \ingroup Tutorial +<p style="font-size:2em"> WARNING this page is deprecated, and will be removed soon, don't look at it :) </p> + <div class="eimainmenu">\ref index "Overview" | \b Core \b features | \ref TutorialGeometry "Geometry" diff --git a/doc/C02_TutorialMatrixArithmetic.dox b/doc/C02_TutorialMatrixArithmetic.dox index 55aab961e..740f8c6ec 100644 --- a/doc/C02_TutorialMatrixArithmetic.dox +++ b/doc/C02_TutorialMatrixArithmetic.dox @@ -143,53 +143,28 @@ When using complex numbers, Eigen's dot product is conjugate-linear in the first second variable. \section TutorialArithmeticRedux Basic arithmetic reduction operations -Eigen also provides some reduction operations to obtain values such as the sum or the maximum -or minimum of all the coefficients in a given matrix or vector. - -TODO: convert this from table format to tutorial/examples format. - -<table class="tutorial_code" align="center"> -<tr><td align="center">\b Reduction \b operation</td><td align="center">\b Usage \b example</td></tr> -<tr><td> -Sum of all the coefficients in a matrix</td><td>\code -MatrixXf m; -float totalSum = m.sum();\endcode</td></tr> -<tr><td> -Maximum coefficient in a matrix</td><td>\code -MatrixXf m; -int row, col; - -// minimum value will be stored in minValue -// and the row and column where it was found in row and col, -// (these two parameters are optional) -float minValue = m.minCoeff(&row,&col);\endcode</td></tr> -<tr><td> -Maximum coefficient in a matrix</td><td>\code -MatrixXf m; -int row, col; - -// maximum value will be stored in maxValue -// and the row and column where it was found in row and col, -// (these two parameters are optional) -float maxValue = m.maxCoeff(&row,&col);\endcode</td></tr> -<tr><td> -Product between all coefficients in a matrix</td><td>\code -MatrixXf m; - -float product = m.prod();\endcode</td></tr> -<tr><td> -Mean of coefficients in a matrix</td><td>\code -MatrixXf m; - -float mean = m.mean();\endcode</td></tr> -<tr><td> -Matrix's trace</td><td>\code -MatrixXf m; - -float trace = m.trace();\endcode</td></tr> -</table> - -\subsection TutorialArithmeticValidity Validity of operations +Eigen also provides some reduction operations to reduce a given matrix or vector to a single value such as the sum (<tt>a.sum()</tt>), product (<tt>a.sum()</tt>), or the maximum (<tt>a.maxCoeff()</tt>) and minimum (<tt>a.minCoeff()</tt>) of all its coefficients. + +<table class="tutorial_code"><tr><td> +Example: \include tut_arithmetic_redux_basic.cpp +</td> +<td> +Output: \include tut_arithmetic_redux_basic.out +</td></tr></table> + +The \em trace of a matrix, as returned by the function \c trace(), is the sum of the diagonal coefficients and can also be computed as efficiently using <tt>a.diagonal().sum()</tt>, as we see later on. + +There also exist variants of the \c minCoeff and \c maxCoeff functions returning the coordinates of the respective coefficient via the arguments: + +<table class="tutorial_code"><tr><td> +Example: \include tut_arithmetic_redux_minmax.cpp +</td> +<td> +Output: \include tut_arithmetic_redux_minmax.out +</td></tr></table> + + +\section TutorialArithmeticValidity Validity of operations Eigen checks the validity of the operations that you perform. When possible, it checks them at compile-time, producing compilation errors. These error messages can be long and ugly, but Eigen writes the important message in UPPERCASE_LETTERS_SO_IT_STANDS_OUT. For example: diff --git a/doc/QuickReference.dox b/doc/QuickReference.dox index fd08a4be0..e24c4f00f 100644 --- a/doc/QuickReference.dox +++ b/doc/QuickReference.dox @@ -35,6 +35,7 @@ namespace Eigen { <a href="#" class="top">top</a> \section QuickRef_Types Array, matrix and vector types + \b Recall: Eigen provides two kinds of dense objects: mathematical matrices and vectors which are both represented by the template class Matrix, and general 1D and 2D arrays represented by the template class Array: \code typedef Matrix<Scalar, RowsAtCompileTime, ColsAtCompileTime, Options> MyMatrixType; @@ -87,7 +88,6 @@ In the rest of this document we will use the following symbols to emphasize the \li <a name="matrixonly"><a/>\matrixworld linear algebra matrix and vector only \li <a name="arrayonly"><a/>\arrayworld array objects only - \subsection QuickRef_Basics Basic matrix manipulation <table class="tutorial_code"> @@ -371,7 +371,7 @@ Coefficient-wise operators for matrices and vectors: <tr><td>\code mat1.cwiseMin(mat2) mat1.cwiseMax(mat2) -mat1.cwiseAbs2() +mat1.cwiseAbs2() mat1.cwiseAbs() mat1.cwiseSqrt() mat1.cwiseProduct(mat2) diff --git a/doc/examples/tut_arithmetic_redux_basic.cpp b/doc/examples/tut_arithmetic_redux_basic.cpp new file mode 100644 index 000000000..5632fb52e --- /dev/null +++ b/doc/examples/tut_arithmetic_redux_basic.cpp @@ -0,0 +1,16 @@ +#include <iostream> +#include <Eigen/Dense> + +using namespace std; +int main() +{ + Eigen::Matrix2d mat; + mat << 1, 2, + 3, 4; + cout << "Here is mat.sum(): " << mat.sum() << endl; + cout << "Here is mat.prod(): " << mat.prod() << endl; + cout << "Here is mat.mean(): " << mat.mean() << endl; + cout << "Here is mat.minCoeff(): " << mat.minCoeff() << endl; + cout << "Here is mat.maxCoeff(): " << mat.maxCoeff() << endl; + cout << "Here is mat.trace(): " << mat.trace() << endl; +} diff --git a/doc/snippets/compile_snippet.cpp.in b/doc/snippets/compile_snippet.cpp.in index 5cfcbfe38..561d5f685 100644 --- a/doc/snippets/compile_snippet.cpp.in +++ b/doc/snippets/compile_snippet.cpp.in @@ -11,6 +11,7 @@ using namespace std; int main(int, char**) { + cout.precision(3); ${snippet_source_code} return 0; } diff --git a/doc/snippets/tut_arithmetic_redux_minmax.cpp b/doc/snippets/tut_arithmetic_redux_minmax.cpp new file mode 100644 index 000000000..b7b71b077 --- /dev/null +++ b/doc/snippets/tut_arithmetic_redux_minmax.cpp @@ -0,0 +1,10 @@ + Matrix3f m = Matrix3f::Random(); + std::ptrdiff_t i, j; + float minOfM = m.minCoeff(&i,&j); + cout << "Here is the matrix m:\n" << m << endl; + cout << "Its minimum coefficient (" << minOfM << ") is at position (" << i << "," << j << ")\n\n"; + + RowVector4i v = RowVector4i::Random(); + int maxOfV = v.maxCoeff(&i); + cout << "Here is the vector v: " << v << endl; + cout << "Its maximum coefficient (" << maxOfV << ") is at position " << i << endl;
\ No newline at end of file diff --git a/doc/snippets/tut_arithmetic_transpose_aliasing.cpp b/doc/snippets/tut_arithmetic_transpose_aliasing.cpp index dec2634a2..c8e4746d0 100644 --- a/doc/snippets/tut_arithmetic_transpose_aliasing.cpp +++ b/doc/snippets/tut_arithmetic_transpose_aliasing.cpp @@ -1,4 +1,5 @@ Matrix2i a; a << 1, 2, 3, 4; cout << "Here is the matrix a:\n" << a << endl; -a = a.transpose(); // fails -cout << "and the aliasing effect:\n" << a << endl;
\ No newline at end of file + +a = a.transpose(); // !!! do NOT do this !!! +cout << "and the result of the aliasing effect:\n" << a << endl;
\ No newline at end of file diff --git a/doc/snippets/tut_arithmetic_transpose_inplace.cpp b/doc/snippets/tut_arithmetic_transpose_inplace.cpp index c46bd5b1a..7a069ff23 100644 --- a/doc/snippets/tut_arithmetic_transpose_inplace.cpp +++ b/doc/snippets/tut_arithmetic_transpose_inplace.cpp @@ -1,4 +1,6 @@ MatrixXf a(2,3); a << 1, 2, 3, 4, 5, 6; cout << "Here is the initial matrix a:\n" << a << endl; + + a.transposeInPlace(); cout << "and after being transposed:\n" << a << endl;
\ No newline at end of file |