mirror of
https://github.com/boostorg/multi_array.git
synced 2026-01-25 06:22:10 +00:00
Compare commits
18 Commits
boost-1.34
...
boost-1.54
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d1a10ae2b | ||
|
|
1e1e4a34d5 | ||
|
|
86b8bf0dda | ||
|
|
05cb2eb119 | ||
|
|
4bc0a9d40b | ||
|
|
123f9708cc | ||
|
|
15536189e4 | ||
|
|
2c2842bee2 | ||
|
|
2325f8bd8c | ||
|
|
6f00b4609c | ||
|
|
8147ea248b | ||
|
|
ed2b6ac3e3 | ||
|
|
5479ef94c8 | ||
|
|
805db3d46f | ||
|
|
1e8a9db226 | ||
|
|
de0307c344 | ||
|
|
d8bf15754e | ||
|
|
06b076cd3e |
@@ -24,8 +24,8 @@
|
||||
width="277" align="middle" height="86"></td>
|
||||
<td><a href="../../../index.htm"><font face="Arial" color="#ffffff"><big>Home</big></font></a></td>
|
||||
<td><a href="../../../libs/libraries.htm"><font face="Arial" color="#ffffff"><big>Libraries</big></font></a></td>
|
||||
<td><a href="../../../people/people.htm"><font face="Arial" color="#ffffff"><big>People</big></font></a></td>
|
||||
<td><a href="../../../more/faq.htm"><font face="Arial" color="#ffffff"><big>FAQ</big></font></a></td>
|
||||
<td><a href="http://www.boost.org/people/people.htm"><font face="Arial" color="#ffffff"><big>People</big></font></a></td>
|
||||
<td><a href="http://www.boost.org/more/faq.htm"><font face="Arial" color="#ffffff"><big>FAQ</big></font></a></td>
|
||||
<td><a href="../../../more/index.htm"><font face="Arial" color="#ffffff"><big>More</big></font></a></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
@@ -45,13 +45,13 @@ definition and common implementations of that interface.
|
||||
<table>
|
||||
<tr valign=top>
|
||||
<td nowrap>Copyright © 2000-2001</td><td>
|
||||
<a href=http://www.osl.iu.edu/~garcia>Ronald Garcia</a>,
|
||||
<a href="http://www.osl.iu.edu/~garcia">Ronald Garcia</a>,
|
||||
Indiana University (<a
|
||||
HREF="mailto:garcia@osl.iu.edu">garcia@osl.iu.edu</a>)<br>
|
||||
<a href="../../../people/jeremy_siek.htm">Jeremy Siek</a>,
|
||||
<a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>,
|
||||
Indiana University (<a
|
||||
HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</a>)<br>
|
||||
<a href=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</a>,
|
||||
<a href="http://www.osl.iu.edu/~lums">Andrew Lumsdaine</a>,
|
||||
Indiana University (<a
|
||||
HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</a>)
|
||||
</td></tr></table>
|
||||
|
||||
@@ -38,7 +38,7 @@ gives a summary of the current dereference return type requirements in the
|
||||
iterator categories.
|
||||
<p>
|
||||
</p><center>
|
||||
<a name="table:2">
|
||||
<a name="table:1">
|
||||
<b>Table 1.</b> Summary of current dereference return type
|
||||
requirements.</a><table border="1">
|
||||
<tbody>
|
||||
@@ -794,4 +794,4 @@ Comparable</a> where <tt><</tt> is a total ordering
|
||||
|
||||
--><!-- LocalWords: Postdecrement
|
||||
|
||||
--></body></html>
|
||||
--></body></html>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Boost.MultiArray Reference Manual</title><meta name="generator" content="DocBook XSL Stylesheets V1.68.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="id729900"></a>Boost.MultiArray Reference Manual</h1></div><div><div class="author"><h3 class="author"><span class="firstname">Ronald</span> <span class="surname">Garcia</span></h3><div class="affiliation"><span class="orgname">Indiana University<br></span><span class="orgdiv">Open Systems Lab<br></span></div></div></div><div><p class="copyright">Copyright © 2002 The Trustees of Indiana University</p></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#synopsis">Library Synopsis</a></span></dt><dt><span class="sect1"><a href="#MultiArray">MultiArray Concept</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id834641">Notation</a></span></dt><dt><span class="sect2"><a href="#id834809">Associated Types</a></span></dt><dt><span class="sect2"><a href="#id835319">Valid expressions</a></span></dt><dt><span class="sect2"><a href="#id836109">Complexity guarantees</a></span></dt><dt><span class="sect2"><a href="#id836133">Invariants</a></span></dt><dt><span class="sect2"><a href="#view_types">Associated Types for Views</a></span></dt><dt><span class="sect2"><a href="#id837503">Models</a></span></dt></dl></dd><dt><span class="sect1"><a href="#array_types">Array Components</a></span></dt><dd><dl><dt><span class="sect2"><a href="#multi_array"><code class="literal">multi_array</code></a></span></dt><dt><span class="sect2"><a href="#multi_array_ref"><code class="literal">multi_array_ref</code></a></span></dt><dt><span class="sect2"><a href="#const_multi_array_ref"><code class="literal">const_multi_array_ref</code></a></span></dt></dl></dd><dt><span class="sect1"><a href="#auxiliary">Auxiliary Components</a></span></dt><dd><dl><dt><span class="sect2"><a href="#multi_array_types"><code class="literal">multi_array_types</code></a></span></dt><dt><span class="sect2"><a href="#extent_range"><code class="classname">extent_range</code></a></span></dt><dt><span class="sect2"><a href="#extent_gen"><code class="classname">extent_gen</code></a></span></dt><dt><span class="sect2"><a href="#id862083">Global Objects</a></span></dt><dt><span class="sect2"><a href="#generators">View and SubArray Generators</a></span></dt><dt><span class="sect2"><a href="#memory_layout">Memory Layout Specifiers</a></span></dt><dt><span class="sect2"><a href="#range_checking">Range Checking</a></span></dt></dl></dd></dl></div><p>Boost.MultiArray is composed of several components.
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Boost.MultiArray Reference Manual</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article" title="Boost.MultiArray Reference Manual"><div class="titlepage"><div><div><h2 class="title"><a name="idp2304"></a>Boost.MultiArray Reference Manual</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Ronald</span> <span class="surname">Garcia</span></h3><div class="affiliation"><span class="orgname">Indiana University<br></span> <span class="orgdiv">Open Systems Lab<br></span></div></div></div><div><p class="copyright">Copyright © 2002 The Trustees of Indiana University</p></div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#synopsis">Library Synopsis</a></span></dt><dt><span class="sect1"><a href="#MultiArray">MultiArray Concept</a></span></dt><dd><dl><dt><span class="sect2"><a href="#idp18427760">Notation</a></span></dt><dt><span class="sect2"><a href="#idp18446208">Associated Types</a></span></dt><dt><span class="sect2"><a href="#idp18501744">Valid expressions</a></span></dt><dt><span class="sect2"><a href="#idp18588736">Complexity guarantees</a></span></dt><dt><span class="sect2"><a href="#idp18591264">Invariants</a></span></dt><dt><span class="sect2"><a href="#view_types">Associated Types for Views</a></span></dt><dt><span class="sect2"><a href="#idp18737792">Models</a></span></dt></dl></dd><dt><span class="sect1"><a href="#array_types">Array Components</a></span></dt><dd><dl><dt><span class="sect2"><a href="#multi_array_class"><code class="literal">multi_array</code></a></span></dt><dt><span class="sect2"><a href="#multi_array_ref"><code class="literal">multi_array_ref</code></a></span></dt><dt><span class="sect2"><a href="#const_multi_array_ref"><code class="literal">const_multi_array_ref</code></a></span></dt></dl></dd><dt><span class="sect1"><a href="#auxiliary">Auxiliary Components</a></span></dt><dd><dl><dt><span class="sect2"><a href="#multi_array_types"><code class="literal">multi_array_types</code></a></span></dt><dt><span class="sect2"><a href="#extent_range"><code class="classname">extent_range</code></a></span></dt><dt><span class="sect2"><a href="#extent_gen"><code class="classname">extent_gen</code></a></span></dt><dt><span class="sect2"><a href="#idp19487120">Global Objects</a></span></dt><dt><span class="sect2"><a href="#generators">View and SubArray Generators</a></span></dt><dt><span class="sect2"><a href="#memory_layout">Memory Layout Specifiers</a></span></dt><dt><span class="sect2"><a href="#range_checking">Range Checking</a></span></dt></dl></dd></dl></div><p>Boost.MultiArray is composed of several components.
|
||||
The MultiArray concept defines a generic interface to multidimensional
|
||||
containers.
|
||||
<code class="literal">multi_array</code> is a general purpose container class
|
||||
@@ -11,7 +11,7 @@ you can manipulate any block of contiguous data as though it were a
|
||||
<code class="literal">multi_array_ref</code> in that its elements cannot
|
||||
be modified through its interface. Finally, several auxiliary classes are used
|
||||
to create and specialize arrays and some global objects are defined as
|
||||
part of the library interface.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="synopsis"></a>Library Synopsis</h2></div></div></div><p>To use Boost.MultiArray, you must include the header
|
||||
part of the library interface.</p><div class="sect1" title="Library Synopsis"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="synopsis"></a>Library Synopsis</h2></div></div></div><p>To use Boost.MultiArray, you must include the header
|
||||
<code class="filename">boost/multi_array.hpp</code> in your source. This file
|
||||
brings the following declarations into scope:</p><pre class="programlisting">
|
||||
namespace boost {
|
||||
@@ -52,7 +52,7 @@ namespace boost {
|
||||
template <std::size_t NumDims> class general_storage_order;
|
||||
|
||||
}
|
||||
</pre></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="MultiArray"></a>MultiArray Concept</h2></div></div></div><p>The MultiArray
|
||||
</pre></div><div class="sect1" title="MultiArray Concept"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="MultiArray"></a>MultiArray Concept</h2></div></div></div><p>The MultiArray
|
||||
concept defines an interface to hierarchically nested
|
||||
containers. It specifies operations for accessing elements,
|
||||
traversing containers, and creating views
|
||||
@@ -150,17 +150,23 @@ number of possible element layouts. For example, the elements of a 2
|
||||
dimensional array can be stored by row (i.e., the elements of each row
|
||||
are stored contiguously) or by column (i.e., the elements of each
|
||||
column are stored contiguously).
|
||||
</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id834641"></a>Notation</h3></div></div></div><p>What follows are the descriptions of symbols that will be used
|
||||
to describe the MultiArray interface.</p><div class="table"><a name="id834650"></a><p class="title"><b>Table 1. Notation</b></p><table summary="Notation" border="1"><colgroup><col><col></colgroup><tbody><tr><td><code class="literal">A</code></td><td>A type that is a model of MultiArray
|
||||
</p><p>
|
||||
Two concept checking classes for the MultiArray concepts
|
||||
(<code class="literal">ConstMultiArrayConcept</code> and
|
||||
<code class="literal">MutableMultiArrayConcept</code>) are in the namespace
|
||||
<code class="literal">boost::multi_array_concepts</code> in
|
||||
<code class="literal"><boost/multi_array/concept_checks.hpp></code>.
|
||||
</p><div class="sect2" title="Notation"><div class="titlepage"><div><div><h3 class="title"><a name="idp18427760"></a>Notation</h3></div></div></div><p>What follows are the descriptions of symbols that will be used
|
||||
to describe the MultiArray interface.</p><div class="table"><a name="idp18428768"></a><p class="title"><b>Table 1. Notation</b></p><div class="table-contents"><table summary="Notation" border="1"><colgroup><col><col></colgroup><tbody><tr><td><code class="literal">A</code></td><td>A type that is a model of MultiArray
|
||||
</td></tr><tr><td><code class="literal">a,b</code></td><td>Objects of type <code class="literal">A</code></td></tr><tr><td><code class="literal">NumDims</code></td><td>The numeric dimension parameter associated with
|
||||
<code class="literal">A</code>.</td></tr><tr><td><code class="literal">Dims</code></td><td>Some numeric dimension parameter such that
|
||||
<code class="literal">0<Dims<NumDims</code>.
|
||||
</td></tr><tr><td><code class="literal">indices</code></td><td>An object created by some number of chained calls
|
||||
to <code class="literal">index_gen::operator[](index_range)</code>.</td></tr><tr><td><code class="literal">index_list</code></td><td>An object whose type models
|
||||
<a href="../../utility/Collection.html" target="_top">Collection</a>
|
||||
<a class="ulink" href="../../utility/Collection.html" target="_top">Collection</a>
|
||||
</td></tr><tr><td><code class="literal">idx</code></td><td>A signed integral value.</td></tr><tr><td><code class="literal">tmp</code></td><td>An object of type
|
||||
<code class="literal">boost::array<index,NumDims></code></td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id834809"></a>Associated Types</h3></div></div></div><p>
|
||||
</p><div class="table"><a name="id834817"></a><p class="title"><b>Table 2. Associated Types</b></p><table summary="Associated Types" border="1"><colgroup><col><col></colgroup><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">value_type</code></td><td>This is the value type of the container.
|
||||
<code class="literal">boost::array<index,NumDims></code></td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="Associated Types"><div class="titlepage"><div><div><h3 class="title"><a name="idp18446208"></a>Associated Types</h3></div></div></div><p>
|
||||
</p><div class="table"><a name="idp18447104"></a><p class="title"><b>Table 2. Associated Types</b></p><div class="table-contents"><table summary="Associated Types" border="1"><colgroup><col><col></colgroup><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">value_type</code></td><td>This is the value type of the container.
|
||||
If <code class="literal">NumDims == 1</code>, then this is
|
||||
<code class="literal">element</code>. Otherwise, this is the value type of the
|
||||
immediately nested containers.
|
||||
@@ -192,15 +198,17 @@ iterators. It is the same type as
|
||||
</td></tr><tr><td><code class="literal">iterator</code></td><td>
|
||||
This is an iterator over the values of <code class="literal">A</code>.
|
||||
If <code class="literal">NumDims == 1</code>, then it models
|
||||
<a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html" target="_top">
|
||||
<a class="ulink" href="http://www.boost.org/doc/html/RandomAccessIterator.html" target="_top">
|
||||
<code class="literal">Random Access Iterator</code></a>.
|
||||
Otherwise it models
|
||||
<a href="./iterator_categories.html#concept_RandomAccessTraversalIterator" target="_top">
|
||||
<a class="ulink" href="./iterator_categories.html#concept_RandomAccessTraversalIterator" target="_top">
|
||||
Random Access Traversal Iterator</a>,
|
||||
<a href="./iterator_categories.html#concept_ReadableIterator" target="_top">
|
||||
Readable Iterator</a>, and
|
||||
<a href="./iterator_categories.html#concept_WritableIterator" target="_top">
|
||||
Writable Iterator</a>.
|
||||
<a class="ulink" href="./iterator_categories.html#concept_ReadableIterator" target="_top">
|
||||
Readable Iterator</a>,
|
||||
<a class="ulink" href="./iterator_categories.html#concept_WritableIterator" target="_top">
|
||||
Writable Iterator</a>, and
|
||||
<a class="ulink" href="http://www.boost.org/doc/html/OutputIterator.html" target="_top">
|
||||
<code class="literal">Output Iterator</code></a>.
|
||||
</td></tr><tr><td>
|
||||
<code class="literal">const_iterator</code>
|
||||
</td><td>
|
||||
@@ -260,7 +268,9 @@ It models MultiArray.
|
||||
const_array_view<Dims>::type</code>
|
||||
</td><td>
|
||||
This is the const view type with <code class="literal">Dims</code> dimensions.
|
||||
</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id835319"></a>Valid expressions</h3></div></div></div><div class="table"><a name="id835323"></a><p class="title"><b>Table 3. Valid Expressions</b></p><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><code class="literal">a.shape()</code></td><td><code class="literal">const size_type*</code></td><td>
|
||||
</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="Valid expressions"><div class="titlepage"><div><div><h3 class="title"><a name="idp18501744"></a>Valid expressions</h3></div></div></div><div class="table"><a name="idp18502256"></a><p class="title"><b>Table 3. Valid Expressions</b></p><div class="table-contents"><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><code class="literal">A::dimensionality</code></td><td><code class="literal">size_type</code></td><td>This compile-time constant represents the number of
|
||||
dimensions of the array (note that
|
||||
<code class="literal">A::dimensionality == NumDims</code>).</td></tr><tr><td><code class="literal">a.shape()</code></td><td><code class="literal">const size_type*</code></td><td>
|
||||
This returns a list of <code class="literal">NumDims</code> elements specifying the
|
||||
extent of each array dimension.
|
||||
</td></tr><tr><td><code class="literal">a.strides()</code></td><td><code class="literal">const index*</code></td><td>
|
||||
@@ -343,26 +353,26 @@ This expression generates a view of the array determined by the
|
||||
used to construct <code class="literal">indices</code>.
|
||||
</td></tr><tr><td><code class="literal">a == b</code></td><td>bool</td><td>This performs a lexicographical comparison of the
|
||||
values of <code class="literal">a</code> and <code class="literal">b</code>. The element
|
||||
type must model <a href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> for this
|
||||
type must model <a class="ulink" href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> for this
|
||||
expression to be valid.</td></tr><tr><td><code class="literal">a < b</code></td><td>bool</td><td>This performs a lexicographical comparison of the
|
||||
values of <code class="literal">a</code> and <code class="literal">b</code>. The element
|
||||
type must model <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
type must model <a class="ulink" href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
expression to be valid.</td></tr><tr><td><code class="literal">a <= b</code></td><td>bool</td><td>This performs a lexicographical comparison of the
|
||||
values of <code class="literal">a</code> and <code class="literal">b</code>. The element
|
||||
type must model <a href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and
|
||||
<a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
type must model <a class="ulink" href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and
|
||||
<a class="ulink" href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
expression to be valid.</td></tr><tr><td><code class="literal">a > b</code></td><td>bool</td><td>This performs a lexicographical comparison of the
|
||||
values of <code class="literal">a</code> and <code class="literal">b</code>. The element
|
||||
type must model <a href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and
|
||||
<a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
type must model <a class="ulink" href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and
|
||||
<a class="ulink" href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
expression to be valid.</td></tr><tr><td><code class="literal">a >= b</code></td><td>bool</td><td>This performs a lexicographical comparison of the
|
||||
values of <code class="literal">a</code> and <code class="literal">b</code>. The element
|
||||
type must model <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
expression to be valid.</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id836109"></a>Complexity guarantees</h3></div></div></div><code class="literal">begin()</code> and <code class="literal">end()</code> execute in amortized
|
||||
type must model <a class="ulink" href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
|
||||
expression to be valid.</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="Complexity guarantees"><div class="titlepage"><div><div><h3 class="title"><a name="idp18588736"></a>Complexity guarantees</h3></div></div></div><code class="literal">begin()</code> and <code class="literal">end()</code> execute in amortized
|
||||
constant time.
|
||||
<code class="literal">size()</code> executes in at most linear time in the
|
||||
MultiArray's size.
|
||||
</div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id836133"></a>Invariants</h3></div></div></div><div class="table"><a name="id836139"></a><p class="title"><b>Table 4. Invariants</b></p><table summary="Invariants" border="1"><colgroup><col><col></colgroup><tbody><tr><td>Valid range</td><td><code class="literal">[a.begin(),a.end())</code> is a valid range.
|
||||
</div><div class="sect2" title="Invariants"><div class="titlepage"><div><div><h3 class="title"><a name="idp18591264"></a>Invariants</h3></div></div></div><div class="table"><a name="idp18591904"></a><p class="title"><b>Table 4. Invariants</b></p><div class="table-contents"><table summary="Invariants" border="1"><colgroup><col><col></colgroup><tbody><tr><td>Valid range</td><td><code class="literal">[a.begin(),a.end())</code> is a valid range.
|
||||
</td></tr><tr><td>Range size</td><td>
|
||||
<code class="literal">a.size() == std::distance(a.begin(),a.end());</code>.
|
||||
</td></tr><tr><td>Completeness</td><td>
|
||||
@@ -373,11 +383,11 @@ Iteration through the range
|
||||
Calling <code class="literal">a[a1][a2]...[aN]</code> where <code class="literal">N==NumDims</code>
|
||||
yields the same result as calling
|
||||
<code class="literal">a(index_list)</code>, where <code class="literal">index_list</code>
|
||||
is a <a href="../../utility/Collection.html" target="_top">Collection</a> containing the values <code class="literal">a1...aN</code>.
|
||||
</td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="view_types"></a>Associated Types for Views</h3></div></div></div><p>The following MultiArray associated
|
||||
is a <a class="ulink" href="../../utility/Collection.html" target="_top">Collection</a> containing the values <code class="literal">a1...aN</code>.
|
||||
</td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect2" title="Associated Types for Views"><div class="titlepage"><div><div><h3 class="title"><a name="view_types"></a>Associated Types for Views</h3></div></div></div><p>The following MultiArray associated
|
||||
types define the interface for creating views of existing
|
||||
MultiArrays. Their interfaces and roles in the
|
||||
concept are described below.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="index_range"></a><code class="literal">index_range</code></h4></div></div></div><p><code class="literal">index_range</code> objects represent half-open
|
||||
concept are described below.</p><div class="sect3" title="index_range"><div class="titlepage"><div><div><h4 class="title"><a name="index_range"></a><code class="literal">index_range</code></h4></div></div></div><p><code class="literal">index_range</code> objects represent half-open
|
||||
strided intervals. They are aggregated (using an
|
||||
<code class="literal">index_gen</code> object) and passed to
|
||||
a MultiArray's <code class="literal">operator[]</code>
|
||||
@@ -401,10 +411,10 @@ operators, a half open range [5,10) can be specified as follows:
|
||||
|
||||
The following describes the
|
||||
<code class="literal">index_range</code> interface.
|
||||
</p><div class="table"><a name="id836367"></a><p class="title"><b>Table 5. Notation</b></p><table summary="Notation" border="1"><colgroup><col><col></colgroup><tbody><tr><td><code class="literal">i</code></td><td>An object of type <code class="literal">index_range</code>.</td></tr><tr><td><code class="literal">idx,idx1,idx2,idx3</code></td><td>Objects of type <code class="literal">index</code>.</td></tr></tbody></table></div><div class="table"><a name="id836420"></a><p class="title"><b>Table 6. Associated Types</b></p><table summary="Associated Types" border="1"><colgroup><col><col></colgroup><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">index</code></td><td>This is a signed integral type. It is used to
|
||||
</p><div class="table"><a name="idp18614960"></a><p class="title"><b>Table 5. Notation</b></p><div class="table-contents"><table summary="Notation" border="1"><colgroup><col><col></colgroup><tbody><tr><td><code class="literal">i</code></td><td>An object of type <code class="literal">index_range</code>.</td></tr><tr><td><code class="literal">idx,idx1,idx2,idx3</code></td><td>Objects of type <code class="literal">index</code>.</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="idp18620944"></a><p class="title"><b>Table 6. Associated Types</b></p><div class="table-contents"><table summary="Associated Types" border="1"><colgroup><col><col></colgroup><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">index</code></td><td>This is a signed integral type. It is used to
|
||||
specify the start, finish, and stride values.</td></tr><tr><td><code class="literal">size_type</code></td><td>This is an unsigned integral type. It is used to
|
||||
report the size of the range an <code class="literal">index_range</code>
|
||||
represents.</td></tr></tbody></table></div><div class="table"><a name="id836483"></a><p class="title"><b>Table 7. Valid Expressions</b></p><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><code class="literal">index_range(idx1,idx2,idx3)</code></td><td><code class="literal">index_range</code></td><td>This constructs an <code class="literal">index_range</code>
|
||||
represents.</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="idp18627920"></a><p class="title"><b>Table 7. Valid Expressions</b></p><div class="table-contents"><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><code class="literal">index_range(idx1,idx2,idx3)</code></td><td><code class="literal">index_range</code></td><td>This constructs an <code class="literal">index_range</code>
|
||||
representing the interval <code class="literal">[idx1,idx2)</code>
|
||||
with stride <code class="literal">idx3</code>.</td></tr><tr><td><code class="literal">index_range(idx1,idx2)</code></td><td><code class="literal">index_range</code></td><td>This constructs an <code class="literal">index_range</code>
|
||||
representing the interval <code class="literal">[idx1,idx2)</code>
|
||||
@@ -436,14 +446,14 @@ value. This notation includes
|
||||
of <code class="literal">i</code> up by <code class="literal">idx</code>. It is equivalent to
|
||||
<code class="literal">index_range(r.start()+idx1, r.finish()+idx, r.stride())</code></td></tr><tr><td><code class="literal">i - idx</code></td><td><code class="literal">index</code></td><td>This expression shifts the start and finish values
|
||||
of <code class="literal">i</code> up by <code class="literal">idx</code>. It is equivalent to
|
||||
<code class="literal">index_range(r.start()-idx1, r.finish()-idx, r.stride())</code></td></tr></tbody></table></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="index_gen"></a><code class="literal">index_gen</code></h4></div></div></div><p> <code class="literal">index_gen</code> aggregates
|
||||
<code class="literal">index_range(r.start()-idx1, r.finish()-idx, r.stride())</code></td></tr></tbody></table></div></div><br class="table-break"></div><div class="sect3" title="index_gen"><div class="titlepage"><div><div><h4 class="title"><a name="index_gen"></a><code class="literal">index_gen</code></h4></div></div></div><p> <code class="literal">index_gen</code> aggregates
|
||||
<code class="literal">index_range</code> objects in order to specify view
|
||||
parameters. Chained calls to <code class="literal">operator[]</code> store
|
||||
range and dimension information used to
|
||||
instantiate a new view into a MultiArray.
|
||||
</p><div class="table"><a name="id837149"></a><p class="title"><b>Table 8. Notation</b></p><table summary="Notation" border="1"><colgroup><col><col></colgroup><tbody><tr><td><code class="literal">Dims,Ranges</code></td><td>Unsigned integral values.</td></tr><tr><td><code class="literal">x</code></td><td>An object of type
|
||||
</p><div class="table"><a name="idp18699808"></a><p class="title"><b>Table 8. Notation</b></p><div class="table-contents"><table summary="Notation" border="1"><colgroup><col><col></colgroup><tbody><tr><td><code class="literal">Dims,Ranges</code></td><td>Unsigned integral values.</td></tr><tr><td><code class="literal">x</code></td><td>An object of type
|
||||
<code class="literal">template gen_type<Dims,Ranges>::type</code>.</td></tr><tr><td><code class="literal">i</code></td><td>An object of type
|
||||
<code class="literal">index_range</code>.</td></tr><tr><td><code class="literal">idx</code></td><td>Objects of type <code class="literal">index</code>.</td></tr></tbody></table></div><div class="table"><a name="id837235"></a><p class="title"><b>Table 9. Associated Types</b></p><table summary="Associated Types" border="1"><colgroup><col><col></colgroup><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">index</code></td><td>This is a signed integral type. It is used to
|
||||
<code class="literal">index_range</code>.</td></tr><tr><td><code class="literal">idx</code></td><td>Objects of type <code class="literal">index</code>.</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="idp18709408"></a><p class="title"><b>Table 9. Associated Types</b></p><div class="table-contents"><table summary="Associated Types" border="1"><colgroup><col><col></colgroup><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">index</code></td><td>This is a signed integral type. It is used to
|
||||
specify degenerate dimensions.</td></tr><tr><td><code class="literal">size_type</code></td><td>This is an unsigned integral type. It is used to
|
||||
report the size of the range an <code class="literal">index_range</code>
|
||||
represents.</td></tr><tr><td>
|
||||
@@ -454,21 +464,21 @@ represents.</td></tr><tr><td>
|
||||
degenerate ranges specified (i.e. calls to
|
||||
<code class="literal">operator[](index)</code>). Note that
|
||||
<code class="classname">index_gen</code> and
|
||||
<code class="classname">gen_type<0,0>::type</code> are the same type.</td></tr></tbody></table></div><div class="table"><a name="id837347"></a><p class="title"><b>Table 10. Valid Expressions</b></p><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><code class="literal">index_gen()</code></td><td><code class="literal">gen_type<0,0>::type</code></td><td>This constructs an <code class="literal">index_gen</code>
|
||||
<code class="classname">gen_type<0,0>::type</code> are the same type.</td></tr></tbody></table></div></div><br class="table-break"><div class="table"><a name="idp18721296"></a><p class="title"><b>Table 10. Valid Expressions</b></p><div class="table-contents"><table summary="Valid Expressions" border="1"><colgroup><col><col><col></colgroup><thead><tr><th>Expression</th><th>Return type</th><th>Semantics</th></tr></thead><tbody><tr><td><code class="literal">index_gen()</code></td><td><code class="literal">gen_type<0,0>::type</code></td><td>This constructs an <code class="literal">index_gen</code>
|
||||
object. This object can then be used to generate tuples of
|
||||
<code class="literal">index_range</code> values.</td></tr><tr><td><code class="literal">x[i]</code></td><td><code class="literal">gen_type<Dims+1,Ranges+1>::type</code>
|
||||
</td><td>Returns a new object containing all previous
|
||||
<code class="classname">index_range</code> objects in addition to
|
||||
<code class="literal">i.</code> Chained calls to
|
||||
<code class="function">operator[]</code> are the means by which
|
||||
<code class="classname">index_range</code> objects are aggregated.</td></tr><tr><td><code class="literal">x[idx]</code></td><td><code class="literal">gen_type<Dims,Ranges>::type</code>
|
||||
<code class="classname">index_range</code> objects are aggregated.</td></tr><tr><td><code class="literal">x[idx]</code></td><td><code class="literal">gen_type<Dims,Ranges+1>::type</code>
|
||||
</td><td>Returns a new object containing all previous
|
||||
<code class="classname">index_range</code> objects in addition to a degenerate
|
||||
range, <code class="literal">index_range(idx,idx).</code> Note that this is NOT
|
||||
equivalent to <code class="literal">x[index_range(idx,idx)].</code>, which will
|
||||
return an object of type
|
||||
<code class="literal">gen_type<Dims+1,Ranges+1>::type</code>.
|
||||
</td></tr></tbody></table></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id837503"></a>Models</h3></div></div></div><div class="itemizedlist"><ul type="disc"><li><code class="literal">multi_array</code></li><li><code class="literal">multi_array_ref</code></li><li><code class="literal">const_multi_array_ref</code></li><li><code class="literal">template array_view<Dims>::type</code></li><li><code class="literal">template const_array_view<Dims>::type</code></li><li><code class="literal">template subarray<Dims>::type</code></li><li><code class="literal">template const_subarray<Dims>::type</code></li></ul></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="array_types"></a>Array Components</h2></div></div></div><p>
|
||||
</td></tr></tbody></table></div></div><br class="table-break"></div></div><div class="sect2" title="Models"><div class="titlepage"><div><div><h3 class="title"><a name="idp18737792"></a>Models</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><code class="literal">multi_array</code></li><li class="listitem"><code class="literal">multi_array_ref</code></li><li class="listitem"><code class="literal">const_multi_array_ref</code></li><li class="listitem"><code class="literal">template array_view<Dims>::type</code></li><li class="listitem"><code class="literal">template const_array_view<Dims>::type</code></li><li class="listitem"><code class="literal">template subarray<Dims>::type</code></li><li class="listitem"><code class="literal">template const_subarray<Dims>::type</code></li></ul></div></div></div><div class="sect1" title="Array Components"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="array_types"></a>Array Components</h2></div></div></div><p>
|
||||
Boost.MultiArray defines an array class,
|
||||
<code class="literal">multi_array</code>, and two adapter classes,
|
||||
<code class="literal">multi_array_ref</code> and
|
||||
@@ -485,7 +495,7 @@ adapts cannot be modified through its interface, though some array
|
||||
properties, including the array shape and index bases, can be altered.
|
||||
Functionality the classes have in common is described
|
||||
below.
|
||||
</p><p><b>Note: Preconditions, Effects, and Implementation. </b>
|
||||
</p><p title="Note: Preconditions, Effects, and Implementation"><b>Note: Preconditions, Effects, and Implementation. </b>
|
||||
Throughout the following sections, small pieces of C++ code are
|
||||
used to specify constraints such as preconditions, effects, and
|
||||
postconditions. These do not necessarily describe the underlying
|
||||
@@ -496,7 +506,7 @@ preconditions results in undefined behavior. Not all effects
|
||||
(i.e. copy constructors, etc.) must be mimicked exactly. The code
|
||||
snippets for effects intend to capture the essence of the described
|
||||
operation.
|
||||
</p><p><b>Queries. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">element* data();
|
||||
</p><p title="Queries"><b>Queries. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">element* data();
|
||||
const element* data() const;</pre></span></dt><dd><p>This returns a pointer to the beginning of the
|
||||
contiguous block that contains the array's data. If all dimensions of
|
||||
the array are 0-indexed and stored in ascending order, this is
|
||||
@@ -514,7 +524,7 @@ version of this function. (Required by MultiArray)
|
||||
<code class="literal">multi_array</code>. (Required by MultiArray)
|
||||
</p></dd><dt><span class="term"><code class="function">const size_type* shape();</code></span></dt><dd><p>This returns the shape of the
|
||||
<code class="literal">multi_array</code>. (Required by MultiArray)
|
||||
</p></dd></dl></div><p><b>Comparators. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
</p></dd></dl></div><p title="Comparators"><b>Comparators. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
bool operator==(const *array-type*& rhs);
|
||||
bool operator!=(const *array-type*& rhs);
|
||||
bool operator<(const *array-type*& rhs);
|
||||
@@ -523,9 +533,9 @@ bool operator>=(const *array-type*& rhs);
|
||||
bool operator<=(const *array-type*& rhs);</pre></span></dt><dd><p>Each comparator executes a lexicographical compare over
|
||||
the value types of the two arrays.
|
||||
(Required by MultiArray)
|
||||
</p><p><b>Preconditions. </b><code class="literal">element</code> must support the
|
||||
</p><p title="Preconditions"><b>Preconditions. </b><code class="literal">element</code> must support the
|
||||
comparator corresponding to that called on
|
||||
<code class="literal">multi_array</code>.</p><p><b>Complexity. </b>O(<code class="literal">num_elements()</code>).</p></dd></dl></div><p><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term">
|
||||
<code class="literal">multi_array</code>.</p><p title="Complexity"><b>Complexity. </b>O(<code class="literal">num_elements()</code>).</p></dd></dl></div><p title="Modifiers"><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term">
|
||||
<pre class="programlisting">
|
||||
|
||||
template <typename SizeList>
|
||||
@@ -535,12 +545,12 @@ void reshape(const SizeList& sizes)
|
||||
</span></dt><dd><p>This changes the shape of the <code class="literal">multi_array</code>. The
|
||||
number of elements and the index bases remain the same, but the number
|
||||
of values at each level of the nested container hierarchy may
|
||||
change.</p><p><b><code class="literal">SizeList</code> Requirements. </b><code class="literal">SizeList</code> must model
|
||||
<a href="../../utility/Collection.html" target="_top">Collection</a>.</p><p><b>Preconditions. </b>
|
||||
change.</p><p title="SizeList Requirements"><b><code class="literal">SizeList</code> Requirements. </b><code class="literal">SizeList</code> must model
|
||||
<a class="ulink" href="../../utility/Collection.html" target="_top">Collection</a>.</p><p title="Preconditions"><b>Preconditions. </b>
|
||||
</p><pre class="programlisting">
|
||||
std::accumulate(sizes.begin(),sizes.end(),size_type(1),std::times<size_type>()) == this->num_elements();
|
||||
sizes.size() == NumDims;
|
||||
</pre><p><b>Postconditions. </b>
|
||||
</pre><p title="Postconditions"><b>Postconditions. </b>
|
||||
<code class="literal">std::equal(sizes.begin(),sizes.end(),this->shape) == true;</code>
|
||||
</p></dd><dt><span class="term">
|
||||
<pre class="programlisting">
|
||||
@@ -550,8 +560,8 @@ void reindex(const BaseList& values);
|
||||
|
||||
</pre>
|
||||
</span></dt><dd><p>This changes the index bases of the <code class="literal">multi_array</code> to
|
||||
correspond to the the values in <code class="literal">values</code>.</p><p><b><code class="literal">BaseList</code> Requirements. </b><code class="literal">BaseList</code> must model
|
||||
<a href="../../utility/Collection.html" target="_top">Collection</a>.</p><p><b>Preconditions. </b><code class="literal">values.size() == NumDims;</code></p><p><b>Postconditions. </b><code class="literal">std::equal(values.begin(),values.end(),this->index_bases());
|
||||
correspond to the the values in <code class="literal">values</code>.</p><p title="BaseList Requirements"><b><code class="literal">BaseList</code> Requirements. </b><code class="literal">BaseList</code> must model
|
||||
<a class="ulink" href="../../utility/Collection.html" target="_top">Collection</a>.</p><p title="Preconditions"><b>Preconditions. </b><code class="literal">values.size() == NumDims;</code></p><p title="Postconditions"><b>Postconditions. </b><code class="literal">std::equal(values.begin(),values.end(),this->index_bases());
|
||||
</code></p></dd><dt><span class="term">
|
||||
<pre class="programlisting">
|
||||
|
||||
@@ -559,15 +569,15 @@ void reindex(index value);
|
||||
|
||||
</pre>
|
||||
</span></dt><dd><p>This changes the index bases of all dimensions of the
|
||||
<code class="literal">multi_array</code> to <code class="literal">value</code>.</p><p><b>Postconditions. </b>
|
||||
<code class="literal">multi_array</code> to <code class="literal">value</code>.</p><p title="Postconditions"><b>Postconditions. </b>
|
||||
</p><pre class="programlisting">
|
||||
|
||||
std::count_if(this->index_bases(),this->index_bases()+this->num_dimensions(),
|
||||
std::bind_2nd(std::equal_to<index>(),value)) ==
|
||||
this->num_dimensions();
|
||||
|
||||
</pre><p>
|
||||
</p></dd></dl></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="multi_array"></a><code class="literal">multi_array</code></h3></div></div></div><p>
|
||||
</pre><p title="Postconditions">
|
||||
</p></dd></dl></div><div class="sect2" title="multi_array"><div class="titlepage"><div><div><h3 class="title"><a name="multi_array_class"></a><code class="literal">multi_array</code></h3></div></div></div><p>
|
||||
<code class="literal">multi_array</code> is a multi-dimensional container that
|
||||
supports random access iteration. Its number of dimensions is
|
||||
fixed at compile time, but its shape and the number of elements it
|
||||
@@ -576,11 +586,11 @@ will remain fixed for the duration of a
|
||||
<code class="literal">multi_array</code>'s lifetime, but the shape of the container can
|
||||
be changed. A <code class="literal">multi_array</code> manages its data elements
|
||||
using a replaceable allocator.
|
||||
</p><p><b>Model Of. </b>
|
||||
<a href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
|
||||
<a href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>. Depending on the element type,
|
||||
it may also model <a href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
|
||||
</p><p><b>Synopsis. </b></p><pre class="programlisting">
|
||||
</p><p title="Model Of."><b>Model Of. </b>
|
||||
<a class="link" href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
|
||||
<a class="ulink" href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>. Depending on the element type,
|
||||
it may also model <a class="ulink" href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a class="ulink" href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
|
||||
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -606,7 +616,7 @@ public:
|
||||
typedef multi_array_types::extent_gen extent_gen;
|
||||
typedef multi_array_types::extent_range extent_range;
|
||||
typedef *unspecified* storage_order_type;
|
||||
|
||||
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t Dims> struct subarray;
|
||||
@@ -615,6 +625,9 @@ public:
|
||||
template <std::size_t Dims> struct const_array_view;
|
||||
|
||||
|
||||
static const std::size_t dimensionality = NumDims;
|
||||
|
||||
|
||||
// constructors and destructors
|
||||
|
||||
multi_array();
|
||||
@@ -697,7 +710,7 @@ public:
|
||||
multi_array& resize(extents_tuple& extents);
|
||||
};
|
||||
|
||||
</pre><p><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template <typename ExtentList>
|
||||
</pre><p title="Constructors"><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template <typename ExtentList>
|
||||
explicit multi_array(const ExtentList& sizes,
|
||||
const storage_order_type& store = c_storage_order(),
|
||||
const Allocator& alloc = Allocator());
|
||||
@@ -708,9 +721,9 @@ constructed <code class="literal">multi_array</code>. <code class="literal">sto
|
||||
specifies the storage order or layout in memory of the array
|
||||
dimensions. <code class="literal">alloc</code> is used to
|
||||
allocate the contained elements.
|
||||
</p><p><b><code class="literal">ExtentList</code> Requirements. </b>
|
||||
<code class="literal">ExtentList</code> must model <a href="../../utility/Collection.html" target="_top">Collection</a>.
|
||||
</p><p><b>Preconditions. </b><code class="literal">sizes.size() == NumDims;</code></p></dd><dt><span class="term">
|
||||
</p><p title="ExtentList Requirements"><b><code class="literal">ExtentList</code> Requirements. </b>
|
||||
<code class="literal">ExtentList</code> must model <a class="ulink" href="../../utility/Collection.html" target="_top">Collection</a>.
|
||||
</p><p title="Preconditions"><b>Preconditions. </b><code class="literal">sizes.size() == NumDims;</code></p></dd><dt><span class="term">
|
||||
<pre class="programlisting">explicit multi_array(extent_gen::gen_type<NumDims>::type ranges,
|
||||
const storage_order_type& store = c_storage_order(),
|
||||
const Allocator& alloc = Allocator());
|
||||
@@ -734,34 +747,34 @@ multi_array(const subarray<NumDims>::type& x);
|
||||
multi_array(const array_view<NumDims>::type& x);
|
||||
</pre></span></dt><dd><p>These constructors all constructs a <code class="literal">multi_array</code> and
|
||||
perform a deep copy of <code class="literal">x</code>.
|
||||
</p><p><b>Complexity. </b> This performs O(<code class="literal">x.num_elements()</code>) calls to
|
||||
</p><p title="Complexity"><b>Complexity. </b> This performs O(<code class="literal">x.num_elements()</code>) calls to
|
||||
<code class="literal">element</code>'s copy
|
||||
constructor.
|
||||
</p></dd><dt><span class="term"><pre class="programlisting">
|
||||
multi_array();
|
||||
</pre></span></dt><dd><p>This constructs a <code class="literal">multi_array</code> whose shape is (0,...,0) and contains no elements.
|
||||
</p></dd></dl></div><p><b>Note on Constructors. </b>
|
||||
</p></dd></dl></div><p title="Note on Constructors"><b>Note on Constructors. </b>
|
||||
The <code class="literal">multi_array</code> construction expressions,
|
||||
</p><pre class="programlisting">
|
||||
multi_array<int,3> A(boost::extents[5][4][3]);
|
||||
</pre><p>
|
||||
</pre><p title="Note on Constructors">
|
||||
and
|
||||
</p><pre class="programlisting">
|
||||
boost::array<multi_array_base::index,3> my_extents = {{5, 4, 3}};
|
||||
multi_array<int,3> A(my_extents);
|
||||
</pre><p>
|
||||
</pre><p title="Note on Constructors">
|
||||
are equivalent.
|
||||
</p><p><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
</p><p title="Modifiers"><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
multi_array& operator=(const multi_array& x);
|
||||
template <class Array> multi_array& operator=(const Array& x);
|
||||
</pre>
|
||||
</span></dt><dd><p>This performs an element-wise copy of <code class="literal">x</code>
|
||||
into the current <code class="literal">multi_array</code>.</p><p><b><code class="literal">Array</code> Requirements. </b><code class="literal">Array</code> must model MultiArray.
|
||||
</p><p><b>Preconditions. </b>
|
||||
into the current <code class="literal">multi_array</code>.</p><p title="Array Requirements"><b><code class="literal">Array</code> Requirements. </b><code class="literal">Array</code> must model MultiArray.
|
||||
</p><p title="Preconditions"><b>Preconditions. </b>
|
||||
</p><pre class="programlisting">std::equal(this->shape(),this->shape()+this->num_dimensions(),
|
||||
x.shape());</pre><p><b>Postconditions. </b>
|
||||
</p><pre class="programlisting">(*.this) == x;</pre><p>
|
||||
</p><p><b>Complexity. </b>The assignment operators perform
|
||||
x.shape());</pre><p title="Postconditions"><b>Postconditions. </b>
|
||||
</p><pre class="programlisting">(*.this) == x;</pre><p title="Postconditions">
|
||||
</p><p title="Complexity"><b>Complexity. </b>The assignment operators perform
|
||||
O(<code class="literal">x.num_elements()</code>) calls to <code class="literal">element</code>'s
|
||||
copy constructor.</p></dd><dt><span class="term">
|
||||
<pre class="programlisting">
|
||||
@@ -772,8 +785,8 @@ void assign(InputIterator begin, InputIterator end);
|
||||
</span></dt><dd><p>This copies the elements in the range
|
||||
<code class="literal">[begin,end)</code> into the array. It is equivalent to
|
||||
<code class="literal">std::copy(begin,end,this->data())</code>.
|
||||
</p><p><b>Preconditions. </b><code class="literal">std::distance(begin,end) == this->num_elements();</code>
|
||||
</p><p><b>Complexity. </b>
|
||||
</p><p title="Preconditions"><b>Preconditions. </b><code class="literal">std::distance(begin,end) == this->num_elements();</code>
|
||||
</p><p title="Complexity"><b>Complexity. </b>
|
||||
The <code class="literal">assign</code> member function performs
|
||||
O(<code class="literal">this->num_elements()</code>) calls to
|
||||
<code class="literal">ValueType</code>'s copy constructor.
|
||||
@@ -790,31 +803,30 @@ contents of the array are preserved whenever possible; if the new
|
||||
array size is smaller, then some data will be lost. Any new elements
|
||||
created by resizing the array are initialized with the
|
||||
<code class="literal">element</code> default constructor.
|
||||
</p></dd></dl></div><p><b>Queries. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
</p></dd></dl></div><p title="Queries"><b>Queries. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
storage_order_type& storage_order() const;
|
||||
</pre>
|
||||
</span></dt><dd><p>This query returns the storage order object associated with the
|
||||
<code class="literal">multi_array</code> in question. It can be used to construct a new array with the same storage order.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="multi_array_ref"></a><code class="literal">multi_array_ref</code></h3></div></div></div><p>
|
||||
<code class="literal">multi_array</code> in question. It can be used to construct a new array with the same storage order.</p></dd></dl></div></div><div class="sect2" title="multi_array_ref"><div class="titlepage"><div><div><h3 class="title"><a name="multi_array_ref"></a><code class="literal">multi_array_ref</code></h3></div></div></div><p>
|
||||
<code class="literal">multi_array_ref</code> is a multi-dimensional container
|
||||
adaptor. It provides the MultiArray interface over any contiguous
|
||||
block of elements. <code class="literal">multi_array_ref</code> exports the
|
||||
same interface as <code class="literal">multi_array</code>, with the exception
|
||||
of the constructors.
|
||||
</p><p><b>Model Of. </b>
|
||||
</p><p title="Model Of."><b>Model Of. </b>
|
||||
<code class="literal">multi_array_ref</code> models
|
||||
<a href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
|
||||
<a href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
|
||||
<a class="link" href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
|
||||
<a class="ulink" href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
|
||||
and depending on the element type, it may also model
|
||||
<a href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
|
||||
<a class="ulink" href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a class="ulink" href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
|
||||
Detailed descriptions are provided here only for operations that are
|
||||
not described in the <code class="literal">multi_array</code> reference.
|
||||
</p><p><b>Synopsis. </b></p><pre class="programlisting">
|
||||
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims,
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
std::size_t NumDims>
|
||||
class multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
@@ -842,7 +854,10 @@ public:
|
||||
template <std::size_t Dims> struct const_array_view;
|
||||
|
||||
|
||||
// structors
|
||||
static const std::size_t dimensionality = NumDims;
|
||||
|
||||
|
||||
// constructors and destructors
|
||||
|
||||
template <typename ExtentList>
|
||||
explicit multi_array_ref(element* data, const ExtentList& sizes,
|
||||
@@ -909,7 +924,7 @@ public:
|
||||
void reindex(index value);
|
||||
};
|
||||
|
||||
</pre><p><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template <typename ExtentList>
|
||||
</pre><p title="Constructors"><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template <typename ExtentList>
|
||||
explicit multi_array_ref(element* data,
|
||||
const ExtentList& sizes,
|
||||
const storage_order& store = c_storage_order(),
|
||||
@@ -921,9 +936,9 @@ constructed <code class="literal">multi_array_ref</code>. <code class="literal"
|
||||
specifies the storage order or layout in memory of the array
|
||||
dimensions. <code class="literal">alloc</code> is used to
|
||||
allocate the contained elements.
|
||||
</p><p><b><code class="literal">ExtentList</code> Requirements. </b>
|
||||
<code class="literal">ExtentList</code> must model <a href="../../utility/Collection.html" target="_top">Collection</a>.
|
||||
</p><p><b>Preconditions. </b><code class="literal">sizes.size() == NumDims;</code></p></dd><dt><span class="term">
|
||||
</p><p title="ExtentList Requirements"><b><code class="literal">ExtentList</code> Requirements. </b>
|
||||
<code class="literal">ExtentList</code> must model <a class="ulink" href="../../utility/Collection.html" target="_top">Collection</a>.
|
||||
</p><p title="Preconditions"><b>Preconditions. </b><code class="literal">sizes.size() == NumDims;</code></p></dd><dt><span class="term">
|
||||
<pre class="programlisting">explicit multi_array_ref(element* data,
|
||||
extent_gen::gen_type<NumDims>::type ranges,
|
||||
const storage_order& store = c_storage_order());
|
||||
@@ -938,42 +953,42 @@ dimensions.
|
||||
</p></dd><dt><span class="term"><pre class="programlisting">
|
||||
multi_array_ref(const multi_array_ref& x);
|
||||
</pre></span></dt><dd><p>This constructs a shallow copy of <code class="literal">x</code>.
|
||||
</p><p><b>Complexity. </b> Constant time (for contrast, compare this to
|
||||
</p><p title="Complexity"><b>Complexity. </b> Constant time (for contrast, compare this to
|
||||
the <code class="literal">multi_array</code> class copy constructor.
|
||||
</p></dd></dl></div><p><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
</p></dd></dl></div><p title="Modifiers"><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
|
||||
multi_array_ref& operator=(const multi_array_ref& x);
|
||||
template <class Array> multi_array_ref& operator=(const Array& x);
|
||||
</pre>
|
||||
</span></dt><dd><p>This performs an element-wise copy of <code class="literal">x</code>
|
||||
into the current <code class="literal">multi_array_ref</code>.</p><p><b><code class="literal">Array</code> Requirements. </b><code class="literal">Array</code> must model MultiArray.
|
||||
</p><p><b>Preconditions. </b>
|
||||
into the current <code class="literal">multi_array_ref</code>.</p><p title="Array Requirements"><b><code class="literal">Array</code> Requirements. </b><code class="literal">Array</code> must model MultiArray.
|
||||
</p><p title="Preconditions"><b>Preconditions. </b>
|
||||
</p><pre class="programlisting">std::equal(this->shape(),this->shape()+this->num_dimensions(),
|
||||
x.shape());</pre><p><b>Postconditions. </b>
|
||||
</p><pre class="programlisting">(*.this) == x;</pre><p>
|
||||
</p><p><b>Complexity. </b>The assignment operators perform
|
||||
x.shape());</pre><p title="Postconditions"><b>Postconditions. </b>
|
||||
</p><pre class="programlisting">(*.this) == x;</pre><p title="Postconditions">
|
||||
</p><p title="Complexity"><b>Complexity. </b>The assignment operators perform
|
||||
O(<code class="literal">x.num_elements()</code>) calls to <code class="literal">element</code>'s
|
||||
copy constructor.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="const_multi_array_ref"></a><code class="literal">const_multi_array_ref</code></h3></div></div></div><p>
|
||||
copy constructor.</p></dd></dl></div></div><div class="sect2" title="const_multi_array_ref"><div class="titlepage"><div><div><h3 class="title"><a name="const_multi_array_ref"></a><code class="literal">const_multi_array_ref</code></h3></div></div></div><p>
|
||||
<code class="literal">const_multi_array_ref</code> is a multi-dimensional container
|
||||
adaptor. It provides the MultiArray interface over any contiguous
|
||||
block of elements. <code class="literal">const_multi_array_ref</code> exports the
|
||||
same interface as <code class="literal">multi_array</code>, with the exception
|
||||
of the constructors.
|
||||
</p><p><b>Model Of. </b>
|
||||
</p><p title="Model Of."><b>Model Of. </b>
|
||||
<code class="literal">const_multi_array_ref</code> models
|
||||
<a href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
|
||||
<a href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
|
||||
<a class="link" href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
|
||||
<a class="ulink" href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
|
||||
and depending on the element type, it may also model
|
||||
<a href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
|
||||
<a class="ulink" href="http://www.sgi.com/tech/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a class="ulink" href="http://www.sgi.com/tech/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
|
||||
|
||||
Detailed descriptions are provided here only for operations that are
|
||||
not described in the <code class="literal">multi_array</code> reference.
|
||||
</p><p><b>Synopsis. </b></p><pre class="programlisting">
|
||||
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
|
||||
|
||||
namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims,
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
typename TPtr = const T*>
|
||||
class const_multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
@@ -1004,9 +1019,9 @@ public:
|
||||
// structors
|
||||
|
||||
template <typename ExtentList>
|
||||
explicit const_multi_array_ref(const element* data, const ExtentList& sizes,
|
||||
explicit const_multi_array_ref(TPtr data, const ExtentList& sizes,
|
||||
const storage_order_type& store = c_storage_order());
|
||||
explicit const_multi_array_ref(const element* data, const extents_tuple& ranges,
|
||||
explicit const_multi_array_ref(TPtr data, const extents_tuple& ranges,
|
||||
const storage_order_type& store = c_storage_order());
|
||||
const_multi_array_ref(const const_multi_array_ref& x);
|
||||
~const_multi_array_ref();
|
||||
@@ -1053,8 +1068,8 @@ public:
|
||||
void reindex(index value);
|
||||
};
|
||||
|
||||
</pre><p><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template <typename ExtentList>
|
||||
explicit const_multi_array_ref(const element* data,
|
||||
</pre><p title="Constructors"><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template <typename ExtentList>
|
||||
explicit const_multi_array_ref(TPtr data,
|
||||
const ExtentList& sizes,
|
||||
const storage_order& store = c_storage_order());
|
||||
</pre></span></dt><dd><p>
|
||||
@@ -1063,13 +1078,13 @@ parameters. <code class="literal">sizes</code> specifies the shape of the
|
||||
constructed <code class="literal">const_multi_array_ref</code>. <code class="literal">store</code>
|
||||
specifies the storage order or layout in memory of the array
|
||||
dimensions.
|
||||
</p><p><b><code class="literal">ExtentList</code> Requirements. </b>
|
||||
<code class="literal">ExtentList</code> must model <a href="../../utility/Collection.html" target="_top">Collection</a>.
|
||||
</p><p><b>Preconditions. </b><code class="literal">sizes.size() == NumDims;</code></p></dd><dt><span class="term">
|
||||
<pre class="programlisting">explicit const_multi_array_ref(const element* data,
|
||||
</p><p title="ExtentList Requirements"><b><code class="literal">ExtentList</code> Requirements. </b>
|
||||
<code class="literal">ExtentList</code> must model <a class="ulink" href="../../utility/Collection.html" target="_top">Collection</a>.
|
||||
</p><p title="Preconditions"><b>Preconditions. </b><code class="literal">sizes.size() == NumDims;</code></p></dd><dt><span class="term">
|
||||
<pre class="programlisting">explicit const_multi_array_ref(TPtr data,
|
||||
extent_gen::gen_type<NumDims>::type ranges,
|
||||
const storage_order& store = c_storage_order());
|
||||
</pre></span></dt><dd><p><b>Effects. </b>
|
||||
</pre></span></dt><dd><p title="Effects"><b>Effects. </b>
|
||||
This constructs a <code class="literal">const_multi_array_ref</code> using the specified
|
||||
parameters. <code class="literal">ranges</code> specifies the shape and
|
||||
index bases of the constructed const_multi_array_ref. It is the result of
|
||||
@@ -1079,8 +1094,8 @@ specifies the storage order or layout in memory of the array
|
||||
dimensions.
|
||||
</p></dd><dt><span class="term"><pre class="programlisting">
|
||||
const_multi_array_ref(const const_multi_array_ref& x);
|
||||
</pre></span></dt><dd><p><b>Effects. </b>This constructs a shallow copy of <code class="literal">x</code>.
|
||||
</p></dd></dl></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="auxiliary"></a>Auxiliary Components</h2></div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="multi_array_types"></a><code class="literal">multi_array_types</code></h3></div></div></div><pre class="programlisting">
|
||||
</pre></span></dt><dd><p title="Effects"><b>Effects. </b>This constructs a shallow copy of <code class="literal">x</code>.
|
||||
</p></dd></dl></div></div></div><div class="sect1" title="Auxiliary Components"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="auxiliary"></a>Auxiliary Components</h2></div></div></div><div class="sect2" title="multi_array_types"><div class="titlepage"><div><div><h3 class="title"><a name="multi_array_types"></a><code class="literal">multi_array_types</code></h3></div></div></div><pre class="programlisting">
|
||||
namespace multi_array_types {
|
||||
typedef *unspecified* index;
|
||||
typedef *unspecified* size_type;
|
||||
@@ -1102,14 +1117,14 @@ With the exception of <code class="literal">extent_gen</code> and
|
||||
same name required by MultiArray and are described in its
|
||||
concept definition. <code class="literal">extent_gen</code> and
|
||||
<code class="literal">extent_range</code> are described below.
|
||||
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="extent_range"></a><code class="classname">extent_range</code></h3></div></div></div><p><code class="classname">extent_range</code> objects define half open
|
||||
</p></div><div class="sect2" title="extent_range"><div class="titlepage"><div><div><h3 class="title"><a name="extent_range"></a><code class="classname">extent_range</code></h3></div></div></div><p><code class="classname">extent_range</code> objects define half open
|
||||
intervals. They provide shape and index base information to
|
||||
<code class="literal">multi_array</code>, <code class="literal">multi_array_ref</code>,
|
||||
and <code class="literal">const_multi_array_ref</code> constructors.
|
||||
<code class="classname">extent_range</code>s are passed in
|
||||
aggregate to an array constructor (see
|
||||
<code class="classname">extent_gen</code> for more details).
|
||||
</p><p><b>Synopsis. </b></p><pre class="programlisting">
|
||||
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
|
||||
class extent_range {
|
||||
public:
|
||||
typedef multi_array_types::index index;
|
||||
@@ -1124,14 +1139,14 @@ public:
|
||||
index start();
|
||||
index finish();
|
||||
size_type size();
|
||||
};</pre><p><b>Model Of. </b>DefaultConstructible,CopyConstructible</p><p><b>Methods and Types. </b></p><div class="variablelist"><dl><dt><span class="term"><code class="function">extent_range(index start, index finish)</code></span></dt><dd><p> This constructor defines the half open interval
|
||||
};</pre><p title="Model Of"><b>Model Of. </b>DefaultConstructible,CopyConstructible</p><p title="Methods and Types"><b>Methods and Types. </b></p><div class="variablelist"><dl><dt><span class="term"><code class="function">extent_range(index start, index finish)</code></span></dt><dd><p> This constructor defines the half open interval
|
||||
<code class="literal">[start,finish)</code>. The expression
|
||||
<code class="literal">finish</code> must be greater than <code class="literal">start</code>.
|
||||
</p></dd><dt><span class="term"><code class="function">extent_range(index finish)</code></span></dt><dd><p>This constructor defines the half open interval
|
||||
<code class="literal">[0,finish)</code>. The value of <code class="literal">finish</code>
|
||||
must be positive.</p></dd><dt><span class="term"><code class="function">index start()</code></span></dt><dd><p>This function returns the first index represented by the range</p></dd><dt><span class="term"><code class="function">index finish()</code></span></dt><dd><p>This function returns the upper boundary value of the half-open
|
||||
interval. Note that the range does not include this value.</p></dd><dt><span class="term"><code class="function">size_type size()</code></span></dt><dd><p>This function returns the size of the specified range. It is
|
||||
equivalent to <code class="literal">finish()-start()</code>.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="extent_gen"></a><code class="classname">extent_gen</code></h3></div></div></div><p>The <code class="classname">extent_gen</code> class defines an
|
||||
equivalent to <code class="literal">finish()-start()</code>.</p></dd></dl></div></div><div class="sect2" title="extent_gen"><div class="titlepage"><div><div><h3 class="title"><a name="extent_gen"></a><code class="classname">extent_gen</code></h3></div></div></div><p>The <code class="classname">extent_gen</code> class defines an
|
||||
interface for aggregating array shape and indexing information to be
|
||||
passed to a <code class="literal">multi_array</code>,
|
||||
<code class="literal">multi_array_ref</code>, or <code class="literal">const_multi_array_ref</code>
|
||||
@@ -1143,7 +1158,7 @@ declared as:
|
||||
</p><pre class="programlisting">int A[3][4][5],</pre><p>
|
||||
a similar <code class="classname">multi_array</code> would be declared:
|
||||
</p><pre class="programlisting">multi_array<int,3> A(extents[3][4][5]).</pre><p>
|
||||
</p><p><b>Synopsis. </b></p><pre class="programlisting">
|
||||
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
|
||||
template <std::size_t NumRanges>
|
||||
class *implementation_defined* {
|
||||
public:
|
||||
@@ -1157,7 +1172,7 @@ public:
|
||||
};
|
||||
|
||||
typedef *implementation_defined*<0> extent_gen;
|
||||
</pre><p><b>Methods and Types. </b></p><div class="variablelist"><dl><dt><span class="term"><code class="function">template gen_type::<Ranges>::type</code></span></dt><dd><p>This type generator is used to specify the result of
|
||||
</pre><p title="Methods and Types"><b>Methods and Types. </b></p><div class="variablelist"><dl><dt><span class="term"><code class="function">template gen_type<Ranges>::type</code></span></dt><dd><p>This type generator is used to specify the result of
|
||||
<code class="literal">Ranges</code> chained calls to
|
||||
<code class="literal">extent_gen::operator[].</code> The types
|
||||
<code class="classname">extent_gen</code> and
|
||||
@@ -1171,7 +1186,7 @@ operator[](index idx) const;</code></span></dt><dd><p>This function returns a ne
|
||||
<code class="classname">extent_range</code> objects in addition to
|
||||
<code class="literal">extent_range(0,idx).</code> This function gives the array
|
||||
constructors a similar syntax to traditional C multidimensional array
|
||||
declaration.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id862083"></a>Global Objects</h3></div></div></div><p>For syntactic convenience, Boost.MultiArray defines two
|
||||
declaration.</p></dd></dl></div></div><div class="sect2" title="Global Objects"><div class="titlepage"><div><div><h3 class="title"><a name="idp19487120"></a>Global Objects</h3></div></div></div><p>For syntactic convenience, Boost.MultiArray defines two
|
||||
global objects as part of its
|
||||
interface. These objects play the role of object generators;
|
||||
expressions involving them create other objects of interest.
|
||||
@@ -1179,7 +1194,7 @@ expressions involving them create other objects of interest.
|
||||
considered excessive overhead. Their construction can be prevented by
|
||||
defining the preprocessor symbol
|
||||
<code class="literal">BOOST_MULTI_ARRAY_NO_GENERATORS</code> before including
|
||||
<code class="filename">boost/multi_array.hpp.</code></p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="extents"></a><code class="literal">extents</code></h4></div></div></div><pre class="programlisting">
|
||||
<code class="filename">boost/multi_array.hpp.</code></p><div class="sect3" title="extents"><div class="titlepage"><div><div><h4 class="title"><a name="extents"></a><code class="literal">extents</code></h4></div></div></div><pre class="programlisting">
|
||||
namespace boost {
|
||||
multi_array_base::extent_gen extents;
|
||||
}
|
||||
@@ -1191,7 +1206,7 @@ a 3 by 3 by 3 <code class="classname">multi_array</code> is constructed as follo
|
||||
</p><pre class="programlisting">multi_array<int,3> A(extents[3][3][3]);</pre><p>
|
||||
The same array could also be created by explicitly declaring an <code class="literal">extent_gen</code>
|
||||
object locally,, but the global object makes this declaration unnecessary.
|
||||
</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="indices"></a><code class="literal">indices</code></h4></div></div></div><pre class="programlisting">
|
||||
</p></div><div class="sect3" title="indices"><div class="titlepage"><div><div><h4 class="title"><a name="indices"></a><code class="literal">indices</code></h4></div></div></div><pre class="programlisting">
|
||||
namespace boost {
|
||||
multi_array_base::index_gen indices;
|
||||
}
|
||||
@@ -1206,7 +1221,7 @@ a view of an array <code class="literal">A</code> is constructed as follows:
|
||||
</p><pre class="programlisting">
|
||||
A[indices[index_range(0,5)][2][index_range(2,4)]];
|
||||
</pre><p>
|
||||
</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="generators"></a>View and SubArray Generators</h3></div></div></div><p>
|
||||
</p></div></div><div class="sect2" title="View and SubArray Generators"><div class="titlepage"><div><div><h3 class="title"><a name="generators"></a>View and SubArray Generators</h3></div></div></div><p>
|
||||
Boost.MultiArray provides traits classes, <code class="literal">subarray_gen</code>,
|
||||
<code class="literal">const_subarray_gen</code>,
|
||||
<code class="literal">array_view_gen</code>,
|
||||
@@ -1232,7 +1247,7 @@ void my_function() {
|
||||
|
||||
In the above example, <code class="literal">view1_t</code> and
|
||||
<code class="literal">view2_t</code> have the same type.
|
||||
</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="memory_layout"></a>Memory Layout Specifiers</h3></div></div></div><p>
|
||||
</p></div><div class="sect2" title="Memory Layout Specifiers"><div class="titlepage"><div><div><h3 class="title"><a name="memory_layout"></a>Memory Layout Specifiers</h3></div></div></div><p>
|
||||
While a multidimensional array represents a hierarchy of containers of
|
||||
elements, at some point the elements must be laid out in
|
||||
memory. As a result, a single multidimensional array
|
||||
@@ -1320,7 +1335,7 @@ that must interoperate with Fortran routines so they can be
|
||||
manipulated naturally at both the C++ and Fortran levels. The
|
||||
following sections describe the Boost.MultiArray components used to
|
||||
specify memory layout.
|
||||
</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="c_storage_order"></a><code class="literal">c_storage_order</code></h4></div></div></div><pre class="programlisting">
|
||||
</p><div class="sect3" title="c_storage_order"><div class="titlepage"><div><div><h4 class="title"><a name="c_storage_order"></a><code class="literal">c_storage_order</code></h4></div></div></div><pre class="programlisting">
|
||||
class c_storage_order {
|
||||
c_storage_order();
|
||||
};
|
||||
@@ -1328,14 +1343,14 @@ class c_storage_order {
|
||||
array should store its elements using the same layout as that used by
|
||||
primitive C++ multidimensional arrays, that is, from last dimension
|
||||
to first. This is the default storage order for the arrays provided by
|
||||
this library.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="fortran_storage_order"></a><code class="literal">fortran_storage_order</code></h4></div></div></div><pre class="programlisting">
|
||||
this library.</p></div><div class="sect3" title="fortran_storage_order"><div class="titlepage"><div><div><h4 class="title"><a name="fortran_storage_order"></a><code class="literal">fortran_storage_order</code></h4></div></div></div><pre class="programlisting">
|
||||
class fortran_storage_order {
|
||||
fortran_storage_order();
|
||||
};
|
||||
</pre><p><code class="literal">fortran_storage_order</code> is used to specify that
|
||||
an array should store its elements using the same memory layout as a
|
||||
Fortran multidimensional array would, that is, from first dimension to
|
||||
last.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="general_storage_order"></a><code class="literal">general_storage_order</code></h4></div></div></div><pre class="programlisting">
|
||||
last.</p></div><div class="sect3" title="general_storage_order"><div class="titlepage"><div><div><h4 class="title"><a name="general_storage_order"></a><code class="literal">general_storage_order</code></h4></div></div></div><pre class="programlisting">
|
||||
template <std::size_t NumDims>
|
||||
class general_storage_order {
|
||||
|
||||
@@ -1355,7 +1370,7 @@ convertible to <code class="literal">bool</code>. A value of
|
||||
order while <code class="literal">false</code> means that a dimension is stored
|
||||
in descending order. <code class="literal">OrderingIter</code> specifies the
|
||||
order in which dimensions are stored.
|
||||
</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="range_checking"></a>Range Checking</h3></div></div></div><p>
|
||||
</p></div></div><div class="sect2" title="Range Checking"><div class="titlepage"><div><div><h3 class="title"><a name="range_checking"></a>Range Checking</h3></div></div></div><p>
|
||||
By default, the array access methods <code class="literal">operator()</code> and
|
||||
<code class="literal">operator[]</code> perform range
|
||||
checking. If a supplied index is out of the range defined for an
|
||||
|
||||
@@ -20,7 +20,7 @@ Boost.MultiArray: Test Descriptions
|
||||
</title>
|
||||
</head>
|
||||
<body bgcolor="#ffffff" text="#000000">
|
||||
<IMG SRC="http://www.boost.org/boost.png"
|
||||
<IMG SRC="../../../boost.png"
|
||||
ALT="C++ Boost" width="277" height="86">
|
||||
<h1>Boost.MultiArray: Test Descriptions</h1>
|
||||
|
||||
@@ -114,6 +114,13 @@ Test re-indexing functionality for the B.M primary components.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="../test/storage_order_convert.cpp">libs/multi_array/test/storage_order_convert.cpp</a></td>
|
||||
<td>
|
||||
Test out conversions among the storage orders data types.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="../test/storage_order.cpp">libs/multi_array/test/storage_order.cpp</a></td>
|
||||
<td>
|
||||
@@ -164,6 +171,14 @@ Ensure that all the array types meet the defined Concepts.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="../test/assert.cpp">libs/multi_array/test/assert.cpp</a></td>
|
||||
<td>
|
||||
Ensure that uses of BOOST_ASSERT within the library can be customized
|
||||
by library users.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><a href="../test/generative_tests.hpp">libs/multi_array/test/generative_tests.hpp</a></td>
|
||||
<td>
|
||||
@@ -285,10 +300,10 @@ summary="This table describes the tests in the multi array test suite
|
||||
<table summary="Copyright information">
|
||||
<tr valign="top">
|
||||
<td nowrap>Copyright © 2001</td>
|
||||
<td><a href="../../../people/ronald_garcia.htm">Ronald Garcia</a>,
|
||||
<td><a href="http://www.boost.org/people/ronald_garcia.htm">Ronald Garcia</a>,
|
||||
Indiana University (<a href=
|
||||
"mailto:garcia@cs.indiana.edu">garcia@cs.indiana.edu</a>)<br>
|
||||
<a href="../../../people/jeremy_siek.htm">Jeremy Siek</a>, Indiana
|
||||
<a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>, Indiana
|
||||
University (<a href=
|
||||
"mailto:jsiek@cs.indiana.edu">jsiek@cs.indiana.edu</a>)<br>
|
||||
<a href="http://www.lsc.nd.edu/~lums">Andrew Lumsdaine</a>, Indiana
|
||||
|
||||
@@ -255,7 +255,9 @@ useful for writing dimension-independent code.
|
||||
</blockquote>
|
||||
|
||||
<p>The second method involves passing the constructor an <tt>extent_gen</tt>
|
||||
object, specifying the matrix dimensions. By default, the library constructs a
|
||||
object, specifying the matrix dimensions. The <tt>extent_gen</tt> type
|
||||
is defined in the <tt>multi_array_types</tt> namespace and as a
|
||||
member of every array type, but by default, the library constructs a
|
||||
global <tt>extent_gen</tt> object <tt>boost::extents</tt>. In case of
|
||||
concern about memory used by these objects, defining
|
||||
<tt>BOOST_MULTI_ARRAY_NO_GENERATORS</tt> before including the library
|
||||
@@ -316,13 +318,17 @@ already existing array component. It allows you to create a sub-view that
|
||||
retains the same number of dimensions as the original array or one
|
||||
that has less dimensions than the original as well.
|
||||
|
||||
<p>Sub-view creation occurs by placing a call to operator[], passing it
|
||||
an <tt>index_gen</tt> type. The <tt>index_gen</tt> is populated by
|
||||
passing <tt>index_range</tt> objects to its <tt>operator[]</tt>.
|
||||
Similar to <tt>boost::extents</tt>, the library by default constructs
|
||||
the object <tt>boost::indices</tt>. You can suppress this object
|
||||
by defining <tt>BOOST_MULTI_ARRAY_NO_GENERATORS</tt> before
|
||||
including the library header. A simple sub-view creation example follows.
|
||||
<p>Sub-view creation occurs by placing a call to operator[], passing
|
||||
it an <tt>index_gen</tt> type. The <tt>index_gen</tt> is populated by
|
||||
passing <tt>index_range</tt> objects to its <tt>operator[]</tt>.
|
||||
The <tt>index_range</tt> and <tt>index_gen</tt> types are defined in
|
||||
the <tt>multi_array_types</tt> namespace and as nested members of
|
||||
every array type. Similar to <tt>boost::extents</tt>, the library by
|
||||
default constructs the object <tt>boost::indices</tt>. You can
|
||||
suppress this object by
|
||||
defining <tt>BOOST_MULTI_ARRAY_NO_GENERATORS</tt> before including the
|
||||
library header. A simple sub-view creation example follows.
|
||||
|
||||
<h3>Example</h3>
|
||||
<blockquote>
|
||||
<pre>
|
||||
@@ -335,7 +341,8 @@ including the library header. A simple sub-view creation example follows.
|
||||
// dim 2: [0,4) (strided by 2),
|
||||
//
|
||||
|
||||
typedef array_type::index_range range;
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
// OR typedef array_type::index_range range;
|
||||
array_type::array_view<3>::type myview =
|
||||
myarray[ boost::indices[range(0,2)][range(1,3)][range(0,4,2)] ];
|
||||
|
||||
@@ -361,7 +368,7 @@ called slicing).
|
||||
// [0,1,2), 1, [0,2,4)
|
||||
//
|
||||
|
||||
typedef array_type::index_range range;
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
array_type::index_gen indices;
|
||||
array_type::array_view<2>::type myview =
|
||||
myarray[ indices[range(0,2)][1][range(0,4,2)] ];
|
||||
@@ -382,7 +389,7 @@ that specify the same range.
|
||||
// [base,stride,bound)
|
||||
// [0,2,4)
|
||||
|
||||
typedef array_type::index_range range;
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
range a_range;
|
||||
a_range = range(0,4,2);
|
||||
a_range = range().start(0).finish(4).stride(2);
|
||||
@@ -402,7 +409,7 @@ dimension it is used to specify.
|
||||
<h3>Example</h3>
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef array_type::index_range range;
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
range a_range;
|
||||
|
||||
// All elements in this dimension
|
||||
@@ -452,7 +459,7 @@ indices will remain zero-based.
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array<double,3> array_type;
|
||||
array_type A(boost::extents[3][4][2],boost::fortran_storage_order);
|
||||
array_type A(boost::extents[3][4][2],boost::fortran_storage_order());
|
||||
call_fortran_function(A.data());
|
||||
</pre>
|
||||
</blockquote>
|
||||
@@ -482,13 +489,16 @@ stored in ascending or descending order.
|
||||
In some situations, it may be inconvenient or awkward to use an
|
||||
array that is zero-based.
|
||||
the Boost.MultiArray components provide two facilities for changing the
|
||||
bases of an array. One may specify a pair of range values to
|
||||
the extent_gen constructor in order to set the base value.
|
||||
bases of an array. One may specify a pair of range values, with
|
||||
the <tt>extent_range</tt> type, to
|
||||
the <tt>extent_gen</tt> constructor in order to set the base value.
|
||||
|
||||
<h3>Example</h3>
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array<double, 3> array_type;
|
||||
typedef array_type::extent_range range;
|
||||
typedef boost::multi_array_types::extent_range range;
|
||||
// OR typedef array_type::extent_range range;
|
||||
|
||||
array_type::extent_gen extents;
|
||||
|
||||
@@ -507,7 +517,6 @@ reset the bases. To set all bases to the same value, use the
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array<double, 3> array_type;
|
||||
typedef array_type::extent_range range;
|
||||
|
||||
array_type::extent_gen extents;
|
||||
|
||||
@@ -524,7 +533,6 @@ An alternative is to set each base separately using the
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array<double, 3> array_type;
|
||||
typedef array_type::extent_range range;
|
||||
|
||||
array_type::extent_gen extents;
|
||||
|
||||
@@ -548,7 +556,6 @@ elements contained remains the same.
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array<double, 3> array_type;
|
||||
typedef array_type::extent_range range;
|
||||
|
||||
array_type::extent_gen extents;
|
||||
array_type A(extents[2][3][4]);
|
||||
@@ -577,7 +584,6 @@ no longer be available.
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array<int, 3> array_type;
|
||||
typedef array_type::extent_range range;
|
||||
|
||||
array_type::extent_gen extents;
|
||||
array_type A(extents[3][3][3]);
|
||||
@@ -632,7 +638,7 @@ arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
|
||||
<li><a href="mailto:garcia@osl.iu.edu">Ronald Garcia</a>
|
||||
is the primary author of the library.
|
||||
|
||||
<li><a href="../../../people/jeremy_siek.htm">Jeremy Siek</a>
|
||||
<li><a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>
|
||||
helped with the library and provided a sounding board for ideas,
|
||||
advice, and assistance porting to Microsoft Visual C++.
|
||||
|
||||
|
||||
@@ -110,6 +110,14 @@ are stored contiguously) or by column (i.e., the elements of each
|
||||
column are stored contiguously).
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Two concept checking classes for the MultiArray concepts
|
||||
(<literal>ConstMultiArrayConcept</literal> and
|
||||
<literal>MutableMultiArrayConcept</literal>) are in the namespace
|
||||
<literal>boost::multi_array_concepts</literal> in
|
||||
<literal><boost/multi_array/concept_checks.hpp></literal>.
|
||||
</para>
|
||||
|
||||
|
||||
<sect2><title>Notation</title>
|
||||
<para>What follows are the descriptions of symbols that will be used
|
||||
@@ -240,15 +248,17 @@ iterators. It is the same type as
|
||||
<entry>
|
||||
This is an iterator over the values of <literal>A</literal>.
|
||||
If <literal>NumDims == 1</literal>, then it models
|
||||
<ulink url="http://www.sgi.com/tech/stl/RandomAccessIterator.html">
|
||||
<ulink url="http://www.boost.org/doc/html/RandomAccessIterator.html">
|
||||
<literal>Random Access Iterator</literal></ulink>.
|
||||
Otherwise it models
|
||||
<ulink url="./iterator_categories.html#concept_RandomAccessTraversalIterator">
|
||||
Random Access Traversal Iterator</ulink>,
|
||||
<ulink url="./iterator_categories.html#concept_ReadableIterator">
|
||||
Readable Iterator</ulink>, and
|
||||
Readable Iterator</ulink>,
|
||||
<ulink url="./iterator_categories.html#concept_WritableIterator">
|
||||
Writable Iterator</ulink>.
|
||||
Writable Iterator</ulink>, and
|
||||
<ulink url="http://www.boost.org/doc/html/OutputIterator.html">
|
||||
<literal>Output Iterator</literal></ulink>.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
@@ -385,6 +395,13 @@ This is the const view type with <literal>Dims</literal> dimensions.
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><literal>A::dimensionality</literal></entry>
|
||||
<entry><literal>size_type</literal></entry>
|
||||
<entry>This compile-time constant represents the number of
|
||||
dimensions of the array (note that
|
||||
<literal>A::dimensionality == NumDims</literal>).</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>a.shape()</literal></entry>
|
||||
<entry><literal>const size_type*</literal></entry>
|
||||
@@ -960,7 +977,7 @@ object. This object can then be used to generate tuples of
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>x[idx]</literal></entry>
|
||||
<entry><literal>gen_type<Dims,Ranges>::type</literal>
|
||||
<entry><literal>gen_type<Dims,Ranges+1>::type</literal>
|
||||
</entry>
|
||||
<entry>Returns a new object containing all previous
|
||||
<classname>index_range</classname> objects in addition to a degenerate
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims,
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
typename TPtr = const T*>
|
||||
class const_multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
@@ -64,9 +64,9 @@ public:
|
||||
// structors
|
||||
|
||||
template <typename ExtentList>
|
||||
explicit const_multi_array_ref(const element* data, const ExtentList& sizes,
|
||||
explicit const_multi_array_ref(TPtr data, const ExtentList& sizes,
|
||||
const storage_order_type& store = c_storage_order());
|
||||
explicit const_multi_array_ref(const element* data, const extents_tuple& ranges,
|
||||
explicit const_multi_array_ref(TPtr data, const extents_tuple& ranges,
|
||||
const storage_order_type& store = c_storage_order());
|
||||
const_multi_array_ref(const const_multi_array_ref& x);
|
||||
~const_multi_array_ref();
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><programlisting>template <typename ExtentList>
|
||||
explicit const_multi_array_ref(const element* data,
|
||||
explicit const_multi_array_ref(TPtr data,
|
||||
const ExtentList& sizes,
|
||||
const storage_order& store = c_storage_order());
|
||||
</programlisting></term>
|
||||
@@ -151,7 +151,7 @@ dimensions.
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<programlisting><![CDATA[explicit const_multi_array_ref(const element* data,
|
||||
<programlisting><![CDATA[explicit const_multi_array_ref(TPtr data,
|
||||
extent_gen::gen_type<NumDims>::type ranges,
|
||||
const storage_order& store = c_storage_order());]]>
|
||||
</programlisting></term>
|
||||
|
||||
@@ -31,27 +31,26 @@ not described in the <literal>multi_array</literal> reference.
|
||||
namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims,
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
std::size_t NumDims>
|
||||
class multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
typedef ValueType element;
|
||||
typedef *implementation-defined* value_type;
|
||||
typedef *implementation-defined* reference;
|
||||
typedef *implementation-defined* const_reference;
|
||||
typedef *implementation-defined* difference_type;
|
||||
typedef *implementation-defined* iterator;
|
||||
typedef *implementation-defined* const_iterator;
|
||||
typedef *implementation-defined* reverse_iterator;
|
||||
typedef *implementation-defined* const_reverse_iterator;
|
||||
typedef *unspecified* value_type;
|
||||
typedef *unspecified* reference;
|
||||
typedef *unspecified* const_reference;
|
||||
typedef *unspecified* difference_type;
|
||||
typedef *unspecified* iterator;
|
||||
typedef *unspecified* const_iterator;
|
||||
typedef *unspecified* reverse_iterator;
|
||||
typedef *unspecified* const_reverse_iterator;
|
||||
typedef multi_array_types::size_type size_type;
|
||||
typedef multi_array_types::index index;
|
||||
typedef multi_array_types::index_gen index_gen;
|
||||
typedef multi_array_types::index_range index_range;
|
||||
typedef multi_array_types::extent_gen extent_gen;
|
||||
typedef multi_array_types::extent_range extent_range;
|
||||
typedef *implementation-defined* storage_order_type;
|
||||
typedef *unspecified* storage_order_type;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t Dims> struct subarray;
|
||||
|
||||
@@ -488,7 +488,7 @@ typedef *implementation_defined*<0> extent_gen;
|
||||
<formalpara><title>Methods and Types</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><function>template gen_type::<Ranges>::type</function></term>
|
||||
<term><function>template gen_type<Ranges>::type</function></term>
|
||||
<listitem>
|
||||
<para>This type generator is used to specify the result of
|
||||
<literal>Ranges</literal> chained calls to
|
||||
|
||||
@@ -45,7 +45,7 @@ void for_each (const boost::type<Element>& type_dispatch,
|
||||
template <typename Array, typename Functor>
|
||||
void for_each (Array& A, Functor xform) {
|
||||
// Dispatch to the proper function
|
||||
for_each(boost::type<Array::element>(),A.begin(),A.end(),xform);
|
||||
for_each(boost::type<typename Array::element>(),A.begin(),A.end(),xform);
|
||||
}
|
||||
|
||||
|
||||
|
||||
57
example/resize_from_other.cpp
Normal file
57
example/resize_from_other.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright 2008 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
//
|
||||
// resize_from_other.cpp - an experiment in writing a resize function for
|
||||
// multi_arrays that will use the extents from another to build itself.
|
||||
//
|
||||
|
||||
#include <boost/multi_array.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
template <typename T, typename U, std::size_t N>
|
||||
void
|
||||
resize_from_MultiArray(boost::multi_array<T,N>& marray, U& other) {
|
||||
|
||||
// U must be a model of MultiArray
|
||||
boost::function_requires<
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<U,U::dimensionality> >();
|
||||
// U better have U::dimensionality == N
|
||||
BOOST_STATIC_ASSERT(U::dimensionality == N);
|
||||
|
||||
boost::array<typename boost::multi_array<T,N>::size_type, N> shape;
|
||||
|
||||
std::copy(other.shape(), other.shape()+N, shape.begin());
|
||||
|
||||
marray.resize(shape);
|
||||
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
int main () {
|
||||
|
||||
boost::multi_array<int,2> A(boost::extents[5][4]), B;
|
||||
boost::multi_array<int,3> C;
|
||||
|
||||
resize_from_MultiArray(B,A);
|
||||
|
||||
#if 0
|
||||
resize_from_MultiArray(C,A); // Compile-time error
|
||||
#endif
|
||||
|
||||
std::cout << B.shape()[0] << ", " << B.shape()[1] << '\n';
|
||||
|
||||
}
|
||||
@@ -429,12 +429,12 @@ public:
|
||||
|
||||
std::transform(new_array.index_base_list_.begin(),
|
||||
new_array.index_base_list_.end(),
|
||||
min_extents.begin(),old_idxes.ranges_.begin(),
|
||||
min_extents.begin(),new_idxes.ranges_.begin(),
|
||||
detail::multi_array::populate_index_ranges());
|
||||
|
||||
std::transform(this->index_base_list_.begin(),
|
||||
this->index_base_list_.end(),
|
||||
min_extents.begin(),new_idxes.ranges_.begin(),
|
||||
min_extents.begin(),old_idxes.ranges_.begin(),
|
||||
detail::multi_array::populate_index_ranges());
|
||||
|
||||
// Build same-shape views of the two arrays
|
||||
|
||||
@@ -81,7 +81,8 @@ class sub_array;
|
||||
template <typename T, std::size_t NumDims, typename TPtr = const T*>
|
||||
class const_sub_array;
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference>
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference,
|
||||
typename IteratorCategory>
|
||||
class array_iterator;
|
||||
|
||||
template <typename T, std::size_t NumDims, typename TPtr = const T*>
|
||||
@@ -251,7 +252,19 @@ struct associated_types
|
||||
// choose value accessor ends
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Due to some imprecision in the C++ Standard,
|
||||
// MSVC 2010 is broken in debug mode: it requires
|
||||
// that an Output Iterator have output_iterator_tag in its iterator_category if
|
||||
// that iterator is not bidirectional_iterator or random_access_iterator.
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
|
||||
struct mutable_iterator_tag
|
||||
: boost::random_access_traversal_tag, std::input_iterator_tag
|
||||
{
|
||||
operator std::output_iterator_tag() const {
|
||||
return std::output_iterator_tag();
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// multi_array_base
|
||||
@@ -301,8 +314,16 @@ public:
|
||||
//
|
||||
// iterator support
|
||||
//
|
||||
typedef array_iterator<T,T*,mpl::size_t<NumDims>,reference> iterator;
|
||||
typedef array_iterator<T,T const*,mpl::size_t<NumDims>,const_reference> const_iterator;
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600)
|
||||
// Deal with VC 2010 output_iterator_tag requirement
|
||||
typedef array_iterator<T,T*,mpl::size_t<NumDims>,reference,
|
||||
mutable_iterator_tag> iterator;
|
||||
#else
|
||||
typedef array_iterator<T,T*,mpl::size_t<NumDims>,reference,
|
||||
boost::random_access_traversal_tag> iterator;
|
||||
#endif
|
||||
typedef array_iterator<T,T const*,mpl::size_t<NumDims>,const_reference,
|
||||
boost::random_access_traversal_tag> const_iterator;
|
||||
|
||||
typedef ::boost::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef ::boost::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
@@ -321,7 +342,8 @@ protected:
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_bases) const {
|
||||
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
ignore_unused_variable_warning(index_bases);
|
||||
ignore_unused_variable_warning(extents);
|
||||
#if !defined(NDEBUG) && !defined(BOOST_DISABLE_ASSERTS)
|
||||
@@ -332,9 +354,15 @@ protected:
|
||||
#endif
|
||||
|
||||
index offset = 0;
|
||||
for (size_type n = 0; n != NumDims; ++n)
|
||||
offset += indices[n] * strides[n];
|
||||
|
||||
{
|
||||
typename IndexList::const_iterator i = indices.begin();
|
||||
size_type n = 0;
|
||||
while (n != NumDims) {
|
||||
offset += (*i) * strides[n];
|
||||
++n;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return base[offset];
|
||||
}
|
||||
|
||||
@@ -431,19 +459,52 @@ protected:
|
||||
index offset = 0;
|
||||
size_type dim = 0;
|
||||
for (size_type n = 0; n != NumDims; ++n) {
|
||||
|
||||
// Use array specs and input specs to produce real specs.
|
||||
const index default_start = index_bases[n];
|
||||
const index default_finish = default_start+extents[n];
|
||||
const index_range& current_range = indices.ranges_[n];
|
||||
index start = current_range.get_start(default_start);
|
||||
index finish = current_range.get_finish(default_finish);
|
||||
index index_factor = current_range.stride();
|
||||
index len = (finish - start + (index_factor - 1)) / index_factor;
|
||||
index stride = current_range.stride();
|
||||
BOOST_ASSERT(stride != 0);
|
||||
|
||||
// An index range indicates a half-open strided interval
|
||||
// [start,finish) (with stride) which faces upward when stride
|
||||
// is positive and downward when stride is negative,
|
||||
|
||||
// RG: The following code for calculating length suffers from
|
||||
// some representation issues: if finish-start cannot be represented as
|
||||
// by type index, then overflow may result.
|
||||
|
||||
index len;
|
||||
if ((finish - start) / stride < 0) {
|
||||
// [start,finish) is empty according to the direction imposed by
|
||||
// the stride.
|
||||
len = 0;
|
||||
} else {
|
||||
// integral trick for ceiling((finish-start) / stride)
|
||||
// taking into account signs.
|
||||
index shrinkage = stride > 0 ? 1 : -1;
|
||||
len = (finish - start + (stride - shrinkage)) / stride;
|
||||
}
|
||||
|
||||
// start marks the closed side of the range, so it must lie
|
||||
// exactly in the set of legal indices
|
||||
// with a special case for empty arrays
|
||||
BOOST_ASSERT(index_bases[n] <= start &&
|
||||
start <= index_bases[n]+index(extents[n]));
|
||||
BOOST_ASSERT(index_bases[n] <= finish &&
|
||||
finish <= index_bases[n]+index(extents[n]));
|
||||
BOOST_ASSERT(index_factor > 0);
|
||||
((start <= index_bases[n]+index(extents[n])) ||
|
||||
(start == index_bases[n] && extents[n] == 0)));
|
||||
|
||||
#ifndef BOOST_DISABLE_ASSERTS
|
||||
// finish marks the open side of the range, so it can go one past
|
||||
// the "far side" of the range (the top if stride is positive, the bottom
|
||||
// if stride is negative).
|
||||
index bound_adjustment = stride < 0 ? 1 : 0;
|
||||
BOOST_ASSERT(((index_bases[n] - bound_adjustment) <= finish) &&
|
||||
(finish <= (index_bases[n] + index(extents[n]) - bound_adjustment)));
|
||||
#endif // BOOST_DISABLE_ASSERTS
|
||||
|
||||
|
||||
// the array data pointer is modified to account for non-zero
|
||||
// bases during slicing (see [Garcia] for the math involved)
|
||||
@@ -451,9 +512,9 @@ protected:
|
||||
|
||||
if (!current_range.is_degenerate()) {
|
||||
|
||||
// The index_factor for each dimension is included into the
|
||||
// The stride for each dimension is included into the
|
||||
// strides for the array_view (see [Garcia] for the math involved).
|
||||
new_strides[dim] = index_factor * strides[n];
|
||||
new_strides[dim] = stride * strides[n];
|
||||
|
||||
// calculate new extents
|
||||
new_extents[dim] = len;
|
||||
|
||||
@@ -17,46 +17,10 @@
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
//===========================================================================
|
||||
// Collection Concept
|
||||
|
||||
template <class Collection>
|
||||
struct CollectionConcept
|
||||
{
|
||||
typedef typename Collection::value_type value_type;
|
||||
typedef typename Collection::iterator iterator;
|
||||
typedef typename Collection::const_iterator const_iterator;
|
||||
typedef typename Collection::reference reference;
|
||||
typedef typename Collection::const_reference const_reference;
|
||||
// typedef typename Collection::pointer pointer;
|
||||
typedef typename Collection::difference_type difference_type;
|
||||
typedef typename Collection::size_type size_type;
|
||||
|
||||
void constraints() {
|
||||
boost::function_requires<boost::InputIteratorConcept<iterator> >();
|
||||
boost::function_requires<boost::InputIteratorConcept<const_iterator> >();
|
||||
boost::function_requires<boost::CopyConstructibleConcept<value_type> >();
|
||||
const_constraints(c);
|
||||
i = c.begin();
|
||||
i = c.end();
|
||||
c.swap(c);
|
||||
}
|
||||
void const_constraints(const Collection& c) {
|
||||
ci = c.begin();
|
||||
ci = c.end();
|
||||
n = c.size();
|
||||
b = c.empty();
|
||||
}
|
||||
Collection c;
|
||||
bool b;
|
||||
iterator i;
|
||||
const_iterator ci;
|
||||
size_type n;
|
||||
};
|
||||
|
||||
namespace multi_array { // Old location for this
|
||||
using boost::CollectionConcept;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif // COLLECTION_CONCEPT_RG103101_HPP
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#include "boost/iterator/iterator_concepts.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
namespace multi_array_concepts {
|
||||
|
||||
namespace detail {
|
||||
//
|
||||
// idgen_helper -
|
||||
// This is a helper for generating index_gen instantiations with
|
||||
@@ -56,6 +56,8 @@ namespace multi_array {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
template <typename Array, std::size_t NumDims >
|
||||
struct ConstMultiArrayConcept
|
||||
@@ -70,13 +72,14 @@ namespace multi_array {
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
a[ id ];
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = Array::dimensionality;
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
@@ -128,15 +131,16 @@ namespace multi_array {
|
||||
function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
||||
function_requires< boost::OutputIterator<iterator,value_type> >();
|
||||
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
@@ -157,10 +161,10 @@ namespace multi_array {
|
||||
// value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
@@ -207,7 +211,14 @@ namespace multi_array {
|
||||
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
|
||||
namespace detail {
|
||||
namespace multi_array { // Old locations for these
|
||||
using boost::multi_array_concepts::ConstMultiArrayConcept;
|
||||
using boost::multi_array_concepts::MutableMultiArrayConcept;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
// shape
|
||||
//
|
||||
#include "boost/type.hpp"
|
||||
#include <cassert>
|
||||
#include "boost/assert.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
@@ -52,8 +52,8 @@ private:
|
||||
|
||||
template <typename Array1, typename Array2>
|
||||
void copy_array (Array1& source, Array2& dest) {
|
||||
assert(std::equal(source.shape(),source.shape()+source.num_dimensions(),
|
||||
dest.shape()));
|
||||
BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
|
||||
dest.shape()));
|
||||
// Dispatch to the proper function
|
||||
typedef typename Array1::element element_type;
|
||||
copy_dispatch<element_type>::
|
||||
|
||||
@@ -44,16 +44,18 @@ struct operator_arrow_proxy
|
||||
mutable T value_;
|
||||
};
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference>
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference,
|
||||
typename IteratorCategory>
|
||||
class array_iterator;
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference>
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference,
|
||||
typename IteratorCategory>
|
||||
class array_iterator
|
||||
: public
|
||||
iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference>
|
||||
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
|
||||
, typename associated_types<T,NumDims>::value_type
|
||||
, boost::random_access_traversal_tag
|
||||
, IteratorCategory
|
||||
, Reference
|
||||
>
|
||||
, private
|
||||
@@ -69,7 +71,7 @@ class array_iterator
|
||||
typedef detail::multi_array::associated_types<T,NumDims> access_t;
|
||||
|
||||
typedef iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference>
|
||||
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
|
||||
, typename detail::multi_array::associated_types<T,NumDims>::value_type
|
||||
, boost::random_access_traversal_tag
|
||||
, Reference
|
||||
@@ -79,7 +81,7 @@ class array_iterator
|
||||
typedef typename access_t::size_type size_type;
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
template <typename, typename, typename, typename>
|
||||
template <typename, typename, typename, typename, typename>
|
||||
friend class array_iterator;
|
||||
#else
|
||||
public:
|
||||
@@ -105,9 +107,9 @@ public:
|
||||
idx_(idx), base_(base), extents_(extents),
|
||||
strides_(strides), index_base_(index_base) { }
|
||||
|
||||
template <typename OPtr, typename ORef>
|
||||
template <typename OPtr, typename ORef, typename Cat>
|
||||
array_iterator(
|
||||
const array_iterator<T,OPtr,NumDims,ORef>& rhs
|
||||
const array_iterator<T,OPtr,NumDims,ORef,Cat>& rhs
|
||||
, typename boost::enable_if_convertible<OPtr,TPtr>::type* = 0
|
||||
)
|
||||
: idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
#include "boost/multi_array/view.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/utility/enable_if.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/concept_check.hpp"
|
||||
#include "boost/functional.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
explicit const_multi_array_ref(TPtr base, const ExtentList& extents) :
|
||||
base_(base), storage_(c_storage_order()) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
CollectionConcept<ExtentList> >();
|
||||
|
||||
index_base_list_.assign(0);
|
||||
init_multi_array_ref(extents.begin());
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
const general_storage_order<NumDims>& so) :
|
||||
base_(base), storage_(so) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
CollectionConcept<ExtentList> >();
|
||||
|
||||
index_base_list_.assign(0);
|
||||
init_multi_array_ref(extents.begin());
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
#endif // BOOST_NO_SFINAE
|
||||
reindex(const BaseList& values) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<BaseList> >();
|
||||
CollectionConcept<BaseList> >();
|
||||
boost::detail::multi_array::
|
||||
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
origin_offset_ =
|
||||
@@ -164,10 +164,10 @@ public:
|
||||
template <typename SizeList>
|
||||
void reshape(const SizeList& extents) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<SizeList> >();
|
||||
assert(num_elements_ ==
|
||||
std::accumulate(extents.begin(),extents.end(),
|
||||
size_type(1),std::multiplies<size_type>()));
|
||||
CollectionConcept<SizeList> >();
|
||||
BOOST_ASSERT(num_elements_ ==
|
||||
std::accumulate(extents.begin(),extents.end(),
|
||||
size_type(1),std::multiplies<size_type>()));
|
||||
|
||||
std::copy(extents.begin(),extents.end(),extent_list_.begin());
|
||||
this->compute_strides(stride_list_,extent_list_,storage_);
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
template <typename IndexList>
|
||||
const element& operator()(IndexList indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
@@ -449,7 +449,7 @@ public:
|
||||
explicit multi_array_ref(T* base, const ExtentList& extents) :
|
||||
super_type(base,extents) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
CollectionConcept<ExtentList> >();
|
||||
}
|
||||
|
||||
template <class ExtentList>
|
||||
@@ -457,7 +457,7 @@ public:
|
||||
const general_storage_order<NumDims>& so) :
|
||||
super_type(base,extents,so) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<ExtentList> >();
|
||||
CollectionConcept<ExtentList> >();
|
||||
}
|
||||
|
||||
|
||||
@@ -479,13 +479,13 @@ public:
|
||||
template <typename ConstMultiArray>
|
||||
multi_array_ref& operator=(const ConstMultiArray& other) {
|
||||
function_requires<
|
||||
detail::multi_array::
|
||||
multi_array_concepts::
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),this->begin());
|
||||
return *this;
|
||||
@@ -495,9 +495,10 @@ public:
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),this->begin());
|
||||
}
|
||||
@@ -511,7 +512,7 @@ public:
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
@@ -578,7 +579,7 @@ public:
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
template <typename IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
@@ -231,13 +231,13 @@ public:
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
sub_array& operator=(const ConstMultiArray& other) {
|
||||
function_requires< boost::detail::multi_array::ConstMultiArrayConcept<
|
||||
function_requires< boost::multi_array_concepts::ConstMultiArrayConcept<
|
||||
ConstMultiArray, NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
@@ -247,9 +247,10 @@ public:
|
||||
sub_array& operator=(const sub_array& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
@@ -287,7 +288,7 @@ public:
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
@@ -322,7 +323,7 @@ public:
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "boost/multi_array/subarray.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/utility/enable_if.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include <algorithm>
|
||||
@@ -81,7 +82,7 @@ public:
|
||||
#endif
|
||||
reindex(const BaseList& values) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<BaseList> >();
|
||||
CollectionConcept<BaseList> >();
|
||||
boost::detail::multi_array::
|
||||
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
origin_offset_ =
|
||||
@@ -119,7 +120,7 @@ public:
|
||||
template <typename IndexList>
|
||||
const element& operator()(IndexList indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
@@ -244,10 +245,7 @@ public: // should be protected
|
||||
|
||||
// Calculate the array size
|
||||
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
#if 0
|
||||
assert(num_elements_ != 0);
|
||||
#endif
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
}
|
||||
|
||||
typedef boost::array<size_type,NumDims> size_list;
|
||||
@@ -300,13 +298,13 @@ public:
|
||||
template <typename ConstMultiArray>
|
||||
multi_array_view& operator=(const ConstMultiArray& other) {
|
||||
function_requires<
|
||||
boost::detail::multi_array::
|
||||
boost::multi_array_concepts::
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
@@ -316,9 +314,10 @@ public:
|
||||
multi_array_view& operator=(const multi_array_view& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
@@ -330,7 +329,7 @@ public:
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
@@ -394,7 +393,7 @@ public:
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<IndexList> >();
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,15 @@ test-suite multi_array
|
||||
[ run assign.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run assign_to_array.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run index_bases.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run storage_order_convert.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run storage_order.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run reshape.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run range1.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run idxgen1.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run stl_interaction.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run resize.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run assert.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
[ run reverse_view.cpp ../../test/build//boost_test_exec_monitor ]
|
||||
|
||||
[ compile concept_checks.cpp ]
|
||||
;
|
||||
|
||||
59
test/assert.cpp
Normal file
59
test/assert.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright 2007 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
//
|
||||
// Using the BOOST.ASSERT mechanism to replace library assertions
|
||||
// with exceptions
|
||||
//
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
#include "boost/multi_array.hpp" // includes assert.hpp
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace boost {
|
||||
|
||||
void assertion_failed(char const* expr, char const* function,
|
||||
char const* file, long line) {
|
||||
throw std::runtime_error(expr);
|
||||
}
|
||||
|
||||
void assertion_failed_msg(char const * expr, char const * msg,
|
||||
char const * function,
|
||||
char const * file, long line) {
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
using namespace boost;
|
||||
|
||||
int
|
||||
test_main(int,char*[]) {
|
||||
|
||||
typedef multi_array<int,2> array_t;
|
||||
|
||||
array_t A(extents[2][2]);
|
||||
|
||||
array_t B(extents[3][3]);
|
||||
|
||||
try {
|
||||
A = B;
|
||||
BOOST_ERROR("did not throw an exception");
|
||||
} catch (std::runtime_error&) {
|
||||
//...all good
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
//
|
||||
//
|
||||
// assign.cpp - Test out operator=() on the different types
|
||||
//
|
||||
//
|
||||
//
|
||||
#include "generative_tests.hpp"
|
||||
#include "boost/array.hpp"
|
||||
@@ -32,7 +32,7 @@ bool equal(const ArrayA& A, const ArrayB& B)
|
||||
typename ArrayA::const_iterator ia;
|
||||
typename ArrayB::const_iterator ib = B.begin();
|
||||
for (ia = A.begin(); ia != A.end(); ++ia, ++ib)
|
||||
if (!equal(*ia, *ib))
|
||||
if (!::equal(*ia, *ib))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void access(Array& A, const mutable_array_tag&) {
|
||||
|
||||
A = filler;
|
||||
|
||||
BOOST_CHECK(equal(A,filler));
|
||||
BOOST_CHECK(::equal(A,filler));
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
//
|
||||
//
|
||||
// assign_to_array.cpp - multi_array should be constructible from any other
|
||||
// array type in the library.
|
||||
//
|
||||
//
|
||||
//
|
||||
#include "generative_tests.hpp"
|
||||
#include "boost/array.hpp"
|
||||
@@ -33,7 +33,7 @@ bool equal(const ArrayA& A, const ArrayB& B)
|
||||
typename ArrayA::const_iterator ia;
|
||||
typename ArrayB::const_iterator ib = B.begin();
|
||||
for (ia = A.begin(); ia != A.end(); ++ia, ++ib)
|
||||
if (!equal(*ia, *ib))
|
||||
if (!::equal(*ia, *ib))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ template <typename Array>
|
||||
void access(Array& A, const const_array_tag&) {
|
||||
typedef boost::multi_array<int,3> array3;
|
||||
array3 acopy(A);
|
||||
BOOST_CHECK(equal(acopy,A));
|
||||
BOOST_CHECK(::equal(acopy,A));
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "boost/multi_array.hpp"
|
||||
|
||||
#include "boost/cstdlib.hpp"
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include "boost/test/test_tools.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
|
||||
#include "boost/array.hpp"
|
||||
|
||||
@@ -38,28 +38,28 @@ test_main(int,char*[])
|
||||
typedef array::const_subarray<ndims>::type const_subarray;
|
||||
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::ConstMultiArrayConcept<array,ndims> >();
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<array,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::ConstMultiArrayConcept<array_ref,ndims> >();
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<array_ref,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::ConstMultiArrayConcept<const_array_ref,ndims> >();
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<const_array_ref,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::ConstMultiArrayConcept<array_view,ndims> >();
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<array_view,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::ConstMultiArrayConcept<const_array_view,ndims> >();
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<const_array_view,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::ConstMultiArrayConcept<subarray,ndims> >();
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<subarray,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::ConstMultiArrayConcept<const_subarray,ndims> >();
|
||||
boost::multi_array_concepts::ConstMultiArrayConcept<const_subarray,ndims> >();
|
||||
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::MutableMultiArrayConcept<array,ndims> >();
|
||||
boost::multi_array_concepts::MutableMultiArrayConcept<array,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::MutableMultiArrayConcept<array_ref,ndims> >();
|
||||
boost::multi_array_concepts::MutableMultiArrayConcept<array_ref,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::MutableMultiArrayConcept<array_view,ndims> >();
|
||||
boost::multi_array_concepts::MutableMultiArrayConcept<array_view,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::MutableMultiArrayConcept<subarray,ndims> >();
|
||||
boost::multi_array_concepts::MutableMultiArrayConcept<subarray,ndims> >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -25,8 +25,8 @@ void check_shape(const double&, std::size_t*, int*, unsigned int)
|
||||
{}
|
||||
|
||||
template <class Array>
|
||||
void check_shape(const Array& A,
|
||||
std::size_t* sizes,
|
||||
void check_shape(const Array& A,
|
||||
std::size_t* sizes,
|
||||
int* strides,
|
||||
unsigned int num_elements)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ bool equal(const ArrayA& A, const ArrayB& B)
|
||||
typename ArrayA::const_iterator ia;
|
||||
typename ArrayB::const_iterator ib = B.begin();
|
||||
for (ia = A.begin(); ia != A.end(); ++ia, ++ib)
|
||||
if (!equal(*ia, *ib))
|
||||
if (!::equal(*ia, *ib))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ test_main(int, char*[])
|
||||
double* ptr = 0;
|
||||
boost::multi_array_ref<double,3> B(ptr,sizes);
|
||||
check_shape(B, &sizes[0], strides, num_elements);
|
||||
|
||||
|
||||
const double* cptr = ptr;
|
||||
boost::const_multi_array_ref<double,3> C(cptr,sizes);
|
||||
check_shape(C, &sizes[0], strides, num_elements);
|
||||
@@ -132,7 +132,7 @@ test_main(int, char*[])
|
||||
A.assign(vals.begin(),vals.end());
|
||||
boost::multi_array<double, 3> B(A);
|
||||
check_shape(B, &sizes[0], strides, num_elements);
|
||||
BOOST_CHECK(equal(A, B));
|
||||
BOOST_CHECK(::equal(A, B));
|
||||
|
||||
double ptr[27];
|
||||
boost::multi_array_ref<double, 3> C(ptr,sizes);
|
||||
@@ -182,7 +182,7 @@ test_main(int, char*[])
|
||||
A.assign(vals.begin(),vals.end());
|
||||
B = A;
|
||||
check_shape(B, &sizes[0], strides, num_elements);
|
||||
BOOST_CHECK(equal(A, B));
|
||||
BOOST_CHECK(::equal(A, B));
|
||||
|
||||
double ptr1[27];
|
||||
double ptr2[27];
|
||||
@@ -190,12 +190,12 @@ test_main(int, char*[])
|
||||
C.assign(vals.begin(),vals.end());
|
||||
D = C;
|
||||
check_shape(D, &sizes[0], strides, num_elements);
|
||||
BOOST_CHECK(equal(C,D));
|
||||
BOOST_CHECK(::equal(C,D));
|
||||
}
|
||||
|
||||
|
||||
// subarray value_type is multi_array
|
||||
{
|
||||
{
|
||||
typedef boost::multi_array<double,3> array;
|
||||
typedef array::size_type size_type;
|
||||
size_type num_elements = 27;
|
||||
@@ -209,8 +209,8 @@ test_main(int, char*[])
|
||||
subarray::value_type C = B[0];
|
||||
|
||||
// should comparisons between the types work?
|
||||
BOOST_CHECK(equal(A[1][0],C));
|
||||
BOOST_CHECK(equal(B[0],C));
|
||||
BOOST_CHECK(::equal(A[1][0],C));
|
||||
BOOST_CHECK(::equal(B[0],C));
|
||||
}
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/type.hpp"
|
||||
#include "boost/cstdlib.hpp"
|
||||
|
||||
int
|
||||
test_main(int,char*[])
|
||||
|
||||
@@ -114,6 +114,14 @@ int test_main(int,char*[]) {
|
||||
}
|
||||
}
|
||||
|
||||
// Resizing that changes index bases too (impl bug caused an assert)
|
||||
{
|
||||
typedef boost::multi_array<int, 1> ar_t;
|
||||
typedef ar_t::extent_range range;
|
||||
ar_t ar;
|
||||
ar.resize(boost::extents[range(-3, 3)]);
|
||||
}
|
||||
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
43
test/reverse_view.cpp
Normal file
43
test/reverse_view.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2002 The Trustees of Indiana University.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Boost.MultiArray Library
|
||||
// Authors: Ronald Garcia
|
||||
// Jeremy Siek
|
||||
// Andrew Lumsdaine
|
||||
// See http://www.boost.org/libs/multi_array for documentation.
|
||||
|
||||
//
|
||||
// reverse_view.cpp - a small test of creating a view with negative strides
|
||||
//
|
||||
|
||||
#include "boost/multi_array.hpp"
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/array.hpp"
|
||||
|
||||
int
|
||||
test_main(int,char*[])
|
||||
{
|
||||
using namespace boost;
|
||||
|
||||
|
||||
// One-dimensional array with views
|
||||
double data[] = { 1, 2, 3, 4 };
|
||||
double rdata[] = { 4, 3, 2, 1 };
|
||||
|
||||
typedef multi_array< double, 1 > array;
|
||||
array A(extents[4]);
|
||||
A.assign(data,data+4);
|
||||
|
||||
typedef array::index_range range;
|
||||
array::array_view<1>::type B = A[indices[range(3, -1, -1)]];
|
||||
|
||||
for(multi_array_types::size_type i = 0; i != B.size(); ++i) {
|
||||
BOOST_CHECK(B[i] == rdata[i]);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
@@ -90,6 +90,28 @@ void test_views(Array& A, const ViewTraits&) {
|
||||
BOOST_CHECK(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]);
|
||||
}
|
||||
}
|
||||
|
||||
// Flip the third dimension
|
||||
{
|
||||
typename ViewTraits::array_view3 B = A[
|
||||
indices[range(idx0+0,idx0+2)]
|
||||
[range(idx1+0,idx1+2)]
|
||||
[range(idx2+2,idx2+0,-1)]
|
||||
];
|
||||
|
||||
// typename ViewTraits::array_view3 B =
|
||||
// A[indices[range(idx0+0,idx0+2)][idx1+1][range(idx2+0,idx2+4,2)]];
|
||||
|
||||
for (index i = 0; i != 2; ++i)
|
||||
for (index j = 0; j != 2; ++j)
|
||||
for (index k = 0; k != 2; ++k) {
|
||||
BOOST_CHECK(B[i][j][k] == A[idx0+i][idx1+j][idx2+2-k]);
|
||||
boost::array<index,3> elmts;
|
||||
elmts[0]=i; elmts[1]=j; elmts[2]=k;
|
||||
BOOST_CHECK(B(elmts) == A[idx0+i][idx1+j][idx2+2-k]);
|
||||
}
|
||||
}
|
||||
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ test_main(int,char*[]) {
|
||||
general_storage_order<5> fortran_storage(fortran_ordering.begin(),
|
||||
ascending.begin());
|
||||
|
||||
BOOST_TEST(c_storage == (general_storage_order<5>) c_storage_order());
|
||||
BOOST_TEST(fortran_storage ==
|
||||
BOOST_CHECK(c_storage == (general_storage_order<5>) c_storage_order());
|
||||
BOOST_CHECK(fortran_storage ==
|
||||
(general_storage_order<5>) fortran_storage_order());
|
||||
|
||||
return boost::report_errors();
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user