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
+
\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.
+Eigen also provides some reduction operations to reduce a given matrix or vector to a single value such as the sum (
a.sum()), product (
a.sum()), or the maximum (
a.maxCoeff()) and minimum (
a.minCoeff()) of all its coefficients.
-TODO: convert this from table format to tutorial/examples format.
+
+Example: \include tut_arithmetic_redux_basic.cpp
+ |
+
+Output: \include tut_arithmetic_redux_basic.out
+ |
-
-\b Reduction \b operation | \b Usage \b example |
-
-Sum of all the coefficients in a matrix | \code
-MatrixXf m;
-float totalSum = m.sum();\endcode |
-
-Maximum coefficient in a matrix | \code
-MatrixXf m;
-int row, col;
+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 a.diagonal().sum(), as we see later on.
-// 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 |
-
-Maximum coefficient in a matrix | \code
-MatrixXf m;
-int row, col;
+There also exist variants of the \c minCoeff and \c maxCoeff functions returning the coordinates of the respective coefficient via the arguments:
-// 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 |
-
-Product between all coefficients in a matrix | \code
-MatrixXf m;
+
+Example: \include tut_arithmetic_redux_minmax.cpp
+ |
+
+Output: \include tut_arithmetic_redux_minmax.out
+ |
-float product = m.prod();\endcode |
-
-Mean of coefficients in a matrix | \code
-MatrixXf m;
-float mean = m.mean();\endcode |
-
-Matrix's trace | \code
-MatrixXf m;
-
-float trace = m.trace();\endcode |
-
-
-\subsection TutorialArithmeticValidity Validity of operations
+\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 {
top
\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
MyMatrixType;
@@ -87,7 +88,6 @@ In the rest of this document we will use the following symbols to emphasize the
\li \matrixworld linear algebra matrix and vector only
\li \arrayworld array objects only
-
\subsection QuickRef_Basics Basic matrix manipulation
@@ -371,7 +371,7 @@ Coefficient-wise operators for matrices and vectors:
\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
+#include
+
+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
|