Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 2f6559b7006594cad03af173263c219e > files > 1840

mrpt-doc-0.9.4-0.1.20110110svn2383.fc15.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>The MRPT project: Diagonal.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.2 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
  <div 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 id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
          <span 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>
          </span><span class="right"></span>
        </div>
      </li>
    </ul>
  </div>
  <div 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">
<h1>Diagonal.h</h1>  </div>
</div>
<div class="contents">
<a href="_diagonal_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// This file is part of Eigen, a lightweight C++ template library</span>
<a name="l00002"></a>00002 <span class="comment">// for linear algebra.</span>
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 2007-2009 Benoit Jacob &lt;jacob.benoit.1@gmail.com&gt;</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// Eigen is free software; you can redistribute it and/or</span>
<a name="l00007"></a>00007 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span>
<a name="l00008"></a>00008 <span class="comment">// License as published by the Free Software Foundation; either</span>
<a name="l00009"></a>00009 <span class="comment">// version 3 of the License, or (at your option) any later version.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// Alternatively, you can redistribute it and/or</span>
<a name="l00012"></a>00012 <span class="comment">// modify it under the terms of the GNU General Public License as</span>
<a name="l00013"></a>00013 <span class="comment">// published by the Free Software Foundation; either version 2 of</span>
<a name="l00014"></a>00014 <span class="comment">// the License, or (at your option) any later version.</span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016 <span class="comment">// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY</span>
<a name="l00017"></a>00017 <span class="comment">// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</span>
<a name="l00018"></a>00018 <span class="comment">// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the</span>
<a name="l00019"></a>00019 <span class="comment">// GNU General Public License for more details.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span>
<a name="l00022"></a>00022 <span class="comment">// License and a copy of the GNU General Public License along with</span>
<a name="l00023"></a>00023 <span class="comment">// Eigen. If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#ifndef EIGEN_DIAGONAL_H</span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define EIGEN_DIAGONAL_H</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00028"></a>00028 <span class="comment">/** \class Diagonal</span>
<a name="l00029"></a>00029 <span class="comment">  * \ingroup Core_Module</span>
<a name="l00030"></a>00030 <span class="comment">  *</span>
<a name="l00031"></a>00031 <span class="comment">  * \brief Expression of a diagonal/subdiagonal/superdiagonal in a matrix</span>
<a name="l00032"></a>00032 <span class="comment">  *</span>
<a name="l00033"></a>00033 <span class="comment">  * \param MatrixType the type of the object in which we are taking a sub/main/super diagonal</span>
<a name="l00034"></a>00034 <span class="comment">  * \param DiagIndex the index of the sub/super diagonal. The default is 0 and it means the main diagonal.</span>
<a name="l00035"></a>00035 <span class="comment">  *              A positive value means a superdiagonal, a negative value means a subdiagonal.</span>
<a name="l00036"></a>00036 <span class="comment">  *              You can also use Dynamic so the index can be set at runtime.</span>
<a name="l00037"></a>00037 <span class="comment">  *</span>
<a name="l00038"></a>00038 <span class="comment">  * The matrix is not required to be square.</span>
<a name="l00039"></a>00039 <span class="comment">  *</span>
<a name="l00040"></a>00040 <span class="comment">  * This class represents an expression of the main diagonal, or any sub/super diagonal</span>
<a name="l00041"></a>00041 <span class="comment">  * of a square matrix. It is the return type of MatrixBase::diagonal() and MatrixBase::diagonal(Index) and most of the</span>
<a name="l00042"></a>00042 <span class="comment">  * time this is the only way it is used.</span>
<a name="l00043"></a>00043 <span class="comment">  *</span>
<a name="l00044"></a>00044 <span class="comment">  * \sa MatrixBase::diagonal(), MatrixBase::diagonal(Index)</span>
<a name="l00045"></a>00045 <span class="comment">  */</span>
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 <span class="keyword">namespace </span>internal {
<a name="l00048"></a>00048 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> MatrixType, <span class="keywordtype">int</span> DiagIndex&gt;
<a name="l00049"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html">00049</a> <span class="keyword">struct </span>traits&lt;<a class="code" href="class_diagonal.html" title="Expression of a diagonal/subdiagonal/superdiagonal in a matrix.">Diagonal</a>&lt;MatrixType,DiagIndex&gt; &gt;
<a name="l00050"></a>00050  : traits&lt;MatrixType&gt;
<a name="l00051"></a>00051 {
<a name="l00052"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#af5f19edd2fbfcdc0e26dc1e3918f3583">00052</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structinternal_1_1nested.html">nested&lt;MatrixType&gt;::type</a> <a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#af5f19edd2fbfcdc0e26dc1e3918f3583">MatrixTypeNested</a>;
<a name="l00053"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#a90ff1e4a67c5e3efdd2014d7119eba1a">00053</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structinternal_1_1remove__reference.html#abee00136272ee0c43df7c9afe03a0eed">remove_reference&lt;MatrixTypeNested&gt;::type</a> <a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#a90ff1e4a67c5e3efdd2014d7119eba1a">_MatrixTypeNested</a>;
<a name="l00054"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#a96039cb3d7ec22d0204da546d542799d">00054</a>   <span class="keyword">typedef</span> <span class="keyword">typename</span> MatrixType::StorageKind <a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#a96039cb3d7ec22d0204da546d542799d">StorageKind</a>;
<a name="l00055"></a>00055   <span class="keyword">enum</span> {
<a name="l00056"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830ae8e5e9ad0cba4a53425ca68b4ccf0797">00056</a>     AbsDiagIndex = DiagIndex&lt;0 ? -DiagIndex : DiagIndex, <span class="comment">// only used if DiagIndex != Dynamic</span>
<a name="l00057"></a>00057     <span class="comment">// FIXME these computations are broken in the case where the matrix is rectangular and DiagIndex!=0</span>
<a name="l00058"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830a195b9956e433344e20097c450df7ec8b">00058</a>     RowsAtCompileTime = (int(DiagIndex) == <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a> || int(MatrixType::SizeAtCompileTime) == <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a>) ? <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a>
<a name="l00059"></a>00059                       : (<a class="code" href="_macros_8h.html#a2a07ba221d47a7d636fd13678c8c75b3">EIGEN_SIZE_MIN_PREFER_DYNAMIC</a>(MatrixType::RowsAtCompileTime,
<a name="l00060"></a>00060                                         MatrixType::ColsAtCompileTime) - AbsDiagIndex),
<a name="l00061"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830ac3faaaf42612b69ac26e5a4b7da2eea1">00061</a>     ColsAtCompileTime = 1,
<a name="l00062"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830a0f1e8126137b0776021274eb9431983f">00062</a>     MaxRowsAtCompileTime = <span class="keywordtype">int</span>(MatrixType::MaxSizeAtCompileTime) == <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a> ? <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a>
<a name="l00063"></a>00063                          : DiagIndex == <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a> ? <a class="code" href="_macros_8h.html#af2d58514e6156c4da2d4af66fafd0b12">EIGEN_SIZE_MIN_PREFER_FIXED</a>(MatrixType::MaxRowsAtCompileTime,
<a name="l00064"></a>00064                                                                     MatrixType::MaxColsAtCompileTime)
<a name="l00065"></a>00065                          : (EIGEN_SIZE_MIN_PREFER_FIXED(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) - AbsDiagIndex),
<a name="l00066"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830a7b18d73e3000c9635db501b2b08edac5">00066</a>     MaxColsAtCompileTime = 1,
<a name="l00067"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830aa1dcbb8a173e9e1745b1907af27fa6fd">00067</a>     MaskLvalueBit = <a class="code" href="structinternal_1_1is__lvalue.html">is_lvalue</a>&lt;MatrixType&gt;::value ? <a class="code" href="group__flags.html#ga64e21b7543bdedce27f013512a4403a3" title="Means the expression has a coeffRef() method, i.e.">LvalueBit</a> : 0,
<a name="l00068"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830a04a50a941d25191016c6d0ddaec6e00e">00068</a>     Flags = (unsigned int)<a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#a90ff1e4a67c5e3efdd2014d7119eba1a">_MatrixTypeNested</a>::Flags &amp; (<a class="code" href="_constants_8h.html#ab3a408f1142a07c31e28ff8b51175c74">HereditaryBits</a> | <a class="code" href="group__flags.html#gab9799bf6feed77fc9fce0136ee55b99c" title="Short version: means the expression can be seen as 1D vector.">LinearAccessBit</a> | MaskLvalueBit | <a class="code" href="group__flags.html#ga54c3b872f5a14e7e0d3d6539b704ea67" title="Means that the underlying array of coefficients can be directly accessed as a plain strided array...">DirectAccessBit</a>) &amp; ~<a class="code" href="group__flags.html#ga7bd49e7b260e869e10fb9dc4fd081a85" title="for a matrix, this means that the storage order is row-major.">RowMajorBit</a>,
<a name="l00069"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830a0af52bbd0cca33d25cc5526ce22e7ae4">00069</a>     CoeffReadCost = <a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#a90ff1e4a67c5e3efdd2014d7119eba1a">_MatrixTypeNested</a>::CoeffReadCost,
<a name="l00070"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830ab361448234f001932a7cb40c353ee1d3">00070</a>     MatrixTypeOuterStride = <a class="code" href="structinternal_1_1outer__stride__at__compile__time.html">outer_stride_at_compile_time</a>&lt;MatrixType&gt;::ret,
<a name="l00071"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830a0a353c7c41fb12aefeccbb112a6add1c">00071</a>     InnerStrideAtCompileTime = MatrixTypeOuterStride == <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a> ? <a class="code" href="_constants_8h.html#adc9da5be31bdce40c25a92c27999c0e3" title="This value means that a quantity is not known at compile-time, and that instead the value is stored i...">Dynamic</a> : MatrixTypeOuterStride+1,
<a name="l00072"></a><a class="code" href="structinternal_1_1traits_3_01_diagonal_3_01_matrix_type_00_01_diag_index_01_4_01_4.html#afe6f8d99aa30595154a7489395f2c830af3ad11d397ef0a4557ac23e9978d7b29">00072</a>     OuterStrideAtCompileTime = 0
<a name="l00073"></a>00073   };
<a name="l00074"></a>00074 };
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 
<a name="l00077"></a><a class="code" href="class_diagonal.html">00077</a> <span class="keyword">template</span>&lt;<span class="keyword">typename</span> MatrixType, <span class="keywordtype">int</span> DiagIndex&gt; <span class="keyword">class </span><a class="code" href="class_diagonal.html" title="Expression of a diagonal/subdiagonal/superdiagonal in a matrix.">Diagonal</a>
<a name="l00078"></a>00078    : <span class="keyword">public</span> internal::dense_xpr_base&lt; Diagonal&lt;MatrixType,DiagIndex&gt; &gt;::<a class="code" href="classinternal_1_1dense__xpr__base_1_1type.html">type</a>
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080   <span class="keyword">public</span>:
<a name="l00081"></a>00081 
<a name="l00082"></a><a class="code" href="class_diagonal.html#a87ee4516b7bf6a833f6e15cac195bfef">00082</a>     <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structinternal_1_1dense__xpr__base.html">internal::dense_xpr_base&lt;Diagonal&gt;::type</a> <a class="code" href="class_diagonal.html#a87ee4516b7bf6a833f6e15cac195bfef">Base</a>;
<a name="l00083"></a>00083     <a class="code" href="_macros_8h.html#ab29ea1da9635d033ca44cf26ad6fa0cf">EIGEN_DENSE_PUBLIC_INTERFACE</a>(<a class="code" href="class_diagonal.html" title="Expression of a diagonal/subdiagonal/superdiagonal in a matrix.">Diagonal</a>)
<a name="l00084"></a>00084 
<a name="l00085"></a><a class="code" href="class_diagonal.html#a8c47b38f1e0d378cd66ece5faa1eda69">00085</a>     inline <a class="code" href="class_diagonal.html" title="Expression of a diagonal/subdiagonal/superdiagonal in a matrix.">Diagonal</a>(const MatrixType&amp; matrix, Index index = DiagIndex) : m_matrix(matrix), m_index(index) {}
<a name="l00086"></a>00086 
<a name="l00087"></a>00087     <a class="code" href="_macros_8h.html#ad84d7b9025947395ef1f67e45cea3150">EIGEN_INHERIT_ASSIGNMENT_OPERATORS</a>(<a class="code" href="class_diagonal.html" title="Expression of a diagonal/subdiagonal/superdiagonal in a matrix.">Diagonal</a>)
<a name="l00088"></a>00088 
<a name="l00089"></a><a class="code" href="class_diagonal.html#a63a03a45984cd299d7c55b145a353fc9">00089</a>     inline Index rows()<span class="keyword"> const</span>
<a name="l00090"></a>00090 <span class="keyword">    </span>{ <span class="keywordflow">return</span> m_index.value()&lt;0 ? std::min(m_matrix.cols(),m_matrix.rows()+m_index.value()) : std::min(m_matrix.rows(),m_matrix.cols()-m_index.value()); }
<a name="l00091"></a>00091 
<a name="l00092"></a><a class="code" href="class_diagonal.html#aca2609dff65a5fd755edb72d142bd26e">00092</a>     <span class="keyword">inline</span> Index <a class="code" href="class_diagonal.html#aca2609dff65a5fd755edb72d142bd26e">cols</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 1; }
<a name="l00093"></a>00093 
<a name="l00094"></a><a class="code" href="class_diagonal.html#aa1b136828bfb6de85faa0f09c83b2882">00094</a>     <span class="keyword">inline</span> Index innerStride()<span class="keyword"> const</span>
<a name="l00095"></a>00095 <span class="keyword">    </span>{
<a name="l00096"></a>00096       <span class="keywordflow">return</span> m_matrix.outerStride() + 1;
<a name="l00097"></a>00097     }
<a name="l00098"></a>00098 
<a name="l00099"></a><a class="code" href="class_diagonal.html#a0a345c5648feed4878298ecc100cdcae">00099</a>     <span class="keyword">inline</span> Index outerStride()<span class="keyword"> const</span>
<a name="l00100"></a>00100 <span class="keyword">    </span>{
<a name="l00101"></a>00101       <span class="keywordflow">return</span> 0;
<a name="l00102"></a>00102     }
<a name="l00103"></a>00103 
<a name="l00104"></a><a class="code" href="class_diagonal.html#a323fa9ae2e51aac0d9a7e5b0aa642f44">00104</a>     <span class="keyword">inline</span> Scalar&amp; coeffRef(Index <a class="code" href="_block_methods_8h.html#ad62dcaf648cca25e9318da34c9840799" title="This is the const version of row().">row</a>, Index)
<a name="l00105"></a>00105     {
<a name="l00106"></a>00106       <span class="keywordflow">return</span> m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset());
<a name="l00107"></a>00107     }
<a name="l00108"></a>00108 
<a name="l00109"></a><a class="code" href="class_diagonal.html#a4ca13ae224add7855e867dc366c6ab03">00109</a>     <span class="keyword">inline</span> <span class="keyword">const</span> Scalar&amp; coeffRef(Index <a class="code" href="_block_methods_8h.html#ad62dcaf648cca25e9318da34c9840799" title="This is the const version of row().">row</a>, Index)<span class="keyword"> const</span>
<a name="l00110"></a>00110 <span class="keyword">    </span>{
<a name="l00111"></a>00111       <span class="keywordflow">return</span> m_matrix.const_cast_derived().coeffRef(row+rowOffset(), row+colOffset());
<a name="l00112"></a>00112     }
<a name="l00113"></a>00113 
<a name="l00114"></a><a class="code" href="class_diagonal.html#a0dc8523475c3899df94bb5dde767d25f">00114</a>     <span class="keyword">inline</span> CoeffReturnType coeff(Index <a class="code" href="_block_methods_8h.html#ad62dcaf648cca25e9318da34c9840799" title="This is the const version of row().">row</a>, Index)<span class="keyword"> const</span>
<a name="l00115"></a>00115 <span class="keyword">    </span>{
<a name="l00116"></a>00116       <span class="keywordflow">return</span> m_matrix.coeff(row+rowOffset(), row+colOffset());
<a name="l00117"></a>00117     }
<a name="l00118"></a>00118 
<a name="l00119"></a><a class="code" href="class_diagonal.html#a0b20e6fa165de8ab69e37a2a36e3100d">00119</a>     <span class="keyword">inline</span> Scalar&amp; coeffRef(Index index)
<a name="l00120"></a>00120     {
<a name="l00121"></a>00121       <span class="keywordflow">return</span> m_matrix.const_cast_derived().coeffRef(index+rowOffset(), index+colOffset());
<a name="l00122"></a>00122     }
<a name="l00123"></a>00123 
<a name="l00124"></a><a class="code" href="class_diagonal.html#a00b3a82ce6a29244f380f01a345f3a7c">00124</a>     <span class="keyword">inline</span> <span class="keyword">const</span> Scalar&amp; coeffRef(Index index)<span class="keyword"> const</span>
<a name="l00125"></a>00125 <span class="keyword">    </span>{
<a name="l00126"></a>00126       <span class="keywordflow">return</span> m_matrix.const_cast_derived().coeffRef(index+rowOffset(), index+colOffset());
<a name="l00127"></a>00127     }
<a name="l00128"></a>00128 
<a name="l00129"></a><a class="code" href="class_diagonal.html#affd60a355a995ed724df8501bb2356ca">00129</a>     <span class="keyword">inline</span> CoeffReturnType coeff(Index index)<span class="keyword"> const</span>
<a name="l00130"></a>00130 <span class="keyword">    </span>{
<a name="l00131"></a>00131       <span class="keywordflow">return</span> m_matrix.coeff(index+rowOffset(), index+colOffset());
<a name="l00132"></a>00132     }
<a name="l00133"></a>00133 
<a name="l00134"></a>00134   <span class="keyword">protected</span>:
<a name="l00135"></a><a class="code" href="class_diagonal.html#a8ebb9609604fee5444c18fe31c21b968">00135</a>     <span class="keyword">const</span> <span class="keyword">typename</span> MatrixType::Nested <a class="code" href="class_diagonal.html#a8ebb9609604fee5444c18fe31c21b968">m_matrix</a>;
<a name="l00136"></a><a class="code" href="class_diagonal.html#ac500340db3d48b96d5099a117c847009">00136</a>     <span class="keyword">const</span> <a class="code" href="classinternal_1_1variable__if__dynamic.html">internal::variable_if_dynamic&lt;Index, DiagIndex&gt;</a> <a class="code" href="class_diagonal.html#ac500340db3d48b96d5099a117c847009">m_index</a>;
<a name="l00137"></a>00137 
<a name="l00138"></a>00138   <span class="keyword">private</span>:
<a name="l00139"></a>00139     <span class="comment">// some compilers may fail to optimize std::max etc in case of compile-time constants...</span>
<a name="l00140"></a><a class="code" href="class_diagonal.html#a36907a368400b50ab7de8d5db30c5a6d">00140</a>     <a class="code" href="_macros_8h.html#af2b60117c00a6e75812de43bfe7db3b1">EIGEN_STRONG_INLINE</a> Index <a class="code" href="class_diagonal.html#a36907a368400b50ab7de8d5db30c5a6d">absDiagIndex</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_index.value()&gt;0 ? m_index.value() : -m_index.value(); }
<a name="l00141"></a><a class="code" href="class_diagonal.html#a2205e564885989f72d0b8a2db4b7d095">00141</a>     <a class="code" href="_macros_8h.html#af2b60117c00a6e75812de43bfe7db3b1">EIGEN_STRONG_INLINE</a> Index <a class="code" href="class_diagonal.html#a2205e564885989f72d0b8a2db4b7d095">rowOffset</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_index.value()&gt;0 ? 0 : -m_index.value(); }
<a name="l00142"></a><a class="code" href="class_diagonal.html#adb0cbb65774fab78b57cf85deb2bef36">00142</a>     <a class="code" href="_macros_8h.html#af2b60117c00a6e75812de43bfe7db3b1">EIGEN_STRONG_INLINE</a> Index <a class="code" href="class_diagonal.html#adb0cbb65774fab78b57cf85deb2bef36">colOffset</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_index.value()&gt;0 ? m_index.value() : 0; }
<a name="l00143"></a>00143     <span class="comment">// triger a compile time error is someone try to call packet</span>
<a name="l00144"></a>00144     <span class="keyword">template</span>&lt;<span class="keywordtype">int</span> LoadMode&gt; <span class="keyword">typename</span> MatrixType::PacketReturnType packet(Index) <span class="keyword">const</span>;
<a name="l00145"></a>00145     <span class="keyword">template</span>&lt;<span class="keywordtype">int</span> LoadMode&gt; <span class="keyword">typename</span> MatrixType::PacketReturnType packet(Index,Index) <span class="keyword">const</span>;
<a name="l00146"></a>00146 };
<a name="l00147"></a>00147 <span class="comment"></span>
<a name="l00148"></a>00148 <span class="comment">/** \returns an expression of the main diagonal of the matrix \c *this</span>
<a name="l00149"></a>00149 <span class="comment">  *</span>
<a name="l00150"></a>00150 <span class="comment">  * \c *this is not required to be square.</span>
<a name="l00151"></a>00151 <span class="comment">  *</span>
<a name="l00152"></a>00152 <span class="comment">  * Example: \include MatrixBase_diagonal.cpp</span>
<a name="l00153"></a>00153 <span class="comment">  * Output: \verbinclude MatrixBase_diagonal.out</span>
<a name="l00154"></a>00154 <span class="comment">  *</span>
<a name="l00155"></a>00155 <span class="comment">  * \sa class Diagonal */</span>
<a name="l00156"></a>00156 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Derived&gt;
<a name="l00157"></a>00157 <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="class_diagonal.html" title="Expression of a diagonal/subdiagonal/superdiagonal in a matrix.">MatrixBase&lt;Derived&gt;::DiagonalReturnType</a>
<a name="l00158"></a><a class="code" href="class_matrix_base.html#ad02d2701732479e8052d1675dd62a3c8">00158</a> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::diagonal</a>()
<a name="l00159"></a>00159 {
<a name="l00160"></a>00160   <span class="keywordflow">return</span> derived();
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 <span class="comment"></span>
<a name="l00163"></a>00163 <span class="comment">/** This is the const version of diagonal(). */</span>
<a name="l00164"></a>00164 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Derived&gt;
<a name="l00165"></a>00165 <span class="keyword">inline</span> <span class="keyword">const</span> <span class="keyword">typename</span> <a class="code" href="class_diagonal.html" title="Expression of a diagonal/subdiagonal/superdiagonal in a matrix.">MatrixBase&lt;Derived&gt;::ConstDiagonalReturnType</a>
<a name="l00166"></a><a class="code" href="class_matrix_base.html#a0b43a50032f84b967a9d4fbf3a27236f">00166</a> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::diagonal</a>()<span class="keyword"> const</span>
<a name="l00167"></a>00167 <span class="keyword"></span>{
<a name="l00168"></a>00168   <span class="keywordflow">return</span> derived();
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170 <span class="comment"></span>
<a name="l00171"></a>00171 <span class="comment">/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this</span>
<a name="l00172"></a>00172 <span class="comment">  *</span>
<a name="l00173"></a>00173 <span class="comment">  * \c *this is not required to be square.</span>
<a name="l00174"></a>00174 <span class="comment">  *</span>
<a name="l00175"></a>00175 <span class="comment">  * The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex &gt; 0</span>
<a name="l00176"></a>00176 <span class="comment">  * and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal.</span>
<a name="l00177"></a>00177 <span class="comment">  *</span>
<a name="l00178"></a>00178 <span class="comment">  * Example: \include MatrixBase_diagonal_int.cpp</span>
<a name="l00179"></a>00179 <span class="comment">  * Output: \verbinclude MatrixBase_diagonal_int.out</span>
<a name="l00180"></a>00180 <span class="comment">  *</span>
<a name="l00181"></a>00181 <span class="comment">  * \sa MatrixBase::diagonal(), class Diagonal */</span>
<a name="l00182"></a>00182 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Derived&gt;
<a name="l00183"></a>00183 <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::template</a> <a class="code" href="namespace_architecture.html#a7ae6186419ae33e4d9019df7b18d883e">DiagonalIndexReturnType&lt;Dynamic&gt;::Type</a>
<a name="l00184"></a><a class="code" href="class_matrix_base.html#ad6ce84179fd8f07860adeca78516801d">00184</a> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::diagonal</a>(<a class="code" href="class_dense_base.html#a059039d9d011413c873e6ae05ee912b6" title="The type of indices.">Index</a> index)
<a name="l00185"></a>00185 {
<a name="l00186"></a>00186   <span class="keywordflow">return</span> <span class="keyword">typename</span> <a class="code" href="namespace_architecture.html#a7ae6186419ae33e4d9019df7b18d883e">DiagonalIndexReturnType&lt;Dynamic&gt;::Type</a>(derived(), index);
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188 <span class="comment"></span>
<a name="l00189"></a>00189 <span class="comment">/** This is the const version of diagonal(Index). */</span>
<a name="l00190"></a>00190 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Derived&gt;
<a name="l00191"></a>00191 <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::template</a> <a class="code" href="namespace_architecture.html#a7ae6186419ae33e4d9019df7b18d883e">ConstDiagonalIndexReturnType&lt;Dynamic&gt;::Type</a>
<a name="l00192"></a><a class="code" href="class_matrix_base.html#a6009169966d07ad669ed5a3b2574ce29">00192</a> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::diagonal</a>(<a class="code" href="class_dense_base.html#a059039d9d011413c873e6ae05ee912b6" title="The type of indices.">Index</a> index)<span class="keyword"> const</span>
<a name="l00193"></a>00193 <span class="keyword"></span>{
<a name="l00194"></a>00194   <span class="keywordflow">return</span> <span class="keyword">typename</span> <a class="code" href="namespace_architecture.html#a7ae6186419ae33e4d9019df7b18d883e">ConstDiagonalIndexReturnType&lt;Dynamic&gt;::Type</a>(derived(), index);
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 <span class="comment"></span>
<a name="l00197"></a>00197 <span class="comment">/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this</span>
<a name="l00198"></a>00198 <span class="comment">  *</span>
<a name="l00199"></a>00199 <span class="comment">  * \c *this is not required to be square.</span>
<a name="l00200"></a>00200 <span class="comment">  *</span>
<a name="l00201"></a>00201 <span class="comment">  * The template parameter \a DiagIndex represent a super diagonal if \a DiagIndex &gt; 0</span>
<a name="l00202"></a>00202 <span class="comment">  * and a sub diagonal otherwise. \a DiagIndex == 0 is equivalent to the main diagonal.</span>
<a name="l00203"></a>00203 <span class="comment">  *</span>
<a name="l00204"></a>00204 <span class="comment">  * Example: \include MatrixBase_diagonal_template_int.cpp</span>
<a name="l00205"></a>00205 <span class="comment">  * Output: \verbinclude MatrixBase_diagonal_template_int.out</span>
<a name="l00206"></a>00206 <span class="comment">  *</span>
<a name="l00207"></a>00207 <span class="comment">  * \sa MatrixBase::diagonal(), class Diagonal */</span>
<a name="l00208"></a>00208 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Derived&gt;
<a name="l00209"></a>00209 <span class="keyword">template</span>&lt;<span class="keywordtype">int</span> Index&gt;
<a name="l00210"></a>00210 <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::template</a> <a class="code" href="namespace_architecture.html#a7ae6186419ae33e4d9019df7b18d883e">DiagonalIndexReturnType&lt;Index&gt;::Type</a>
<a name="l00211"></a>00211 <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::diagonal</a>()
<a name="l00212"></a>00212 {
<a name="l00213"></a>00213   <span class="keywordflow">return</span> derived();
<a name="l00214"></a>00214 }
<a name="l00215"></a>00215 <span class="comment"></span>
<a name="l00216"></a>00216 <span class="comment">/** This is the const version of diagonal&lt;int&gt;(). */</span>
<a name="l00217"></a>00217 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Derived&gt;
<a name="l00218"></a>00218 <span class="keyword">template</span>&lt;<span class="keywordtype">int</span> Index&gt;
<a name="l00219"></a>00219 <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::template</a> <a class="code" href="namespace_architecture.html#a7ae6186419ae33e4d9019df7b18d883e">ConstDiagonalIndexReturnType&lt;Index&gt;::Type</a>
<a name="l00220"></a>00220 <a class="code" href="class_matrix_base.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase&lt;Derived&gt;::diagonal</a>()<span class="keyword"> const</span>
<a name="l00221"></a>00221 <span class="keyword"></span>{
<a name="l00222"></a>00222   <span class="keywordflow">return</span> derived();
<a name="l00223"></a>00223 }
<a name="l00224"></a>00224 
<a name="l00225"></a>00225 <span class="preprocessor">#endif // EIGEN_DIAGONAL_H</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.2</a> for MRPT 0.9.4 SVN: at Mon Jan 10 22:30:30 UTC 2011</td><td></td> <td width="100"> </td> <td width="150">  </td></tr> </table> </body></html>