mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 17:40:05 +08:00
move tables from class "tutorial_code" to "example"
also remove a align="center" in the Aliasing page -- it doesn't make sense to have 1 centered table page when all others are left aligned.
This commit is contained in:
parent
ca4bd5851c
commit
9fa54d4cc9
@ -45,12 +45,12 @@ The following three statements sets the other three entries. The final line outp
|
|||||||
|
|
||||||
Here is another example, which combines matrices with vectors. Concentrate on the left-hand program for now; we will talk about the right-hand program later.
|
Here is another example, which combines matrices with vectors. Concentrate on the left-hand program for now; we will talk about the right-hand program later.
|
||||||
|
|
||||||
<table class="tutorial_code"><tr><td>
|
<table class="example">
|
||||||
Size set at run time:
|
<tr><th>Size set at run time:</th><th>Size set at compile time:</th></tr>
|
||||||
|
<tr><td>
|
||||||
\include QuickStart_example2_dynamic.cpp
|
\include QuickStart_example2_dynamic.cpp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Size set at compile time:
|
|
||||||
\include QuickStart_example2_fixed.cpp
|
\include QuickStart_example2_fixed.cpp
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ but the following code is legal:
|
|||||||
|
|
||||||
Assignment is the action of copying a matrix into another, using \c operator=. Eigen resizes the matrix on the left-hand side automatically so that it matches the size of the matrix on the right-hand size. For example:
|
Assignment is the action of copying a matrix into another, using \c operator=. Eigen resizes the matrix on the left-hand side automatically so that it matches the size of the matrix on the right-hand size. For example:
|
||||||
|
|
||||||
<table class="tutorial_code">
|
<table class="example">
|
||||||
<tr><th>Example:</th><th>Output:</th></tr>
|
<tr><th>Example:</th><th>Output:</th></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\include tut_matrix_assignment_resizing.cpp </td>
|
<td>\include tut_matrix_assignment_resizing.cpp </td>
|
||||||
|
@ -42,12 +42,12 @@ which exactly matches our GEMM routine.
|
|||||||
\subsection GEMM_Limitations Limitations
|
\subsection GEMM_Limitations Limitations
|
||||||
Unfortunately, this simplification mechanism is not perfect yet and not all expressions which could be
|
Unfortunately, this simplification mechanism is not perfect yet and not all expressions which could be
|
||||||
handled by a single GEMM-like call are correctly detected.
|
handled by a single GEMM-like call are correctly detected.
|
||||||
<table class="tutorial_code" style="width:100%">
|
<table class="example" style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Not optimal expression</td>
|
<th>Not optimal expression</th>
|
||||||
<td>Evaluated as</td>
|
<th>Evaluated as</th>
|
||||||
<td>Optimal version (single evaluation)</td>
|
<th>Optimal version (single evaluation)</th>
|
||||||
<td>Comments</td>
|
<th>Comments</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>\code
|
<td>\code
|
||||||
|
@ -20,11 +20,13 @@ to do about it.
|
|||||||
|
|
||||||
Here is a simple example exhibiting aliasing:
|
Here is a simple example exhibiting aliasing:
|
||||||
|
|
||||||
<table class="tutorial_code"><tr><td>
|
<table class="example">
|
||||||
Example: \include TopicAliasing_block.cpp
|
<tr><th>Example</th><th>Output</th></tr>
|
||||||
|
<tr><td>
|
||||||
|
\include TopicAliasing_block.cpp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Output: \verbinclude TopicAliasing_block.out
|
\verbinclude TopicAliasing_block.out
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
||||||
The output is not what one would expect. The problem is the assignment
|
The output is not what one would expect. The problem is the assignment
|
||||||
@ -51,11 +53,13 @@ problem. This means that in general aliasing cannot be detected at compile time.
|
|||||||
some instances of aliasing, albeit at run time. The following example exhibiting aliasing was mentioned in
|
some instances of aliasing, albeit at run time. The following example exhibiting aliasing was mentioned in
|
||||||
\ref TutorialMatrixArithmetic :
|
\ref TutorialMatrixArithmetic :
|
||||||
|
|
||||||
<table class="tutorial_code"><tr><td>
|
<table class="example">
|
||||||
Example: \include tut_arithmetic_transpose_aliasing.cpp
|
<tr><th>Example</th><th>Output</th></tr>
|
||||||
|
<tr><td>
|
||||||
|
\include tut_arithmetic_transpose_aliasing.cpp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Output: \verbinclude tut_arithmetic_transpose_aliasing.out
|
\verbinclude tut_arithmetic_transpose_aliasing.out
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
||||||
Again, the output shows the aliasing issue. However, by default Eigen uses a run-time assertion to detect this
|
Again, the output shows the aliasing issue. However, by default Eigen uses a run-time assertion to detect this
|
||||||
@ -81,11 +85,13 @@ side. The function \link DenseBase::eval() eval() \endlink does precisely that.
|
|||||||
|
|
||||||
For example, here is the corrected version of the first example above:
|
For example, here is the corrected version of the first example above:
|
||||||
|
|
||||||
<table class="tutorial_code"><tr><td>
|
<table class="example">
|
||||||
Example: \include TopicAliasing_block_correct.cpp
|
<tr><th>Example</th><th>Output</th></tr>
|
||||||
|
<tr><td>
|
||||||
|
\include TopicAliasing_block_correct.cpp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Output: \verbinclude TopicAliasing_block_correct.out
|
\verbinclude TopicAliasing_block_correct.out
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
||||||
Now, \c mat(2,2) equals 5 after the assignment, as it should be.
|
Now, \c mat(2,2) equals 5 after the assignment, as it should be.
|
||||||
@ -96,19 +102,21 @@ better solution. Eigen provides the special-purpose function
|
|||||||
\link DenseBase::transposeInPlace() transposeInPlace() \endlink which replaces a matrix by its transpose.
|
\link DenseBase::transposeInPlace() transposeInPlace() \endlink which replaces a matrix by its transpose.
|
||||||
This is shown below:
|
This is shown below:
|
||||||
|
|
||||||
<table class="tutorial_code"><tr><td>
|
<table class="example">
|
||||||
Example: \include tut_arithmetic_transpose_inplace.cpp
|
<tr><th>Example</th><th>Output</th></tr>
|
||||||
|
<tr><td>
|
||||||
|
\include tut_arithmetic_transpose_inplace.cpp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Output: \verbinclude tut_arithmetic_transpose_inplace.out
|
\verbinclude tut_arithmetic_transpose_inplace.out
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
|
||||||
If an xxxInPlace() function is available, then it is best to use it, because it indicate more clearly what you
|
If an xxxInPlace() function is available, then it is best to use it, because it indicates more clearly what you
|
||||||
are doing. This may also allow Eigen to optimize more aggressively. These are some of the xxxInPlace()
|
are doing. This may also allow Eigen to optimize more aggressively. These are some of the xxxInPlace()
|
||||||
functions provided:
|
functions provided:
|
||||||
|
|
||||||
<table class="tutorial_code" align="center">
|
<table class="example">
|
||||||
<tr> <td> <b>Original function</b> </td> <td> <b>In-place function</b> </td> </tr>
|
<tr><th>Original function</th><th>In-place function</th></tr>
|
||||||
<tr> <td> MatrixBase::adjoint() </td> <td> MatrixBase::adjointInPlace() </td> </tr>
|
<tr> <td> MatrixBase::adjoint() </td> <td> MatrixBase::adjointInPlace() </td> </tr>
|
||||||
<tr> <td> DenseBase::reverse() </td> <td> DenseBase::reverseInPlace() </td> </tr>
|
<tr> <td> DenseBase::reverse() </td> <td> DenseBase::reverseInPlace() </td> </tr>
|
||||||
<tr> <td> LDLT::solve() </td> <td> LDLT::solveInPlace() </td> </tr>
|
<tr> <td> LDLT::solve() </td> <td> LDLT::solveInPlace() </td> </tr>
|
||||||
|
@ -26,11 +26,13 @@ This section will provide simple examples for different types of objects Eigen i
|
|||||||
|
|
||||||
<b> %EigenBase Example </b><br/><br/>
|
<b> %EigenBase Example </b><br/><br/>
|
||||||
Prints the dimensions of the most generic object present in Eigen. It coulde be any matrix expressions, any dense or sparse matrix and any array.
|
Prints the dimensions of the most generic object present in Eigen. It coulde be any matrix expressions, any dense or sparse matrix and any array.
|
||||||
<table class="tutorial_code"><tr><td>
|
<table class="example">
|
||||||
Example: \include function_taking_eigenbase.cpp
|
<tr><th>Example:</th><th>Output:</th></tr>
|
||||||
|
<tr><td>
|
||||||
|
\include function_taking_eigenbase.cpp
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Output: \verbinclude function_taking_eigenbase.out
|
\verbinclude function_taking_eigenbase.out
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
<b> %DenseBase Example </b><br/><br/>
|
<b> %DenseBase Example </b><br/><br/>
|
||||||
Prints a sub-block of the dense expression. Accepts any dense matrix or array expression, but no sparse objects and no special matrix classes such as DiagonalMatrix.
|
Prints a sub-block of the dense expression. Accepts any dense matrix or array expression, but no sparse objects and no special matrix classes such as DiagonalMatrix.
|
||||||
|
@ -62,7 +62,8 @@ Matrix<double, 13, 3> // Fully fixed (static allocation)
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
In most cases, you can simply use one of the convenience typedefs for \ref matrixtypedefs "matrices" and \ref arraytypedefs "arrays". Some examples:
|
In most cases, you can simply use one of the convenience typedefs for \ref matrixtypedefs "matrices" and \ref arraytypedefs "arrays". Some examples:
|
||||||
<table class="tutorial_code">
|
<table class="example">
|
||||||
|
<tr><th>Matrices</th><th>Arrays</th></tr>
|
||||||
<tr><td>\code
|
<tr><td>\code
|
||||||
Matrix<float,Dynamic,Dynamic> <=> MatrixXf
|
Matrix<float,Dynamic,Dynamic> <=> MatrixXf
|
||||||
Matrix<double,Dynamic,1> <=> VectorXd
|
Matrix<double,Dynamic,1> <=> VectorXd
|
||||||
@ -537,7 +538,8 @@ Read-write access to sub-matrices:</td></tr>
|
|||||||
|
|
||||||
\subsection QuickRef_Diagonal Diagonal matrices
|
\subsection QuickRef_Diagonal Diagonal matrices
|
||||||
|
|
||||||
<table class="tutorial_code">
|
<table class="example">
|
||||||
|
<tr><th>Operation</th><th>Code</th></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
view a vector \link MatrixBase::asDiagonal() as a diagonal matrix \endlink \n </td><td>\code
|
view a vector \link MatrixBase::asDiagonal() as a diagonal matrix \endlink \n </td><td>\code
|
||||||
mat1 = vec1.asDiagonal();\endcode
|
mat1 = vec1.asDiagonal();\endcode
|
||||||
@ -572,7 +574,8 @@ mat3 = mat1 * diag1.inverse()
|
|||||||
|
|
||||||
TriangularView gives a view on a triangular part of a dense matrix and allows to perform optimized operations on it. The opposite triangular part is never referenced and can be used to store other information.
|
TriangularView gives a view on a triangular part of a dense matrix and allows to perform optimized operations on it. The opposite triangular part is never referenced and can be used to store other information.
|
||||||
|
|
||||||
<table class="tutorial_code">
|
<table class="example">
|
||||||
|
<tr><th>Operation</th><th>Code</th></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
Reference to a triangular with optional \n
|
Reference to a triangular with optional \n
|
||||||
unit or null diagonal (read/write):
|
unit or null diagonal (read/write):
|
||||||
@ -615,7 +618,8 @@ Just as for triangular matrix, you can reference any triangular part of a square
|
|||||||
matrix and perform special and optimized operations. Again the opposite triangular part is never referenced and can be
|
matrix and perform special and optimized operations. Again the opposite triangular part is never referenced and can be
|
||||||
used to store other information.
|
used to store other information.
|
||||||
|
|
||||||
<table class="tutorial_code">
|
<table class="example">
|
||||||
|
<tr><th>Operation</th><th>Code</th></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
Conversion to a dense matrix:
|
Conversion to a dense matrix:
|
||||||
</td><td>\code
|
</td><td>\code
|
||||||
|
Loading…
Reference in New Issue
Block a user