Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 99cb5ede6a5329071fbeecc8218deb35 > files > 1077

eigen3-doc-3.2-3.mga4.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>Eigen: Aliasing</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css"   rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
<!-- <script type="text/javascript"> -->
<!-- </script> -->
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!-- <a name="top"></a> -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.2.0</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__TopicAliasing.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Aliasing<div class="ingroups"><a class="el" href="group__DenseMatrixManipulation__chapter.html">Dense matrix and array manipulation</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<p>In Eigen, aliasing refers to assignment statement in which the same matrix (or array or vector) appears on the left and on the right of the assignment operators. Statements like <code>mat = 2 * mat;</code> or <code>mat = mat.transpose();</code> exhibit aliasing. The aliasing in the first example is harmless, but the aliasing in the second example leads to unexpected results. This page explains what aliasing is, when it is harmful, and what to do about it.</p>
<h1><a class="anchor" id="TopicAliasingExamples"></a>
Examples</h1>
<p>Here is a simple example exhibiting aliasing:</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#ga5b9d0d11e78fd355d23221154b7620e4">MatrixXi</a> mat(3,3); </div>
<div class="line">mat &lt;&lt; 1, 2, 3,   4, 5, 6,   7, 8, 9;</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;Here is the matrix mat:\n&quot;</span> &lt;&lt; mat &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line"><span class="comment">// This assignment shows the aliasing problem</span></div>
<div class="line">mat.bottomRightCorner(2,2) = mat.topLeftCorner(2,2);</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;After the assignment, mat = \n&quot;</span> &lt;&lt; mat &lt;&lt; endl;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Here is the matrix mat:
1 2 3
4 5 6
7 8 9
After the assignment, mat = 
1 2 3
4 1 2
7 4 1
</pre> </td></tr>
</table>
<p>The output is not what one would expect. The problem is the assignment </p>
<div class="fragment"><div class="line">mat.bottomRightCorner(2,2) = mat.topLeftCorner(2,2);</div>
</div><!-- fragment --><p> This assignment exhibits aliasing: the coefficient <code>mat(1,1)</code> appears both in the block <code>mat.bottomRightCorner(2,2)</code> on the left-hand side of the assignment and the block <code>mat.topLeftCorner(2,2)</code> on the right-hand side. After the assignment, the (2,2) entry in the bottom right corner should have the value of <code>mat(1,1)</code> before the assignment, which is 5. However, the output shows that <code>mat(2,2)</code> is actually 1. The problem is that Eigen uses lazy evaluation (see <a class="el" href="TopicEigenExpressionTemplates.html">Expression templates in Eigen</a>) for <code>mat.topLeftCorner(2,2)</code>. The result is similar to </p>
<div class="fragment"><div class="line">mat(1,1) = mat(0,0);</div>
<div class="line">mat(1,2) = mat(0,1);</div>
<div class="line">mat(2,1) = mat(1,0);</div>
<div class="line">mat(2,2) = mat(1,1);</div>
</div><!-- fragment --><p> Thus, <code>mat(2,2)</code> is assigned the <em>new</em> value of <code>mat(1,1)</code> instead of the old value. The next section explains how to solve this problem by calling <a class="el" href="classEigen_1_1DenseBase.html#a6cb26f170dd440dfafe11117cf826334">eval()</a>.</p>
<p>Aliasing occurs more naturally when trying to shrink a matrix. For example, the expressions <code>vec = vec.head(n)</code> and <code>mat = mat.block(i,j,r,c)</code> exhibit aliasing.</p>
<p>In general, aliasing cannot be detected at compile time: if <code>mat</code> in the first example were a bit bigger, then the blocks would not overlap, and there would be no aliasing problem. However, Eigen does detect some instances of aliasing, albeit at run time. The following example exhibiting aliasing was mentioned in <a class="el" href="group__TutorialMatrixArithmetic.html">Matrix and vector arithmetic</a> :</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gab837976997f1fdef130c5f47f712b9b0">Matrix2i</a> a; a &lt;&lt; 1, 2, 3, 4;</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;Here is the matrix a:\n&quot;</span> &lt;&lt; a &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line">a = a.transpose(); <span class="comment">// !!! do NOT do this !!!</span></div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;and the result of the aliasing effect:\n&quot;</span> &lt;&lt; a &lt;&lt; endl;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Here is the matrix a:
1 2
3 4
and the result of the aliasing effect:
1 2
2 4
</pre> </td></tr>
</table>
<p>Again, the output shows the aliasing issue. However, by default Eigen uses a run-time assertion to detect this and exits with a message like</p>
<pre class="fragment">void Eigen::DenseBase&lt;Derived&gt;::checkTransposeAliasing(const OtherDerived&amp;) const 
[with OtherDerived = Eigen::Transpose&lt;Eigen::Matrix&lt;int, 2, 2, 0, 2, 2&gt; &gt;, Derived = Eigen::Matrix&lt;int, 2, 2, 0, 2, 2&gt;]: 
Assertion `(!internal::check_transpose_aliasing_selector&lt;Scalar,internal::blas_traits&lt;Derived&gt;::IsTransposed,OtherDerived&gt;::run(internal::extract_data(derived()), other)) 
&amp;&amp; "aliasing detected during transposition, use transposeInPlace() or evaluate the rhs into a temporary using .eval()"' failed.
</pre><p>The user can turn Eigen's run-time assertions like the one to detect this aliasing problem off by defining the EIGEN_NO_DEBUG macro, and the above program was compiled with this macro turned off in order to illustrate the aliasing problem. See <a class="el" href="TopicAssertions.html">Assertions</a> for more information about Eigen's run-time assertions.</p>
<h1><a class="anchor" id="TopicAliasingSolution"></a>
Resolving aliasing issues</h1>
<p>If you understand the cause of the aliasing issue, then it is obvious what must happen to solve it: Eigen has to evaluate the right-hand side fully into a temporary matrix/array and then assign it to the left-hand side. The function <a class="el" href="classEigen_1_1DenseBase.html#a6cb26f170dd440dfafe11117cf826334">eval() </a> does precisely that.</p>
<p>For example, here is the corrected version of the first example above:</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#ga5b9d0d11e78fd355d23221154b7620e4">MatrixXi</a> mat(3,3); </div>
<div class="line">mat &lt;&lt; 1, 2, 3,   4, 5, 6,   7, 8, 9;</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;Here is the matrix mat:\n&quot;</span> &lt;&lt; mat &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line"><span class="comment">// The eval() solves the aliasing problem</span></div>
<div class="line">mat.bottomRightCorner(2,2) = mat.topLeftCorner(2,2).eval();</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;After the assignment, mat = \n&quot;</span> &lt;&lt; mat &lt;&lt; endl;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Here is the matrix mat:
1 2 3
4 5 6
7 8 9
After the assignment, mat = 
1 2 3
4 1 2
7 4 5
</pre> </td></tr>
</table>
<p>Now, <code>mat(2,2)</code> equals 5 after the assignment, as it should be.</p>
<p>The same solution also works for the second example, with the transpose: simply replace the line <code>a = a.transpose();</code> with <code>a = a.transpose().eval();</code>. However, in this common case there is a better solution. Eigen provides the special-purpose function <a class="el" href="classEigen_1_1DenseBase.html#a3689faf485a5e405a4fc9bf0e05564c9">transposeInPlace() </a> which replaces a matrix by its transpose. This is shown below:</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gabab09c32e96cfa9829a88400627af162">MatrixXf</a> a(2,3); a &lt;&lt; 1, 2, 3, 4, 5, 6;</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;Here is the initial matrix a:\n&quot;</span> &lt;&lt; a &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line"></div>
<div class="line">a.transposeInPlace();</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;and after being transposed:\n&quot;</span> &lt;&lt; a &lt;&lt; endl;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Here is the initial matrix a:
1 2 3
4 5 6
and after being transposed:
1 4
2 5
3 6
</pre> </td></tr>
</table>
<p>If an xxxInPlace() function is available, then it is best to use it, because it indicates more clearly what you are doing. This may also allow Eigen to optimize more aggressively. These are some of the xxxInPlace() functions provided:</p>
<table  class="manual">
<tr>
<th>Original function</th><th>In-place function </th></tr>
<tr>
<td><a class="el" href="classEigen_1_1MatrixBase.html#ac43d5834cffcedbd27777329a8f5eeca">MatrixBase::adjoint()</a>  </td><td><a class="el" href="classEigen_1_1MatrixBase.html#aa9915f22bf6388c78f860dfe20e8e4e3">MatrixBase::adjointInPlace()</a>   </td></tr>
<tr class="alt">
<td><a class="el" href="classEigen_1_1DenseBase.html#a6e354bb81f0c7b6888c6a0ce4b4649e2">DenseBase::reverse()</a>  </td><td><a class="el" href="classEigen_1_1DenseBase.html#af148c4e77e657d04573c4fda43740ed5">DenseBase::reverseInPlace()</a>   </td></tr>
<tr>
<td><a class="el" href="classEigen_1_1LDLT.html#a71f78ede18adb53bdfe988161653e812">LDLT::solve()</a>  </td><td>LDLT::solveInPlace()   </td></tr>
<tr class="alt">
<td><a class="el" href="classEigen_1_1LLT.html#a301e28d205fb0308cb4f4b04718e1685">LLT::solve()</a>  </td><td>LLT::solveInPlace()   </td></tr>
<tr>
<td>TriangularView::solve()  </td><td><a class="el" href="classEigen_1_1TriangularView.html#a136a6a60e421673ac17e8c4cfd51681b">TriangularView::solveInPlace()</a>   </td></tr>
<tr class="alt">
<td><a class="el" href="classEigen_1_1DenseBase.html#a3c187c30922fc5e42f208ae3eb0970ee">DenseBase::transpose()</a>  </td><td><a class="el" href="classEigen_1_1DenseBase.html#a3689faf485a5e405a4fc9bf0e05564c9">DenseBase::transposeInPlace()</a>   </td></tr>
</table>
<p>In the special case where a matrix or vector is shrunk using an expression like <code>vec = vec.head(n)</code>, you can use <a class="el" href="classEigen_1_1PlainObjectBase.html#a4ac24a195e3e35ce2d8946cee5873e51">conservativeResize() </a>.</p>
<h1><a class="anchor" id="TopicAliasingCwise"></a>
Aliasing and component-wise operations</h1>
<p>As explained above, it may be dangerous if the same matrix or array occurs on both the left-hand side and the right-hand side of an assignment operator, and it is then often necessary to evaluate the right-hand side explicitly. However, applying component-wise operations (such as matrix addition, scalar multiplication and array multiplication) is safe.</p>
<p>The following example has only component-wise operations. Thus, there is no need for <a class="el" href="classEigen_1_1DenseBase.html#a6cb26f170dd440dfafe11117cf826334">eval() </a> even though the same matrix appears on both sides of the assignments.</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gabab09c32e96cfa9829a88400627af162">MatrixXf</a> mat(2,2); </div>
<div class="line">mat &lt;&lt; 1, 2,  4, 7;</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;Here is the matrix mat:\n&quot;</span> &lt;&lt; mat &lt;&lt; endl &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line">mat = 2 * mat;</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;After &#39;mat = 2 * mat&#39;, mat = \n&quot;</span> &lt;&lt; mat &lt;&lt; endl &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line"></div>
<div class="line">mat = mat - <a class="code" href="classEigen_1_1MatrixBase.html#a0650b65c6ae6c3d19a138b72a6d68568">MatrixXf::Identity</a>(2,2);</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;After the subtraction, it becomes\n&quot;</span> &lt;&lt; mat &lt;&lt; endl &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line"></div>
<div class="line">ArrayXXf arr = mat;</div>
<div class="line">arr = arr.square();</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;After squaring, it becomes\n&quot;</span> &lt;&lt; arr &lt;&lt; endl &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line"><span class="comment">// Combining all operations in one statement:</span></div>
<div class="line">mat &lt;&lt; 1, 2,  4, 7;</div>
<div class="line">mat = (2 * mat - <a class="code" href="classEigen_1_1MatrixBase.html#a0650b65c6ae6c3d19a138b72a6d68568">MatrixXf::Identity</a>(2,2)).array().square();</div>
<div class="line">cout &lt;&lt; <span class="stringliteral">&quot;Doing everything at once yields\n&quot;</span> &lt;&lt; mat &lt;&lt; endl &lt;&lt; endl;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Here is the matrix mat:
1 2
4 7

After 'mat = 2 * mat', mat = 
 2  4
 8 14

After the subtraction, it becomes
 1  4
 8 13

After squaring, it becomes
  1  16
 64 169

Doing everything at once yields
  1  16
 64 169

</pre> </td></tr>
</table>
<p>In general, an assignment is safe if the (i,j) entry of the expression on the right-hand side depends only on the (i,j) entry of the matrix or array on the left-hand side and not on any other entries. In that case it is not necessary to evaluate the right-hand side explicitly.</p>
<h1><a class="anchor" id="TopicAliasingMatrixMult"></a>
Aliasing and matrix multiplication</h1>
<p><a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors. ">Matrix</a> multiplication is the only operation in Eigen that assumes aliasing by default. Thus, if <code>matA</code> is a matrix, then the statement <code>matA = matA * matA;</code> is safe. All other operations in Eigen assume that there are no aliasing problems, either because the result is assigned to a different matrix or because it is a component-wise operation.</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gabab09c32e96cfa9829a88400627af162">MatrixXf</a> matA(2,2); </div>
<div class="line">matA &lt;&lt; 2, 0,  0, 2;</div>
<div class="line">matA = matA * matA;</div>
<div class="line">cout &lt;&lt; matA;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">4 0
0 4</pre> </td></tr>
</table>
<p>However, this comes at a price. When executing the expression <code>matA = matA * matA</code>, Eigen evaluates the product in a temporary matrix which is assigned to <code>matA</code> after the computation. This is fine. But Eigen does the same when the product is assigned to a different matrix (e.g., <code>matB = matA * matA</code>). In that case, it is more efficient to evaluate the product directly into <code>matB</code> instead of evaluating it first into a temporary matrix and copying that matrix to <code>matB</code>.</p>
<p>The user can indicate with the <a class="el" href="classEigen_1_1MatrixBase.html#ae77f3c3ccfb21694555dafc92c2da340">noalias()</a> function that there is no aliasing, as follows: <code>matB.noalias() = matA * matA</code>. This allows Eigen to evaluate the matrix product <code>matA * matA</code> directly into <code>matB</code>.</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gabab09c32e96cfa9829a88400627af162">MatrixXf</a> matA(2,2), matB(2,2); </div>
<div class="line">matA &lt;&lt; 2, 0,  0, 2;</div>
<div class="line"></div>
<div class="line"><span class="comment">// Simple but not quite as efficient</span></div>
<div class="line">matB = matA * matA;</div>
<div class="line">cout &lt;&lt; matB &lt;&lt; endl &lt;&lt; endl;</div>
<div class="line"></div>
<div class="line"><span class="comment">// More complicated but also more efficient</span></div>
<div class="line">matB.noalias() = matA * matA;</div>
<div class="line">cout &lt;&lt; matB;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">4 0
0 4

4 0
0 4</pre> </td></tr>
</table>
<p>Of course, you should not use <code>noalias()</code> when there is in fact aliasing taking place. If you do, then you may get wrong results:</p>
<table  class="example">
<tr>
<th>Example</th><th>Output </th></tr>
<tr>
<td><div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#gabab09c32e96cfa9829a88400627af162">MatrixXf</a> matA(2,2); </div>
<div class="line">matA &lt;&lt; 2, 0,  0, 2;</div>
<div class="line">matA.noalias() = matA * matA;</div>
<div class="line">cout &lt;&lt; matA;</div>
</div><!-- fragment -->  </td><td><pre class="fragment">0 0
0 0</pre> </td></tr>
</table>
<h1><a class="anchor" id="TopicAliasingSummary"></a>
Summary</h1>
<p>Aliasing occurs when the same matrix or array coefficients appear both on the left- and the right-hand side of an assignment operator.</p>
<ul>
<li>Aliasing is harmless with coefficient-wise computations; this includes scalar multiplication and matrix or array addition.</li>
<li>When you multiply two matrices, Eigen assumes that aliasing occurs. If you know that there is no aliasing, then you can use <a class="el" href="classEigen_1_1MatrixBase.html#ae77f3c3ccfb21694555dafc92c2da340">noalias()</a>.</li>
<li>In all other situations, Eigen assumes that there is no aliasing issue and thus gives the wrong result if aliasing does in fact occur. To prevent this, you have to use <a class="el" href="classEigen_1_1DenseBase.html#a6cb26f170dd440dfafe11117cf826334">eval() </a> or one of the xxxInPlace() functions. </li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Mon Oct 28 2013 11:04:27 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.5 </li>
  </ul>
</div>
<!-- Piwik --> 
<!--
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://stats.sylphide-consulting.com/piwik/" : "http://stats.sylphide-consulting.com/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 20);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://stats.sylphide-consulting.com/piwik/piwik.php?idsite=20" style="border:0" alt="" /></p></noscript>
-->
<!-- End Piwik Tracking Code -->
</body>
</html>