Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 4bc66056a634db26a1f4d0845dc41ca6 > files > 968

mrpt-doc-0.9.5-0.1.20110925svn2670.fc16.i686.rpm

<!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>CMatrixTemplate.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> &gt; <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&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;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&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">CMatrixTemplate.h</div>  </div>
</div>
<div class="contents">
<a href="_c_matrix_template_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  &lt;jlblanco@ctima.uma.es&gt;                     |</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 &lt;http://www.gnu.org/licenses/&gt;.         |</span>
<a name="l00026"></a>00026 <span class="comment">   |                                                                           |</span>
<a name="l00027"></a>00027 <span class="comment">   +---------------------------------------------------------------------------+ */</span>
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef CMatrixTemplate_H</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define CMatrixTemplate_H</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;<a class="code" href="utils__defs_8h.html">mrpt/utils/utils_defs.h</a>&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="memory_8h.html">mrpt/system/memory.h</a>&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;<a class="code" href="datetime_8h.html">mrpt/system/datetime.h</a>&gt;</span>
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;<a class="code" href="math__frwds_8h.html">mrpt/math/math_frwds.h</a>&gt;</span>  <span class="comment">// Fordward declarations</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;<a class="code" href="matrix__adaptors_8h.html">mrpt/math/matrix_adaptors.h</a>&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;<a class="code" href="_c_array_8h.html">mrpt/math/CArray.h</a>&gt;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="keyword">namespace </span>mrpt
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041         <span class="keyword">namespace </span>math
<a name="l00042"></a>00042         {
<a name="l00043"></a>00043 <span class="comment"></span>
<a name="l00044"></a>00044 <span class="comment">                /**  This template class provides the basic functionality for a general 2D any-size, resizable container of numerical or non-numerical elements.</span>
<a name="l00045"></a>00045 <span class="comment">                 * NOTES:</span>
<a name="l00046"></a>00046 <span class="comment">                 *              - This class is not serializable since it is a template. For using serialization, see mrpt::math::CMatrixNumeric</span>
<a name="l00047"></a>00047 <span class="comment">                 *              - First row or column index is &quot;0&quot;.</span>
<a name="l00048"></a>00048 <span class="comment">                 *              - This class includes range checks with ASSERT_() if compiling with &quot;_DEBUG&quot; or &quot;MRPT_ALWAYS_CHECKS_DEBUG_MATRICES=1&quot;.</span>
<a name="l00049"></a>00049 <span class="comment">                 *              - Please DO NOT use as template class type any other class. It can be safely used the following types:</span>
<a name="l00050"></a>00050 <span class="comment">                 *                      - Elemental types (int,char,float,doble,...)</span>
<a name="l00051"></a>00051 <span class="comment">                 *                      - Data struct (Not classes!)</span>
<a name="l00052"></a>00052 <span class="comment">                 *                      - Any kind of pointers (user is responsible for allocating and freeing the memory addressed by pointers).</span>
<a name="l00053"></a>00053 <span class="comment">                 *</span>
<a name="l00054"></a>00054 <span class="comment">                 * \note Memory blocks for each row are 16-bytes aligned (since MRPT 0.7.0).</span>
<a name="l00055"></a>00055 <span class="comment">                 * \note For a complete introduction to Matrices and vectors in MRPT, see: http://www.mrpt.org/Matrices_vectors_arrays_and_Linear_Algebra_MRPT_and_Eigen_classes</span>
<a name="l00056"></a>00056 <span class="comment">                 * \sa CMatrixTemplateNumeric</span>
<a name="l00057"></a>00057 <span class="comment">                 * \ingroup mrpt_base_grp</span>
<a name="l00058"></a>00058 <span class="comment">                 */</span>
<a name="l00059"></a>00059                 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00060"></a>00060                 <span class="keyword">class </span>CMatrixTemplate
<a name="l00061"></a>00061                 {
<a name="l00062"></a>00062                 <span class="keyword">public</span>:
<a name="l00063"></a>00063                         <span class="comment">// type definitions</span>
<a name="l00064"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a4830116521101867b1476d22ca6a693d">00064</a>                         <span class="keyword">typedef</span> T              <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a4830116521101867b1476d22ca6a693d" title="The type of the matrix elements.">value_type</a>;              <span class="comment">//!&lt; The type of the matrix elements</span>
<a name="l00065"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a108346cbe078d54ec6fad3ff8e1ff9b1">00065</a> <span class="comment"></span>                        <span class="keyword">typedef</span> T&amp;             <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a108346cbe078d54ec6fad3ff8e1ff9b1">reference</a>;
<a name="l00066"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a7effa0f8b45eecf05f527e6feaa61091">00066</a>                         <span class="keyword">typedef</span> <span class="keyword">const</span> T&amp;       <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a7effa0f8b45eecf05f527e6feaa61091">const_reference</a>;
<a name="l00067"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a10907affc3d4f25d535ad2a0cd38bf67">00067</a>                         <span class="keyword">typedef</span> std::size_t    <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a10907affc3d4f25d535ad2a0cd38bf67">size_type</a>;
<a name="l00068"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#aeba2da88f247ab02643262b0b0b0dce9">00068</a>                         <span class="keyword">typedef</span> std::ptrdiff_t <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#aeba2da88f247ab02643262b0b0b0dce9">difference_type</a>;
<a name="l00069"></a>00069 
<a name="l00070"></a>00070 
<a name="l00071"></a>00071                 <span class="keyword">protected</span>:
<a name="l00072"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">00072</a>                         T                               **<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>;
<a name="l00073"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">00073</a>                         <span class="keywordtype">size_t</span>                  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>, <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>;
<a name="l00074"></a>00074 <span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">                        /** Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if posible.</span>
<a name="l00076"></a>00076 <span class="comment">                          */</span>
<a name="l00077"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835">00077</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col, <span class="keywordtype">bool</span> newElementsToZero = <span class="keyword">false</span>)
<a name="l00078"></a>00078                         {
<a name="l00079"></a>00079                                 <span class="keywordflow">if</span> (row!=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> || col!=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a> || <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>==NULL)
<a name="l00080"></a>00080                                 {
<a name="l00081"></a>00081                                         <span class="keywordtype">size_t</span>  r;
<a name="l00082"></a>00082                                         <span class="keywordtype">bool</span>    doZeroColumns   = newElementsToZero &amp;&amp; (col&gt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>);
<a name="l00083"></a>00083                                         <span class="keywordtype">size_t</span>  sizeZeroColumns = <span class="keyword">sizeof</span>(T)*(col-<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>);
<a name="l00084"></a>00084 
<a name="l00085"></a>00085                                         <span class="comment">// If we are reducing rows, free that memory:</span>
<a name="l00086"></a>00086                                         <span class="keywordflow">for</span> (r=row;r&lt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>;r++)
<a name="l00087"></a>00087                                                 <a class="code" href="group__mrpt__memory.html#gab6aa729988ee1bd79ce4922b0bfc1f54" title="Frees a memory block reserved by aligned_malloc.">mrpt::system::os::aligned_free</a>( <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[r] );
<a name="l00088"></a>00088 
<a name="l00089"></a>00089                                         <span class="comment">// Realloc the vector of pointers:</span>
<a name="l00090"></a>00090                                         <span class="keywordflow">if</span> (!row)
<a name="l00091"></a>00091                                                         { <a class="code" href="group__mrpt__memory.html#gab6aa729988ee1bd79ce4922b0bfc1f54" title="Frees a memory block reserved by aligned_malloc.">mrpt::system::os::aligned_free</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>); <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>=NULL; }
<a name="l00092"></a>00092                                         <span class="keywordflow">else</span>    <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a> = <span class="keyword">static_cast&lt;</span>T**<span class="keyword">&gt;</span> (<a class="code" href="group__mrpt__memory.html#gaa0dd8ec272a9f40a191342057c185bd9" title="Frees a memory block reserved by aligned_malloc.">mrpt::system::os::aligned_realloc</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>, <span class="keyword">sizeof</span>(T*) * row, 16 ) );
<a name="l00093"></a>00093 
<a name="l00094"></a>00094                                         <span class="comment">// How many new rows/cols?</span>
<a name="l00095"></a>00095                                         <span class="keywordtype">size_t</span>  row_size = col * <span class="keyword">sizeof</span>(T);
<a name="l00096"></a>00096 
<a name="l00097"></a>00097                                         <span class="comment">// Alloc new ROW pointers &amp; resize previously existing rows, as required:</span>
<a name="l00098"></a>00098                                         <span class="keywordflow">for</span> (r=0;r&lt;row;r++)
<a name="l00099"></a>00099                                         {
<a name="l00100"></a>00100                                                 <span class="keywordflow">if</span> (r&lt;m_Rows)
<a name="l00101"></a>00101                                                 {
<a name="l00102"></a>00102                                                         <span class="comment">// This was an existing row: Resize the memory:</span>
<a name="l00103"></a>00103                                                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[r] = <span class="keyword">static_cast&lt;</span>T*<span class="keyword">&gt;</span> (<a class="code" href="group__mrpt__memory.html#gaa0dd8ec272a9f40a191342057c185bd9" title="Frees a memory block reserved by aligned_malloc.">mrpt::system::os::aligned_realloc</a>( <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[r], row_size, 16));
<a name="l00104"></a>00104 
<a name="l00105"></a>00105                                                         <span class="keywordflow">if</span> (doZeroColumns)
<a name="l00106"></a>00106                                                         {
<a name="l00107"></a>00107                                                                 <span class="comment">// Fill with zeros:</span>
<a name="l00108"></a>00108                                                                 ::memset(&amp;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[r][<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>],0,sizeZeroColumns);
<a name="l00109"></a>00109                                                         }
<a name="l00110"></a>00110                                                 }
<a name="l00111"></a>00111                                                 <span class="keywordflow">else</span>
<a name="l00112"></a>00112                                                 {
<a name="l00113"></a>00113                                                         <span class="comment">// This is a new row, alloc the memory for the first time:</span>
<a name="l00114"></a>00114                                                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[r] = <span class="keyword">static_cast&lt;</span>T*<span class="keyword">&gt;</span> ( <a class="code" href="group__mrpt__memory.html#ga1f0f740a33507bf943af5bac26e3abb0" title="Identical to aligned_malloc, but it zeroes the reserved memory block.">mrpt::system::os::aligned_calloc</a>( row_size, 16 ));
<a name="l00115"></a>00115                                                 }
<a name="l00116"></a>00116                                         }
<a name="l00117"></a>00117                                         <span class="comment">// Done!</span>
<a name="l00118"></a>00118                                         m_Rows  = row;
<a name="l00119"></a>00119                                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>  = col;
<a name="l00120"></a>00120                                 }
<a name="l00121"></a>00121                         }
<a name="l00122"></a>00122 
<a name="l00123"></a>00123                 <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00124"></a>00124 <span class="comment">                        /**</span>
<a name="l00125"></a>00125 <span class="comment">                          * Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix.</span>
<a name="l00126"></a>00126 <span class="comment">                          */</span>
<a name="l00127"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a3cba8d34be5588f1feac6087b222f660">00127</a>                         <span class="keyword">template</span>&lt;<span class="keywordtype">size_t</span> N&gt; <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a3cba8d34be5588f1feac6087b222f660" title="Checks whether the rows [r-N,r+N] and the columns [c-N,c+N] are present in the matrix.">ASSERT_ENOUGHROOM</a>(<span class="keywordtype">size_t</span> r,<span class="keywordtype">size_t</span> c)<span class="keyword"> const       </span>{
<a name="l00128"></a>00128 <span class="preprocessor">                                #if defined(_DEBUG)||(MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00129"></a>00129 <span class="preprocessor"></span>                                        <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>((r&gt;=N)&amp;&amp;(r+N&lt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a0d8f81e3e3bd53007eb189734f6bfd05" title="Number of rows in the matrix.">getRowCount</a>())&amp;&amp;(c&gt;=N)&amp;&amp;(c+N&lt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a6e471dbc4f15a3f90a969afa16adb5ac" title="Number of columns in the matrix.">getColCount</a>()));
<a name="l00130"></a>00130 <span class="preprocessor">                                #endif</span>
<a name="l00131"></a>00131 <span class="preprocessor"></span>                        }<span class="comment"></span>
<a name="l00132"></a>00132 <span class="comment">                        /*! Fill all the elements with a given value (Note: named &quot;fillAll&quot; since &quot;fill&quot; will be used by child classes) */</span>
<a name="l00133"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#abf0d2fd28afe3dfb231644b488063aaa">00133</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#abf0d2fd28afe3dfb231644b488063aaa">fillAll</a>(<span class="keyword">const</span> T &amp;val) {
<a name="l00134"></a>00134                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> r=0;r&lt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>;r++)
<a name="l00135"></a>00135                                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> c=0;c&lt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>;c++)
<a name="l00136"></a>00136                                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[r][c]=val;
<a name="l00137"></a>00137                         }
<a name="l00138"></a>00138 <span class="comment"></span>
<a name="l00139"></a>00139 <span class="comment">                        /** Swap with another matrix very efficiently (just swaps a pointer and two integer values). */</span>
<a name="l00140"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab3dbe770776954d72852612ccd776148">00140</a>                         <span class="keyword">inline</span> <span class="keywordtype">void</span>  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab3dbe770776954d72852612ccd776148" title="Swap with another matrix very efficiently (just swaps a pointer and two integer values).">swap</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate&lt;T&gt;</a> &amp;o)
<a name="l00141"></a>00141                         {
<a name="l00142"></a>00142                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab3dbe770776954d72852612ccd776148" title="Swap with another matrix very efficiently (just swaps a pointer and two integer values).">std::swap</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>,  o.m_Val  );
<a name="l00143"></a>00143                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab3dbe770776954d72852612ccd776148" title="Swap with another matrix very efficiently (just swaps a pointer and two integer values).">std::swap</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>, o.m_Rows );
<a name="l00144"></a>00144                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab3dbe770776954d72852612ccd776148" title="Swap with another matrix very efficiently (just swaps a pointer and two integer values).">std::swap</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>, o.m_Cols );
<a name="l00145"></a>00145                         }
<a name="l00146"></a>00146 <span class="comment"></span>
<a name="l00147"></a>00147 <span class="comment">                        /** Constructors */</span>
<a name="l00148"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#acde4bbf7122752da968620879d77f4a5">00148</a>                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#acde4bbf7122752da968620879d77f4a5" title="Constructors.">CMatrixTemplate</a> (<span class="keyword">const</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate</a>&amp; m) : <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>(NULL),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>(0),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>(0)
<a name="l00149"></a>00149                         {
<a name="l00150"></a>00150                                 (*this) = m;
<a name="l00151"></a>00151                         }
<a name="l00152"></a>00152 
<a name="l00153"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab21ba4098d7c413d95a1729c0d3e3d74">00153</a>                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#acde4bbf7122752da968620879d77f4a5" title="Constructors.">CMatrixTemplate</a> (<span class="keywordtype">size_t</span> row = 1, <span class="keywordtype">size_t</span> col = 1) :  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>(NULL),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>(0),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>(0)
<a name="l00154"></a>00154                         {
<a name="l00155"></a>00155                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>(row,col);
<a name="l00156"></a>00156                         }
<a name="l00157"></a>00157 <span class="comment"></span>
<a name="l00158"></a>00158 <span class="comment">                        /** Copy constructor &amp; crop from another matrix</span>
<a name="l00159"></a>00159 <span class="comment">                        */</span>
<a name="l00160"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#aad657a6feb35f398a22e97d2ea91ea9b">00160</a>                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#acde4bbf7122752da968620879d77f4a5" title="Constructors.">CMatrixTemplate</a> (<span class="keyword">const</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate</a>&amp; m, <span class="keyword">const</span> <span class="keywordtype">size_t</span> cropRowCount, <span class="keyword">const</span> <span class="keywordtype">size_t</span> cropColCount) : <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>(NULL),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>(0),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>(0)
<a name="l00161"></a>00161                         {
<a name="l00162"></a>00162                                 <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(m.m_Rows&gt;=cropRowCount)
<a name="l00163"></a>00163                                 <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(m.m_Cols&gt;=cropColCount)
<a name="l00164"></a>00164                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>( cropRowCount, cropColCount );
<a name="l00165"></a>00165                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>; i++)
<a name="l00166"></a>00166                                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>; j++)
<a name="l00167"></a>00167                                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][j] = m.m_Val[i][j];
<a name="l00168"></a>00168                         }
<a name="l00169"></a>00169 <span class="comment"></span>
<a name="l00170"></a>00170 <span class="comment">                        /** Constructor from a given size and a C array. The array length must match cols x row.</span>
<a name="l00171"></a>00171 <span class="comment">                          * \code</span>
<a name="l00172"></a>00172 <span class="comment">                          *  const double numbers[] = {</span>
<a name="l00173"></a>00173 <span class="comment">                          *    1,2,3,</span>
<a name="l00174"></a>00174 <span class="comment">                          *    4,5,6 };</span>
<a name="l00175"></a>00175 <span class="comment">                          *      CMatrixDouble   M(3,2, numbers);</span>
<a name="l00176"></a>00176 <span class="comment">                          * \endcode</span>
<a name="l00177"></a>00177 <span class="comment">                          */</span>
<a name="l00178"></a>00178                         <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V, <span class="keywordtype">size_t</span> N&gt;
<a name="l00179"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab88aee6ec8116d03c1155012936f8b47">00179</a>                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#acde4bbf7122752da968620879d77f4a5" title="Constructors.">CMatrixTemplate</a> (<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col, V (&amp;theArray)[N] ) :  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>(NULL),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>(0),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>(0)
<a name="l00180"></a>00180                         {
<a name="l00181"></a>00181                                 <a class="code" href="mrpt__macros_8h.html#a375dbd0ce9cb69a56d76d0fa21536bae">MRPT_COMPILE_TIME_ASSERT</a>(N!=0)
<a name="l00182"></a>00182                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>(row,col);
<a name="l00183"></a>00183                                 <span class="keywordflow">if</span> (<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>*<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a> != N) <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Mismatch between matrix size %lu x %lu and array of length %lu&quot;</span>,static_cast&lt;long unsigned&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;long unsigned&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>),static_cast&lt;long unsigned&gt;(N)))
<a name="l00184"></a>00184                                 <span class="keywordtype">size_t</span>  idx=0;
<a name="l00185"></a>00185                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>; i++)
<a name="l00186"></a>00186                                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>; j++)
<a name="l00187"></a>00187                                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][j] = static_cast&lt;T&gt;(theArray[idx++]);
<a name="l00188"></a>00188                         }
<a name="l00189"></a>00189 <span class="comment"></span>
<a name="l00190"></a>00190 <span class="comment">                        /** Constructor from a given size and a STL container (std::vector, std::list,...) with the initial values. The vector length must match cols x row.</span>
<a name="l00191"></a>00191 <span class="comment">                        */</span>
<a name="l00192"></a>00192                         <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V&gt;
<a name="l00193"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ae955c632d1aced03fa08d3952374c9f7">00193</a>                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#acde4bbf7122752da968620879d77f4a5" title="Constructors.">CMatrixTemplate</a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col, <span class="keyword">const</span> V &amp;theVector ) :  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>(NULL),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>(0),<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>(0)
<a name="l00194"></a>00194                         {
<a name="l00195"></a>00195                                 <span class="keyword">const</span> <span class="keywordtype">size_t</span> N = theVector.size();
<a name="l00196"></a>00196                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>(row,col);
<a name="l00197"></a>00197                                 <span class="keywordflow">if</span> (<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>*<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a> != N)  <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Mismatch between matrix size %lu x %lu and array of length %lu&quot;</span>,static_cast&lt;long unsigned&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;long unsigned&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>),static_cast&lt;long unsigned&gt;(N)))
<a name="l00198"></a>00198                                 <span class="keyword">typename</span> V<a class="code" href="eigen__plugins_8h.html#a8dbda719917732693c56cee228465ed9">::const_iterator</a> it = theVector.begin();
<a name="l00199"></a>00199                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>; i++)
<a name="l00200"></a>00200                                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>; j++)
<a name="l00201"></a>00201                                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][j] = static_cast&lt;T&gt;( *(it++) );
<a name="l00202"></a>00202                         }
<a name="l00203"></a>00203 <span class="comment"></span>
<a name="l00204"></a>00204 <span class="comment">                        /** Destructor */</span>
<a name="l00205"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a9d9d888c9ddbe823c176589ea3425055">00205</a>                         <span class="keyword">virtual</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a9d9d888c9ddbe823c176589ea3425055" title="Destructor.">~CMatrixTemplate</a>() { <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>(0,0); }
<a name="l00206"></a>00206 <span class="comment"></span>
<a name="l00207"></a>00207 <span class="comment">                        /** Assignment operator from another matrix */</span>
<a name="l00208"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#abf284b2591a23c32ea02f997ea7c380e">00208</a>                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate</a>&amp; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#abf284b2591a23c32ea02f997ea7c380e" title="Assignment operator from another matrix.">operator = </a>(<span class="keyword">const</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate</a>&amp; m)
<a name="l00209"></a>00209                         {
<a name="l00210"></a>00210                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>( m.m_Rows, m.m_Cols );
<a name="l00211"></a>00211                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>; i++)
<a name="l00212"></a>00212                                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>; j++)
<a name="l00213"></a>00213                                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][j] = m.m_Val[i][j];
<a name="l00214"></a>00214                                 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00215"></a>00215                         }
<a name="l00216"></a>00216 <span class="comment"></span>
<a name="l00217"></a>00217 <span class="comment">                        /** Assignment operator for initializing from a C array (The matrix must be set to the correct size before invoking this asignament)</span>
<a name="l00218"></a>00218 <span class="comment">                          * \code</span>
<a name="l00219"></a>00219 <span class="comment">                          *      CMatrixDouble   M(3,2);</span>
<a name="l00220"></a>00220 <span class="comment">                          *  const double numbers[] = {</span>
<a name="l00221"></a>00221 <span class="comment">                          *    1,2,3,</span>
<a name="l00222"></a>00222 <span class="comment">                          *    4,5,6 };</span>
<a name="l00223"></a>00223 <span class="comment">                          *  M = numbers;</span>
<a name="l00224"></a>00224 <span class="comment">                          * \endcode</span>
<a name="l00225"></a>00225 <span class="comment">                          *  Refer also to the constructor with initialization data CMatrixTemplate::CMatrixTemplate</span>
<a name="l00226"></a>00226 <span class="comment">                          */</span>
<a name="l00227"></a>00227                         <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V, <span class="keywordtype">size_t</span> N&gt;
<a name="l00228"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a8ba6eb0d9cfbd59246e0410c922ca914">00228</a>                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate</a>&amp; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#abf284b2591a23c32ea02f997ea7c380e" title="Assignment operator from another matrix.">operator = </a>(V (&amp;theArray)[N] )
<a name="l00229"></a>00229                         {
<a name="l00230"></a>00230                                 <a class="code" href="mrpt__macros_8h.html#a375dbd0ce9cb69a56d76d0fa21536bae">MRPT_COMPILE_TIME_ASSERT</a>(N!=0)
<a name="l00231"></a>00231                                 <span class="keywordflow">if</span> (<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>*<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a> != N)
<a name="l00232"></a>00232                                 {
<a name="l00233"></a>00233                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Mismatch between matrix size %lu x %lu and array of length %lu&quot;</span>,<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>,<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>,N))
<a name="l00234"></a>00234                                 }
<a name="l00235"></a>00235                                 <span class="keywordtype">size_t</span>  idx=0;
<a name="l00236"></a>00236                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0; i &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>; i++)
<a name="l00237"></a>00237                                         <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0; j &lt; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>; j++)
<a name="l00238"></a>00238                                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][j] = static_cast&lt;T&gt;(theArray[idx++]);
<a name="l00239"></a>00239                                 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
<a name="l00240"></a>00240                         }
<a name="l00241"></a>00241 <span class="comment"></span>
<a name="l00242"></a>00242 <span class="comment">                        /** Number of rows in the matrix</span>
<a name="l00243"></a>00243 <span class="comment">                          * \sa getRowCount, getColCount, nr, nc</span>
<a name="l00244"></a>00244 <span class="comment">                          */</span>
<a name="l00245"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a0d8f81e3e3bd53007eb189734f6bfd05">00245</a>                         <span class="keyword">inline</span> <span class="keywordtype">size_t</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a0d8f81e3e3bd53007eb189734f6bfd05" title="Number of rows in the matrix.">getRowCount</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>; }
<a name="l00246"></a>00246 <span class="comment"></span>
<a name="l00247"></a>00247 <span class="comment">                        /** Number of columns in the matrix</span>
<a name="l00248"></a>00248 <span class="comment">                          * \sa getRowCount, getColCount, nr, nc</span>
<a name="l00249"></a>00249 <span class="comment">                         */</span>
<a name="l00250"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a6e471dbc4f15a3f90a969afa16adb5ac">00250</a>                         <span class="keyword">inline</span> <span class="keywordtype">size_t</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a6e471dbc4f15a3f90a969afa16adb5ac" title="Number of columns in the matrix.">getColCount</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>; }
<a name="l00251"></a>00251 <span class="comment"></span>
<a name="l00252"></a>00252 <span class="comment">                        /** Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x)) */</span>
<a name="l00253"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#af45d31ffeb9baae30b246793cd795f19">00253</a>                         <span class="keyword">inline</span> <a class="code" href="structmrpt_1_1math_1_1_c_matrix_template_size.html" title="Auxiliary class used in CMatrixTemplate:size(), CMatrixTemplate::resize(), CMatrixFixedNumeric::size(...">CMatrixTemplateSize</a> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#af45d31ffeb9baae30b246793cd795f19" title="Get a 2-vector with [NROWS NCOLS] (as in MATLAB command size(x))">size</a>()<span class="keyword"> const</span>
<a name="l00254"></a>00254 <span class="keyword">                        </span>{
<a name="l00255"></a>00255                                 <a class="code" href="structmrpt_1_1math_1_1_c_matrix_template_size.html" title="Auxiliary class used in CMatrixTemplate:size(), CMatrixTemplate::resize(), CMatrixFixedNumeric::size(...">CMatrixTemplateSize</a> dims;
<a name="l00256"></a>00256                                 dims[0]=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>;
<a name="l00257"></a>00257                                 dims[1]=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>;
<a name="l00258"></a>00258                                 <span class="keywordflow">return</span> dims;
<a name="l00259"></a>00259                         }
<a name="l00260"></a>00260 <span class="comment"></span>
<a name="l00261"></a>00261 <span class="comment">                        /** Changes the size of matrix, maintaining the previous contents. */</span>
<a name="l00262"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#af881b80ad52c0cd378cdf85a10120ace">00262</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#af881b80ad52c0cd378cdf85a10120ace" title="Changes the size of matrix, maintaining the previous contents.">setSize</a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col,<span class="keywordtype">bool</span> zeroNewElements=<span class="keyword">false</span>)
<a name="l00263"></a>00263                         {
<a name="l00264"></a>00264                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>(row,col,zeroNewElements);
<a name="l00265"></a>00265                         }
<a name="l00266"></a>00266 <span class="comment"></span>
<a name="l00267"></a>00267 <span class="comment">                        /** This method just checks has no effects in this class, but raises an exception if the expected size does not match */</span>
<a name="l00268"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afebb79fd81c53f5dba00869c0ad43b9b">00268</a>                         <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afebb79fd81c53f5dba00869c0ad43b9b" title="This method just checks has no effects in this class, but raises an exception if the expected size do...">resize</a>(<span class="keyword">const</span> <a class="code" href="structmrpt_1_1math_1_1_c_matrix_template_size.html" title="Auxiliary class used in CMatrixTemplate:size(), CMatrixTemplate::resize(), CMatrixFixedNumeric::size(...">CMatrixTemplateSize</a> &amp;siz,<span class="keywordtype">bool</span> zeroNewElements=<span class="keyword">false</span>)
<a name="l00269"></a>00269                         {
<a name="l00270"></a>00270                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#af881b80ad52c0cd378cdf85a10120ace" title="Changes the size of matrix, maintaining the previous contents.">setSize</a>(siz[0],siz[1],zeroNewElements);
<a name="l00271"></a>00271                         }
<a name="l00272"></a>00272 <span class="comment"></span>
<a name="l00273"></a>00273 <span class="comment">                        /** Subscript operator to get/set individual elements</span>
<a name="l00274"></a>00274 <span class="comment">                                */</span>
<a name="l00275"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afe572c043df380736510f33c01eceb40">00275</a>                         <span class="keyword">inline</span> T&amp; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afe572c043df380736510f33c01eceb40" title="Subscript operator to get/set individual elements.">operator () </a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col)
<a name="l00276"></a>00276                         {
<a name="l00277"></a>00277 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00278"></a>00278 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (row &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> || col &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00279"></a>00279                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>( <a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Indexes (%lu,%lu) out of range. Matrix is %lux%lu&quot;</span>,static_cast&lt;unsigned long&gt;(row),static_cast&lt;unsigned long&gt;(col),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)) );
<a name="l00280"></a>00280 <span class="preprocessor">                #endif</span>
<a name="l00281"></a>00281 <span class="preprocessor"></span>                                <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row][col];
<a name="l00282"></a>00282                         }
<a name="l00283"></a>00283 <span class="comment"></span>
<a name="l00284"></a>00284 <span class="comment">                        /** Subscript operator to get individual elements</span>
<a name="l00285"></a>00285 <span class="comment">                                */</span>
<a name="l00286"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a3c971495663e675d8e2c500139499f1e">00286</a>                         <span class="keyword">inline</span> <span class="keyword">const</span> T &amp;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afe572c043df380736510f33c01eceb40" title="Subscript operator to get/set individual elements.">operator () </a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col)<span class="keyword"> const</span>
<a name="l00287"></a>00287 <span class="keyword">                        </span>{
<a name="l00288"></a>00288 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00289"></a>00289 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (row &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> || col &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00290"></a>00290                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>( <a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Indexes (%lu,%lu) out of range. Matrix is %lux%lu&quot;</span>,static_cast&lt;unsigned long&gt;(row),static_cast&lt;unsigned long&gt;(col),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)) );
<a name="l00291"></a>00291 <span class="preprocessor">                #endif</span>
<a name="l00292"></a>00292 <span class="preprocessor"></span>                                <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row][col];
<a name="l00293"></a>00293                         }
<a name="l00294"></a>00294 <span class="comment"></span>
<a name="l00295"></a>00295 <span class="comment">                        /** Subscript operator to get/set an individual element from a row or column matrix.</span>
<a name="l00296"></a>00296 <span class="comment">                          * \exception std::exception If the object is not a column or row matrix.</span>
<a name="l00297"></a>00297 <span class="comment">                          */</span>
<a name="l00298"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a59e5ba44ee8bce50f381c6ade90031ea">00298</a>                         <span class="keyword">inline</span> T&amp; <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afe572c043df380736510f33c01eceb40" title="Subscript operator to get/set individual elements.">operator () </a>(<span class="keywordtype">size_t</span> ith)
<a name="l00299"></a>00299                         {
<a name="l00300"></a>00300 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00301"></a>00301 <span class="preprocessor"></span>                                <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>==1 || <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>==1);
<a name="l00302"></a>00302 <span class="preprocessor">                #endif</span>
<a name="l00303"></a>00303 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>==1)
<a name="l00304"></a>00304                                 {
<a name="l00305"></a>00305                                         <span class="comment">// A row matrix:</span>
<a name="l00306"></a>00306 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00307"></a>00307 <span class="preprocessor"></span>                                        <span class="keywordflow">if</span> (ith &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00308"></a>00308                                                 <a class="code" href="mrpt__macros_8h.html#a61a8d46146210ee20fa1ff423257a5ec">THROW_EXCEPTION_CUSTOM_MSG1</a>( <span class="stringliteral">&quot;Index %u out of range!&quot;</span>,static_cast&lt;unsigned&gt;(ith) );
<a name="l00309"></a>00309 <span class="preprocessor">                #endif</span>
<a name="l00310"></a>00310 <span class="preprocessor"></span>                                        <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[0][ith];
<a name="l00311"></a>00311                                 }
<a name="l00312"></a>00312                                 <span class="keywordflow">else</span>
<a name="l00313"></a>00313                                 {
<a name="l00314"></a>00314                                         <span class="comment">// A columns matrix:</span>
<a name="l00315"></a>00315 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00316"></a>00316 <span class="preprocessor"></span>                                        <span class="keywordflow">if</span> (ith &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>)
<a name="l00317"></a>00317                                                 <a class="code" href="mrpt__macros_8h.html#a61a8d46146210ee20fa1ff423257a5ec">THROW_EXCEPTION_CUSTOM_MSG1</a>( <span class="stringliteral">&quot;Index %u out of range!&quot;</span>,static_cast&lt;unsigned&gt;(ith) );
<a name="l00318"></a>00318 <span class="preprocessor">                #endif</span>
<a name="l00319"></a>00319 <span class="preprocessor"></span>                                        <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[ith][0];
<a name="l00320"></a>00320                                 }
<a name="l00321"></a>00321                         }
<a name="l00322"></a>00322 <span class="comment"></span>
<a name="l00323"></a>00323 <span class="comment">                        /** Subscript operator to get/set an individual element from a row or column matrix.</span>
<a name="l00324"></a>00324 <span class="comment">                          * \exception std::exception If the object is not a column or row matrix.</span>
<a name="l00325"></a>00325 <span class="comment">                          */</span>
<a name="l00326"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca169901f8db5f2f845176e5b5db2f0">00326</a>                         <span class="keyword">inline</span> T <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afe572c043df380736510f33c01eceb40" title="Subscript operator to get/set individual elements.">operator () </a>(<span class="keywordtype">size_t</span> ith)<span class="keyword"> const</span>
<a name="l00327"></a>00327 <span class="keyword">                        </span>{
<a name="l00328"></a>00328 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00329"></a>00329 <span class="preprocessor"></span>                                <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>==1 || <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>==1);
<a name="l00330"></a>00330 <span class="preprocessor">                #endif</span>
<a name="l00331"></a>00331 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>==1)
<a name="l00332"></a>00332                                 {
<a name="l00333"></a>00333                                         <span class="comment">// A row matrix:</span>
<a name="l00334"></a>00334 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00335"></a>00335 <span class="preprocessor"></span>                                        <span class="keywordflow">if</span> (ith &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00336"></a>00336                                                 <a class="code" href="mrpt__macros_8h.html#a61a8d46146210ee20fa1ff423257a5ec">THROW_EXCEPTION_CUSTOM_MSG1</a>( <span class="stringliteral">&quot;Index %u out of range!&quot;</span>,static_cast&lt;unsigned&gt;(ith) );
<a name="l00337"></a>00337 <span class="preprocessor">                #endif</span>
<a name="l00338"></a>00338 <span class="preprocessor"></span>                                        <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[0][ith];
<a name="l00339"></a>00339                                 }
<a name="l00340"></a>00340                                 <span class="keywordflow">else</span>
<a name="l00341"></a>00341                                 {
<a name="l00342"></a>00342                                         <span class="comment">// A columns matrix:</span>
<a name="l00343"></a>00343 <span class="preprocessor">                #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00344"></a>00344 <span class="preprocessor"></span>                                        <span class="keywordflow">if</span> (ith &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>)
<a name="l00345"></a>00345                                                 <a class="code" href="mrpt__macros_8h.html#a61a8d46146210ee20fa1ff423257a5ec">THROW_EXCEPTION_CUSTOM_MSG1</a>( <span class="stringliteral">&quot;Index %u out of range!&quot;</span>,static_cast&lt;unsigned&gt;(ith) );
<a name="l00346"></a>00346 <span class="preprocessor">                #endif</span>
<a name="l00347"></a>00347 <span class="preprocessor"></span>                                        <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[ith][0];
<a name="l00348"></a>00348                                 }
<a name="l00349"></a>00349                         }
<a name="l00350"></a>00350 <span class="comment"></span>
<a name="l00351"></a>00351 <span class="comment">                        /** Fast but unsafe method to write a value in the matrix</span>
<a name="l00352"></a>00352 <span class="comment">                                */</span>
<a name="l00353"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac53acd13b4798e52710f2d90511f2df5">00353</a>                         <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac53acd13b4798e52710f2d90511f2df5" title="Fast but unsafe method to write a value in the matrix.">set_unsafe</a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col,<span class="keyword">const</span> T &amp;v)
<a name="l00354"></a>00354                         {
<a name="l00355"></a>00355 <span class="preprocessor">                #ifdef _DEBUG</span>
<a name="l00356"></a>00356 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (row &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> || col &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00357"></a>00357                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>( <a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Indexes (%lu,%lu) out of range. Matrix is %lux%lu&quot;</span>,static_cast&lt;unsigned long&gt;(row),static_cast&lt;unsigned long&gt;(col),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)) );
<a name="l00358"></a>00358 <span class="preprocessor">                #endif</span>
<a name="l00359"></a>00359 <span class="preprocessor"></span>                                <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row][col] = v;
<a name="l00360"></a>00360                         }
<a name="l00361"></a>00361 <span class="comment"></span>
<a name="l00362"></a>00362 <span class="comment">                        /** Fast but unsafe method to read a value from the matrix</span>
<a name="l00363"></a>00363 <span class="comment">                                */</span>
<a name="l00364"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a776dd903be8dcd2306399757bf503e0e">00364</a>                         <span class="keyword">inline</span> <span class="keyword">const</span> T &amp;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a776dd903be8dcd2306399757bf503e0e" title="Fast but unsafe method to read a value from the matrix.">get_unsafe</a>(<span class="keywordtype">size_t</span> row, <span class="keywordtype">size_t</span> col)<span class="keyword"> const</span>
<a name="l00365"></a>00365 <span class="keyword">                        </span>{
<a name="l00366"></a>00366 <span class="preprocessor">                #ifdef _DEBUG</span>
<a name="l00367"></a>00367 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (row &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> || col &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00368"></a>00368                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>( <a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Indexes (%lu,%lu) out of range. Matrix is %lux%lu&quot;</span>,static_cast&lt;unsigned long&gt;(row),static_cast&lt;unsigned long&gt;(col),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)) );
<a name="l00369"></a>00369 <span class="preprocessor">                #endif</span>
<a name="l00370"></a>00370 <span class="preprocessor"></span>                                <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row][col];
<a name="l00371"></a>00371                         }
<a name="l00372"></a>00372 <span class="comment"></span>
<a name="l00373"></a>00373 <span class="comment">                        /** Fast but unsafe method to get a reference from the matrix</span>
<a name="l00374"></a>00374 <span class="comment">                                */</span>
<a name="l00375"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a565d5d3ae7691d9aa78d6087838fc2bd">00375</a>                         <span class="keyword">inline</span> T &amp;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a776dd903be8dcd2306399757bf503e0e" title="Fast but unsafe method to read a value from the matrix.">get_unsafe</a>(<span class="keywordtype">size_t</span> row,<span class="keywordtype">size_t</span> col)
<a name="l00376"></a>00376                         {
<a name="l00377"></a>00377 <span class="preprocessor">                #ifdef _DEBUG</span>
<a name="l00378"></a>00378 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (row &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> || col &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00379"></a>00379                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>( <a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Indexes (%lu,%lu) out of range. Matrix is %lux%lu&quot;</span>,static_cast&lt;unsigned long&gt;(row),static_cast&lt;unsigned long&gt;(col),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)) );
<a name="l00380"></a>00380 <span class="preprocessor">                #endif</span>
<a name="l00381"></a>00381 <span class="preprocessor"></span>                                <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row][col];
<a name="l00382"></a>00382                         }
<a name="l00383"></a>00383 <span class="comment"></span>
<a name="l00384"></a>00384 <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="l00385"></a>00385 <span class="comment">                                */</span>
<a name="l00386"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ad41b157404a09714853365a6d627117a">00386</a>                         <span class="keyword">inline</span> T* <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ad41b157404a09714853365a6d627117a" 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)
<a name="l00387"></a>00387                         {
<a name="l00388"></a>00388 <span class="preprocessor">                #ifdef _DEBUG</span>
<a name="l00389"></a>00389 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (row &gt;= <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>)
<a name="l00390"></a>00390                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>( <a class="code" href="namespacemrpt.html#a3a27af794b658df5491e2b7678f8ccb8" title="A std::string version of C sprintf.">format</a>(<span class="stringliteral">&quot;Row index %&quot;</span><a class="code" href="msvc__inttypes_8h.html#aa1ca3a85113e897b5cf7ed6b92d74de2">PRIuPTR</a><span class="stringliteral">&quot; out of range. Matrix is %&quot;</span><a class="code" href="msvc__inttypes_8h.html#aa1ca3a85113e897b5cf7ed6b92d74de2">PRIuPTR</a><span class="stringliteral">&quot;x%&quot;</span><a class="code" href="msvc__inttypes_8h.html#aa1ca3a85113e897b5cf7ed6b92d74de2">PRIuPTR</a>,static_cast&lt;unsigned long&gt;(row),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>),static_cast&lt;unsigned long&gt;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)) );
<a name="l00391"></a>00391 <span class="preprocessor">                #endif</span>
<a name="l00392"></a>00392 <span class="preprocessor"></span>                                <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row];
<a name="l00393"></a>00393                         }
<a name="l00394"></a>00394 <span class="comment"></span>
<a name="l00395"></a>00395 <span class="comment">                        /** Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in critical applications)</span>
<a name="l00396"></a>00396 <span class="comment">                                */</span>
<a name="l00397"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ad4d5f63aa3c05fa1ef0465aac02dc857">00397</a>                         <span class="keyword">inline</span> <span class="keyword">const</span> T* <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ad4d5f63aa3c05fa1ef0465aac02dc857" title="Fast but unsafe method to obtain a pointer to a given row of the matrix (Use only in critical applica...">get_unsafe_row</a>(<span class="keywordtype">size_t</span> row)<span class="keyword"> const        </span>{
<a name="l00398"></a>00398                                 <span class="keywordflow">return</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row];
<a name="l00399"></a>00399                         }
<a name="l00400"></a>00400 <span class="comment"></span>
<a name="l00401"></a>00401 <span class="comment">                        /** Subscript operator to get a submatrix</span>
<a name="l00402"></a>00402 <span class="comment">                          */</span>
<a name="l00403"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#aa258e3f0f8b27cc7ffa1b7b8c7b4fe80">00403</a>                         <span class="keyword">inline</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate&lt;T&gt;</a> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afe572c043df380736510f33c01eceb40" title="Subscript operator to get/set individual elements.">operator() </a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row1,<span class="keyword">const</span> <span class="keywordtype">size_t</span> row2,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col1,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col2)<span class="keyword"> const    </span>{
<a name="l00404"></a>00404                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate&lt;T&gt;</a> val(0,0);
<a name="l00405"></a>00405                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a62539c7ee371c00298f4515209bc7b21" title="Get a submatrix, given its bounds.">extractSubmatrix</a>(row1,row2,col1,col2,val);
<a name="l00406"></a>00406                                 <span class="keywordflow">return</span> val;
<a name="l00407"></a>00407                         }
<a name="l00408"></a>00408 <span class="comment"></span>
<a name="l00409"></a>00409 <span class="comment">                        /** Get a submatrix, given its bounds</span>
<a name="l00410"></a>00410 <span class="comment">                          * \sa extractSubmatrixSymmetricalBlocks</span>
<a name="l00411"></a>00411 <span class="comment">                          */</span>
<a name="l00412"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a62539c7ee371c00298f4515209bc7b21">00412</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a62539c7ee371c00298f4515209bc7b21" title="Get a submatrix, given its bounds.">extractSubmatrix</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row1,<span class="keyword">const</span> <span class="keywordtype">size_t</span> row2,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col1,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col2,<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate&lt;T&gt;</a> &amp;out)<span class="keyword"> const</span>
<a name="l00413"></a>00413 <span class="keyword">                        </span>{
<a name="l00414"></a>00414                                 <span class="keywordtype">size_t</span> nrows=row2-row1+1;
<a name="l00415"></a>00415                                 <span class="keywordtype">size_t</span> ncols=col2-col1+1;
<a name="l00416"></a>00416                                 <span class="keywordflow">if</span> (nrows&lt;=0||ncols&lt;=0) {
<a name="l00417"></a>00417                                         out.realloc(0,0);
<a name="l00418"></a>00418                                         <span class="keywordflow">return</span>;
<a name="l00419"></a>00419                                 }
<a name="l00420"></a>00420                                 <span class="keywordflow">if</span> (row1&lt;0||row2&gt;=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>||col1&lt;0||col2&gt;=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>) <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<span class="stringliteral">&quot;Indices out of range!&quot;</span>);
<a name="l00421"></a>00421                                 out.realloc(nrows,ncols);
<a name="l00422"></a>00422                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;nrows;i++) <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0;j&lt;ncols;j++) out.m_Val[i][j]=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i+row1][j+col1];
<a name="l00423"></a>00423                         }<span class="comment"></span>
<a name="l00424"></a>00424 <span class="comment">                        /// @overload</span>
<a name="l00425"></a>00425 <span class="comment"></span>                        <span class="keyword">template</span> &lt;<span class="keyword">class</span> Derived&gt;
<a name="l00426"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#abc4dce3ea43af685bba2ac9e6f51efb8">00426</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a62539c7ee371c00298f4515209bc7b21" title="Get a submatrix, given its bounds.">extractSubmatrix</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> row1,<span class="keyword">const</span> <span class="keywordtype">size_t</span> row2,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col1,<span class="keyword">const</span> <span class="keywordtype">size_t</span> col2,<a class="code" href="class_eigen_1_1_matrix_base.html">Eigen::MatrixBase&lt;Derived&gt;</a> &amp;out)<span class="keyword"> const</span>
<a name="l00427"></a>00427 <span class="keyword">                        </span>{
<a name="l00428"></a>00428                                 <span class="keywordtype">size_t</span> nrows=row2-row1+1;
<a name="l00429"></a>00429                                 <span class="keywordtype">size_t</span> ncols=col2-col1+1;
<a name="l00430"></a>00430                                 <span class="keywordflow">if</span> (nrows&lt;=0||ncols&lt;=0) {
<a name="l00431"></a>00431                                         out = <span class="keyword">typename</span> <a class="code" href="class_eigen_1_1_matrix.html" title="The matrix class, also used for vectors and row-vectors.">Eigen::MatrixBase&lt;Derived&gt;::PlainObject</a>();
<a name="l00432"></a>00432                                         <span class="keywordflow">return</span>;
<a name="l00433"></a>00433                                 }
<a name="l00434"></a>00434                                 <span class="keywordflow">if</span> (row1&lt;0||row2&gt;=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>||col1&lt;0||col2&gt;=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>) <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<span class="stringliteral">&quot;Indices out of range!&quot;</span>);
<a name="l00435"></a>00435                                 out.resize(nrows,ncols);
<a name="l00436"></a>00436                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;nrows;i++) <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> j=0;j&lt;ncols;j++) out.coeffRef(i,j)=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i+row1][j+col1];
<a name="l00437"></a>00437                         }
<a name="l00438"></a>00438 
<a name="l00439"></a>00439 <span class="comment"></span>
<a name="l00440"></a>00440 <span class="comment">                        /** Gets a series of contiguous rows.</span>
<a name="l00441"></a>00441 <span class="comment">                                * \exception std::logic_error On index out of bounds</span>
<a name="l00442"></a>00442 <span class="comment">                                * \sa extractRow</span>
<a name="l00443"></a>00443 <span class="comment">                                * \sa extractColumns</span>
<a name="l00444"></a>00444 <span class="comment">                                */</span>
<a name="l00445"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#af904aba259f53063f49e0a098ddb5924">00445</a>                         <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#af904aba259f53063f49e0a098ddb5924" title="Gets a series of contiguous rows.">extractRows</a>(<span class="keywordtype">size_t</span> firstRow,<span class="keywordtype">size_t</span> lastRow,<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate&lt;T&gt;</a> &amp;out)<span class="keyword"> const   </span>{
<a name="l00446"></a>00446                                 out.setSize(lastRow-firstRow+1,<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>);
<a name="l00447"></a>00447                                 <a class="code" href="eigen__plugins_8h.html#aac01fcdfdbdb053b1c1d97dadfa2a8f0">detail::extractMatrix</a>(*<span class="keyword">this</span>,firstRow,0,out);
<a name="l00448"></a>00448                         }
<a name="l00449"></a>00449 <span class="comment"></span>
<a name="l00450"></a>00450 <span class="comment">                        /** Gets a series of contiguous columns.</span>
<a name="l00451"></a>00451 <span class="comment">                                * \exception std::logic_error On index out of bounds</span>
<a name="l00452"></a>00452 <span class="comment">                                * \sa extractColumn</span>
<a name="l00453"></a>00453 <span class="comment">                                * \sa extractRows</span>
<a name="l00454"></a>00454 <span class="comment">                                */</span>
<a name="l00455"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab56d5fe81d7f3a83ff3d1035828aacdc">00455</a>                         <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ab56d5fe81d7f3a83ff3d1035828aacdc" title="Gets a series of contiguous columns.">extractColumns</a>(<span class="keywordtype">size_t</span> firstCol,<span class="keywordtype">size_t</span> lastCol,<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate&lt;T&gt;</a> &amp;out)<span class="keyword"> const        </span>{
<a name="l00456"></a>00456                                 out.setSize(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>,lastCol-firstCol+1);
<a name="l00457"></a>00457                                 <a class="code" href="eigen__plugins_8h.html#aac01fcdfdbdb053b1c1d97dadfa2a8f0">detail::extractMatrix</a>(*<span class="keyword">this</span>,0,firstCol,out);
<a name="l00458"></a>00458                         }
<a name="l00459"></a>00459 <span class="comment"></span>
<a name="l00460"></a>00460 <span class="comment">                        /** Returns a given column to a vector (without modifying the matrix)</span>
<a name="l00461"></a>00461 <span class="comment">                                * \exception std::exception On index out of bounds</span>
<a name="l00462"></a>00462 <span class="comment">                                */</span>
<a name="l00463"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#aea9bf548aabe05429ab6b3d7349101af">00463</a>                         <span class="keywordtype">void</span>  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#aea9bf548aabe05429ab6b3d7349101af" title="Returns a given column to a vector (without modifying the matrix) On index out of bounds...">extractCol</a>(<span class="keywordtype">size_t</span> nCol, <a class="code" href="classstd_1_1vector.html">std::vector&lt;T&gt;</a> &amp;out, <span class="keywordtype">int</span> startingRow = 0)<span class="keyword"> const</span>
<a name="l00464"></a>00464 <span class="keyword">                        </span>{
<a name="l00465"></a>00465                                 <span class="keywordtype">size_t</span>          i,n;
<a name="l00466"></a>00466 <span class="preprocessor">                        #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00467"></a>00467 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (nCol&gt;=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00468"></a>00468                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<span class="stringliteral">&quot;extractCol: Column index out of bounds&quot;</span>);
<a name="l00469"></a>00469 <span class="preprocessor">                        #endif</span>
<a name="l00470"></a>00470 <span class="preprocessor"></span>
<a name="l00471"></a>00471                                 n = <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> - startingRow;
<a name="l00472"></a>00472                                 out.resize( n );
<a name="l00473"></a>00473 
<a name="l00474"></a>00474                                 <span class="keywordflow">for</span> (i=0;i&lt;n;i++)
<a name="l00475"></a>00475                                         out[i] = <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i+startingRow][nCol];
<a name="l00476"></a>00476                         }
<a name="l00477"></a>00477 <span class="comment"></span>
<a name="l00478"></a>00478 <span class="comment">                        /** Gets a given column to a vector (without modifying the matrix)</span>
<a name="l00479"></a>00479 <span class="comment">                                * \exception std::exception On index out of bounds</span>
<a name="l00480"></a>00480 <span class="comment">                                */</span>
<a name="l00481"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a213ac5db8e74efbcdb550ff3d13635bf">00481</a>                         <span class="keywordtype">void</span>  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#aea9bf548aabe05429ab6b3d7349101af" title="Returns a given column to a vector (without modifying the matrix) On index out of bounds...">extractCol</a>(<span class="keywordtype">size_t</span> nCol, <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html" title="This template class provides the basic functionality for a general 2D any-size, resizable container o...">CMatrixTemplate&lt;T&gt;</a> &amp;out, <span class="keywordtype">int</span> startingRow = 0)<span class="keyword"> const</span>
<a name="l00482"></a>00482 <span class="keyword">                        </span>{
<a name="l00483"></a>00483                                 <span class="keywordtype">size_t</span>          i,n;
<a name="l00484"></a>00484 <span class="preprocessor">                        #if defined(_DEBUG) || (MRPT_ALWAYS_CHECKS_DEBUG_MATRICES)</span>
<a name="l00485"></a>00485 <span class="preprocessor"></span>                                <span class="keywordflow">if</span> (nCol&gt;=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>)
<a name="l00486"></a>00486                                         <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<span class="stringliteral">&quot;extractCol: Column index out of bounds&quot;</span>);
<a name="l00487"></a>00487 <span class="preprocessor">                        #endif</span>
<a name="l00488"></a>00488 <span class="preprocessor"></span>
<a name="l00489"></a>00489                                 n = <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> - startingRow;
<a name="l00490"></a>00490                                 out.setSize(n,1);
<a name="l00491"></a>00491 
<a name="l00492"></a>00492                                 <span class="keywordflow">for</span> (i=0;i&lt;n;i++)
<a name="l00493"></a>00493                                         out(i,0) = <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i+startingRow][nCol];
<a name="l00494"></a>00494                         }
<a name="l00495"></a>00495 <span class="comment"></span>
<a name="l00496"></a>00496 <span class="comment">                        /** Appends a new row to the MxN matrix from a 1xN vector.</span>
<a name="l00497"></a>00497 <span class="comment">                                *  The lenght of the vector must match the width of the matrix, unless it&#39;s empty: in that case the matrix is resized to 1xN.</span>
<a name="l00498"></a>00498 <span class="comment">                                *  \code</span>
<a name="l00499"></a>00499 <span class="comment">                                *    CMatrixDouble  M(0,0);</span>
<a name="l00500"></a>00500 <span class="comment">                                *    vector_double  v(7),w(7);</span>
<a name="l00501"></a>00501 <span class="comment">                                *    // ...</span>
<a name="l00502"></a>00502 <span class="comment">                                *    M.appendRow(v);</span>
<a name="l00503"></a>00503 <span class="comment">                                *    M.appendRow(w);</span>
<a name="l00504"></a>00504 <span class="comment">                                *  \endcode</span>
<a name="l00505"></a>00505 <span class="comment">                                * \exception std::exception On incorrect vector length.</span>
<a name="l00506"></a>00506 <span class="comment">                                * \sa extractRow</span>
<a name="l00507"></a>00507 <span class="comment">                                * \sa appendCol</span>
<a name="l00508"></a>00508 <span class="comment">                                */</span>
<a name="l00509"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afc2e5b7b39c14733589e4c8b1d10e448">00509</a>                         <span class="keywordtype">void</span>  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#afc2e5b7b39c14733589e4c8b1d10e448" title="Appends a new row to the MxN matrix from a 1xN vector.">appendRow</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector&lt;T&gt;</a> &amp;in)
<a name="l00510"></a>00510                         {
<a name="l00511"></a>00511                                 <span class="keywordtype">size_t</span>          i,n, row;
<a name="l00512"></a>00512 
<a name="l00513"></a>00513                                 n = <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>;
<a name="l00514"></a>00514                                 row = <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>;
<a name="l00515"></a>00515 
<a name="l00516"></a>00516                                 <span class="keywordflow">if</span> (<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>==0 || <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>==0)
<a name="l00517"></a>00517                                 {
<a name="l00518"></a>00518                                         <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(!in.empty());
<a name="l00519"></a>00519                                         n=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>=in.size();
<a name="l00520"></a>00520                                 }
<a name="l00521"></a>00521                                 <span class="keywordflow">else</span>
<a name="l00522"></a>00522                                 {
<a name="l00523"></a>00523                                         <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(in.size()==<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>);
<a name="l00524"></a>00524                                 }
<a name="l00525"></a>00525 
<a name="l00526"></a>00526                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>( row+1,n );
<a name="l00527"></a>00527 
<a name="l00528"></a>00528                                 <span class="keywordflow">for</span> (i=0;i&lt;n;i++)
<a name="l00529"></a>00529                                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[row][i] = in[i];
<a name="l00530"></a>00530                         }
<a name="l00531"></a>00531 <span class="comment"></span>
<a name="l00532"></a>00532 <span class="comment">                        /** Appends a new column to the matrix from a vector.</span>
<a name="l00533"></a>00533 <span class="comment">                                * The length of the vector must match the number of rows of the matrix, unless it is (0,0).</span>
<a name="l00534"></a>00534 <span class="comment">                                * \exception std::exception On size mismatch.</span>
<a name="l00535"></a>00535 <span class="comment">                                * \sa extractCol</span>
<a name="l00536"></a>00536 <span class="comment">                                * \sa appendRow</span>
<a name="l00537"></a>00537 <span class="comment">                                */</span>
<a name="l00538"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a235ad47bf6791ab3a36d66c47594b087">00538</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a235ad47bf6791ab3a36d66c47594b087" title="Appends a new column to the matrix from a vector.">appendCol</a>(<span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector&lt;T&gt;</a> &amp;in)        {
<a name="l00539"></a>00539                                 <span class="keywordtype">size_t</span> r=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>,c=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>;
<a name="l00540"></a>00540                                 <span class="keywordflow">if</span> (<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>==0||<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>==0)       {
<a name="l00541"></a>00541                                         <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(!in.empty());
<a name="l00542"></a>00542                                         r=in.size();
<a name="l00543"></a>00543                                         c=0;
<a name="l00544"></a>00544                                 }       <span class="keywordflow">else</span> <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>(in.size()==<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>);
<a name="l00545"></a>00545                                 <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#ac10c5fd22bc63a60fd50cdcee3c10835" title="Internal use only: It reallocs the memory for the 2D matrix, maintaining the previous contents if pos...">realloc</a>(r,c+1);
<a name="l00546"></a>00546                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>;i++) <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>-1]=in[i];
<a name="l00547"></a>00547                         }
<a name="l00548"></a>00548 <span class="comment"></span>
<a name="l00549"></a>00549 <span class="comment">                        /** Inserts a column from a vector, replacing the current contents of that column.</span>
<a name="l00550"></a>00550 <span class="comment">                                * \exception std::exception On index out of bounds</span>
<a name="l00551"></a>00551 <span class="comment">                                * \sa extractCol</span>
<a name="l00552"></a>00552 <span class="comment">                                */</span>
<a name="l00553"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a8319a14f3c11bf1b98620b5750854472">00553</a>                         <span class="keywordtype">void</span>  <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a8319a14f3c11bf1b98620b5750854472" title="Inserts a column from a vector, replacing the current contents of that column.">insertCol</a>(<span class="keywordtype">size_t</span> nCol, <span class="keyword">const</span> <a class="code" href="classstd_1_1vector.html">std::vector&lt;T&gt;</a> &amp;in)
<a name="l00554"></a>00554                         {
<a name="l00555"></a>00555                                 <span class="keywordflow">if</span> (nCol&gt;=<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>) <a class="code" href="mrpt__macros_8h.html#aaa3f404ea85a6575a7139f8d101370ba">THROW_EXCEPTION</a>(<span class="stringliteral">&quot;insertCol: Row index out of bounds&quot;</span>);
<a name="l00556"></a>00556 
<a name="l00557"></a>00557                                 <span class="keywordtype">size_t</span> n = in.size();
<a name="l00558"></a>00558                                 <a class="code" href="mrpt__macros_8h.html#a47eb5a445c2bf3d9190396510ea9683e">ASSERT_</a>( <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a> &gt;= in.size() );
<a name="l00559"></a>00559 
<a name="l00560"></a>00560                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;n;i++)
<a name="l00561"></a>00561                                         <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][nCol] = in[i];
<a name="l00562"></a>00562                         }
<a name="l00563"></a>00563 <span class="comment"></span>
<a name="l00564"></a>00564 <span class="comment">                        /** Returns a vector containing the matrix&#39;s values.</span>
<a name="l00565"></a>00565 <span class="comment">                          */</span>
<a name="l00566"></a><a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a76be0234bdae0cfbf2e2cffbf527ce21">00566</a>                         <span class="keywordtype">void</span> <a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a76be0234bdae0cfbf2e2cffbf527ce21" title="Returns a vector containing the matrix&#39;s values.">getAsVector</a>(<a class="code" href="classstd_1_1vector.html">std::vector&lt;T&gt;</a> &amp;out)<span class="keyword"> const     </span>{
<a name="l00567"></a>00567                                 out.clear();
<a name="l00568"></a>00568                                 out.reserve(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>*<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a40ecbadd8c4dc2267173df7f4a85ed62">m_Cols</a>);
<a name="l00569"></a>00569                                 <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i=0;i&lt;<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a1d1a2aac6aaa02123208cdab76ce4de1">m_Rows</a>;i++) out.insert(out.end(),&amp;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][0]),&amp;(<a class="code" href="classmrpt_1_1math_1_1_c_matrix_template.html#a5ca0244e5b348d1ce5666efe9d1d97f4">m_Val</a>[i][m_Cols]));
<a name="l00570"></a>00570                         }
<a name="l00571"></a>00571 
<a name="l00572"></a>00572                 }; <span class="comment">// end of class CMatrixTemplate</span>
<a name="l00573"></a>00573 
<a name="l00574"></a>00574 
<a name="l00575"></a>00575         } <span class="comment">// End of namespace</span>
<a name="l00576"></a>00576 } <span class="comment">// End of namespace</span>
<a name="l00577"></a>00577 
<a name="l00578"></a>00578 
<a name="l00579"></a>00579 <span class="preprocessor">#endif</span>
</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>