| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | namespace Eigen { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big changes in Eigen documentation:
- Organize the documentation into "chapters".
  - Each chapter include many documentation pages, reference pages organized as modules, and a quick reference page.
  - The "Chapters" tree is created using the defgroup/ingroup mechanism, even for the documentation pages (i.e., .dox files for which I added an \eigenManualPage macro that we can switch between \page or \defgroup ).
  - Add a "General topics" entry for all pages that do not fit well in the previous "chapters".
  - The highlevel struture is managed by a new eigendoxy_layout.xml file.
- remove the "index" and quite useless pages (namespace list, class hierarchy, member list, file list, etc.)
- add the javascript search-engine.
- add the "treeview" panel.
- remove \tableofcontents (replace them by a custom \eigenAutoToc macro to be able to easily re-enable if needed).
- add javascript to automatically generate a TOC from the h1/h2 tags of the current page, and put the TOC in the left side panel.
- overload various javascript function generated by doxygen to:
  - remove the root of the treeview
  - remove links to section/subsection from the treeview
  - automatically expand the "Chapters" section
  - automatically expand the current section
  - adjust the height of the treeview to take into account the TOC
- always use the default .css file, eigendoxy.css now only includes our modifications
- use Doxyfile to specify our logo
- remove cross references to unsupported modules (temporarily)
											
										 
											2013-01-05 23:37:11 +08:00
										 |  |  | /** \eigenManualPage TutorialAdvancedInitialization Advanced initialization | 
					
						
							| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | This page discusses several advanced methods for initializing matrices. It gives more details on the | 
					
						
							|  |  |  | comma-initializer, which was introduced before. It also explains how to get special matrices such as the | 
					
						
							|  |  |  | identity matrix and the zero matrix. | 
					
						
							| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Big changes in Eigen documentation:
- Organize the documentation into "chapters".
  - Each chapter include many documentation pages, reference pages organized as modules, and a quick reference page.
  - The "Chapters" tree is created using the defgroup/ingroup mechanism, even for the documentation pages (i.e., .dox files for which I added an \eigenManualPage macro that we can switch between \page or \defgroup ).
  - Add a "General topics" entry for all pages that do not fit well in the previous "chapters".
  - The highlevel struture is managed by a new eigendoxy_layout.xml file.
- remove the "index" and quite useless pages (namespace list, class hierarchy, member list, file list, etc.)
- add the javascript search-engine.
- add the "treeview" panel.
- remove \tableofcontents (replace them by a custom \eigenAutoToc macro to be able to easily re-enable if needed).
- add javascript to automatically generate a TOC from the h1/h2 tags of the current page, and put the TOC in the left side panel.
- overload various javascript function generated by doxygen to:
  - remove the root of the treeview
  - remove links to section/subsection from the treeview
  - automatically expand the "Chapters" section
  - automatically expand the current section
  - adjust the height of the treeview to take into account the TOC
- always use the default .css file, eigendoxy.css now only includes our modifications
- use Doxyfile to specify our logo
- remove cross references to unsupported modules (temporarily)
											
										 
											2013-01-05 23:37:11 +08:00
										 |  |  | \eigenAutoToc | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | \section TutorialAdvancedInitializationCommaInitializer The comma initializer | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Eigen offers a comma initializer syntax which allows the user to easily set all the coefficients of a matrix, | 
					
						
							|  |  |  | vector or array. Simply list the coefficients, starting at the top-left corner and moving from left to right | 
					
						
							|  |  |  | and from the top to the bottom. The size of the object needs to be specified beforehand. If you list too few | 
					
						
							|  |  |  | or too many coefficients, Eigen will complain. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include Tutorial_commainit_01.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | \verbinclude Tutorial_commainit_01.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-13 07:17:31 +08:00
										 |  |  | Moreover, the elements of the initialization list may themselves be vectors or matrices. A common use is | 
					
						
							|  |  |  | to join vectors or matrices together. For example, here is how to join two row vectors together. Remember | 
					
						
							|  |  |  | that you have to set the size before you can use the comma initializer. | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							| 
									
										
										
										
											2011-02-13 07:17:31 +08:00
										 |  |  | \include Tutorial_AdvancedInitialization_Join.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2011-02-13 07:17:31 +08:00
										 |  |  | \verbinclude Tutorial_AdvancedInitialization_Join.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-13 07:17:31 +08:00
										 |  |  | We can use the same technique to initialize matrices with a block structure. | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include Tutorial_AdvancedInitialization_Block.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | \verbinclude Tutorial_AdvancedInitialization_Block.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-13 07:17:31 +08:00
										 |  |  | The comma initializer can also be used to fill block expressions such as <tt>m.row(i)</tt>. Here is a more | 
					
						
							|  |  |  | complicated way to get the same result as in the first example above: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include Tutorial_commainit_01b.cpp | 
					
						
							|  |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							|  |  |  | \verbinclude Tutorial_commainit_01b.out | 
					
						
							|  |  |  | </td></tr></table> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | \section TutorialAdvancedInitializationSpecialMatrices Special matrices and arrays | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The Matrix and Array classes have static methods like \link DenseBase::Zero() Zero()\endlink, which can be | 
					
						
							|  |  |  | used to initialize all coefficients to zero. There are three variants. The first variant takes no arguments | 
					
						
							|  |  |  | and can only be used for fixed-size objects. If you want to initialize a dynamic-size object to zero, you need | 
					
						
							|  |  |  | to specify the size. Thus, the second variant requires one argument and can be used for one-dimensional | 
					
						
							|  |  |  | dynamic-size objects, while the third variant requires two arguments and can be used for two-dimensional | 
					
						
							|  |  |  | objects. All three variants are illustrated in the following example: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include Tutorial_AdvancedInitialization_Zero.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | \verbinclude Tutorial_AdvancedInitialization_Zero.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-18 21:09:30 +08:00
										 |  |  | Similarly, the static method \link DenseBase::Constant() Constant\endlink(value) sets all coefficients to \c value. | 
					
						
							|  |  |  | If the size of the object needs to be specified, the additional arguments go before the \c value | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | argument, as in <tt>MatrixXd::Constant(rows, cols, value)</tt>. The method \link DenseBase::Random() Random() | 
					
						
							|  |  |  | \endlink fills the matrix or array with random coefficients. The identity matrix can be obtained by calling | 
					
						
							|  |  |  | \link MatrixBase::Identity() Identity()\endlink; this method is only available for Matrix, not for Array, | 
					
						
							|  |  |  | because "identity matrix" is a linear algebra concept.  The method | 
					
						
							| 
									
										
										
										
											2011-01-28 23:00:34 +08:00
										 |  |  | \link DenseBase::LinSpaced LinSpaced\endlink(size, low, high) is only available for vectors and | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | one-dimensional arrays; it yields a vector of the specified size whose coefficients are equally spaced between | 
					
						
							|  |  |  | \c low and \c high. The method \c LinSpaced() is illustrated in the following example, which prints a table | 
					
						
							|  |  |  | with angles in degrees, the corresponding angle in radians, and their sine and cosine. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include Tutorial_AdvancedInitialization_LinSpaced.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | \verbinclude Tutorial_AdvancedInitialization_LinSpaced.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This example shows that objects like the ones returned by LinSpaced() can be assigned to variables (and | 
					
						
							|  |  |  | expressions). Eigen defines utility functions like \link DenseBase::setZero() setZero()\endlink,  | 
					
						
							| 
									
										
										
										
											2010-07-26 03:29:07 +08:00
										 |  |  | \link MatrixBase::setIdentity() \endlink and \link DenseBase::setLinSpaced() \endlink to do this | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | conveniently. The following example contrasts three ways to construct the matrix | 
					
						
							|  |  |  | \f$ J = \bigl[ \begin{smallmatrix} O & I \\ I & O \end{smallmatrix} \bigr] \f$: using static methods and | 
					
						
							|  |  |  | assignment, using static methods and the comma-initializer, or using the setXxx() methods. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include Tutorial_AdvancedInitialization_ThreeWays.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | \verbinclude Tutorial_AdvancedInitialization_ThreeWays.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | A summary of all pre-defined matrix, vector and array objects can be found in the \ref QuickRefPage. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-18 21:09:30 +08:00
										 |  |  | \section TutorialAdvancedInitializationTemporaryObjects Usage as temporary objects | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-18 21:09:30 +08:00
										 |  |  | As shown above, static methods as Zero() and Constant() can be used to initialize variables at the time of | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | declaration or at the right-hand side of an assignment operator. You can think of these methods as returning a | 
					
						
							| 
									
										
										
										
											2010-10-18 21:09:30 +08:00
										 |  |  | matrix or array; in fact, they return so-called \ref TopicEigenExpressionTemplates "expression objects" which | 
					
						
							|  |  |  | evaluate to a matrix or array when needed, so that this syntax does not incur any overhead. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | These expressions can also be used as a temporary object. The second example in | 
					
						
							|  |  |  | the \ref GettingStarted guide, which we reproduce here, already illustrates this. | 
					
						
							| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include QuickStart_example2_dynamic.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | \verbinclude QuickStart_example2_dynamic.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-18 21:09:30 +08:00
										 |  |  | The expression <tt>m + MatrixXf::Constant(3,3,1.2)</tt> constructs the 3-by-3 matrix expression with all its coefficients | 
					
						
							|  |  |  | equal to 1.2 plus the corresponding coefficient of \a m. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The comma-initializer, too, can also be used to construct temporary objects. The following example constructs a random | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | matrix of size 2-by-3, and then multiplies this matrix on the left with  | 
					
						
							|  |  |  | \f$ \bigl[ \begin{smallmatrix} 0 & 1 \\ 1 & 0 \end{smallmatrix} \bigr] \f$. | 
					
						
							| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | <table class="example"> | 
					
						
							|  |  |  | <tr><th>Example:</th><th>Output:</th></tr> | 
					
						
							|  |  |  | <tr><td> | 
					
						
							|  |  |  | \include Tutorial_AdvancedInitialization_CommaTemporary.cpp | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td> | 
					
						
							|  |  |  | <td> | 
					
						
							| 
									
										
										
										
											2010-10-19 17:40:49 +08:00
										 |  |  | \verbinclude Tutorial_AdvancedInitialization_CommaTemporary.out | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | </td></tr></table> | 
					
						
							| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-22 22:53:21 +08:00
										 |  |  | The \link CommaInitializer::finished() finished() \endlink method is necessary here to get the actual matrix | 
					
						
							|  |  |  | object once the comma initialization of our temporary submatrix is done. | 
					
						
							| 
									
										
										
										
											2010-06-27 02:00:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |