/usr/share/doc/libeigen2-doc/html/PassingByValue.html is in libeigen2-doc 2.0.17-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Passing Eigen objects by value to functions</title>
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<link href="eigendoxy_tabs.css" rel="stylesheet" type="text/css">
</head><body>
<a name="top"></a>
<a class="logo" href="http://eigen.tuxfamily.org/">
<img src="Eigen_Silly_Professor_64x64.png" width=64 height=64 alt="Eiegn's silly professor"
style="position:absolute; border:none" /></a>
<!-- Generated by Doxygen 1.8.6 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Passing Eigen objects by value to functions </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Passing objects by value is almost always a very bad idea in C++, as this means useless copies, and one should pass them by reference instead.</p>
<p>With Eigen, this is even more important: passing <a class="el" href="FixedSizeVectorizable.html">fixed-size vectorizable Eigen objects</a> by value is not only inefficient, it can be illegal or make your program crash! And the reason is that these Eigen objects have alignment modifiers that aren't respected when they are passed by value.</p>
<p>So for example, a function like this, where v is passed by value:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> my_function(<a class="code" href="classEigen_1_1Matrix.html">Eigen::Vector2d</a> v);</div>
</div><!-- fragment --><p>needs to be rewritten as follows, passing v by reference:</p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> my_function(<span class="keyword">const</span> <a class="code" href="classEigen_1_1Matrix.html">Eigen::Vector2d</a>& v);</div>
</div><!-- fragment --><p>Likewise if you have a class having a Eigen object as member:</p>
<div class="fragment"><div class="line"><span class="keyword">struct </span>Foo</div>
<div class="line">{</div>
<div class="line"> <a class="code" href="classEigen_1_1Matrix.html">Eigen::Vector2d</a> v;</div>
<div class="line">};</div>
<div class="line"><span class="keywordtype">void</span> my_function(Foo v);</div>
</div><!-- fragment --><p>This function also needs to be rewritten like this: </p>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> my_function(<span class="keyword">const</span> Foo& v);</div>
</div><!-- fragment --><p>Note that on the other hand, there is no problem with functions that return objects by value. </p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 21 2014 05:14:49 for Eigen by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
|