<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>eigen_plugins.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <div align="left"><a href="http://www.mrpt.org/">Main MRPT website</a> > <b>C++ reference</b> </div> <div align="right"> <a href="index.html"><img border="0" src="mrpt_logo.png" alt="MRPT logo"></a> </div> <!-- Generated by Doxygen 1.7.5 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <div class="left"> <form id="FSearchBox" action="search.php" method="get"> <img id="MSearchSelect" src="search/mag.png" alt=""/> <input type="text" id="MSearchField" name="query" value="Search" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"/> </form> </div><div class="right"></div> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">eigen_plugins.h</div> </div> </div> <div class="contents"> <a href="eigen__plugins_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* +---------------------------------------------------------------------------+</span> <a name="l00002"></a>00002 <span class="comment"> | The Mobile Robot Programming Toolkit (MRPT) C++ library |</span> <a name="l00003"></a>00003 <span class="comment"> | |</span> <a name="l00004"></a>00004 <span class="comment"> | http://www.mrpt.org/ |</span> <a name="l00005"></a>00005 <span class="comment"> | |</span> <a name="l00006"></a>00006 <span class="comment"> | Copyright (C) 2005-2011 University of Malaga |</span> <a name="l00007"></a>00007 <span class="comment"> | |</span> <a name="l00008"></a>00008 <span class="comment"> | This software was written by the Machine Perception and Intelligent |</span> <a name="l00009"></a>00009 <span class="comment"> | Robotics Lab, University of Malaga (Spain). |</span> <a name="l00010"></a>00010 <span class="comment"> | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |</span> <a name="l00011"></a>00011 <span class="comment"> | |</span> <a name="l00012"></a>00012 <span class="comment"> | This file is part of the MRPT project. |</span> <a name="l00013"></a>00013 <span class="comment"> | |</span> <a name="l00014"></a>00014 <span class="comment"> | MRPT is free software: you can redistribute it and/or modify |</span> <a name="l00015"></a>00015 <span class="comment"> | it under the terms of the GNU General Public License as published by |</span> <a name="l00016"></a>00016 <span class="comment"> | the Free Software Foundation, either version 3 of the License, or |</span> <a name="l00017"></a>00017 <span class="comment"> | (at your option) any later version. |</span> <a name="l00018"></a>00018 <span class="comment"> | |</span> <a name="l00019"></a>00019 <span class="comment"> | MRPT is distributed in the hope that it will be useful, |</span> <a name="l00020"></a>00020 <span class="comment"> | but WITHOUT ANY WARRANTY; without even the implied warranty of |</span> <a name="l00021"></a>00021 <span class="comment"> | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |</span> <a name="l00022"></a>00022 <span class="comment"> | GNU General Public License for more details. |</span> <a name="l00023"></a>00023 <span class="comment"> | |</span> <a name="l00024"></a>00024 <span class="comment"> | You should have received a copy of the GNU General Public License |</span> <a name="l00025"></a>00025 <span class="comment"> | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |</span> <a name="l00026"></a>00026 <span class="comment"> | |</span> <a name="l00027"></a>00027 <span class="comment"> +---------------------------------------------------------------------------+ */</span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="comment">// -------------------------------------------------------------------------</span> <a name="l00030"></a>00030 <span class="comment">// Note: This file will be included within the body of Eigen::MatrixBase</span> <a name="l00031"></a>00031 <span class="comment">// -------------------------------------------------------------------------</span> <a name="l00032"></a>00032 <span class="keyword">public</span>:<span class="comment"></span> <a name="l00033"></a>00033 <span class="comment"> /** @name MRPT plugin: Types</span> <a name="l00034"></a>00034 <span class="comment"> * @{ */</span> <a name="l00035"></a><a class="code" href="eigen__plugins_8h.html#afd07186978da46f9908364e389f8a403">00035</a> <span class="keyword">typedef</span> Scalar <a class="code" href="eigen__plugins_8h.html#afd07186978da46f9908364e389f8a403" title="Type of the elements.">value_type</a>; <span class="comment">//!< Type of the elements</span> <a name="l00036"></a>00036 <span class="comment"></span> <span class="comment">// size is constant</span> <a name="l00037"></a><a class="code" href="eigen__plugins_8h.html#a99fb83031ce9923c84392b4e92f956b5ad4a8f9f8c603d29a20ca6f9c056dd4da">00037</a> <span class="keyword">enum</span> { <a class="code" href="eigen__plugins_8h.html#a99fb83031ce9923c84392b4e92f956b5ad4a8f9f8c603d29a20ca6f9c056dd4da">static_size</a> = RowsAtCompileTime*ColsAtCompileTime };<span class="comment"></span> <a name="l00038"></a>00038 <span class="comment"> /** @} */</span> <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="comment"></span> <a name="l00041"></a>00041 <span class="comment"> /** @name MRPT plugin: Basic iterators. These iterators are intended for 1D matrices only, i.e. column or row vectors.</span> <a name="l00042"></a>00042 <span class="comment"> * @{ */</span> <a name="l00043"></a><a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">00043</a> <span class="keyword">typedef</span> Scalar* <a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">iterator</a>; <a name="l00044"></a><a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">00044</a> <span class="keyword">typedef</span> <span class="keyword">const</span> Scalar* <a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">const_iterator</a>; <a name="l00045"></a>00045 <a name="l00046"></a><a class="code" href="eigen__plugins_8h.html#ab295fd8164bf1b1acecbcb29520d62b7">00046</a> EIGEN_STRONG_INLINE <a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">iterator</a> <a class="code" href="eigen__plugins_8h.html#ab295fd8164bf1b1acecbcb29520d62b7">begin</a>() { <span class="keywordflow">return</span> derived().data(); } <a name="l00047"></a><a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">00047</a> EIGEN_STRONG_INLINE <a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">iterator</a> <a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">end</a>() { <span class="keywordflow">return</span> &(derived().data()[<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()-1]); } <a name="l00048"></a>00048 EIGEN_STRONG_INLINE <a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">const_iterator</a> <a class="code" href="eigen__plugins_8h.html#ab295fd8164bf1b1acecbcb29520d62b7">begin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> derived().data(); } <a name="l00049"></a>00049 EIGEN_STRONG_INLINE <a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">const_iterator</a> <a class="code" href="eigen__plugins_8h.html#ade5b39864c905cbb824d0ff6eb0d888c">end</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> &(derived().data()[<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()-1]); } <a name="l00050"></a>00050 <span class="comment"></span> <a name="l00051"></a>00051 <span class="comment"> /** @} */</span> <a name="l00052"></a>00052 <a name="l00053"></a>00053 <span class="comment"></span> <a name="l00054"></a>00054 <span class="comment"> /** @name MRPT plugin: Set/get/load/save and other miscelaneous methods</span> <a name="l00055"></a>00055 <span class="comment"> * @{ */</span> <a name="l00056"></a>00056 <span class="comment"></span> <a name="l00057"></a>00057 <span class="comment"> /*! Fill all the elements with a given value */</span> <a name="l00058"></a><a class="code" href="eigen__plugins_8h.html#a57fce471b07c3c84924883b5e17e2388">00058</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a57fce471b07c3c84924883b5e17e2388">fill</a>(<span class="keyword">const</span> Scalar v) { derived().setConstant(v); } <a name="l00059"></a>00059 <span class="comment"></span> <a name="l00060"></a>00060 <span class="comment"> /*! Fill all the elements with a given value */</span> <a name="l00061"></a><a class="code" href="eigen__plugins_8h.html#a430e227498fc091226ec9d694f07ac8d">00061</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a430e227498fc091226ec9d694f07ac8d">assign</a>(<span class="keyword">const</span> Scalar v) { derived().setConstant(v); }<span class="comment"></span> <a name="l00062"></a>00062 <span class="comment"> /*! Resize to N and set all the elements to a given value */</span> <a name="l00063"></a><a class="code" href="eigen__plugins_8h.html#ae60818fcccc06ff267dd500c8a2155f7">00063</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a430e227498fc091226ec9d694f07ac8d">assign</a>(<span class="keywordtype">size_t</span> N, <span class="keyword">const</span> Scalar v) { derived().resize(N); derived().setConstant(v); } <a name="l00064"></a>00064 <span class="comment"></span> <a name="l00065"></a>00065 <span class="comment"> /** Get number of rows */</span> <a name="l00066"></a><a class="code" href="eigen__plugins_8h.html#a61275d6dcd40b0676f9a430be46ef876">00066</a> EIGEN_STRONG_INLINE <span class="keywordtype">size_t</span> <a class="code" href="eigen__plugins_8h.html#a61275d6dcd40b0676f9a430be46ef876" title="Get number of rows.">getRowCount</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rows(); }<span class="comment"></span> <a name="l00067"></a>00067 <span class="comment"> /** Get number of columns */</span> <a name="l00068"></a><a class="code" href="eigen__plugins_8h.html#a4d49034b9785c1bd62e4d4540a39066b">00068</a> EIGEN_STRONG_INLINE <span class="keywordtype">size_t</span> <a class="code" href="eigen__plugins_8h.html#a4d49034b9785c1bd62e4d4540a39066b" title="Get number of columns.">getColCount</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> cols(); } <a name="l00069"></a>00069 <span class="comment"></span> <a name="l00070"></a>00070 <span class="comment"> /** Make the matrix an identity matrix (the diagonal values can be 1.0 or any other value) */</span> <a name="l00071"></a><a class="code" href="eigen__plugins_8h.html#a7a11472b9fe01428f7a3a641deede260">00071</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a7a11472b9fe01428f7a3a641deede260" title="Make the matrix an identity matrix (the diagonal values can be 1.0 or any other value)">unit</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> nRows, <span class="keyword">const</span> Scalar diag_vals) { <a name="l00072"></a>00072 <span class="keywordflow">if</span> (diag_vals==1) <a name="l00073"></a>00073 derived().setIdentity(nRows,nRows); <a name="l00074"></a>00074 <span class="keywordflow">else</span> { <a name="l00075"></a>00075 derived().setZero(nRows,nRows); <a name="l00076"></a>00076 derived().diagonal().setConstant(diag_vals); <a name="l00077"></a>00077 } <a name="l00078"></a>00078 } <a name="l00079"></a>00079 <span class="comment"></span> <a name="l00080"></a>00080 <span class="comment"> /** Make the matrix an identity matrix */</span> <a name="l00081"></a><a class="code" href="eigen__plugins_8h.html#ad9cadcc3439e2277c50991f55fb46ceb">00081</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a7a11472b9fe01428f7a3a641deede260" title="Make the matrix an identity matrix (the diagonal values can be 1.0 or any other value)">unit</a>() { derived().setIdentity(); }<span class="comment"></span> <a name="l00082"></a>00082 <span class="comment"> /** Make the matrix an identity matrix */</span> <a name="l00083"></a><a class="code" href="eigen__plugins_8h.html#a099661ff1d800e1a14acac4857fef23a">00083</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a099661ff1d800e1a14acac4857fef23a" title="Make the matrix an identity matrix.">eye</a>() { derived().setIdentity(); } <a name="l00084"></a>00084 <span class="comment"></span> <a name="l00085"></a>00085 <span class="comment"> /** Set all elements to zero */</span> <a name="l00086"></a><a class="code" href="eigen__plugins_8h.html#a249c737f74d106ad35d54b2c361949f2">00086</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a249c737f74d106ad35d54b2c361949f2" title="Set all elements to zero.">zeros</a>() { derived().setZero(); }<span class="comment"></span> <a name="l00087"></a>00087 <span class="comment"> /** Resize and set all elements to zero */</span> <a name="l00088"></a><a class="code" href="eigen__plugins_8h.html#a2bf1b81848a7115a7129552f10b41f81">00088</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a249c737f74d106ad35d54b2c361949f2" title="Set all elements to zero.">zeros</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col) { derived().setZero(row,col); } <a name="l00089"></a>00089 <span class="comment"></span> <a name="l00090"></a>00090 <span class="comment"> /** Resize matrix and set all elements to one */</span> <a name="l00091"></a><a class="code" href="eigen__plugins_8h.html#a753bc55837e086a6aab4e67b6a89649c">00091</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a753bc55837e086a6aab4e67b6a89649c" title="Resize matrix and set all elements to one.">ones</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> col) { derived().setOnes(row,col); }<span class="comment"></span> <a name="l00092"></a>00092 <span class="comment"> /** Set all elements to one */</span> <a name="l00093"></a><a class="code" href="eigen__plugins_8h.html#aed382a83834a6cb23b6ffca7eb7d8a1f">00093</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a753bc55837e086a6aab4e67b6a89649c" title="Resize matrix and set all elements to one.">ones</a>() { derived().setOnes(); } <a name="l00094"></a>00094 <span class="comment"></span> <a name="l00095"></a>00095 <span class="comment"> /** Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical applications)</span> <a name="l00096"></a>00096 <span class="comment"> * VERY IMPORTANT WARNING: You must be aware of the memory layout, either Column or Row-major ordering.</span> <a name="l00097"></a>00097 <span class="comment"> */</span> <a name="l00098"></a><a class="code" href="eigen__plugins_8h.html#a75979a41a239d9510ce581f3e57b5758">00098</a> EIGEN_STRONG_INLINE Scalar * <a class="code" href="eigen__plugins_8h.html#a75979a41a239d9510ce581f3e57b5758" title="Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical ap...">get_unsafe_row</a>(<span class="keywordtype">size_t</span> row) { <span class="keywordflow">return</span> &derived().coeffRef(row,0); } <a name="l00099"></a>00099 EIGEN_STRONG_INLINE <span class="keyword">const</span> Scalar* <a class="code" href="eigen__plugins_8h.html#a75979a41a239d9510ce581f3e57b5758" title="Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in time critical ap...">get_unsafe_row</a>(<span class="keywordtype">size_t</span> row)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> &derived().coeff(row,0); } <a name="l00100"></a>00100 <span class="comment"></span> <a name="l00101"></a>00101 <span class="comment"> /** Read-only access to one element (Use with caution, bounds are not checked!) */</span> <a name="l00102"></a><a class="code" href="eigen__plugins_8h.html#a7ee1e2b5233fb9717bf66fa1a43229a5">00102</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a7ee1e2b5233fb9717bf66fa1a43229a5" title="Read-only access to one element (Use with caution, bounds are not checked!)">get_unsafe</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> col)<span class="keyword"> const </span>{ <a name="l00103"></a>00103 <span class="preprocessor">#ifdef _DEBUG</span> <a name="l00104"></a>00104 <span class="preprocessor"></span> <span class="keywordflow">return</span> derived()(row,col); <a name="l00105"></a>00105 <span class="preprocessor">#else</span> <a name="l00106"></a>00106 <span class="preprocessor"></span> <span class="keywordflow">return</span> derived().coeff(row,col); <a name="l00107"></a>00107 <span class="preprocessor">#endif</span> <a name="l00108"></a>00108 <span class="preprocessor"></span> }<span class="comment"></span> <a name="l00109"></a>00109 <span class="comment"> /** Reference access to one element (Use with caution, bounds are not checked!) */</span> <a name="l00110"></a>00110 EIGEN_STRONG_INLINE Scalar& <a class="code" href="eigen__plugins_8h.html#a7ee1e2b5233fb9717bf66fa1a43229a5" title="Read-only access to one element (Use with caution, bounds are not checked!)">get_unsafe</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> col) { <a name="l00111"></a>00111 <span class="preprocessor">#ifdef _DEBUG</span> <a name="l00112"></a>00112 <span class="preprocessor"></span> <span class="keywordflow">return</span> derived()(row,col); <a name="l00113"></a>00113 <span class="preprocessor">#endif</span> <a name="l00114"></a>00114 <span class="preprocessor"></span> <span class="keywordflow">return</span> derived().coeffRef(row,col); <a name="l00115"></a>00115 }<span class="comment"></span> <a name="l00116"></a>00116 <span class="comment"> /** Sets an element (Use with caution, bounds are not checked!) */</span> <a name="l00117"></a><a class="code" href="eigen__plugins_8h.html#a49571dc3efee6a1c8acb8e91150583ce">00117</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a49571dc3efee6a1c8acb8e91150583ce" title="Sets an element (Use with caution, bounds are not checked!)">set_unsafe</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row, <span class="keyword">const</span> <span class="keywordtype">size_t</span> col, <span class="keyword">const</span> Scalar val) { <a name="l00118"></a>00118 <span class="preprocessor">#ifdef _DEBUG</span> <a name="l00119"></a>00119 <span class="preprocessor"></span> derived()(row,col) = val; <a name="l00120"></a>00120 <span class="preprocessor">#endif</span> <a name="l00121"></a>00121 <span class="preprocessor"></span> derived().coeffRef(row,col) = val; <a name="l00122"></a>00122 } <a name="l00123"></a>00123 <span class="comment"></span> <a name="l00124"></a>00124 <span class="comment"> /** Insert an element at the end of the container (for 1D vectors/arrays) */</span> <a name="l00125"></a><a class="code" href="eigen__plugins_8h.html#a9d57842d20d6813ae39cc88859d6f3c8">00125</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a9d57842d20d6813ae39cc88859d6f3c8" title="Insert an element at the end of the container (for 1D vectors/arrays)">push_back</a>(Scalar val) <a name="l00126"></a>00126 { <a name="l00127"></a>00127 <span class="keyword">const</span> Index N = <a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>(); <a name="l00128"></a>00128 derived().conservativeResize(N+1); <a name="l00129"></a>00129 coeffRef(N) = val; <a name="l00130"></a>00130 } <a name="l00131"></a>00131 <a name="l00132"></a><a class="code" href="eigen__plugins_8h.html#ab5beed52769c21a10fff9af4b0b85b4b">00132</a> EIGEN_STRONG_INLINE <span class="keywordtype">bool</span> <a class="code" href="eigen__plugins_8h.html#ab5beed52769c21a10fff9af4b0b85b4b">isSquare</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> cols()==rows(); } <a name="l00133"></a><a class="code" href="eigen__plugins_8h.html#a1a3ece0f4cde1ebf5e4e92373d4743fe">00133</a> EIGEN_STRONG_INLINE <span class="keywordtype">bool</span> <a class="code" href="eigen__plugins_8h.html#a1a3ece0f4cde1ebf5e4e92373d4743fe">isSingular</a>(<span class="keyword">const</span> Scalar absThreshold = 0)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="group__metric__grp.html#gaf15608f8914516f8d949a8c053d55021">std::abs</a>(derived().determinant())<absThreshold; } <a name="l00134"></a>00134 <span class="comment"></span> <a name="l00135"></a>00135 <span class="comment"> /** Read a matrix from a string in Matlab-like format, for example "[1 0 2; 0 4 -1]"</span> <a name="l00136"></a>00136 <span class="comment"> * The string must start with '[' and end with ']'. Rows are separated by semicolons ';' and</span> <a name="l00137"></a>00137 <span class="comment"> * columns in each row by one or more whitespaces ' ', commas ',' or tabs '\t'.</span> <a name="l00138"></a>00138 <span class="comment"> *</span> <a name="l00139"></a>00139 <span class="comment"> * This format is also used for CConfigFile::read_matrix.</span> <a name="l00140"></a>00140 <span class="comment"> *</span> <a name="l00141"></a>00141 <span class="comment"> * This template method can be instantiated for matrices of the types: int, long, unsinged int, unsigned long, float, double, long double</span> <a name="l00142"></a>00142 <span class="comment"> *</span> <a name="l00143"></a>00143 <span class="comment"> * \return true on success. false if the string is malformed, and then the matrix will be resized to 0x0.</span> <a name="l00144"></a>00144 <span class="comment"> * \sa inMatlabFormat, CConfigFile::read_matrix</span> <a name="l00145"></a>00145 <span class="comment"> */</span> <a name="l00146"></a>00146 <span class="keywordtype">bool</span> <a class="code" href="eigen__plugins_8h.html#a2cef7b6558f3749d76a8a6b551a769f4" title="Read a matrix from a string in Matlab-like format, for example "[1 0 2; 0 4 -1]" The string must st...">fromMatlabStringFormat</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &s, <span class="keywordtype">bool</span> dumpErrorMsgToStdErr = <span class="keyword">true</span>); <a name="l00147"></a>00147 <span class="comment">// Method implemented in eigen_plugins_impl.h</span> <a name="l00148"></a>00148 <span class="comment"></span> <a name="l00149"></a>00149 <span class="comment"> /** Dump matrix in matlab format.</span> <a name="l00150"></a>00150 <span class="comment"> * This template method can be instantiated for matrices of the types: int, long, unsinged int, unsigned long, float, double, long double</span> <a name="l00151"></a>00151 <span class="comment"> * \sa fromMatlabStringFormat</span> <a name="l00152"></a>00152 <span class="comment"> */</span> <a name="l00153"></a>00153 std::string <a class="code" href="eigen__plugins_8h.html#a4a8ae8c8ac821391e46088d63e30ef6e" title="Dump matrix in matlab format.">inMatlabFormat</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> decimal_digits = 6) <span class="keyword">const</span>; <a name="l00154"></a>00154 <span class="comment">// Method implemented in eigen_plugins_impl.h</span> <a name="l00155"></a>00155 <span class="comment"></span> <a name="l00156"></a>00156 <span class="comment"> /** Save matrix to a text file, compatible with MATLAB text format (see also the methods of matrix classes themselves).</span> <a name="l00157"></a>00157 <span class="comment"> * \param theMatrix It can be a CMatrixTemplate or a CMatrixFixedNumeric.</span> <a name="l00158"></a>00158 <span class="comment"> * \param file The target filename.</span> <a name="l00159"></a>00159 <span class="comment"> * \param fileFormat See TMatrixTextFileFormat. The format of the numbers in the text file.</span> <a name="l00160"></a>00160 <span class="comment"> * \param appendMRPTHeader Insert this header to the file "% File generated by MRPT. Load with MATLAB with: VAR=load(FILENAME);"</span> <a name="l00161"></a>00161 <span class="comment"> * \param userHeader Additional text to be written at the head of the file. Typically MALAB comments "% This file blah blah". Final end-of-line is not needed.</span> <a name="l00162"></a>00162 <span class="comment"> * \sa loadFromTextFile, CMatrixTemplate::inMatlabFormat, SAVE_MATRIX</span> <a name="l00163"></a>00163 <span class="comment"> */</span> <a name="l00164"></a>00164 <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#abea6659e38ab7a50b625ea1a4af3ec72" title="Save matrix to a text file, compatible with MATLAB text format (see also the methods of matrix classe...">saveToTextFile</a>( <a name="l00165"></a>00165 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &file, <a name="l00166"></a>00166 <a class="code" href="namespacemrpt_1_1math.html#a5c655254dc91e1e5e5b7e43ab7572d85">mrpt::math::TMatrixTextFileFormat</a> fileFormat = <a class="code" href="namespacemrpt_1_1math.html#a5c655254dc91e1e5e5b7e43ab7572d85a40e11335e625d349cfb19366b9d23e04" title="engineering format 'e'">mrpt::math::MATRIX_FORMAT_ENG</a>, <a name="l00167"></a>00167 <span class="keywordtype">bool</span> appendMRPTHeader = <span class="keyword">false</span>, <a name="l00168"></a>00168 <span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &userHeader = <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a>() <a name="l00169"></a>00169 ) <span class="keyword">const</span>; <a name="l00170"></a>00170 <span class="comment">// Method implemented in eigen_plugins_impl.h</span> <a name="l00171"></a>00171 <span class="comment"></span> <a name="l00172"></a>00172 <span class="comment"> /** Load matrix from a text file, compatible with MATLAB text format.</span> <a name="l00173"></a>00173 <span class="comment"> * Lines starting with '%' or '#' are interpreted as comments and ignored.</span> <a name="l00174"></a>00174 <span class="comment"> * \sa saveToTextFile, fromMatlabStringFormat</span> <a name="l00175"></a>00175 <span class="comment"> */</span> <a name="l00176"></a>00176 <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ad3c68c35368d8a0254192e3c34ea5f61" title="Load matrix from a text file, compatible with MATLAB text format.">loadFromTextFile</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1string.html" title="STL class.">std::string</a> &file); <a name="l00177"></a>00177 <span class="comment">// Method implemented in eigen_plugins_impl.h</span> <a name="l00178"></a>00178 <span class="comment"></span> <a name="l00179"></a>00179 <span class="comment"> //! \overload</span> <a name="l00180"></a>00180 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ad3c68c35368d8a0254192e3c34ea5f61" title="Load matrix from a text file, compatible with MATLAB text format.">loadFromTextFile</a>(<a class="code" href="classstd_1_1istream.html" title="STL class.">std::istream</a> &_input_text_stream); <a name="l00181"></a>00181 <span class="comment">// Method implemented in eigen_plugins_impl.h</span> <a name="l00182"></a>00182 <a name="l00183"></a><a class="code" href="eigen__plugins_8h.html#a96151b602836b52bc85171af9d5c56e7">00183</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a96151b602836b52bc85171af9d5c56e7">multiplyColumnByScalar</a>(<span class="keywordtype">size_t</span> c, Scalar s) { derived().col(c)*=s; } <a name="l00184"></a><a class="code" href="eigen__plugins_8h.html#a671005d4630e5b00468c10b62832ac8a">00184</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a671005d4630e5b00468c10b62832ac8a">multiplyRowByScalar</a>(<span class="keywordtype">size_t</span> r, Scalar s) { derived().row(r)*=s; } <a name="l00185"></a>00185 <a name="l00186"></a><a class="code" href="eigen__plugins_8h.html#ae464358652aea0d45e931665fd2beaec">00186</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ae464358652aea0d45e931665fd2beaec">swapCols</a>(<span class="keywordtype">size_t</span> i1,<span class="keywordtype">size_t</span> i2) { derived().col(i1).swap( derived().col(i2) ); } <a name="l00187"></a><a class="code" href="eigen__plugins_8h.html#a2f02ee28067c59514a36f45f4cd73d49">00187</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a2f02ee28067c59514a36f45f4cd73d49">swapRows</a>(<span class="keywordtype">size_t</span> i1,<span class="keywordtype">size_t</span> i2) { derived().row(i1).swap( derived().row(i2) ); } <a name="l00188"></a>00188 <a name="l00189"></a><a class="code" href="eigen__plugins_8h.html#aaa7a3455c836702a4b437978873aaf18">00189</a> EIGEN_STRONG_INLINE <span class="keywordtype">size_t</span> <a class="code" href="eigen__plugins_8h.html#aaa7a3455c836702a4b437978873aaf18">countNonZero</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ((*static_cast<const Derived*>(<span class="keyword">this</span>))!= 0).count(); } <a name="l00190"></a>00190 <span class="comment"></span> <a name="l00191"></a>00191 <span class="comment"> /** [VECTORS OR MATRICES] Finds the maximum value</span> <a name="l00192"></a>00192 <span class="comment"> * \exception std::exception On an empty input container</span> <a name="l00193"></a>00193 <span class="comment"> */</span> <a name="l00194"></a><a class="code" href="eigen__plugins_8h.html#a29bcf29c0462f07b71b310f5cdf01cb5">00194</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a29bcf29c0462f07b71b310f5cdf01cb5" title="[VECTORS OR MATRICES] Finds the maximum value On an empty input container">maximum</a>()<span class="keyword"> const</span> <a name="l00195"></a>00195 <span class="keyword"> </span>{ <a name="l00196"></a>00196 <span class="keywordflow">if</span> (<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"maximum: container is empty"</span>); <a name="l00197"></a>00197 <span class="keywordflow">return</span> derived().maxCoeff(); <a name="l00198"></a>00198 } <a name="l00199"></a>00199 <span class="comment"></span> <a name="l00200"></a>00200 <span class="comment"> /** [VECTORS OR MATRICES] Finds the minimum value</span> <a name="l00201"></a>00201 <span class="comment"> * \sa maximum, minimum_maximum</span> <a name="l00202"></a>00202 <span class="comment"> * \exception std::exception On an empty input container */</span> <a name="l00203"></a><a class="code" href="eigen__plugins_8h.html#a5358430f009a259d728f3da31785e986">00203</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a5358430f009a259d728f3da31785e986" title="[VECTORS OR MATRICES] Finds the minimum value">minimum</a>()<span class="keyword"> const</span> <a name="l00204"></a>00204 <span class="keyword"> </span>{ <a name="l00205"></a>00205 <span class="keywordflow">if</span> (<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"minimum: container is empty"</span>); <a name="l00206"></a>00206 <span class="keywordflow">return</span> derived().minCoeff(); <a name="l00207"></a>00207 } <a name="l00208"></a>00208 <span class="comment"></span> <a name="l00209"></a>00209 <span class="comment"> /** [VECTORS OR MATRICES] Compute the minimum and maximum of a container at once</span> <a name="l00210"></a>00210 <span class="comment"> * \sa maximum, minimum</span> <a name="l00211"></a>00211 <span class="comment"> * \exception std::exception On an empty input container */</span> <a name="l00212"></a><a class="code" href="eigen__plugins_8h.html#af1242c3a6add388208167442fd51b314">00212</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#af1242c3a6add388208167442fd51b314" title="[VECTORS OR MATRICES] Compute the minimum and maximum of a container at once">minimum_maximum</a>( <a name="l00213"></a>00213 Scalar & out_min, <a name="l00214"></a>00214 Scalar & out_max)<span class="keyword"> const</span> <a name="l00215"></a>00215 <span class="keyword"> </span>{ <a name="l00216"></a>00216 out_min = <a class="code" href="eigen__plugins_8h.html#a5358430f009a259d728f3da31785e986" title="[VECTORS OR MATRICES] Finds the minimum value">minimum</a>(); <a name="l00217"></a>00217 out_max = <a class="code" href="eigen__plugins_8h.html#a29bcf29c0462f07b71b310f5cdf01cb5" title="[VECTORS OR MATRICES] Finds the maximum value On an empty input container">maximum</a>(); <a name="l00218"></a>00218 } <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="comment"></span> <a name="l00221"></a>00221 <span class="comment"> /** [VECTORS ONLY] Finds the maximum value (and the corresponding zero-based index) from a given container.</span> <a name="l00222"></a>00222 <span class="comment"> * \exception std::exception On an empty input vector</span> <a name="l00223"></a>00223 <span class="comment"> */</span> <a name="l00224"></a><a class="code" href="eigen__plugins_8h.html#a2898e1e0abdc8bdb31e7aee10a4ae727">00224</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a29bcf29c0462f07b71b310f5cdf01cb5" title="[VECTORS OR MATRICES] Finds the maximum value On an empty input container">maximum</a>(<span class="keywordtype">size_t</span> *maxIndex)<span class="keyword"> const</span> <a name="l00225"></a>00225 <span class="keyword"> </span>{ <a name="l00226"></a>00226 <span class="keywordflow">if</span> (<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"maximum: container is empty"</span>); <a name="l00227"></a>00227 Index idx; <a name="l00228"></a>00228 <span class="keyword">const</span> Scalar m = derived().maxCoeff(&idx); <a name="l00229"></a>00229 <span class="keywordflow">if</span> (maxIndex) *maxIndex = idx; <a name="l00230"></a>00230 <span class="keywordflow">return</span> m; <a name="l00231"></a>00231 } <a name="l00232"></a>00232 <span class="comment"></span> <a name="l00233"></a>00233 <span class="comment"> /** [VECTORS OR MATRICES] Finds the maximum value (and the corresponding zero-based index) from a given container.</span> <a name="l00234"></a>00234 <span class="comment"> * \exception std::exception On an empty input vector</span> <a name="l00235"></a>00235 <span class="comment"> */</span> <a name="l00236"></a><a class="code" href="eigen__plugins_8h.html#a5ec04514dba4a51e2b57215e6c51ea9f">00236</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a5ec04514dba4a51e2b57215e6c51ea9f" title="[VECTORS OR MATRICES] Finds the maximum value (and the corresponding zero-based index) from a given c...">find_index_max_value</a>(<span class="keywordtype">size_t</span> &u,<span class="keywordtype">size_t</span> &v,Scalar &valMax)<span class="keyword"> const</span> <a name="l00237"></a>00237 <span class="keyword"> </span>{ <a name="l00238"></a>00238 <span class="keywordflow">if</span> (cols()==0 || rows()==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"find_index_max_value: container is empty"</span>); <a name="l00239"></a>00239 Index idx1,idx2; <a name="l00240"></a>00240 valMax = derived().maxCoeff(&idx1,&idx2); <a name="l00241"></a>00241 u = idx1; v = idx2; <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <a name="l00244"></a>00244 <span class="comment"></span> <a name="l00245"></a>00245 <span class="comment"> /** [VECTORS ONLY] Finds the minimum value (and the corresponding zero-based index) from a given container.</span> <a name="l00246"></a>00246 <span class="comment"> * \sa maximum, minimum_maximum</span> <a name="l00247"></a>00247 <span class="comment"> * \exception std::exception On an empty input vector */</span> <a name="l00248"></a><a class="code" href="eigen__plugins_8h.html#af80dfb5ebbb5600f2b3f3a66ad8bb10c">00248</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a5358430f009a259d728f3da31785e986" title="[VECTORS OR MATRICES] Finds the minimum value">minimum</a>(<span class="keywordtype">size_t</span> *minIndex)<span class="keyword"> const</span> <a name="l00249"></a>00249 <span class="keyword"> </span>{ <a name="l00250"></a>00250 <span class="keywordflow">if</span> (<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"minimum: container is empty"</span>); <a name="l00251"></a>00251 Index idx; <a name="l00252"></a>00252 <span class="keyword">const</span> Scalar m =derived().minCoeff(&idx); <a name="l00253"></a>00253 <span class="keywordflow">if</span> (minIndex) *minIndex = idx; <a name="l00254"></a>00254 <span class="keywordflow">return</span> m; <a name="l00255"></a>00255 } <a name="l00256"></a>00256 <span class="comment"></span> <a name="l00257"></a>00257 <span class="comment"> /** [VECTORS ONLY] Compute the minimum and maximum of a container at once</span> <a name="l00258"></a>00258 <span class="comment"> * \sa maximum, minimum</span> <a name="l00259"></a>00259 <span class="comment"> * \exception std::exception On an empty input vector */</span> <a name="l00260"></a><a class="code" href="eigen__plugins_8h.html#abf32831ad6edc3ed67356f3e0dd8f6a9">00260</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#af1242c3a6add388208167442fd51b314" title="[VECTORS OR MATRICES] Compute the minimum and maximum of a container at once">minimum_maximum</a>( <a name="l00261"></a>00261 Scalar & out_min, <a name="l00262"></a>00262 Scalar & out_max, <a name="l00263"></a>00263 <span class="keywordtype">size_t</span> *minIndex, <a name="l00264"></a>00264 <span class="keywordtype">size_t</span> *maxIndex)<span class="keyword"> const</span> <a name="l00265"></a>00265 <span class="keyword"> </span>{ <a name="l00266"></a>00266 out_min = <a class="code" href="eigen__plugins_8h.html#a5358430f009a259d728f3da31785e986" title="[VECTORS OR MATRICES] Finds the minimum value">minimum</a>(minIndex); <a name="l00267"></a>00267 out_max = <a class="code" href="eigen__plugins_8h.html#a29bcf29c0462f07b71b310f5cdf01cb5" title="[VECTORS OR MATRICES] Finds the maximum value On an empty input container">maximum</a>(maxIndex); <a name="l00268"></a>00268 } <a name="l00269"></a>00269 <span class="comment"></span> <a name="l00270"></a>00270 <span class="comment"> /** Compute the norm-infinite of a vector ($f[ ||\mathbf{v}||_\infnty $f]), ie the maximum absolute value of the elements. */</span> <a name="l00271"></a><a class="code" href="eigen__plugins_8h.html#a53e8ff87dce50057b8d035590926db88">00271</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a53e8ff87dce50057b8d035590926db88" title="Compute the norm-infinite of a vector ($f[ ||{v}||_ $f]), ie the maximum absolute value of the elemen...">norm_inf</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> lpNorm<Eigen::Infinity>(); } <a name="l00272"></a>00272 <span class="comment"></span> <a name="l00273"></a>00273 <span class="comment"> /** Compute the square norm of a vector/array/matrix (the Euclidean distance to the origin, taking all the elements as a single vector). \sa norm */</span> <a name="l00274"></a><a class="code" href="eigen__plugins_8h.html#ae14bebc96536a68f0d0882100323e64e">00274</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#ae14bebc96536a68f0d0882100323e64e" title="Compute the square norm of a vector/array/matrix (the Euclidean distance to the origin, taking all the elements as a single vector).">squareNorm</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> squaredNorm(); } <a name="l00275"></a>00275 <span class="comment"></span> <a name="l00276"></a>00276 <span class="comment"> /*! Sum all the elements, returning a value of the same type than the container */</span> <a name="l00277"></a><a class="code" href="eigen__plugins_8h.html#a8e317bb5dedefdd9f59f2894982981ea">00277</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a8e317bb5dedefdd9f59f2894982981ea">sumAll</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> derived().sum(); } <a name="l00278"></a>00278 <span class="comment"></span> <a name="l00279"></a>00279 <span class="comment"> /** Computes the laplacian of this square graph weight matrix.</span> <a name="l00280"></a>00280 <span class="comment"> * The laplacian matrix is L = D - W, with D a diagonal matrix with the degree of each node, W the</span> <a name="l00281"></a>00281 <span class="comment"> */</span> <a name="l00282"></a>00282 <span class="keyword">template</span><<span class="keyword">typename</span> OtherDerived> <a name="l00283"></a><a class="code" href="eigen__plugins_8h.html#ae00c75ae00f634956069b741adf686df">00283</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ae00c75ae00f634956069b741adf686df" title="Computes the laplacian of this square graph weight matrix.">laplacian</a>(<a class="code" href="class_eigen_1_1_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">Eigen::MatrixBase <OtherDerived></a>& ret)<span class="keyword"> const</span> <a name="l00284"></a>00284 <span class="keyword"> </span>{ <a name="l00285"></a>00285 <span class="keywordflow">if</span> (rows()!=cols()) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"laplacian: Defined for square matrixes only"</span>); <a name="l00286"></a>00286 <span class="keyword">const</span> Index N = rows(); <a name="l00287"></a>00287 ret = -(*this); <a name="l00288"></a>00288 <span class="keywordflow">for</span> (Index i=0;i<N;i++) <a name="l00289"></a>00289 { <a name="l00290"></a>00290 Scalar deg = 0; <a name="l00291"></a>00291 <span class="keywordflow">for</span> (Index j=0;j<N;j++) deg+= derived().coeff(j,i); <a name="l00292"></a>00292 ret.coeffRef(i,i)+=deg; <a name="l00293"></a>00293 } <a name="l00294"></a>00294 } <a name="l00295"></a>00295 <a name="l00296"></a>00296 <span class="comment"></span> <a name="l00297"></a>00297 <span class="comment"> /** Changes the size of matrix, maintaining its previous content as possible and padding with zeros where applicable.</span> <a name="l00298"></a>00298 <span class="comment"> * **WARNING**: MRPT's add-on method \a setSize() pads with zeros, while Eigen's \a resize() does NOT (new elements are undefined).</span> <a name="l00299"></a>00299 <span class="comment"> */</span> <a name="l00300"></a><a class="code" href="eigen__plugins_8h.html#a8133077108cd44f617e7784243eb5db9">00300</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a8133077108cd44f617e7784243eb5db9" title="Changes the size of matrix, maintaining its previous content as possible and padding with zeros where...">setSize</a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col) <a name="l00301"></a>00301 { <a name="l00302"></a>00302 <span class="preprocessor">#ifdef _DEBUG</span> <a name="l00303"></a>00303 <span class="preprocessor"></span> <span class="keywordflow">if</span> ((Derived::RowsAtCompileTime!=<a class="code" href="namespace_eigen.html#ad81fa7195215a0ce30017dfac309f0b2" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Eigen::Dynamic</a> && Derived::RowsAtCompileTime!=<span class="keywordtype">int</span>(row)) || (Derived::ColsAtCompileTime!=<a class="code" href="namespace_eigen.html#ad81fa7195215a0ce30017dfac309f0b2" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Eigen::Dynamic</a> && Derived::ColsAtCompileTime!=<span class="keywordtype">int</span>(col))) { <a name="l00304"></a>00304 std::stringstream ss; ss << <span class="stringliteral">"setSize: Trying to change a fixed sized matrix from "</span> << rows() << <span class="stringliteral">"x"</span> << cols() << <span class="stringliteral">" to "</span> << row << <span class="stringliteral">"x"</span> << col; <a name="l00305"></a>00305 <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(ss.str()); <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <span class="preprocessor">#endif</span> <a name="l00308"></a>00308 <span class="preprocessor"></span> <span class="keyword">const</span> Index oldCols = cols(); <a name="l00309"></a>00309 <span class="keyword">const</span> Index oldRows = rows(); <a name="l00310"></a>00310 <span class="keyword">const</span> <span class="keywordtype">int</span> nNewCols = int(col) - int(cols()); <a name="l00311"></a>00311 <span class="keyword">const</span> <span class="keywordtype">int</span> nNewRows = int(row) - int(rows()); <a name="l00312"></a>00312 <a class="code" href="structmrpt_1_1math_1_1detail_1_1_t_aux_resizer.html" title="Internal resize which compiles to nothing on fixed-size matrices.">::mrpt::math::detail::TAuxResizer<Eigen::MatrixBase<Derived></a>,SizeAtCompileTime>::internal_resize(*<span class="keyword">this</span>,row,col); <a name="l00313"></a>00313 <span class="keywordflow">if</span> (nNewCols>0) derived().block(0,oldCols,row,nNewCols).setZero(); <a name="l00314"></a>00314 <span class="keywordflow">if</span> (nNewRows>0) derived().block(oldRows,0,nNewRows,col).setZero(); <a name="l00315"></a>00315 } <a name="l00316"></a>00316 <span class="comment"></span> <a name="l00317"></a>00317 <span class="comment"> /** Efficiently computes only the biggest eigenvector of the matrix using the Power Method, and returns it in the passed vector "x". */</span> <a name="l00318"></a>00318 <span class="keyword">template</span> <<span class="keyword">class</span> OUTVECT> <a name="l00319"></a><a class="code" href="eigen__plugins_8h.html#a27fb9d81da9bb17a95bda4dda0b9a452">00319</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a27fb9d81da9bb17a95bda4dda0b9a452" title="Efficiently computes only the biggest eigenvector of the matrix using the Power Method, and returns it in the passed vector "x".">largestEigenvector</a>( <a name="l00320"></a>00320 OUTVECT &x, <a name="l00321"></a>00321 Scalar resolution = Scalar(0.01), <a name="l00322"></a>00322 <span class="keywordtype">size_t</span> maxIterations = 6, <a name="l00323"></a>00323 <span class="keywordtype">int</span> *out_Iterations = NULL, <a name="l00324"></a>00324 <span class="keywordtype">float</span> *out_estimatedResolution = NULL )<span class="keyword"> const</span> <a name="l00325"></a>00325 <span class="keyword"> </span>{ <a name="l00326"></a>00326 <span class="comment">// Apply the iterative Power Method:</span> <a name="l00327"></a>00327 <span class="keywordtype">size_t</span> iter=0; <a name="l00328"></a>00328 <span class="keyword">const</span> Index n = rows(); <a name="l00329"></a>00329 x.resize(n); <a name="l00330"></a>00330 x.setConstant(1); <span class="comment">// Initially, set to all ones, for example...</span> <a name="l00331"></a>00331 Scalar dif; <a name="l00332"></a>00332 <span class="keywordflow">do</span> <span class="comment">// Iterative loop:</span> <a name="l00333"></a>00333 { <a name="l00334"></a>00334 Eigen::Matrix<Scalar,Derived::RowsAtCompileTime,1> xx = (*this) * x; <a name="l00335"></a>00335 xx *= Scalar(1.0/xx.norm()); <a name="l00336"></a>00336 dif = (x-xx).array().abs().sum(); <span class="comment">// Compute diference between iterations:</span> <a name="l00337"></a>00337 x = xx; <span class="comment">// Set as current estimation:</span> <a name="l00338"></a>00338 iter++; <span class="comment">// Iteration counter:</span> <a name="l00339"></a>00339 } <span class="keywordflow">while</span> (iter<maxIterations && dif>resolution); <a name="l00340"></a>00340 <span class="keywordflow">if</span> (out_Iterations) *out_Iterations=<span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(iter); <a name="l00341"></a>00341 <span class="keywordflow">if</span> (out_estimatedResolution) *out_estimatedResolution=dif; <a name="l00342"></a>00342 } <a name="l00343"></a>00343 <span class="comment"></span> <a name="l00344"></a>00344 <span class="comment"> /** Combined matrix power and assignment operator */</span> <a name="l00345"></a><a class="code" href="eigen__plugins_8h.html#a59de153a45c710749417ed1c1b9a317d">00345</a> MatrixBase<Derived>& <a class="code" href="eigen__plugins_8h.html#a59de153a45c710749417ed1c1b9a317d" title="Combined matrix power and assignment operator.">operator ^= </a>(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> pow) <a name="l00346"></a>00346 { <a name="l00347"></a>00347 <span class="keywordflow">if</span> (pow==0) <a name="l00348"></a>00348 derived().setIdentity(); <a name="l00349"></a>00349 <span class="keywordflow">else</span> <a name="l00350"></a>00350 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=1;i<pow;i++) <a name="l00351"></a>00351 derived() *= derived(); <a name="l00352"></a>00352 <span class="keywordflow">return</span> *<span class="keyword">this</span>; <a name="l00353"></a>00353 } <a name="l00354"></a>00354 <span class="comment"></span> <a name="l00355"></a>00355 <span class="comment"> /** Scalar power of all elements to a given power, this is diferent of ^ operator. */</span> <a name="l00356"></a><a class="code" href="eigen__plugins_8h.html#a5d6e5c1d2e7d30b703716e59bf66a731">00356</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a5d6e5c1d2e7d30b703716e59bf66a731" title="Scalar power of all elements to a given power, this is diferent of ^ operator.">scalarPow</a>(<span class="keyword">const</span> Scalar s) { (*this)=array().pow(s); } <a name="l00357"></a>00357 <span class="comment"></span> <a name="l00358"></a>00358 <span class="comment"> /** Checks for matrix type */</span> <a name="l00359"></a><a class="code" href="eigen__plugins_8h.html#ab0110c458e325a70d74be26bedb2c0a6">00359</a> EIGEN_STRONG_INLINE <span class="keywordtype">bool</span> <a class="code" href="eigen__plugins_8h.html#ab0110c458e325a70d74be26bedb2c0a6" title="Checks for matrix type.">isDiagonal</a>()<span class="keyword"> const</span> <a name="l00360"></a>00360 <span class="keyword"> </span>{ <a name="l00361"></a>00361 <span class="keywordflow">for</span> (Index c=0;c<cols();c++) <a name="l00362"></a>00362 <span class="keywordflow">for</span> (Index r=0;r<rows();r++) <a name="l00363"></a>00363 <span class="keywordflow">if</span> (r!=c && coeff(r,c)!=0) <a name="l00364"></a>00364 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00365"></a>00365 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00366"></a>00366 } <a name="l00367"></a>00367 <span class="comment"></span> <a name="l00368"></a>00368 <span class="comment"> /** Finds the maximum value in the diagonal of the matrix. */</span> <a name="l00369"></a><a class="code" href="eigen__plugins_8h.html#a77e1f95f883d99800c8db1e4bd505633">00369</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a77e1f95f883d99800c8db1e4bd505633" title="Finds the maximum value in the diagonal of the matrix.">maximumDiagonal</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> diagonal().maximum(); } <a name="l00370"></a>00370 <span class="comment"></span> <a name="l00371"></a>00371 <span class="comment"> /** Computes the mean of the entire matrix</span> <a name="l00372"></a>00372 <span class="comment"> * \sa meanAndStdAll */</span> <a name="l00373"></a><a class="code" href="eigen__plugins_8h.html#a378ef7ee1218e4aa29b595c6e0f8ee4a">00373</a> EIGEN_STRONG_INLINE <span class="keywordtype">double</span> <a class="code" href="eigen__plugins_8h.html#a378ef7ee1218e4aa29b595c6e0f8ee4a" title="Computes the mean of the entire matrix.">mean</a>()<span class="keyword"> const</span> <a name="l00374"></a>00374 <span class="keyword"> </span>{ <a name="l00375"></a>00375 <span class="keywordflow">if</span> ( <a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"mean: Empty container."</span>); <a name="l00376"></a>00376 <span class="keywordflow">return</span> derived().sum()/<span class="keyword">static_cast<</span><span class="keywordtype">double</span><span class="keyword">></span>(<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()); <a name="l00377"></a>00377 } <a name="l00378"></a>00378 <span class="comment"></span> <a name="l00379"></a>00379 <span class="comment"> /** Computes a row with the mean values of each column in the matrix and the associated vector with the standard deviation of each column.</span> <a name="l00380"></a>00380 <span class="comment"> * \sa mean,meanAndStdAll \exception std::exception If the matrix/vector is empty.</span> <a name="l00381"></a>00381 <span class="comment"> * \param unbiased_variance Standard deviation is sum(vals-mean)/K, with K=N-1 or N for unbiased_variance=true or false, respectively.</span> <a name="l00382"></a>00382 <span class="comment"> */</span> <a name="l00383"></a>00383 <span class="keyword">template</span> <<span class="keyword">class</span> VEC> <a name="l00384"></a><a class="code" href="eigen__plugins_8h.html#a37ca262197838f94a2d9ab537d81c857">00384</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a37ca262197838f94a2d9ab537d81c857" title="Computes a row with the mean values of each column in the matrix and the associated vector with the s...">meanAndStd</a>( <a name="l00385"></a>00385 VEC &outMeanVector, <a name="l00386"></a>00386 VEC &outStdVector, <a name="l00387"></a>00387 <span class="keyword">const</span> <span class="keywordtype">bool</span> unbiased_variance = <span class="keyword">true</span> )<span class="keyword"> const</span> <a name="l00388"></a>00388 <span class="keyword"> </span>{ <a name="l00389"></a>00389 <span class="keyword">const</span> <span class="keywordtype">double</span> N = rows(); <a name="l00390"></a>00390 <span class="keywordflow">if</span> (N==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"meanAndStd: Empty container."</span>); <a name="l00391"></a>00391 <span class="keyword">const</span> <span class="keywordtype">double</span> N_inv = 1.0/N; <a name="l00392"></a>00392 <span class="keyword">const</span> <span class="keywordtype">double</span> N_ = unbiased_variance ? (N>1 ? 1.0/(N-1) : 1.0) : 1.0/N; <a name="l00393"></a>00393 outMeanVector.resize(cols()); <a name="l00394"></a>00394 outStdVector.resize(cols()); <a name="l00395"></a>00395 <span class="keywordflow">for</span> (Index i=0;i<cols();i++) <a name="l00396"></a>00396 { <a name="l00397"></a>00397 outMeanVector[i]= col(i).array().sum() * N_inv; <a name="l00398"></a>00398 outStdVector[i] = std::sqrt( (col(i).array()-outMeanVector[i]).<a class="code" href="namespacemrpt_1_1utils.html#a67cb05bb8ad4e725875a7ee54b7042ae" title="Inline function for the square of a number.">square</a>().<a class="code" href="namespacemrpt_1_1math.html#a0c97e69e10a10499133480daa055e7c4" title="Computes the sum of all the elements.">sum</a>() * N_ ); <a name="l00399"></a>00399 } <a name="l00400"></a>00400 } <a name="l00401"></a>00401 <span class="comment"></span> <a name="l00402"></a>00402 <span class="comment"> /** Computes the mean and standard deviation of all the elements in the matrix as a whole.</span> <a name="l00403"></a>00403 <span class="comment"> * \sa mean,meanAndStd \exception std::exception If the matrix/vector is empty.</span> <a name="l00404"></a>00404 <span class="comment"> * \param unbiased_variance Standard deviation is sum(vals-mean)/K, with K=N-1 or N for unbiased_variance=true or false, respectively.</span> <a name="l00405"></a>00405 <span class="comment"> */</span> <a name="l00406"></a><a class="code" href="eigen__plugins_8h.html#a59dd066bddb77e59609564c036a04294">00406</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a59dd066bddb77e59609564c036a04294" title="Computes the mean and standard deviation of all the elements in the matrix as a whole.">meanAndStdAll</a>( <a name="l00407"></a>00407 <span class="keywordtype">double</span> &outMean, <a name="l00408"></a>00408 <span class="keywordtype">double</span> &outStd, <a name="l00409"></a>00409 <span class="keyword">const</span> <span class="keywordtype">bool</span> unbiased_variance = <span class="keyword">true</span> )<span class="keyword"> const</span> <a name="l00410"></a>00410 <span class="keyword"> </span>{ <a name="l00411"></a>00411 <span class="keyword">const</span> <span class="keywordtype">double</span> N = <a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>(); <a name="l00412"></a>00412 <span class="keywordflow">if</span> (N==0) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"meanAndStdAll: Empty container."</span>); <a name="l00413"></a>00413 <span class="keyword">const</span> <span class="keywordtype">double</span> N_ = unbiased_variance ? (N>1 ? 1.0/(N-1) : 1.0) : 1.0/N; <a name="l00414"></a>00414 outMean = derived().array().sum()/<span class="keyword">static_cast<</span><span class="keywordtype">double</span><span class="keyword">></span>(<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()); <a name="l00415"></a>00415 outStd = std::sqrt( (this->array() - outMean).<a class="code" href="namespacemrpt_1_1utils.html#a67cb05bb8ad4e725875a7ee54b7042ae" title="Inline function for the square of a number.">square</a>().<a class="code" href="namespacemrpt_1_1math.html#a0c97e69e10a10499133480daa055e7c4" title="Computes the sum of all the elements.">sum</a>()*N_); <a name="l00416"></a>00416 } <a name="l00417"></a>00417 <span class="comment"></span> <a name="l00418"></a>00418 <span class="comment"> /** Insert matrix "m" into this matrix at indices (r,c), that is, (*this)(r,c)=m(0,0) and so on */</span> <a name="l00419"></a>00419 <span class="keyword">template</span> <<span class="keyword">typename</span> MAT> <a name="l00420"></a><a class="code" href="eigen__plugins_8h.html#a7ef3e78b94ad34d5dbbd1813f8ee52c5">00420</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a7ef3e78b94ad34d5dbbd1813f8ee52c5" title="Insert matrix "m" into this matrix at indices (r,c), that is, (*this)(r,c)=m(0,0) and so on...">insertMatrix</a>(<span class="keywordtype">size_t</span> r,<span class="keywordtype">size_t</span> c, <span class="keyword">const</span> MAT &m) { derived().block(r,c,m.rows(),m.cols())=m; } <a name="l00421"></a>00421 <a name="l00422"></a>00422 <span class="keyword">template</span> <<span class="keyword">typename</span> MAT> <a name="l00423"></a><a class="code" href="eigen__plugins_8h.html#a4c55ec8071d6f0d708a8d9c2ffbd3d7c">00423</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a4c55ec8071d6f0d708a8d9c2ffbd3d7c">insertMatrixTranspose</a>(<span class="keywordtype">size_t</span> r,<span class="keywordtype">size_t</span> c, <span class="keyword">const</span> MAT &m) { derived().block(r,c,m.cols(),m.rows())=m.adjoint(); } <a name="l00424"></a>00424 <a name="l00425"></a><a class="code" href="eigen__plugins_8h.html#a8dbf0e61572da6d0e8d0f22d28d21837">00425</a> <span class="keyword">template</span> <<span class="keyword">typename</span> MAT> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a8dbf0e61572da6d0e8d0f22d28d21837">insertRow</a>(<span class="keywordtype">size_t</span> nRow, <span class="keyword">const</span> MAT & aRow) { this->row(nRow) = aRow; } <a name="l00426"></a><a class="code" href="eigen__plugins_8h.html#ae944e54fd502b0650c003d4c131681d8">00426</a> <span class="keyword">template</span> <<span class="keyword">typename</span> MAT> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ae944e54fd502b0650c003d4c131681d8">insertCol</a>(<span class="keywordtype">size_t</span> nCol, <span class="keyword">const</span> MAT & aCol) { this->col(nCol) = aCol; } <a name="l00427"></a>00427 <a name="l00428"></a><a class="code" href="eigen__plugins_8h.html#af7af3299aa14d7c2d2caf3be800fea33">00428</a> <span class="keyword">template</span> <<span class="keyword">typename</span> R> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a8dbf0e61572da6d0e8d0f22d28d21837">insertRow</a>(<span class="keywordtype">size_t</span> nRow, <span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html" title="STL class.">std::vector<R></a> & aRow) <a name="l00429"></a>00429 { <a name="l00430"></a>00430 <span class="keywordflow">if</span> (static_cast<Index>(aRow.size())!=cols()) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"insertRow: Row size doesn't fit the size of this matrix."</span>); <a name="l00431"></a>00431 <span class="keywordflow">for</span> (Index j=0;j<cols();j++) <a name="l00432"></a>00432 coeffRef(nRow,j) = aRow[j]; <a name="l00433"></a>00433 } <a name="l00434"></a><a class="code" href="eigen__plugins_8h.html#ad74f9fce83eab01230c8bd900aab9267">00434</a> <span class="keyword">template</span> <<span class="keyword">typename</span> R> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ae944e54fd502b0650c003d4c131681d8">insertCol</a>(<span class="keywordtype">size_t</span> nCol, <span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html" title="STL class.">std::vector<R></a> & aCol) <a name="l00435"></a>00435 { <a name="l00436"></a>00436 <span class="keywordflow">if</span> (static_cast<Index>(aCol.size())!=rows()) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"insertRow: Row size doesn't fit the size of this matrix."</span>); <a name="l00437"></a>00437 <span class="keywordflow">for</span> (Index j=0;j<rows();j++) <a name="l00438"></a>00438 coeffRef(j,nCol) = aCol[j]; <a name="l00439"></a>00439 } <a name="l00440"></a>00440 <span class="comment"></span> <a name="l00441"></a>00441 <span class="comment"> /** Remove columns of the matrix.*/</span> <a name="l00442"></a><a class="code" href="eigen__plugins_8h.html#ad9b9bf3484c9aab42077498f5882cb16">00442</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ad9b9bf3484c9aab42077498f5882cb16" title="Remove columns of the matrix.">removeColumns</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector<size_t></a> &idxsToRemove) <a name="l00443"></a>00443 { <a name="l00444"></a>00444 std::vector<size_t> idxs = idxsToRemove; <a name="l00445"></a>00445 std::sort( idxs.begin(), idxs.end() ); <a name="l00446"></a>00446 std<a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">::vector<size_t>::iterator</a> itEnd = std::unique( idxs.begin(), idxs.end() ); <a name="l00447"></a>00447 idxs.resize( itEnd - idxs.begin() ); <a name="l00448"></a>00448 <a name="l00449"></a>00449 <a class="code" href="eigen__plugins_8h.html#a854c27aefa2d3f14bec7dd94eab61e7d" title="Remove columns of the matrix.">unsafeRemoveColumns</a>( idxs ); <a name="l00450"></a>00450 } <a name="l00451"></a>00451 <span class="comment"></span> <a name="l00452"></a>00452 <span class="comment"> /** Remove columns of the matrix. The unsafe version assumes that, the indices are sorted in ascending order. */</span> <a name="l00453"></a><a class="code" href="eigen__plugins_8h.html#a854c27aefa2d3f14bec7dd94eab61e7d">00453</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a854c27aefa2d3f14bec7dd94eab61e7d" title="Remove columns of the matrix.">unsafeRemoveColumns</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector<size_t></a> &idxs) <a name="l00454"></a>00454 { <a name="l00455"></a>00455 <span class="keywordtype">size_t</span> k = 1; <a name="l00456"></a>00456 <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1vector_1_1const__reverse__iterator.html" title="STL iterator class.">std::vector<size_t>::const_reverse_iterator</a> it = idxs.rbegin(); it != idxs.rend(); it++, k++) <a name="l00457"></a>00457 { <a name="l00458"></a>00458 <span class="keyword">const</span> <span class="keywordtype">size_t</span> nC = cols() - *it - k; <a name="l00459"></a>00459 <span class="keywordflow">if</span>( nC > 0 ) <a name="l00460"></a>00460 derived().block(0,*it,rows(),nC) = derived().block(0,*it+1,rows(),nC).eval(); <a name="l00461"></a>00461 } <a name="l00462"></a>00462 derived().conservativeResize(NoChange,cols()-idxs.size()); <a name="l00463"></a>00463 } <a name="l00464"></a>00464 <span class="comment"></span> <a name="l00465"></a>00465 <span class="comment"> /** Remove rows of the matrix. */</span> <a name="l00466"></a><a class="code" href="eigen__plugins_8h.html#aae04af00326409b3eeabb5ea3c5eea4a">00466</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aae04af00326409b3eeabb5ea3c5eea4a" title="Remove rows of the matrix.">removeRows</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector<size_t></a> &idxsToRemove) <a name="l00467"></a>00467 { <a name="l00468"></a>00468 std::vector<size_t> idxs = idxsToRemove; <a name="l00469"></a>00469 std::sort( idxs.begin(), idxs.end() ); <a name="l00470"></a>00470 std<a class="code" href="eigen__plugins_8h.html#a39c5d6430ea9395ae7ae729dd0c3f18c">::vector<size_t>::iterator</a> itEnd = std::unique( idxs.begin(), idxs.end() ); <a name="l00471"></a>00471 idxs.resize( itEnd - idxs.begin() ); <a name="l00472"></a>00472 <a name="l00473"></a>00473 <a class="code" href="eigen__plugins_8h.html#a6213c85ee1df93e7e54a36c09c76b6d4" title="Remove rows of the matrix.">unsafeRemoveRows</a>( idxs ); <a name="l00474"></a>00474 } <a name="l00475"></a>00475 <span class="comment"></span> <a name="l00476"></a>00476 <span class="comment"> /** Remove rows of the matrix. The unsafe version assumes that, the indices are sorted in ascending order. */</span> <a name="l00477"></a><a class="code" href="eigen__plugins_8h.html#a6213c85ee1df93e7e54a36c09c76b6d4">00477</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a6213c85ee1df93e7e54a36c09c76b6d4" title="Remove rows of the matrix.">unsafeRemoveRows</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector<size_t></a> &idxs) <a name="l00478"></a>00478 { <a name="l00479"></a>00479 <span class="keywordtype">size_t</span> k = 1; <a name="l00480"></a>00480 <span class="keywordflow">for</span> (<a class="code" href="classstd_1_1vector_1_1reverse__iterator.html" title="STL iterator class.">std::vector<size_t>::reverse_iterator</a> it = idxs.rbegin(); it != idxs.rend(); it++, k++) <a name="l00481"></a>00481 { <a name="l00482"></a>00482 <span class="keyword">const</span> <span class="keywordtype">size_t</span> nR = rows() - *it - k; <a name="l00483"></a>00483 <span class="keywordflow">if</span>( nR > 0 ) <a name="l00484"></a>00484 derived().block(*it,0,nR,cols()) = derived().block(*it+1,0,nR,cols()).eval(); <a name="l00485"></a>00485 } <a name="l00486"></a>00486 derived().conservativeResize(rows()-idxs.size(),NoChange); <a name="l00487"></a>00487 } <a name="l00488"></a>00488 <span class="comment"></span> <a name="l00489"></a>00489 <span class="comment"> /** Transpose */</span> <a name="l00490"></a><a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d">00490</a> EIGEN_STRONG_INLINE <span class="keyword">const</span> AdjointReturnType <a class="code" href="eigen__plugins_8h.html#a7b88b312dc3827120dbfc60da344625d" title="Transpose.">t</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> derived().adjoint(); } <a name="l00491"></a>00491 <a name="l00492"></a><a class="code" href="eigen__plugins_8h.html#ac60dd2d7ef18e0196be37dcc5d18c760">00492</a> EIGEN_STRONG_INLINE PlainObject <a class="code" href="eigen__plugins_8h.html#ac60dd2d7ef18e0196be37dcc5d18c760">inv</a>()<span class="keyword"> const </span>{ PlainObject outMat = derived().inverse().eval(); <span class="keywordflow">return</span> outMat; } <a name="l00493"></a><a class="code" href="eigen__plugins_8h.html#a25529959d227094eb565f14dabd2b094">00493</a> <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ac60dd2d7ef18e0196be37dcc5d18c760">inv</a>(MATRIX &outMat)<span class="keyword"> const </span>{ outMat = derived().inverse().eval(); } <a name="l00494"></a><a class="code" href="eigen__plugins_8h.html#aef34f5ccac35fa506b6d702cfc01edb8">00494</a> <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aef34f5ccac35fa506b6d702cfc01edb8">inv_fast</a>(MATRIX &outMat)<span class="keyword"> const </span>{ outMat = derived().inverse().eval(); } <a name="l00495"></a><a class="code" href="eigen__plugins_8h.html#a96d156d50856525aa2e9e4e106012f78">00495</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a96d156d50856525aa2e9e4e106012f78">det</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> derived().determinant(); } <a name="l00496"></a>00496 <span class="comment"></span> <a name="l00497"></a>00497 <span class="comment"> /** @} */</span> <span class="comment">// end miscelaneous</span> <a name="l00498"></a>00498 <a name="l00499"></a>00499 <span class="comment"></span> <a name="l00500"></a>00500 <span class="comment"> /** @name MRPT plugin: Multiply and extra addition functions</span> <a name="l00501"></a>00501 <span class="comment"> @{ */</span> <a name="l00502"></a>00502 <a name="l00503"></a><a class="code" href="eigen__plugins_8h.html#a05ed04d61c4f7d75d93908c25a09d8c4">00503</a> EIGEN_STRONG_INLINE <span class="keywordtype">bool</span> <a class="code" href="eigen__plugins_8h.html#a05ed04d61c4f7d75d93908c25a09d8c4">empty</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this-><a class="code" href="eigen__plugins_8h.html#a4d49034b9785c1bd62e4d4540a39066b" title="Get number of columns.">getColCount</a>()==0 || this-><a class="code" href="eigen__plugins_8h.html#a61275d6dcd40b0676f9a430be46ef876" title="Get number of rows.">getRowCount</a>()==0; } <a name="l00504"></a>00504 <span class="comment"></span> <a name="l00505"></a>00505 <span class="comment"> /*! Add c (scalar) times A to this matrix: this += A * c */</span> <a name="l00506"></a><a class="code" href="eigen__plugins_8h.html#a79ef27edb8c8c56d4a1f4fede691b9e6">00506</a> <span class="keyword">template</span><<span class="keyword">typename</span> OTHERMATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a79ef27edb8c8c56d4a1f4fede691b9e6">add_Ac</a>(<span class="keyword">const</span> OTHERMATRIX &m,<span class="keyword">const</span> Scalar c) { (*this)+=c*m; }<span class="comment"></span> <a name="l00507"></a>00507 <span class="comment"> /*! Substract c (scalar) times A to this matrix: this -= A * c */</span> <a name="l00508"></a><a class="code" href="eigen__plugins_8h.html#ad588530378b75fee39970714fafb9b14">00508</a> <span class="keyword">template</span><<span class="keyword">typename</span> OTHERMATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ad588530378b75fee39970714fafb9b14">substract_Ac</a>(<span class="keyword">const</span> OTHERMATRIX &m,<span class="keyword">const</span> Scalar c) { (*this) -= c*m; } <a name="l00509"></a>00509 <span class="comment"></span> <a name="l00510"></a>00510 <span class="comment"> /*! Substract A transposed to this matrix: this -= A.adjoint() */</span> <a name="l00511"></a><a class="code" href="eigen__plugins_8h.html#aafbfccc8bf00546a77e11d39e51c30b9">00511</a> <span class="keyword">template</span><<span class="keyword">typename</span> OTHERMATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aafbfccc8bf00546a77e11d39e51c30b9">substract_At</a>(<span class="keyword">const</span> OTHERMATRIX &m) { (*this) -= m.adjoint(); } <a name="l00512"></a>00512 <span class="comment"></span> <a name="l00513"></a>00513 <span class="comment"> /*! Substract n (integer) times A to this matrix: this -= A * n */</span> <a name="l00514"></a><a class="code" href="eigen__plugins_8h.html#a3d2f623699d93b2d43c620b5209c9246">00514</a> <span class="keyword">template</span><<span class="keyword">typename</span> OTHERMATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a3d2f623699d93b2d43c620b5209c9246">substract_An</a>(<span class="keyword">const</span> OTHERMATRIX& m, <span class="keyword">const</span> <span class="keywordtype">size_t</span> n) { this->noalias() -= n * m; } <a name="l00515"></a>00515 <span class="comment"></span> <a name="l00516"></a>00516 <span class="comment"> /*! this += A + A<sup>T</sup> */</span> <a name="l00517"></a><a class="code" href="eigen__plugins_8h.html#a6a371e05e1660d6257674cfef0c9bc34">00517</a> <span class="keyword">template</span><<span class="keyword">typename</span> OTHERMATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a6a371e05e1660d6257674cfef0c9bc34">add_AAt</a>(<span class="keyword">const</span> OTHERMATRIX &A) { this->noalias() += A; this->noalias() += A.adjoint(); } <a name="l00518"></a>00518 <span class="comment"></span> <a name="l00519"></a>00519 <span class="comment"> /*! this -= A + A<sup>T</sup> */</span> \ <a name="l00520"></a><a class="code" href="eigen__plugins_8h.html#acaad37e9c18497409f56a53e7d7b4b8e">00520</a> template<typename OTHERMATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#acaad37e9c18497409f56a53e7d7b4b8e">substract_AAt</a>(<span class="keyword">const</span> OTHERMATRIX &A) { this->noalias() -= A; this->noalias() -= A.adjoint(); } <a name="l00521"></a>00521 <a name="l00522"></a>00522 <a name="l00523"></a><a class="code" href="eigen__plugins_8h.html#a2785f297af30ced4f8e6606a4bb0be9f">00523</a> <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX1,<span class="keyword">class</span> MATRIX2> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a2785f297af30ced4f8e6606a4bb0be9f">multiply</a>( <span class="keyword">const</span> MATRIX1& A, <span class="keyword">const</span> MATRIX2 &B ) <span class="comment">/*!< this = A * B */</span> { (*this)= A*B; } <a name="l00524"></a>00524 <a name="l00525"></a>00525 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX1,<span class="keyword">class</span> MATRIX2> <a name="l00526"></a><a class="code" href="eigen__plugins_8h.html#a7f39ab70bf340ee5bc203aad960d57e0">00526</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a7f39ab70bf340ee5bc203aad960d57e0">multiply_AB</a>( <span class="keyword">const</span> MATRIX1& A, <span class="keyword">const</span> MATRIX2 &B ) <span class="comment">/*!< this = A * B */</span> { <a name="l00527"></a>00527 (*this)= A*B; <a name="l00528"></a>00528 } <a name="l00529"></a>00529 <a name="l00530"></a>00530 <span class="keyword">template</span> <<span class="keyword">typename</span> MATRIX1,<span class="keyword">typename</span> MATRIX2> <a name="l00531"></a><a class="code" href="eigen__plugins_8h.html#a803e1e1591c53f90563c94be395f69b0">00531</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a803e1e1591c53f90563c94be395f69b0">multiply_AtB</a>(<span class="keyword">const</span> MATRIX1 &A,<span class="keyword">const</span> MATRIX2 &B) <span class="comment">/*!< this=A^t * B */</span> { <a name="l00532"></a>00532 *<span class="keyword">this</span> = A.adjoint() * B; <a name="l00533"></a>00533 } <a name="l00534"></a>00534 <span class="comment"></span> <a name="l00535"></a>00535 <span class="comment"> /*! Computes the vector vOut = this * vIn, where "vIn" is a column vector of the appropriate length. */</span> <a name="l00536"></a>00536 <span class="keyword">template</span><<span class="keyword">typename</span> OTHERVECTOR1,<span class="keyword">typename</span> OTHERVECTOR2> <a name="l00537"></a><a class="code" href="eigen__plugins_8h.html#a768efc255b5ecad2750092f47313d549">00537</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a768efc255b5ecad2750092f47313d549">multiply_Ab</a>(<span class="keyword">const</span> OTHERVECTOR1 &vIn,OTHERVECTOR2 &vOut,<span class="keywordtype">bool</span> accumToOutput = <span class="keyword">false</span>)<span class="keyword"> const </span>{ <a name="l00538"></a>00538 <span class="keywordflow">if</span> (accumToOutput) vOut.noalias() += (*this) * vIn; <a name="l00539"></a>00539 <span class="keywordflow">else</span> vOut = (*this) * vIn; <a name="l00540"></a>00540 } <a name="l00541"></a>00541 <span class="comment"></span> <a name="l00542"></a>00542 <span class="comment"> /*! Computes the vector vOut = this<sup>T</sup> * vIn, where "vIn" is a column vector of the appropriate length. */</span> \ <a name="l00543"></a>00543 template<typename OTHERVECTOR1,typename OTHERVECTOR2> <a name="l00544"></a><a class="code" href="eigen__plugins_8h.html#a902fb479b9250b43ece91634cc315dd4">00544</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a902fb479b9250b43ece91634cc315dd4">multiply_Atb</a>(<span class="keyword">const</span> OTHERVECTOR1 &vIn,OTHERVECTOR2 &vOut,<span class="keywordtype">bool</span> accumToOutput = <span class="keyword">false</span>)<span class="keyword"> const </span>{ <a name="l00545"></a>00545 <span class="keywordflow">if</span> (accumToOutput) vOut.noalias() += this->adjoint() * vIn; <a name="l00546"></a>00546 <span class="keywordflow">else</span> vOut = this->adjoint() * vIn; <a name="l00547"></a>00547 } <a name="l00548"></a>00548 <a name="l00549"></a>00549 <span class="keyword">template</span> <<span class="keyword">typename</span> MAT_C, <span class="keyword">typename</span> MAT_R> <a name="l00550"></a><a class="code" href="eigen__plugins_8h.html#aff40658c0e151aed0734d6ddb7b301a3">00550</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aff40658c0e151aed0734d6ddb7b301a3">multiply_HCHt</a>(<span class="keyword">const</span> MAT_C &C,MAT_R &R,<span class="keywordtype">bool</span> accumResultInOutput=<span class="keyword">false</span>) const <span class="comment">/*!< R = this * C * this<sup>T</sup> */</span> { <a name="l00551"></a>00551 <span class="keywordflow">if</span> (accumResultInOutput) <a name="l00552"></a>00552 R.noalias() += (*this) * C * this->adjoint(); <a name="l00553"></a>00553 <span class="keywordflow">else</span> R.noalias() = (*this) * C * this->adjoint(); <a name="l00554"></a>00554 } <a name="l00555"></a>00555 <a name="l00556"></a>00556 <span class="keyword">template</span> <<span class="keyword">typename</span> MAT_C, <span class="keyword">typename</span> MAT_R> <a name="l00557"></a><a class="code" href="eigen__plugins_8h.html#a417f1b8366cd61a369e5861494fde53a">00557</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a417f1b8366cd61a369e5861494fde53a">multiply_HtCH</a>(<span class="keyword">const</span> MAT_C &C,MAT_R &R,<span class="keywordtype">bool</span> accumResultInOutput=<span class="keyword">false</span>) const <span class="comment">/*!< R = this<sup>T</sup> * C * this */</span> { <a name="l00558"></a>00558 <span class="keywordflow">if</span> (accumResultInOutput) <a name="l00559"></a>00559 R.noalias() += this->adjoint() * C * (*this); <a name="l00560"></a>00560 <span class="keywordflow">else</span> R.noalias() = this->adjoint() * C * (*this); <a name="l00561"></a>00561 } <a name="l00562"></a>00562 <span class="comment"></span> <a name="l00563"></a>00563 <span class="comment"> /*! R = H * C * H<sup>T</sup> (with a vector H and a symmetric matrix C) In fact when H is a vector, multiply_HCHt_scalar and multiply_HtCH_scalar are exactly equivalent */</span> <a name="l00564"></a>00564 <span class="keyword">template</span> <<span class="keyword">typename</span> MAT_C> <a name="l00565"></a><a class="code" href="eigen__plugins_8h.html#afda0882e4db840bc1d8e9bc13bc80e76">00565</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#afda0882e4db840bc1d8e9bc13bc80e76">multiply_HCHt_scalar</a>(<span class="keyword">const</span> MAT_C &C)<span class="keyword"> const </span>{ <a name="l00566"></a>00566 <span class="keywordflow">return</span> ( (*<span class="keyword">this</span>) * C * this->adjoint() ).eval()(0,0); <a name="l00567"></a>00567 } <a name="l00568"></a>00568 <span class="comment"></span> <a name="l00569"></a>00569 <span class="comment"> /*! R = H<sup>T</sup> * C * H (with a vector H and a symmetric matrix C) In fact when H is a vector, multiply_HCHt_scalar and multiply_HtCH_scalar are exactly equivalent */</span> <a name="l00570"></a>00570 <span class="keyword">template</span> <<span class="keyword">typename</span> MAT_C> <a name="l00571"></a><a class="code" href="eigen__plugins_8h.html#a46b547830ec3e1491ca84b09253256f8">00571</a> EIGEN_STRONG_INLINE Scalar <a class="code" href="eigen__plugins_8h.html#a46b547830ec3e1491ca84b09253256f8">multiply_HtCH_scalar</a>(<span class="keyword">const</span> MAT_C &C)<span class="keyword"> const </span>{ <a name="l00572"></a>00572 <span class="keywordflow">return</span> ( this->adjoint() * C * (*<span class="keyword">this</span>) ).eval()(0,0); <a name="l00573"></a>00573 } <a name="l00574"></a>00574 <span class="comment"></span> <a name="l00575"></a>00575 <span class="comment"> /*! this = C * C<sup>T</sup> * f (with a matrix C and a scalar f). */</span> <a name="l00576"></a>00576 <span class="keyword">template</span><<span class="keyword">typename</span> MAT_A> <a name="l00577"></a><a class="code" href="eigen__plugins_8h.html#a155a829abd54b7e41ca32f96ad06f879">00577</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a155a829abd54b7e41ca32f96ad06f879">multiply_AAt_scalar</a>(<span class="keyword">const</span> MAT_A &A,<span class="keyword">typename</span> <a class="code" href="eigen__plugins_8h.html#afd07186978da46f9908364e389f8a403" title="Type of the elements.">MAT_A::value_type</a> f) { <a name="l00578"></a>00578 *<span class="keyword">this</span> = (A * A.adjoint()) * f; <a name="l00579"></a>00579 } <a name="l00580"></a>00580 <span class="comment"></span> <a name="l00581"></a>00581 <span class="comment"> /*! this = C<sup>T</sup> * C * f (with a matrix C and a scalar f). */</span> <a name="l00582"></a><a class="code" href="eigen__plugins_8h.html#af12616f77a4ee38cf80e8c305777763b">00582</a> <span class="keyword">template</span><<span class="keyword">typename</span> MAT_A> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#af12616f77a4ee38cf80e8c305777763b">multiply_AtA_scalar</a>(<span class="keyword">const</span> MAT_A &A,<span class="keyword">typename</span> <a class="code" href="eigen__plugins_8h.html#afd07186978da46f9908364e389f8a403" title="Type of the elements.">MAT_A::value_type</a> f) { <a name="l00583"></a>00583 *<span class="keyword">this</span> = (A.adjoint() * A) * f; <a name="l00584"></a>00584 } <a name="l00585"></a>00585 <span class="comment"></span> <a name="l00586"></a>00586 <span class="comment"> /*! this = A * skew(v), with \a v being a 3-vector (or 3-array) and skew(v) the skew symmetric matrix of v (see mrpt::math::skew_symmetric3) */</span> <a name="l00587"></a><a class="code" href="eigen__plugins_8h.html#a5b52acfbd9696a318035334cbbad49c1">00587</a> <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A,<span class="keyword">class</span> SKEW_3VECTOR> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a5b52acfbd9696a318035334cbbad49c1">multiply_A_skew3</a>(<span class="keyword">const</span> MAT_A &A,<span class="keyword">const</span> SKEW_3VECTOR &v) { <a name="l00588"></a>00588 <a class="code" href="namespacemrpt_1_1math.html#ad21f2859644b754aba9a1392503a9776" title="Only for vectors/arrays "v" of length3, compute out = A * Skew(v), where Skew(v) is the skew symmetri...">mrpt::math::multiply_A_skew3</a>(A,v,*<span class="keyword">this</span>); } <a name="l00589"></a>00589 <span class="comment"></span> <a name="l00590"></a>00590 <span class="comment"> /*! this = skew(v)*A, with \a v being a 3-vector (or 3-array) and skew(v) the skew symmetric matrix of v (see mrpt::math::skew_symmetric3) */</span> <a name="l00591"></a><a class="code" href="eigen__plugins_8h.html#a6a2b0f46328ae7d7535cb20cb0e81ac3">00591</a> <span class="keyword">template</span> <<span class="keyword">class</span> SKEW_3VECTOR,<span class="keyword">class</span> MAT_A> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a6a2b0f46328ae7d7535cb20cb0e81ac3">multiply_skew3_A</a>(<span class="keyword">const</span> SKEW_3VECTOR &v,<span class="keyword">const</span> MAT_A &A) { <a name="l00592"></a>00592 <a class="code" href="namespacemrpt_1_1math.html#a134f1d14fa12f25cbc82fa36faf59393" title="Only for vectors/arrays "v" of length3, compute out = Skew(v) * A, where Skew(v) is the skew symmetri...">mrpt::math::multiply_skew3_A</a>(v,A,*<span class="keyword">this</span>); } <a name="l00593"></a>00593 <span class="comment"></span> <a name="l00594"></a>00594 <span class="comment"> /** outResult = this * A</span> <a name="l00595"></a>00595 <span class="comment"> */</span> <a name="l00596"></a>00596 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A,<span class="keyword">class</span> MAT_OUT> <a name="l00597"></a><a class="code" href="eigen__plugins_8h.html#ad46367c9dd976753b2a734b1771684db">00597</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ad46367c9dd976753b2a734b1771684db" title="outResult = this * A">multiply_subMatrix</a>(<span class="keyword">const</span> MAT_A &A,MAT_OUT &outResult,<span class="keyword">const</span> <span class="keywordtype">size_t</span> A_cols_offset,<span class="keyword">const</span> <span class="keywordtype">size_t</span> A_rows_offset,<span class="keyword">const</span> <span class="keywordtype">size_t</span> A_col_count)<span class="keyword"> const </span>{ <a name="l00598"></a>00598 outResult = derived() * A.block(A_rows_offset,A_cols_offset,derived().cols(),A_col_count); <a name="l00599"></a>00599 } <a name="l00600"></a>00600 <a name="l00601"></a>00601 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A,<span class="keyword">class</span> MAT_B,<span class="keyword">class</span> MAT_C> <a name="l00602"></a><a class="code" href="eigen__plugins_8h.html#a16e1c59496aad553322db233f7ec85b7">00602</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a16e1c59496aad553322db233f7ec85b7">multiply_ABC</a>(<span class="keyword">const</span> MAT_A &A, <span class="keyword">const</span> MAT_B &B, <span class="keyword">const</span> MAT_C &C) <span class="comment">/*!< this = A*B*C */</span> { <a name="l00603"></a>00603 *<span class="keyword">this</span> = A*B*C; <a name="l00604"></a>00604 } <a name="l00605"></a>00605 <a name="l00606"></a>00606 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A,<span class="keyword">class</span> MAT_B,<span class="keyword">class</span> MAT_C> <a name="l00607"></a><a class="code" href="eigen__plugins_8h.html#a1439097bdfd93e40d7bb2814cb07c681">00607</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a1439097bdfd93e40d7bb2814cb07c681">multiply_ABCt</a>(<span class="keyword">const</span> MAT_A &A, <span class="keyword">const</span> MAT_B &B, <span class="keyword">const</span> MAT_C &C) <span class="comment">/*!< this = A*B*(C<sup>T</sup>) */</span> { <a name="l00608"></a>00608 *<span class="keyword">this</span> = A*B*C.adjoint(); <a name="l00609"></a>00609 } <a name="l00610"></a>00610 <a name="l00611"></a>00611 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A,<span class="keyword">class</span> MAT_B,<span class="keyword">class</span> MAT_C> <a name="l00612"></a><a class="code" href="eigen__plugins_8h.html#ae34f77f56288c48df01c2176bd2c8461">00612</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ae34f77f56288c48df01c2176bd2c8461">multiply_AtBC</a>(<span class="keyword">const</span> MAT_A &A, <span class="keyword">const</span> MAT_B &B, <span class="keyword">const</span> MAT_C &C) <span class="comment">/*!< this = A(<sup>T</sup>)*B*C */</span> { <a name="l00613"></a>00613 *<span class="keyword">this</span> = A.adjoint()*B*C; <a name="l00614"></a>00614 } <a name="l00615"></a>00615 <a name="l00616"></a>00616 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A,<span class="keyword">class</span> MAT_B> <a name="l00617"></a><a class="code" href="eigen__plugins_8h.html#aaf5a04bce9f479ef8b8a5a0792bb2fc4">00617</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aaf5a04bce9f479ef8b8a5a0792bb2fc4">multiply_ABt</a>(<span class="keyword">const</span> MAT_A &A,<span class="keyword">const</span> MAT_B &B) <span class="comment">/*!< this = A * B<sup>T</sup> */</span> { <a name="l00618"></a>00618 *<span class="keyword">this</span> = A*B.adjoint(); <a name="l00619"></a>00619 } <a name="l00620"></a>00620 <a name="l00621"></a>00621 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A> <a name="l00622"></a><a class="code" href="eigen__plugins_8h.html#a2cdadc937335307b67568c2dfb7d1cce">00622</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a2cdadc937335307b67568c2dfb7d1cce">multiply_AAt</a>(<span class="keyword">const</span> MAT_A &A) <span class="comment">/*!< this = A * A<sup>T</sup> */</span> { <a name="l00623"></a>00623 *<span class="keyword">this</span> = A*A.adjoint(); <a name="l00624"></a>00624 } <a name="l00625"></a>00625 <a name="l00626"></a>00626 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A> <a name="l00627"></a><a class="code" href="eigen__plugins_8h.html#affe8d191272ecbb4e23fa730b5e1fa88">00627</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#affe8d191272ecbb4e23fa730b5e1fa88">multiply_AtA</a>(<span class="keyword">const</span> MAT_A &A) <span class="comment">/*!< this = A<sup>T</sup> * A */</span> { <a name="l00628"></a>00628 *<span class="keyword">this</span> = A.adjoint()*A; <a name="l00629"></a>00629 } <a name="l00630"></a>00630 <a name="l00631"></a>00631 <span class="keyword">template</span> <<span class="keyword">class</span> MAT_A,<span class="keyword">class</span> MAT_B> <a name="l00632"></a><a class="code" href="eigen__plugins_8h.html#ae7e21bec5c3c60fdf8c3c9bf29620aee">00632</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ae7e21bec5c3c60fdf8c3c9bf29620aee">multiply_result_is_symmetric</a>(<span class="keyword">const</span> MAT_A &A,<span class="keyword">const</span> MAT_B &B) <span class="comment">/*!< this = A * B (result is symmetric) */</span> { <a name="l00633"></a>00633 *<span class="keyword">this</span> = A*B; <a name="l00634"></a>00634 } <a name="l00635"></a>00635 <a name="l00636"></a>00636 <span class="comment"></span> <a name="l00637"></a>00637 <span class="comment"> /** Matrix left divide: RES = A<sup>-1</sup> * this , with A being squared (using the Eigen::ColPivHouseholderQR method) */</span> <a name="l00638"></a>00638 <span class="keyword">template</span><<span class="keyword">class</span> MAT2,<span class="keyword">class</span> MAT3 > <a name="l00639"></a><a class="code" href="eigen__plugins_8h.html#afd8031084236ac10c884496896a19538">00639</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#afd8031084236ac10c884496896a19538" title="Matrix left divide: RES = A-1 * this , with A being squared (using the Eigen::ColPivHouseholderQR met...">leftDivideSquare</a>(<span class="keyword">const</span> MAT2 &A, MAT3 &RES)<span class="keyword"> const</span> <a name="l00640"></a>00640 <span class="keyword"> </span>{ <a name="l00641"></a>00641 Eigen::ColPivHouseholderQR<PlainObject> QR = A.colPivHouseholderQr(); <a name="l00642"></a>00642 <span class="keywordflow">if</span> (!QR.<a class="code" href="class_eigen_1_1_col_piv_householder_q_r.html#aee3d8f40aa691d8d5e0b434ca586a490">isInvertible</a>()) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"leftDivideSquare: Matrix A is not invertible"</span>); <a name="l00643"></a>00643 RES = QR.<a class="code" href="class_eigen_1_1_col_piv_householder_q_r.html#a2471bdc11f51e656e2b8a0a5708b5c75">inverse</a>() * (*this); <a name="l00644"></a>00644 } <a name="l00645"></a>00645 <span class="comment"></span> <a name="l00646"></a>00646 <span class="comment"> /** Matrix right divide: RES = this * B<sup>-1</sup>, with B being squared (using the Eigen::ColPivHouseholderQR method) */</span> <a name="l00647"></a>00647 <span class="keyword">template</span><<span class="keyword">class</span> MAT2,<span class="keyword">class</span> MAT3 > <a name="l00648"></a><a class="code" href="eigen__plugins_8h.html#a973da4e6b14d828141087469807141e0">00648</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a973da4e6b14d828141087469807141e0" title="Matrix right divide: RES = this * B-1, with B being squared (using the Eigen::ColPivHouseholderQR met...">rightDivideSquare</a>(<span class="keyword">const</span> MAT2 &B, MAT3 &RES)<span class="keyword"> const</span> <a name="l00649"></a>00649 <span class="keyword"> </span>{ <a name="l00650"></a>00650 Eigen::ColPivHouseholderQR<PlainObject> QR = B.colPivHouseholderQr(); <a name="l00651"></a>00651 <span class="keywordflow">if</span> (!QR.<a class="code" href="class_eigen_1_1_col_piv_householder_q_r.html#aee3d8f40aa691d8d5e0b434ca586a490">isInvertible</a>()) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"rightDivideSquare: Matrix B is not invertible"</span>); <a name="l00652"></a>00652 RES = (*this) * QR.<a class="code" href="class_eigen_1_1_col_piv_householder_q_r.html#a2471bdc11f51e656e2b8a0a5708b5c75">inverse</a>(); <a name="l00653"></a>00653 } <a name="l00654"></a>00654 <span class="comment"></span> <a name="l00655"></a>00655 <span class="comment"> /** @} */</span> <span class="comment">// end multiply functions</span> <a name="l00656"></a>00656 <a name="l00657"></a>00657 <span class="comment"></span> <a name="l00658"></a>00658 <span class="comment"> /** @name MRPT plugin: Eigenvalue / Eigenvectors</span> <a name="l00659"></a>00659 <span class="comment"> @{ */</span> <a name="l00660"></a>00660 <span class="comment"></span> <a name="l00661"></a>00661 <span class="comment"> /** [For square matrices only] Compute the eigenvectors and eigenvalues (sorted), both returned as matrices: eigenvectors are the columns in "eVecs", and eigenvalues in ascending order as the diagonal of "eVals".</span> <a name="l00662"></a>00662 <span class="comment"> * \note Warning: Only the real part of complex eigenvectors and eigenvalues are returned.</span> <a name="l00663"></a>00663 <span class="comment"> * \sa eigenVectorsSymmetric, eigenVectorsVec</span> <a name="l00664"></a>00664 <span class="comment"> */</span> <a name="l00665"></a>00665 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX1,<span class="keyword">class</span> MATRIX2> <a name="l00666"></a>00666 EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#af97ed883f3a3fe3c644b878457869e25" title="[For square matrices only] Compute the eigenvectors and eigenvalues (sorted), both returned as matric...">eigenVectors</a>( MATRIX1 & eVecs, MATRIX2 & eVals ) <span class="keyword">const</span>; <a name="l00667"></a>00667 <span class="comment">// Implemented in eigen_plugins_impl.h (can't be here since Eigen::SelfAdjointEigenSolver isn't defined yet at this point.</span> <a name="l00668"></a>00668 <span class="comment"></span> <a name="l00669"></a>00669 <span class="comment"> /** [For square matrices only] Compute the eigenvectors and eigenvalues (sorted), eigenvectors are the columns in "eVecs", and eigenvalues are returned in in ascending order in the vector "eVals".</span> <a name="l00670"></a>00670 <span class="comment"> * \note Warning: Only the real part of complex eigenvectors and eigenvalues are returned.</span> <a name="l00671"></a>00671 <span class="comment"> * \sa eigenVectorsSymmetric, eigenVectorsVec</span> <a name="l00672"></a>00672 <span class="comment"> */</span> <a name="l00673"></a>00673 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX1,<span class="keyword">class</span> VECTOR1> <a name="l00674"></a>00674 EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a97273e1933b74fb9d39e97500344dbed" title="[For square matrices only] Compute the eigenvectors and eigenvalues (sorted), eigenvectors are the co...">eigenVectorsVec</a>( MATRIX1 & eVecs, VECTOR1 & eVals ) <span class="keyword">const</span>; <a name="l00675"></a>00675 <span class="comment">// Implemented in eigen_plugins_impl.h</span> <a name="l00676"></a>00676 <span class="comment"></span> <a name="l00677"></a>00677 <span class="comment"> /** [For square matrices only] Compute the eigenvectors and eigenvalues (sorted), and return only the eigenvalues in the vector "eVals".</span> <a name="l00678"></a>00678 <span class="comment"> * \note Warning: Only the real part of complex eigenvectors and eigenvalues are returned.</span> <a name="l00679"></a>00679 <span class="comment"> * \sa eigenVectorsSymmetric, eigenVectorsVec</span> <a name="l00680"></a>00680 <span class="comment"> */</span> <a name="l00681"></a>00681 <span class="keyword">template</span> <<span class="keyword">class</span> VECTOR> <a name="l00682"></a><a class="code" href="eigen__plugins_8h.html#ac24d22bc3b24cb9dea3ba3731727d187">00682</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ac24d22bc3b24cb9dea3ba3731727d187" title="[For square matrices only] Compute the eigenvectors and eigenvalues (sorted), and return only the eig...">eigenValues</a>( VECTOR & eVals )<span class="keyword"> const</span> <a name="l00683"></a>00683 <span class="keyword"> </span>{ <a name="l00684"></a>00684 PlainObject eVecs; <a name="l00685"></a>00685 eVecs.resizeLike(*<span class="keyword">this</span>); <a name="l00686"></a>00686 this-><a class="code" href="eigen__plugins_8h.html#a97273e1933b74fb9d39e97500344dbed" title="[For square matrices only] Compute the eigenvectors and eigenvalues (sorted), eigenvectors are the co...">eigenVectorsVec</a>(eVecs,eVals); <a name="l00687"></a>00687 } <a name="l00688"></a>00688 <span class="comment"></span> <a name="l00689"></a>00689 <span class="comment"> /** [For symmetric matrices only] Compute the eigenvectors and eigenvalues (in no particular order), both returned as matrices: eigenvectors are the columns, and eigenvalues \sa eigenVectors</span> <a name="l00690"></a>00690 <span class="comment"> */</span> <a name="l00691"></a>00691 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX1,<span class="keyword">class</span> MATRIX2> <a name="l00692"></a>00692 EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a387e48a41c325a427c5bd3591b39a65f" title="[For symmetric matrices only] Compute the eigenvectors and eigenvalues (in no particular order)...">eigenVectorsSymmetric</a>( MATRIX1 & eVecs, MATRIX2 & eVals ) <span class="keyword">const</span>; <a name="l00693"></a>00693 <span class="comment">// Implemented in eigen_plugins_impl.h (can't be here since Eigen::SelfAdjointEigenSolver isn't defined yet at this point.</span> <a name="l00694"></a>00694 <span class="comment"></span> <a name="l00695"></a>00695 <span class="comment"> /** [For symmetric matrices only] Compute the eigenvectors and eigenvalues (in no particular order), both returned as matrices: eigenvectors are the columns, and eigenvalues \sa eigenVectorsVec</span> <a name="l00696"></a>00696 <span class="comment"> */</span> <a name="l00697"></a>00697 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX1,<span class="keyword">class</span> VECTOR1> <a name="l00698"></a>00698 EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#ab9f00b88574d88f92bb42e8ac1d49f5f" title="[For symmetric matrices only] Compute the eigenvectors and eigenvalues (in no particular order)...">eigenVectorsSymmetricVec</a>( MATRIX1 & eVecs, VECTOR1 & eVals ) <span class="keyword">const</span>; <a name="l00699"></a>00699 <span class="comment">// Implemented in eigen_plugins_impl.h</span> <a name="l00700"></a>00700 <a name="l00701"></a>00701 <span class="comment"></span> <a name="l00702"></a>00702 <span class="comment"> /** @} */</span> <span class="comment">// end eigenvalues</span> <a name="l00703"></a>00703 <a name="l00704"></a>00704 <a name="l00705"></a>00705 <span class="comment"></span> <a name="l00706"></a>00706 <span class="comment"> /** @name MRPT plugin: Linear algebra & decomposition-based methods</span> <a name="l00707"></a>00707 <span class="comment"> @{ */</span> <a name="l00708"></a>00708 <span class="comment"></span> <a name="l00709"></a>00709 <span class="comment"> /** Cholesky M=U<sup>T</sup> * U decomposition for simetric matrix (upper-half of the matrix will be actually ignored) */</span> <a name="l00710"></a><a class="code" href="eigen__plugins_8h.html#a3e6cd09a812e8a005ddb760bad4e34b1">00710</a> <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">bool</span> <a class="code" href="eigen__plugins_8h.html#a3e6cd09a812e8a005ddb760bad4e34b1" title="Cholesky M=UT * U decomposition for simetric matrix (upper-half of the matrix will be actually ignore...">chol</a>(MATRIX &U)<span class="keyword"> const</span> <a name="l00711"></a>00711 <span class="keyword"> </span>{ <a name="l00712"></a>00712 Eigen::LLT<PlainObject> Chol = derived().selfadjointView<Eigen<a class="code" href="group__enums.html#gga551bdecb88b22a20eac625ce98ca18a5af581029282d421eee5aae14238c6f749" title="View matrix as a lower triangular matrix.">::Lower</a>>().llt(); <a name="l00713"></a>00713 <span class="keywordflow">if</span> (Chol.<a class="code" href="class_eigen_1_1_l_l_t.html#a366f42dcf9e0ec0cf4e9b3d1aad3cc82" title="Reports whether previous computation was successful.">info</a>()==Eigen<a class="code" href="namespace_eigen.html#a85fad7b87587764e5cf6b513a9e0ee5ea6a68dfb88a8336108a30588bdf356c57" title="Iterative procedure did not converge.">::NoConvergence</a>) <a name="l00714"></a>00714 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00715"></a>00715 U = PlainObject(Chol.<a class="code" href="class_eigen_1_1_l_l_t.html#a7e89a9e6861b04055ec25470d418eb8f">matrixU</a>()); <a name="l00716"></a>00716 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00717"></a>00717 } <a name="l00718"></a>00718 <span class="comment"></span> <a name="l00719"></a>00719 <span class="comment"> /** Gets the rank of the matrix via the Eigen::ColPivHouseholderQR method</span> <a name="l00720"></a>00720 <span class="comment"> * \param threshold If set to >0, it's used as threshold instead of Eigen's default one.</span> <a name="l00721"></a>00721 <span class="comment"> */</span> <a name="l00722"></a><a class="code" href="eigen__plugins_8h.html#a7fd59dfe4f0464d4f771e7ce60aad7ce">00722</a> EIGEN_STRONG_INLINE <span class="keywordtype">size_t</span> <a class="code" href="eigen__plugins_8h.html#a7fd59dfe4f0464d4f771e7ce60aad7ce" title="Gets the rank of the matrix via the Eigen::ColPivHouseholderQR method.">rank</a>(<span class="keywordtype">double</span> threshold=0)<span class="keyword"> const</span> <a name="l00723"></a>00723 <span class="keyword"> </span>{ <a name="l00724"></a>00724 Eigen::ColPivHouseholderQR<PlainObject> QR = this->colPivHouseholderQr(); <a name="l00725"></a>00725 <span class="keywordflow">if</span> (threshold>0) QR.<a class="code" href="class_eigen_1_1_col_piv_householder_q_r.html#a439472b02b9326c60f5ca4aaf24d1660" title="Allows to prescribe a threshold to be used by certain methods, such as rank(), who need to determine ...">setThreshold</a>(threshold); <a name="l00726"></a>00726 <span class="keywordflow">return</span> QR.<a class="code" href="class_eigen_1_1_col_piv_householder_q_r.html#a44ec27529fb69374116c3da688bd3173">rank</a>(); <a name="l00727"></a>00727 } <a name="l00728"></a>00728 <span class="comment"></span> <a name="l00729"></a>00729 <span class="comment"> /** @} */</span> <span class="comment">// end linear algebra</span> <a name="l00730"></a>00730 <a name="l00731"></a>00731 <a name="l00732"></a>00732 <span class="comment"></span> <a name="l00733"></a>00733 <span class="comment"> /** @name MRPT plugin: Scalar and element-wise extra operators</span> <a name="l00734"></a>00734 <span class="comment"> @{ */</span> <a name="l00735"></a>00735 <a name="l00736"></a><a class="code" href="eigen__plugins_8h.html#ab2acb79dd7808744862acb0a4ef9be85">00736</a> EIGEN_STRONG_INLINE MatrixBase<Derived>& <a class="code" href="eigen__plugins_8h.html#ab2acb79dd7808744862acb0a4ef9be85">Sqrt</a>() { (*this) = this->array().sqrt(); <span class="keywordflow">return</span> *<span class="keyword">this</span>; } <a name="l00737"></a>00737 EIGEN_STRONG_INLINE PlainObject <a class="code" href="eigen__plugins_8h.html#ab2acb79dd7808744862acb0a4ef9be85">Sqrt</a>()<span class="keyword"> const </span>{ PlainObject res = this->array().sqrt(); <span class="keywordflow">return</span> res; } <a name="l00738"></a>00738 <a name="l00739"></a><a class="code" href="eigen__plugins_8h.html#a77d94451cb53e337e050fd77ba12f8ef">00739</a> EIGEN_STRONG_INLINE MatrixBase<Derived>& <a class="code" href="eigen__plugins_8h.html#a77d94451cb53e337e050fd77ba12f8ef">Abs</a>() { (*this) = this->array().abs(); <span class="keywordflow">return</span> *<span class="keyword">this</span>; } <a name="l00740"></a>00740 EIGEN_STRONG_INLINE PlainObject <a class="code" href="eigen__plugins_8h.html#a77d94451cb53e337e050fd77ba12f8ef">Abs</a>()<span class="keyword"> const </span>{ PlainObject res = this->array().abs(); <span class="keywordflow">return</span> res; } <a name="l00741"></a>00741 <a name="l00742"></a><a class="code" href="eigen__plugins_8h.html#a092c46b72a955dcc19d4d54409b712f3">00742</a> EIGEN_STRONG_INLINE MatrixBase<Derived>& <a class="code" href="eigen__plugins_8h.html#a092c46b72a955dcc19d4d54409b712f3">Log</a>() { (*this) = this->array().log(); <span class="keywordflow">return</span> *<span class="keyword">this</span>; } <a name="l00743"></a>00743 EIGEN_STRONG_INLINE PlainObject <a class="code" href="eigen__plugins_8h.html#a092c46b72a955dcc19d4d54409b712f3">Log</a>()<span class="keyword"> const </span>{ PlainObject res = this->array().log(); <span class="keywordflow">return</span> res; } <a name="l00744"></a>00744 <a name="l00745"></a><a class="code" href="eigen__plugins_8h.html#abbbbcc2b169a97762e31203c4c9c6ac9">00745</a> EIGEN_STRONG_INLINE MatrixBase<Derived>& <a class="code" href="eigen__plugins_8h.html#abbbbcc2b169a97762e31203c4c9c6ac9">Exp</a>() { (*this) = this->array().exp(); <span class="keywordflow">return</span> *<span class="keyword">this</span>; } <a name="l00746"></a>00746 EIGEN_STRONG_INLINE PlainObject <a class="code" href="eigen__plugins_8h.html#abbbbcc2b169a97762e31203c4c9c6ac9">Exp</a>()<span class="keyword"> const </span>{ PlainObject res = this->array().exp(); <span class="keywordflow">return</span> res; } <a name="l00747"></a>00747 <a name="l00748"></a><a class="code" href="eigen__plugins_8h.html#ac0e63ea4f052f957e4428a3df2c09937">00748</a> EIGEN_STRONG_INLINE MatrixBase<Derived>& <a class="code" href="eigen__plugins_8h.html#ac0e63ea4f052f957e4428a3df2c09937">Square</a>() { (*this) = this->array().square(); <span class="keywordflow">return</span> *<span class="keyword">this</span>; } <a name="l00749"></a>00749 EIGEN_STRONG_INLINE PlainObject <a class="code" href="eigen__plugins_8h.html#ac0e63ea4f052f957e4428a3df2c09937">Square</a>()<span class="keyword"> const </span>{ PlainObject res = this->array().square(); <span class="keywordflow">return</span> res; } <a name="l00750"></a>00750 <span class="comment"></span> <a name="l00751"></a>00751 <span class="comment"> /** Scales all elements such as the minimum & maximum values are shifted to the given values */</span> <a name="l00752"></a><a class="code" href="eigen__plugins_8h.html#a9fa151d57c4246db2c3aed3642dd249b">00752</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a9fa151d57c4246db2c3aed3642dd249b" title="Scales all elements such as the minimum & maximum values are shifted to the given values...">normalize</a>(Scalar valMin, Scalar valMax) <a name="l00753"></a>00753 { <a name="l00754"></a>00754 <span class="keywordflow">if</span> (<a class="code" href="namespacemrpt_1_1math.html#a632ae0aecf78103f87f18f9ac33f7170">size</a>()==0) <span class="keywordflow">return</span>; <a name="l00755"></a>00755 Scalar curMin,curMax; <a name="l00756"></a>00756 <a class="code" href="eigen__plugins_8h.html#af1242c3a6add388208167442fd51b314" title="[VECTORS OR MATRICES] Compute the minimum and maximum of a container at once">minimum_maximum</a>(curMin,curMax); <a name="l00757"></a>00757 Scalar minMaxDelta = curMax - curMin; <a name="l00758"></a>00758 <span class="keywordflow">if</span> (minMaxDelta==0) minMaxDelta = 1; <a name="l00759"></a>00759 <span class="keyword">const</span> Scalar minMaxDelta_ = (valMax-valMin)/minMaxDelta; <a name="l00760"></a>00760 this->array() = (this->array()-curMin)*minMaxDelta_+valMin; <a name="l00761"></a>00761 }<span class="comment"></span> <a name="l00762"></a>00762 <span class="comment"> //! \overload</span> <a name="l00763"></a><a class="code" href="eigen__plugins_8h.html#a1f4ffe0a232a537963e88ba6dee3d943">00763</a> <span class="comment"></span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a1f4ffe0a232a537963e88ba6dee3d943">adjustRange</a>(Scalar valMin, Scalar valMax) { <a class="code" href="eigen__plugins_8h.html#a9fa151d57c4246db2c3aed3642dd249b" title="Scales all elements such as the minimum & maximum values are shifted to the given values...">normalize</a>(valMin,valMax); } <a name="l00764"></a>00764 <span class="comment"></span> <a name="l00765"></a>00765 <span class="comment"> /** @} */</span> <span class="comment">// end Scalar</span> <a name="l00766"></a>00766 <a name="l00767"></a>00767 <span class="comment"></span> <a name="l00768"></a>00768 <span class="comment"> /** Extract one row from the matrix into a row vector */</span> <a name="l00769"></a><a class="code" href="eigen__plugins_8h.html#a9287183f027bd93f24e8aa89e19dd375">00769</a> <span class="keyword">template</span> <<span class="keyword">class</span> OtherDerived> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a9287183f027bd93f24e8aa89e19dd375" title="Extract one row from the matrix into a row vector.">extractRow</a>(<span class="keywordtype">size_t</span> nRow, <a class="code" href="struct_eigen_1_1_eigen_base.html" title="Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...">Eigen::EigenBase<OtherDerived></a> &v, <span class="keywordtype">size_t</span> startingCol = 0)<span class="keyword"> const </span>{ <a name="l00770"></a>00770 v = derived().block(nRow,startingCol,1,cols()-startingCol); <a name="l00771"></a>00771 }<span class="comment"></span> <a name="l00772"></a>00772 <span class="comment"> //! \overload</span> <a name="l00773"></a><a class="code" href="eigen__plugins_8h.html#a8da0109df3a33350c614571c8ebdee52">00773</a> <span class="comment"></span> <span class="keyword">template</span> <<span class="keyword">typename</span> T> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a9287183f027bd93f24e8aa89e19dd375" title="Extract one row from the matrix into a row vector.">extractRow</a>(<span class="keywordtype">size_t</span> nRow, <a class="code" href="classstd_1_1vector.html">std::vector<T></a> &v, <span class="keywordtype">size_t</span> startingCol = 0)<span class="keyword"> const </span>{ <a name="l00774"></a>00774 <span class="keyword">const</span> <span class="keywordtype">size_t</span> N = cols()-startingCol; <a name="l00775"></a>00775 v.resize(N); <a name="l00776"></a>00776 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i<N;i++) v[i]=(*<span class="keyword">this</span>)(nRow,startingCol+i); <a name="l00777"></a>00777 }<span class="comment"></span> <a name="l00778"></a>00778 <span class="comment"> /** Extract one row from the matrix into a column vector */</span> <a name="l00779"></a><a class="code" href="eigen__plugins_8h.html#a177b6023e41b53873b82bfd79f3b0334">00779</a> <span class="keyword">template</span> <<span class="keyword">class</span> VECTOR> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a177b6023e41b53873b82bfd79f3b0334" title="Extract one row from the matrix into a column vector.">extractRowAsCol</a>(<span class="keywordtype">size_t</span> nRow, VECTOR &v, <span class="keywordtype">size_t</span> startingCol = 0)<span class="keyword"> const</span> <a name="l00780"></a>00780 <span class="keyword"> </span>{ <a name="l00781"></a>00781 v = derived().adjoint().block(startingCol,nRow,cols()-startingCol,1); <a name="l00782"></a>00782 } <a name="l00783"></a>00783 <a name="l00784"></a>00784 <span class="comment"></span> <a name="l00785"></a>00785 <span class="comment"> /** Extract one column from the matrix into a column vector */</span> <a name="l00786"></a><a class="code" href="eigen__plugins_8h.html#a41b03d2479325f3dafee31651ee3c41c">00786</a> <span class="keyword">template</span> <<span class="keyword">class</span> VECTOR> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a41b03d2479325f3dafee31651ee3c41c" title="Extract one column from the matrix into a column vector.">extractCol</a>(<span class="keywordtype">size_t</span> nCol, VECTOR &v, <span class="keywordtype">size_t</span> startingRow = 0)<span class="keyword"> const </span>{ <a name="l00787"></a>00787 v = derived().block(startingRow,nCol,rows()-startingRow,1); <a name="l00788"></a>00788 }<span class="comment"></span> <a name="l00789"></a>00789 <span class="comment"> //! \overload</span> <a name="l00790"></a><a class="code" href="eigen__plugins_8h.html#abd2bea909ed1fe0d393a29df274260f1">00790</a> <span class="comment"></span> <span class="keyword">template</span> <<span class="keyword">typename</span> T> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a41b03d2479325f3dafee31651ee3c41c" title="Extract one column from the matrix into a column vector.">extractCol</a>(<span class="keywordtype">size_t</span> nCol, <a class="code" href="classstd_1_1vector.html">std::vector<T></a> &v, <span class="keywordtype">size_t</span> startingRow = 0)<span class="keyword"> const </span>{ <a name="l00791"></a>00791 <span class="keyword">const</span> <span class="keywordtype">size_t</span> N = rows()-startingRow; <a name="l00792"></a>00792 v.resize(N); <a name="l00793"></a>00793 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i<N;i++) v[i]=(*<span class="keyword">this</span>)(startingRow+i,nCol); <a name="l00794"></a>00794 } <a name="l00795"></a>00795 <a name="l00796"></a><a class="code" href="eigen__plugins_8h.html#aac01fcdfdbdb053b1c1d97dadfa2a8f0">00796</a> <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aac01fcdfdbdb053b1c1d97dadfa2a8f0">extractMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> firstRow, <span class="keyword">const</span> <span class="keywordtype">size_t</span> firstCol, MATRIX &m)<span class="keyword"> const</span> <a name="l00797"></a>00797 <span class="keyword"> </span>{ <a name="l00798"></a>00798 m = derived().block(firstRow,firstCol,m.rows(),m.cols()); <a name="l00799"></a>00799 } <a name="l00800"></a><a class="code" href="eigen__plugins_8h.html#a76c16c7bf173250e67ee99aae434add0">00800</a> <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aac01fcdfdbdb053b1c1d97dadfa2a8f0">extractMatrix</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> firstRow, <span class="keyword">const</span> <span class="keywordtype">size_t</span> firstCol, <span class="keyword">const</span> <span class="keywordtype">size_t</span> nRows, <span class="keyword">const</span> <span class="keywordtype">size_t</span> nCols, MATRIX &m)<span class="keyword"> const</span> <a name="l00801"></a>00801 <span class="keyword"> </span>{ <a name="l00802"></a>00802 m.resize(nRows,nCols); <a name="l00803"></a>00803 m = derived().block(firstRow,firstCol,nRows,nCols); <a name="l00804"></a>00804 } <a name="l00805"></a>00805 <span class="comment"></span> <a name="l00806"></a>00806 <span class="comment"> /** Get a submatrix, given its bounds: first & last column and row (inclusive). */</span> <a name="l00807"></a>00807 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> <a name="l00808"></a><a class="code" href="eigen__plugins_8h.html#a21d99dfeb5280bf3286a3321ca4615e8">00808</a> EIGEN_STRONG_INLINE <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#a21d99dfeb5280bf3286a3321ca4615e8" title="Get a submatrix, given its bounds: first & last column and row (inclusive).">extractSubmatrix</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row_first,<span class="keyword">const</span> <span class="keywordtype">size_t</span> row_last,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col_first,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col_last,MATRIX &out)<span class="keyword"> const</span> <a name="l00809"></a>00809 <span class="keyword"> </span>{ <a name="l00810"></a>00810 out.resize(row_last-row_first+1,col_last-col_first+1); <a name="l00811"></a>00811 out = derived().block(row_first,col_first,row_last-row_first+1,col_last-col_first+1); <a name="l00812"></a>00812 } <a name="l00813"></a>00813 <span class="comment"></span> <a name="l00814"></a>00814 <span class="comment"> /** Get a submatrix from a square matrix, by collecting the elements M(idxs,idxs), where idxs is a sequence {block_indices(i):block_indices(i)+block_size-1} for all "i" up to the size of block_indices.</span> <a name="l00815"></a>00815 <span class="comment"> * A perfect application of this method is in extracting covariance matrices of a subset of variables from the full covariance matrix.</span> <a name="l00816"></a>00816 <span class="comment"> * \sa extractSubmatrix, extractSubmatrixSymmetrical</span> <a name="l00817"></a>00817 <span class="comment"> */</span> <a name="l00818"></a>00818 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> <a name="l00819"></a><a class="code" href="eigen__plugins_8h.html#aa12505e1d04f09e70f443609aacd86c8">00819</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#aa12505e1d04f09e70f443609aacd86c8" title="Get a submatrix from a square matrix, by collecting the elements M(idxs,idxs), where idxs is a sequen...">extractSubmatrixSymmetricalBlocks</a>( <a name="l00820"></a>00820 <span class="keyword">const</span> <span class="keywordtype">size_t</span> block_size, <a name="l00821"></a>00821 <span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector<size_t></a> &block_indices, <a name="l00822"></a>00822 MATRIX& out)<span class="keyword"> const</span> <a name="l00823"></a>00823 <span class="keyword"> </span>{ <a name="l00824"></a>00824 <span class="keywordflow">if</span> (block_size<1) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"extractSubmatrixSymmetricalBlocks: block_size must be >=1"</span>); <a name="l00825"></a>00825 <span class="keywordflow">if</span> (cols()!=rows()) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"extractSubmatrixSymmetricalBlocks: Matrix is not square."</span>); <a name="l00826"></a>00826 <a name="l00827"></a>00827 <span class="keyword">const</span> <span class="keywordtype">size_t</span> N = block_indices.size(); <a name="l00828"></a>00828 <span class="keyword">const</span> <span class="keywordtype">size_t</span> nrows_out=N*block_size; <a name="l00829"></a>00829 out.resize(nrows_out,nrows_out); <a name="l00830"></a>00830 <span class="keywordflow">if</span> (!N) <span class="keywordflow">return</span>; <span class="comment">// Done</span> <a name="l00831"></a>00831 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> dst_row_blk=0;dst_row_blk<N; ++dst_row_blk ) <a name="l00832"></a>00832 { <a name="l00833"></a>00833 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> dst_col_blk=0;dst_col_blk<N; ++dst_col_blk ) <a name="l00834"></a>00834 { <a name="l00835"></a>00835 <span class="preprocessor">#if defined(_DEBUG)</span> <a name="l00836"></a>00836 <span class="preprocessor"></span> <span class="keywordflow">if</span> (block_indices[dst_col_blk]*block_size + block_size-1>=<span class="keywordtype">size_t</span>(cols())) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"extractSubmatrixSymmetricalBlocks: Indices out of range!"</span>); <a name="l00837"></a>00837 <span class="preprocessor">#endif</span> <a name="l00838"></a>00838 <span class="preprocessor"></span> out.block(dst_row_blk * block_size,dst_col_blk * block_size, block_size,block_size) <a name="l00839"></a>00839 = <a name="l00840"></a>00840 derived().block(block_indices[dst_row_blk] * block_size, block_indices[dst_col_blk] * block_size, block_size,block_size); <a name="l00841"></a>00841 } <a name="l00842"></a>00842 } <a name="l00843"></a>00843 } <a name="l00844"></a>00844 <a name="l00845"></a>00845 <span class="comment"></span> <a name="l00846"></a>00846 <span class="comment"> /** Get a submatrix from a square matrix, by collecting the elements M(idxs,idxs), where idxs is the sequence of indices passed as argument.</span> <a name="l00847"></a>00847 <span class="comment"> * A perfect application of this method is in extracting covariance matrices of a subset of variables from the full covariance matrix.</span> <a name="l00848"></a>00848 <span class="comment"> * \sa extractSubmatrix, extractSubmatrixSymmetricalBlocks</span> <a name="l00849"></a>00849 <span class="comment"> */</span> <a name="l00850"></a>00850 <span class="keyword">template</span> <<span class="keyword">class</span> MATRIX> <a name="l00851"></a><a class="code" href="eigen__plugins_8h.html#acf0a71b2db4cd84f9a4b71d86f5f5a2f">00851</a> <span class="keywordtype">void</span> <a class="code" href="eigen__plugins_8h.html#acf0a71b2db4cd84f9a4b71d86f5f5a2f" title="Get a submatrix from a square matrix, by collecting the elements M(idxs,idxs), where idxs is the sequ...">extractSubmatrixSymmetrical</a>( <a name="l00852"></a>00852 <span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector<size_t></a> &indices, <a name="l00853"></a>00853 MATRIX& out)<span class="keyword"> const</span> <a name="l00854"></a>00854 <span class="keyword"> </span>{ <a name="l00855"></a>00855 <span class="keywordflow">if</span> (cols()!=rows()) <span class="keywordflow">throw</span> <a class="code" href="classstd_1_1runtime__error.html" title="STL class.">std::runtime_error</a>(<span class="stringliteral">"extractSubmatrixSymmetrical: Matrix is not square."</span>); <a name="l00856"></a>00856 <a name="l00857"></a>00857 <span class="keyword">const</span> <span class="keywordtype">size_t</span> N = indices.size(); <a name="l00858"></a>00858 <span class="keyword">const</span> <span class="keywordtype">size_t</span> nrows_out=N; <a name="l00859"></a>00859 out.resize(nrows_out,nrows_out); <a name="l00860"></a>00860 <span class="keywordflow">if</span> (!N) <span class="keywordflow">return</span>; <span class="comment">// Done</span> <a name="l00861"></a>00861 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> dst_row_blk=0;dst_row_blk<N; ++dst_row_blk ) <a name="l00862"></a>00862 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> dst_col_blk=0;dst_col_blk<N; ++dst_col_blk ) <a name="l00863"></a>00863 out.coeffRef(dst_row_blk,dst_col_blk) = this->coeff(indices[dst_row_blk],indices[dst_col_blk]); <a name="l00864"></a>00864 } <a name="l00865"></a>00865 </pre></div></div> </div> <br><hr><br> <table border="0" width="100%"> <tr> <td> Page generated by <a href="http://www.doxygen.org" target="_blank">Doxygen 1.7.5</a> for MRPT 0.9.5 SVN: at Sun Sep 25 17:20:18 UTC 2011</td><td></td> <td width="100"> </td> <td width="150"> </td></tr> </table> </body></html>