Compare commits

..

2 Commits

Author SHA1 Message Date
nobody
24d1980304 This commit was manufactured by cvs2svn to create tag
'Version_1_31_0'.

[SVN r22162]
2004-02-04 15:24:32 +00:00
nobody
f34bc373f2 This commit was manufactured by cvs2svn to create branch 'RC_1_31_0'.
[SVN r21427]
2003-12-30 12:10:04 +00:00
59 changed files with 892 additions and 1132 deletions

View File

@@ -20,13 +20,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="../../../people/people.htm"><font face="Arial" color="#ffffff"><big>People</big></font></a></td>
<td><a href="../../../more/faq.htm"><font face="Arial" color="#ffffff"><big>FAQ</big></font></a></td>
<td><a href="../../../more/index.htm"><font face="Arial" color="#ffffff"><big>More</big></font></a></td>
<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="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>

View File

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

View File

@@ -21,7 +21,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

@@ -20,7 +20,7 @@ Boost.MultiArray: Test Descriptions
</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<IMG SRC="http://www.boost.org/boost.png"
<IMG SRC="http://www.boost.org/c++boost.gif"
ALT="C++ Boost" width="277" height="86">
<h1>Boost.MultiArray: Test Descriptions</h1>
@@ -99,14 +99,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>
@@ -150,13 +142,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>

View File

@@ -21,7 +21,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)
@@ -582,7 +582,7 @@ cases can be found <a href="./test_cases.html">here</a>.
arrays.
This library is analogous to
<a href="../../array/index.html">boost::array</a> in that it augments C style N-dimensional
<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.
@@ -625,7 +625,7 @@ arrays, as <tt>boost::array</tt> does for C one-dimensional arrays.
</address>
<!-- Created: Fri Jun 29 10:53:07 EST 2001 -->
<!-- hhmts start -->
Last modified: Wed Nov 30 23:29:03 EST 2005
Last modified: Tue Sep 10 11:14:15 EST 2002
<!-- hhmts end -->
</body>

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:

View File

@@ -72,14 +72,6 @@ public:
const storage_order_type& store = c_storage_order(),
const Allocator& alloc = Allocator());
multi_array(const multi_array& x);
multi_array(const const_multi_array_ref<ValueType,NumDims>& x);
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
@@ -201,17 +193,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>

View File

@@ -26,7 +26,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,7 +38,6 @@
namespace boost {
namespace detail {
namespace multi_array {
struct populate_index_ranges {
multi_array_types::index_range
operator()(multi_array_types::index base,
@@ -47,61 +45,6 @@ namespace boost {
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
@@ -137,26 +80,22 @@ public:
};
explicit multi_array() :
super_type((T*)initial_base_,c_storage_order(),
/*index_bases=*/0, /*extents=*/0) {
allocate_space();
super_type((T*)initial_base_) {
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
) :
, typename detail::multi_array::disable_non_sub_array<ExtentList>::type* = 0
#endif
) :
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,
@@ -207,158 +146,23 @@ 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())
{
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())
{
sub_array<T,NumDims>& rhs) :
super_type(rhs) {
allocate_space();
std::copy(rhs.begin(),rhs.end(),this->begin());
}

View File

@@ -43,8 +43,7 @@
#include "boost/iterator.hpp"
namespace boost {
namespace detail {
namespace multi_array {
//--------------------------------------------------
// copy_n (not part of the C++ standard)
#if 1
@@ -96,8 +95,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

@@ -25,7 +25,7 @@
#include "boost/multi_array/storage_order.hpp"
#include "boost/multi_array/types.hpp"
#include "boost/config.hpp"
#include "boost/mpl/eval_if.hpp"
#include "boost/mpl/apply_if.hpp"
#include "boost/mpl/if.hpp"
#include "boost/mpl/size_t.hpp"
#include "boost/mpl/aux_/msvc_eti_base.hpp"
@@ -195,7 +195,7 @@ struct value_accessor_generator {
BOOST_STATIC_CONSTANT(std::size_t, dimensionality = NumDims::value);
typedef typename
mpl::eval_if_c<(dimensionality == 1),
mpl::apply_if_c<(dimensionality == 1),
choose_value_accessor_one<T>,
choose_value_accessor_n<T,dimensionality>
>::type type;

View File

@@ -150,10 +150,10 @@ namespace multi_array {
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

@@ -98,7 +98,7 @@ public:
array_iterator() {}
array_iterator(index idx, TPtr base, const size_type* extents,
array_iterator(int idx, TPtr base, const size_type* extents,
const index* strides,
const index* index_base) :
idx_(idx), base_(base), extents_(extents),

View File

@@ -71,12 +71,14 @@ public:
// make const_multi_array_ref a friend of itself
template <typename,std::size_t,typename>
friend class const_multi_array_ref;
// template <typename From, typename To> // needed for enable_if_convertible tests
// friend class boost::detail::is_convertible_basic_impl;
#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_),
@@ -140,8 +142,7 @@ public:
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_);
@@ -243,7 +244,7 @@ public:
}
const_iterator end() const {
return const_iterator(*index_bases()+(index)*shape(),origin(),
return const_iterator(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases());
}
@@ -302,46 +303,44 @@ public:
return !(*this < rhs);
}
protected:
// This is only supplied to support multi_array's default constructor
explicit const_multi_array_ref(TPtr base) :
base_(base), storage_(c_storage_order()) {
index_base_list_.assign(0);
boost::array<size_type,NumDims> filler;
filler.assign(0);
init_multi_array_ref(filler.begin());
}
// 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
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; }
template <typename OPtr>
const_multi_array_ref(
const detail::multi_array::const_sub_array<T,NumDims,OPtr>& rhs
)
: base_(0), // playing it "safe"; so we learn of errors
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());
}
// 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());
}
}
typedef boost::array<size_type,NumDims> size_list;
typedef boost::array<index,NumDims> index_list;
TPtr base_;
storage_order_type storage_;
@@ -377,23 +376,18 @@ 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>());
#if 0
assert(num_elements_ != 0);
#endif
this->compute_strides(stride_list_,extent_list_,storage_);
origin_offset_ =
@@ -424,9 +418,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 {
@@ -467,6 +459,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>
@@ -545,12 +541,12 @@ public:
}
iterator end() {
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
return iterator(*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;
@@ -612,11 +608,10 @@ public:
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) { }
explicit multi_array_ref(T* base) :
super_type(base) {
}
};

View File

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

@@ -142,7 +142,7 @@ public:
}
const_iterator end() const {
return const_iterator(*index_bases()+(index)*shape(),origin(),
return const_iterator(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases());
}
@@ -194,6 +194,44 @@ private:
const_sub_array& operator=(const const_sub_array&);
};
#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_non_sub_array.
//
template <typename T, std::size_t NumDims, typename TPtr>
char is_sub_array_help(const_sub_array<T,NumDims,TPtr>&);
char ( &is_sub_array_help(...) )[2];
template <class T>
struct is_sub_array
{
static T x;
BOOST_STATIC_CONSTANT(bool, value = sizeof((is_sub_array_help)(x)) == 1);
};
template <bool sub_array = false>
struct disable_non_sub_array_impl
{
// forming a pointer to a reference triggers SFINAE
typedef int& type;
};
template <>
struct disable_non_sub_array_impl<true>
{
typedef int type;
};
template <class T>
struct disable_non_sub_array
{
typedef typename disable_non_sub_array_impl<is_sub_array<T>::value>::type type;
};
#endif
//
// sub_array
@@ -295,7 +333,7 @@ public:
}
iterator end() {
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
return iterator(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),this->index_bases());
}

View File

@@ -73,8 +73,7 @@ public:
template <class BaseList>
void reindex(const BaseList& values) {
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_indexing_offset(stride_list_,index_base_list_);
}
@@ -147,7 +146,7 @@ public:
}
const_iterator end() const {
return const_iterator(*index_bases()+(index)*shape(),origin(),
return const_iterator(*index_bases()+*shape(),origin(),
shape(),strides(),index_bases());
}
@@ -226,10 +225,8 @@ 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(),
@@ -359,7 +356,7 @@ public:
}
iterator end() {
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
return iterator(*this->index_bases()+*this->shape(),origin(),
this->shape(),this->strides(),
this->index_bases());
}

View File

@@ -33,19 +33,18 @@ test-suite multi_array
[ compile-fail fail_ref_cview2.cpp ]
[ compile-fail fail_ref_cview3.cpp ]
[ run constructors.cpp ]
[ run access.cpp ]
[ run compare.cpp ]
[ run iterators.cpp ]
[ run slice.cpp ]
[ run assign.cpp ]
[ run assign_to_array.cpp ]
[ run index_bases.cpp ]
[ run storage_order.cpp ]
[ run reshape.cpp ]
[ run range1.cpp ]
[ run idxgen1.cpp ]
[ run stl_interaction.cpp ]
[ run resize.cpp ]
[ run constructors.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run access.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run compare.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run iterators.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run slice.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run assign.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run index_bases.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run storage_order.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run reshape.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run range1.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run idxgen1.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run stl_interaction.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ run resize.cpp <lib>../../test/build/boost_test_exec_monitor ]
[ compile concept_checks.cpp ]
;

View File

@@ -1,47 +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.cpp ../../test/build//boost_test_exec_monitor ]
[ run reshape.cpp ../../test/build//boost_test_exec_monitor ]
[ run range1.cpp ../../test/build//boost_test_exec_monitor ]
[ run idxgen1.cpp ../../test/build//boost_test_exec_monitor ]
[ run stl_interaction.cpp ../../test/build//boost_test_exec_monitor ]
[ run resize.cpp ../../test/build//boost_test_exec_monitor ]
[ compile concept_checks.cpp ]
;

View File

@@ -42,8 +42,8 @@ void access(Array& A, const const_array_tag&) {
for (index i = idx0; i != idx0+2; ++i)
for (index j = idx1; j != idx1+3; ++j)
for (index k = idx2; k != idx2+4; ++k) {
BOOST_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()
@@ -52,8 +52,8 @@ void access(Array& A, const const_array_tag&) {
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

@@ -59,7 +59,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

@@ -14,7 +14,8 @@
#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 +35,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 +45,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 +63,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 +109,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,6 +1,6 @@
// Copyright 2002 The Trustees of Indiana University.
// Use, modification and distribution is subject to the Boost Software
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -10,7 +10,7 @@
// Andrew Lumsdaine
// See http://www.boost.org/libs/multi_array for documentation.
//
//
// concept_checks.cpp -
// make sure the types meet concept requirements
//
@@ -19,7 +19,6 @@
#include "boost/multi_array/concept_checks.hpp"
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
@@ -60,6 +59,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

@@ -15,7 +15,8 @@
//
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include "boost/multi_array.hpp"
#include <algorithm>
@@ -30,10 +31,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());
}
@@ -132,20 +133,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 +162,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 +183,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 +191,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 +210,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

@@ -141,10 +141,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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

@@ -17,7 +17,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,7 +35,8 @@
//
#include "boost/multi_array.hpp"
#include "boost/test/minimal.hpp"
#define BOOST_INCLUDE_MAIN
#include "boost/test/test_tools.hpp"
#include <algorithm>
#include <iostream>

View File

@@ -17,7 +17,8 @@
#include "boost/multi_array/index_gen.hpp"
#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>
@@ -64,18 +65,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

@@ -16,7 +16,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 <vector>
@@ -63,11 +64,11 @@ 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[b].size(); ++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_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 +101,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]);
}
}
@@ -134,10 +135,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+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

@@ -18,8 +18,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 +64,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 +137,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 +151,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 +164,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 +178,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

@@ -17,7 +17,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 +31,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() == 5);
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

@@ -16,7 +16,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"
@@ -52,9 +53,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 +81,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

@@ -14,7 +14,7 @@
// resize.cpp - Test of resizing multi_arrays
//
#include "boost/test/minimal.hpp"
#include "boost/test/test_tools.hpp"
#include "boost/multi_array.hpp"
#include <iostream>
using namespace std;
@@ -60,13 +60,13 @@ int test_main(int,char*[]) {
0,0
};
BOOST_CHECK(std::equal(A_resize,A_resize+(4*3*2),A.data()));
BOOST_TEST(std::equal(A_resize,A_resize+(4*3*2),A.data()));
{
marray defaultA;
defaultA.resize(boost::extents[2][3][4]);
BOOST_CHECK(std::accumulate(defaultA.data(),
BOOST_TEST(std::accumulate(defaultA.data(),
defaultA.data()+(2*3*4),0) == 0);
}
return boost::exit_success;

View File

@@ -16,8 +16,6 @@
#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 +39,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 +101,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,10 +114,10 @@ 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]);
}
}
++tests_run;

View File

@@ -14,7 +14,8 @@
// 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 +52,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 +66,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

@@ -16,7 +16,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"
@@ -67,7 +68,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 +89,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 +120,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 +153,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

@@ -14,7 +14,8 @@
// 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"

View File

@@ -16,7 +16,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 <vector>