Compare commits

..

4 Commits

Author SHA1 Message Date
nobody
77b637777d This commit was manufactured by cvs2svn to create tag
'Version_1_30_2'.

[SVN r19685]
2003-08-18 18:40:31 +00:00
Ronald Garcia
cd7b6f7c52 Fixed broken patch.
[SVN r17855]
2003-03-12 15:44:35 +00:00
Markus Schöpflin
98f7604258 Merged fix for regression test failure for VA6 from trunk to branch
[SVN r17832]
2003-03-12 10:49:11 +00:00
nobody
c563bf58fb This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'.
[SVN r17693]
2003-03-01 19:43:06 +00:00
86 changed files with 2719 additions and 3156 deletions

View File

@@ -1,22 +0,0 @@
#----------------------------------------------------------------------------
# This file was automatically generated from the original CMakeLists.txt file
# Add a variable to hold the headers for the library
set (lib_headers
multi_array.hpp
multi_array
)
# Add a library target to the build system
boost_library_project(
multi_array
# SRCDIRS
TESTDIRS test
HEADERS ${lib_headers}
# DOCDIRS
# DESCRIPTION
MODULARIZED
# AUTHORS
# MAINTAINERS
)

View File

@@ -1,16 +1,14 @@
<html>
<!--
== 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.
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
-->
<head>
<title>MultiDimensional Array Libary</title></head>
@@ -20,13 +18,13 @@
<table border="1" bgcolor="#007f7f" cellpadding="2">
<tbody><tr>
<td bgcolor="#ffffff">
<img src="../../../boost.png" alt="boost logo"
<img src="../../../c++boost.gif" alt="boost logo"
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/index.htm"><font face="Arial" color="#ffffff"><big>Home</big></font></a></td>
<td><a href="http://www.boost.org/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="../../../more/index.htm"><font face="Arial" color="#ffffff"><big>More</big></font></a></td>
<td><a href="http://www.boost.org/more/index.htm"><font face="Arial" color="#ffffff"><big>More</big></font></a></td>
</tr>
</tbody></table>
<h1>Boost.MultiArray</h1>
@@ -45,13 +43,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

@@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><!-- saved from url=(0022)http://internet.e-mail --><title>Improved Iterator Categories and Requirements</title>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<meta content="Microsoft FrontPage 5.0" name="GENERATOR"></head>
<meta content="MSHTML 5.00.2919.6307" name="GENERATOR"></head>
<body bgcolor="#ffffff">
<p align="right">
<table border="0">
@@ -70,7 +70,7 @@ is so nonintuitive that at least one implementation erroneously assigns
not return true references: there is the often cited example of disk-based
collections.
</p><p>Another example is a counting iterator, an iterator the returns a sequence of
integers when incremented and dereferenced (see <a href="http://www.boost.org/libs/iterator/doc/counting_iterator.html"><tt>boost::counting_iterator</tt></a>).
integers when incremented and dereferenced (see <a href="http://www.boost.org/libs/utility/counting_iterator.htm"><tt>boost::counting_iterator</tt></a>).
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
@@ -79,7 +79,7 @@ iterator) or 2) make the <tt>reference</tt> type be the same as the
2) is therefore a better choice, but then we have a counting iterator that
cannot be a random access iterator.
</p><p>Yet another example is a transform iterator, an iterator adaptor that applies
a unary function object to the dereference value of the wrapped iterator (see <a href="http://www.boost.org/libs/iterator/doc/transform_iterator.html"><tt>boost::transform_iterator</tt></a>).
a unary function object to the dereference value of the wrapped iterator (see <a href="http://www.boost.org/libs/utility/transform_iterator.htm"><tt>boost::transform_iterator</tt></a>).
For unary functions such as <tt>std::times</tt> the return type of
<tt>operator*</tt> clearly needs to be the <tt>result_type</tt> of the function
object, which is typically not a reference. However, with the current iterator
@@ -105,23 +105,23 @@ standard iterator categories. As a result, the following bad things happen:
requirements should be separated into two hierarchies. One set of concepts
handles the return type semantics:
<ul>
<li><a href="#concept_ReadableIterator">Readable
Iterator</a>
</li><li><a href="#concept_WritableIterator">Writable
Iterator</a>
</li><li><a href="#concept_SwappableIterator">Swappable
Iterator</a>
</li><li><a href="#concept_ConstantLvalueIterator">Constant
Lvalue Iterator</a>
</li><li><a href="#concept_MutableLvalueIterator">Mutable
<li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_ReadableIterator">Readable
Iterator</a>
</li><li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_WritableIterator">Writable
Iterator</a>
</li><li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_SwappableIterator">Swappable
Iterator</a>
</li><li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_ConstantLvalueIterator">Constant
Lvalue Iterator</a>
</li><li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_MutableLvalueIterator">Mutable
Lvalue Iterator</a> </li></ul>The other set of concepts handles iterator
traversal:
<ul>
<li><a href="#concept_ForwardTraversalIterator">Forward
Traversal Iterator</a>
</li><li><a href="#concept_BidirectionalTraversalIterator">Bidirectional
Traversal Iterator</a>
</li><li><a href="#concept_RandomAccessTraversalIterator">Random
<li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_ForwardTraversalIterator">Forward
Traversal Iterator</a>
</li><li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_BidirectionalTraversalIterator">Bidirectional
Traversal Iterator</a>
</li><li><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_RandomAccessTraversalIterator">Random
Access Traversal Iterator</a> </li></ul>The current Input Iterator and Output
Iterator requirements will continue to be used as is. Note that Input Iterator
implies Readable Iterator and Output Iterator implies Writable Iterator.
@@ -487,7 +487,7 @@ reference to the pointed-to object, i.e., the associated <tt>reference</tt> type
is <tt>const T&amp;</tt>. Changing the value of or destroying an iterator that
models Constant Lvalue Iterator does not invalidate pointers and references
previously obtained from that iterator.
<h3>Refinement of</h3><a href="#concept_ReadableIterator">Readable
<h3>Refinement of</h3><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_ReadableIterator">Readable
Iterator</a>
<h3>Associated Types</h3>
<table border="1">
@@ -497,68 +497,39 @@ Iterator</a>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
<td>The return type of dereferencing the iterator, which must be <tt>const
T&amp;</tt>. </td></tr><!-- I don't think this is needed
<tr>
<td>Pointer type</td>
<td><tt>std::iterator_traits&lt;X&gt;::pointer</tt></td>
<td>
The pointer to the value type, which must be <tt>const T*</tt>.
</td>
</tr>
-->
<tr>
<td>Return Category</td>
<td><tt>std::return_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::constant_lvalue_iterator_tag</tt>
</td></tr></tbody></table><!-- these are not necessary now that we use reference as operator* return type
<h3>Valid expressions</h3>
<Table border>
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></tr>
<tr>
<td>Dereference</td>
<td><tt>*x</tt></td>
<td>&nbsp;</td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
</tr>
<tr>
<td>Member access</td>
<td><tt>x-&gt;m</tt></td>
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
<td>
&nbsp;
</td>
</tr>
</table>
-->
<p>
</p><hr>
@@ -569,9 +540,9 @@ to the pointed-to object. The associated <tt>reference</tt> type is
<tt>T&amp;</tt>. Changing the value of or destroying an iterator that models
Mutable Lvalue Iterator does not invalidate pointers and references previously
obtained from that iterator.
<h3>Refinement of</h3><a href="#concept_ReadableIterator">Readable
Iterator</a>, <a href="#concept_WritableIterator">Writable
Iterator</a>, and <a href="#concept_SwappableIterator">Swappable
<h3>Refinement of</h3><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_ReadableIterator">Readable
Iterator</a>, <a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_WritableIterator">Writable
Iterator</a>, and <a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_SwappableIterator">Swappable
Iterator</a>.
<h3>Associated Types</h3>
<table border="1">
@@ -581,68 +552,39 @@ Iterator</a>.
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
<td>The return type of dereferencing the iterator, which must be
<tt>T&amp;</tt>.</td></tr><!-- I don't think this is necessary
<tr>
<td>Pointer type</td>
<td><tt>std::iterator_traits&lt;X&gt;::pointer</tt></td>
<td>
The pointer to the value type, which is <tt>T*</tt>.
</td>
</tr>
-->
<tr>
<td>Return Category</td>
<td><tt>std::return_category&lt;X&gt;::type</tt></td>
<td>A type convertible to <tt>std::mutable_lvalue_iterator_tag</tt>
</td></tr></tbody></table><!-- no longer needed since the return type is specified as reference in the readable iterator
<h3>Valid expressions</h3>
<Table border>
<tr><TH>Name</TH><TH>Expression</TH><TH>Type requirements</TH><TH>Return type</TH></tr>
<tr>
<td>Dereference</td>
<td><tt>*x</tt></td>
<td>&nbsp;</td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td>
</tr>
<tr>
<td>Member access</td>
<td><tt>x-&gt;m</tt></td>
<td><tt>T</tt> is a type with a member named <tt>m</tt>.</td>
<td>
&nbsp;
</td>
</tr>
</table>
-->
<p>
</p><hr>
@@ -690,7 +632,7 @@ Comparable</a>
<!--------------------------------------------------------------------------->
<h3><a name="concept_BidirectionalTraversalIterator"></a>Bidirectional Traversal
Iterator </h3>An iterator that can be incremented and decremented.
<h3>Refinement of</h3><a href="#concept_ForwardTraversalIterator">Forward
<h3>Refinement of</h3><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_ForwardTraversalIterator">Forward
Traversal Iterator</a>
<h3>Associated types</h3>
<table border="1">
@@ -724,7 +666,7 @@ Traversal Iterator</a>
<h3><a name="concept_RandomAccessTraversalIterator"></a>Random Access Traversal
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
<h3>Refinement of</h3><a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_BidirectionalTraversalIterator">Bidirectional
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>
@@ -771,27 +713,21 @@ Comparable</a> where <tt>&lt;</tt> is a total ordering
<tr>
<td>Element operator</td>
<td><tt>i[n]</tt></td>
<td><tt>X</tt> must also be a model of <a href="#concept_ReadableIterator">Readable
<td><tt>X</tt> must also be a model of <a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_ReadableIterator">Readable
Iterator</a>. </td>
<td><tt>std::iterator_traits&lt;X&gt;::reference</tt></td></tr>
<tr>
<td>Element assignment</td>
<td><tt>i[n] = t</tt></td>
<td><tt>X</tt> must also be a model of <a href="#concept_WritableIterator">Writable
<td><tt>X</tt> must also be a model of <a href="file:///C:/WINDOWS/TEMP/iterator-categories.html#concept_WritableIterator">Writable
Iterator</a>.</td>
<td>unspecified</td></tr></tbody></table>
<p>
</p><hr>
<!-- LocalWords: HTML BGCOLOR FFFFFF TR TD Siek HREF mailto jsiek
--><!-- LocalWords: lsc edu tt const href http anubis dkuug dk JTC SC WG docs lt
--><!-- LocalWords: lwg html bool gt Sutter's htm Lvalue namespace std struct
--><!-- LocalWords: lvalue typename OldTraits reusability min iter prev inplace
--><!-- LocalWords: rvalue templated Preincrement Postincrement Predecrement
--><!-- LocalWords: Postdecrement
--></body></html>

View File

@@ -2,18 +2,17 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
== 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.
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
-->
<head>
<title>Boost.MultiArray: Extra Notes</title>
</head>
@@ -21,7 +20,7 @@
<body>
<h1>
<img src="../../../boost.png" alt="boost logo"
<img src="../../../c++boost.gif" alt="boost logo"
width="277" align="middle" height="86">
<br>Boost.MultiArray: Extra Notes
<br>

File diff suppressed because it is too large Load Diff

View File

@@ -2,17 +2,15 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
== 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.
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
-->
<head>
<title>
@@ -20,7 +18,7 @@ Boost.MultiArray: Test Descriptions
</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<IMG SRC="http://www.boost.org/boost.png"
<IMG SRC="http://www.boost.org/c++boost.gif"
ALT="C++ Boost" width="277" height="86">
<h1>Boost.MultiArray: Test Descriptions</h1>
@@ -99,14 +97,6 @@ Tests out <tt>operator=()</tt> on the various B.M array types.
</td>
</tr>
<tr>
<td><a href="../test/assign_to_array.cpp">libs/multi_array/test/assign_to_array.cpp</a></td>
<td>
Ensure that a <tt>multi_array</tt> can be constructed from any other
array type.
</td>
</tr>
<tr>
<td><a href="../test/index_bases.cpp">libs/multi_array/test/index_bases.cpp</a></td>
<td>
@@ -114,13 +104,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>
@@ -157,13 +140,6 @@ Test interaction between array types and STL containers.
</td>
</tr>
<tr>
<td><a href="../test/resize.cpp">libs/multi_array/test/resize.cpp</a></td>
<td>
Test the <tt>multi_array</tt> class' resizing functionality.
</td>
</tr>
<tr>
<td><a href="../test/concept_checks.cpp">libs/multi_array/test/concept_checks.cpp</a></td>
<td>
@@ -171,14 +147,6 @@ Ensure that all the array types meet the defined Concepts.
</td>
</tr>
<tr>
<td><a href="../test/assert.cpp">libs/multi_array/test/assert.cpp</a></td>
<td>
Ensure that uses of BOOST_ASSERT within the library can be customized
by library users.
</td>
</tr>
<tr>
<td><a href="../test/generative_tests.hpp">libs/multi_array/test/generative_tests.hpp</a></td>
<td>
@@ -300,10 +268,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

@@ -2,18 +2,17 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
== 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.
== Copyright (c) Ronald Garcia, Jeremy Siek 2001
==
== Permission to use, copy, modify, distribute and sell this software
== and its documentation for any purpose is hereby granted without fee,
== provided that the above copyright notice appears in all copies and
== that both that copyright notice and this permission notice appear
== in supporting documentation. Jeremy Siek makes no
== representations about the suitability of this software for any
== purpose. It is provided "as is" without express or implied warranty.
-->
<head>
<title>The Boost Multidimensional Array Library (Boost.MultiArray)</title>
</head>
@@ -21,7 +20,7 @@
<body>
<h1>
<img src="../../../boost.png" alt="boost logo"
<img src="../../../c++boost.gif" alt="boost logo"
width="277" align="middle" height="86">
<br>The Boost Multidimensional Array Library
<br>(Boost.MultiArray)
@@ -30,25 +29,22 @@
<h2>Synopsis</h2>
<p>
The Boost Multidimensional Array Library provides a class template for
multidimensional arrays, as well as semantically equivalent
The Boost Multidimensional Array Library provides
a multidimensional container of elements and semantically equivalent
adaptors for arrays of contiguous data. The classes in this library
implement a common interface, formalized as a generic programming
concept. The interface design is in line with the precedent set by the
C++ Standard Library containers. Boost MultiArray is a more efficient
and convenient way to express N-dimensional arrays than existing
alternatives (especially the
<tt>std::vector&lt;std::vector&lt;...&gt;&gt;</tt> formulation
of N-dimensional arrays). The arrays provided by the library may be
accessed using the familiar syntax of native C++ arrays. Additional
features, such as resizing, reshaping, and creating views are
available (and described below).
behave as closely as possible to STL Containers, providing a more
convenient and efficient implementation than the equivalent "vectors
of vectors" formulation of N-dimensional arrays. Arrays are not
re-sizable once constructed, but may be sliced and shaped, providing
alternate views of the contained data.
<h2>Table of Contents</h2>
<ol>
<li><a href="#sec_introduction">Introduction</a>
<li><a href="#sec_rationale">Rationale</a>
<li><a href="#sec_related">Related Work</a>
<li><a href="#sec_example">Short Example</a>
@@ -70,53 +66,61 @@ available (and described below).
<li><a href="#sec_reshape">Changing an Array's Shape</a>
<li><a href="#sec_resize">Resizing an Array</a>
<li><a href="#sec_concepts">MultiArray Concept</a>
<li><a href="#sec_testcases">Test Cases</a>
<li><a href="#sec_related">Related Work</a>
<li><a href="#sec_credits">Credits</a>
</ol>
<a name="sec_introduction"></a>
<h2>Introduction</h2>
<a name="sec_rationale"></a>
<h2>Rationale</h2>
<p>
The C++ standard library provides several generic containers, but it
does not provide any multidimensional array types. The
<tt>std::vector</tt> class template can be used to implement
N-dimensional arrays, for example expressing a 2-dimensional array of
<tt>double</tt> elements using the type
<tt>std::vector&lt;std::vector&lt;double&gt;&gt;</tt>, but the
resulting interface is unwieldy and the memory overhead can be quite
high. Native C++ arrays (i.e. <tt>int arr[2][2][2];</tt>) do not
immediately interoperate well with the C++ Standard Library, and they
also lose information at function call boundaries (specifically the
extent of the last dimension). Finally, a dynamically allocated
contiguous block of elements can be treated as an array, though this
method requires manual bookkeeping that is error prone and obfuscates
the intent of the programmer.
</p>
The C++ standard library provides several generic containers, but
it does not provide any multidimensional array types.
Using <tt>std::vector</tt>, you can simulate N-dimensional arrays as
"nested vectors", but the
interface is unwieldy and the memory overhead can be quite high. You can also
use a native C++ arrays (i.e. <tt>int arr[2][2][2];</tt>),
or a dynamically allocated array of contigous data which you treat as
a multidimensional array. Using
<a href="../../array_traits/index.html">array_traits</a>,
you can extract from a statically defined C++ array
iterators over its dimensions.
In either case, however, dimensional data may be lost if it is
passed to a function that is not properly specialized to accept
it. Beyond the above, neither the <tt>std::vector</tt> nor C++ array-based
solution provides a convenient method of honing in upon a specific
subset or "view" of a multi-dimensional array.
<p>
The Boost MultiArray library enhances the C++ standard containers with
versatile multi-dimensional array abstractions. It includes a general
array class template and native array adaptors that support idiomatic
array operations and interoperate with C++ Standard Library containers
and algorithms. The arrays share a common interface, expressed as a
generic programming in terms of which generic array algorithms can be
implemented.
</p>
<p>Boost.MultiArray defines the MultiArray concept, a generic
interface for N-dimensional containers. The primary components of
this library model MultiArray and support adapting user data
to model MultiArray as well.
<a name="sec_related"></a>
<h2>Related Work</h2>
<a href="../../array/index.htm">boost::array</a>
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
meant to provide portable high performance for numerical applications.
<a href="http://www.oonumerics.org/blitz/">Blitz++</a> is
an array library developed by Todd
Veldhuizen. It uses
advanced C++ techniques to provide near-Fortran performance for
array-based numerical applications.
<a href="../../array_traits/index.html">array_traits</a> is a beta
library distributed with Boost that provides a means to create
iterators over native C++ arrays.
This library is analogous to
<a href="">boost::array</a> in that it augments C style N-dimensional
arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
<p>
This document is meant to provide an introductory tutorial and user's
guide for the most basic and common usage patterns of MultiArray
components. The <a href="./reference.html">reference manual</a>
provides more complete and formal documentation of library features.
</p>
<a name="sec_example"></a>
<h2>Short Example</h2>
@@ -156,20 +160,22 @@ main () {
<a name="sec_components"></a>
<h2>MultiArray Components</h2>
Boost.MultiArray's implementation (boost/multi_array.hpp) provides three user-level class templates:
Boost.MultiArray provides three user-level class templates:
<ol>
<li><a href="./reference.html#multi_array"><tt>multi_array</tt></a>,
<li><a href="./reference.html#multi_array"><tt>multi_array</tt></a> -
defined in "boost/multi_array.hpp",
<li><a href="./reference.html#multi_array_ref"><tt>multi_array_ref</tt></a>, and
<li><a href="./reference.html#multi_array_ref"><tt>multi_array_ref</tt></a> -
defined in "boost/multi_array_ref.hpp", and
<li><a href="./reference.html#const_multi_array_ref"><tt>const_multi_array_ref</tt></a>
<li><a href="./reference.html#const_multi_array_ref"><tt>const_multi_array_ref</tt></a> -
defined in "boost/multi_array_ref.hpp"
</ol>
<tt>multi_array</tt> is a container template. When instantiated, it
allocates space for the number of elements corresponding to the
dimensions specified at construction time. A <tt>multi_array</tt> may
also be default constructed and resized as needed.
dimensions specified at construction time.
<p>
<tt>multi_array_ref</tt> adapts an existing array of data to provide
@@ -185,8 +191,8 @@ thus wrap pointers of type <i>T const*</i>.
The three components exhibit very similar behavior. Aside from
constructor parameters, <tt>multi_array</tt> and
<tt>multi_array_ref</tt> export the same interface.
<tt>const_multi_array_ref</tt> provides only the constness-preserving
portions of the <tt>multi_array_ref</tt> interface.
<tt>const_multi_array_ref</tt> provides only the const portions
of the <tt>multi_array_ref</tt> interface.
<a name="sec_assignment"></a>
<h2>Construction and Assignment</h2>
@@ -232,9 +238,8 @@ void my_function() {
<a name="sec_dimensions"></a>
<h2>Specifying Array Dimensions</h2>
When creating most of the Boost.MultiArray components, it is necessary
to specify both the number of dimensions and the extent of each
(<tt>boost::multi_array</tt> also provides a default constructor).
When creating one of the Boost.MultiArray components, it is necessary
to specify both the number of dimensions and the extent of each.
Though the number of dimensions is always specified as a template
parameter, two separate mechanisms have been provided to specify the
extent of each.
@@ -255,9 +260,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
@@ -303,14 +306,6 @@ from the Collection for the N dimensions of the container.
This can be useful for writing dimension-independent code, and under
some compilers may yield higher performance than <tt>operator[].</tt>
<p>
By default, both of the above element access methods 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 <tt>BOOST_DISABLE_ASSERTS</tt> preprocessor macro prior to
including multi_array.hpp in your application.
<a name="sec_views"></a>
<h2>Creating Views</h2>
Boost.MultiArray provides the facilities for creating a sub-view of an
@@ -318,17 +313,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 +332,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 +358,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 +379,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 +399,7 @@ dimension it is used to specify.
<h3>Example</h3>
<blockquote>
<pre>
typedef boost::multi_array_types::index_range range;
typedef array_type::index_range range;
range a_range;
// All elements in this dimension
@@ -489,16 +479,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 +504,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 +521,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 +545,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]);
@@ -567,35 +557,6 @@ elements contained remains the same.
<p>
Note that reshaping an array does not affect the indexing.
<a name="sec_resize"></a>
<h2>Resizing an Array</h2>
The <tt>boost::multi_array</tt> class provides an element-preserving
resize operation. The number of dimensions must remain the same, but
the extent of each dimension may be increased and decreased as
desired. When an array is made strictly larger, the existing elements
will be preserved by copying them into the new underlying memory and
subsequently destructing the elements in the old underlying memory.
Any new elements in the array are default constructed. However, if
the new array size shrinks some of the dimensions, some elements will
no longer be available.
<h3>Example</h3>
<blockquote>
<pre>
typedef boost::multi_array&lt;int, 3&gt; array_type;
array_type::extent_gen extents;
array_type A(extents[3][3][3]);
A[0][0][0] = 4;
A[2][2][2] = 5;
A.resize(extents[2][3][4]);
assert(A[0][0][0] == 4);
// A[2][2][2] is no longer valid.
</pre>
</blockquote>
<a name="sec_concepts"></a>
<h2>MultiArray Concept</h2>
Boost.MultiArray defines and uses the
@@ -608,37 +569,13 @@ Boost.MultiArray comes with a suite of test cases meant to exercise
the features and semantics of the library. A description of the test
cases can be found <a href="./test_cases.html">here</a>.
<a name="sec_related"></a>
<h2>Related Work</h2>
<a href="../../array/index.html">boost::array</a>
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
meant to provide portable high performance for numerical applications.
<a href="http://www.oonumerics.org/blitz/">Blitz++</a> is
an array library developed by Todd
Veldhuizen. It uses
advanced C++ techniques to provide near-Fortran performance for
array-based numerical applications.
<b>array_traits</b> is a beta library, formerly distributed with
Boost, that provides a means to create iterators over native C++
arrays.
This library is analogous to
<a href="../../array/index.html">boost::array</a> in that it augments C style N-dimensional
arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
<a name="sec_credits"></a>
<h2>Credits</h2>
<ul>
<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++.
@@ -669,7 +606,9 @@ arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
<a href="mailto:garcia@.cs.indiana.edu">Ronald Garcia</a>
</address>
<!-- Created: Fri Jun 29 10:53:07 EST 2001 -->
<!-- hhmts start -->Last modified: Tue Feb 7 17:15:50 EST 2006 <!-- hhmts end -->
<!-- hhmts start -->
Last modified: Tue Sep 10 11:14:15 EST 2002
<!-- hhmts end -->
</body>
</html>

View File

@@ -77,7 +77,7 @@ occurs when a single-index is specified to
</programlisting>
has a degenerate second dimension. The view generated from the above
specification will have 2 dimensions with shape <literal>5 x 4</literal>.
specification will have 2 dimensions with shape <literal>5 x 2</literal>.
If the "<literal>2</literal>" above were replaced with
another <literal>index_range</literal> object, for example:
@@ -124,8 +124,8 @@ to describe the MultiArray interface.</para>
</entry>
</row>
<row>
<entry><literal>a,b</literal></entry>
<entry>Objects of type <literal>A</literal></entry>
<entry><literal>a</literal></entry>
<entry>An object of type <literal>A</literal></entry>
</row>
<row>
<entry><literal>NumDims</literal></entry>
@@ -385,13 +385,6 @@ This is the const view type with <literal>Dims</literal> dimensions.
</row>
</thead>
<tbody>
<row>
<entry><literal>A::dimensionality</literal></entry>
<entry><literal>size_type</literal></entry>
<entry>This compile-time constant represents the number of
dimensions of the array (note that
<literal>A::dimensionality == NumDims</literal>).</entry>
</row>
<row>
<entry><literal>a.shape()</literal></entry>
<entry><literal>const size_type*</literal></entry>

View File

@@ -33,26 +33,25 @@ 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:
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 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* 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;
// template typedefs
template <std::size_t Dims> struct subarray;
@@ -64,10 +63,10 @@ public:
// structors
template <typename ExtentList>
explicit const_multi_array_ref(TPtr data, const ExtentList& sizes,
const storage_order_type& store = c_storage_order());
explicit const_multi_array_ref(TPtr data, const extents_tuple& ranges,
const storage_order_type& store = c_storage_order());
explicit const_multi_array_ref(const element* data, const ExtentList& sizes,
const storage_order& store = c_storage_order());
explicit const_multi_array_ref(const element* data, const extents_tuple& ranges,
const storage_order& store = c_storage_order());
const_multi_array_ref(const const_multi_array_ref& x);
~const_multi_array_ref();
@@ -96,7 +95,6 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type& storage_order() const;
// comparators
bool operator==(const const_multi_array_ref& rhs);
@@ -122,7 +120,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 +149,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>

71
doc/xml/main.xml Normal file
View File

@@ -0,0 +1,71 @@
<?xml version='1.0' encoding="ISO-Latin-1" ?>
<!DOCTYPE article
PUBLIC "-//OASIS//DTD DocBook XML MathML V4.1.2//EN"
"/home/rgarcia/docbook-xml/docbookx.dtd"
>
<article>
<articleinfo>
<title>Class template <literal>multi_array</literal></title>
<author>
<surname>Garcia</surname><firstname>Ronald</firstname>
<affiliation>
<orgname>Indiana University</orgname>
<orgdiv>Open Systems Lab</orgdiv>
</affiliation>
</author>
<orgname>BOOST</orgname>
<copyright>
<year>2002</year>
<holder>Ronald Garcia</holder>
</copyright>
<legalnotice>
<para>blah blah legal blah blah</para>
</legalnotice>
<revhistory>
<revision>
<revnumber>1</revnumber>
<date>1/18/2002</date>
<revdescription>
<simpara>Initial Revision.</simpara>
</revdescription>
</revision>
</revhistory>
</articleinfo>
Boost.MultiArray
Headers boost/multi_array.hpp and
boost/multi_array_ref.hpp
Motivation
Examples
Tutorial
Reference Manual
Comparison to Other Libraries
Performance
Portability
Design Rationale
Acknowledgements
FAQ
Motivation
Examples
*Insert examples here*
(External Tutorial)
(External Reference Manual)
Comparison to Other Libraries
Performance
Portability
Design Rationale
Acknowledgements
FAQ

View File

@@ -36,23 +36,21 @@ class multi_array {
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 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* 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;
// template typedefs
template <std::size_t Dims> struct subarray;
template <std::size_t Dims> struct const_subarray;
@@ -62,24 +60,14 @@ public:
// constructors and destructors
multi_array();
template <typename ExtentList>
explicit multi_array(const ExtentList& sizes,
const storage_order_type& store = c_storage_order(),
const storage_order& store = c_storage_order(),
const Allocator& alloc = Allocator());
explicit multi_array(const extents_tuple& ranges,
const storage_order_type& store = c_storage_order(),
const storage_order& store = c_storage_order(),
const Allocator& alloc = Allocator());
multi_array(const multi_array& x);
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);
~multi_array();
// modifiers
@@ -120,7 +108,6 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type& storage_order() const;
// comparators
bool operator==(const multi_array& rhs);
@@ -136,10 +123,7 @@ public:
template <typename SizeList>
void reshape(const SizeList& sizes)
template <typename BaseList> void reindex(const BaseList& values);
void reindex(index value);
template <typename ExtentList>
multi_array& resize(const ExtentList& extents);
multi_array& resize(extents_tuple& extents);
void reindex(index value);
};
]]>
</programlisting>
@@ -152,7 +136,7 @@ public:
<varlistentry>
<term><programlisting>template &lt;typename ExtentList&gt;
explicit multi_array(const ExtentList&amp; sizes,
const storage_order_type&amp; store = c_storage_order(),
const storage_order&amp; store = c_storage_order(),
const Allocator&amp; alloc = Allocator());
</programlisting></term>
<listitem>
@@ -182,7 +166,7 @@ allocate the contained elements.
<varlistentry>
<term>
<programlisting><![CDATA[explicit multi_array(extent_gen::gen_type<NumDims>::type ranges,
const storage_order_type& store = c_storage_order(),
const storage_order& store = c_storage_order(),
const Allocator& alloc = Allocator());]]>
</programlisting></term>
<listitem>
@@ -203,17 +187,11 @@ elements.
<varlistentry>
<term><programlisting>
<![CDATA[multi_array(const multi_array& x);
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);]]>
<![CDATA[multi_array(const multi_array& x);]]>
</programlisting></term>
<listitem>
<para>These constructors all constructs a <literal>multi_array</literal> and
perform a deep copy of <literal>x</literal>.
<para>This constructs a <literal>multi_array</literal> and performs a deep
copy of <literal>x</literal>.
</para>
<formalpara>
@@ -225,16 +203,6 @@ constructor.
</listitem>
</varlistentry>
<varlistentry>
<term><programlisting>
<![CDATA[multi_array();]]>
</programlisting></term>
<listitem>
<para>This constructs a <literal>multi_array</literal> whose shape is (0,...,0) and contains no elements.
</para>
</listitem>
</varlistentry>
</variablelist>
<formalpara><title>Note on Constructors</title>
@@ -326,47 +294,6 @@ O(<literal>this->num_elements()</literal>) calls to
</formalpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
<programlisting><![CDATA[multi_array& resize(extent_gen::gen_type<NumDims>::type extents);
template <typename ExtentList>
multi_array& resize(const ExtentList& extents);
]]>
</programlisting></term>
<listitem>
<para>
This function resizes an array to the shape specified by
<literal>extents</literal>, which is either a generated list of
extents or a model of the <literal>Collection</literal> concept. The
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
<literal>element</literal> default constructor.
</para>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
<formalpara>
<title>Queries</title>
<variablelist>
<varlistentry>
<term><programlisting>
<![CDATA[storage_order_type& storage_order() const;]]>
</programlisting>
</term>
<listitem>
<para>This query returns the storage order object associated with the
<literal>multi_array</literal> in question. It can be used to construct a new array with the same storage order.</para>
</listitem>
</varlistentry>
</variablelist>
</formalpara>
</sect2>

View File

@@ -31,26 +31,26 @@ 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 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* 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;
// template typedefs
template <std::size_t Dims> struct subarray;
@@ -63,9 +63,9 @@ public:
template <typename ExtentList>
explicit multi_array_ref(element* data, const ExtentList& sizes,
const storage_order_type& store = c_storage_order());
const storage_order& store = c_storage_order());
explicit multi_array_ref(element* data, const extents_tuple& ranges,
const storage_order_type& store = c_storage_order());
const storage_order& store = c_storage_order());
multi_array_ref(const multi_array_ref& x);
~multi_array_ref();
@@ -107,7 +107,6 @@ public:
const size_type* shape() const;
const index* strides() const;
const index* index_bases() const;
const storage_order_type& storage_order() const;
// comparators
bool operator==(const multi_array_ref& rhs);

View File

@@ -21,7 +21,7 @@
<orgname>BOOST</orgname>
<copyright>
<year>2002</year>
<holder>The Trustees of Indiana University</holder>
<holder>Ronald Garcia</holder>
</copyright>
</articleinfo>
@@ -50,13 +50,13 @@ brings the following declarations into scope:</para>
<![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;
typedef *implementation-defined* index;
typedef *implementation-defined* size_type;
typedef *implementation-defined* difference_type;
typedef *implementation-defined* index_range;
typedef *implementation-defined* extent_range;
typedef *implementation-defined* index_gen;
typedef *implementation-defined* extent_gen;
}
template <typename ValueType,
@@ -343,13 +343,13 @@ std::count_if(this->index_bases(),this->index_bases()+this->num_dimensions(),
<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;
typedef *implementation-defined* index;
typedef *implementation-defined* size_type;
typedef *implementation-defined* difference_type;
typedef *implementation-defined* index_range;
typedef *implementation-defined* extent_range;
typedef *implementation-defined* index_gen;
typedef *implementation-defined* extent_gen;
}]]>
</programlisting>
@@ -779,20 +779,6 @@ 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>

View File

@@ -1,15 +1,3 @@
// 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.
#include <cassert>
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
#include <cassert>
#include "boost/multi_array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
#ifndef FOR_EACH_HPP
#define FOR_EACH_HPP

View File

@@ -1,15 +1,3 @@
// 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.
// foreach_test.cpp
// Let's see if this stuff works

View File

@@ -1,15 +1,3 @@
// 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.
#include "boost/multi_array.hpp"
#include "for_each.hpp"
#include <algorithm>

View File

@@ -1,15 +1,3 @@
// 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.
#include <cassert>
#include "boost/multi_array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
#include <iostream>
#include "boost/multi_array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"

View File

@@ -1,13 +1,15 @@
// Copyright 2002 The Trustees of Indiana University.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
// 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.
#ifndef BOOST_MULTI_ARRAY_RG071801_HPP
@@ -26,7 +28,6 @@
#include "boost/multi_array/multi_array_ref.hpp"
#include "boost/multi_array/algorithm.hpp"
#include "boost/array.hpp"
#include "boost/mpl/if.hpp"
#include "boost/type_traits.hpp"
#include <algorithm>
#include <cstddef>
@@ -39,85 +40,30 @@
namespace boost {
namespace detail {
namespace multi_array {
struct populate_index_ranges {
multi_array_types::index_range
// RG: underscore on extent_ to stifle strange MSVC warning.
operator()(multi_array_types::index base,
multi_array_types::size_type extent_) {
return multi_array_types::index_range(base,base+extent_);
multi_array_types::size_type extent) {
return multi_array_types::index_range(base,base+extent);
}
};
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
//
// Compilers that don't support partial ordering may need help to
// disambiguate multi_array's templated constructors. Even vc6/7 are
// capable of some limited SFINAE, so we take the most-general version
// out of the overload set with disable_multi_array_impl.
//
template <typename T, std::size_t NumDims, typename TPtr>
char is_multi_array_impl_help(const_multi_array_view<T,NumDims,TPtr>&);
template <typename T, std::size_t NumDims, typename TPtr>
char is_multi_array_impl_help(const_sub_array<T,NumDims,TPtr>&);
template <typename T, std::size_t NumDims, typename TPtr>
char is_multi_array_impl_help(const_multi_array_ref<T,NumDims,TPtr>&);
char ( &is_multi_array_impl_help(...) )[2];
template <class T>
struct is_multi_array_impl
{
static T x;
BOOST_STATIC_CONSTANT(bool, value = sizeof((is_multi_array_impl_help)(x)) == 1);
typedef mpl::bool_<value> type;
};
template <bool multi_array = false>
struct disable_multi_array_impl_impl
{
typedef int type;
};
template <>
struct disable_multi_array_impl_impl<true>
{
// forming a pointer to a reference triggers SFINAE
typedef int& type;
};
template <class T>
struct disable_multi_array_impl :
disable_multi_array_impl_impl<is_multi_array_impl<T>::value>
{ };
template <>
struct disable_multi_array_impl<int>
{
typedef int type;
};
#endif
} //namespace multi_array
} // namespace detail
template<typename T, std::size_t NumDims,
typename Allocator>
class multi_array :
class multi_array :
public multi_array_ref<T,NumDims>
{
typedef multi_array_ref<T,NumDims> super_type;
public:
public:
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::iterator iterator;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
@@ -137,31 +83,17 @@ public:
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
};
explicit multi_array() :
super_type((T*)initial_base_,c_storage_order(),
/*index_bases=*/0, /*extents=*/0) {
allocate_space();
}
template <class ExtentList>
explicit multi_array(
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
) :
explicit multi_array(ExtentList const& extents) :
super_type((T*)initial_base_,extents) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
allocate_space();
}
template <class ExtentList>
explicit multi_array(ExtentList const& extents,
const general_storage_order<NumDims>& so) :
const general_storage_order<NumDims>& so) :
super_type((T*)initial_base_,extents,so) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
@@ -208,163 +140,28 @@ public:
multi_array(const multi_array& rhs) :
super_type(rhs), allocator_(rhs.allocator_) {
allocate_space();
boost::detail::multi_array::copy_n(rhs.base_,rhs.num_elements(),base_);
}
//
// A multi_array is constructible from any multi_array_ref, subarray, or
// array_view object. The following constructors ensure that.
//
// Due to limited support for partial template ordering,
// MSVC 6&7 confuse the following with the most basic ExtentList
// constructor.
#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())
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
allocate_space();
// Warning! storage order may change, hence the following copy technique.
std::copy(rhs.begin(),rhs.end(),this->begin());
boost::copy_n(rhs.base_,rhs.num_elements(),base_);
}
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())
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
const_sub_array<T,NumDims,OPtr>& rhs) :
super_type(rhs) {
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
}
template <typename OPtr>
// For some reason, gcc 2.95.2 doesn't pick the above template
// member function when passed a subarray, so i was forced to
// duplicate the functionality here...
multi_array(const detail::multi_array::
const_multi_array_view<T,NumDims,OPtr>& rhs,
const general_storage_order<NumDims>& so = c_storage_order())
: super_type(0,so,rhs.index_bases(),rhs.shape())
{
sub_array<T,NumDims>& rhs) :
super_type(rhs) {
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
}
#else // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
// More limited support for MSVC
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.
std::copy(rhs.begin(),rhs.end(),this->begin());
}
multi_array(const const_multi_array_ref<T,NumDims>& rhs,
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.
std::copy(rhs.begin(),rhs.end(),this->begin());
}
multi_array(const detail::multi_array::
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());
}
multi_array(const detail::multi_array::
const_sub_array<T,NumDims>& rhs,
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());
}
multi_array(const detail::multi_array::
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());
}
multi_array(const detail::multi_array::
const_multi_array_view<T,NumDims>& rhs,
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());
}
#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)
: super_type(0,c_storage_order(),rhs.index_bases(),rhs.shape())
{
allocate_space();
// Warning! storage order may change, hence the following copy technique.
std::copy(rhs.begin(),rhs.end(),this->begin());
}
multi_array(const multi_array_ref<T,NumDims>& rhs,
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.
std::copy(rhs.begin(),rhs.end(),this->begin());
}
multi_array(const detail::multi_array::
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());
}
multi_array(const detail::multi_array::
sub_array<T,NumDims>& rhs,
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());
}
multi_array(const detail::multi_array::
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());
}
multi_array(const detail::multi_array::
multi_array_view<T,NumDims>& rhs,
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());
}
// Since assignment is a deep copy, multi_array_ref
// Since assignment is a deep copy, multi_array_ref
// contains all the necessary code.
template <typename ConstMultiArray>
multi_array& operator=(const ConstMultiArray& other) {
@@ -380,30 +177,12 @@ public:
}
template <typename ExtentList>
multi_array& resize(const ExtentList& extents) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
typedef detail::multi_array::extent_gen<NumDims> gen_type;
gen_type ranges;
for (int i=0; i != NumDims; ++i) {
typedef typename gen_type::range range_type;
ranges.ranges_[i] = range_type(0,extents[i]);
}
return this->resize(ranges);
}
multi_array& resize(const detail::multi_array
::extent_gen<NumDims>& ranges) {
// build a multi_array with the specs given
multi_array new_array(ranges,this->storage_order());
multi_array new_array(ranges);
// build a view of tmp with the minimum extents
@@ -412,13 +191,13 @@ public:
boost::array<size_type,NumDims> min_extents;
const size_type& (*min)(const size_type&, const size_type&) =
std::min;
std::min<size_type>;
std::transform(new_array.extent_list_.begin(),new_array.extent_list_.end(),
this->extent_list_.begin(),
min_extents.begin(),
min);
// typedef boost::array<index,NumDims> index_list;
// Build index_gen objects to create views with the same shape
@@ -429,19 +208,17 @@ 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
typename
multi_array::BOOST_NESTED_TEMPLATE array_view<NumDims>::type view_old = (*this)[old_idxes];
typename
multi_array::BOOST_NESTED_TEMPLATE array_view<NumDims>::type view_new = new_array[new_idxes];
typename multi_array::array_view<3>::type view_old = (*this)[old_idxes];
typename multi_array::array_view<3>::type view_new = new_array[new_idxes];
// Set the right portion of the new array
view_new = view_old;
@@ -483,8 +260,8 @@ private:
allocator_.destroy(i);
allocator_.deallocate(base_,allocated_elements_);
}
}
}
typedef boost::array<size_type,NumDims> size_list;
typedef boost::array<index,NumDims> index_list;

View File

@@ -26,25 +26,23 @@
// representations about the suitability of this software for any
// purpose. It is provided "as is" without express or implied warranty.
//
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#include "boost/iterator.hpp"
namespace boost {
namespace detail {
namespace multi_array {
//--------------------------------------------------
// copy_n (not part of the C++ standard)
#if 1
@@ -96,8 +94,7 @@ copy_n(InputIter first, Size count, OutputIter result) {
}
#endif // 1
} // namespace multi_array
} // namespace detail
} // namespace boost
#endif // BOOST_ALGORITHM_RG071801_HPP

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BASE_RG071801_HPP
#define BASE_RG071801_HPP
@@ -25,15 +25,10 @@
#include "boost/multi_array/storage_order.hpp"
#include "boost/multi_array/types.hpp"
#include "boost/config.hpp"
#include "boost/multi_array/concept_checks.hpp" //for ignore_unused_...
#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/multi_array/iterator_adaptors.hpp"
#include "boost/static_assert.hpp"
#include "boost/type.hpp"
#include "boost/assert.hpp"
#include <cassert>
#include <cstddef>
#include <memory>
@@ -81,8 +76,27 @@ 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>
class array_iterator;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct iterator_generator;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_iterator_generator;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct reverse_iterator_generator;
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_reverse_iterator_generator;
template <typename T,typename TPtr>
struct iterator_base;
template <typename T, std::size_t NumDims>
struct iterator_policies;
template <typename T, std::size_t NumDims, typename TPtr = const T*>
class const_multi_array_view;
@@ -130,13 +144,11 @@ protected:
Reference access(boost::type<Reference>,index idx,TPtr base,
const size_type* extents,
const index* strides,
const index* index_bases) const {
const index* index_base) const {
BOOST_ASSERT(idx - index_bases[0] >= 0);
BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
// return a sub_array<T,NDims-1> proxy object
TPtr newbase = base + idx * strides[0];
return Reference(newbase,extents+1,strides+1,index_bases+1);
return Reference(newbase,extents+1,strides+1,index_base+1);
}
@@ -168,14 +180,9 @@ protected:
// used by array operator[] and iterators to get reference types.
template <typename Reference, typename TPtr>
Reference access(boost::type<Reference>,index idx,TPtr base,
const size_type* extents,
const size_type*,
const index* strides,
const index* index_bases) const {
ignore_unused_variable_warning(index_bases);
ignore_unused_variable_warning(extents);
BOOST_ASSERT(idx - index_bases[0] >= 0);
BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
const index*) const {
return *(base + idx * strides[0]);
}
@@ -188,94 +195,73 @@ protected:
// choose value accessor begins
//
template <typename T, std::size_t NumDims>
struct choose_value_accessor_n {
typedef value_accessor_n<T,NumDims> type;
template <typename T, std::size_t NumDims>
struct bind {
typedef value_accessor_n<T,NumDims> type;
};
};
template <typename T>
struct choose_value_accessor_one {
typedef value_accessor_one<T> type;
template <typename T, std::size_t NumDims>
struct bind {
typedef value_accessor_one<T> type;
};
};
template <typename T, typename NumDims>
template <std::size_t NumDims>
struct value_accessor_gen_helper {
typedef choose_value_accessor_n choice;
};
template <>
struct value_accessor_gen_helper<1> {
typedef choose_value_accessor_one choice;
};
template <typename T, std::size_t NumDims>
struct value_accessor_generator {
BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims::value);
typedef typename
mpl::eval_if_c<(dimensionality == 1),
choose_value_accessor_one<T>,
choose_value_accessor_n<T,dimensionality>
>::type type;
private:
typedef typename value_accessor_gen_helper<NumDims>::choice Choice;
public:
typedef typename Choice::template bind<T,NumDims>::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
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// multi_array/sub_array base stuffs
/////////////////////////////////////////////////////////////////////////
template <std::size_t NumDims>
struct iterator_tag_selector {
typedef std::input_iterator_tag type;
};
template <>
struct iterator_tag_selector<1> {
typedef std::random_access_iterator_tag type;
};
////////////////////////////////////////////////////////////////////////
// multi_array_base
////////////////////////////////////////////////////////////////////////
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;
class multi_array_impl_base :
public value_accessor_generator<T,NumDims>::type {
typedef typename value_accessor_generator<T,NumDims>::type super_type;
public:
typedef typename types::index index;
typedef typename types::size_type size_type;
typedef typename types::element element;
typedef typename types::index_range index_range;
typedef typename types::value_type value_type;
typedef typename types::reference reference;
typedef typename types::const_reference const_reference;
typedef typename super_type::index index;
typedef typename super_type::size_type size_type;
typedef typename super_type::element element;
typedef typename super_type::index_range index_range;
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::const_reference const_reference;
template <std::size_t NDims>
struct subarray {
@@ -301,36 +287,37 @@ public:
//
// iterator support
//
typedef array_iterator<T,T*,mpl::size_t<NumDims>,reference> iterator;
typedef array_iterator<T,T const*,mpl::size_t<NumDims>,const_reference> const_iterator;
typedef ::boost::reverse_iterator<iterator> reverse_iterator;
typedef ::boost::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename iterator_tag_selector<NumDims>::type iterator_tag;
typedef typename
iterator_generator<T,NumDims,value_type,
reference,iterator_tag,index>::type iterator;
typedef typename
const_iterator_generator<T,NumDims,value_type,
const_reference,iterator_tag,index>::type const_iterator;
typedef typename
reverse_iterator_generator<T,NumDims,value_type,
reference,iterator_tag,index>::type reverse_iterator;
typedef typename
const_reverse_iterator_generator<T,NumDims,value_type,
const_reference,iterator_tag,index>::type const_reverse_iterator;
BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims);
protected:
typedef iterator_base<T,T*> iter_base;
typedef iterator_base<T,const T*> const_iter_base;
multi_array_impl_base() { }
~multi_array_impl_base() { }
// Used by operator() in our array classes
template <typename Reference, typename IndexList, typename TPtr>
Reference access_element(boost::type<Reference>,
Reference access_element(boost::type<Reference>, TPtr base,
const IndexList& indices,
TPtr base,
const size_type* extents,
const index* strides,
const index* index_bases) const {
ignore_unused_variable_warning(index_bases);
ignore_unused_variable_warning(extents);
#if !defined(NDEBUG) && !defined(BOOST_DISABLE_ASSERTS)
for (size_type i = 0; i != NumDims; ++i) {
BOOST_ASSERT(indices[i] - index_bases[i] >= 0);
BOOST_ASSERT(size_type(indices[i] - index_bases[i]) < extents[i]);
}
#endif
const index* strides) const {
index offset = 0;
for (size_type n = 0; n != NumDims; ++n)
offset += indices[n] * strides[n];
@@ -437,16 +424,7 @@ protected:
index start = current_range.get_start(default_start);
index finish = current_range.get_finish(default_finish);
index index_factor = current_range.stride();
// integral trick for ceiling((finish-start) / index_factor)
index shrinkage = index_factor > 0 ? 1 : -1;
index len = (finish - start + (index_factor - shrinkage)) / index_factor;
BOOST_ASSERT(index_bases[n] <= start &&
start <= index_bases[n]+index(extents[n]));
BOOST_ASSERT(index_bases[n] <= finish &&
finish <= index_bases[n]+index(extents[n]));
BOOST_ASSERT(index_factor != 0);
index len = (finish - start) / index_factor;
// the array data pointer is modified to account for non-zero
// bases during slicing (see [Garcia] for the math involved)
@@ -463,7 +441,7 @@ protected:
++dim;
}
}
BOOST_ASSERT(dim == NDims);
assert (dim == NDims);
return
ArrayRef(base+offset,

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef COLLECTION_CONCEPT_RG103101_HPP
#define COLLECTION_CONCEPT_RG103101_HPP

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
#define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
@@ -19,7 +19,6 @@
//
#include "boost/concept_check.hpp"
#include "boost/iterator/iterator_concepts.hpp"
namespace boost {
namespace detail {
@@ -61,11 +60,7 @@ namespace multi_array {
struct ConstMultiArrayConcept
{
void constraints() {
// function_requires< CopyConstructibleConcept<Array> >();
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
// function_requires< CopyConstructibleConcept<Array> >();
// RG - a( CollectionArchetype) when available...
a[ id ];
@@ -77,7 +72,6 @@ namespace multi_array {
st = a.size();
st = a.num_dimensions();
st = Array::dimensionality;
st = a.num_elements();
stp = a.shape();
idp = a.strides();
@@ -124,12 +118,6 @@ namespace multi_array {
void constraints() {
// function_requires< CopyConstructibleConcept<Array> >();
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
// RG - a( CollectionArchetype) when available...
value_type vt = a[ id ];

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef COPY_ARRAY_RG092101_HPP
#define COPY_ARRAY_RG092101_HPP
@@ -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

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_EXTENT_GEN_RG071801_HPP
#define BOOST_EXTENT_GEN_RG071801_HPP
@@ -29,8 +29,8 @@ class extent_gen {
public:
typedef boost::detail::multi_array::index index;
typedef boost::detail::multi_array::size_type size_type;
typedef extent_range<index,size_type> range;
private:
typedef extent_range<index,size_type> range;
typedef typename range_list_generator<range,NumRanges>::type range_list;
public:
template <std::size_t Ranges>

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_EXTENT_RANGE_RG071801_HPP
#define BOOST_EXTENT_RANGE_RG071801_HPP

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_INDEX_GEN_RG071801_HPP
#define BOOST_INDEX_GEN_RG071801_HPP
@@ -28,9 +28,9 @@ namespace multi_array {
template <int NumRanges, int NumDims>
struct index_gen {
private:
typedef ::boost::detail::multi_array::index index;
typedef ::boost::detail::multi_array::size_type size_type;
typedef index_range<index,size_type> range;
typedef index Index;
typedef std::size_t SizeType;
typedef index_range<Index,SizeType> range;
public:
template <int Dims, int Ranges>
struct gen_type {
@@ -44,27 +44,27 @@ public:
template <int ND>
explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
const range& r)
const index_range<Index,SizeType>& range)
{
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
*ranges_.rbegin() = r;
*ranges_.rbegin() = range;
}
index_gen<NumRanges+1,NumDims+1>
operator[](const range& r) const
operator[](const index_range<Index,SizeType>& range) const
{
index_gen<NumRanges+1,NumDims+1> tmp;
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
*tmp.ranges_.rbegin() = r;
*tmp.ranges_.rbegin() = range;
return tmp;
}
index_gen<NumRanges+1,NumDims>
operator[](index idx) const
operator[](Index idx) const
{
index_gen<NumRanges+1,NumDims> tmp;
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
*tmp.ranges_.rbegin() = range(idx);
*tmp.ranges_.rbegin() = index_range<Index,SizeType>(idx);
return tmp;
}

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_INDEX_RANGE_RG071801_HPP
#define BOOST_INDEX_RANGE_RG071801_HPP
@@ -35,15 +35,6 @@ namespace multi_array {
typedef Index index;
typedef SizeType size_type;
private:
static index from_start()
{ return (std::numeric_limits<index>::min)(); }
static index to_end()
{ return (std::numeric_limits<index>::max)(); }
public:
index_range()
{
start_ = from_start();
@@ -55,27 +46,27 @@ namespace multi_array {
explicit index_range(index pos)
{
start_ = pos;
finish_ = pos+1;
finish_ = pos;
stride_ = 1;
degenerate_ = true;
}
explicit index_range(index start, index finish, index stride=1)
: start_(start), finish_(finish), stride_(stride),
degenerate_(false)
degenerate_(start_ == finish_)
{ }
// These are for chaining assignments to an index_range
index_range& start(index s) {
start_ = s;
degenerate_ = false;
degenerate_ = (start_ == finish_);
return *this;
}
index_range& finish(index f) {
finish_ = f;
degenerate_ = false;
degenerate_ = (start_ == finish_);
return *this;
}
@@ -86,7 +77,7 @@ namespace multi_array {
return start_;
}
index get_start(index low_index_range = index_range::from_start()) const
index get_start(index low_index_range = 0) const
{
if (start_ == from_start())
return low_index_range;
@@ -98,15 +89,28 @@ namespace multi_array {
return finish_;
}
index get_finish(index high_index_range = index_range::to_end()) const
index get_finish(index high_index_range = 0) const
{
if (finish_ == to_end())
return high_index_range;
return finish_;
}
size_type size(index recommended_length = 0) const
{
if ((start_ == from_start()) || (finish_ == to_end()))
return recommended_length;
else
return (finish_ - start_) / stride_;
}
index stride() const { return stride_; }
bool is_ascending_contiguous() const
{
return (start_ < finish_) && is_unit_stride();
}
void set_index_range(index start, index finish, index stride=1)
{
start_ = start;
@@ -117,6 +121,9 @@ namespace multi_array {
static index_range all()
{ return index_range(from_start(), to_end(), 1); }
bool is_unit_stride() const
{ return stride_ == 1; }
bool is_degenerate() const { return degenerate_; }
index_range operator-(index shift) const
@@ -141,6 +148,12 @@ namespace multi_array {
// add conversion to std::slice?
private:
static index from_start()
{ return std::numeric_limits<index>::min(); }
static index to_end()
{ return std::numeric_limits<index>::max(); }
public:
index start_, finish_, stride_;
bool degenerate_;

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef ITERATOR_RG071801_HPP
#define ITERATOR_RG071801_HPP
@@ -19,9 +19,8 @@
//
#include "boost/multi_array/base.hpp"
#include "boost/iterator/iterator_facade.hpp"
#include "boost/mpl/aux_/msvc_eti_base.hpp"
#include <algorithm>
#include "boost/multi_array/iterator_adaptors.hpp"
#include "boost/iterator_adaptors.hpp"
#include <cstddef>
#include <iterator>
@@ -33,134 +32,136 @@ namespace multi_array {
// iterator components
/////////////////////////////////////////////////////////////////////////
template <class T>
struct operator_arrow_proxy
{
operator_arrow_proxy(T const& px) : value_(px) {}
T* operator->() const { return &value_; }
// This function is needed for MWCW and BCC, which won't call operator->
// again automatically per 13.3.1.2 para 8
operator T*() const { return &value_; }
mutable T value_;
};
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator;
template <typename T, typename TPtr, typename NumDims, typename Reference>
class array_iterator
: public
iterator_facade<
array_iterator<T,TPtr,NumDims,Reference>
, typename associated_types<T,NumDims>::value_type
, 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 iterator_core_access;
typedef detail::multi_array::associated_types<T,NumDims> access_t;
typedef iterator_facade<
array_iterator<T,TPtr,NumDims,Reference>
, typename detail::multi_array::associated_types<T,NumDims>::value_type
, boost::random_access_traversal_tag
, Reference
> facade_type;
typedef typename access_t::index index;
typedef typename access_t::size_type size_type;
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
template <typename, typename, typename, typename>
friend class array_iterator;
#else
public:
#endif
template <typename T, typename TPtr>
struct iterator_base : private multi_array_base {
typedef multi_array_base super_type;
typedef super_type::index index;
typedef super_type::size_type size_type;
index idx_;
TPtr base_;
const size_type* extents_;
const index* strides_;
const index* index_base_;
public:
// Typedefs to circumvent ambiguities between parent classes
typedef typename facade_type::reference reference;
typedef typename facade_type::value_type value_type;
typedef typename facade_type::difference_type difference_type;
array_iterator() {}
array_iterator(index idx, TPtr base, const size_type* extents,
iterator_base(int idx, TPtr base, const size_type* extents,
const index* strides,
const index* index_base) :
idx_(idx), base_(base), extents_(extents),
strides_(strides), index_base_(index_base) { }
strides_(strides), index_base_(index_base) {
}
template <typename OPtr, typename ORef>
array_iterator(
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_),
strides_(rhs.strides_), index_base_(rhs.index_base_) { }
template <typename OPtr>
iterator_base(const iterator_base<T,OPtr>& rhs) :
idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),
strides_(rhs.strides_), index_base_(rhs.index_base_) {
}
// default constructor required
iterator_base() {}
};
// RG - we make our own operator->
operator_arrow_proxy<reference>
operator->() const
{
return operator_arrow_proxy<reference>(this->dereference());
template<typename T, std::size_t NumDims>
struct iterator_policies :
public boost::detail::multi_array::default_iterator_policies,
private value_accessor_generator<T,NumDims>::type {
private:
typedef typename value_accessor_generator<T,NumDims>::type super_type;
public:
template <class IteratorAdaptor>
typename IteratorAdaptor::reference
dereference(const IteratorAdaptor& iter) const {
typedef typename IteratorAdaptor::reference reference;
return super_type::access(boost::type<reference>(),
iter.base().idx_,
iter.base().base_,
iter.base().extents_,
iter.base().strides_,
iter.base().index_base_);
}
reference dereference() const
{
typedef typename value_accessor_generator<T,NumDims>::type accessor;
return accessor::access(boost::type<reference>(),
idx_,
base_,
extents_,
strides_,
index_base_);
}
void increment() { ++idx_; }
void decrement() { --idx_; }
template <class IteratorAdaptor>
static void increment(IteratorAdaptor& x) { ++x.base().idx_; }
template <class IteratorAdaptor>
bool equal(IteratorAdaptor& rhs) const {
const std::size_t N = NumDims::value;
return (idx_ == rhs.idx_) &&
(base_ == rhs.base_) &&
( (extents_ == rhs.extents_) ||
std::equal(extents_,extents_+N,rhs.extents_) ) &&
( (strides_ == rhs.strides_) ||
std::equal(strides_,strides_+N,rhs.strides_) ) &&
( (index_base_ == rhs.index_base_) ||
std::equal(index_base_,index_base_+N,rhs.index_base_) );
static void decrement(IteratorAdaptor& x) { --x.base().idx_; }
template <class IteratorAdaptor1, class IteratorAdaptor2>
bool equal(IteratorAdaptor1& lhs, IteratorAdaptor2& rhs) const {
return (lhs.base().idx_ == rhs.base().idx_) &&
(lhs.base().base_ == rhs.base().base_) &&
(lhs.base().extents_ == rhs.base().extents_) &&
(lhs.base().strides_ == rhs.base().strides_) &&
(lhs.base().index_base_ == rhs.base().index_base_);
}
template <class DifferenceType>
void advance(DifferenceType n) {
idx_ += n;
template <class IteratorAdaptor, class DifferenceType>
static void advance(IteratorAdaptor& x, DifferenceType n) {
x.base().idx_ += n;
}
template <class IteratorAdaptor>
typename facade_type::difference_type
distance_to(IteratorAdaptor& rhs) const {
return rhs.idx_ - idx_;
template <class IteratorAdaptor1, class IteratorAdaptor2>
typename IteratorAdaptor1::difference_type
distance(IteratorAdaptor1& lhs, IteratorAdaptor2& rhs) const {
return rhs.base().idx_ - lhs.base().idx_;
}
};
template <typename T, typename base_type,
std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct iterator_gen_helper {
private:
typedef iterator_policies<T,NumDims> policies;
typedef value_type* pointer_type;
typedef tag category;
public:
typedef boost::detail::multi_array::iterator_adaptor<base_type,policies,value_type,
reference_type,pointer_type,category,difference_type> type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct iterator_generator {
private:
typedef iterator_base<T,T*> base_type;
public:
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_iterator_generator {
private:
typedef iterator_base<T,const T*> base_type;
public:
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct reverse_iterator_generator {
private:
typedef iterator_base<T,T*> base_type;
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type it_type;
public:
typedef typename boost::reverse_iterator_generator<it_type>::type type;
};
template <typename T, std::size_t NumDims, typename value_type,
typename reference_type, typename tag, typename difference_type>
struct const_reverse_iterator_generator {
private:
typedef iterator_base<T,const T*> base_type;
typedef typename iterator_gen_helper<T,base_type,NumDims,value_type,
reference_type,tag,difference_type>::type it_type;
public:
typedef typename boost::reverse_iterator_generator<it_type>::type type;
};
} // namespace multi_array

View File

@@ -0,0 +1,970 @@
// (C) Copyright David Abrahams 2000. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
//
// (C) Copyright Jeremy Siek 2000. Permission to copy, use, modify,
// sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
//
// Thes code is modified from its original form to meet the needs of
// Boost.MultiArray.
// Revision History:
// 27 Mar 2002 Ronald Garcia
// Forked from the main tree iterator adaptors. Necessary to
// allow iterator::operator->*() to work with multi_array iterators.
// 01 Feb 2002 Jeremy Siek
// Added more comments in default_iterator_policies.
// 08 Jan 2001 David Abrahams
// Moved concept checks into a separate class, which makes MSVC
// better at dealing with them.
// 07 Jan 2001 David Abrahams
// Choose proxy for operator->() only if the reference type is not a reference.
// Updated workarounds for __MWERKS__ == 0x2406
// 20 Dec 2001 David Abrahams
// Adjusted is_convertible workarounds for __MWERKS__ == 0x2406
// 03 Nov 2001 Jeremy Siek
// Changed the named template parameter interface and internal.
// 04 Oct 2001 Jeremy Siek
// Changed projection_iterator to not rely on the default reference,
// working around a limitation of detail::iterator_traits.
// 04 Oct 2001 David Abrahams
// Applied indirect_iterator patch from George A. Heintzelman <georgeh@aya.yale.edu>
// Changed name of "bind" to "select" to avoid problems with MSVC.
// 26 Sep 2001 David Abrahams
// Added borland bug fix
// 08 Mar 2001 Jeremy Siek
// Added support for optional named template parameters.
// 19 Feb 2001 David Abrahams
// Rolled back reverse_iterator_pair_generator again, as it doesn't
// save typing on a conforming compiler.
// 18 Feb 2001 David Abrahams
// Reinstated reverse_iterator_pair_generator
// 16 Feb 2001 David Abrahams
// Add an implicit conversion operator to operator_arrow_proxy
// as CW and BCC workarounds.
// 11 Feb 2001 David Abrahams
// Switch to use of BOOST_STATIC_CONSTANT where possible
// 11 Feb 2001 Jeremy Siek
// Removed workaround for older MIPSpro compiler. The workaround
// was preventing the proper functionality of the underlying
// iterator being carried forward into the iterator adaptor.
// Also added is_bidirectional enum to avoid EDG compiler error.
// 11 Feb 2001 David Abrahams
// Borland fixes up the wazoo. It finally works!
// 10 Feb 2001 David Abrahams
// Removed traits argument from iterator_adaptor<> and switched to
// explicit trait specification for maximum ease-of-use.
// Added comments to detail::iterator_defaults<>
// Began using detail::iterator_defaults<> unconditionally for code clarity
// Changed uses of `Iterator' to `Base' where non-iterators can be used.
//
// 10 Feb 2001 David Abrahams
// Rolled in supposed Borland fixes from John Maddock, but not seeing any
// improvement yet
// Changed argument order to indirect_ generator, for convenience in the
// case of input iterators (where Reference must be a value type).
// Removed derivation of filter_iterator_policies from
// default_iterator_policies, since the iterator category is likely to be
// reduced (we don't want to allow illegal operations like decrement).
// Support for a simpler filter iterator interface.
//
// 09 Feb 2001 David Abrahams
// Improved interface to indirect_ and reverse_ iterators
// Rolled back Jeremy's new constructor for now; it was causing
// problems with counting_iterator_test
// Attempted fix for Borland
//
// 09 Feb 2001 Jeremy Siek
// Added iterator constructor to allow const adaptor
// from non-const adaptee.
// Changed make_xxx to pass iterators by-value to
// get arrays converted to pointers.
// Removed InnerIterator template parameter from
// indirect_iterator_generator.
// Rearranged parameters for make_filter_iterator
//
// 07 Feb 2001 Jeremy Siek
// Removed some const iterator adaptor generators.
// Added make_xxx_iterator() helper functions for remaining
// iterator adaptors.
// Removed some traits template parameters where they
// where no longer needed thanks to detail::iterator_traits.
// Moved some of the compile-time logic into enums for
// EDG compatibility.
//
// 07 Feb 2001 David Abrahams
// Removed iterator_adaptor_pair_generator and
// reverse_iterator_pair_generator (more such culling to come)
// Improved comments
// Changed all uses of std::iterator_traits as default arguments
// to boost::detail::iterator_traits for improved utility in
// non-generic contexts
// Fixed naming convention of non-template parameter names
//
// 06 Feb 2001 David Abrahams
// Produce operator-> proxy objects for InputIterators
// Added static assertions to do some basic concept checks
// Renamed single-type generators -> xxx_generator
// Renamed const/nonconst iterator generators -> xxx_pair_generator
// Added make_transform_iterator(iter, function)
// The existence of boost::detail::iterator_traits allowed many
// template arguments to be defaulted. Some arguments had to be
// moved to accomplish it.
//
// 04 Feb 2001 MWERKS bug workaround, concept checking for proper
// reference types (David Abrahams)
#ifndef BOOST_ITERATOR_ADAPTOR_RG032702_HPP_
# define BOOST_ITERATOR_ADAPTOR_RG032702_HPP_
# include <boost/iterator.hpp>
# include <boost/utility.hpp>
# include <boost/compressed_pair.hpp>
# include <boost/concept_check.hpp>
# include <boost/type.hpp>
# include <boost/static_assert.hpp>
# include <boost/type_traits.hpp>
# include <boost/detail/iterator.hpp>
# include <boost/detail/select_type.hpp>
// I was having some problems with VC6. I couldn't tell whether our hack for
// stock GCC was causing problems so I needed an easy way to turn it on and
// off. Now we can test the hack with various compilers and still have an
// "out" if it doesn't work. -dwa 7/31/00
# if __GNUC__ == 2 && __GNUC_MINOR__ <= 96 && !defined(__STL_USE_NAMESPACES)
# define BOOST_RELOPS_AMBIGUITY_BUG 1
# endif
namespace boost {
namespace detail {
namespace multi_array {
//============================================================================
// Default policies for iterator adaptors. You can use this as a base
// class if you want to customize particular policies.
struct default_iterator_policies
{
// Some of the member functions were defined static, but Borland
// got confused and thought they were non-const. Also, Sun C++
// does not like static function templates.
//
// The reason some members were defined static is because there is
// not state (data members) needed by those members of the
// default_iterator_policies class. If your policies class member
// functions need to access state stored in the policies object,
// then the member functions should not be static (they can't be).
template <class Base>
void initialize(Base&)
{ }
template <class IteratorAdaptor>
typename IteratorAdaptor::reference dereference(const IteratorAdaptor& x) const
{ return *x.base(); }
template <class IteratorAdaptor>
void increment(IteratorAdaptor& x)
{ ++x.base(); }
template <class IteratorAdaptor>
void decrement(IteratorAdaptor& x)
{ --x.base(); }
template <class IteratorAdaptor, class DifferenceType>
void advance(IteratorAdaptor& x, DifferenceType n)
{ x.base() += n; }
template <class IteratorAdaptor1, class IteratorAdaptor2>
typename IteratorAdaptor1::difference_type
distance(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
{ return y.base() - x.base(); }
template <class IteratorAdaptor1, class IteratorAdaptor2>
bool equal(const IteratorAdaptor1& x, const IteratorAdaptor2& y) const
{ return x.base() == y.base(); }
};
// putting the comparisons in a base class avoids the g++
// ambiguous overload bug due to the relops operators
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
template <class Derived, class Base>
struct iterator_comparisons : Base { };
template <class D1, class D2, class Base1, class Base2>
inline bool operator==(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().equal(x, y);
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator!=(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return !x.policies().equal(x, y);
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator<(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) < 0;
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator>(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) > 0;
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator>=(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) >= 0;
}
template <class D1, class D2, class Base1, class Base2>
inline bool operator<=(const iterator_comparisons<D1,Base1>& xb,
const iterator_comparisons<D2,Base2>& yb)
{
const D1& x = static_cast<const D1&>(xb);
const D2& y = static_cast<const D2&>(yb);
return x.policies().distance(y, x) <= 0;
}
#endif
namespace detail {
// operator->() needs special support for input iterators to strictly meet the
// standard's requirements. If *i is not a reference type, we must still
// produce a (constant) lvalue to which a pointer can be formed. We do that by
// returning an instantiation of this special proxy class template.
template <class T>
struct operator_arrow_proxy
{
operator_arrow_proxy(const T& x) : m_value(x) {}
// RG removed const below
T* operator->() const { return &m_value; }
// This function is needed for MWCW and BCC, which won't call operator->
// again automatically per 13.3.1.2 para 8
// RG - removed const below
operator T*() const { return &m_value; }
mutable T m_value;
};
template <class Iter>
inline operator_arrow_proxy<typename Iter::reference>
operator_arrow(const Iter& i, std::input_iterator_tag) {
// RG - THIS is the change I needed to make!
// My input iterators need to return proxy references rather than values
typedef typename Iter::reference value_t; // VC++ needs this typedef
return operator_arrow_proxy<value_t>(*i);
}
template <class Iter>
inline typename Iter::pointer
operator_arrow(const Iter& i, std::forward_iterator_tag) {
return &(*i);
}
template <class Value, class Reference, class Pointer>
struct operator_arrow_result_generator
{
//RG - another important change!
typedef operator_arrow_proxy<Reference> proxy;
// Borland chokes unless it's an actual enum (!)
enum { use_proxy = !boost::is_reference<Reference>::value };
typedef typename boost::detail::if_true<(use_proxy)>::template
then<
proxy,
// else
Pointer
>::type type;
};
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(BOOST_NO_STD_ITERATOR_TRAITS)
// Select default pointer and reference types for adapted non-pointer
// iterators based on the iterator and the value_type. Poor man's partial
// specialization is in use here.
template <bool is_pointer>
struct iterator_defaults_select
{
template <class Iterator,class Value>
struct traits
{
// The assumption is that iterator_traits can deduce these types
// properly as long as the iterator is not a pointer.
typedef typename boost::detail::iterator_traits<Iterator>::pointer pointer;
typedef typename boost::detail::iterator_traits<Iterator>::reference reference;
};
};
// Select default pointer and reference types for adapted pointer iterators
// given a (possibly-const) value_type.
template <>
struct iterator_defaults_select<true>
{
template <class Iterator,class Value>
struct traits
{
typedef Value* pointer;
typedef Value& reference;
};
};
// Consolidate selection of the default pointer and reference type
template <class Iterator,class Value>
struct iterator_defaults
{
BOOST_STATIC_CONSTANT(bool, is_ptr = boost::is_pointer<Iterator>::value);
typedef typename iterator_defaults_select<is_ptr>::template traits<Iterator,Value> traits;
typedef typename traits::pointer pointer;
typedef typename traits::reference reference;
};
# else
template <class Iterator,class Value>
struct iterator_defaults : iterator_traits<Iterator>
{
// Trying to factor the common is_same expression into an enum or a
// static bool constant confused Borland.
typedef typename if_true<(
::boost::is_same<Value,typename iterator_traits<Iterator>::value_type>::value
)>::template then<
typename iterator_traits<Iterator>::pointer,
Value*
>::type pointer;
typedef typename if_true<(
::boost::is_same<Value,typename iterator_traits<Iterator>::value_type>::value
)>::template then<
typename iterator_traits<Iterator>::reference,
Value&
>::type reference;
};
# endif
//===========================================================================
// Specify the defaults for iterator_adaptor's template parameters
struct default_argument { };
// This class template is a workaround for MSVC.
struct dummy_default_gen {
template <class Base, class Traits>
struct select { typedef default_argument type; };
};
// This class template is a workaround for MSVC.
template <class Gen> struct default_generator {
typedef dummy_default_gen type;
};
struct default_value_type {
template <class Base, class Traits>
struct select {
typedef typename boost::detail::iterator_traits<Base>::value_type type;
};
};
template <> struct default_generator<default_value_type>
{ typedef default_value_type type; }; // VC++ workaround
struct default_difference_type {
template <class Base, class Traits>
struct select {
typedef typename boost::detail::iterator_traits<Base>::difference_type type;
};
};
template <> struct default_generator<default_difference_type>
{ typedef default_difference_type type; }; // VC++ workaround
struct default_iterator_category {
template <class Base, class Traits>
struct select {
typedef typename boost::detail::iterator_traits<Base>::iterator_category type;
};
};
template <> struct default_generator<default_iterator_category>
{ typedef default_iterator_category type; }; // VC++ workaround
struct default_pointer {
template <class Base, class Traits>
struct select {
typedef typename Traits::value_type Value;
typedef typename boost::detail::multi_array::detail::iterator_defaults<Base,Value>::pointer
type;
};
};
template <> struct default_generator<default_pointer>
{ typedef default_pointer type; }; // VC++ workaround
struct default_reference {
template <class Base, class Traits>
struct select {
typedef typename Traits::value_type Value;
typedef typename boost::detail::multi_array::detail::iterator_defaults<Base,Value>::reference
type;
};
};
template <> struct default_generator<default_reference>
{ typedef default_reference type; }; // VC++ workaround
} // namespace detail
//===========================================================================
// Support for named template parameters
struct named_template_param_base { };
namespace detail {
struct value_type_tag { };
struct reference_tag { };
struct pointer_tag { };
struct difference_type_tag { };
struct iterator_category_tag { };
// avoid using std::pair because A or B might be a reference type, and g++
// complains about forming references to references inside std::pair
template <class A, class B>
struct cons_type {
typedef A first_type;
typedef B second_type;
};
} // namespace detail
template <class Value> struct value_type_is : public named_template_param_base
{
typedef detail::cons_type<detail::value_type_tag, Value> type;
};
template <class Reference> struct reference_is : public named_template_param_base
{
typedef detail::cons_type<detail::reference_tag, Reference> type;
};
template <class Pointer> struct pointer_is : public named_template_param_base
{
typedef detail::cons_type<detail::pointer_tag, Pointer> type;
};
template <class Difference> struct difference_type_is
: public named_template_param_base
{
typedef detail::cons_type<detail::difference_type_tag, Difference> type;
};
template <class IteratorCategory> struct iterator_category_is
: public named_template_param_base
{
typedef detail::cons_type<detail::iterator_category_tag, IteratorCategory> type;
};
namespace detail {
struct end_of_list { };
// Given an associative list, find the value with the matching key.
// An associative list is a list of key-value pairs. The list is
// built out of cons_type's and is terminated by end_of_list.
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) || defined(__BORLANDC__)
template <class AssocList, class Key>
struct find_param;
struct find_param_continue {
template <class AssocList, class Key2> struct select {
typedef typename AssocList::first_type Head;
typedef typename Head::first_type Key1;
typedef typename Head::second_type Value;
typedef typename if_true<(is_same<Key1, Key2>::value)>::template
then<Value,
typename find_param<typename AssocList::second_type, Key2>::type
>::type type;
};
};
struct find_param_end {
template <class AssocList, class Key>
struct select { typedef detail::default_argument type; };
};
template <class AssocList> struct find_param_helper1
{ typedef find_param_continue type; };
template <> struct find_param_helper1<end_of_list>
{ typedef find_param_end type; };
template <class AssocList, class Key>
struct find_param {
typedef typename find_param_helper1<AssocList>::type select1;
typedef typename select1::template select<AssocList, Key>::type type;
};
# else
template <class AssocList, class Key> struct find_param;
template <class Key>
struct find_param<end_of_list, Key> { typedef default_argument type; };
// Found a matching Key, return the associated Value
template <class Key, class Value, class Rest>
struct find_param<detail::cons_type< detail::cons_type<Key, Value>, Rest>, Key> {
typedef Value type;
};
// Non-matching keys, continue the search
template <class Key1, class Value, class Rest, class Key2>
struct find_param<detail::cons_type< detail::cons_type<Key1, Value>, Rest>, Key2> {
typedef typename find_param<Rest, Key2>::type type;
};
# endif
struct make_named_arg {
template <class Key, class Value>
struct select { typedef typename Value::type type; };
};
struct make_key_value {
template <class Key, class Value>
struct select { typedef detail::cons_type<Key, Value> type; };
};
template <class Value>
struct is_named_parameter
{
enum { value = is_convertible<Value, named_template_param_base>::value };
};
# if defined(__MWERKS__) && __MWERKS__ <= 0x2406 // workaround for broken is_convertible implementation
template <class T> struct is_named_parameter<value_type_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<reference_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<pointer_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<difference_type_is<T> > { enum { value = true }; };
template <class T> struct is_named_parameter<iterator_category_is<T> > { enum { value = true }; };
# endif
template <class Key, class Value>
struct make_arg {
# ifdef __BORLANDC__
// Borland C++ doesn't like the extra indirection of is_named_parameter
typedef typename
if_true<(is_convertible<Value,named_template_param_base>::value)>::
template then<make_named_arg, make_key_value>::type Make;
# else
enum { is_named = is_named_parameter<Value>::value };
typedef typename if_true<(is_named)>::template
then<make_named_arg, make_key_value>::type Make;
# endif
typedef typename Make::template select<Key, Value>::type type;
};
// Mechanism for resolving the default argument for a template parameter.
template <class T> struct is_default { typedef type_traits::no_type type; };
template <> struct is_default<default_argument>
{ typedef type_traits::yes_type type; };
struct choose_default {
template <class Arg, class DefaultGen, class Base, class Traits>
struct select {
typedef typename default_generator<DefaultGen>::type Gen;
typedef typename Gen::template select<Base,Traits>::type type;
};
};
struct choose_arg {
template <class Arg, class DefaultGen, class Base, class Traits>
struct select {
typedef Arg type;
};
};
template <class UseDefault>
struct choose_arg_or_default { typedef choose_arg type; };
template <> struct choose_arg_or_default<type_traits::yes_type> {
typedef choose_default type;
};
template <class Arg, class DefaultGen, class Base, class Traits>
class resolve_default {
typedef typename choose_arg_or_default<typename is_default<Arg>::type>::type
Selector;
public:
typedef typename Selector
::template select<Arg, DefaultGen, Base, Traits>::type type;
};
template <class Base, class Value, class Reference, class Pointer,
class Category, class Distance>
class iterator_adaptor_traits_gen
{
// Form an associative list out of the template parameters
// If the argument is a normal parameter (not named) then make_arg
// creates a key-value pair. If the argument is a named parameter,
// then make_arg extracts the key-value pair defined inside the
// named parameter.
typedef detail::cons_type< typename make_arg<value_type_tag, Value>::type,
detail::cons_type<typename make_arg<reference_tag, Reference>::type,
detail::cons_type<typename make_arg<pointer_tag, Pointer>::type,
detail::cons_type<typename make_arg<iterator_category_tag, Category>::type,
detail::cons_type<typename make_arg<difference_type_tag, Distance>::type,
end_of_list> > > > > ArgList;
// Search the list for particular parameters
typedef typename find_param<ArgList, value_type_tag>::type Val;
typedef typename find_param<ArgList, difference_type_tag>::type Diff;
typedef typename find_param<ArgList, iterator_category_tag>::type Cat;
typedef typename find_param<ArgList, pointer_tag>::type Ptr;
typedef typename find_param<ArgList, reference_tag>::type Ref;
typedef boost::iterator<Category, Value, Distance, Pointer, Reference>
Traits0;
// Compute the defaults if necessary
typedef typename resolve_default<Val, default_value_type, Base, Traits0>::type
value_type;
// if getting default value type from iterator_traits, then it won't be const
typedef typename resolve_default<Diff, default_difference_type, Base,
Traits0>::type difference_type;
typedef typename resolve_default<Cat, default_iterator_category, Base,
Traits0>::type iterator_category;
typedef boost::iterator<iterator_category, value_type, difference_type,
Pointer, Reference> Traits1;
// Compute the defaults for pointer and reference. This is done as a
// separate step because the defaults for pointer and reference depend
// on value_type.
typedef typename resolve_default<Ptr, default_pointer, Base, Traits1>::type
pointer;
typedef typename resolve_default<Ref, default_reference, Base, Traits1>::type
reference;
public:
typedef boost::iterator<iterator_category,
typename remove_const<value_type>::type,
difference_type, pointer, reference> type;
};
// This is really a partial concept check for iterators. Should it
// be moved or done differently?
template <class Category, class Value, class Difference, class Pointer, class Reference>
struct validator
{
BOOST_STATIC_CONSTANT(
bool, is_input_or_output_iter
= (boost::is_convertible<Category*,std::input_iterator_tag*>::value
| boost::is_convertible<Category*,std::output_iterator_tag*>::value));
// Iterators should satisfy one of the known categories
BOOST_STATIC_ASSERT(is_input_or_output_iter);
// Iterators >= ForwardIterator must produce real references
// as required by the C++ standard requirements in Table 74.
BOOST_STATIC_CONSTANT(
bool, forward_iter_with_real_reference
= ((!boost::is_convertible<Category*,std::forward_iterator_tag*>::value)
| boost::is_same<Reference,Value&>::value
| boost::is_same<Reference,typename add_const<Value>::type&>::value));
BOOST_STATIC_ASSERT(forward_iter_with_real_reference);
};
} // namespace detail
// This macro definition is only temporary in this file
# if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
# define BOOST_ARG_DEPENDENT_TYPENAME typename
# else
# define BOOST_ARG_DEPENDENT_TYPENAME
# endif
//============================================================================
//iterator_adaptor - Adapts a generic piece of data as an iterator. Adaptation
// is especially easy if the data being adapted is itself an iterator
//
// Base - the base (usually iterator) type being wrapped.
//
// Policies - a set of policies determining how the resulting iterator
// works.
//
// Value - if supplied, the value_type of the resulting iterator, unless
// const. If const, a conforming compiler strips constness for the
// value_type. If not supplied, iterator_traits<Base>::value_type is used
//
// Reference - the reference type of the resulting iterator, and in
// particular, the result type of operator*(). If not supplied but
// Value is supplied, Value& is used. Otherwise
// iterator_traits<Base>::reference is used.
//
// Pointer - the pointer type of the resulting iterator, and in
// particular, the result type of operator->(). If not
// supplied but Value is supplied, Value* is used. Otherwise
// iterator_traits<Base>::pointer is used.
//
// Category - the iterator_category of the resulting iterator. If not
// supplied, iterator_traits<Base>::iterator_category is used.
//
// Distance - the difference_type of the resulting iterator. If not
// supplied, iterator_traits<Base>::difference_type is used.
template <class Base, class Policies,
class Value = ::boost::detail::multi_array::detail::default_argument,
class Reference = ::boost::detail::multi_array::detail::default_argument,
class Pointer = ::boost::detail::multi_array::detail::default_argument,
class Category = ::boost::detail::multi_array::detail::default_argument,
class Distance = ::boost::detail::multi_array::detail::default_argument
>
struct iterator_adaptor :
#ifdef BOOST_RELOPS_AMBIGUITY_BUG
iterator_comparisons<
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance>,
typename detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category, Distance>::type
>
#else
detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category,Distance>::type
#endif
{
typedef iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance> self;
public:
typedef detail::iterator_adaptor_traits_gen<Base,Value,Reference,Pointer,Category,Distance> TraitsGen;
typedef typename TraitsGen::type Traits;
typedef typename Traits::difference_type difference_type;
typedef typename Traits::value_type value_type;
typedef typename Traits::pointer pointer;
typedef typename Traits::reference reference;
typedef typename Traits::iterator_category iterator_category;
typedef Base base_type;
typedef Policies policies_type;
private:
typedef detail::validator<
iterator_category,value_type,difference_type,pointer,reference
> concept_check;
public:
iterator_adaptor()
{
}
explicit
iterator_adaptor(const Base& it, const Policies& p = Policies())
: m_iter_p(it, p) {
policies().initialize(base());
}
template <class Iter2, class Value2, class Pointer2, class Reference2>
iterator_adaptor (
const iterator_adaptor<Iter2,Policies,Value2,Reference2,Pointer2,Category,Distance>& src)
: m_iter_p(src.base(), src.policies())
{
policies().initialize(base());
}
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 || defined(__BORLANDC__)
// This is required to prevent a bug in how VC++ generates
// the assignment operator for compressed_pair
iterator_adaptor& operator= (const iterator_adaptor& x) {
m_iter_p = x.m_iter_p;
return *this;
}
#endif
reference operator*() const {
return policies().dereference(*this);
}
#ifdef BOOST_MSVC
# pragma warning(push)
# pragma warning( disable : 4284 )
#endif
typename boost::detail::multi_array::detail::operator_arrow_result_generator<value_type,reference,pointer>::type
operator->() const
{ return detail::operator_arrow(*this, iterator_category()); }
#ifdef BOOST_MSVC
# pragma warning(pop)
#endif
value_type operator[](difference_type n) const
{ return *(*this + n); }
self& operator++() {
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
policies().increment(*this);
#else
// Odd bug, MWERKS couldn't deduce the type for the member template
// Workaround by explicitly specifying the type.
policies().increment<self>(*this);
#endif
return *this;
}
self operator++(int) { self tmp(*this); ++*this; return tmp; }
self& operator--() {
#if !defined(__MWERKS__) || __MWERKS__ >= 0x2405
policies().decrement(*this);
#else
policies().decrement<self>(*this);
#endif
return *this;
}
self operator--(int) { self tmp(*this); --*this; return tmp; }
self& operator+=(difference_type n) {
policies().advance(*this, n);
return *this;
}
self& operator-=(difference_type n) {
policies().advance(*this, -n);
return *this;
}
base_type const& base() const { return m_iter_p.first(); }
// Moved from global scope to avoid ambiguity with the operator-() which
// subtracts iterators from one another.
self operator-(difference_type x) const
{ self result(*this); return result -= x; }
private:
compressed_pair<Base,Policies> m_iter_p;
public: // implementation details (too many compilers have trouble when these are private).
base_type& base() { return m_iter_p.first(); }
Policies& policies() { return m_iter_p.second(); }
const Policies& policies() const { return m_iter_p.second(); }
};
template <class Base, class Policies, class Value, class Reference, class Pointer,
class Category, class Distance1, class Distance2>
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1>
operator+(
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1> p,
Distance2 x)
{
return p += x;
}
template <class Base, class Policies, class Value, class Reference, class Pointer,
class Category, class Distance1, class Distance2>
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1>
operator+(
Distance2 x,
iterator_adaptor<Base,Policies,Value,Reference,Pointer,Category,Distance1> p)
{
return p += x;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2, class Category,
class Distance>
typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>::difference_type
operator-(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
typedef typename iterator_adaptor<Iterator1,Policies,Value1,Reference1,
Pointer1,Category,Distance>::difference_type difference_type;
return x.policies().distance(y, x);
}
#ifndef BOOST_RELOPS_AMBIGUITY_BUG
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator==(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().equal(x, y);
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator<(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) < 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator>(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) > 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator>=(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) >= 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator<=(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return x.policies().distance(y, x) <= 0;
}
template <class Iterator1, class Iterator2, class Policies, class Value1, class Value2,
class Reference1, class Reference2, class Pointer1, class Pointer2,
class Category, class Distance>
inline bool
operator!=(
const iterator_adaptor<Iterator1,Policies,Value1,Reference1,Pointer1,Category,Distance>& x,
const iterator_adaptor<Iterator2,Policies,Value2,Reference2,Pointer2,Category,Distance>& y)
{
return !x.policies().equal(x, y);
}
#endif
} // namespace multi_array
} // namespace detail
} // namespace boost
# undef BOOST_ARG_DEPENDENT_TYPENAME
#endif

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_MULTI_ARRAY_REF_RG071801_HPP
#define BOOST_MULTI_ARRAY_REF_RG071801_HPP
@@ -25,12 +25,12 @@
#include "boost/multi_array/subarray.hpp"
#include "boost/multi_array/view.hpp"
#include "boost/multi_array/algorithm.hpp"
#include "boost/type_traits/is_integral.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>
@@ -48,13 +48,14 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
typedef typename super_type::difference_type difference_type;
typedef typename super_type::index index;
typedef typename super_type::extent_range extent_range;
typedef general_storage_order<NumDims> storage_order_type;
// template typedefs
template <std::size_t NDims>
@@ -73,10 +74,9 @@ public:
friend class const_multi_array_ref;
#endif
// This ensures that const_multi_array_ref types with different TPtr
// types can convert to each other
template <typename OPtr>
const_multi_array_ref(const const_multi_array_ref<T,NumDims,OPtr>& other)
const_multi_array_ref(const const_multi_array_ref<T,NumDims,
OPtr>& other)
: base_(other.base_), storage_(other.storage_),
extent_list_(other.extent_list_),
stride_list_(other.stride_list_),
@@ -137,17 +137,10 @@ public:
}
template <class BaseList>
#ifdef BOOST_NO_SFINAE
void
#else
typename
disable_if<typename boost::is_integral<BaseList>::type,void >::type
#endif // BOOST_NO_SFINAE
reindex(const BaseList& values) {
void reindex(const BaseList& values) {
boost::function_requires<
detail::multi_array::CollectionConcept<BaseList> >();
boost::detail::multi_array::
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
origin_offset_ =
this->calculate_origin_offset(stride_list_,extent_list_,
storage_,index_base_list_);
@@ -164,9 +157,9 @@ public:
void reshape(const SizeList& extents) {
boost::function_requires<
detail::multi_array::CollectionConcept<SizeList> >();
BOOST_ASSERT(num_elements_ ==
std::accumulate(extents.begin(),extents.end(),
size_type(1),std::multiplies<size_type>()));
assert(num_elements_ ==
std::accumulate(extents.begin(),extents.end(),
size_type(1),std::multiplies<size_type>()));
std::copy(extents.begin(),extents.end(),extent_list_.begin());
this->compute_strides(stride_list_,extent_list_,storage_);
@@ -202,18 +195,13 @@ public:
return index_base_list_.data();
}
const storage_order_type& storage_order() const {
return storage_;
}
template <typename IndexList>
const element& operator()(IndexList indices) const {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<const element&>(),
indices,origin(),
shape(),strides(),index_bases());
origin(),
indices,strides());
}
// Only allow const element access
@@ -244,13 +232,13 @@ public:
}
const_iterator begin() const {
return const_iterator(*index_bases(),origin(),
shape(),strides(),index_bases());
return const_iterator(const_iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
}
const_iterator end() const {
return const_iterator(*index_bases()+(index)*shape(),origin(),
shape(),strides(),index_bases());
return const_iterator(const_iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
}
const_reverse_iterator rbegin() const {
@@ -308,49 +296,35 @@ public:
return !(*this < rhs);
}
// This ensures that const_multi_array_ref types with different TPtr
// types can convert to each other
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
protected:
#else
public:
#endif
// This is used by multi_array, which is a subclass of this
void set_base_ptr(TPtr new_base) { base_ = new_base; }
template <typename OPtr>
const_multi_array_ref(const detail::multi_array::
const_sub_array<T,NumDims,OPtr>& rhs)
: base_(rhs.origin()),
storage_(c_storage_order()),
origin_offset_(0), directional_offset_(0),
num_elements_(rhs.num_elements())
{
using boost::copy_n;
copy_n(rhs.shape(),rhs.num_dimensions(),extent_list_.begin());
copy_n(rhs.strides(),rhs.num_dimensions(),stride_list_.begin());
copy_n(rhs.index_bases(),rhs.num_dimensions(),index_base_list_.begin());
}
typedef boost::array<size_type,NumDims> size_list;
typedef boost::array<index,NumDims> index_list;
// This is used by multi_array, which is a subclass of this
void set_base_ptr(TPtr new_base) { base_ = new_base; }
// This constructor supports multi_array's default constructor
// and constructors from multi_array_ref, subarray, and array_view
explicit
const_multi_array_ref(TPtr base,
const storage_order_type& so,
const index * index_bases,
const size_type* extents) :
base_(base), storage_(so), origin_offset_(0), directional_offset_(0)
{
// If index_bases or extents is null, then initialize the corresponding
// private data to zeroed lists.
if(index_bases) {
boost::detail::multi_array::
copy_n(index_bases,NumDims,index_base_list_.begin());
} else {
std::fill_n(index_base_list_.begin(),NumDims,0);
}
if(extents) {
init_multi_array_ref(extents);
} else {
boost::array<index,NumDims> extent_list;
extent_list.assign(0);
init_multi_array_ref(extent_list.begin());
}
}
TPtr base_;
storage_order_type storage_;
general_storage_order<NumDims> storage_;
size_list extent_list_;
index_list stride_list_;
index_list index_base_list_;
@@ -383,22 +357,16 @@ private:
}
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
protected:
#else
public:
#endif
// RG - move me!
template <class InputIterator>
void init_multi_array_ref(InputIterator extents_iter) {
boost::function_requires<InputIteratorConcept<InputIterator> >();
boost::detail::multi_array::
copy_n(extents_iter,num_dimensions(),extent_list_.begin());
boost::copy_n(extents_iter,num_dimensions(),extent_list_.begin());
// Calculate the array size
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
size_type(1),std::multiplies<size_type>());
1,std::multiplies<index>());
assert(num_elements_ != 0);
this->compute_strides(stride_list_,extent_list_,storage_);
@@ -411,6 +379,7 @@ public:
}
};
template <typename T, std::size_t NumDims>
class multi_array_ref :
public const_multi_array_ref<T,NumDims,T*>
@@ -420,9 +389,11 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::iterator iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -430,9 +401,7 @@ public:
typedef typename super_type::index index;
typedef typename super_type::extent_range extent_range;
typedef typename super_type::storage_order_type storage_order_type;
typedef typename super_type::index_list index_list;
typedef typename super_type::size_list size_list;
template <std::size_t NDims>
struct const_array_view {
@@ -473,6 +442,10 @@ public:
const general_storage_order<NumDims>& so) :
super_type(base,ranges,so) { }
template <typename OPtr>
multi_array_ref(const detail::multi_array::
const_sub_array<T,NumDims,OPtr>& rhs)
: super_type(rhs) {}
// Assignment from other ConstMultiArray types.
template <typename ConstMultiArray>
@@ -482,9 +455,9 @@ public:
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
// make sure the dimensions agree
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),this->begin());
return *this;
@@ -494,10 +467,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());
}
@@ -510,12 +482,11 @@ public:
template <class IndexList>
element& operator()(const IndexList& indices) {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
indices,origin(),
this->shape(),this->strides(),
this->index_bases());
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
origin(),
indices,this->strides());
}
@@ -548,17 +519,17 @@ public:
iterator begin() {
return iterator(*this->index_bases(),origin(),this->shape(),
this->strides(),this->index_bases());
return iterator(iter_base(*this->index_bases(),origin(),this->shape(),
this->strides(),this->index_bases()));
}
iterator end() {
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases());
return iterator(iter_base(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases()));
}
// rbegin() and rend() written naively to thwart MSVC ICE.
// RG - rbegin() and rend() written naively to thwart MSVC ICE.
reverse_iterator rbegin() {
reverse_iterator ri(end());
return ri;
@@ -617,15 +588,6 @@ public:
const_reverse_iterator rend() const {
return super_type::rend();
}
protected:
// This is only supplied to support multi_array's default constructor
explicit multi_array_ref(T* base,
const storage_order_type& so,
const index* index_bases,
const size_type* extents) :
super_type(base,so,index_bases,extents) { }
};
} // namespace boost

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef RANGE_LIST_RG072501_HPP
#define RANGE_LIST_RG072501_HPP

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_STORAGE_ORDER_RG071801_HPP
#define BOOST_STORAGE_ORDER_RG071801_HPP
@@ -36,8 +36,8 @@ namespace boost {
template <typename OrderingIter, typename AscendingIter>
general_storage_order(OrderingIter ordering,
AscendingIter ascending) {
boost::detail::multi_array::copy_n(ordering,NumDims,ordering_.begin());
boost::detail::multi_array::copy_n(ascending,NumDims,ascending_.begin());
boost::copy_n(ordering,NumDims,ordering_.begin());
boost::copy_n(ascending,NumDims,ascending_.begin());
}
// RG - ideally these would not be necessary, but some compilers

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef SUBARRAY_RG071801_HPP
#define SUBARRAY_RG071801_HPP
@@ -44,6 +44,7 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -79,11 +80,9 @@ public:
template <typename IndexList>
const element& operator()(const IndexList& indices) const {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<const element&>(),
indices,origin(),
shape(),strides(),index_bases());
origin(),
indices,strides());
}
// see generate_array_view in base.hpp
@@ -139,13 +138,13 @@ public:
}
const_iterator begin() const {
return const_iterator(*index_bases(),origin(),
shape(),strides(),index_bases());
return const_iterator(const_iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
}
const_iterator end() const {
return const_iterator(*index_bases()+(index)*shape(),origin(),
shape(),strides(),index_bases());
return const_iterator(const_iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
}
const_reverse_iterator rbegin() const {
@@ -196,7 +195,6 @@ private:
const_sub_array& operator=(const const_sub_array&);
};
//
// sub_array
// multi_array's proxy class to allow multiple overloads of
@@ -213,9 +211,11 @@ public:
typedef typename super_type::size_type size_type;
typedef typename super_type::iterator iterator;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::const_iter_base const_iter_base;
// template typedefs
template <std::size_t NDims>
@@ -235,9 +235,9 @@ public:
ConstMultiArray, NumDims> >();
// make sure the dimensions agree
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
return *this;
@@ -247,10 +247,9 @@ public:
sub_array& operator=(const sub_array& other) {
if (&other != this) {
// make sure the dimensions agree
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
BOOST_ASSERT(std::equal(other.shape(),
other.shape()+this->num_dimensions(),
this->shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
}
@@ -287,22 +286,19 @@ public:
template <class IndexList>
element& operator()(const IndexList& indices) {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
indices,origin(),
this->shape(),this->strides(),
this->index_bases());
origin(),
indices,this->strides());
}
iterator begin() {
return iterator(*this->index_bases(),origin(),
this->shape(),this->strides(),this->index_bases());
return iterator(iter_base(*this->index_bases(),origin(),
this->shape(),this->strides(),this->index_bases()));
}
iterator end() {
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
this->shape(),this->strides(),this->index_bases());
return iterator(iter_base(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),this->index_bases()));
}
// RG - rbegin() and rend() written naively to thwart MSVC ICE.
@@ -322,8 +318,6 @@ public:
template <class IndexList>
const element& operator()(const IndexList& indices) const {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::operator()(indices);
}

View File

@@ -1,15 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
#define BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
@@ -26,7 +25,7 @@ namespace multi_array{
// needed typedefs
typedef std::size_t size_type;
typedef std::ptrdiff_t index;
typedef int index;
} // namespace multi_array
} // namespace detail

View File

@@ -1,14 +1,14 @@
// 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.
// Copyright (C) 2002 Ronald Garcia
//
// Permission to copy, use, sell and distribute this software is granted
// provided this copyright notice appears in all copies.
// Permission to modify the code and to distribute modified code is granted
// provided this copyright notice appears in all copies, and a notice
// that the code was modified is included with the copyright notice.
//
// This software is provided "as is" without express or implied warranty,
// and with no claim as to its suitability for any purpose.
//
#ifndef BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
#define BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
@@ -23,7 +23,6 @@
#include "boost/multi_array/storage_order.hpp"
#include "boost/multi_array/subarray.hpp"
#include "boost/multi_array/algorithm.hpp"
#include "boost/type_traits/is_integral.hpp"
#include "boost/array.hpp"
#include "boost/limits.hpp"
#include <algorithm>
@@ -45,6 +44,7 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -73,17 +73,8 @@ public:
template <class BaseList>
#ifdef BOOST_NO_SFINAE
void
#else
typename
disable_if<typename boost::is_integral<BaseList>::type,void >::type
#endif
reindex(const BaseList& values) {
boost::function_requires<
detail::multi_array::CollectionConcept<BaseList> >();
boost::detail::multi_array::
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
void reindex(const BaseList& values) {
boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
origin_offset_ =
this->calculate_indexing_offset(stride_list_,index_base_list_);
}
@@ -118,11 +109,9 @@ public:
template <typename IndexList>
const element& operator()(IndexList indices) const {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<const element&>(),
indices,origin(),
shape(),strides(),index_bases());
origin(),
indices,strides());
}
// Only allow const element access
@@ -153,13 +142,13 @@ public:
origin());
}
const_iterator begin() const {
return const_iterator(*index_bases(),origin(),
shape(),strides(),index_bases());
return const_iterator(const_iter_base(*index_bases(),origin(),
shape(),strides(),index_bases()));
}
const_iterator end() const {
return const_iterator(*index_bases()+(index)*shape(),origin(),
shape(),strides(),index_bases());
return const_iterator(const_iter_base(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases()));
}
const_reverse_iterator rbegin() const {
@@ -237,14 +226,13 @@ public: // should be protected
index_base_list_.assign(0);
// Get the extents and strides
boost::detail::multi_array::
copy_n(extents.begin(),NumDims,extent_list_.begin());
boost::detail::multi_array::
copy_n(strides.begin(),NumDims,stride_list_.begin());
boost::copy_n(extents.begin(),NumDims,extent_list_.begin());
boost::copy_n(strides.begin(),NumDims,stride_list_.begin());
// 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>());
assert(num_elements_ != 0);
}
typedef boost::array<size_type,NumDims> size_list;
@@ -272,9 +260,11 @@ public:
typedef typename super_type::value_type value_type;
typedef typename super_type::reference reference;
typedef typename super_type::iterator iterator;
typedef typename super_type::iter_base iter_base;
typedef typename super_type::reverse_iterator reverse_iterator;
typedef typename super_type::const_reference const_reference;
typedef typename super_type::const_iterator const_iterator;
typedef typename super_type::const_iter_base const_iter_base;
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
typedef typename super_type::element element;
typedef typename super_type::size_type size_type;
@@ -301,9 +291,9 @@ public:
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
// make sure the dimensions agree
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
assert(other.num_dimensions() == this->num_dimensions());
assert(std::equal(other.shape(),other.shape()+this->num_dimensions(),
this->shape()));
// iterator-based copy
std::copy(other.begin(),other.end(),begin());
return *this;
@@ -313,10 +303,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());
}
@@ -327,12 +316,9 @@ public:
template <class IndexList>
element& operator()(const IndexList& indices) {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::access_element(boost::type<element&>(),
indices,origin(),
this->shape(),this->strides(),
this->index_bases());
origin(),
indices,this->strides());
}
@@ -365,15 +351,15 @@ public:
iterator begin() {
return iterator(*this->index_bases(),origin(),
this->shape(),this->strides(),
this->index_bases());
return iterator(iter_base(*this->index_bases(),origin(),
this->shape(),this->strides(),
this->index_bases()));
}
iterator end() {
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases());
return iterator(iter_base(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases()));
}
reverse_iterator rbegin() {
@@ -391,8 +377,6 @@ public:
template <class IndexList>
const element& operator()(const IndexList& indices) const {
boost::function_requires<
detail::multi_array::CollectionConcept<IndexList> >();
return super_type::operator()(indices);
}

View File

@@ -4,10 +4,6 @@
</head>
<body>
Automatic redirection failed, please go to
<a href="doc/index.html">doc/index.html</a>.&nbsp;<hr>
<p>© Copyright Beman Dawes, 2001</p>
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
<a href="doc/index.html">doc/index.html</a>.
</body>
</html>

View File

@@ -1,2 +0,0 @@
boost_module(multi_array DEPENDS array iterator detail concept_check mpl static_assert functional)

View File

@@ -1,41 +0,0 @@
boost_additional_test_dependencies(multi_array BOOST_DEPENDS test)
boost_test_compile_fail(fail_cbracket)
boost_test_compile_fail(fail_cdata)
boost_test_compile_fail(fail_citerator)
boost_test_compile_fail(fail_cparen)
boost_test_compile_fail(fail_criterator)
boost_test_compile_fail(fail_csubarray)
boost_test_compile_fail(fail_csubarray2)
boost_test_compile_fail(fail_csubarray3)
boost_test_compile_fail(fail_cview)
boost_test_compile_fail(fail_cview2)
boost_test_compile_fail(fail_cview3)
boost_test_compile_fail(fail_ref_cbracket)
boost_test_compile_fail(fail_ref_cdata)
boost_test_compile_fail(fail_ref_citerator)
boost_test_compile_fail(fail_ref_cparen)
boost_test_compile_fail(fail_ref_criterator)
boost_test_compile_fail(fail_ref_csubarray)
boost_test_compile_fail(fail_ref_csubarray2)
boost_test_compile_fail(fail_ref_csubarray3)
boost_test_compile_fail(fail_ref_cview)
boost_test_compile_fail(fail_ref_cview2)
boost_test_compile_fail(fail_ref_cview3)
boost_test_run(constructors DEPENDS boost_test_exec_monitor)
boost_test_run(access DEPENDS boost_test_exec_monitor)
boost_test_run(compare DEPENDS boost_test_exec_monitor)
boost_test_run(iterators DEPENDS boost_test_exec_monitor)
boost_test_run(slice DEPENDS boost_test_exec_monitor)
boost_test_run(assign DEPENDS boost_test_exec_monitor)
boost_test_run(assign_to_array DEPENDS boost_test_exec_monitor)
boost_test_run(index_bases DEPENDS boost_test_exec_monitor)
boost_test_run(storage_order DEPENDS boost_test_exec_monitor)
boost_test_run(reshape DEPENDS boost_test_exec_monitor)
boost_test_run(range1 DEPENDS boost_test_exec_monitor)
boost_test_run(idxgen1 DEPENDS boost_test_exec_monitor)
boost_test_run(stl_interaction DEPENDS boost_test_exec_monitor)
boost_test_run(resize DEPENDS boost_test_exec_monitor)
boost_test_compile(concept_checks)

View File

@@ -1,49 +0,0 @@
# Copyright David Abrahams 2003. Permission to copy, use,
# modify, sell and distribute this software is granted provided this
# copyright notice appears in all copies. This software is provided
# "as is" without express or implied warranty, and with no claim as
# to its suitability for any purpose.
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 ../../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_convert.cpp ../../test/build//boost_test_exec_monitor ]
[ run storage_order.cpp ../../test/build//boost_test_exec_monitor ]
[ run reshape.cpp ../../test/build//boost_test_exec_monitor ]
[ run range1.cpp ../../test/build//boost_test_exec_monitor ]
[ run idxgen1.cpp ../../test/build//boost_test_exec_monitor ]
[ run stl_interaction.cpp ../../test/build//boost_test_exec_monitor ]
[ run resize.cpp ../../test/build//boost_test_exec_monitor ]
[ run assert.cpp ../../test/build//boost_test_exec_monitor ]
[ compile concept_checks.cpp ]
;

View File

@@ -1,22 +1,9 @@
// 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.
//
// access.cpp - operator[] and operator() tests with various arrays
// The tests assume that they are working on an Array of shape 2x3x4
//
#include "generative_tests.hpp"
#include "boost/static_assert.hpp"
template <typename Array>
void access(Array& A, const mutable_array_tag&) {
@@ -29,8 +16,8 @@ void access(Array& A, const mutable_array_tag&) {
template <typename Array>
void access(Array& A, const const_array_tag&) {
const unsigned int ndims = 3;
BOOST_STATIC_ASSERT((Array::dimensionality == ndims));
const int ndims = 3;
typedef typename Array::index index;
const index idx0 = A.index_bases()[0];
const index idx1 = A.index_bases()[1];
@@ -42,18 +29,18 @@ 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_CHECK(A[i][j][k] == cnum++);
BOOST_CHECK(CA[i][j][k] == A[i][j][k]);
BOOST_TEST(A[i][j][k] == cnum++);
BOOST_TEST(CA[i][j][k] == A[i][j][k]);
}
// operator()
for (index i2 = idx0; i2 != idx0+2; ++i2)
for (index j2 = idx1; j2 != idx1+3; ++j2)
for (index k2 = idx2; k2 != idx2+4; ++k2) {
for (index i2 = 0; i2 != 2; ++i2)
for (index j2 = 0; j2 != 3; ++j2)
for (index k2 = 0; k2 != 4; ++k2) {
boost::array<index,ndims> indices;
indices[0] = i2; indices[1] = j2; indices[2] = k2;
BOOST_CHECK(A(indices) == A[i2][j2][k2]);
BOOST_CHECK(CA(indices) == A(indices));
BOOST_TEST(A(indices) == A[i2][j2][k2]);
BOOST_TEST(CA(indices) == A(indices));
}
++tests_run;
}

View File

@@ -1,51 +0,0 @@
// Copyright 2007 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Boost.MultiArray Library
// Authors: Ronald Garcia
// Jeremy Siek
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
// Using the BOOST.ASSERT mechanism to replace library assertions
// with exceptions
//
#include "boost/test/minimal.hpp"
#define BOOST_ENABLE_ASSERT_HANDLER
#include "boost/multi_array.hpp" // includes assert.hpp
#include <stdexcept>
namespace boost {
void assertion_failed(char const* expr, char const* function,
char const* file, long line) {
throw std::runtime_error(expr);
}
} // namespace boost
using namespace boost;
int
test_main(int,char*[]) {
typedef multi_array<int,2> array_t;
array_t A(extents[2][2]);
array_t B(extents[3][3]);
try {
A = B;
BOOST_ERROR("did not throw an exception");
} catch (std::runtime_error&) {
//...all good
}
return boost::exit_success;
}

View File

@@ -1,15 +1,3 @@
// 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.
//
// assign.cpp - Test out operator=() on the different types
//
@@ -59,7 +47,7 @@ void access(Array& A, const mutable_array_tag&) {
A = filler;
BOOST_CHECK(equal(A,filler));
BOOST_TEST(equal(A,filler));
++tests_run;
}

View File

@@ -1,60 +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.
//
// 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 <algorithm>
#include <iostream>
bool equal(const int& a, const int& b)
{
return a == b;
}
template <typename ArrayA, typename ArrayB>
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))
return false;
return true;
}
template <typename Array>
void access(Array& A, const mutable_array_tag&) {
assign(A);
access(A,const_array_tag());
}
template <typename Array>
void access(Array& A, const const_array_tag&) {
typedef boost::multi_array<int,3> array3;
array3 acopy(A);
BOOST_CHECK(equal(acopy,A));
++tests_run;
}
int test_main(int,char*[]) {
return run_generative_tests();
}

View File

@@ -1,20 +1,9 @@
// 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.
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include <algorithm>
#include <list>
@@ -34,9 +23,9 @@ test_main(int, char*[])
std::vector<double> vals(num_elements, 4.5);
A.assign(vals.begin(),vals.end());
array B(A);
BOOST_CHECK(A == B);
BOOST_CHECK(B == A);
BOOST_CHECK(A[0] == B[0]);
BOOST_TEST(A == B);
BOOST_TEST(B == A);
BOOST_TEST(A[0] == B[0]);
}
// Assignment Operator
{
@@ -44,15 +33,15 @@ test_main(int, char*[])
std::vector<double> vals(num_elements, 4.5);
A.assign(vals.begin(),vals.end());
B = A;
BOOST_CHECK(A == B);
BOOST_CHECK(B == A);
BOOST_CHECK(B[0] == A[0]);
BOOST_TEST(A == B);
BOOST_TEST(B == A);
BOOST_TEST(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_CHECK(C == D);
BOOST_TEST(C == D);
}
// Different Arrays
{
@@ -62,15 +51,15 @@ test_main(int, char*[])
A.assign(valsA.begin(),valsA.end());
B.assign(valsB.begin(),valsB.end());
BOOST_CHECK(A != B);
BOOST_CHECK(B != A);
BOOST_CHECK(A[0] != B[0]);
BOOST_TEST(A != B);
BOOST_TEST(B != A);
BOOST_TEST(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_CHECK(C != D);
BOOST_TEST(C != D);
}
// Comparisons galore!
@@ -108,30 +97,30 @@ test_main(int, char*[])
A.assign(valsA,valsA+num_elements);
B.assign(valsB,valsB+num_elements);
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 <= A);
BOOST_TEST(A >= B);
BOOST_CHECK(B[0] == A[0]);
BOOST_CHECK(B[2] < A[2]);
BOOST_TEST(B[0] == A[0]);
BOOST_TEST(B[2] < A[2]);
array 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));
BOOST_TEST(!(C < A));
BOOST_TEST(!(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_CHECK(E < D);
BOOST_CHECK(E <= D);
BOOST_TEST(E < D);
BOOST_TEST(E <= D);
}

View File

@@ -1,16 +1,4 @@
// 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.
//
//
// concept_checks.cpp -
// make sure the types meet concept requirements
//
@@ -19,9 +7,8 @@
#include "boost/multi_array/concept_checks.hpp"
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
@@ -60,6 +47,6 @@ boost::function_requires<
boost::detail::multi_array::MutableMultiArrayConcept<array_view,ndims> >();
boost::function_requires<
boost::detail::multi_array::MutableMultiArrayConcept<subarray,ndims> >();
return 0;
return boost::exit_success;
}

View File

@@ -1,21 +1,10 @@
// 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.
//
// constructors.cpp - Testing out the various constructor options
//
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/multi_array.hpp"
#include <algorithm>
@@ -30,10 +19,10 @@ void check_shape(const Array& A,
int* strides,
unsigned int num_elements)
{
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()));
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()));
check_shape(A[0], ++sizes, ++strides, num_elements / A.size());
}
@@ -63,11 +52,6 @@ test_main(int, char*[])
int strides[] = { 9, 3, 1 };
size_type num_elements = 27;
// Default multi_array constructor
{
boost::multi_array<double, 3> A;
}
// Constructor 1, default storage order and allocator
{
boost::multi_array<double, 3> A(sizes);
@@ -132,20 +116,20 @@ test_main(int, char*[])
A.assign(vals.begin(),vals.end());
boost::multi_array<double, 3> B(A);
check_shape(B, &sizes[0], strides, num_elements);
BOOST_CHECK(equal(A, B));
BOOST_TEST(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_CHECK(C.data() == D.data());
BOOST_TEST(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_CHECK(E.data() == F.data());
BOOST_TEST(E.data() == F.data());
}
@@ -161,15 +145,15 @@ test_main(int, char*[])
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_CHECK(B.data() == A.data());
BOOST_CHECK(C.data() == A.data());
BOOST_TEST(B.data() == A.data());
BOOST_TEST(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_CHECK(E.data() == D.data());
BOOST_TEST(E.data() == D.data());
}
// Assignment Operator
@@ -182,7 +166,7 @@ test_main(int, char*[])
A.assign(vals.begin(),vals.end());
B = A;
check_shape(B, &sizes[0], strides, num_elements);
BOOST_CHECK(equal(A, B));
BOOST_TEST(equal(A, B));
double ptr1[27];
double ptr2[27];
@@ -190,7 +174,7 @@ test_main(int, char*[])
C.assign(vals.begin(),vals.end());
D = C;
check_shape(D, &sizes[0], strides, num_elements);
BOOST_CHECK(equal(C,D));
BOOST_TEST(equal(C,D));
}
@@ -209,8 +193,8 @@ test_main(int, char*[])
subarray::value_type C = B[0];
// should comparisons between the types work?
BOOST_CHECK(equal(A[1][0],C));
BOOST_CHECK(equal(B[0],C));
BOOST_TEST(equal(A[1][0],C));
BOOST_TEST(equal(B[0],C));
}
return boost::exit_success;
}

View File

@@ -1,15 +1,3 @@
// 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.
//
// Trying to diagnose problems under visual
@@ -141,10 +129,10 @@ typedef std::size_t size_type;
private:
static Index from_start()
{ return (std::numeric_limits<Index>::min)(); }
{ return std::numeric_limits<Index>::min(); }
static Index to_end()
{ return (std::numeric_limits<Index>::max)(); }
{ return std::numeric_limits<Index>::max(); }
public:
Index start_, finish_, stride_;
bool degenerate_;

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_cbracket.cpp -
// checking constness of const operator[].
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_cdata.cpp
// Testing data() member function constness.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
@@ -36,6 +25,7 @@ test_main(int,char*[])
const array& csma = sma;
// FAIL! data() returns a const int*
*csma.data() = 0;
int* cdptr = csma.data();
(void)cdptr; // suppress compiler warnings;
return boost::exit_success;
}

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_citerator.cpp -
// const_iterator/iterator conversion test
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
int test_main(int,char*[]) {

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_cparen.cpp -
// Testing const operator() constness.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_criterator.cpp
// const_reverse_iterator/reverse_iterator conversion test
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
int test_main(int,char*[]) {

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_csubarray.cpp -
// Testing subarray and const_subarray assignment
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_csubarray2.cpp
// Testing constness of subarray operations.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_csubarray3.cpp
// Testing constness of subarray operations.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_cview.cpp -
// ensure const_array_view doesn't allow element assignment.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include "boost/type.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_cview2.cpp
// ensure const_array_view cannot be converted to array_view

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_cview3.cpp
// ensure const_array_ref doesn't allow assignment.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include "boost/type.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_cbracket.cpp
// checking constness of const operator[].
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_cdata.cpp -
// Testing data() member function constness.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
@@ -35,6 +24,7 @@ test_main(int,char*[])
const array_ref& csma = sma;
// FAIL! data() returns const int*.
*csma.data() = 0;
int* cdptr = csma.data();
(void)cdptr; // suppress compiler warnings
return boost::exit_success;
}

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_citerator.cpp
// const_iterator/iterator conversion test
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
int test_main(int,char*[]) {

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_cparen.cpp
// Testing const operator() constness.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_criterator.cpp
// const_reverse_iterator/reverse_iterator conversion test
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
int test_main(int,char*[]) {

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_csubarray.cpp -
// Testing subarray and const_subarray assignment
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_csubarray2.cpp -
// Testing constness of subarray operations.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_csubarray3.cpp -
// Testing constness of subarray operations.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_cview.cpp
// ensure const_array_view doesn't allow element assignment.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include "boost/type.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_cview2.cpp
// ensure const_array_view cannot be converted to array_view
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include "boost/type.hpp"

View File

@@ -1,15 +1,3 @@
// 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.
//
// fail_ref_cview3.cpp -
// ensure const_array_view doesn't allow assignment.
@@ -17,7 +5,8 @@
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include "boost/type.hpp"

View File

@@ -1,18 +1,6 @@
#ifndef GENERATIVE_TESTS_RG072001_HPP
#define GENERATIVE_TESTS_RG072001_HPP
// 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.
//
// generative-tests.hpp - Framework for running tests on all the types
// of multi_array
@@ -47,9 +35,9 @@
//
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include <boost/config.hpp> /* BOOST_NO_SFINAE */
#include <algorithm>
#include <iostream>
#include <vector>
@@ -239,14 +227,7 @@ struct null_modifier {
struct set_index_base_modifier {
template <typename Array>
void modify(Array& A) const {
#ifdef BOOST_NO_SFINAE
typedef boost::multi_array_types::index index;
A.reindex(index(1));
#else
A.reindex(1);
#endif
}
void modify(Array& A) const { A.reindex(1); }
};
struct reindex_modifier {

View File

@@ -1,35 +1,25 @@
// 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.
//
// 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/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include <cstddef>
typedef boost::detail::multi_array::index index_type;
typedef boost::detail::multi_array::size_type size_type;
typedef boost::detail::multi_array::index_range<index_type,size_type> range;
template <int NumRanges, int NumDims>
void check(const boost::detail::multi_array::
index_gen<NumRanges,NumDims>&) { }
bool operator==(const range& lhs,const range& rhs) {
bool operator==(const boost::detail::multi_array::
index_range<int,std::size_t>& lhs,
const boost::detail::multi_array::
index_range<int,std::size_t>& rhs) {
return lhs.start_ == rhs.start_ &&
lhs.finish_ == rhs.finish_ &&
lhs.stride_ == rhs.stride_ &&
@@ -39,6 +29,7 @@ bool operator==(const range& lhs,const range& rhs) {
int
test_main(int,char*[])
{
typedef boost::detail::multi_array::index_range<int,std::size_t> range;
boost::detail::multi_array::index_gen<0,0> indices;
@@ -62,18 +53,18 @@ test_main(int,char*[])
{
boost::detail::multi_array::index_gen<3,3> is1 =
indices[range(0,1,2)][range(1,2,3)][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_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::detail::multi_array::index_gen<3,2> is2 =
indices[range(0,1,2)][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));
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));
}
return boost::exit_success;

View File

@@ -1,22 +1,11 @@
// 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.
//
// index_bases - test of the index_base modifying facilities.
//
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include <vector>
@@ -62,12 +51,12 @@ test_main(int,char*[])
boost::array<int,3> bases = { { 1, 2, 3 } };
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_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]);
for (size_type c = 0; c < A[b].size(); ++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]);
// Test that E does not inherit A's index_base
BOOST_CHECK(E[a][b][c] == B[a][b][c]);
BOOST_TEST(E[a][b][c] == B[a][b][c]);
}
}
@@ -100,10 +89,10 @@ test_main(int,char*[])
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_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]);
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]);
}
}
@@ -126,26 +115,18 @@ test_main(int,char*[])
B.assign(vals.begin(),vals.end());
C.assign(vals.begin(),vals.end());
#ifdef BOOST_NO_SFINAE
typedef boost::multi_array_types::index index;
A.reindex(index(1));
C.reindex(index(1));
D.reindex(index(1));
E.reindex(index(1));
#else
A.reindex(1);
C.reindex(1);
D.reindex(1);
E.reindex(1);
#endif
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_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]);
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]);
}
}

View File

@@ -1,15 +1,3 @@
// 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.
//
// iterators.cpp - checking out iterator stuffs.
// The tests assume that the array has shape 2x3x4
@@ -18,8 +6,6 @@
#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"
// iterator-test-specific code
@@ -66,14 +52,46 @@ struct ittraits_mutable {
riterator1;
};
/////////////////////////////////////////////////////////////////////////
// choose ittraits begins
//
struct choose_ittraits_const {
template <typename Array>
struct bind {
typedef ittraits_const<Array> type;
};
};
struct choose_ittraits_mutable {
template <typename Array>
struct bind {
typedef ittraits_mutable<Array> type;
};
};
template <typename ConstnessTag>
struct ittraits_gen_helper {
typedef choose_ittraits_mutable choice;
};
template <>
struct ittraits_gen_helper<const_array_tag> {
typedef choose_ittraits_const choice;
};
// Meta-program chooses ittraits implementation.
template <typename Array, typename ConstTag>
struct ittraits_generator :
boost::mpl::if_< boost::is_same<ConstTag,const_array_tag>,
ittraits_const<Array>,
ittraits_mutable<Array> >
{};
struct ittraits_generator {
private:
typedef typename ittraits_gen_helper<ConstTag>::choice Choice;
public:
typedef typename Choice::template bind<Array>::type type;
};
//
// choose ittraits ends
/////////////////////////////////////////////////////////////////////////
template <typename Array>
@@ -107,8 +125,8 @@ void test_iterators(Array& A, const IterTraits&) {
typedef typename IterTraits::iterator3 iterator;
iterator i1 = A.begin();
iterator i2 = A.end();
BOOST_CHECK(i1 < i2);
BOOST_CHECK((i2 - i1) == typename iterator::difference_type(2));
BOOST_TEST(i1 < i2);
BOOST_TEST((i2 - i1) == typename iterator::difference_type(2));
}
// Standard Array Iteration
@@ -121,7 +139,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_CHECK(*iii == vals++);
BOOST_TEST(*iii == vals++);
}
// Using operator->() on iterators
@@ -134,7 +152,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_CHECK(*iii == vals++);
BOOST_TEST(*iii == vals++);
}
// Reverse Iterator Hierarchy Test
@@ -148,7 +166,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_CHECK(*iii == check_iter_val--);
BOOST_TEST(*iii == check_iter_val--);
}
++tests_run;
}

View File

@@ -1,15 +1,3 @@
// 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.
//
// range1.cpp - test of index_range
//
@@ -17,7 +5,8 @@
#include "boost/multi_array/index_range.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include <cstddef>
@@ -30,75 +19,75 @@ test_main(int,char*[])
{
// typical range creation and extraction
range r1(-3,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);
BOOST_TEST(r1.start() == -3);
BOOST_TEST(r1.finish() == 5);
BOOST_TEST(r1.stride() == 1);
BOOST_TEST(!r1.is_degenerate());
BOOST_TEST(r1.get_start(0) == -3);
BOOST_TEST(r1.get_finish(100) == 5);
}
{
range r2(-3,5,2);
BOOST_CHECK(r2.start() == -3);
BOOST_CHECK(r2.finish() == 5);
BOOST_CHECK(r2.stride() == 2);
BOOST_CHECK(!r2.is_degenerate());
BOOST_TEST(r2.start() == -3);
BOOST_TEST(r2.finish() == 5);
BOOST_TEST(r2.stride() == 2);
BOOST_TEST(!r2.is_degenerate());
}
{
// degenerate creation
range r3(5);
BOOST_CHECK(r3.start() == 5);
BOOST_CHECK(r3.finish() == 6);
BOOST_CHECK(r3.stride() == 1);
BOOST_CHECK(r3.is_degenerate());
BOOST_TEST(r3.start() == 5);
BOOST_TEST(r3.finish() == 5);
BOOST_TEST(r3.stride() == 1);
BOOST_TEST(r3.is_degenerate());
}
{
// default range creation
range r4;
BOOST_CHECK(r4.get_start(0) == 0);
BOOST_CHECK(r4.get_finish(100) == 100);
BOOST_CHECK(r4.stride() == 1);
BOOST_TEST(r4.get_start(0) == 0);
BOOST_TEST(r4.get_finish(100) == 100);
BOOST_TEST(r4.stride() == 1);
}
{
// create a range using the setter methods
range r5 = range().stride(2).start(-3).finish(7);
BOOST_CHECK(r5.start() == -3);
BOOST_CHECK(r5.stride() == 2);
BOOST_CHECK(r5.finish() == 7);
BOOST_TEST(r5.start() == -3);
BOOST_TEST(r5.stride() == 2);
BOOST_TEST(r5.finish() == 7);
}
// try out all the comparison operators
{
range r6 = -3 <= range().stride(2) < 7;
BOOST_CHECK(r6.start() == -3);
BOOST_CHECK(r6.stride() == 2);
BOOST_CHECK(r6.finish() == 7);
BOOST_TEST(r6.start() == -3);
BOOST_TEST(r6.stride() == 2);
BOOST_TEST(r6.finish() == 7);
}
{
range r7 = -3 < range() <= 7;
BOOST_CHECK(r7.start() == -2);
BOOST_CHECK(r7.stride() == 1);
BOOST_CHECK(r7.finish() == 8);
BOOST_TEST(r7.start() == -2);
BOOST_TEST(r7.stride() == 1);
BOOST_TEST(r7.finish() == 8);
}
// arithmetic operators
{
range r8 = range(0,5) + 2;
BOOST_CHECK(r8.start() == 2);
BOOST_CHECK(r8.stride() == 1);
BOOST_CHECK(r8.finish() == 7);
BOOST_TEST(r8.start() == 2);
BOOST_TEST(r8.stride() == 1);
BOOST_TEST(r8.finish() == 7);
}
{
range r9 = range(0,5) - 2;
BOOST_CHECK(r9.start() == -2);
BOOST_CHECK(r9.stride() == 1);
BOOST_CHECK(r9.finish() == 3);
BOOST_TEST(r9.start() == -2);
BOOST_TEST(r9.stride() == 1);
BOOST_TEST(r9.finish() == 3);
}
return boost::exit_success;

View File

@@ -1,22 +1,11 @@
// 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.
//
// reshape.cpp - testing reshaping functionality
//
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include "boost/type.hpp"
@@ -52,9 +41,9 @@ test_main(int,char*[])
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_CHECK(A[i][j][k] == *ptr);
BOOST_CHECK(B[i][j][k] == *ptr);
BOOST_CHECK(C[i][j][k] == *ptr++);
BOOST_TEST(A[i][j][k] == *ptr);
BOOST_TEST(B[i][j][k] == *ptr);
BOOST_TEST(C[i][j][k] == *ptr++);
}
}
@@ -80,9 +69,9 @@ test_main(int,char*[])
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_CHECK(A[i][j][k] == *ptr);
BOOST_CHECK(B[i][j][k] == *ptr);
BOOST_CHECK(C[i][j][k] == *ptr++);
BOOST_TEST(A[i][j][k] == *ptr);
BOOST_TEST(B[i][j][k] == *ptr);
BOOST_TEST(C[i][j][k] == *ptr++);
}
}

View File

@@ -1,26 +1,30 @@
// 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.
//
// resize.cpp - Test of resizing multi_arrays
//
#include "boost/test/minimal.hpp"
#include "boost/multi_array.hpp"
#include <iostream>
using namespace std;
template <typename Array>
void print(std::ostream& os, const Array& A)
{
typename Array::const_iterator i;
os << "[";
for (i = A.begin(); i != A.end(); ++i) {
print(os, *i);
if (boost::next(i) != A.end())
os << ',';
}
os << "]";
}
int test_main(int,char*[]) {
void print(std::ostream& os, const int& x)
{
os << x;
}
int main() {
typedef boost::multi_array<int,3> marray;
@@ -35,6 +39,13 @@ int test_main(int,char*[]) {
20,21,22,23
};
marray A(boost::extents[2][3][4]);
A.assign(A_data,A_data+(2*3*4));
A.resize(boost::extents[4][3][2]);
int A_resize[] = {
0,1,
4,5,
@@ -53,75 +64,6 @@ int test_main(int,char*[]) {
0,0
};
// resize through the extent_gen interface
{
marray A(boost::extents[2][3][4]);
A.assign(A_data,A_data+(2*3*4));
A.resize(boost::extents[4][3][2]);
BOOST_CHECK(std::equal(A_resize,A_resize+(4*3*2),A.data()));
}
assert(std::equal(A_resize,A_resize+(4*3*2),A.data()));
// resize through the Collection
{
marray A(boost::extents[2][3][4]);
A.assign(A_data,A_data+(2*3*4));
boost::array<int,3> new_extents = {{4,3,2}};
A.resize(new_extents);
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_CHECK(std::accumulate(defaultA.data(),
defaultA.data()+(2*3*4),0) == 0);
}
// verify the preservation of storage order
{
int tiling_graph_storage_order[] = {2, 0, 1};
bool tiling_graph_index_order[] = {true, true, true};
marray A(boost::extents[3][4][2],
boost::general_storage_order<3>(tiling_graph_storage_order,
tiling_graph_index_order));
int value = 0;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 2; k++) {
*(A.data() + value) = value;
++value;
}
}
}
// "Resize" to the same size
A.resize(boost::extents[3][4][2]);
int check = 0;
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 4; y++) {
for (int z = 0; z < 2; z++) {
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::exit_success;
}

View File

@@ -1,23 +1,9 @@
// 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.
//
// slice.cpp - testing out slicing on a matrices
//
#include "generative_tests.hpp"
#include "boost/array.hpp"
#include "boost/mpl/if.hpp"
#include "boost/type_traits/is_same.hpp"
template <typename Array>
struct view_traits_mutable {
@@ -41,14 +27,46 @@ struct view_traits_const {
};
// Meta-program selects the proper view_traits implementation.
template <typename Array, typename ConstTag>
struct view_traits_generator :
boost::mpl::if_< boost::is_same<ConstTag,const_array_tag>,
view_traits_const<Array>,
view_traits_mutable<Array> >
{};
/////////////////////////////////////////////////////////////////////////
// choose view_traits begins
//
struct choose_view_traits_const {
template <typename Array>
struct bind {
typedef view_traits_const<Array> type;
};
};
struct choose_view_traits_mutable {
template <typename Array>
struct bind {
typedef view_traits_mutable<Array> type;
};
};
template <typename ConstnessTag>
struct view_traits_gen_helper {
typedef choose_view_traits_mutable choice;
};
template <>
struct view_traits_gen_helper<const_array_tag> {
typedef choose_view_traits_const choice;
};
template <typename Array, typename ConstTag>
struct view_traits_generator {
private:
typedef typename view_traits_gen_helper<ConstTag>::choice Choice;
public:
typedef typename Choice::template bind<Array>::type type;
};
//
// choose view_traits ends
/////////////////////////////////////////////////////////////////////////
template <typename Array, typename ViewTraits>
void test_views(Array& A, const ViewTraits&) {
@@ -71,10 +89,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_CHECK(B[i][j][k] == A[idx0+i][idx1+j+1][idx2+k*2]);
BOOST_TEST(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_CHECK(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]);
BOOST_TEST(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]);
}
}
// Degenerate dimensions
@@ -84,34 +102,12 @@ void test_views(Array& A, const ViewTraits&) {
for (index i = 0; i != 2; ++i)
for (index j = 0; j != 2; ++j) {
BOOST_CHECK(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]);
BOOST_TEST(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]);
boost::array<index,2> elmts;
elmts[0]=i; elmts[1]=j;
BOOST_CHECK(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]);
BOOST_TEST(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]);
}
}
// Flip the third dimension
{
typename ViewTraits::array_view3 B = A[
indices[range(idx0+0,idx0+2)]
[range(idx1+0,idx1+2)]
[range(idx2+2,idx2+0,-1)]
];
// typename ViewTraits::array_view3 B =
// A[indices[range(idx0+0,idx0+2)][idx1+1][range(idx2+0,idx2+4,2)]];
for (index i = 0; i != 2; ++i)
for (index j = 0; j != 2; ++j)
for (index k = 0; k != 2; ++k) {
BOOST_CHECK(B[i][j][k] == A[idx0+i][idx1+j][idx2+2-k]);
boost::array<index,3> elmts;
elmts[0]=i; elmts[1]=j; elmts[2]=k;
BOOST_CHECK(B(elmts) == A[idx0+i][idx1+j][idx2+2-k]);
}
}
++tests_run;
}

View File

@@ -1,20 +1,9 @@
// 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.
//
// stl_interaction.cpp - Make sure multi_arrays work with STL containers.
//
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/multi_array.hpp"
#include <algorithm>
@@ -51,7 +40,7 @@ test_main(int, char*[])
myarray.assign(data,data+data_size);
array3vec myvec(5,myarray);
BOOST_CHECK(myarray == myvec[1]);
BOOST_TEST(myarray == myvec[1]);
array3::array_view<2>::type myview =
myarray[indices[1][range(0,2)][range(1,3)]];
@@ -65,8 +54,8 @@ test_main(int, char*[])
myvec.push_back(myarray);
BOOST_CHECK(myarray != myvec[1]);
BOOST_CHECK(myarray == myvec[5]);
BOOST_TEST(myarray != myvec[1]);
BOOST_TEST(myarray == myvec[5]);
return boost::exit_success;
}

View File

@@ -1,22 +1,11 @@
// 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.
//
// storage_order.cpp - testing storage_order-isms.
//
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
@@ -67,7 +56,7 @@ test_main(int,char*[])
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_CHECK(A[i][j][k] == *num++);
BOOST_TEST(A[i][j][k] == *num++);
}
// Mimic fortran_storage_order using
@@ -88,7 +77,7 @@ test_main(int,char*[])
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_CHECK(A[i][j][k] == *num++);
BOOST_TEST(A[i][j][k] == *num++);
}
// general_storage_order with arbitrary storage order
@@ -119,7 +108,7 @@ test_main(int,char*[])
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_CHECK(A[i][j][k] == *num++);
BOOST_TEST(A[i][j][k] == *num++);
}
@@ -152,7 +141,7 @@ test_main(int,char*[])
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_CHECK(A[i][j][k] == *num++);
BOOST_TEST(A[i][j][k] == *num++);
}
return boost::exit_success;

View File

@@ -1,20 +1,9 @@
// 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.
//
// test out my new storage_order stuff
//
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/multi_array/storage_order.hpp"
@@ -31,8 +20,8 @@ test_main(int,char*[]) {
general_storage_order<5> fortran_storage(fortran_ordering.begin(),
ascending.begin());
BOOST_CHECK(c_storage == (general_storage_order<5>) c_storage_order());
BOOST_CHECK(fortran_storage ==
BOOST_TEST(c_storage == (general_storage_order<5>) c_storage_order());
BOOST_TEST(fortran_storage ==
(general_storage_order<5>) fortran_storage_order());
return boost::exit_success;

View File

@@ -1,22 +1,11 @@
// 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.
//
// index_bases - test of the index_base modifying facilities.
//
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/array.hpp"
#include <vector>