/usr/share/doc/libeigen3-dev/html/TopicAssertions.html is in libeigen3-doc 3.3.4-4.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | <!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.13"/>
<title>Eigen: Assertions</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="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</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>
 <span id="projectnumber">3.3.4</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.13 -->
<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('TopicAssertions.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)">
</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">Assertions </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="PlainAssert"></a>
Assertions</h1>
<p>The macro eigen_assert is defined to be <code>eigen_plain_assert</code> by default. We use eigen_plain_assert instead of <code>assert</code> to work around a known bug for GCC <= 4.3. Basically, eigen_plain_assert <em>is</em> <code>assert</code>.</p>
<h2><a class="anchor" id="RedefineAssert"></a>
Redefining assertions</h2>
<p>Both eigen_assert and eigen_plain_assert are defined in <a class="el" href="Macros_8h_source.html">Macros.h</a>. Defining eigen_assert indirectly gives you a chance to change its behavior. You can redefine this macro if you want to do something else such as throwing an exception, and fall back to its default behavior with eigen_plain_assert. The code below tells <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library. ">Eigen</a> to throw an std::runtime_error:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <stdexcept></span></div><div class="line"><span class="preprocessor">#undef eigen_assert</span></div><div class="line"><span class="preprocessor">#define eigen_assert(x) \</span></div><div class="line"><span class="preprocessor"> if (!(x)) { throw (std::runtime_error("Put your message here")); }</span></div></div><!-- fragment --><h2><a class="anchor" id="DisableAssert"></a>
Disabling assertions</h2>
<p>Assertions cost run time and can be turned off. You can suppress eigen_assert by defining <code>EIGEN_NO_DEBUG</code> <b>before</b> including <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library. ">Eigen</a> headers. <code>EIGEN_NO_DEBUG</code> is undefined by default unless <code>NDEBUG</code> is defined.</p>
<h1><a class="anchor" id="StaticAssert"></a>
Static assertions</h1>
<p>Static assertions are not standardized until C++11. However, in the <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library. ">Eigen</a> library, there are many conditions can and should be detectedat compile time. For instance, we use static assertions to prevent the code below from compiling.</p>
<div class="fragment"><div class="line"><a class="code" href="group__matrixtypedefs.html#ga84e9fd068879d808012bb6d5dbfecb17">Matrix3d</a>() + <a class="code" href="group__matrixtypedefs.html#ga31c5fac458c04196a36b36b5e51127ff">Matrix4d</a>(); <span class="comment">// adding matrices of different sizes</span></div><div class="line"><a class="code" href="group__matrixtypedefs.html#gaf2b40d33e069e1116ce298c91947dab6">Matrix4cd</a>() * <a class="code" href="group__matrixtypedefs.html#ga1f9f0b80ba445671559b20b18900f1c3">Vector3cd</a>(); <span class="comment">// invalid product known at compile time</span></div></div><!-- fragment --><p>Static assertions are defined in <a class="el" href="StaticAssert_8h_source.html">StaticAssert.h</a>. If there is native static_assert, we use it. Otherwise, we have implemented an assertion macro that can show a limited range of messages.</p>
<p>One can easily come up with static assertions without messages, such as:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#define STATIC_ASSERT(x) \</span></div><div class="line"><span class="preprocessor"> switch(0) { case 0: case x:; }</span></div></div><!-- fragment --><p>However, the example above obviously cannot tell why the assertion failed. Therefore, we define a <code>struct</code> in namespace Eigen::internal to handle available messages.</p>
<div class="fragment"><div class="line"><span class="keyword">template</span><<span class="keywordtype">bool</span> condition></div><div class="line"><span class="keyword">struct </span>static_assertion {};</div><div class="line"></div><div class="line"><span class="keyword">template</span><></div><div class="line"><span class="keyword">struct </span>static_assertion<true></div><div class="line">{</div><div class="line"> <span class="keyword">enum</span> {</div><div class="line"> YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX,</div><div class="line"> YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES,</div><div class="line"> <span class="comment">// see StaticAssert.h for all enums.</span></div><div class="line"> };</div><div class="line">};</div></div><!-- fragment --><p>And then, we define EIGEN_STATIC_ASSERT(CONDITION,MSG) to access Eigen::internal::static_assertion<bool(CONDITION)>::MSG. If the condition evaluates into <code>false</code>, your compiler displays a lot of messages explaining there is no MSG in static_assert<false>. Nevertheless, this is <em>not</em> in what we are interested. As you can see, all members of static_assert<true> are ALL_CAPS_AND_THEY_ARE_SHOUTING.</p>
<dl class="section warning"><dt>Warning</dt><dd>When using this macro, MSG should be a member of static_assertion<true>, or the static assertion <b>always</b> fails. Currently, it can only be used in function scope.</dd></dl>
<h2><a class="anchor" id="DerivedStaticAssert"></a>
Derived static assertions</h2>
<p>There are other macros derived from EIGEN_STATIC_ASSERT to enhance readability. Their names are self-explanatory.</p>
<ul>
<li><b>EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE)</b> - passes if <em>TYPE</em> is fixed size.</li>
<li><b>EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE)</b> - passes if <em>TYPE</em> is dynamic size.</li>
<li><b>EIGEN_STATIC_ASSERT_LVALUE(Derived)</b> - failes if <em>Derived</em> is read-only.</li>
<li><b>EIGEN_STATIC_ASSERT_ARRAYXPR(Derived)</b> - passes if <em>Derived</em> is an array expression.</li>
<li><b>EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2)</b> - failes if the two expressions are an array one and a matrix one.</li>
</ul>
<p>Because <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library. ">Eigen</a> handles both fixed-size and dynamic-size expressions, some conditions cannot be clearly determined at compile time. We classify them into strict assertions and permissive assertions.</p>
<h3><a class="anchor" id="StrictAssertions"></a>
Strict assertions</h3>
<p>These assertions fail if the condition <b>may not</b> be met. For example, MatrixXd may not be a vector, so it fails EIGEN_STATIC_ASSERT_VECTOR_ONLY.</p>
<ul>
<li><b>EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)</b> - passes if <em>TYPE</em> must be a vector type.</li>
<li><b>EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)</b> - passes if <em>TYPE</em> must be a vector of the given size.</li>
<li><b>EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS)</b> - passes if <em>TYPE</em> must be a matrix with given rows and columns.</li>
</ul>
<h3><a class="anchor" id="PermissiveAssertions"></a>
Permissive assertions</h3>
<p>These assertions fail if the condition <b>cannot</b> be met. For example, MatrixXd and Matrix4d may have the same size, so they pass EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE.</p>
<ul>
<li><b>EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1)</b> - fails if the two vector expression types must have different sizes.</li>
<li><b>EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1)</b> - fails if the two matrix expression types must have different sizes.</li>
<li><b>EIGEN_STATIC_ASSERT_SIZE_1x1(TYPE)</b> - fails if <em>TYPE</em> cannot be an 1x1 expression.</li>
</ul>
<p>See <a class="el" href="StaticAssert_8h_source.html">StaticAssert.h</a> for details such as what messages they throw.</p>
<h2><a class="anchor" id="DisableStaticAssert"></a>
Disabling static assertions</h2>
<p>If <code>EIGEN_NO_STATIC_ASSERT</code> is defined, static assertions turn into <code>eigen_assert</code>'s, working like:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#define EIGEN_STATIC_ASSERT(CONDITION,MSG) eigen_assert((CONDITION) && #MSG);</span></div></div><!-- fragment --><p>This saves compile time but consumes more run time. <code>EIGEN_NO_STATIC_ASSERT</code> is undefined by default. </p>
</div></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 by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
</ul>
</div>
</body>
</html>
|