diff --git a/doc/reference.html b/doc/reference.html index 907309e..3cd136d 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -1,4 +1,4 @@ -Boost.MultiArray Reference Manual

Boost.MultiArray Reference Manual

Ronald Garcia

Indiana University
Open Systems Lab

Table of Contents

Library Synopsis
MultiArray Concept
Notation
Associated Types
Valid expressions
Complexity guarantees
Invariants
Associated Types for Views
Models
Array Components
multi_array
multi_array_ref
const_multi_array_ref
Auxiliary Components
multi_array_types
extent_range
extent_gen
Global Objects
View and SubArray Generators
Memory Layout Specifiers
Range Checking

Boost.MultiArray is composed of several components. +Boost.MultiArray Reference Manual

Boost.MultiArray Reference Manual

Ronald Garcia

Indiana University
Open Systems Lab

Boost.MultiArray is composed of several components. The MultiArray concept defines a generic interface to multidimensional containers. multi_array is a general purpose container class @@ -11,7 +11,7 @@ you can manipulate any block of contiguous data as though it were a multi_array_ref in that its elements cannot be modified through its interface. Finally, several auxiliary classes are used to create and specialize arrays and some global objects are defined as -part of the library interface.

Library Synopsis

To use Boost.MultiArray, you must include the header +part of the library interface.

Library Synopsis

To use Boost.MultiArray, you must include the header boost/multi_array.hpp in your source. This file brings the following declarations into scope:

 namespace boost {
@@ -52,7 +52,7 @@ namespace boost {
   template <std::size_t NumDims> class general_storage_order;
 
 }
-

MultiArray Concept

The MultiArray +

MultiArray Concept

The MultiArray concept defines an interface to hierarchically nested containers. It specifies operations for accessing elements, traversing containers, and creating views @@ -150,17 +150,23 @@ number of possible element layouts. For example, the elements of a 2 dimensional array can be stored by row (i.e., the elements of each row are stored contiguously) or by column (i.e., the elements of each column are stored contiguously). -

Notation

What follows are the descriptions of symbols that will be used -to describe the MultiArray interface.

Table 1. Notation

AA type that is a model of MultiArray +

+Two concept checking classes for the MultiArray concepts +(ConstMultiArrayConcept and +MutableMultiArrayConcept) are in the namespace +boost::multi_array_concepts in +<boost/multi_array/concept_checks.hpp>. +

Notation

What follows are the descriptions of symbols that will be used +to describe the MultiArray interface.

Table 1. Notation

AA type that is a model of MultiArray
a,bObjects of type A
NumDimsThe numeric dimension parameter associated with A.
DimsSome numeric dimension parameter such that 0<Dims<NumDims.
indicesAn object created by some number of chained calls to index_gen::operator[](index_range).
index_listAn object whose type models -Collection +Collection
idxA signed integral value.
tmpAn object of type - boost::array<index,NumDims>

Associated Types

-

Table 2. Associated Types

TypeDescription
value_typeThis is the value type of the container. + boost::array<index,NumDims>

Associated Types

+

Table 2. Associated Types

TypeDescription
value_typeThis is the value type of the container. If NumDims == 1, then this is element. Otherwise, this is the value type of the immediately nested containers. @@ -192,15 +198,17 @@ iterators. It is the same type as
iterator This is an iterator over the values of A. If NumDims == 1, then it models - + Random Access Iterator. Otherwise it models - + Random Access Traversal Iterator, - -Readable Iterator, and - -Writable Iterator. + +Readable Iterator, + +Writable Iterator, and + +Output Iterator.
const_iterator @@ -260,7 +268,7 @@ It models MultiArray. const_array_view<Dims>::type This is the const view type with Dims dimensions. -

Valid expressions

Table 3. Valid Expressions

ExpressionReturn typeSemantics
A::dimensionalitysize_typeThis compile-time constant represents the number of +

Valid expressions

Table 3. Valid Expressions

ExpressionReturn typeSemantics
A::dimensionalitysize_typeThis compile-time constant represents the number of dimensions of the array (note that A::dimensionality == NumDims).
a.shape()const size_type* This returns a list of NumDims elements specifying the @@ -345,26 +353,26 @@ This expression generates a view of the array determined by the used to construct indices.
a == bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable for this +type must model EqualityComparable for this expression to be valid.
a < bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model LessThanComparable for this +type must model LessThanComparable for this expression to be valid.
a <= bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable and -LessThanComparable for this +type must model EqualityComparable and +LessThanComparable for this expression to be valid.
a > bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model EqualityComparable and -LessThanComparable for this +type must model EqualityComparable and +LessThanComparable for this expression to be valid.
a >= bboolThis performs a lexicographical comparison of the values of a and b. The element -type must model LessThanComparable for this -expression to be valid.

Complexity guarantees

begin() and end() execute in amortized +type must model LessThanComparable for this +expression to be valid.

Complexity guarantees

begin() and end() execute in amortized constant time. size() executes in at most linear time in the MultiArray's size. -

Invariants

Table 4. Invariants

Valid range[a.begin(),a.end()) is a valid range. +

Invariants

Table 4. Invariants

Valid range[a.begin(),a.end()) is a valid range.
Range size a.size() == std::distance(a.begin(),a.end());.
Completeness @@ -375,11 +383,11 @@ Iteration through the range Calling a[a1][a2]...[aN] where N==NumDims yields the same result as calling a(index_list), where index_list -is a Collection containing the values a1...aN. -

Associated Types for Views

The following MultiArray associated +is a Collection containing the values a1...aN. +


Associated Types for Views

The following MultiArray associated types define the interface for creating views of existing MultiArrays. Their interfaces and roles in the -concept are described below.

index_range

index_range objects represent half-open +concept are described below.

index_range

index_range objects represent half-open strided intervals. They are aggregated (using an index_gen object) and passed to a MultiArray's operator[] @@ -403,10 +411,10 @@ operators, a half open range [5,10) can be specified as follows: The following describes the index_range interface. -

Table 5. Notation

iAn object of type index_range.
idx,idx1,idx2,idx3Objects of type index.

Table 6. Associated Types

TypeDescription
indexThis is a signed integral type. It is used to +

Table 5. Notation

iAn object of type index_range.
idx,idx1,idx2,idx3Objects of type index.

Table 6. Associated Types

TypeDescription
indexThis is a signed integral type. It is used to specify the start, finish, and stride values.
size_typeThis is an unsigned integral type. It is used to report the size of the range an index_range -represents.

Table 7. Valid Expressions

ExpressionReturn typeSemantics
index_range(idx1,idx2,idx3)index_rangeThis constructs an index_range +represents.

Table 7. Valid Expressions

ExpressionReturn typeSemantics
index_range(idx1,idx2,idx3)index_rangeThis constructs an index_range representing the interval [idx1,idx2) with stride idx3.
index_range(idx1,idx2)index_rangeThis constructs an index_range representing the interval [idx1,idx2) @@ -438,14 +446,14 @@ value. This notation includes of i up by idx. It is equivalent to index_range(r.start()+idx1, r.finish()+idx, r.stride())
i - idxindexThis expression shifts the start and finish values of i up by idx. It is equivalent to -index_range(r.start()-idx1, r.finish()-idx, r.stride())

index_gen

index_gen aggregates +index_range(r.start()-idx1, r.finish()-idx, r.stride())


index_gen

index_gen aggregates index_range objects in order to specify view parameters. Chained calls to operator[] store range and dimension information used to instantiate a new view into a MultiArray. -

Table 8. Notation

Dims,RangesUnsigned integral values.
xAn object of type +

Table 8. Notation

Dims,RangesUnsigned integral values.
xAn object of type template gen_type<Dims,Ranges>::type.
iAn object of type -index_range.
idxObjects of type index.

Table 9. Associated Types

TypeDescription
indexThis is a signed integral type. It is used to +index_range.
idxObjects of type index.

Table 9. Associated Types

TypeDescription
indexThis is a signed integral type. It is used to specify degenerate dimensions.
size_typeThis is an unsigned integral type. It is used to report the size of the range an index_range represents.
@@ -456,7 +464,7 @@ represents.
degenerate ranges specified (i.e. calls to operator[](index)). Note that index_gen and -gen_type<0,0>::type are the same type.

Table 10. Valid Expressions

ExpressionReturn typeSemantics
index_gen()gen_type<0,0>::typeThis constructs an index_gen +gen_type<0,0>::type are the same type.

Table 10. Valid Expressions

ExpressionReturn typeSemantics
index_gen()gen_type<0,0>::typeThis constructs an index_gen object. This object can then be used to generate tuples of index_range values.
x[i]gen_type<Dims+1,Ranges+1>::type Returns a new object containing all previous @@ -470,7 +478,7 @@ range, index_range(idx,idx). Note that this is NOT equivalent to x[index_range(idx,idx)]., which will return an object of type gen_type<Dims+1,Ranges+1>::type. -

Models

  • multi_array
  • multi_array_ref
  • const_multi_array_ref
  • template array_view<Dims>::type
  • template const_array_view<Dims>::type
  • template subarray<Dims>::type
  • template const_subarray<Dims>::type

Array Components

+


Models

  • multi_array
  • multi_array_ref
  • const_multi_array_ref
  • template array_view<Dims>::type
  • template const_array_view<Dims>::type
  • template subarray<Dims>::type
  • template const_subarray<Dims>::type

Array Components

Boost.MultiArray defines an array class, multi_array, and two adapter classes, multi_array_ref and @@ -487,7 +495,7 @@ adapts cannot be modified through its interface, though some array properties, including the array shape and index bases, can be altered. Functionality the classes have in common is described below. -

Note: Preconditions, Effects, and Implementation.  +

Note: Preconditions, Effects, and Implementation.  Throughout the following sections, small pieces of C++ code are used to specify constraints such as preconditions, effects, and postconditions. These do not necessarily describe the underlying @@ -498,7 +506,7 @@ preconditions results in undefined behavior. Not all effects (i.e. copy constructors, etc.) must be mimicked exactly. The code snippets for effects intend to capture the essence of the described operation. -

Queries. 

element* data();
+

Queries. 

element* data();
 const element* data() const;

This returns a pointer to the beginning of the contiguous block that contains the array's data. If all dimensions of the array are 0-indexed and stored in ascending order, this is @@ -516,7 +524,7 @@ version of this function. (Required by MultiArray) multi_array. (Required by MultiArray)

const size_type* shape();

This returns the shape of the multi_array. (Required by MultiArray) -

Comparators. 

+

Comparators. 

 bool operator==(const *array-type*& rhs);
 bool operator!=(const *array-type*& rhs);
 bool operator<(const *array-type*& rhs);
@@ -525,9 +533,9 @@ bool operator>=(const *array-type*& rhs);
 bool operator<=(const *array-type*& rhs);

Each comparator executes a lexicographical compare over the value types of the two arrays. (Required by MultiArray) -

Preconditions. element must support the +

Preconditions. element must support the comparator corresponding to that called on -multi_array.

Complexity. O(num_elements()).

Modifiers. 

+multi_array.

Complexity. O(num_elements()).

Modifiers. 

 
 template <typename SizeList>
@@ -537,12 +545,12 @@ void reshape(const SizeList& sizes)
 

This changes the shape of the multi_array. The number of elements and the index bases remain the same, but the number of values at each level of the nested container hierarchy may -change.

SizeList Requirements. SizeList must model -Collection.

Preconditions.  +change.

SizeList Requirements. SizeList must model +Collection.

Preconditions. 

-std::accumulate(sizes.begin(),sizes.end(),size_type(1),std::multiplies<size_type>()) == this->num_elements();
+std::accumulate(sizes.begin(),sizes.end(),size_type(1),std::times<size_type>()) == this->num_elements();
 sizes.size() == NumDims;
-

Postconditions.  +

Postconditions.  std::equal(sizes.begin(),sizes.end(),this->shape) == true;

@@ -552,8 +560,8 @@ void reindex(const BaseList& values);
 
 

This changes the index bases of the multi_array to -correspond to the the values in values.

BaseList Requirements. BaseList must model -Collection.

Preconditions. values.size() == NumDims;

Postconditions. std::equal(values.begin(),values.end(),this->index_bases()); +correspond to the the values in values.

BaseList Requirements. BaseList must model +Collection.

Preconditions. values.size() == NumDims;

Postconditions. std::equal(values.begin(),values.end(),this->index_bases());

 
@@ -561,15 +569,15 @@ void reindex(index value);
 
 

This changes the index bases of all dimensions of the -multi_array to value.

Postconditions.  +multi_array to value.

Postconditions. 

 
 std::count_if(this->index_bases(),this->index_bases()+this->num_dimensions(),
               std::bind_2nd(std::equal_to<index>(),value)) == 
               this->num_dimensions();
 
-

-

multi_array

+

+

multi_array

multi_array is a multi-dimensional container that supports random access iteration. Its number of dimensions is fixed at compile time, but its shape and the number of elements it @@ -578,11 +586,11 @@ will remain fixed for the duration of a multi_array's lifetime, but the shape of the container can be changed. A multi_array manages its data elements using a replaceable allocator. -

Model Of.  -MultiArray, -CopyConstructible. Depending on the element type, -it may also model EqualityComparable and LessThanComparable. -

Synopsis. 

+

Model Of.  +MultiArray, +CopyConstructible. Depending on the element type, +it may also model EqualityComparable and LessThanComparable. +

Synopsis. 

 
 namespace boost {
 
@@ -608,7 +616,7 @@ public:
   typedef multi_array_types::extent_gen         extent_gen;
   typedef multi_array_types::extent_range       extent_range;
   typedef *unspecified*                         storage_order_type;
-  
+
 
   // template typedefs
   template <std::size_t Dims> struct            subarray;
@@ -617,6 +625,9 @@ public:
   template <std::size_t Dims> struct            const_array_view;
   
 
+  static const std::size_t dimensionality = NumDims;
+  
+
   // constructors and destructors
 
   multi_array();
@@ -699,7 +710,7 @@ public:
   multi_array&                  resize(extents_tuple& extents);
 };
 
-

Constructors. 

template <typename ExtentList>
+

Constructors. 

template <typename ExtentList>
 explicit multi_array(const ExtentList& sizes,
                      const storage_order_type& store = c_storage_order(),
                      const Allocator& alloc = Allocator());
@@ -710,9 +721,9 @@ constructed multi_array.  sto
 specifies the storage order or layout in memory of the array
 dimensions.  alloc is used to
 allocate the contained elements.
-

ExtentList Requirements.  -ExtentList must model Collection. -

Preconditions. sizes.size() == NumDims;

+

ExtentList Requirements.  +ExtentList must model Collection. +

Preconditions. sizes.size() == NumDims;

explicit multi_array(extent_gen::gen_type<NumDims>::type ranges,
                      const storage_order_type& store = c_storage_order(),
                      const Allocator& alloc = Allocator());
@@ -736,34 +747,34 @@ multi_array(const subarray<NumDims>::type& x);
 multi_array(const array_view<NumDims>::type& x);
 

These constructors all constructs a multi_array and perform a deep copy of x. -

Complexity.  This performs O(x.num_elements()) calls to +

Complexity.  This performs O(x.num_elements()) calls to element's copy constructor.

 multi_array();
 

This constructs a multi_array whose shape is (0,...,0) and contains no elements. -

Note on Constructors.  +

Note on Constructors.  The multi_array construction expressions,

      multi_array<int,3> A(boost::extents[5][4][3]);
-

+

and

      boost::array<multi_array_base::index,3> my_extents = {{5, 4, 3}};
      multi_array<int,3> A(my_extents);
-

+

are equivalent. -

Modifiers. 

+

Modifiers. 

 multi_array& operator=(const multi_array& x);
 template <class Array> multi_array& operator=(const Array& x);
 

This performs an element-wise copy of x -into the current multi_array.

Array Requirements. Array must model MultiArray. -

Preconditions.  +into the current multi_array.

Array Requirements. Array must model MultiArray. +

Preconditions. 

std::equal(this->shape(),this->shape()+this->num_dimensions(),
-x.shape());

Postconditions.  -

(*.this) == x;

-

Complexity. The assignment operators perform +x.shape());

Postconditions.  +

(*.this) == x;

+

Complexity. The assignment operators perform O(x.num_elements()) calls to element's copy constructor.

@@ -774,8 +785,8 @@ void assign(InputIterator begin, InputIterator end);
 

This copies the elements in the range [begin,end) into the array. It is equivalent to std::copy(begin,end,this->data()). -

Preconditions. std::distance(begin,end) == this->num_elements(); -

Complexity.  +

Preconditions. std::distance(begin,end) == this->num_elements(); +

Complexity.  The assign member function performs O(this->num_elements()) calls to ValueType's copy constructor. @@ -792,25 +803,25 @@ 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 element default constructor. -

Queries. 

+

Queries. 

 storage_order_type& storage_order() const;
 

This query returns the storage order object associated with the -multi_array in question. It can be used to construct a new array with the same storage order.

multi_array_ref

+multi_array in question. It can be used to construct a new array with the same storage order.

multi_array_ref

multi_array_ref is a multi-dimensional container adaptor. It provides the MultiArray interface over any contiguous block of elements. multi_array_ref exports the same interface as multi_array, with the exception of the constructors. -

Model Of.  +

Model Of.  multi_array_ref models -MultiArray, -CopyConstructible. +MultiArray, +CopyConstructible. and depending on the element type, it may also model -EqualityComparable and LessThanComparable. +EqualityComparable and LessThanComparable. Detailed descriptions are provided here only for operations that are not described in the multi_array reference. -

Synopsis. 

+

Synopsis. 

 
 namespace boost {
 
@@ -843,7 +854,10 @@ public:
   template <std::size_t Dims> struct            const_array_view;
   
 
-  // structors
+  static const std::size_t dimensionality = NumDims;
+
+
+  // constructors and destructors
 
   template <typename ExtentList>
   explicit multi_array_ref(element* data, const ExtentList& sizes,
@@ -910,7 +924,7 @@ public:
   void				reindex(index value);
 };
 
-

Constructors. 

template <typename ExtentList>
+

Constructors. 

template <typename ExtentList>
 explicit multi_array_ref(element* data, 
                      const ExtentList& sizes,
                      const storage_order& store = c_storage_order(),
@@ -922,9 +936,9 @@ constructed multi_array_ref.  alloc is used to
 allocate the contained elements.
-

ExtentList Requirements.  -ExtentList must model Collection. -

Preconditions. sizes.size() == NumDims;

+

ExtentList Requirements.  +ExtentList must model Collection. +

Preconditions. sizes.size() == NumDims;

explicit multi_array_ref(element* data,
                      extent_gen::gen_type<NumDims>::type ranges,
                      const storage_order& store = c_storage_order());
@@ -939,36 +953,36 @@ dimensions.
 

 multi_array_ref(const multi_array_ref& x);
 

This constructs a shallow copy of x. -

Complexity.  Constant time (for contrast, compare this to +

Complexity.  Constant time (for contrast, compare this to the multi_array class copy constructor. -

Modifiers. 

+

Modifiers. 

 multi_array_ref& operator=(const multi_array_ref& x);
 template <class Array> multi_array_ref& operator=(const Array& x);
 

This performs an element-wise copy of x -into the current multi_array_ref.

Array Requirements. Array must model MultiArray. -

Preconditions.  +into the current multi_array_ref.

Array Requirements. Array must model MultiArray. +

Preconditions. 

std::equal(this->shape(),this->shape()+this->num_dimensions(),
-x.shape());

Postconditions.  -

(*.this) == x;

-

Complexity. The assignment operators perform +x.shape());

Postconditions.  +

(*.this) == x;

+

Complexity. The assignment operators perform O(x.num_elements()) calls to element's -copy constructor.

const_multi_array_ref

+copy constructor.

const_multi_array_ref

const_multi_array_ref is a multi-dimensional container adaptor. It provides the MultiArray interface over any contiguous block of elements. const_multi_array_ref exports the same interface as multi_array, with the exception of the constructors. -

Model Of.  +

Model Of.  const_multi_array_ref models -MultiArray, -CopyConstructible. +MultiArray, +CopyConstructible. and depending on the element type, it may also model -EqualityComparable and LessThanComparable. +EqualityComparable and LessThanComparable. Detailed descriptions are provided here only for operations that are not described in the multi_array reference. -

Synopsis. 

+

Synopsis. 

 
 namespace boost {
 
@@ -1054,7 +1068,7 @@ public:
   void				reindex(index value);
 };
 
-

Constructors. 

template <typename ExtentList>
+

Constructors. 

template <typename ExtentList>
 explicit const_multi_array_ref(TPtr data, 
                      const ExtentList& sizes,
                      const storage_order& store = c_storage_order());
@@ -1064,13 +1078,13 @@ parameters.  sizes specifies the shape of the
 constructed const_multi_array_ref.  store
 specifies the storage order or layout in memory of the array
 dimensions.
-

ExtentList Requirements.  -ExtentList must model Collection. -

Preconditions. sizes.size() == NumDims;

+

ExtentList Requirements.  +ExtentList must model Collection. +

Preconditions. sizes.size() == NumDims;

explicit const_multi_array_ref(TPtr data,
                      extent_gen::gen_type<NumDims>::type ranges,
                      const storage_order& store = c_storage_order());
-

Effects.  +

Effects.  This constructs a const_multi_array_ref using the specified parameters. ranges specifies the shape and index bases of the constructed const_multi_array_ref. It is the result of @@ -1080,8 +1094,8 @@ specifies the storage order or layout in memory of the array dimensions.

 const_multi_array_ref(const const_multi_array_ref& x);
-

Effects. This constructs a shallow copy of x. -

Auxiliary Components

multi_array_types

+

Effects. This constructs a shallow copy of x. +

Auxiliary Components

multi_array_types

 namespace multi_array_types {
   typedef *unspecified* index;
   typedef *unspecified* size_type;
@@ -1103,14 +1117,14 @@ With the exception of extent_gen and
 same name required by MultiArray and are described in its
 concept definition.  extent_gen and
 extent_range are described below.
-

extent_range

extent_range objects define half open +

extent_range

extent_range objects define half open intervals. They provide shape and index base information to multi_array, multi_array_ref, and const_multi_array_ref constructors. extent_ranges are passed in aggregate to an array constructor (see extent_gen for more details). -

Synopsis. 

+

Synopsis. 

 class extent_range {
 public:
   typedef multi_array_types::index      index;
@@ -1125,14 +1139,14 @@ public:
   index start();
   index finish();
   size_type size();
-};

Model Of. DefaultConstructible,CopyConstructible

Methods and Types. 

extent_range(index start, index finish)

This constructor defines the half open interval +};

Model Of. DefaultConstructible,CopyConstructible

Methods and Types. 

extent_range(index start, index finish)

This constructor defines the half open interval [start,finish). The expression finish must be greater than start.

extent_range(index finish)

This constructor defines the half open interval [0,finish). The value of finish must be positive.

index start()

This function returns the first index represented by the range

index finish()

This function returns the upper boundary value of the half-open interval. Note that the range does not include this value.

size_type size()

This function returns the size of the specified range. It is -equivalent to finish()-start().

extent_gen

The extent_gen class defines an +equivalent to finish()-start().

extent_gen

The extent_gen class defines an interface for aggregating array shape and indexing information to be passed to a multi_array, multi_array_ref, or const_multi_array_ref @@ -1144,7 +1158,7 @@ declared as:

int A[3][4][5],

a similar multi_array would be declared:

multi_array<int,3> A(extents[3][4][5]).

-

Synopsis. 

+

Synopsis. 

 template <std::size_t NumRanges>
 class *implementation_defined* {
 public:
@@ -1158,7 +1172,7 @@ public:
 };
 
 typedef *implementation_defined*<0> extent_gen;
-

Methods and Types. 

template gen_type<Ranges>::type

This type generator is used to specify the result of +

Methods and Types. 

template gen_type<Ranges>::type

This type generator is used to specify the result of Ranges chained calls to extent_gen::operator[]. The types extent_gen and @@ -1172,7 +1186,7 @@ operator[](index idx) const;

This function returns a ne extent_range objects in addition to extent_range(0,idx). This function gives the array constructors a similar syntax to traditional C multidimensional array -declaration.

Global Objects

For syntactic convenience, Boost.MultiArray defines two +declaration.

Global Objects

For syntactic convenience, Boost.MultiArray defines two global objects as part of its interface. These objects play the role of object generators; expressions involving them create other objects of interest. @@ -1180,7 +1194,7 @@ expressions involving them create other objects of interest. considered excessive overhead. Their construction can be prevented by defining the preprocessor symbol BOOST_MULTI_ARRAY_NO_GENERATORS before including -boost/multi_array.hpp.

extents

+boost/multi_array.hpp.

extents

 namespace boost {
   multi_array_base::extent_gen extents;
 }
@@ -1192,7 +1206,7 @@ a 3 by 3 by 3 multi_array is constructed as follo
 

multi_array<int,3> A(extents[3][3][3]);

The same array could also be created by explicitly declaring an extent_gen object locally,, but the global object makes this declaration unnecessary. -

indices

+

indices

 namespace boost {
   multi_array_base::index_gen  indices;
 }
@@ -1207,7 +1221,7 @@ a view of an array A is constructed as follows:
 

 A[indices[index_range(0,5)][2][index_range(2,4)]];
 

-

View and SubArray Generators

+

View and SubArray Generators

Boost.MultiArray provides traits classes, subarray_gen, const_subarray_gen, array_view_gen, @@ -1233,7 +1247,7 @@ void my_function() { In the above example, view1_t and view2_t have the same type. -

Memory Layout Specifiers

+

Memory Layout Specifiers

While a multidimensional array represents a hierarchy of containers of elements, at some point the elements must be laid out in memory. As a result, a single multidimensional array @@ -1321,7 +1335,7 @@ that must interoperate with Fortran routines so they can be manipulated naturally at both the C++ and Fortran levels. The following sections describe the Boost.MultiArray components used to specify memory layout. -

c_storage_order

+

c_storage_order

 class c_storage_order {
   c_storage_order();
 };
@@ -1329,14 +1343,14 @@ class c_storage_order {
 array should store its elements using the same layout as that used by
 primitive C++ multidimensional arrays, that is, from last dimension
 to first. This is the default storage order for the arrays provided by
-this library.

fortran_storage_order

+this library.

fortran_storage_order

 class fortran_storage_order {
   fortran_storage_order();
 };
 

fortran_storage_order is used to specify that an array should store its elements using the same memory layout as a Fortran multidimensional array would, that is, from first dimension to -last.

general_storage_order

+last.

general_storage_order

 template <std::size_t NumDims> 
 class general_storage_order {
 
@@ -1356,7 +1370,7 @@ convertible to bool.  A value of
 order while false means that a dimension is stored
 in descending order.  OrderingIter specifies the
 order in which dimensions are stored.
-

Range Checking

+

Range Checking

By default, the array access methods operator() and operator[] perform range checking. If a supplied index is out of the range defined for an diff --git a/doc/xml/MultiArray.xml b/doc/xml/MultiArray.xml index 0cf7580..5978b07 100644 --- a/doc/xml/MultiArray.xml +++ b/doc/xml/MultiArray.xml @@ -248,15 +248,17 @@ iterators. It is the same type as This is an iterator over the values of A. If NumDims == 1, then it models - + Random Access Iterator. Otherwise it models Random Access Traversal Iterator, -Readable Iterator, and +Readable Iterator, -Writable Iterator. +Writable Iterator, and + +Output Iterator. diff --git a/include/boost/multi_array/base.hpp b/include/boost/multi_array/base.hpp index ecbe097..0189831 100644 --- a/include/boost/multi_array/base.hpp +++ b/include/boost/multi_array/base.hpp @@ -81,7 +81,8 @@ class sub_array; template class const_sub_array; -template + template class array_iterator; template @@ -251,7 +252,19 @@ struct associated_types // choose value accessor ends ///////////////////////////////////////////////////////////////////////// - +// Due to some imprecision in the C++ Standard, +// MSVC 2010 is broken in debug mode: it requires +// that an Output Iterator have output_iterator_tag in its iterator_category if +// that iterator is not bidirectional_iterator or random_access_iterator. +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600) +struct mutable_iterator_tag + : boost::random_access_traversal_tag, std::input_iterator_tag +{ + operator std::output_iterator_tag() const { + return std::output_iterator_tag(); + } +}; +#endif //////////////////////////////////////////////////////////////////////// // multi_array_base @@ -301,8 +314,16 @@ public: // // iterator support // - typedef array_iterator,reference> iterator; - typedef array_iterator,const_reference> const_iterator; +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1600) + // Deal with VC 2010 output_iterator_tag requirement + typedef array_iterator,reference, + mutable_iterator_tag> iterator; +#else + typedef array_iterator,reference, + boost::random_access_traversal_tag> iterator; +#endif + typedef array_iterator,const_reference, + boost::random_access_traversal_tag> const_iterator; typedef ::boost::reverse_iterator reverse_iterator; typedef ::boost::reverse_iterator const_reverse_iterator; @@ -321,7 +342,8 @@ protected: const size_type* extents, const index* strides, const index* index_bases) const { - + boost::function_requires< + CollectionConcept >(); ignore_unused_variable_warning(index_bases); ignore_unused_variable_warning(extents); #if !defined(NDEBUG) && !defined(BOOST_DISABLE_ASSERTS) @@ -332,9 +354,15 @@ protected: #endif index offset = 0; - for (size_type n = 0; n != NumDims; ++n) - offset += indices[n] * strides[n]; - + { + typename IndexList::const_iterator i = indices.begin(); + size_type n = 0; + while (n != NumDims) { + offset += (*i) * strides[n]; + ++n; + ++i; + } + } return base[offset]; } diff --git a/include/boost/multi_array/concept_checks.hpp b/include/boost/multi_array/concept_checks.hpp index 8b9d465..3a53df8 100644 --- a/include/boost/multi_array/concept_checks.hpp +++ b/include/boost/multi_array/concept_checks.hpp @@ -131,6 +131,7 @@ namespace detail { function_requires< boost_concepts::WritableIteratorConcept >(); function_requires< boost_concepts::ForwardTraversalConcept >(); function_requires< boost_concepts::ReadableIteratorConcept >(); + function_requires< boost::OutputIterator >(); // RG - a( CollectionArchetype) when available... value_type vt = a[ id ]; diff --git a/include/boost/multi_array/iterator.hpp b/include/boost/multi_array/iterator.hpp index 59e7724..c77d34e 100644 --- a/include/boost/multi_array/iterator.hpp +++ b/include/boost/multi_array/iterator.hpp @@ -44,16 +44,18 @@ struct operator_arrow_proxy mutable T value_; }; -template +template class array_iterator; -template +template class array_iterator : public iterator_facade< - array_iterator + array_iterator , typename associated_types::value_type - , boost::random_access_traversal_tag + , IteratorCategory , Reference > , private @@ -69,7 +71,7 @@ class array_iterator typedef detail::multi_array::associated_types access_t; typedef iterator_facade< - array_iterator + array_iterator , typename detail::multi_array::associated_types::value_type , boost::random_access_traversal_tag , Reference @@ -79,7 +81,7 @@ class array_iterator typedef typename access_t::size_type size_type; #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - template + template friend class array_iterator; #else public: @@ -105,9 +107,9 @@ public: idx_(idx), base_(base), extents_(extents), strides_(strides), index_base_(index_base) { } - template + template array_iterator( - const array_iterator& rhs + const array_iterator& rhs , typename boost::enable_if_convertible::type* = 0 ) : idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),