strides.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  6. <link rel="stylesheet" href="../../../../boost.css" type="text/css"/>
  7. <link rel="stylesheet" href="ublas.css" type="text/css" />
  8. <script type="text/javascript" src="js/jquery-1.3.2.min.js" async="async" ></script>
  9. <script type="text/javascript" src="js/jquery.toc-gw.js" async="async" ></script>
  10. <script type="text/x-mathjax-config">
  11. MathJax.Hub.Config({
  12. jax: ["input/TeX", "output/HTML-CSS"],
  13. extensions: ["tex2jax.js"],
  14. "HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], scale: "80" },
  15. tex2jax: {
  16. inlineMath: [ ["$", "$"], ["\\(","\\)"] ],
  17. displayMath: [ ["$$","$$"], ["\\[", "\\]"] ],
  18. processEscapes: true,
  19. ignoreClass: "tex2jax_ignore|dno" },
  20. TeX: { noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } } },
  21. messageStyle: "none"
  22. });
  23. </script>
  24. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js"></script>
  25. <title>Strides</title>
  26. </head>
  27. <body>
  28. <h1><img src="../../../../boost.png" align="middle" />Strides</h1>
  29. <div class="toc" id="toc"></div>
  30. <h2><a name="extents"></a>basic_strides&lt;size_type, format_type&gt;</h2>
  31. <h4>Description</h4>
  32. <p>The template class <code>basic_strides</code> contains weights for a given storage format in order to map multi-indices to scalar memory indices for <a href=
  33. "../tensor.html#tensor">tensor</a> instances.</p>
  34. <h4>Example</h4>
  35. <pre>
  36. #include &lt;boost/numeric/ublas/tensor/strides.hpp&gt;
  37. int main () {
  38. <b>using namespace</b> boost::numeric::ublas;
  39. <b>auto</b> wf = strides&lt;first_order&gt;(shape{4,3,2});
  40. for (<b>auto</b> i = 0u; i &lt; wf.size(); ++i)
  41. std::cout &lt;&lt; wf.at(i) &lt;&lt; std::endl;
  42. // 1,4,12
  43. <b>auto</b> wl = strides&lt;first_order&gt;(shape{4,3,2});
  44. for (<b>auto</b> i = 0u; i &lt; wl.size(); ++i)
  45. std::cout &lt;&lt; wl.at(i) &lt;&lt; std::endl;
  46. // 6,2,1
  47. }
  48. </pre>
  49. <h4>Definition</h4>
  50. <p>Defined in the header tensor/strides.hpp.</p>
  51. <h4>Public base classes</h4>
  52. <p>None.</p>
  53. <h4>Specialization</h4>
  54. <p><code><b>template</b>&lt;<b>class</b> format_t&gt;<br><b>using</b> strides = basic_strides&lt;std::size_t,format_t&gt;</code></p>
  55. <h4>Template parameters</h4>
  56. <table border="1" style="font-size:100%" summary="parameters">
  57. <tbody style="font-size:100%">
  58. <tr>
  59. <th>Parameter</th>
  60. <th>Description</th>
  61. </tr>
  62. <tr>
  63. <td><code>size_type</code></td>
  64. <td>Unsigned integer type.</td>
  65. </tr>
  66. </tbody>
  67. </table>
  68. <h4>Member types</h4>
  69. <table border="1" style="font-size:100%" summary="members">
  70. <tbody style="font-size:100%" >
  71. <tr>
  72. <th>Member type</th>
  73. <th>Description</th>
  74. </tr>
  75. <tr>
  76. <td><code>value_type</code></td>
  77. <td>Type <code>size_type</code> of the strides.</td>
  78. </tr>
  79. <tr>
  80. <td><code>size_type</code></td>
  81. <td>Unsigned integer such as <code>std::size_t</code>.</td>
  82. </tr>
  83. <tr>
  84. <td><code>reference</code></td>
  85. <td>Reference type which is <code>value_type&</code>.</td>
  86. </tr>
  87. <tr>
  88. <td><code>const_reference</code></td>
  89. <td>Constant reference type which is <code>const value_type&</code>.</td>
  90. </tr>
  91. <tr>
  92. <td><code>pointer</code></td>
  93. <td>Pointer type which is <code>value_type*</code>.</td>
  94. </tr>
  95. <tr>
  96. <td><code>const_pointer</code></td>
  97. <td>Constant pointer type which is <code>const value_type*</code>.</td>
  98. </tr>
  99. <tr>
  100. <td><code>layout_type</code></td>
  101. <td>Layout type which can be either <code>boost::numeric::ublas::first_order</code> or <code>boost::numeric::ublas::last_order</code>.</td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. <h4>Member Functions</h4>
  106. <table border="1" summary="members functions">
  107. <tbody>
  108. <tr>
  109. <th>Member Function</th>
  110. <th>Description</th>
  111. </tr>
  112. <tr>
  113. <td><code>basic_strides ()</code></td>
  114. <td>Constructs an empty instance of <code>basic_strides</code>.</td>
  115. </tr>
  116. <tr>
  117. <td><code>basic_strides (basic_extents&lt;value_type&gt; const& be)</code></td>
  118. <td>Constructs an instance based on the tensor extents specified by <code>be</code>.</td>
  119. </tr>
  120. <tr>
  121. <td><code>basic_strides (std::vector&lt;value_type&gt; const& v)</code></td>
  122. <td>Constructs an instance copying the content of <code>v</code>.</td>
  123. </tr>
  124. <tr>
  125. <td><code>basic_strides (std::vector&lt;value_type&gt; && v)</code></td>
  126. <td>Constructs an instance moving the content of <code>v</code>.</td>
  127. </tr>
  128. <tr>
  129. <td><code>basic_strides (basic_strides const& other)</code></td>
  130. <td>Constructs an instance from <code>other</code> copying its elements.</td>
  131. </tr>
  132. <tr>
  133. <td><code>basic_strides (basic_strides && other)</code></td>
  134. <td>Constructs an instance from <code>other</code> by moving its elements.</td>
  135. </tr>
  136. <tr>
  137. <td><code>basic_strides& operator= (basic_strides other)</code></td>
  138. <td>Assigns the elements of <code>other</code> to this instance.</td>
  139. </tr>
  140. <tr>
  141. <td><code>const_pointer data() const</code></td>
  142. <td>Returns a <code>const_pointer</code> to the first element.</td>
  143. </tr>
  144. <tr>
  145. <td><code>const_reference operator[](size_type i) const</code></td>
  146. <td>Returns a <code>const_reference</code> to the <code>i</code>-th element.</td>
  147. </tr>
  148. <tr>
  149. <td><code>const_reference at(size_type i) const</code></td>
  150. <td>Returns a <code>const_reference</code> to the <code>i</code>-th element.</td>
  151. </tr>
  152. <tr>
  153. <td><code>bool empty()</code></td>
  154. <td>Returns true if the container has no elements.</td>
  155. </tr>
  156. <tr>
  157. <td><code>size_type size() const</code></td>
  158. <td>Returns the number of elements.</td>
  159. </tr>
  160. <tr>
  161. <td><code>void clear()</code></td>
  162. <td>Erases all elements.</td>
  163. </tr>
  164. <tr>
  165. <td><code>bool operator==(basic_strides const& b) const</code></td>
  166. <td>Returns true if all elements are equal.</td>
  167. </tr>
  168. <tr>
  169. <td><code>bool operator!=(basic_strides const& b) const</code></td>
  170. <td>Returns true if some elements are not equal.</td>
  171. </tr>
  172. <tr>
  173. <td><code>const_iterator begin() const</code></td>
  174. <td>Returns an <code>const_iterator</code> pointing to the first element.</td>
  175. </tr>
  176. <tr>
  177. <td><code>const_iterator end() const</code></td>
  178. <td>Returns a <code>const_iterator</code> pointing to an element passed the last element.</td>
  179. </tr>
  180. <tr>
  181. <td><code>std::vector&lt;size_type&gt; base() const</code></td>
  182. <td>Returns the private member sequence container holding all elements.</td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. <h4>Non-Member Functions</h4>
  187. <table border="1" summary="members functions">
  188. <tbody>
  189. <tr>
  190. <th>Function</th>
  191. <th>Description</th>
  192. </tr>
  193. <tr>
  194. <td><code>access(std::vector&lt;size_type&gt; const& i, strides&lt;layout_type&gt; w)</code></td>
  195. <td>Returns relative memory location depending on the multi-index vector <code>i</code> and strides <code>w</code>.</td>
  196. </tr>
  197. <tr>
  198. <td><code>access(size_type sum, strides&lt;layout_type&gt; w, size_type i, size_types ... is)</code></td>
  199. <td>Returns relative memory location depending on the indices <code>i</code>, <code>is ... </code> and stride vector <code>w</code> (recursive function).</td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. <hr />
  204. <p>
  205. Copyright (&copy;) 2018 Cem Bassoy<br />
  206. Use, modification and distribution are subject to the
  207. Boost Software License, Version 1.0.
  208. (See accompanying file LICENSE_1_0.txt
  209. or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  210. http://www.boost.org/LICENSE_1_0.txt
  211. </a>).
  212. </p>
  213. <script type="text/javascript">
  214. (function($) {
  215. $('#toc').toc();
  216. })(jQuery);
  217. </script>
  218. </body>
  219. </html>