Compare commits

..

1 Commits

Author SHA1 Message Date
nobody
288a5bfb78 This commit was manufactured by cvs2svn to create tag
'Version_1_34_0_RC3'.

[SVN r37663]
2007-05-11 03:40:35 +00:00
74 changed files with 860 additions and 2470 deletions

View File

@@ -1,234 +0,0 @@
# Copyright 2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
language: cpp
sudo: false
python: "2.7"
branches:
only:
- master
- develop
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libc++-dev
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost
- cd boost
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- mkdir -p libs/multi_array
- cp -r $TRAVIS_BUILD_DIR/* libs/multi_array
- python tools/boostdep/depinst/depinst.py multi_array
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j 3 libs/multi_array/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
on_success: always

View File

@@ -1,56 +0,0 @@
# Copyright 2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-10.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-11.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
ADDRMD: 32,64
STANDARD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
ADDRMD: 32,64
STANDARD: 14,17
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost
- cd boost
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\multi_array\
- python tools/boostdep/depinst/depinst.py multi_array
- cmd /c bootstrap
- b2 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- b2 -j 3 libs/multi_array/test toolset=%TOOLSET% %CXXSTD%

View File

@@ -1,15 +0,0 @@
# Copyright (c) 2016 Rene Rivera
#
# Distributed under 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)
###############################################################################
alias boostdoc
: xml/bbref.xml
:
:
: ;
explicit boostdoc ;
alias boostrelease ;
explicit boostrelease ;

View File

@@ -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>
@@ -45,13 +45,13 @@ definition and common implementations of that interface.
<table>
<tr valign=top>
<td nowrap>Copyright &copy 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="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>,
<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>

View File

@@ -38,7 +38,7 @@ gives a summary of the current dereference return type requirements in the
iterator categories.
<p>
</p><center>
<a name="table:1">
<a name="table:2">
<b>Table 1.</b> Summary of current dereference return type
requirements.</a><table border="1">
<tbody>
@@ -50,7 +50,7 @@ iterator categories.
<td><tt>*i</tt> is convertible to <tt>T</tt></td></tr>
<tr>
<td>Forward Iterator</td>
<td><tt>*i</tt> is <tt>T&amp;</tt> (or <tt>const T&amp;</tt> once <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#200">issue
<td><tt>*i</tt> is <tt>T&amp;</tt> (or <tt>const T&amp;</tt> once <a href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#200">issue
200</a> is resolved)</td></tr>
<tr>
<td>Random Access Iterator</td>
@@ -61,7 +61,7 @@ iterator categories.
<p>Because of the mixing of iterator traversal and dereference return type, many
useful iterators can not be appropriately categorized. For example,
<tt>vector&lt;bool&gt;::iterator</tt> is almost a random access iterator, but
the return type is not <tt>bool&amp;</tt> (see <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#96">issue
the return type is not <tt>bool&amp;</tt> (see <a href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#96">issue
96</a> and Herb Sutter's paper J16/99-0008 = WG21 N1185). Therefore, the
iterators only meet the requirements of input iterator and output iterator. This
is so nonintuitive that at least one implementation erroneously assigns
@@ -74,7 +74,7 @@ integers when incremented and dereferenced (see <a href="http://www.boost.org/li
There are two ways to implement this iterator, 1) make the <tt>reference</tt>
type be a true reference (a reference to an integer data member of the counting
iterator) or 2) make the <tt>reference</tt> type be the same as the
<tt>value_type</tt>. Option 1) runs into the problems discussed in <a href="http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#198">Issue
<tt>value_type</tt>. Option 1) runs into the problems discussed in <a href="http://anubis.dkuug.dk/JTC1/SC22/WG21/docs/lwg-active.html#198">Issue
198</a>, the reference will not be valid after the iterator is destroyed. Option
2) is therefore a better choice, but then we have a counting iterator that
cannot be a random access iterator.
@@ -651,8 +651,8 @@ Iterator</a>.
</h3>The Forward Iterator is an iterator that can be incremented. Also, it is
permissible to make multiple passes through the iterator's range.
<h3>Refinement of</h3><a href="http://www.boost.org/libs/utility/CopyConstructible.html">Copy
Constructible</a>, <a href="http://www.boost.org/libs/utility/Assignable.html">Assignable</a>, <a href="https://www.boost.org/sgi/stl/DefaultConstructible.html">Default
Constructible</a>, and <a href="https://www.boost.org/sgi/stl/EqualityComparable.html">Equality
Constructible</a>, <a href="http://www.boost.org/libs/utility/Assignable.html">Assignable</a>, <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">Default
Constructible</a>, and <a href="http://www.sgi.com/tech/stl/EqualityComparable.html">Equality
Comparable</a>
<h3>Associated types</h3>
<table border="1">
@@ -725,7 +725,7 @@ Traversal Iterator</a>
Iterator </h3>An iterator that provides constant-time methods for moving forward
and backward in arbitrary-sized steps.
<h3>Refinement of</h3><a href="#concept_BidirectionalTraversalIterator">Bidirectional
Traversal Iterator</a> and <a href="https://www.boost.org/sgi/stl/LessThanComparable.html">Less Than
Traversal Iterator</a> and <a href="http://www.sgi.com/tech/stl/LessThanComparable.html">Less Than
Comparable</a> where <tt>&lt;</tt> is a total ordering
<h3>Associated types</h3>
<table border="1">
@@ -794,4 +794,4 @@ Comparable</a> where <tt>&lt;</tt> is a total ordering
--><!-- LocalWords: Postdecrement
--></body></html>
--></body></html>

View File

@@ -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.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.
<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
@@ -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" 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
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
<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 &lt;std::size_t NumDims&gt; class general_storage_order;
}
</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
</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
concept defines an interface to hierarchically nested
containers. It specifies operations for accessing elements,
traversing containers, and creating views
@@ -150,23 +150,17 @@ 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><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">&lt;boost/multi_array/concept_checks.hpp&gt;</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
</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&lt;Dims&lt;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 class="ulink" href="../../utility/Collection.html" target="_top">Collection</a>
<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&lt;index,NumDims&gt;</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.
<code class="literal">boost::array&lt;index,NumDims&gt;</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.
@@ -198,17 +192,15 @@ 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 class="ulink" href="http://www.boost.org/doc/html/RandomAccessIterator.html" target="_top">
<a href="http://www.sgi.com/tech/stl/RandomAccessIterator.html" target="_top">
<code class="literal">Random Access Iterator</code></a>.
Otherwise it models
<a class="ulink" href="./iterator_categories.html#concept_RandomAccessTraversalIterator" target="_top">
<a href="./iterator_categories.html#concept_RandomAccessTraversalIterator" target="_top">
Random Access Traversal 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>.
<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>.
</td></tr><tr><td>
<code class="literal">const_iterator</code>
</td><td>
@@ -268,9 +260,7 @@ It models MultiArray.
const_array_view&lt;Dims&gt;::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" 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>
</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>
@@ -353,26 +343,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 class="ulink" href="https://www.boost.org/sgi/stl/EqualityComparable.html" target="_top">EqualityComparable</a> for this
type must model <a 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 &lt; 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 class="ulink" href="https://www.boost.org/sgi/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
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><tr><td><code class="literal">a &lt;= 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 class="ulink" href="https://www.boost.org/sgi/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and
<a class="ulink" href="https://www.boost.org/sgi/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
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
expression to be valid.</td></tr><tr><td><code class="literal">a &gt; 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 class="ulink" href="https://www.boost.org/sgi/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and
<a class="ulink" href="https://www.boost.org/sgi/stl/LessThanComparable.html" target="_top">LessThanComparable</a> for this
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
expression to be valid.</td></tr><tr><td><code class="literal">a &gt;= 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 class="ulink" href="https://www.boost.org/sgi/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
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
constant time.
<code class="literal">size()</code> executes in at most linear time in the
MultiArray's size.
</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.
</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>
@@ -383,11 +373,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 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
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
types define the interface for creating views of existing
MultiArrays. Their interfaces and roles in the
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
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
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>
@@ -411,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="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
</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="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>
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>
@@ -446,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" 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(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="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
</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&lt;Dims,Ranges&gt;::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="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
<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>
@@ -464,21 +454,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&lt;0,0&gt;::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&lt;0,0&gt;::type</code></td><td>This constructs an <code class="literal">index_gen</code>
<code class="classname">gen_type&lt;0,0&gt;::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&lt;0,0&gt;::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&lt;Dims+1,Ranges+1&gt;::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&lt;Dims,Ranges+1&gt;::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&lt;Dims,Ranges&gt;::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&lt;Dims+1,Ranges+1&gt;::type</code>.
</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&lt;Dims&gt;::type</code></li><li class="listitem"><code class="literal">template const_array_view&lt;Dims&gt;::type</code></li><li class="listitem"><code class="literal">template subarray&lt;Dims&gt;::type</code></li><li class="listitem"><code class="literal">template const_subarray&lt;Dims&gt;::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>
</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&lt;Dims&gt;::type</code></li><li><code class="literal">template const_array_view&lt;Dims&gt;::type</code></li><li><code class="literal">template subarray&lt;Dims&gt;::type</code></li><li><code class="literal">template const_subarray&lt;Dims&gt;::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
@@ -495,7 +485,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 title="Note: Preconditions, Effects, and Implementation"><b>Note: Preconditions, Effects, and Implementation. </b>
</p><p><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
@@ -506,7 +496,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 title="Queries"><b>Queries. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">element* data();
</p><p><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
@@ -524,7 +514,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 title="Comparators"><b>Comparators. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
</p></dd></dl></div><p><b>Comparators. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
bool operator==(const *array-type*&amp; rhs);
bool operator!=(const *array-type*&amp; rhs);
bool operator&lt;(const *array-type*&amp; rhs);
@@ -533,9 +523,9 @@ bool operator&gt;=(const *array-type*&amp; rhs);
bool operator&lt;=(const *array-type*&amp; 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 title="Preconditions"><b>Preconditions. </b><code class="literal">element</code> must support the
</p><p><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 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">
<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">
<pre class="programlisting">
template &lt;typename SizeList&gt;
@@ -545,12 +535,12 @@ void reshape(const SizeList&amp; 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 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>
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>
</p><pre class="programlisting">
std::accumulate(sizes.begin(),sizes.end(),size_type(1),std::times&lt;size_type&gt;()) == this-&gt;num_elements();
sizes.size() == NumDims;
</pre><p title="Postconditions"><b>Postconditions. </b>
</pre><p><b>Postconditions. </b>
<code class="literal">std::equal(sizes.begin(),sizes.end(),this-&gt;shape) == true;</code>
</p></dd><dt><span class="term">
<pre class="programlisting">
@@ -560,8 +550,8 @@ void reindex(const BaseList&amp; 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 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-&gt;index_bases());
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-&gt;index_bases());
</code></p></dd><dt><span class="term">
<pre class="programlisting">
@@ -569,15 +559,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 title="Postconditions"><b>Postconditions. </b>
<code class="literal">multi_array</code> to <code class="literal">value</code>.</p><p><b>Postconditions. </b>
</p><pre class="programlisting">
std::count_if(this-&gt;index_bases(),this-&gt;index_bases()+this-&gt;num_dimensions(),
std::bind_2nd(std::equal_to&lt;index&gt;(),value)) ==
this-&gt;num_dimensions();
</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>
</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>
<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
@@ -586,11 +576,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 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="https://www.boost.org/sgi/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a class="ulink" href="https://www.boost.org/sgi/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
</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">
namespace boost {
@@ -616,7 +606,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 &lt;std::size_t Dims&gt; struct subarray;
@@ -625,9 +615,6 @@ public:
template &lt;std::size_t Dims&gt; struct const_array_view;
static const std::size_t dimensionality = NumDims;
// constructors and destructors
multi_array();
@@ -710,7 +697,7 @@ public:
multi_array&amp; resize(extents_tuple&amp; extents);
};
</pre><p title="Constructors"><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template &lt;typename ExtentList&gt;
</pre><p><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template &lt;typename ExtentList&gt;
explicit multi_array(const ExtentList&amp; sizes,
const storage_order_type&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
@@ -721,9 +708,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 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">
</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 multi_array(extent_gen::gen_type&lt;NumDims&gt;::type ranges,
const storage_order_type&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
@@ -747,34 +734,34 @@ multi_array(const subarray&lt;NumDims&gt;::type&amp; x);
multi_array(const array_view&lt;NumDims&gt;::type&amp; 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 title="Complexity"><b>Complexity. </b> This performs O(<code class="literal">x.num_elements()</code>) calls to
</p><p><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 title="Note on Constructors"><b>Note on Constructors. </b>
</p></dd></dl></div><p><b>Note on Constructors. </b>
The <code class="literal">multi_array</code> construction expressions,
</p><pre class="programlisting">
multi_array&lt;int,3&gt; A(boost::extents[5][4][3]);
</pre><p title="Note on Constructors">
</pre><p>
and
</p><pre class="programlisting">
boost::array&lt;multi_array_base::index,3&gt; my_extents = {{5, 4, 3}};
multi_array&lt;int,3&gt; A(my_extents);
</pre><p title="Note on Constructors">
</pre><p>
are equivalent.
</p><p title="Modifiers"><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
</p><p><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
multi_array&amp; operator=(const multi_array&amp; x);
template &lt;class Array&gt; multi_array&amp; operator=(const Array&amp; 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 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>
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>
</p><pre class="programlisting">std::equal(this-&gt;shape(),this-&gt;shape()+this-&gt;num_dimensions(),
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
x.shape());</pre><p><b>Postconditions. </b>
</p><pre class="programlisting">(*.this) == x;</pre><p>
</p><p><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">
@@ -785,8 +772,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-&gt;data())</code>.
</p><p title="Preconditions"><b>Preconditions. </b><code class="literal">std::distance(begin,end) == this-&gt;num_elements();</code>
</p><p title="Complexity"><b>Complexity. </b>
</p><p><b>Preconditions. </b><code class="literal">std::distance(begin,end) == this-&gt;num_elements();</code>
</p><p><b>Complexity. </b>
The <code class="literal">assign</code> member function performs
O(<code class="literal">this-&gt;num_elements()</code>) calls to
<code class="literal">ValueType</code>'s copy constructor.
@@ -803,30 +790,31 @@ 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 title="Queries"><b>Queries. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
</p></dd></dl></div><p><b>Queries. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
storage_order_type&amp; 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" 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</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_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 title="Model Of."><b>Model Of. </b>
</p><p><b>Model Of. </b>
<code class="literal">multi_array_ref</code> models
<a class="link" href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
<a class="ulink" href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
<a href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
<a href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
and depending on the element type, it may also model
<a class="ulink" href="https://www.boost.org/sgi/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a class="ulink" href="https://www.boost.org/sgi/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
<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>.
Detailed descriptions are provided here only for operations that are
not described in the <code class="literal">multi_array</code> reference.
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
</p><p><b>Synopsis. </b></p><pre class="programlisting">
namespace boost {
template &lt;typename ValueType,
std::size_t NumDims&gt;
std::size_t NumDims,
typename Allocator = std::allocator&lt;ValueType&gt; &gt;
class multi_array_ref {
public:
// types:
@@ -854,10 +842,7 @@ public:
template &lt;std::size_t Dims&gt; struct const_array_view;
static const std::size_t dimensionality = NumDims;
// constructors and destructors
// structors
template &lt;typename ExtentList&gt;
explicit multi_array_ref(element* data, const ExtentList&amp; sizes,
@@ -924,7 +909,7 @@ public:
void reindex(index value);
};
</pre><p title="Constructors"><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template &lt;typename ExtentList&gt;
</pre><p><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template &lt;typename ExtentList&gt;
explicit multi_array_ref(element* data,
const ExtentList&amp; sizes,
const storage_order&amp; store = c_storage_order(),
@@ -936,9 +921,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 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">
</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 multi_array_ref(element* data,
extent_gen::gen_type&lt;NumDims&gt;::type ranges,
const storage_order&amp; store = c_storage_order());
@@ -953,42 +938,42 @@ dimensions.
</p></dd><dt><span class="term"><pre class="programlisting">
multi_array_ref(const multi_array_ref&amp; x);
</pre></span></dt><dd><p>This constructs a shallow copy of <code class="literal">x</code>.
</p><p title="Complexity"><b>Complexity. </b> Constant time (for contrast, compare this to
</p><p><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 title="Modifiers"><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
</p></dd></dl></div><p><b>Modifiers. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">
multi_array_ref&amp; operator=(const multi_array_ref&amp; x);
template &lt;class Array&gt; multi_array_ref&amp; operator=(const Array&amp; 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 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>
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>
</p><pre class="programlisting">std::equal(this-&gt;shape(),this-&gt;shape()+this-&gt;num_dimensions(),
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
x.shape());</pre><p><b>Postconditions. </b>
</p><pre class="programlisting">(*.this) == x;</pre><p>
</p><p><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" 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>
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>
<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 title="Model Of."><b>Model Of. </b>
</p><p><b>Model Of. </b>
<code class="literal">const_multi_array_ref</code> models
<a class="link" href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
<a class="ulink" href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
<a href="#MultiArray" title="MultiArray Concept">MultiArray</a>,
<a href="../../../libs/utility/CopyConstructible.html" target="_top">CopyConstructible</a>.
and depending on the element type, it may also model
<a class="ulink" href="https://www.boost.org/sgi/stl/EqualityComparable.html" target="_top">EqualityComparable</a> and <a class="ulink" href="https://www.boost.org/sgi/stl/LessThanComparable.html" target="_top">LessThanComparable</a>.
<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>.
Detailed descriptions are provided here only for operations that are
not described in the <code class="literal">multi_array</code> reference.
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
</p><p><b>Synopsis. </b></p><pre class="programlisting">
namespace boost {
template &lt;typename ValueType,
std::size_t NumDims,
typename TPtr = const T*&gt;
typename Allocator = std::allocator&lt;ValueType&gt; &gt;
class const_multi_array_ref {
public:
// types:
@@ -1019,9 +1004,9 @@ public:
// structors
template &lt;typename ExtentList&gt;
explicit const_multi_array_ref(TPtr data, const ExtentList&amp; sizes,
explicit const_multi_array_ref(const element* data, const ExtentList&amp; sizes,
const storage_order_type&amp; store = c_storage_order());
explicit const_multi_array_ref(TPtr data, const extents_tuple&amp; ranges,
explicit const_multi_array_ref(const element* data, const extents_tuple&amp; ranges,
const storage_order_type&amp; store = c_storage_order());
const_multi_array_ref(const const_multi_array_ref&amp; x);
~const_multi_array_ref();
@@ -1068,8 +1053,8 @@ public:
void reindex(index value);
};
</pre><p title="Constructors"><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template &lt;typename ExtentList&gt;
explicit const_multi_array_ref(TPtr data,
</pre><p><b>Constructors. </b></p><div class="variablelist"><dl><dt><span class="term"><pre class="programlisting">template &lt;typename ExtentList&gt;
explicit const_multi_array_ref(const element* data,
const ExtentList&amp; sizes,
const storage_order&amp; store = c_storage_order());
</pre></span></dt><dd><p>
@@ -1078,13 +1063,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 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,
</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,
extent_gen::gen_type&lt;NumDims&gt;::type ranges,
const storage_order&amp; store = c_storage_order());
</pre></span></dt><dd><p title="Effects"><b>Effects. </b>
</pre></span></dt><dd><p><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
@@ -1094,8 +1079,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&amp; x);
</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">
</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">
namespace multi_array_types {
typedef *unspecified* index;
typedef *unspecified* size_type;
@@ -1117,14 +1102,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" 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
</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
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 title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
</p><p><b>Synopsis. </b></p><pre class="programlisting">
class extent_range {
public:
typedef multi_array_types::index index;
@@ -1139,14 +1124,14 @@ public:
index start();
index finish();
size_type size();
};</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
};</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
<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" 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
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
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>
@@ -1158,7 +1143,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&lt;int,3&gt; A(extents[3][4][5]).</pre><p>
</p><p title="Synopsis"><b>Synopsis. </b></p><pre class="programlisting">
</p><p><b>Synopsis. </b></p><pre class="programlisting">
template &lt;std::size_t NumRanges&gt;
class *implementation_defined* {
public:
@@ -1172,7 +1157,7 @@ public:
};
typedef *implementation_defined*&lt;0&gt; extent_gen;
</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&lt;Ranges&gt;::type</code></span></dt><dd><p>This type generator is used to specify the result of
</pre><p><b>Methods and Types. </b></p><div class="variablelist"><dl><dt><span class="term"><code class="function">template gen_type::&lt;Ranges&gt;::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
@@ -1186,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" 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
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.
@@ -1194,7 +1179,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" 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">
<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">
namespace boost {
multi_array_base::extent_gen extents;
}
@@ -1206,7 +1191,7 @@ a 3 by 3 by 3 <code class="classname">multi_array</code> is constructed as follo
</p><pre class="programlisting">multi_array&lt;int,3&gt; 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" 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">
</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">
namespace boost {
multi_array_base::index_gen indices;
}
@@ -1221,7 +1206,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" 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>
</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>
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>,
@@ -1247,7 +1232,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" 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>
</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>
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
@@ -1335,7 +1320,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" 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">
</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">
class c_storage_order {
c_storage_order();
};
@@ -1343,14 +1328,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" 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">
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">
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" 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">
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">
template &lt;std::size_t NumDims&gt;
class general_storage_order {
@@ -1370,7 +1355,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" title="Range Checking"><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" lang="en"><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

View File

@@ -20,7 +20,7 @@ Boost.MultiArray: Test Descriptions
</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<IMG SRC="../../../boost.png"
<IMG SRC="http://www.boost.org/boost.png"
ALT="C++ Boost" width="277" height="86">
<h1>Boost.MultiArray: Test Descriptions</h1>
@@ -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,21 +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/allocators.cpp">libs/multi_array/test/allocators.cpp</a></td>
<td>
Test support for custom allocators.
</td>
</tr>
<tr>
<td><a href="../test/generative_tests.hpp">libs/multi_array/test/generative_tests.hpp</a></td>
<td>
@@ -307,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 &copy; 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

View File

@@ -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&lt;3&gt;::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&lt;2&gt;::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
@@ -459,7 +452,7 @@ indices will remain zero-based.
<blockquote>
<pre>
typedef boost::multi_array&lt;double,3&gt; 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>
@@ -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&lt;double, 3&gt; 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&lt;double, 3&gt; 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&lt;double, 3&gt; 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&lt;double, 3&gt; 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&lt;int, 3&gt; array_type;
typedef array_type::extent_range range;
array_type::extent_gen extents;
array_type A(extents[3][3][3]);
@@ -612,7 +606,7 @@ cases can be found <a href="./test_cases.html">here</a>.
<h2>Related Work</h2>
<a href="../../array/index.html">boost::array</a>
and <a href="https://www.boost.org/sgi/stl/Vector.html">std::vector</a> are
and <a href="http://www.sgi.com/tech/stl/Vector.html">std::vector</a> are
one-dimensional containers of user data. Both manage their own
memory. <tt>std::valarray</tt> is a low-level
C++ Standard Library component
@@ -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++.
@@ -661,11 +655,6 @@ arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
<li><a href="mailto:bdawes@acm.org">Beman Dawes</a>
helped immensely with porting the library to Microsoft Windows
compilers.
<li><a href="mailto:glenjofe@gmail.com">Glen Fernandes</a>
implemented support for the C++11 allocator model, including
support for stateful allocators, minimal allocators, and
optimized storage for stateless allocators.
</ul>
<hr>

View File

@@ -1,19 +0,0 @@
# Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
# Distributed under 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)
project multi_array/doc ;
import boostbook : boostbook ;
path-constant here : . ;
boostbook multi_array-doc
:
bbref.xml
:
<xsl:param>boost.root=../../../../..
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
<format>pdf:<xsl:param>img.src.path=$(here)/../
;

View File

@@ -110,14 +110,6 @@ 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>&lt;boost/multi_array/concept_checks.hpp&gt;</literal>.
</para>
<sect2><title>Notation</title>
<para>What follows are the descriptions of symbols that will be used
@@ -248,17 +240,15 @@ 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.boost.org/doc/html/RandomAccessIterator.html">
<ulink url="http://www.sgi.com/tech/stl/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>,
Readable Iterator</ulink>, and
<ulink url="./iterator_categories.html#concept_WritableIterator">
Writable Iterator</ulink>, and
<ulink url="http://www.boost.org/doc/html/OutputIterator.html">
<literal>Output Iterator</literal></ulink>.
Writable Iterator</ulink>.
</entry>
</row>
@@ -395,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>
@@ -567,7 +550,7 @@ This expression generates a view of the array determined by the
<entry>bool</entry>
<entry>This performs a lexicographical comparison of the
values of <literal>a</literal> and <literal>b</literal>. The element
type must model <ulink url="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</ulink> for this
type must model <ulink url="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</ulink> for this
expression to be valid.</entry>
</row>
<row>
@@ -575,7 +558,7 @@ expression to be valid.</entry>
<entry>bool</entry>
<entry>This performs a lexicographical comparison of the
values of <literal>a</literal> and <literal>b</literal>. The element
type must model <ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink> for this
type must model <ulink url="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</ulink> for this
expression to be valid.</entry>
</row>
<row>
@@ -583,8 +566,8 @@ expression to be valid.</entry>
<entry>bool</entry>
<entry>This performs a lexicographical comparison of the
values of <literal>a</literal> and <literal>b</literal>. The element
type must model <ulink url="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</ulink> and
<ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink> for this
type must model <ulink url="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</ulink> and
<ulink url="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</ulink> for this
expression to be valid.</entry>
</row>
<row>
@@ -592,8 +575,8 @@ expression to be valid.</entry>
<entry>bool</entry>
<entry>This performs a lexicographical comparison of the
values of <literal>a</literal> and <literal>b</literal>. The element
type must model <ulink url="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</ulink> and
<ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink> for this
type must model <ulink url="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</ulink> and
<ulink url="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</ulink> for this
expression to be valid.</entry>
</row>
<row>
@@ -601,7 +584,7 @@ expression to be valid.</entry>
<entry>bool</entry>
<entry>This performs a lexicographical comparison of the
values of <literal>a</literal> and <literal>b</literal>. The element
type must model <ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink> for this
type must model <ulink url="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</ulink> for this
expression to be valid.</entry>
</row>
</tbody>
@@ -977,7 +960,7 @@ object. This object can then be used to generate tuples of
</row>
<row>
<entry><literal>x[idx]</literal></entry>
<entry><literal>gen_type&lt;Dims,Ranges+1&gt;::type</literal>
<entry><literal>gen_type&lt;Dims,Ranges&gt;::type</literal>
</entry>
<entry>Returns a new object containing all previous
<classname>index_range</classname> objects in addition to a degenerate

View File

@@ -1,806 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd" [
<!ENTITY concepts SYSTEM "MultiArray.xml">
<!ENTITY multi_array SYSTEM "multi_array.xml">
<!ENTITY multi_array_ref SYSTEM "multi_array_ref.xml">
<!ENTITY const_multi_array_ref SYSTEM "const_multi_array_ref.xml">
]>
<library name="MultiArray" dirname="multi_array" id="multi_array"
xmlns:xi="http://www.w3.org/2001/XInclude"
last-revision="$Date$">
<libraryinfo>
<author>
<firstname>Ronald</firstname>
<surname>Garcia</surname>
<affiliation>
<orgname>Indiana University</orgname>
<orgdiv>Open Systems Lab</orgdiv>
</affiliation>
</author>
<orgname>BOOST</orgname>
<copyright>
<year>2002</year>
<holder>The Trustees of Indiana University</holder>
</copyright>
<librarypurpose>Multidimensional containers and adaptors for
arrays of contiguous data</librarypurpose>
<librarycategory name="category:math"/>
<librarycategory name="category:containers"/>
</libraryinfo>
<title>Boost.MultiArray Reference Manual</title>
<para>Boost.MultiArray is composed of several components.
The MultiArray concept defines a generic interface to multidimensional
containers.
<literal>multi_array</literal> is a general purpose container class
that models MultiArray. <literal>multi_array_ref</literal>
and <literal>const_multi_array_ref</literal> are adapter
classes. Using them,
you can manipulate any block of contiguous data as though it were a
<literal>multi_array</literal>.
<literal>const_multi_array_ref</literal> differs from
<literal>multi_array_ref</literal> 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.</para>
<sect1 id="synopsis">
<title>Library Synopsis</title>
<para>To use Boost.MultiArray, you must include the header
<filename>boost/multi_array.hpp</filename> in your source. This file
brings the following declarations into scope:</para>
<programlisting>
<![CDATA[namespace boost {
namespace multi_array_types {
typedef *unspecified* index;
typedef *unspecified* size_type;
typedef *unspecified* difference_type;
typedef *unspecified* index_range;
typedef *unspecified* extent_range;
typedef *unspecified* index_gen;
typedef *unspecified* extent_gen;
}
template <typename ValueType,
std::size_t NumDims,
typename Allocator = std::allocator<ValueType> >
class multi_array;
template <typename ValueType,
std::size_t NumDims>
class multi_array_ref;
template <typename ValueType,
std::size_t NumDims>
class const_multi_array_ref;
multi_array_types::extent_gen extents;
multi_array_types::index_gen indices;
template <typename Array, int N> class subarray_gen;
template <typename Array, int N> class const_subarray_gen;
template <typename Array, int N> class array_view_gen;
template <typename Array, int N> class const_array_view_gen;
class c_storage_order;
class fortran_storage_order;
template <std::size_t NumDims> class general_storage_order;
}]]>
</programlisting>
</sect1>
&concepts;
<sect1 id="array_types">
<title>Array Components</title>
<para>
Boost.MultiArray defines an array class,
<literal>multi_array</literal>, and two adapter classes,
<literal>multi_array_ref</literal> and
<literal>const_multi_array_ref</literal>. The three classes model
MultiArray and so they share a lot of functionality.
<literal>multi_array_ref</literal> differs from
<literal>multi_array</literal> in that the
<literal>multi_array</literal> manages its own memory, while
<literal>multi_array_ref</literal> is passed a block of memory that it
expects to be externally managed.
<literal>const_multi_array_ref</literal> differs from
<literal>multi_array_ref</literal> in that the underlying elements it
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.
</para>
<formalpara>
<title>Note: Preconditions, Effects, and Implementation</title>
<para>
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
implementation of array components; rather, they describe the
expected input to and
behavior of the specified operations. Failure to meet
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.
</para>
</formalpara>
<formalpara>
<title>Queries</title>
<variablelist>
<varlistentry>
<term><programlisting>element* data();
const element* data() const;</programlisting></term>
<listitem>
<para>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
equivalent to <literal>origin()</literal>. Note that
<literal>const_multi_array_ref</literal> only provides the const
version of this function.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><programlisting>element* origin();
const element* origin() const;</programlisting></term>
<listitem>
<para>This returns the origin element of the
<literal>multi_array</literal>. Note that
<literal>const_multi_array_ref</literal> only provides the const
version of this function. (Required by MultiArray)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>const index* index_bases();</function></term>
<listitem>
<para>This returns the index bases for the
<literal>multi_array</literal>. (Required by MultiArray)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>const index* strides();</function></term>
<listitem>
<para>This returns the strides for the
<literal>multi_array</literal>. (Required by MultiArray)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>const size_type* shape();</function></term>
<listitem>
<para>This returns the shape of the
<literal>multi_array</literal>. (Required by MultiArray)
</para>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
<formalpara>
<title>Comparators</title>
<variablelist>
<varlistentry>
<term><programlisting><![CDATA[
bool operator==(const *array-type*& rhs);
bool operator!=(const *array-type*& rhs);
bool operator<(const *array-type*& rhs);
bool operator>(const *array-type*& rhs);
bool operator>=(const *array-type*& rhs);
bool operator<=(const *array-type*& rhs);]]></programlisting></term>
<listitem>
<para>Each comparator executes a lexicographical compare over
the value types of the two arrays.
(Required by MultiArray)
</para>
<formalpara>
<title>Preconditions</title>
<para><literal>element</literal> must support the
comparator corresponding to that called on
<literal>multi_array</literal>.</para>
</formalpara>
<formalpara>
<title>Complexity</title>
<para>O(<literal>num_elements()</literal>).</para>
</formalpara>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
<formalpara>
<title>Modifiers</title>
<variablelist>
<varlistentry>
<term>
<programlisting>
<![CDATA[
template <typename SizeList>
void reshape(const SizeList& sizes)
]]>
</programlisting>
</term>
<listitem>
<para>This changes the shape of the <literal>multi_array</literal>. 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.</para>
<formalpara><title><literal>SizeList</literal> Requirements</title>
<para><literal>SizeList</literal> must model
<ulink url="../../utility/Collection.html">Collection</ulink>.</para>
</formalpara>
<formalpara><title>Preconditions</title>
<para>
<programlisting>
<![CDATA[std::accumulate(sizes.begin(),sizes.end(),size_type(1),std::times<size_type>()) == this->num_elements();
sizes.size() == NumDims;]]>
</programlisting></para>
</formalpara>
<formalpara><title>Postconditions</title>
<para>
<literal>std::equal(sizes.begin(),sizes.end(),this->shape) == true;</literal>
</para>
</formalpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<programlisting>
<![CDATA[
template <typename BaseList>
void reindex(const BaseList& values);
]]>
</programlisting>
</term>
<listitem>
<para>This changes the index bases of the <literal>multi_array</literal> to
correspond to the the values in <literal>values</literal>.</para>
<formalpara>
<title><literal>BaseList</literal> Requirements</title>
<para><literal>BaseList</literal> must model
<ulink url="../../utility/Collection.html">Collection</ulink>.</para>
</formalpara>
<formalpara>
<title>Preconditions</title>
<para><literal>values.size() == NumDims;</literal></para>
</formalpara>
<formalpara>
<title>Postconditions</title>
<para><literal>std::equal(values.begin(),values.end(),this->index_bases());
</literal></para>
</formalpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<programlisting>
<![CDATA[
void reindex(index value);
]]>
</programlisting>
</term>
<listitem>
<para>This changes the index bases of all dimensions of the
<literal>multi_array</literal> to <literal>value</literal>.</para>
<formalpara>
<title>Postconditions</title>
<para>
<programlisting>
<![CDATA[
std::count_if(this->index_bases(),this->index_bases()+this->num_dimensions(),
std::bind_2nd(std::equal_to<index>(),value)) ==
this->num_dimensions();
]]>
</programlisting>
</para>
</formalpara>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
&multi_array;
&multi_array_ref;
&const_multi_array_ref;
</sect1>
<sect1 id="auxiliary">
<title>Auxiliary Components</title>
<sect2 id="multi_array_types">
<title><literal>multi_array_types</literal></title>
<programlisting>
<![CDATA[namespace multi_array_types {
typedef *unspecified* index;
typedef *unspecified* size_type;
typedef *unspecified* difference_type;
typedef *unspecified* index_range;
typedef *unspecified* extent_range;
typedef *unspecified* index_gen;
typedef *unspecified* extent_gen;
}]]>
</programlisting>
<para>Namespace <literal>multi_array_types</literal> defines types
associated with <literal>multi_array</literal>,
<literal>multi_array_ref</literal>, and
<literal>const_multi_array_ref</literal> that are not
dependent upon template parameters. These types find common use with
all Boost.Multiarray components. They are defined
in a namespace from which they can be accessed conveniently.
With the exception of <literal>extent_gen</literal> and
<literal>extent_range</literal>, these types fulfill the roles of the
same name required by MultiArray and are described in its
concept definition. <literal>extent_gen</literal> and
<literal>extent_range</literal> are described below.
</para>
</sect2>
<sect2 id="extent_range">
<title><classname>extent_range</classname></title>
<para><classname>extent_range</classname> objects define half open
intervals. They provide shape and index base information to
<literal>multi_array</literal>, <literal>multi_array_ref</literal>,
and <literal>const_multi_array_ref</literal> constructors.
<classname>extent_range</classname>s are passed in
aggregate to an array constructor (see
<classname>extent_gen</classname> for more details).
</para>
<formalpara>
<title>Synopsis</title>
<programlisting><![CDATA[
class extent_range {
public:
typedef multi_array_types::index index;
typedef multi_array_types::size_type size_type;
// Structors
extent_range(index start, index finish);
extent_range(index finish);
~extent_range();
// Queries
index start();
index finish();
size_type size();
};]]></programlisting>
</formalpara>
<formalpara>
<title>Model Of</title>
<para>DefaultConstructible,CopyConstructible</para>
</formalpara>
<formalpara><title>Methods and Types</title>
<variablelist>
<varlistentry>
<term><function>extent_range(index start, index finish)</function></term>
<listitem>
<para> This constructor defines the half open interval
<literal>[start,finish)</literal>. The expression
<literal>finish</literal> must be greater than <literal>start</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry><term><function>extent_range(index finish)</function></term>
<listitem>
<para>This constructor defines the half open interval
<literal>[0,finish)</literal>. The value of <literal>finish</literal>
must be positive.</para>
</listitem>
</varlistentry>
<varlistentry><term><function>index start()</function></term>
<listitem>
<para>This function returns the first index represented by the range</para>
</listitem>
</varlistentry>
<varlistentry><term><function>index finish()</function></term>
<listitem>
<para>This function returns the upper boundary value of the half-open
interval. Note that the range does not include this value.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>size_type size()</function></term>
<listitem>
<para>This function returns the size of the specified range. It is
equivalent to <literal>finish()-start()</literal>.</para>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
</sect2>
<sect2 id="extent_gen">
<title><classname>extent_gen</classname></title>
<para>The <classname>extent_gen</classname> class defines an
interface for aggregating array shape and indexing information to be
passed to a <literal>multi_array</literal>,
<literal>multi_array_ref</literal>, or <literal>const_multi_array_ref</literal>
constructor. Its interface mimics
the syntax used to declare built-in array types
in C++. For example, while a 3-dimensional array of
<classname>int</classname> values in C++ would be
declared as:
<programlisting>int A[3][4][5],</programlisting>
a similar <classname>multi_array</classname> would be declared:
<programlisting>multi_array&lt;int,3&gt; A(extents[3][4][5]).</programlisting>
</para>
<formalpara><title>Synopsis</title>
<programlisting><![CDATA[
template <std::size_t NumRanges>
class *implementation_defined* {
public:
typedef multi_array_types::index index;
typedef multi_array_types::size_type size_type;
template <std::size_t NumRanges> class gen_type;
gen_type<NumRanges+1>::type operator[](const range& a_range) const;
gen_type<NumRanges+1>::type operator[](index idx) const;
};
typedef *implementation_defined*<0> extent_gen;
]]></programlisting>
</formalpara>
<formalpara><title>Methods and Types</title>
<variablelist>
<varlistentry>
<term><function>template gen_type&lt;Ranges&gt;::type</function></term>
<listitem>
<para>This type generator is used to specify the result of
<literal>Ranges</literal> chained calls to
<literal>extent_gen::operator[].</literal> The types
<classname>extent_gen</classname> and
<classname>gen_type&lt;0&gt;::type</classname> are the same.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>gen_type&lt;NumRanges+1&gt;::type
operator[](const extent_range&amp; a_range) const;</function></term>
<listitem>
<para>This function returns a new object containing all previous
<classname>extent_range</classname> objects in addition to
<literal>a_range.</literal> <classname>extent_range</classname>
objects are aggregated by chained calls to
<function>operator[]</function>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><function>gen_type&lt;NumRanges+1&gt;::type
operator[](index idx) const;</function></term>
<listitem>
<para>This function returns a new object containing all previous
<classname>extent_range</classname> objects in addition to
<literal>extent_range(0,idx).</literal> This function gives the array
constructors a similar syntax to traditional C multidimensional array
declaration.</para>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
</sect2>
<sect2>
<title>Global Objects</title>
<para>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.
</para>
<para> Under some circumstances, the two global objects may be
considered excessive overhead. Their construction can be prevented by
defining the preprocessor symbol
<literal>BOOST_MULTI_ARRAY_NO_GENERATORS</literal> before including
<filename>boost/multi_array.hpp.</filename></para>
<sect3 id="extents">
<title><literal>extents</literal></title>
<programlisting>
<![CDATA[namespace boost {
multi_array_base::extent_gen extents;
}]]>
</programlisting>
<para>Boost.MultiArray's array classes use the
<literal>extents</literal> global object to specify
array shape during their construction.
For example,
a 3 by 3 by 3 <classname>multi_array</classname> is constructed as follows:
<programlisting>multi_array&lt;int,3&gt; A(extents[3][3][3]);</programlisting>
The same array could also be created by explicitly declaring an <literal>extent_gen</literal>
object locally,, but the global object makes this declaration unnecessary.
</para>
</sect3>
<sect3 id="indices">
<title><literal>indices</literal></title>
<programlisting>
<![CDATA[namespace boost {
multi_array_base::index_gen indices;
}]]>
</programlisting>
<para>The MultiArray concept specifies an
<literal>index_gen</literal> associated type that is used to
create views.
<literal>indices</literal> is a global object that serves the role of
<literal>index_gen</literal> for all array components provided by this
library and their associated subarrays and views.
</para>
<para>For example, using the <literal>indices</literal> object,
a view of an array <literal>A</literal> is constructed as follows:
<programlisting>
A[indices[index_range(0,5)][2][index_range(2,4)]];
</programlisting>
</para>
</sect3>
</sect2>
<sect2 id="generators">
<title>View and SubArray Generators</title>
<para>
Boost.MultiArray provides traits classes, <literal>subarray_gen</literal>,
<literal>const_subarray_gen</literal>,
<literal>array_view_gen</literal>,
and <literal>const_array_view_gen</literal>, for naming of
array associated types within function templates.
In general this is no more convenient to use than the nested
type generators, but the library author found that some C++ compilers do not
properly handle templates nested within function template parameter types.
These generators constitute a workaround for this deficit.
The following code snippet illustrates
the correspondence between the <literal>array_view_gen</literal>
traits class and the <literal>array_view</literal> type associated to
an array:
<programlisting>
template &lt;typename Array&gt;
void my_function() {
typedef typename Array::template array_view&lt;3&gt;::type view1_t;
typedef typename boost::array_view_gen&lt;Array,3&gt;::type view2_t;
// ...
}
</programlisting>
In the above example, <literal>view1_t</literal> and
<literal>view2_t</literal> have the same type.
</para>
</sect2>
<sect2 id="memory_layout">
<title>Memory Layout Specifiers</title>
<para>
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
can be represented in memory more than one way.
</para>
<para>For example, consider the two dimensional array shown below in
matrix notation:
<graphic fileref="matrix.gif"/>
Here is how the above array is expressed in C++:
<programlisting>
int a[3][4] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
</programlisting>
This is an example of row-major storage, where elements of each row
are stored contiguously.
While C++ transparently handles accessing elements of an array, you
can also manage the array and its indexing manually. One way that
this may be expressed in memory is as follows:
<programlisting>
int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
int s[] = { 4, 1 };
</programlisting>
With the latter declaration of <literal>a</literal> and
strides <literal>s</literal>, element <literal>a(i,j)</literal>
of the array can be
accessed using the expression
<programlisting>*a+i*s[0]+j*s[1]</programlisting>.
</para>
<para>The same two dimensional array could be laid out by column as follows:
<programlisting>
int a[] = { 0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11 };
int s[] = { 3, 1 };
</programlisting>
Notice that the strides here are different. As a result,
The expression given above to access values will work with this pair
of data and strides as well.
</para>
<para>In addition to dimension order, it is also possible to
store any dimension in descending order. For example, returning to the
first example, the first dimension of the example array, the
rows, could be stored in
reverse, resulting in the following:
<programlisting>
int data[] = { 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 };
int *a = data + 8;
int s[] = { -4, 1 };
</programlisting>
Note that in this example <literal>a</literal> must be explicitly set
to the origin. In the previous examples, the
first element stored in memory was the origin; here this is no longer
the case.
</para>
<para>
Alternatively, the second dimension, or the columns, could be reversed
and the rows stored in ascending order:
<programlisting>
int data[] = { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8 };
int *a = data + 3;
int s[] = { 4, -1 };
</programlisting>
</para>
<para>
Finally, both dimensions could be stored in descending order:
<programlisting>
int data[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int *a = data + 11;
int s[] = { -4, -1 };
</programlisting>
<literal>
</literal>
</para>
<para>
All of the above arrays are equivalent. The expression
given above for <literal>a(i,j)</literal> will yield the same value
regardless of the memory layout.
Boost.MultiArray arrays can be created with customized storage
parameters as described above. Thus, existing data can be adapted
(with <literal>multi_array_ref</literal> or
<literal>const_multi_array_ref</literal>) as suited to the array
abstraction. A common usage of this feature would be to wrap arrays
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.
</para>
<sect3 id="c_storage_order">
<title><literal>c_storage_order</literal></title>
<programlisting>
<![CDATA[class c_storage_order {
c_storage_order();
};]]>
</programlisting>
<para><literal>c_storage_order</literal> is used to specify that an
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.</para>
</sect3>
<sect3 id="fortran_storage_order">
<title><literal>fortran_storage_order</literal></title>
<programlisting>
<![CDATA[class fortran_storage_order {
fortran_storage_order();
};]]>
</programlisting>
<para><literal>fortran_storage_order</literal> 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.</para>
</sect3>
<sect3 id="general_storage_order">
<title><literal>general_storage_order</literal></title>
<programlisting>
<![CDATA[template <std::size_t NumDims>
class general_storage_order {
template <typename OrderingIter, typename AscendingIter>
general_storage_order(OrderingIter ordering, AscendingIter ascending);
};]]>
</programlisting>
<para><literal>general_storage_order</literal> allows the user to
specify an arbitrary memory layout for the contents of an array. The
constructed object is passed to the array constructor in order to
specify storage order.</para>
<para>
<literal>OrderingIter</literal> and <literal>AscendingIter</literal>
must model the <literal>InputIterator</literal> concept. Both
iterators must refer to a range of <literal>NumDims</literal>
elements. <literal>AscendingIter</literal> points to objects
convertible to <literal>bool</literal>. A value of
<literal>true</literal> means that a dimension is stored in ascending
order while <literal>false</literal> means that a dimension is stored
in descending order. <literal>OrderingIter</literal> specifies the
order in which dimensions are stored.
</para>
</sect3>
</sect2>
<sect2 id="range_checking">
<title>Range Checking</title>
<para>
By default, the array access methods <literal>operator()</literal> and
<literal>operator[]</literal> perform range
checking. If a supplied index is out of the range defined for an
array, an assertion will abort the program. To disable range
checking (for performance reasons in production releases), define
the <literal>BOOST_DISABLE_ASSERTS</literal> preprocessor macro prior to
including multi_array.hpp in an application.
</para>
</sect2>
</sect1>
</library>

View File

@@ -17,7 +17,7 @@ of the constructors.
<link linkend="MultiArray">MultiArray</link>,
<ulink url="../../../libs/utility/CopyConstructible.html">CopyConstructible</ulink>.
and depending on the element type, it may also model
<ulink url="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</ulink> and <ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink>.
<ulink url="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</ulink> and <ulink url="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</ulink>.
Detailed descriptions are provided here only for operations that are
not described in the <literal>multi_array</literal> reference.
@@ -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 &lt;typename ExtentList&gt;
explicit const_multi_array_ref(TPtr data,
explicit const_multi_array_ref(const element* data,
const ExtentList&amp; sizes,
const storage_order&amp; 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>

View File

@@ -1,4 +1,4 @@
<sect2 id="multi_array_class">
<sect2 id="multi_array">
<title><literal>multi_array</literal></title>
<para>
@@ -18,7 +18,7 @@ using a replaceable allocator.
<para>
<link linkend="MultiArray">MultiArray</link>,
<ulink url="../../../libs/utility/CopyConstructible.html">CopyConstructible</ulink>. Depending on the element type,
it may also model <ulink url="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</ulink> and <ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink>.
it may also model <ulink url="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</ulink> and <ulink url="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</ulink>.
</para>
</formalpara>
@@ -51,7 +51,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;
@@ -60,12 +60,9 @@ public:
template <std::size_t Dims> struct const_array_view;
static const std::size_t dimensionality = NumDims;
// constructors and destructors
multi_array(const Allocator& alloc = Allocator());
multi_array();
template <typename ExtentList>
explicit multi_array(const ExtentList& sizes,
@@ -75,19 +72,13 @@ public:
const storage_order_type& store = c_storage_order(),
const Allocator& alloc = Allocator());
multi_array(const multi_array& x);
multi_array(const const_multi_array_ref<ValueType,NumDims>& x,
const Allocator& alloc = Allocator());
multi_array(const const_subarray<NumDims>::type& x,
const Allocator& alloc = Allocator());
multi_array(const const_array_view<NumDims>::type& x,
const Allocator& alloc = Allocator());
multi_array(const const_multi_array_ref<ValueType,NumDims>& x);
multi_array(const const_subarray<NumDims>::type& x);
multi_array(const const_array_view<NumDims>::type& x);
multi_array(const multi_array_ref<ValueType,NumDims>& x,
const Allocator& alloc = Allocator());
multi_array(const subarray<NumDims>::type& x,
const Allocator& alloc = Allocator());
multi_array(const array_view<NumDims>::type& x,
const Allocator& alloc = Allocator());
multi_array(const multi_array_ref<ValueType,NumDims>& x);
multi_array(const subarray<NumDims>::type& x);
multi_array(const array_view<NumDims>::type& x);
~multi_array();
@@ -213,18 +204,12 @@ elements.
<varlistentry>
<term><programlisting>
<![CDATA[multi_array(const multi_array& x);
multi_array(const const_multi_array_ref<ValueType,NumDims>& x,
const Allocator& alloc = Allocator());
multi_array(const const_subarray<NumDims>::type& x,
const Allocator& alloc = Allocator());
multi_array(const const_array_view<NumDims>::type& x,
const Allocator& alloc = Allocator());
multi_array(const multi_array_ref<ValueType,NumDims>& x,
const Allocator& alloc = Allocator());
multi_array(const subarray<NumDims>::type& x,
const Allocator& alloc = Allocator());
multi_array(const array_view<NumDims>::type& x,
const Allocator& alloc = Allocator());]]>
multi_array(const const_multi_array_ref<ValueType,NumDims>& x);
multi_array(const const_subarray<NumDims>::type& x);
multi_array(const const_array_view<NumDims>::type& x);
multi_array(const multi_array_ref<ValueType,NumDims>& x);
multi_array(const subarray<NumDims>::type& x);
multi_array(const array_view<NumDims>::type& x);]]>
</programlisting></term>
<listitem>
<para>These constructors all constructs a <literal>multi_array</literal> and

View File

@@ -17,7 +17,7 @@ of the constructors.
<link linkend="MultiArray">MultiArray</link>,
<ulink url="../../../libs/utility/CopyConstructible.html">CopyConstructible</ulink>.
and depending on the element type, it may also model
<ulink url="https://www.boost.org/sgi/stl/EqualityComparable.html">EqualityComparable</ulink> and <ulink url="https://www.boost.org/sgi/stl/LessThanComparable.html">LessThanComparable</ulink>.
<ulink url="http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</ulink> and <ulink url="http://www.sgi.com/tech/stl/LessThanComparable.html">LessThanComparable</ulink>.
Detailed descriptions are provided here only for operations that are
not described in the <literal>multi_array</literal> reference.
</para>
@@ -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;
@@ -59,10 +60,7 @@ public:
template <std::size_t Dims> struct const_array_view;
static const std::size_t dimensionality = NumDims;
// constructors and destructors
// structors
template <typename ExtentList>
explicit multi_array_ref(element* data, const ExtentList& sizes,

View File

@@ -488,7 +488,7 @@ typedef *implementation_defined*<0> extent_gen;
<formalpara><title>Methods and Types</title>
<variablelist>
<varlistentry>
<term><function>template gen_type&lt;Ranges&gt;::type</function></term>
<term><function>template gen_type::&lt;Ranges&gt;::type</function></term>
<listitem>
<para>This type generator is used to specify the result of
<literal>Ranges</literal> chained calls to

View File

@@ -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<typename Array::element>(),A.begin(),A.end(),xform);
for_each(boost::type<Array::element>(),A.begin(),A.end(),xform);
}

View File

@@ -1,57 +0,0 @@
// 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';
}

View File

@@ -1,8 +1,5 @@
// Copyright 2002 The Trustees of Indiana University.
// Copyright 2018 Glen Joseph Fernandes
// (glenjofe@gmail.com)
// 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)
@@ -21,11 +18,6 @@
// declaration and definition
//
#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 406)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wshadow"
#endif
#include "boost/multi_array/base.hpp"
#include "boost/multi_array/collection_concept.hpp"
#include "boost/multi_array/copy_array.hpp"
@@ -33,8 +25,6 @@
#include "boost/multi_array/subarray.hpp"
#include "boost/multi_array/multi_array_ref.hpp"
#include "boost/multi_array/algorithm.hpp"
#include "boost/core/alloc_construct.hpp"
#include "boost/core/empty_value.hpp"
#include "boost/array.hpp"
#include "boost/mpl/if.hpp"
#include "boost/type_traits.hpp"
@@ -119,10 +109,8 @@ struct disable_multi_array_impl<int>
template<typename T, std::size_t NumDims,
typename Allocator>
class multi_array :
public multi_array_ref<T,NumDims>,
private boost::empty_value<Allocator>
public multi_array_ref<T,NumDims>
{
typedef boost::empty_value<Allocator> alloc_base;
typedef multi_array_ref<T,NumDims> super_type;
public:
typedef typename super_type::value_type value_type;
@@ -149,25 +137,22 @@ public:
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
};
explicit multi_array(const Allocator& alloc = Allocator()) :
explicit multi_array() :
super_type((T*)initial_base_,c_storage_order(),
/*index_bases=*/0, /*extents=*/0),
alloc_base(boost::empty_init_t(),alloc) {
/*index_bases=*/0, /*extents=*/0) {
allocate_space();
}
template <class ExtentList>
explicit multi_array(
ExtentList const& extents,
const Allocator& alloc = Allocator()
ExtentList const& extents
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
, typename mpl::if_<
detail::multi_array::is_multi_array_impl<ExtentList>,
int&,int>::type* = 0
#endif
) :
super_type((T*)initial_base_,extents),
alloc_base(boost::empty_init_t(),alloc) {
super_type((T*)initial_base_,extents) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
allocate_space();
@@ -177,8 +162,7 @@ public:
template <class ExtentList>
explicit multi_array(ExtentList const& extents,
const general_storage_order<NumDims>& so) :
super_type((T*)initial_base_,extents,so),
alloc_base(boost::empty_init_t()) {
super_type((T*)initial_base_,extents,so) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
allocate_space();
@@ -188,8 +172,7 @@ public:
explicit multi_array(ExtentList const& extents,
const general_storage_order<NumDims>& so,
Allocator const& alloc) :
super_type((T*)initial_base_,extents,so),
alloc_base(boost::empty_init_t(),alloc) {
super_type((T*)initial_base_,extents,so), allocator_(alloc) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
allocate_space();
@@ -197,10 +180,8 @@ public:
explicit multi_array(const detail::multi_array
::extent_gen<NumDims>& ranges,
const Allocator& alloc = Allocator()) :
super_type((T*)initial_base_,ranges),
alloc_base(boost::empty_init_t(),alloc) {
::extent_gen<NumDims>& ranges) :
super_type((T*)initial_base_,ranges) {
allocate_space();
}
@@ -209,8 +190,7 @@ public:
explicit multi_array(const detail::multi_array
::extent_gen<NumDims>& ranges,
const general_storage_order<NumDims>& so) :
super_type((T*)initial_base_,ranges,so),
alloc_base(boost::empty_init_t()) {
super_type((T*)initial_base_,ranges,so) {
allocate_space();
}
@@ -220,15 +200,13 @@ public:
::extent_gen<NumDims>& ranges,
const general_storage_order<NumDims>& so,
Allocator const& alloc) :
super_type((T*)initial_base_,ranges,so),
alloc_base(boost::empty_init_t(),alloc) {
super_type((T*)initial_base_,ranges,so), allocator_(alloc) {
allocate_space();
}
multi_array(const multi_array& rhs) :
super_type(rhs),
alloc_base(static_cast<const alloc_base&>(rhs)) {
super_type(rhs), allocator_(rhs.allocator_) {
allocate_space();
boost::detail::multi_array::copy_n(rhs.base_,rhs.num_elements(),base_);
}
@@ -245,10 +223,8 @@ public:
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
template <typename OPtr>
multi_array(const const_multi_array_ref<T,NumDims,OPtr>& rhs,
const general_storage_order<NumDims>& so = c_storage_order(),
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so = c_storage_order())
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
// Warning! storage order may change, hence the following copy technique.
@@ -258,10 +234,8 @@ public:
template <typename OPtr>
multi_array(const detail::multi_array::
const_sub_array<T,NumDims,OPtr>& rhs,
const general_storage_order<NumDims>& so = c_storage_order(),
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so = c_storage_order())
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -271,10 +245,8 @@ public:
template <typename OPtr>
multi_array(const detail::multi_array::
const_multi_array_view<T,NumDims,OPtr>& rhs,
const general_storage_order<NumDims>& so = c_storage_order(),
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so = c_storage_order())
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -284,10 +256,8 @@ public:
// More limited support for MSVC
multi_array(const const_multi_array_ref<T,NumDims>& rhs,
const Allocator& alloc = Allocator())
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
multi_array(const const_multi_array_ref<T,NumDims>& rhs)
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
{
allocate_space();
// Warning! storage order may change, hence the following copy technique.
@@ -295,10 +265,8 @@ public:
}
multi_array(const const_multi_array_ref<T,NumDims>& rhs,
const general_storage_order<NumDims>& so,
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so)
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
// Warning! storage order may change, hence the following copy technique.
@@ -306,10 +274,8 @@ public:
}
multi_array(const detail::multi_array::
const_sub_array<T,NumDims>& rhs,
const Allocator& alloc = Allocator())
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const_sub_array<T,NumDims>& rhs)
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -317,10 +283,8 @@ public:
multi_array(const detail::multi_array::
const_sub_array<T,NumDims>& rhs,
const general_storage_order<NumDims>& so,
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so)
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -328,10 +292,8 @@ public:
multi_array(const detail::multi_array::
const_multi_array_view<T,NumDims>& rhs,
const Allocator& alloc = Allocator())
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const_multi_array_view<T,NumDims>& rhs)
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -339,10 +301,8 @@ public:
multi_array(const detail::multi_array::
const_multi_array_view<T,NumDims>& rhs,
const general_storage_order<NumDims>& so,
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so)
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -351,10 +311,8 @@ public:
#endif // !BOOST_NO_FUNCTION_TEMPLATE_ORDERING
// Thes constructors are necessary because of more exact template matches.
multi_array(const multi_array_ref<T,NumDims>& rhs,
const Allocator& alloc = Allocator())
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
multi_array(const multi_array_ref<T,NumDims>& rhs)
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
{
allocate_space();
// Warning! storage order may change, hence the following copy technique.
@@ -362,10 +320,8 @@ public:
}
multi_array(const multi_array_ref<T,NumDims>& rhs,
const general_storage_order<NumDims>& so,
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so)
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
// Warning! storage order may change, hence the following copy technique.
@@ -374,10 +330,8 @@ public:
multi_array(const detail::multi_array::
sub_array<T,NumDims>& rhs,
const Allocator& alloc = Allocator())
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
sub_array<T,NumDims>& rhs)
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -385,10 +339,8 @@ public:
multi_array(const detail::multi_array::
sub_array<T,NumDims>& rhs,
const general_storage_order<NumDims>& so,
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so)
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -396,10 +348,8 @@ public:
multi_array(const detail::multi_array::
multi_array_view<T,NumDims>& rhs,
const Allocator& alloc = Allocator())
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
multi_array_view<T,NumDims>& rhs)
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -407,10 +357,8 @@ public:
multi_array(const detail::multi_array::
multi_array_view<T,NumDims>& rhs,
const general_storage_order<NumDims>& so,
const Allocator& alloc = Allocator())
: super_type(0,so,rhs.index_bases(),rhs.shape()),
alloc_base(boost::empty_init_t(),alloc)
const general_storage_order<NumDims>& so)
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
@@ -455,7 +403,7 @@ public:
// build a multi_array with the specs given
multi_array new_array(ranges,this->storage_order(),allocator());
multi_array new_array(ranges,this->storage_order());
// build a view of tmp with the minimum extents
@@ -481,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
@@ -501,7 +449,6 @@ public:
using std::swap;
// Swap the internals of these arrays.
swap(this->super_type::base_,new_array.super_type::base_);
swap(this->allocator(),new_array.allocator());
swap(this->storage_,new_array.storage_);
swap(this->extent_list_,new_array.extent_list_);
swap(this->stride_list_,new_array.stride_list_);
@@ -509,6 +456,7 @@ public:
swap(this->origin_offset_,new_array.origin_offset_);
swap(this->directional_offset_,new_array.directional_offset_);
swap(this->num_elements_,new_array.num_elements_);
swap(this->allocator_,new_array.allocator_);
swap(this->base_,new_array.base_);
swap(this->allocated_elements_,new_array.allocated_elements_);
@@ -521,43 +469,26 @@ public:
}
private:
friend inline bool operator==(const multi_array& a, const multi_array& b) {
return a.base() == b.base();
}
friend inline bool operator!=(const multi_array& a, const multi_array& b) {
return !(a == b);
}
const super_type& base() const {
return *this;
}
const Allocator& allocator() const {
return alloc_base::get();
}
Allocator& allocator() {
return alloc_base::get();
}
void allocate_space() {
base_ = allocator().allocate(this->num_elements());
typename Allocator::const_pointer no_hint=0;
base_ = allocator_.allocate(this->num_elements(),no_hint);
this->set_base_ptr(base_);
allocated_elements_ = this->num_elements();
boost::alloc_construct_n(allocator(),base_,allocated_elements_);
std::uninitialized_fill_n(base_,allocated_elements_,T());
}
void deallocate_space() {
if(base_) {
boost::alloc_destroy_n(allocator(),base_,allocated_elements_);
allocator().deallocate(base_,allocated_elements_);
for(T* i = base_; i != base_+allocated_elements_; ++i)
allocator_.destroy(i);
allocator_.deallocate(base_,allocated_elements_);
}
}
typedef boost::array<size_type,NumDims> size_list;
typedef boost::array<index,NumDims> index_list;
Allocator allocator_;
T* base_;
size_type allocated_elements_;
enum {initial_base_ = 0};
@@ -565,8 +496,4 @@ private:
} // namespace boost
#if defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 406)
# pragma GCC diagnostic pop
#endif
#endif // BOOST_MULTI_ARRAY_RG071801_HPP

View File

@@ -40,7 +40,7 @@
// See http://www.boost.org/libs/multi_array for documentation.
#include <iterator>
#include "boost/iterator.hpp"
namespace boost {
namespace detail {

View File

@@ -29,6 +29,7 @@
#include "boost/mpl/eval_if.hpp"
#include "boost/mpl/if.hpp"
#include "boost/mpl/size_t.hpp"
#include "boost/mpl/aux_/msvc_eti_base.hpp"
#include "boost/iterator/reverse_iterator.hpp"
#include "boost/static_assert.hpp"
#include "boost/type.hpp"
@@ -64,7 +65,7 @@ namespace multi_array_types {
// object creation in small-memory environments. Thus, the objects
// can be left undefined by defining BOOST_MULTI_ARRAY_NO_GENERATORS
// before loading multi_array.hpp.
#ifndef BOOST_MULTI_ARRAY_NO_GENERATORS
#if !BOOST_MULTI_ARRAY_NO_GENERATORS
namespace {
multi_array_types::extent_gen extents;
multi_array_types::index_gen indices;
@@ -80,8 +81,7 @@ 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,
typename IteratorCategory>
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator;
template <typename T, std::size_t NumDims, typename TPtr = const T*>
@@ -209,28 +209,49 @@ struct value_accessor_generator {
>::type type;
};
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
struct eti_value_accessor
{
typedef int index;
typedef int size_type;
typedef int element;
typedef int index_range;
typedef int value_type;
typedef int reference;
typedef int const_reference;
};
template <>
struct value_accessor_generator<int,int>
{
typedef eti_value_accessor type;
};
template <class T, class NumDims>
struct associated_types
: mpl::aux::msvc_eti_base<
typename value_accessor_generator<T,NumDims>::type
>::type
{};
template <>
struct associated_types<int,int> : eti_value_accessor {};
#else
template <class T, class NumDims>
struct associated_types
: value_accessor_generator<T,NumDims>::type
{};
#endif
//
// 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
@@ -238,7 +259,13 @@ struct mutable_iterator_tag
template <typename T, std::size_t NumDims>
class multi_array_impl_base
:
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
public mpl::aux::msvc_eti_base<
typename value_accessor_generator<T,mpl::size_t<NumDims> >::type
>::type
#else
public value_accessor_generator<T,mpl::size_t<NumDims> >::type
#endif
{
typedef associated_types<T,mpl::size_t<NumDims> > types;
public:
@@ -274,16 +301,8 @@ public:
//
// iterator support
//
#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 array_iterator<T,T*,mpl::size_t<NumDims>,reference> iterator;
typedef array_iterator<T,T const*,mpl::size_t<NumDims>,const_reference> const_iterator;
typedef ::boost::reverse_iterator<iterator> reverse_iterator;
typedef ::boost::reverse_iterator<const_iterator> const_reverse_iterator;
@@ -302,8 +321,7 @@ 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)
@@ -314,15 +332,9 @@ protected:
#endif
index offset = 0;
{
typename IndexList::const_iterator i = indices.begin();
size_type n = 0;
while (n != NumDims) {
offset += (*i) * strides[n];
++n;
++i;
}
}
for (size_type n = 0; n != NumDims; ++n)
offset += indices[n] * strides[n];
return base[offset];
}
@@ -419,53 +431,19 @@ 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 stride = current_range.stride();
BOOST_ASSERT(stride != 0);
index index_factor = current_range.stride();
index len = (finish - start + (index_factor - 1)) / index_factor;
// 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])) ||
(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)));
ignore_unused_variable_warning(bound_adjustment);
#endif // BOOST_DISABLE_ASSERTS
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);
// the array data pointer is modified to account for non-zero
// bases during slicing (see [Garcia] for the math involved)
@@ -473,9 +451,9 @@ protected:
if (!current_range.is_degenerate()) {
// The stride for each dimension is included into the
// The index_factor for each dimension is included into the
// strides for the array_view (see [Garcia] for the math involved).
new_strides[dim] = stride * strides[n];
new_strides[dim] = index_factor * strides[n];
// calculate new extents
new_extents[dim] = len;

View File

@@ -17,10 +17,46 @@
namespace boost {
namespace detail {
namespace multi_array { // Old location for this
using boost::CollectionConcept;
}
}
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;
};
}
}
}
#endif // COLLECTION_CONCEPT_RG103101_HPP

View File

@@ -22,9 +22,9 @@
#include "boost/iterator/iterator_concepts.hpp"
namespace boost {
namespace multi_array_concepts {
namespace detail {
namespace multi_array {
//
// idgen_helper -
// This is a helper for generating index_gen instantiations with
@@ -39,6 +39,8 @@ namespace detail {
template <typename Array, typename IdxGen, typename Call_Type>
static void call(Array& a, const IdxGen& idgen, Call_Type c) {
typedef typename Array::index_range index_range;
typedef typename Array::index index;
idgen_helper<N-1>::call(a,idgen[c],c);
}
};
@@ -48,12 +50,12 @@ namespace detail {
template <typename Array, typename IdxGen, typename Call_Type>
static void call(Array& a, const IdxGen& idgen, Call_Type) {
typedef typename Array::index_range index_range;
typedef typename Array::index index;
a[ idgen ];
}
};
} // namespace detail
template <typename Array, std::size_t NumDims >
struct ConstMultiArrayConcept
@@ -68,14 +70,13 @@ namespace detail {
// RG - a( CollectionArchetype) when available...
a[ id ];
// Test slicing, keeping only the first dimension, losing the rest
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
idgen_helper<NumDims-1>::call(a,idgen[range],id);
// Test slicing, keeping all dimensions.
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
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();
@@ -127,16 +128,15 @@ namespace detail {
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
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
idgen_helper<NumDims-1>::call(a,idgen[range],id);
// Test slicing, keeping all dimensions.
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
idgen_helper<NumDims-1>::call(a,idgen[range],range);
st = a.size();
st = a.num_dimensions();
@@ -157,10 +157,10 @@ namespace detail {
// value_type vt = a[ id ];
// Test slicing, keeping only the first dimension, losing the rest
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
idgen_helper<NumDims-1>::call(a,idgen[range],id);
// Test slicing, keeping all dimensions.
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
idgen_helper<NumDims-1>::call(a,idgen[range],range);
st = a.size();
st = a.num_dimensions();
@@ -207,14 +207,7 @@ namespace detail {
} // namespace multi_array
namespace detail {
namespace multi_array { // Old locations for these
using boost::multi_array_concepts::ConstMultiArrayConcept;
using boost::multi_array_concepts::MutableMultiArrayConcept;
}
}
} // namespace detail
} // namespace boost

View File

@@ -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>::

View File

@@ -107,12 +107,6 @@ namespace multi_array {
index stride() const { return stride_; }
size_type size(index idx) const
{
return (start_ == from_start() || finish_ == to_end())
? idx : ((finish_ - start_) / stride_);
}
void set_index_range(index start, index finish, index stride=1)
{
start_ = start;

View File

@@ -20,6 +20,7 @@
#include "boost/multi_array/base.hpp"
#include "boost/iterator/iterator_facade.hpp"
#include "boost/mpl/aux_/msvc_eti_base.hpp"
#include <algorithm>
#include <cstddef>
#include <iterator>
@@ -43,28 +44,32 @@ struct operator_arrow_proxy
mutable T value_;
};
template <typename T, typename TPtr, typename NumDims, typename Reference,
typename IteratorCategory>
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator;
template <typename T, typename TPtr, typename NumDims, typename Reference,
typename IteratorCategory>
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator
: public
iterator_facade<
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
array_iterator<T,TPtr,NumDims,Reference>
, typename associated_types<T,NumDims>::value_type
, IteratorCategory
, boost::random_access_traversal_tag
, Reference
>
, private
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
mpl::aux::msvc_eti_base<typename
#endif
value_accessor_generator<T,NumDims>::type
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
>::type
#endif
{
friend class ::boost::iterator_core_access;
friend class iterator_core_access;
typedef detail::multi_array::associated_types<T,NumDims> access_t;
typedef iterator_facade<
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
array_iterator<T,TPtr,NumDims,Reference>
, typename detail::multi_array::associated_types<T,NumDims>::value_type
, boost::random_access_traversal_tag
, Reference
@@ -74,7 +79,7 @@ class array_iterator
typedef typename access_t::size_type size_type;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
template <typename, typename, typename, typename, typename>
template <typename, typename, typename, typename>
friend class array_iterator;
#else
public:
@@ -100,9 +105,9 @@ public:
idx_(idx), base_(base), extents_(extents),
strides_(strides), index_base_(index_base) { }
template <typename OPtr, typename ORef, typename Cat>
template <typename OPtr, typename ORef>
array_iterator(
const array_iterator<T,OPtr,NumDims,ORef,Cat>& rhs
const array_iterator<T,OPtr,NumDims,ORef>& rhs
, typename boost::enable_if_convertible<OPtr,TPtr>::type* = 0
)
: idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),

View File

@@ -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<
CollectionConcept<ExtentList> >();
detail::multi_array::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<
CollectionConcept<ExtentList> >();
detail::multi_array::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<
CollectionConcept<BaseList> >();
detail::multi_array::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<
CollectionConcept<SizeList> >();
BOOST_ASSERT(num_elements_ ==
std::accumulate(extents.begin(),extents.end(),
size_type(1),std::multiplies<size_type>()));
detail::multi_array::CollectionConcept<SizeList> >();
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<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<const element&>(),
indices,origin(),
shape(),strides(),index_bases());
@@ -225,7 +225,11 @@ public:
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const detail::multi_array::
index_gen<NumDims,NDims>& indices)
@@ -445,7 +449,7 @@ public:
explicit multi_array_ref(T* base, const ExtentList& extents) :
super_type(base,extents) {
boost::function_requires<
CollectionConcept<ExtentList> >();
detail::multi_array::CollectionConcept<ExtentList> >();
}
template <class ExtentList>
@@ -453,7 +457,7 @@ public:
const general_storage_order<NumDims>& so) :
super_type(base,extents,so) {
boost::function_requires<
CollectionConcept<ExtentList> >();
detail::multi_array::CollectionConcept<ExtentList> >();
}
@@ -475,13 +479,13 @@ public:
template <typename ConstMultiArray>
multi_array_ref& operator=(const ConstMultiArray& other) {
function_requires<
multi_array_concepts::
detail::multi_array::
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;
@@ -491,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());
}
@@ -508,7 +511,7 @@ public:
template <class IndexList>
element& operator()(const IndexList& indices) {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
indices,origin(),
this->shape(),this->strides(),
@@ -525,7 +528,11 @@ public:
// See note attached to generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename array_view<NDims>::type
operator[](const detail::multi_array::
index_gen<NumDims,NDims>& indices) {
@@ -571,7 +578,7 @@ public:
template <class IndexList>
const element& operator()(const IndexList& indices) const {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::operator()(indices);
}
@@ -583,7 +590,11 @@ public:
}
// See note attached to generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const detail::multi_array::
index_gen<NumDims,NDims>& indices)

View File

@@ -80,14 +80,18 @@ public:
template <typename IndexList>
const element& operator()(const IndexList& indices) const {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<const element&>(),
indices,origin(),
shape(),strides(),index_bases());
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices)
@@ -227,13 +231,13 @@ public:
// Assignment from other ConstMultiArray types.
template <typename ConstMultiArray>
sub_array& operator=(const ConstMultiArray& other) {
function_requires< boost::multi_array_concepts::ConstMultiArrayConcept<
function_requires< boost::detail::multi_array::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;
@@ -243,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());
}
@@ -263,7 +266,11 @@ public:
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices) {
@@ -280,7 +287,7 @@ public:
template <class IndexList>
element& operator()(const IndexList& indices) {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
indices,origin(),
this->shape(),this->strides(),
@@ -315,7 +322,7 @@ public:
template <class IndexList>
const element& operator()(const IndexList& indices) const {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::operator()(indices);
}
@@ -324,7 +331,11 @@ public:
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices)

View File

@@ -24,7 +24,6 @@
#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>
@@ -82,7 +81,7 @@ public:
#endif
reindex(const BaseList& values) {
boost::function_requires<
CollectionConcept<BaseList> >();
detail::multi_array::CollectionConcept<BaseList> >();
boost::detail::multi_array::
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
origin_offset_ =
@@ -120,7 +119,7 @@ public:
template <typename IndexList>
const element& operator()(IndexList indices) const {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<const element&>(),
indices,origin(),
shape(),strides(),index_bases());
@@ -135,7 +134,11 @@ public:
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices)
@@ -241,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;
@@ -294,13 +300,13 @@ public:
template <typename ConstMultiArray>
multi_array_view& operator=(const ConstMultiArray& other) {
function_requires<
boost::multi_array_concepts::
boost::detail::multi_array::
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;
@@ -310,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());
}
@@ -325,7 +330,7 @@ public:
template <class IndexList>
element& operator()(const IndexList& indices) {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
indices,origin(),
this->shape(),this->strides(),
@@ -342,7 +347,11 @@ public:
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices) {
@@ -385,7 +394,7 @@ public:
template <class IndexList>
const element& operator()(const IndexList& indices) const {
boost::function_requires<
CollectionConcept<IndexList> >();
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::operator()(indices);
}
@@ -394,7 +403,11 @@ public:
}
// see generate_array_view in base.hpp
#if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
template <int NDims>
#else
template <int NumDims, int NDims> // else ICE
#endif // BOOST_MSVC
typename const_array_view<NDims>::type
operator[](const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices)

View File

@@ -1,15 +0,0 @@
{
"key": "multi_array",
"name": "Multi-Array",
"authors": [
"Ron Garcia"
],
"description": "Boost.MultiArray provides a generic N-dimensional array concept definition and common implementations of that interface.",
"category": [
"Containers",
"Math"
],
"maintainers": [
"Ronald Garcia <garcia -at- osl.iu.edu>"
]
}

View File

@@ -4,48 +4,44 @@
# "as is" without express or implied warranty, and with no claim as
# to its suitability for any purpose.
import testing ;
compile-fail fail_cbracket.cpp ;
compile-fail fail_cdata.cpp ;
compile-fail fail_citerator.cpp ;
compile-fail fail_cparen.cpp ;
compile-fail fail_criterator.cpp ;
compile-fail fail_csubarray.cpp ;
compile-fail fail_csubarray2.cpp ;
compile-fail fail_csubarray3.cpp ;
compile-fail fail_cview.cpp ;
compile-fail fail_cview2.cpp ;
compile-fail fail_cview3.cpp ;
compile-fail fail_ref_cbracket.cpp ;
compile-fail fail_ref_cdata.cpp ;
compile-fail fail_ref_citerator.cpp ;
compile-fail fail_ref_cparen.cpp ;
compile-fail fail_ref_criterator.cpp ;
compile-fail fail_ref_csubarray.cpp ;
compile-fail fail_ref_csubarray2.cpp ;
compile-fail fail_ref_csubarray3.cpp ;
compile-fail fail_ref_cview.cpp ;
compile-fail fail_ref_cview2.cpp ;
compile-fail fail_ref_cview3.cpp ;
test-suite multi_array
:
[ compile-fail fail_cbracket.cpp ]
[ compile-fail fail_cdata.cpp ]
[ compile-fail fail_citerator.cpp ]
[ compile-fail fail_cparen.cpp ]
[ compile-fail fail_criterator.cpp ]
[ compile-fail fail_csubarray.cpp ]
[ compile-fail fail_csubarray2.cpp ]
[ compile-fail fail_csubarray3.cpp ]
[ compile-fail fail_cview.cpp ]
[ compile-fail fail_cview2.cpp ]
[ compile-fail fail_cview3.cpp ]
[ compile-fail fail_ref_cbracket.cpp ]
[ compile-fail fail_ref_cdata.cpp ]
[ compile-fail fail_ref_citerator.cpp ]
[ compile-fail fail_ref_cparen.cpp ]
[ compile-fail fail_ref_criterator.cpp ]
[ compile-fail fail_ref_csubarray.cpp ]
[ compile-fail fail_ref_csubarray2.cpp ]
[ compile-fail fail_ref_csubarray3.cpp ]
[ compile-fail fail_ref_cview.cpp ]
[ compile-fail fail_ref_cview2.cpp ]
[ compile-fail fail_ref_cview3.cpp ]
run constructors.cpp ;
run access.cpp ;
run compare.cpp ;
run iterators.cpp ;
run slice.cpp ;
run assign.cpp ;
run assign_to_array.cpp ;
run index_bases.cpp ;
run storage_order_convert.cpp ;
run storage_order.cpp ;
run reshape.cpp ;
run range1.cpp ;
run idxgen1.cpp ;
run stl_interaction.cpp ;
run resize.cpp ;
run assert.cpp ;
run reverse_view.cpp ;
run allocators.cpp ;
compile concept_checks.cpp ;
[ run constructors.cpp ../../test/build//boost_test_exec_monitor ]
[ run access.cpp ../../test/build//boost_test_exec_monitor ]
[ run compare.cpp ../../test/build//boost_test_exec_monitor ]
[ run iterators.cpp ../../test/build//boost_test_exec_monitor ]
[ run slice.cpp ../../test/build//boost_test_exec_monitor ]
[ 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.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 ]
[ compile concept_checks.cpp ]
;

View File

@@ -16,7 +16,7 @@
//
#include "generative_tests.hpp"
#include <boost/static_assert.hpp>
#include "boost/static_assert.hpp"
template <typename Array>
void access(Array& A, const mutable_array_tag&) {
@@ -42,8 +42,8 @@ void access(Array& A, const const_array_tag&) {
for (index i = idx0; i != idx0+2; ++i)
for (index j = idx1; j != idx1+3; ++j)
for (index k = idx2; k != idx2+4; ++k) {
BOOST_TEST(A[i][j][k] == cnum++);
BOOST_TEST(CA[i][j][k] == A[i][j][k]);
BOOST_CHECK(A[i][j][k] == cnum++);
BOOST_CHECK(CA[i][j][k] == A[i][j][k]);
}
// operator()
@@ -52,12 +52,12 @@ void access(Array& A, const const_array_tag&) {
for (index k2 = idx2; k2 != idx2+4; ++k2) {
boost::array<index,ndims> indices;
indices[0] = i2; indices[1] = j2; indices[2] = k2;
BOOST_TEST(A(indices) == A[i2][j2][k2]);
BOOST_TEST(CA(indices) == A(indices));
BOOST_CHECK(A(indices) == A[i2][j2][k2]);
BOOST_CHECK(CA(indices) == A(indices));
}
++tests_run;
}
int main() {
int test_main(int,char*[]) {
return run_generative_tests();
}

View File

@@ -1,151 +0,0 @@
// Copyright 2019 Glen Joseph Fernandes
// (glenjofe@gmail.com)
//
// Distributed under 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)
#include <boost/core/lightweight_test.hpp>
#include <boost/multi_array.hpp>
#include <algorithm>
template<class T>
class creator {
public:
typedef T value_type;
typedef T* pointer;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator(int state)
: state_(state) { }
template<class U>
creator(const creator<U>& other)
: state_(other.state()) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
int state() const {
return state_;
}
private:
int state_;
};
template<class T, class U>
inline bool
operator==(const creator<T>& a, const creator<U>& b)
{
return a.state() == b.state();
}
template<class T, class U>
inline bool
operator!=(const creator<T>& a, const creator<U>& b)
{
return !(a == b);
}
void test(const double&, std::size_t*, int*, unsigned)
{
}
template<class Array>
void test(const Array& array, std::size_t* sizes, int* strides,
unsigned elements)
{
BOOST_TEST(array.num_elements() == elements);
BOOST_TEST(array.size() == *sizes);
BOOST_TEST(std::equal(sizes, sizes + array.num_dimensions(), array.shape()));
BOOST_TEST(std::equal(strides, strides + array.num_dimensions(),
array.strides()));
test(array[0], ++sizes, ++strides, elements / array.size());
}
bool test(const double& a, const double& b)
{
return a == b;
}
template<class A1, class A2>
bool test(const A1& a1, const A2& a2)
{
typename A1::const_iterator i1 = a1.begin();
typename A2::const_iterator i2 = a2.begin();
for (; i1 != a1.end(); ++i1, ++i2) {
if (!test(*i1, *i2)) {
return false;
}
}
return true;
}
int main()
{
typedef boost::multi_array<double, 3, creator<double> > type;
creator<double> state(1);
{
type array(state);
}
boost::array<type::size_type, 3> sizes = { { 3, 3, 3 } };
type::size_type elements = 27;
{
int strides[] = { 9, 3, 1 };
type array(sizes, state);
test(array, &sizes[0], strides, elements);
}
{
int strides[] = { 1, 3, 9 };
type array(sizes, boost::fortran_storage_order(), state);
test(array, &sizes[0], strides, elements);
}
{
int strides[] = { 9, 3, 1 };
type::extent_gen extents;
type array(extents[3][3][3], state);
test(array, &sizes[0], strides, elements);
}
{
type array1(sizes, state);
std::vector<double> values(elements, 4.5);
array1.assign(values.begin(), values.end());
type array2(array1);
int strides[] = { 9, 3, 1 };
test(array2, &sizes[0], strides, elements);
BOOST_TEST(test(array1, array2));
}
{
type array1(sizes, state);
type array2(sizes, state);
std::vector<double> values(elements, 4.5);
array1.assign(values.begin(), values.end());
array2 = array1;
int strides[] = { 9, 3, 1 };
test(array2, &sizes[0], strides, elements);
BOOST_TEST(test(array1, array2));
}
{
type array1(sizes, state);
std::vector<double> values(elements, 4.5);
array1.assign(values.begin(), values.end());
typedef type::subarray<2>::type other;
other array2 = array1[1];
other::value_type value = array2[0];
BOOST_TEST(test(array1[1][0], value));
BOOST_TEST(test(array2[0], value));
}
return boost::report_errors();
}

View File

@@ -1,59 +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/core/lightweight_test.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
main() {
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::report_errors();
}

View File

@@ -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,14 +10,14 @@
// 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>
#include <boost/multi_array.hpp>
#include <boost/cstdlib.hpp>
#include "boost/array.hpp"
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"
#include <algorithm>
#include <iostream>
@@ -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_TEST(::equal(A,filler));
BOOST_CHECK(equal(A,filler));
++tests_run;
}
@@ -68,6 +68,6 @@ void access(Array&, const const_array_tag&) {
}
int main() {
int test_main(int,char*[]) {
return run_generative_tests();
}

View File

@@ -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,15 +10,15 @@
// 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>
#include <boost/multi_array.hpp>
#include <boost/cstdlib.hpp>
#include "boost/array.hpp"
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"
#include <algorithm>
#include <iostream>
@@ -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,11 +50,11 @@ template <typename Array>
void access(Array& A, const const_array_tag&) {
typedef boost::multi_array<int,3> array3;
array3 acopy(A);
BOOST_TEST(::equal(acopy,A));
BOOST_CHECK(equal(acopy,A));
++tests_run;
}
int main() {
int test_main(int,char*[]) {
return run_generative_tests();
}

View File

@@ -12,16 +12,16 @@
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <algorithm>
#include <list>
int
main()
test_main(int, char*[])
{
typedef boost::multi_array<double, 3> array;
typedef array::size_type size_type;
@@ -34,9 +34,9 @@ main()
std::vector<double> vals(num_elements, 4.5);
A.assign(vals.begin(),vals.end());
array B(A);
BOOST_TEST(A == B);
BOOST_TEST(B == A);
BOOST_TEST(A[0] == B[0]);
BOOST_CHECK(A == B);
BOOST_CHECK(B == A);
BOOST_CHECK(A[0] == B[0]);
}
// Assignment Operator
{
@@ -44,15 +44,15 @@ main()
std::vector<double> vals(num_elements, 4.5);
A.assign(vals.begin(),vals.end());
B = A;
BOOST_TEST(A == B);
BOOST_TEST(B == A);
BOOST_TEST(B[0] == A[0]);
BOOST_CHECK(A == B);
BOOST_CHECK(B == A);
BOOST_CHECK(B[0] == A[0]);
typedef array::index_range range;
array::index_gen indices;
array::array_view<2>::type C = A[indices[2][range()][range()]];
array::array_view<2>::type D = B[indices[2][range()][range()]];
BOOST_TEST(C == D);
BOOST_CHECK(C == D);
}
// Different Arrays
{
@@ -62,15 +62,15 @@ main()
A.assign(valsA.begin(),valsA.end());
B.assign(valsB.begin(),valsB.end());
BOOST_TEST(A != B);
BOOST_TEST(B != A);
BOOST_TEST(A[0] != B[0]);
BOOST_CHECK(A != B);
BOOST_CHECK(B != A);
BOOST_CHECK(A[0] != B[0]);
typedef array::index_range range;
array::index_gen indices;
array::array_view<2>::type C = A[indices[2][range()][range()]];
array::array_view<2>::type D = B[indices[2][range()][range()]];
BOOST_TEST(C != D);
BOOST_CHECK(C != D);
}
// Comparisons galore!
@@ -108,35 +108,35 @@ main()
A.assign(valsA,valsA+num_elements);
B.assign(valsB,valsB+num_elements);
BOOST_TEST(B < A);
BOOST_TEST(A > B);
BOOST_CHECK(B < A);
BOOST_CHECK(A > B);
BOOST_TEST(B <= A);
BOOST_TEST(A >= B);
BOOST_CHECK(B <= A);
BOOST_CHECK(A >= B);
BOOST_TEST(B[0] == A[0]);
BOOST_TEST(B[2] < A[2]);
BOOST_CHECK(B[0] == A[0]);
BOOST_CHECK(B[2] < A[2]);
array C = A;
BOOST_TEST(C <= A);
BOOST_TEST(C >= A);
BOOST_CHECK(C <= A);
BOOST_CHECK(C >= A);
BOOST_TEST(!(C < A));
BOOST_TEST(!(C > A));
BOOST_CHECK(!(C < A));
BOOST_CHECK(!(C > A));
typedef array::index_range range;
array::index_gen indices;
array::array_view<2>::type D = A[indices[2][range()][range()]];
array::array_view<2>::type E = B[indices[2][range()][range()]];
BOOST_TEST(E < D);
BOOST_TEST(E <= D);
BOOST_CHECK(E < D);
BOOST_CHECK(E <= D);
}
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,18 +15,18 @@
// make sure the types meet concept requirements
//
#include <boost/concept_check.hpp>
#include <boost/multi_array/concept_checks.hpp>
#include <boost/multi_array.hpp>
#include "boost/concept_check.hpp"
#include "boost/multi_array/concept_checks.hpp"
#include "boost/multi_array.hpp"
#include <boost/cstdlib.hpp>
#include "boost/cstdlib.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include <boost/core/lightweight_test.hpp>
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -38,28 +38,28 @@ main()
typedef array::const_subarray<ndims>::type const_subarray;
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<array,ndims> >();
boost::detail::multi_array::ConstMultiArrayConcept<array,ndims> >();
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<array_ref,ndims> >();
boost::detail::multi_array::ConstMultiArrayConcept<array_ref,ndims> >();
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<const_array_ref,ndims> >();
boost::detail::multi_array::ConstMultiArrayConcept<const_array_ref,ndims> >();
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<array_view,ndims> >();
boost::detail::multi_array::ConstMultiArrayConcept<array_view,ndims> >();
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<const_array_view,ndims> >();
boost::detail::multi_array::ConstMultiArrayConcept<const_array_view,ndims> >();
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<subarray,ndims> >();
boost::detail::multi_array::ConstMultiArrayConcept<subarray,ndims> >();
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<const_subarray,ndims> >();
boost::detail::multi_array::ConstMultiArrayConcept<const_subarray,ndims> >();
boost::function_requires<
boost::multi_array_concepts::MutableMultiArrayConcept<array,ndims> >();
boost::detail::multi_array::MutableMultiArrayConcept<array,ndims> >();
boost::function_requires<
boost::multi_array_concepts::MutableMultiArrayConcept<array_ref,ndims> >();
boost::detail::multi_array::MutableMultiArrayConcept<array_ref,ndims> >();
boost::function_requires<
boost::multi_array_concepts::MutableMultiArrayConcept<array_view,ndims> >();
boost::detail::multi_array::MutableMultiArrayConcept<array_view,ndims> >();
boost::function_requires<
boost::multi_array_concepts::MutableMultiArrayConcept<subarray,ndims> >();
boost::detail::multi_array::MutableMultiArrayConcept<subarray,ndims> >();
return 0;
}

View File

@@ -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)
@@ -15,9 +15,9 @@
//
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <algorithm>
#include <list>
@@ -25,15 +25,15 @@ 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)
{
BOOST_TEST(A.num_elements() == num_elements);
BOOST_TEST(A.size() == *sizes);
BOOST_TEST(std::equal(sizes, sizes + A.num_dimensions(), A.shape()));
BOOST_TEST(std::equal(strides, strides + A.num_dimensions(), A.strides()));
BOOST_CHECK(A.num_elements() == num_elements);
BOOST_CHECK(A.size() == *sizes);
BOOST_CHECK(std::equal(sizes, sizes + A.num_dimensions(), A.shape()));
BOOST_CHECK(std::equal(strides, strides + A.num_dimensions(), A.strides()));
check_shape(A[0], ++sizes, ++strides, num_elements / A.size());
}
@@ -49,14 +49,14 @@ 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;
}
int
main()
test_main(int, char*[])
{
typedef boost::multi_array<double, 3>::size_type size_type;
boost::array<size_type,3> sizes = { { 3, 3, 3 } };
@@ -76,7 +76,7 @@ main()
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,20 +132,20 @@ main()
A.assign(vals.begin(),vals.end());
boost::multi_array<double, 3> B(A);
check_shape(B, &sizes[0], strides, num_elements);
BOOST_TEST(::equal(A, B));
BOOST_CHECK(equal(A, B));
double ptr[27];
boost::multi_array_ref<double, 3> C(ptr,sizes);
A.assign(vals.begin(),vals.end());
boost::multi_array_ref<double, 3> D(C);
check_shape(D, &sizes[0], strides, num_elements);
BOOST_TEST(C.data() == D.data());
BOOST_CHECK(C.data() == D.data());
const double* cptr = ptr;
boost::const_multi_array_ref<double, 3> E(cptr,sizes);
boost::const_multi_array_ref<double, 3> F(E);
check_shape(F, &sizes[0], strides, num_elements);
BOOST_TEST(E.data() == F.data());
BOOST_CHECK(E.data() == F.data());
}
@@ -161,15 +161,15 @@ main()
boost::const_multi_array_ref<double, 3> C(A);
check_shape(B, &sizes[0], strides, num_elements);
check_shape(C, &sizes[0], strides, num_elements);
BOOST_TEST(B.data() == A.data());
BOOST_TEST(C.data() == A.data());
BOOST_CHECK(B.data() == A.data());
BOOST_CHECK(C.data() == A.data());
double ptr[27];
boost::multi_array_ref<double, 3> D(ptr,sizes);
D.assign(vals.begin(),vals.end());
boost::const_multi_array_ref<double, 3> E(D);
check_shape(E, &sizes[0], strides, num_elements);
BOOST_TEST(E.data() == D.data());
BOOST_CHECK(E.data() == D.data());
}
// Assignment Operator
@@ -182,7 +182,7 @@ main()
A.assign(vals.begin(),vals.end());
B = A;
check_shape(B, &sizes[0], strides, num_elements);
BOOST_TEST(::equal(A, B));
BOOST_CHECK(equal(A, B));
double ptr1[27];
double ptr2[27];
@@ -190,12 +190,12 @@ main()
C.assign(vals.begin(),vals.end());
D = C;
check_shape(D, &sizes[0], strides, num_elements);
BOOST_TEST(::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,10 +209,10 @@ main()
subarray::value_type C = B[0];
// should comparisons between the types work?
BOOST_TEST(::equal(A[1][0],C));
BOOST_TEST(::equal(B[0],C));
BOOST_CHECK(equal(A[1][0],C));
BOOST_CHECK(equal(B[0],C));
}
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -13,9 +13,9 @@
//
// Trying to diagnose problems under visual
#include <boost/config.hpp>
#include <boost/array.hpp>
#include <boost/limits.hpp>
#include "boost/config.hpp"
#include "boost/array.hpp"
#include "boost/limits.hpp"
#include <algorithm>
#include <utility>

View File

@@ -15,14 +15,14 @@
// checking constness of const operator[].
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -36,5 +36,5 @@ main()
// FAIL! cannot assign to csma.
csma[0][0][0] = 5;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing data() member function constness.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -37,5 +37,5 @@ main()
// FAIL! data() returns a const int*
*csma.data() = 0;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,12 +15,12 @@
// const_iterator/iterator conversion test
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
int main() {
int test_main(int,char*[]) {
typedef boost::multi_array<int,3> array;
typedef array::iterator iterator1;
@@ -29,5 +29,5 @@ int main() {
// ILLEGAL conversion from const_iterator to iterator
iterator1 in = citerator1();
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing const operator() constness.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -40,5 +40,5 @@ main()
// FAIL! Cannot assign to csma
csma(indices) = 5;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,12 +15,12 @@
// const_reverse_iterator/reverse_iterator conversion test
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
int main() {
int test_main(int,char*[]) {
typedef boost::multi_array<int,3> array;
typedef array::reverse_iterator riterator1;
@@ -29,5 +29,5 @@ int main() {
// ILLEGAL conversion from const_reverse_iterator to reverse_iterator
riterator1 in = criterator1();
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing subarray and const_subarray assignment
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -42,5 +42,5 @@ main()
// FAIL! Preserve constness (no const_subarray -> subarray conversion).
array::subarray<ndims-1>::type sba = csba;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing constness of subarray operations.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -41,5 +41,5 @@ main()
// FAIL! preserve constness.
array::subarray<ndims-1>::type sba = sma_const[0];
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing constness of subarray operations.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -45,5 +45,5 @@ main()
// FAIL! sba cannot be assigned to.
sba[j][k] = num++;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,15 +15,15 @@
// ensure const_array_view doesn't allow element assignment.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include <boost/type.hpp>
#include "boost/array.hpp"
#include "boost/type.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -54,7 +54,7 @@ main()
// FAIL! const_array_view cannot be assigned to.
csma2(elmt) = 5;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,17 +15,16 @@
// ensure const_array_view cannot be converted to array_view
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#define BOOST_INCLUDE_MAIN
#include <boost/test/test_tools.hpp>
#include "boost/test/test_tools.hpp"
#include <boost/array.hpp>
#include <boost/type.hpp>
#include <boost/cstdlib.hpp>
#include "boost/array.hpp"
#include "boost/type.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -52,7 +51,7 @@ main()
array::array_view<ndims>::type csma2 =
csma[indices[range(0,2)][range(1,3)][range(0,4,2)]];
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,15 +15,15 @@
// ensure const_array_ref doesn't allow assignment.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include <boost/type.hpp>
#include "boost/array.hpp"
#include "boost/type.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -55,7 +55,7 @@ main()
// FAIL! csma2 cannot be assigned to.
csma2[i][j][k] = 0;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// checking constness of const operator[].
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -40,5 +40,5 @@ main()
// FAIL! can't assign to const multi_array_ref.
csma[0][0][0] = 5;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing data() member function constness.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -36,5 +36,5 @@ main()
// FAIL! data() returns const int*.
*csma.data() = 0;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,12 +15,12 @@
// const_iterator/iterator conversion test
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
int main() {
int test_main(int,char*[]) {
typedef boost::multi_array_ref<int,3> array_ref;
typedef array_ref::iterator iterator1;
@@ -29,5 +29,5 @@ int main() {
// FAIL! ILLEGAL conversion from const_iterator to iterator
iterator1 in = citerator1();
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing const operator() constness.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -40,5 +40,5 @@ main()
// FAIL! cannot assign to a const multi_array_ref
csma(indices) = 5;
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,12 +15,12 @@
// const_reverse_iterator/reverse_iterator conversion test
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
int main() {
int test_main(int,char*[]) {
typedef boost::multi_array_ref<int,3> array_ref;
typedef array_ref::reverse_iterator riterator1;
@@ -29,5 +29,5 @@ int main() {
// Fail! ILLEGAL conversion from const_reverse_iterator to reverse_iterator
riterator1 in = criterator1();
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing subarray and const_subarray assignment
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -44,5 +44,5 @@ main()
array_ref::subarray<ndims-1>::type sba = csba; // FAIL! preserve constness.
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing constness of subarray operations.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -45,5 +45,5 @@ main()
array_ref::subarray<ndims-1>::type sba = sma_const[0]; // FAIL!
// preserve constness
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,14 +15,14 @@
// Testing constness of subarray operations.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -48,5 +48,5 @@ main()
for (array_ref::index k = 0; k != 4; ++k)
sba[j][k] = num++; // FAIL! can't assign to const_subarray.
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,15 +15,15 @@
// ensure const_array_view doesn't allow element assignment.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include <boost/type.hpp>
#include "boost/array.hpp"
#include "boost/type.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -51,7 +51,7 @@ main()
csma2(elmt) = 5; // FAIL! csma is read only
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,15 +15,15 @@
// ensure const_array_view cannot be converted to array_view
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include <boost/type.hpp>
#include "boost/array.hpp"
#include "boost/type.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -52,7 +52,7 @@ main()
for (array_ref::index k = 0; k != 2; ++k)
csma2[i][j][k] = 0; // FAIL! csma2 is read only
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -15,15 +15,15 @@
// ensure const_array_view doesn't allow assignment.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include <boost/type.hpp>
#include "boost/array.hpp"
#include "boost/type.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array_ref<int,ndims> array_ref;
@@ -53,7 +53,7 @@ main()
for (array_ref::index k = 0; k != 2; ++k)
csma2[i][j][k] = 0; // FAIL! csma2 is read only.
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -45,9 +45,9 @@
//
// int test_main(int,char*[]) { return run_generative_tests(); }
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/config.hpp> /* BOOST_NO_SFINAE */
#include <algorithm>
@@ -100,7 +100,7 @@ template <typename Array>
void access(Array& A, const const_array_tag&);
template <typename StorageOrder3,typename StorageOrder4,typename Modifier>
void run_configuration(const StorageOrder3& so3,
int run_configuration(const StorageOrder3& so3,
const StorageOrder4& so4,
const Modifier& modifier) {
// multi_array
@@ -213,10 +213,11 @@ void run_configuration(const StorageOrder3& so3,
access(C,const_array_tag());
}
}
return boost::exit_success;
}
template <typename ArrayModifier>
void run_storage_tests(const ArrayModifier& modifier) {
int run_storage_tests(const ArrayModifier& modifier) {
run_configuration(boost::c_storage_order(),
boost::c_storage_order(),modifier);
run_configuration(boost::fortran_storage_order(),
@@ -227,6 +228,8 @@ void run_storage_tests(const ArrayModifier& modifier) {
run_configuration(boost::general_storage_order<3>(ordering,ascending),
boost::general_storage_order<4>(ordering,ascending),
modifier);
return boost::exit_success;
}
struct null_modifier {
@@ -276,7 +279,7 @@ int run_generative_tests() {
run_storage_tests(reindex_modifier());
run_storage_tests(reshape_modifier());
std::cout << "Total Tests Run: " << tests_run << '\n';
return boost::report_errors();
return boost::exit_success;
}
#endif // GENERATIVE_TESTS_RG072001_HPP

View File

@@ -14,12 +14,12 @@
// idxset1.cpp - testing the code for index_gen
//
#include <boost/multi_array/index_gen.hpp>
#include <boost/multi_array/index_range.hpp>
#include <boost/multi_array/types.hpp>
#include <boost/core/lightweight_test.hpp>
#include "boost/multi_array/index_gen.hpp"
#include "boost/multi_array/index_range.hpp"
#include "boost/multi_array/types.hpp"
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
typedef boost::detail::multi_array::index index_type;
typedef boost::detail::multi_array::size_type size_type;
@@ -37,7 +37,7 @@ bool operator==(const range& lhs,const range& rhs) {
}
int
main()
test_main(int,char*[])
{
boost::detail::multi_array::index_gen<0,0> indices;
@@ -62,20 +62,20 @@ main()
{
boost::detail::multi_array::index_gen<3,3> is1 =
indices[range(0,1,2)][range(1,2,3)][range(2,3,4)];
BOOST_TEST(is1.ranges_[0] == range(0,1,2));
BOOST_TEST(is1.ranges_[1] == range(1,2,3));
BOOST_TEST(is1.ranges_[2] == range(2,3,4));
BOOST_CHECK(is1.ranges_[0] == range(0,1,2));
BOOST_CHECK(is1.ranges_[1] == range(1,2,3));
BOOST_CHECK(is1.ranges_[2] == range(2,3,4));
}
{
boost::detail::multi_array::index_gen<3,2> is2 =
indices[range(0,1,2)][2][range(2,3,4)];
BOOST_TEST(is2.ranges_[0] == range(0,1,2));
BOOST_TEST(is2.ranges_[1] == range(2));
BOOST_TEST(is2.ranges_[1].is_degenerate());
BOOST_TEST(is2.ranges_[2] == range(2,3,4));
BOOST_CHECK(is2.ranges_[0] == range(0,1,2));
BOOST_CHECK(is2.ranges_[1] == range(2));
BOOST_CHECK(is2.ranges_[1].is_degenerate());
BOOST_CHECK(is2.ranges_[2] == range(2,3,4));
}
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -14,15 +14,15 @@
// index_bases - test of the index_base modifying facilities.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
#include <vector>
#include <iostream>
int
main()
test_main(int,char*[])
{
typedef boost::multi_array<double, 3> array;
typedef boost::multi_array_ref<double, 3> array_ref;
@@ -63,11 +63,11 @@ main()
for (size_type a = 0; a < A.shape()[0]; ++a)
for (size_type b = 0; b < A.shape()[1]; ++b)
for (size_type c = 0; c < A.shape()[2]; ++c) {
BOOST_TEST(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_TEST(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_TEST(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_CHECK(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_CHECK(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_CHECK(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
// Test that E does not inherit A's index_base
BOOST_TEST(E[a][b][c] == B[a][b][c]);
BOOST_CHECK(E[a][b][c] == B[a][b][c]);
}
}
@@ -100,10 +100,10 @@ main()
for (size_type a = 0; a < A.shape()[0]; ++a)
for (size_type b = 0; b < A.shape()[1]; ++b)
for (size_type c = 0; c < A.shape()[2]; ++c) {
BOOST_TEST(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_TEST(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_TEST(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_TEST(E[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_CHECK(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_CHECK(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_CHECK(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
BOOST_CHECK(E[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
}
}
@@ -142,12 +142,12 @@ main()
for (size_type a = 0; a < A.shape()[0]; ++a)
for (size_type b = 0; b < A.shape()[1]; ++b)
for (size_type c = 0; c < A.shape()[2]; ++c) {
BOOST_TEST(A[a+1][b+1][c+1] == B[a][b][c]);
BOOST_TEST(C[a+1][b+1][c+1] == B[a][b][c]);
BOOST_TEST(D[a+1][b+1][c+1] == B[a][b][c]);
BOOST_TEST(E[a+1][b+1][c+1] == B[a][b][c]);
BOOST_CHECK(A[a+1][b+1][c+1] == B[a][b][c]);
BOOST_CHECK(C[a+1][b+1][c+1] == B[a][b][c]);
BOOST_CHECK(D[a+1][b+1][c+1] == B[a][b][c]);
BOOST_CHECK(E[a+1][b+1][c+1] == B[a][b][c]);
}
}
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -17,9 +17,9 @@
#define MULTIARRAY_TEST_ASSIGN
#include "generative_tests.hpp"
#include <boost/concept_check.hpp> // for ignore_unused_variable_warning
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include "boost/concept_check.hpp" // for ignore_unused_variable_warning
#include "boost/mpl/if.hpp"
#include "boost/type_traits/is_same.hpp"
// iterator-test-specific code
@@ -107,8 +107,8 @@ void test_iterators(Array& A, const IterTraits&) {
typedef typename IterTraits::iterator3 iterator;
iterator i1 = A.begin();
iterator i2 = A.end();
BOOST_TEST(i1 < i2);
BOOST_TEST((i2 - i1) == typename iterator::difference_type(2));
BOOST_CHECK(i1 < i2);
BOOST_CHECK((i2 - i1) == typename iterator::difference_type(2));
}
// Standard Array Iteration
@@ -121,7 +121,7 @@ void test_iterators(Array& A, const IterTraits&) {
for (iterator3 i = A.begin(); i != A.end(); ++i)
for(iterator2 ii = (*i).begin(); ii != (*i).end(); ++ii)
for(iterator1 iii = (*ii).begin(); iii != (*ii).end(); ++iii)
BOOST_TEST(*iii == vals++);
BOOST_CHECK(*iii == vals++);
}
// Using operator->() on iterators
@@ -134,7 +134,7 @@ void test_iterators(Array& A, const IterTraits&) {
for (iterator3 i = A.begin(); i != A.end(); ++i)
for(iterator2 ii = i->begin(); ii != i->end(); ++ii)
for(iterator1 iii = ii->begin(); iii != ii->end(); ++iii)
BOOST_TEST(*iii == vals++);
BOOST_CHECK(*iii == vals++);
}
// Reverse Iterator Hierarchy Test
@@ -148,7 +148,7 @@ void test_iterators(Array& A, const IterTraits&) {
for(riterator2 ii = (*i).rbegin(); ii != (riterator2)(*i).rend(); ++ii)
for(riterator1 iii = (*ii).rbegin(); iii != (riterator1)(*ii).rend();
++iii)
BOOST_TEST(*iii == check_iter_val--);
BOOST_CHECK(*iii == check_iter_val--);
}
++tests_run;
}
@@ -182,7 +182,7 @@ void access(Array& A, const const_array_tag&) {
int
main()
test_main(int, char*[])
{
return run_generative_tests();
}

View File

@@ -15,100 +15,91 @@
//
#include <boost/multi_array/index_range.hpp>
#include "boost/multi_array/index_range.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
#include <cstddef>
int
main()
test_main(int,char*[])
{
typedef boost::detail::multi_array::index_range<int,std::size_t> range;
{
// typical range creation and extraction
range r1(-3,5);
BOOST_TEST(r1.start() == -3);
BOOST_TEST(r1.finish() == 5);
BOOST_TEST(r1.stride() == 1);
BOOST_TEST(r1.size(0) == 8);
BOOST_TEST(!r1.is_degenerate());
BOOST_TEST(r1.get_start(0) == -3);
BOOST_TEST(r1.get_finish(100) == 5);
BOOST_CHECK(r1.start() == -3);
BOOST_CHECK(r1.finish() == 5);
BOOST_CHECK(r1.stride() == 1);
BOOST_CHECK(!r1.is_degenerate());
BOOST_CHECK(r1.get_start(0) == -3);
BOOST_CHECK(r1.get_finish(100) == 5);
}
{
range r2(-3,5,2);
BOOST_TEST(r2.start() == -3);
BOOST_TEST(r2.finish() == 5);
BOOST_TEST(r2.stride() == 2);
BOOST_TEST(r2.size(0) == 4);
BOOST_TEST(!r2.is_degenerate());
BOOST_CHECK(r2.start() == -3);
BOOST_CHECK(r2.finish() == 5);
BOOST_CHECK(r2.stride() == 2);
BOOST_CHECK(!r2.is_degenerate());
}
{
// degenerate creation
range r3(5);
BOOST_TEST(r3.start() == 5);
BOOST_TEST(r3.finish() == 6);
BOOST_TEST(r3.stride() == 1);
BOOST_TEST(r3.size(0) == 1);
BOOST_TEST(r3.is_degenerate());
BOOST_CHECK(r3.start() == 5);
BOOST_CHECK(r3.finish() == 6);
BOOST_CHECK(r3.stride() == 1);
BOOST_CHECK(r3.is_degenerate());
}
{
// default range creation
range r4;
BOOST_TEST(r4.get_start(0) == 0);
BOOST_TEST(r4.get_finish(100) == 100);
BOOST_TEST(r4.stride() == 1);
BOOST_TEST(r4.size(0) == 0);
BOOST_CHECK(r4.get_start(0) == 0);
BOOST_CHECK(r4.get_finish(100) == 100);
BOOST_CHECK(r4.stride() == 1);
}
{
// create a range using the setter methods
range r5 = range().stride(2).start(-3).finish(7);
BOOST_TEST(r5.start() == -3);
BOOST_TEST(r5.stride() == 2);
BOOST_TEST(r5.finish() == 7);
BOOST_TEST(r5.size(0) == 5);
BOOST_CHECK(r5.start() == -3);
BOOST_CHECK(r5.stride() == 2);
BOOST_CHECK(r5.finish() == 7);
}
// try out all the comparison operators
{
range r6 = -3 <= range().stride(2) < 7;
BOOST_TEST(r6.start() == -3);
BOOST_TEST(r6.stride() == 2);
BOOST_TEST(r6.finish() == 7);
BOOST_TEST(r6.size(0) == 5);
BOOST_CHECK(r6.start() == -3);
BOOST_CHECK(r6.stride() == 2);
BOOST_CHECK(r6.finish() == 7);
}
{
range r7 = -3 < range() <= 7;
BOOST_TEST(r7.start() == -2);
BOOST_TEST(r7.stride() == 1);
BOOST_TEST(r7.finish() == 8);
BOOST_TEST(r7.size(0) == 10);
BOOST_CHECK(r7.start() == -2);
BOOST_CHECK(r7.stride() == 1);
BOOST_CHECK(r7.finish() == 8);
}
// arithmetic operators
{
range r8 = range(0,5) + 2;
BOOST_TEST(r8.start() == 2);
BOOST_TEST(r8.stride() == 1);
BOOST_TEST(r8.finish() == 7);
BOOST_TEST(r8.size(0) == 5);
BOOST_CHECK(r8.start() == 2);
BOOST_CHECK(r8.stride() == 1);
BOOST_CHECK(r8.finish() == 7);
}
{
range r9 = range(0,5) - 2;
BOOST_TEST(r9.start() == -2);
BOOST_TEST(r9.stride() == 1);
BOOST_TEST(r9.finish() == 3);
BOOST_TEST(r9.size(0) == 5);
BOOST_CHECK(r9.start() == -2);
BOOST_CHECK(r9.stride() == 1);
BOOST_CHECK(r9.finish() == 3);
}
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -14,15 +14,15 @@
// reshape.cpp - testing reshaping functionality
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include <boost/type.hpp>
#include "boost/array.hpp"
#include "boost/type.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
@@ -52,9 +52,9 @@ main()
for (array::index i = 0; i != 4; ++i)
for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 2; ++k) {
BOOST_TEST(A[i][j][k] == *ptr);
BOOST_TEST(B[i][j][k] == *ptr);
BOOST_TEST(C[i][j][k] == *ptr++);
BOOST_CHECK(A[i][j][k] == *ptr);
BOOST_CHECK(B[i][j][k] == *ptr);
BOOST_CHECK(C[i][j][k] == *ptr++);
}
}
@@ -80,13 +80,13 @@ main()
for (array::index i = 0; i != 4; ++i)
for (array::index j = 1; j != 4; ++j)
for (array::index k = -1; k != 1; ++k) {
BOOST_TEST(A[i][j][k] == *ptr);
BOOST_TEST(B[i][j][k] == *ptr);
BOOST_TEST(C[i][j][k] == *ptr++);
BOOST_CHECK(A[i][j][k] == *ptr);
BOOST_CHECK(B[i][j][k] == *ptr);
BOOST_CHECK(C[i][j][k] == *ptr++);
}
}
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -14,13 +14,13 @@
// resize.cpp - Test of resizing multi_arrays
//
#include <boost/core/lightweight_test.hpp>
#include <boost/multi_array.hpp>
#include "boost/test/minimal.hpp"
#include "boost/multi_array.hpp"
#include <iostream>
using namespace std;
int main() {
int test_main(int,char*[]) {
typedef boost::multi_array<int,3> marray;
@@ -58,7 +58,7 @@ int main() {
marray A(boost::extents[2][3][4]);
A.assign(A_data,A_data+(2*3*4));
A.resize(boost::extents[4][3][2]);
BOOST_TEST(std::equal(A_resize,A_resize+(4*3*2),A.data()));
BOOST_CHECK(std::equal(A_resize,A_resize+(4*3*2),A.data()));
}
// resize through the Collection
@@ -67,14 +67,14 @@ int main() {
A.assign(A_data,A_data+(2*3*4));
boost::array<int,3> new_extents = {{4,3,2}};
A.resize(new_extents);
BOOST_TEST(std::equal(A_resize,A_resize+(4*3*2),A.data()));
BOOST_CHECK(std::equal(A_resize,A_resize+(4*3*2),A.data()));
}
// default construct all the new elements (in this case, all elements)
{
marray defaultA;
defaultA.resize(boost::extents[2][3][4]);
BOOST_TEST(std::accumulate(defaultA.data(),
BOOST_CHECK(std::accumulate(defaultA.data(),
defaultA.data()+(2*3*4),0) == 0);
}
@@ -107,21 +107,13 @@ int main() {
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 4; y++) {
for (int z = 0; z < 2; z++) {
BOOST_TEST(*(A.data() + check) == check);
BOOST_CHECK(*(A.data() + check) == check);
++check;
}
}
}
}
// 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::report_errors();
return boost::exit_success;
}

View File

@@ -1,43 +0,0 @@
// 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/core/lightweight_test.hpp>
#include <boost/array.hpp>
int
main()
{
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_TEST(B[i] == rdata[i]);
}
return boost::report_errors();
}

View File

@@ -15,9 +15,9 @@
//
#include "generative_tests.hpp"
#include <boost/array.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include "boost/array.hpp"
#include "boost/mpl/if.hpp"
#include "boost/type_traits/is_same.hpp"
template <typename Array>
struct view_traits_mutable {
@@ -71,10 +71,10 @@ void test_views(Array& A, const ViewTraits&) {
for (index i = 0; i != 2; ++i)
for (index j = 0; j != 2; ++j)
for (index k = 0; k != 2; ++k) {
BOOST_TEST(B[i][j][k] == A[idx0+i][idx1+j+1][idx2+k*2]);
BOOST_CHECK(B[i][j][k] == A[idx0+i][idx1+j+1][idx2+k*2]);
boost::array<index,3> elmts;
elmts[0]=i; elmts[1]=j; elmts[2]=k;
BOOST_TEST(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]);
BOOST_CHECK(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]);
}
}
// Degenerate dimensions
@@ -84,34 +84,12 @@ void test_views(Array& A, const ViewTraits&) {
for (index i = 0; i != 2; ++i)
for (index j = 0; j != 2; ++j) {
BOOST_TEST(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]);
BOOST_CHECK(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]);
boost::array<index,2> elmts;
elmts[0]=i; elmts[1]=j;
BOOST_TEST(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]);
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_TEST(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_TEST(B(elmts) == A[idx0+i][idx1+j][idx2+2-k]);
}
}
++tests_run;
}
@@ -141,6 +119,6 @@ void access(Array& A, const const_array_tag&) {
}
int main() {
int test_main(int,char*[]) {
return run_generative_tests();
}

View File

@@ -14,14 +14,14 @@
// stl_interaction.cpp - Make sure multi_arrays work with STL containers.
//
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <algorithm>
#include <vector>
int
main()
test_main(int, char*[])
{
using boost::extents;
using boost::indices;
@@ -51,7 +51,7 @@ main()
myarray.assign(data,data+data_size);
array3vec myvec(5,myarray);
BOOST_TEST(myarray == myvec[1]);
BOOST_CHECK(myarray == myvec[1]);
array3::array_view<2>::type myview =
myarray[indices[1][range(0,2)][range(1,3)]];
@@ -65,8 +65,8 @@ main()
myvec.push_back(myarray);
BOOST_TEST(myarray != myvec[1]);
BOOST_TEST(myarray == myvec[5]);
BOOST_CHECK(myarray != myvec[1]);
BOOST_CHECK(myarray == myvec[5]);
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -14,14 +14,14 @@
// storage_order.cpp - testing storage_order-isms.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
int
main()
test_main(int,char*[])
{
const int ndims=3;
@@ -67,7 +67,7 @@ main()
for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++);
BOOST_CHECK(A[i][j][k] == *num++);
}
// Mimic fortran_storage_order using
@@ -88,7 +88,7 @@ main()
for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++);
BOOST_CHECK(A[i][j][k] == *num++);
}
// general_storage_order with arbitrary storage order
@@ -119,7 +119,7 @@ main()
for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++);
BOOST_CHECK(A[i][j][k] == *num++);
}
@@ -152,8 +152,8 @@ main()
for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++);
BOOST_CHECK(A[i][j][k] == *num++);
}
return boost::report_errors();
return boost::exit_success;
}

View File

@@ -14,12 +14,12 @@
// test out my new storage_order stuff
//
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/multi_array/storage_order.hpp>
#include "boost/multi_array/storage_order.hpp"
int
main() {
test_main(int,char*[]) {
using namespace boost;

View File

@@ -14,15 +14,15 @@
// index_bases - test of the index_base modifying facilities.
//
#include <boost/multi_array.hpp>
#include "boost/multi_array.hpp"
#include <boost/core/lightweight_test.hpp>
#include "boost/test/minimal.hpp"
#include <boost/array.hpp>
#include "boost/array.hpp"
#include <vector>
#include <iostream>
int
main()
test_main(int,char*[])
{
typedef boost::multi_array<double, 3> array;
typedef array::array_view<3>::type array_view;
@@ -40,5 +40,5 @@ main()
array_view E = A[indices[irange(1,2)][irange(1,2)][irange(1,2)]];
}
return boost::report_errors();
return boost::exit_success;
}