mirror of
https://github.com/boostorg/multi_array.git
synced 2026-01-25 06:22:10 +00:00
Compare commits
1 Commits
boost-1.36
...
boost-1.34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
288a5bfb78 |
@@ -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="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="../../../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="../../../more/index.htm"><font face="Arial" color="#ffffff"><big>More</big></font></a></td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
@@ -48,7 +48,7 @@ definition and common implementations of that interface.
|
||||
<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="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>,
|
||||
<a href="../../../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>,
|
||||
|
||||
@@ -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.71.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="id823342"></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="#id896773">Notation</a></span></dt><dt><span class="sect2"><a href="#id896941">Associated Types</a></span></dt><dt><span class="sect2"><a href="#id897451">Valid expressions</a></span></dt><dt><span class="sect2"><a href="#id898268">Complexity guarantees</a></span></dt><dt><span class="sect2"><a href="#id898293">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="#id899663">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="#id906792">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.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.
|
||||
The MultiArray concept defines a generic interface to multidimensional
|
||||
containers.
|
||||
<code class="literal">multi_array</code> is a general purpose container class
|
||||
@@ -150,8 +150,8 @@ 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="id896773"></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="id896782"></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
|
||||
</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
|
||||
</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>.
|
||||
@@ -159,8 +159,8 @@ to describe the MultiArray interface.</p><div class="table"><a name="id896782"><
|
||||
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>
|
||||
</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><br class="table-break"></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id896941"></a>Associated Types</h3></div></div></div><p>
|
||||
</p><div class="table"><a name="id896949"></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.
|
||||
<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.
|
||||
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.
|
||||
@@ -260,9 +260,7 @@ 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><br class="table-break"></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id897451"></a>Valid expressions</h3></div></div></div><div class="table"><a name="id897455"></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>
|
||||
</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>
|
||||
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>
|
||||
@@ -360,11 +358,11 @@ type must model <a href="http://www.sgi.com/tech/stl/EqualityComparable.html" ta
|
||||
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><br class="table-break"></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id898268"></a>Complexity guarantees</h3></div></div></div><code class="literal">begin()</code> and <code class="literal">end()</code> execute in amortized
|
||||
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
|
||||
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="id898293"></a>Invariants</h3></div></div></div><div class="table"><a name="id898298"></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.
|
||||
</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.
|
||||
</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>
|
||||
@@ -376,7 +374,7 @@ Calling <code class="literal">a[a1][a2]...[aN]</code> where <code class="literal
|
||||
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><br class="table-break"></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
|
||||
</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
|
||||
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
|
||||
@@ -403,10 +401,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="id898526"></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="id898580"></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
|
||||
</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
|
||||
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><br class="table-break"><div class="table"><a name="id898642"></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>
|
||||
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>
|
||||
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>
|
||||
@@ -438,14 +436,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><br class="table-break"></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><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</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="id899309"></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
|
||||
</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
|
||||
<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><br class="table-break"><div class="table"><a name="id899395"></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
|
||||
<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
|
||||
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>
|
||||
@@ -456,7 +454,7 @@ 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><br class="table-break"><div class="table"><a name="id899506"></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>
|
||||
<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>
|
||||
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
|
||||
@@ -470,7 +468,7 @@ 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><br class="table-break"></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id899663"></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></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>
|
||||
Boost.MultiArray defines an array class,
|
||||
<code class="literal">multi_array</code>, and two adapter classes,
|
||||
<code class="literal">multi_array_ref</code> and
|
||||
@@ -815,7 +813,8 @@ not described in the <code class="literal">multi_array</code> reference.
|
||||
namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims>
|
||||
std::size_t NumDims,
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
class multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
@@ -974,7 +973,7 @@ namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims,
|
||||
typename TPtr = const T*>
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
class const_multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
@@ -1005,9 +1004,9 @@ public:
|
||||
// structors
|
||||
|
||||
template <typename ExtentList>
|
||||
explicit const_multi_array_ref(TPtr data, const ExtentList& sizes,
|
||||
explicit const_multi_array_ref(const element* data, const ExtentList& sizes,
|
||||
const storage_order_type& store = c_storage_order());
|
||||
explicit const_multi_array_ref(TPtr data, const extents_tuple& ranges,
|
||||
explicit const_multi_array_ref(const element* 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();
|
||||
@@ -1055,7 +1054,7 @@ public:
|
||||
};
|
||||
|
||||
</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(TPtr data,
|
||||
explicit const_multi_array_ref(const element* data,
|
||||
const ExtentList& sizes,
|
||||
const storage_order& store = c_storage_order());
|
||||
</pre></span></dt><dd><p>
|
||||
@@ -1067,7 +1066,7 @@ 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(TPtr data,
|
||||
<pre class="programlisting">explicit const_multi_array_ref(const element* data,
|
||||
extent_gen::gen_type<NumDims>::type ranges,
|
||||
const storage_order& store = c_storage_order());
|
||||
</pre></span></dt><dd><p><b>Effects. </b>
|
||||
@@ -1172,7 +1171,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="id906792"></a>Global Objects</h3></div></div></div><p>For syntactic convenience, Boost.MultiArray defines two
|
||||
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
|
||||
global objects as part of its
|
||||
interface. These objects play the role of object generators;
|
||||
expressions involving them create other objects of interest.
|
||||
|
||||
@@ -114,13 +114,6 @@ 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>
|
||||
@@ -171,14 +164,6 @@ 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>
|
||||
@@ -300,10 +285,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="http://www.boost.org/people/ronald_garcia.htm">Ronald Garcia</a>,
|
||||
<td><a href="../../../people/ronald_garcia.htm">Ronald Garcia</a>,
|
||||
Indiana University (<a href=
|
||||
"mailto:garcia@cs.indiana.edu">garcia@cs.indiana.edu</a>)<br>
|
||||
<a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>, Indiana
|
||||
<a href="../../../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,9 +255,7 @@ 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. 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
|
||||
object, specifying the matrix dimensions. 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
|
||||
@@ -318,17 +316,13 @@ 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>.
|
||||
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.
|
||||
|
||||
<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.
|
||||
<h3>Example</h3>
|
||||
<blockquote>
|
||||
<pre>
|
||||
@@ -341,8 +335,7 @@ library header. A simple sub-view creation example follows.
|
||||
// dim 2: [0,4) (strided by 2),
|
||||
//
|
||||
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
// OR typedef array_type::index_range range;
|
||||
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)] ];
|
||||
|
||||
@@ -368,7 +361,7 @@ called slicing).
|
||||
// [0,1,2), 1, [0,2,4)
|
||||
//
|
||||
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
typedef array_type::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)] ];
|
||||
@@ -389,7 +382,7 @@ that specify the same range.
|
||||
// [base,stride,bound)
|
||||
// [0,2,4)
|
||||
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
typedef array_type::index_range range;
|
||||
range a_range;
|
||||
a_range = range(0,4,2);
|
||||
a_range = range().start(0).finish(4).stride(2);
|
||||
@@ -409,7 +402,7 @@ dimension it is used to specify.
|
||||
<h3>Example</h3>
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array_types::index_range range;
|
||||
typedef array_type::index_range range;
|
||||
range a_range;
|
||||
|
||||
// All elements in this dimension
|
||||
@@ -489,16 +482,13 @@ 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, with
|
||||
the <tt>extent_range</tt> type, to
|
||||
the <tt>extent_gen</tt> constructor in order to set the base value.
|
||||
|
||||
bases of an array. One may specify a pair of range values to
|
||||
the extent_gen constructor in order to set the base value.
|
||||
<h3>Example</h3>
|
||||
<blockquote>
|
||||
<pre>
|
||||
typedef boost::multi_array<double, 3> array_type;
|
||||
typedef boost::multi_array_types::extent_range range;
|
||||
// OR typedef array_type::extent_range range;
|
||||
typedef array_type::extent_range range;
|
||||
|
||||
array_type::extent_gen extents;
|
||||
|
||||
@@ -517,6 +507,7 @@ 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;
|
||||
|
||||
@@ -533,6 +524,7 @@ 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;
|
||||
|
||||
@@ -556,6 +548,7 @@ 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]);
|
||||
@@ -584,6 +577,7 @@ 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]);
|
||||
@@ -638,7 +632,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="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</a>
|
||||
<li><a href="../../../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++.
|
||||
|
||||
|
||||
@@ -385,13 +385,6 @@ 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>
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims,
|
||||
typename TPtr = const T*>
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
class const_multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
@@ -64,9 +64,9 @@ public:
|
||||
// structors
|
||||
|
||||
template <typename ExtentList>
|
||||
explicit const_multi_array_ref(TPtr data, const ExtentList& sizes,
|
||||
explicit const_multi_array_ref(const element* data, const ExtentList& sizes,
|
||||
const storage_order_type& store = c_storage_order());
|
||||
explicit const_multi_array_ref(TPtr data, const extents_tuple& ranges,
|
||||
explicit const_multi_array_ref(const element* 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(TPtr data,
|
||||
explicit const_multi_array_ref(const element* 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(TPtr data,
|
||||
<programlisting><![CDATA[explicit const_multi_array_ref(const element* data,
|
||||
extent_gen::gen_type<NumDims>::type ranges,
|
||||
const storage_order& store = c_storage_order());]]>
|
||||
</programlisting></term>
|
||||
|
||||
@@ -31,26 +31,27 @@ not described in the <literal>multi_array</literal> reference.
|
||||
namespace boost {
|
||||
|
||||
template <typename ValueType,
|
||||
std::size_t NumDims>
|
||||
std::size_t NumDims,
|
||||
typename Allocator = std::allocator<ValueType> >
|
||||
class multi_array_ref {
|
||||
public:
|
||||
// types:
|
||||
typedef ValueType element;
|
||||
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 *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 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 *unspecified* storage_order_type;
|
||||
typedef *implementation-defined* storage_order_type;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t Dims> struct subarray;
|
||||
|
||||
@@ -429,12 +429,12 @@ public:
|
||||
|
||||
std::transform(new_array.index_base_list_.begin(),
|
||||
new_array.index_base_list_.end(),
|
||||
min_extents.begin(),new_idxes.ranges_.begin(),
|
||||
min_extents.begin(),old_idxes.ranges_.begin(),
|
||||
detail::multi_array::populate_index_ranges());
|
||||
|
||||
std::transform(this->index_base_list_.begin(),
|
||||
this->index_base_list_.end(),
|
||||
min_extents.begin(),old_idxes.ranges_.begin(),
|
||||
min_extents.begin(),new_idxes.ranges_.begin(),
|
||||
detail::multi_array::populate_index_ranges());
|
||||
|
||||
// Build same-shape views of the two arrays
|
||||
|
||||
@@ -437,16 +437,13 @@ protected:
|
||||
index start = current_range.get_start(default_start);
|
||||
index finish = current_range.get_finish(default_finish);
|
||||
index index_factor = current_range.stride();
|
||||
|
||||
// integral trick for ceiling((finish-start) / index_factor)
|
||||
index shrinkage = index_factor > 0 ? 1 : -1;
|
||||
index len = (finish - start + (index_factor - shrinkage)) / index_factor;
|
||||
index len = (finish - start + (index_factor - 1)) / index_factor;
|
||||
|
||||
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);
|
||||
BOOST_ASSERT(index_factor > 0);
|
||||
|
||||
// the array data pointer is modified to account for non-zero
|
||||
// bases during slicing (see [Garcia] for the math involved)
|
||||
|
||||
@@ -77,7 +77,6 @@ namespace multi_array {
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = Array::dimensionality;
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
// shape
|
||||
//
|
||||
#include "boost/type.hpp"
|
||||
#include "boost/assert.hpp"
|
||||
#include <cassert>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
@@ -52,8 +52,8 @@ private:
|
||||
|
||||
template <typename Array1, typename Array2>
|
||||
void copy_array (Array1& source, Array2& dest) {
|
||||
BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
|
||||
dest.shape()));
|
||||
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>::
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "boost/functional.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
@@ -164,9 +165,9 @@ public:
|
||||
void reshape(const SizeList& extents) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<SizeList> >();
|
||||
BOOST_ASSERT(num_elements_ ==
|
||||
std::accumulate(extents.begin(),extents.end(),
|
||||
size_type(1),std::multiplies<size_type>()));
|
||||
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_);
|
||||
@@ -482,9 +483,9 @@ public:
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
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;
|
||||
@@ -494,10 +495,9 @@ public:
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),this->begin());
|
||||
}
|
||||
|
||||
@@ -235,9 +235,9 @@ public:
|
||||
ConstMultiArray, NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
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,10 +247,9 @@ public:
|
||||
sub_array& operator=(const sub_array& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
|
||||
@@ -244,7 +244,10 @@ 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>());
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
#if 0
|
||||
assert(num_elements_ != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef boost::array<size_type,NumDims> size_list;
|
||||
@@ -301,9 +304,9 @@ public:
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
@@ -313,10 +316,9 @@ public:
|
||||
multi_array_view& operator=(const multi_array_view& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
assert(other.num_dimensions() == this->num_dimensions());
|
||||
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
|
||||
@@ -37,13 +37,11 @@ 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 ]
|
||||
[ compile concept_checks.cpp ]
|
||||
;
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
} // 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;
|
||||
}
|
||||
@@ -20,8 +20,8 @@
|
||||
#include "boost/multi_array.hpp"
|
||||
|
||||
#include "boost/cstdlib.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include "boost/test/test_tools.hpp"
|
||||
|
||||
#include "boost/array.hpp"
|
||||
|
||||
|
||||
@@ -114,14 +114,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -90,28 +90,6 @@ 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_CHECK(c_storage == (general_storage_order<5>) c_storage_order());
|
||||
BOOST_CHECK(fortran_storage ==
|
||||
BOOST_TEST(c_storage == (general_storage_order<5>) c_storage_order());
|
||||
BOOST_TEST(fortran_storage ==
|
||||
(general_storage_order<5>) fortran_storage_order());
|
||||
|
||||
return boost::exit_success;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user