mirror of
https://github.com/boostorg/multi_array.git
synced 2026-01-25 18:32:13 +00:00
Compare commits
10 Commits
boost-1.32
...
boost-1.33
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b18e81bebb | ||
|
|
24a7094017 | ||
|
|
49fd97b7de | ||
|
|
9260aaedbc | ||
|
|
afcd2d7e68 | ||
|
|
c6561fe6dd | ||
|
|
df70434391 | ||
|
|
2c011a11be | ||
|
|
99435c37fc | ||
|
|
26a0021e4f |
@@ -22,11 +22,11 @@
|
||||
<td bgcolor="#ffffff">
|
||||
<img src="../../../boost.png" alt="boost logo"
|
||||
width="277" align="middle" height="86"></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>
|
||||
<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>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
<h1>Boost.MultiArray</h1>
|
||||
|
||||
@@ -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/utility/counting_iterator.htm"><tt>boost::counting_iterator</tt></a>).
|
||||
integers when incremented and dereferenced (see <a href="http://www.boost.org/libs/iterator/doc/counting_iterator.html"><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/utility/transform_iterator.htm"><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/iterator/doc/transform_iterator.html"><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
|
||||
|
||||
@@ -207,7 +207,7 @@ public:
|
||||
multi_array(const multi_array& rhs) :
|
||||
super_type(rhs), allocator_(rhs.allocator_) {
|
||||
allocate_space();
|
||||
boost::copy_n(rhs.base_,rhs.num_elements(),base_);
|
||||
boost::detail::multi_array::copy_n(rhs.base_,rhs.num_elements(),base_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
#include "boost/iterator.hpp"
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
#if 1
|
||||
@@ -95,7 +96,8 @@ copy_n(InputIter first, Size count, OutputIter result) {
|
||||
}
|
||||
|
||||
#endif // 1
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ALGORITHM_RG071801_HPP
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
array_iterator() {}
|
||||
|
||||
array_iterator(int idx, TPtr base, const size_type* extents,
|
||||
array_iterator(index idx, TPtr base, const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
idx_(idx), base_(base), extents_(extents),
|
||||
|
||||
@@ -140,7 +140,8 @@ public:
|
||||
void reindex(const BaseList& values) {
|
||||
boost::function_requires<
|
||||
detail::multi_array::CollectionConcept<BaseList> >();
|
||||
boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
boost::detail::multi_array::
|
||||
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
origin_offset_ =
|
||||
this->calculate_origin_offset(stride_list_,extent_list_,
|
||||
storage_,index_base_list_);
|
||||
@@ -242,7 +243,7 @@ public:
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+*shape(),origin(),
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
@@ -327,7 +328,8 @@ public:
|
||||
// If index_bases or extents is null, then initialize the corresponding
|
||||
// private data to zeroed lists.
|
||||
if(index_bases) {
|
||||
boost::copy_n(index_bases,NumDims,index_base_list_.begin());
|
||||
boost::detail::multi_array::
|
||||
copy_n(index_bases,NumDims,index_base_list_.begin());
|
||||
} else {
|
||||
std::fill_n(index_base_list_.begin(),NumDims,0);
|
||||
}
|
||||
@@ -385,11 +387,12 @@ public:
|
||||
void init_multi_array_ref(InputIterator extents_iter) {
|
||||
boost::function_requires<InputIteratorConcept<InputIterator> >();
|
||||
|
||||
boost::copy_n(extents_iter,num_dimensions(),extent_list_.begin());
|
||||
boost::detail::multi_array::
|
||||
copy_n(extents_iter,num_dimensions(),extent_list_.begin());
|
||||
|
||||
// Calculate the array size
|
||||
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
|
||||
1,std::multiplies<index>());
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
|
||||
this->compute_strides(stride_list_,extent_list_,storage_);
|
||||
|
||||
@@ -542,7 +545,7 @@ public:
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+*this->shape(),origin(),
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace boost {
|
||||
template <typename OrderingIter, typename AscendingIter>
|
||||
general_storage_order(OrderingIter ordering,
|
||||
AscendingIter ascending) {
|
||||
boost::copy_n(ordering,NumDims,ordering_.begin());
|
||||
boost::copy_n(ascending,NumDims,ascending_.begin());
|
||||
boost::detail::multi_array::copy_n(ordering,NumDims,ordering_.begin());
|
||||
boost::detail::multi_array::copy_n(ascending,NumDims,ascending_.begin());
|
||||
}
|
||||
|
||||
// RG - ideally these would not be necessary, but some compilers
|
||||
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+*shape(),origin(),
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ public:
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+*this->shape(),origin(),
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ public:
|
||||
|
||||
template <class BaseList>
|
||||
void reindex(const BaseList& values) {
|
||||
boost::copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
boost::detail::multi_array::
|
||||
copy_n(values.begin(),num_dimensions(),index_base_list_.begin());
|
||||
origin_offset_ =
|
||||
this->calculate_indexing_offset(stride_list_,index_base_list_);
|
||||
}
|
||||
@@ -146,7 +147,7 @@ public:
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+*shape(),origin(),
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
@@ -225,8 +226,10 @@ public: // should be protected
|
||||
index_base_list_.assign(0);
|
||||
|
||||
// Get the extents and strides
|
||||
boost::copy_n(extents.begin(),NumDims,extent_list_.begin());
|
||||
boost::copy_n(strides.begin(),NumDims,stride_list_.begin());
|
||||
boost::detail::multi_array::
|
||||
copy_n(extents.begin(),NumDims,extent_list_.begin());
|
||||
boost::detail::multi_array::
|
||||
copy_n(strides.begin(),NumDims,stride_list_.begin());
|
||||
|
||||
// Calculate the array size
|
||||
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
|
||||
@@ -356,7 +359,7 @@ public:
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+*this->shape(),origin(),
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ void access(Array& A, const const_array_tag&) {
|
||||
for (index i = idx0; i != idx0+2; ++i)
|
||||
for (index j = idx1; j != idx1+3; ++j)
|
||||
for (index k = idx2; k != idx2+4; ++k) {
|
||||
BOOST_TEST(A[i][j][k] == cnum++);
|
||||
BOOST_TEST(CA[i][j][k] == A[i][j][k]);
|
||||
BOOST_CHECK(A[i][j][k] == cnum++);
|
||||
BOOST_CHECK(CA[i][j][k] == A[i][j][k]);
|
||||
}
|
||||
|
||||
// operator()
|
||||
@@ -52,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_TEST(A(indices) == A[i2][j2][k2]);
|
||||
BOOST_TEST(CA(indices) == A(indices));
|
||||
BOOST_CHECK(A(indices) == A[i2][j2][k2]);
|
||||
BOOST_CHECK(CA(indices) == A(indices));
|
||||
}
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void access(Array& A, const mutable_array_tag&) {
|
||||
|
||||
A = filler;
|
||||
|
||||
BOOST_TEST(equal(A,filler));
|
||||
BOOST_CHECK(equal(A,filler));
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ template <typename Array>
|
||||
void access(Array& A, const const_array_tag&) {
|
||||
typedef boost::multi_array<int,3> array3;
|
||||
array3 acopy(A);
|
||||
BOOST_TEST(equal(acopy,A));
|
||||
BOOST_CHECK(equal(acopy,A));
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ test_main(int, char*[])
|
||||
std::vector<double> vals(num_elements, 4.5);
|
||||
A.assign(vals.begin(),vals.end());
|
||||
array B(A);
|
||||
BOOST_TEST(A == B);
|
||||
BOOST_TEST(B == A);
|
||||
BOOST_TEST(A[0] == B[0]);
|
||||
BOOST_CHECK(A == B);
|
||||
BOOST_CHECK(B == A);
|
||||
BOOST_CHECK(A[0] == B[0]);
|
||||
}
|
||||
// Assignment Operator
|
||||
{
|
||||
@@ -44,15 +44,15 @@ test_main(int, char*[])
|
||||
std::vector<double> vals(num_elements, 4.5);
|
||||
A.assign(vals.begin(),vals.end());
|
||||
B = A;
|
||||
BOOST_TEST(A == B);
|
||||
BOOST_TEST(B == A);
|
||||
BOOST_TEST(B[0] == A[0]);
|
||||
BOOST_CHECK(A == B);
|
||||
BOOST_CHECK(B == A);
|
||||
BOOST_CHECK(B[0] == A[0]);
|
||||
|
||||
typedef array::index_range range;
|
||||
array::index_gen indices;
|
||||
array::array_view<2>::type C = A[indices[2][range()][range()]];
|
||||
array::array_view<2>::type D = B[indices[2][range()][range()]];
|
||||
BOOST_TEST(C == D);
|
||||
BOOST_CHECK(C == D);
|
||||
}
|
||||
// Different Arrays
|
||||
{
|
||||
@@ -62,15 +62,15 @@ test_main(int, char*[])
|
||||
A.assign(valsA.begin(),valsA.end());
|
||||
B.assign(valsB.begin(),valsB.end());
|
||||
|
||||
BOOST_TEST(A != B);
|
||||
BOOST_TEST(B != A);
|
||||
BOOST_TEST(A[0] != B[0]);
|
||||
BOOST_CHECK(A != B);
|
||||
BOOST_CHECK(B != A);
|
||||
BOOST_CHECK(A[0] != B[0]);
|
||||
|
||||
typedef array::index_range range;
|
||||
array::index_gen indices;
|
||||
array::array_view<2>::type C = A[indices[2][range()][range()]];
|
||||
array::array_view<2>::type D = B[indices[2][range()][range()]];
|
||||
BOOST_TEST(C != D);
|
||||
BOOST_CHECK(C != D);
|
||||
}
|
||||
|
||||
// Comparisons galore!
|
||||
@@ -108,30 +108,30 @@ test_main(int, char*[])
|
||||
A.assign(valsA,valsA+num_elements);
|
||||
B.assign(valsB,valsB+num_elements);
|
||||
|
||||
BOOST_TEST(B < A);
|
||||
BOOST_TEST(A > B);
|
||||
BOOST_CHECK(B < A);
|
||||
BOOST_CHECK(A > B);
|
||||
|
||||
BOOST_TEST(B <= A);
|
||||
BOOST_TEST(A >= B);
|
||||
BOOST_CHECK(B <= A);
|
||||
BOOST_CHECK(A >= B);
|
||||
|
||||
BOOST_TEST(B[0] == A[0]);
|
||||
BOOST_TEST(B[2] < A[2]);
|
||||
BOOST_CHECK(B[0] == A[0]);
|
||||
BOOST_CHECK(B[2] < A[2]);
|
||||
|
||||
array C = A;
|
||||
|
||||
BOOST_TEST(C <= A);
|
||||
BOOST_TEST(C >= A);
|
||||
BOOST_CHECK(C <= A);
|
||||
BOOST_CHECK(C >= A);
|
||||
|
||||
BOOST_TEST(!(C < A));
|
||||
BOOST_TEST(!(C > A));
|
||||
BOOST_CHECK(!(C < A));
|
||||
BOOST_CHECK(!(C > A));
|
||||
|
||||
typedef array::index_range range;
|
||||
array::index_gen indices;
|
||||
array::array_view<2>::type D = A[indices[2][range()][range()]];
|
||||
array::array_view<2>::type E = B[indices[2][range()][range()]];
|
||||
|
||||
BOOST_TEST(E < D);
|
||||
BOOST_TEST(E <= D);
|
||||
BOOST_CHECK(E < D);
|
||||
BOOST_CHECK(E <= D);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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,6 +19,7 @@
|
||||
#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"
|
||||
|
||||
@@ -59,6 +60,6 @@ boost::function_requires<
|
||||
boost::detail::multi_array::MutableMultiArrayConcept<array_view,ndims> >();
|
||||
boost::function_requires<
|
||||
boost::detail::multi_array::MutableMultiArrayConcept<subarray,ndims> >();
|
||||
|
||||
return boost::exit_success;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ void check_shape(const Array& A,
|
||||
int* strides,
|
||||
unsigned int num_elements)
|
||||
{
|
||||
BOOST_TEST(A.num_elements() == num_elements);
|
||||
BOOST_TEST(A.size() == *sizes);
|
||||
BOOST_TEST(std::equal(sizes, sizes + A.num_dimensions(), A.shape()));
|
||||
BOOST_TEST(std::equal(strides, strides + A.num_dimensions(), A.strides()));
|
||||
BOOST_CHECK(A.num_elements() == num_elements);
|
||||
BOOST_CHECK(A.size() == *sizes);
|
||||
BOOST_CHECK(std::equal(sizes, sizes + A.num_dimensions(), A.shape()));
|
||||
BOOST_CHECK(std::equal(strides, strides + A.num_dimensions(), A.strides()));
|
||||
check_shape(A[0], ++sizes, ++strides, num_elements / A.size());
|
||||
}
|
||||
|
||||
@@ -132,20 +132,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_TEST(equal(A, B));
|
||||
BOOST_CHECK(equal(A, B));
|
||||
|
||||
double ptr[27];
|
||||
boost::multi_array_ref<double, 3> C(ptr,sizes);
|
||||
A.assign(vals.begin(),vals.end());
|
||||
boost::multi_array_ref<double, 3> D(C);
|
||||
check_shape(D, &sizes[0], strides, num_elements);
|
||||
BOOST_TEST(C.data() == D.data());
|
||||
BOOST_CHECK(C.data() == D.data());
|
||||
|
||||
const double* cptr = ptr;
|
||||
boost::const_multi_array_ref<double, 3> E(cptr,sizes);
|
||||
boost::const_multi_array_ref<double, 3> F(E);
|
||||
check_shape(F, &sizes[0], strides, num_elements);
|
||||
BOOST_TEST(E.data() == F.data());
|
||||
BOOST_CHECK(E.data() == F.data());
|
||||
}
|
||||
|
||||
|
||||
@@ -161,15 +161,15 @@ 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_TEST(B.data() == A.data());
|
||||
BOOST_TEST(C.data() == A.data());
|
||||
BOOST_CHECK(B.data() == A.data());
|
||||
BOOST_CHECK(C.data() == A.data());
|
||||
|
||||
double ptr[27];
|
||||
boost::multi_array_ref<double, 3> D(ptr,sizes);
|
||||
D.assign(vals.begin(),vals.end());
|
||||
boost::const_multi_array_ref<double, 3> E(D);
|
||||
check_shape(E, &sizes[0], strides, num_elements);
|
||||
BOOST_TEST(E.data() == D.data());
|
||||
BOOST_CHECK(E.data() == D.data());
|
||||
}
|
||||
|
||||
// Assignment Operator
|
||||
@@ -182,7 +182,7 @@ test_main(int, char*[])
|
||||
A.assign(vals.begin(),vals.end());
|
||||
B = A;
|
||||
check_shape(B, &sizes[0], strides, num_elements);
|
||||
BOOST_TEST(equal(A, B));
|
||||
BOOST_CHECK(equal(A, B));
|
||||
|
||||
double ptr1[27];
|
||||
double ptr2[27];
|
||||
@@ -190,7 +190,7 @@ test_main(int, char*[])
|
||||
C.assign(vals.begin(),vals.end());
|
||||
D = C;
|
||||
check_shape(D, &sizes[0], strides, num_elements);
|
||||
BOOST_TEST(equal(C,D));
|
||||
BOOST_CHECK(equal(C,D));
|
||||
}
|
||||
|
||||
|
||||
@@ -209,8 +209,8 @@ test_main(int, char*[])
|
||||
subarray::value_type C = B[0];
|
||||
|
||||
// should comparisons between the types work?
|
||||
BOOST_TEST(equal(A[1][0],C));
|
||||
BOOST_TEST(equal(B[0],C));
|
||||
BOOST_CHECK(equal(A[1][0],C));
|
||||
BOOST_CHECK(equal(B[0],C));
|
||||
}
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
@@ -64,18 +64,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_TEST(is1.ranges_[0] == range(0,1,2));
|
||||
BOOST_TEST(is1.ranges_[1] == range(1,2,3));
|
||||
BOOST_TEST(is1.ranges_[2] == range(2,3,4));
|
||||
BOOST_CHECK(is1.ranges_[0] == range(0,1,2));
|
||||
BOOST_CHECK(is1.ranges_[1] == range(1,2,3));
|
||||
BOOST_CHECK(is1.ranges_[2] == range(2,3,4));
|
||||
}
|
||||
|
||||
{
|
||||
boost::detail::multi_array::index_gen<3,2> is2 =
|
||||
indices[range(0,1,2)][2][range(2,3,4)];
|
||||
BOOST_TEST(is2.ranges_[0] == range(0,1,2));
|
||||
BOOST_TEST(is2.ranges_[1] == range(2));
|
||||
BOOST_TEST(is2.ranges_[1].is_degenerate());
|
||||
BOOST_TEST(is2.ranges_[2] == range(2,3,4));
|
||||
BOOST_CHECK(is2.ranges_[0] == range(0,1,2));
|
||||
BOOST_CHECK(is2.ranges_[1] == range(2));
|
||||
BOOST_CHECK(is2.ranges_[1].is_degenerate());
|
||||
BOOST_CHECK(is2.ranges_[2] == range(2,3,4));
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
|
||||
@@ -63,11 +63,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_TEST(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_TEST(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_TEST(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_CHECK(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_CHECK(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_CHECK(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
// Test that E does not inherit A's index_base
|
||||
BOOST_TEST(E[a][b][c] == B[a][b][c]);
|
||||
BOOST_CHECK(E[a][b][c] == B[a][b][c]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ 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_TEST(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_TEST(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_TEST(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_TEST(E[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_CHECK(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_CHECK(C[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_CHECK(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
BOOST_CHECK(E[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,10 +134,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_TEST(A[a+1][b+1][c+1] == B[a][b][c]);
|
||||
BOOST_TEST(C[a+1][b+1][c+1] == B[a][b][c]);
|
||||
BOOST_TEST(D[a+1][b+1][c+1] == B[a][b][c]);
|
||||
BOOST_TEST(E[a+1][b+1][c+1] == B[a][b][c]);
|
||||
BOOST_CHECK(A[a+1][b+1][c+1] == B[a][b][c]);
|
||||
BOOST_CHECK(C[a+1][b+1][c+1] == B[a][b][c]);
|
||||
BOOST_CHECK(D[a+1][b+1][c+1] == B[a][b][c]);
|
||||
BOOST_CHECK(E[a+1][b+1][c+1] == B[a][b][c]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ void test_iterators(Array& A, const IterTraits&) {
|
||||
typedef typename IterTraits::iterator3 iterator;
|
||||
iterator i1 = A.begin();
|
||||
iterator i2 = A.end();
|
||||
BOOST_TEST(i1 < i2);
|
||||
BOOST_TEST((i2 - i1) == typename iterator::difference_type(2));
|
||||
BOOST_CHECK(i1 < i2);
|
||||
BOOST_CHECK((i2 - i1) == typename iterator::difference_type(2));
|
||||
}
|
||||
|
||||
// Standard Array Iteration
|
||||
@@ -121,7 +121,7 @@ void test_iterators(Array& A, const IterTraits&) {
|
||||
for (iterator3 i = A.begin(); i != A.end(); ++i)
|
||||
for(iterator2 ii = (*i).begin(); ii != (*i).end(); ++ii)
|
||||
for(iterator1 iii = (*ii).begin(); iii != (*ii).end(); ++iii)
|
||||
BOOST_TEST(*iii == vals++);
|
||||
BOOST_CHECK(*iii == vals++);
|
||||
}
|
||||
|
||||
// Using operator->() on iterators
|
||||
@@ -134,7 +134,7 @@ void test_iterators(Array& A, const IterTraits&) {
|
||||
for (iterator3 i = A.begin(); i != A.end(); ++i)
|
||||
for(iterator2 ii = i->begin(); ii != i->end(); ++ii)
|
||||
for(iterator1 iii = ii->begin(); iii != ii->end(); ++iii)
|
||||
BOOST_TEST(*iii == vals++);
|
||||
BOOST_CHECK(*iii == vals++);
|
||||
}
|
||||
|
||||
// Reverse Iterator Hierarchy Test
|
||||
@@ -148,7 +148,7 @@ void test_iterators(Array& A, const IterTraits&) {
|
||||
for(riterator2 ii = (*i).rbegin(); ii != (riterator2)(*i).rend(); ++ii)
|
||||
for(riterator1 iii = (*ii).rbegin(); iii != (riterator1)(*ii).rend();
|
||||
++iii)
|
||||
BOOST_TEST(*iii == check_iter_val--);
|
||||
BOOST_CHECK(*iii == check_iter_val--);
|
||||
}
|
||||
++tests_run;
|
||||
}
|
||||
|
||||
@@ -30,75 +30,75 @@ test_main(int,char*[])
|
||||
{
|
||||
// typical range creation and extraction
|
||||
range r1(-3,5);
|
||||
BOOST_TEST(r1.start() == -3);
|
||||
BOOST_TEST(r1.finish() == 5);
|
||||
BOOST_TEST(r1.stride() == 1);
|
||||
BOOST_TEST(!r1.is_degenerate());
|
||||
BOOST_TEST(r1.get_start(0) == -3);
|
||||
BOOST_TEST(r1.get_finish(100) == 5);
|
||||
BOOST_CHECK(r1.start() == -3);
|
||||
BOOST_CHECK(r1.finish() == 5);
|
||||
BOOST_CHECK(r1.stride() == 1);
|
||||
BOOST_CHECK(!r1.is_degenerate());
|
||||
BOOST_CHECK(r1.get_start(0) == -3);
|
||||
BOOST_CHECK(r1.get_finish(100) == 5);
|
||||
}
|
||||
|
||||
{
|
||||
range r2(-3,5,2);
|
||||
BOOST_TEST(r2.start() == -3);
|
||||
BOOST_TEST(r2.finish() == 5);
|
||||
BOOST_TEST(r2.stride() == 2);
|
||||
BOOST_TEST(!r2.is_degenerate());
|
||||
BOOST_CHECK(r2.start() == -3);
|
||||
BOOST_CHECK(r2.finish() == 5);
|
||||
BOOST_CHECK(r2.stride() == 2);
|
||||
BOOST_CHECK(!r2.is_degenerate());
|
||||
}
|
||||
|
||||
{
|
||||
// degenerate creation
|
||||
range r3(5);
|
||||
BOOST_TEST(r3.start() == 5);
|
||||
BOOST_TEST(r3.finish() == 5);
|
||||
BOOST_TEST(r3.stride() == 1);
|
||||
BOOST_TEST(r3.is_degenerate());
|
||||
BOOST_CHECK(r3.start() == 5);
|
||||
BOOST_CHECK(r3.finish() == 5);
|
||||
BOOST_CHECK(r3.stride() == 1);
|
||||
BOOST_CHECK(r3.is_degenerate());
|
||||
}
|
||||
|
||||
{
|
||||
// default range creation
|
||||
range r4;
|
||||
BOOST_TEST(r4.get_start(0) == 0);
|
||||
BOOST_TEST(r4.get_finish(100) == 100);
|
||||
BOOST_TEST(r4.stride() == 1);
|
||||
BOOST_CHECK(r4.get_start(0) == 0);
|
||||
BOOST_CHECK(r4.get_finish(100) == 100);
|
||||
BOOST_CHECK(r4.stride() == 1);
|
||||
}
|
||||
|
||||
{
|
||||
// create a range using the setter methods
|
||||
range r5 = range().stride(2).start(-3).finish(7);
|
||||
BOOST_TEST(r5.start() == -3);
|
||||
BOOST_TEST(r5.stride() == 2);
|
||||
BOOST_TEST(r5.finish() == 7);
|
||||
BOOST_CHECK(r5.start() == -3);
|
||||
BOOST_CHECK(r5.stride() == 2);
|
||||
BOOST_CHECK(r5.finish() == 7);
|
||||
}
|
||||
|
||||
// try out all the comparison operators
|
||||
{
|
||||
range r6 = -3 <= range().stride(2) < 7;
|
||||
BOOST_TEST(r6.start() == -3);
|
||||
BOOST_TEST(r6.stride() == 2);
|
||||
BOOST_TEST(r6.finish() == 7);
|
||||
BOOST_CHECK(r6.start() == -3);
|
||||
BOOST_CHECK(r6.stride() == 2);
|
||||
BOOST_CHECK(r6.finish() == 7);
|
||||
}
|
||||
|
||||
{
|
||||
range r7 = -3 < range() <= 7;
|
||||
BOOST_TEST(r7.start() == -2);
|
||||
BOOST_TEST(r7.stride() == 1);
|
||||
BOOST_TEST(r7.finish() == 8);
|
||||
BOOST_CHECK(r7.start() == -2);
|
||||
BOOST_CHECK(r7.stride() == 1);
|
||||
BOOST_CHECK(r7.finish() == 8);
|
||||
}
|
||||
|
||||
// arithmetic operators
|
||||
{
|
||||
range r8 = range(0,5) + 2;
|
||||
BOOST_TEST(r8.start() == 2);
|
||||
BOOST_TEST(r8.stride() == 1);
|
||||
BOOST_TEST(r8.finish() == 7);
|
||||
BOOST_CHECK(r8.start() == 2);
|
||||
BOOST_CHECK(r8.stride() == 1);
|
||||
BOOST_CHECK(r8.finish() == 7);
|
||||
}
|
||||
|
||||
{
|
||||
range r9 = range(0,5) - 2;
|
||||
BOOST_TEST(r9.start() == -2);
|
||||
BOOST_TEST(r9.stride() == 1);
|
||||
BOOST_TEST(r9.finish() == 3);
|
||||
BOOST_CHECK(r9.start() == -2);
|
||||
BOOST_CHECK(r9.stride() == 1);
|
||||
BOOST_CHECK(r9.finish() == 3);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
|
||||
@@ -52,9 +52,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_TEST(A[i][j][k] == *ptr);
|
||||
BOOST_TEST(B[i][j][k] == *ptr);
|
||||
BOOST_TEST(C[i][j][k] == *ptr++);
|
||||
BOOST_CHECK(A[i][j][k] == *ptr);
|
||||
BOOST_CHECK(B[i][j][k] == *ptr);
|
||||
BOOST_CHECK(C[i][j][k] == *ptr++);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,9 +80,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_TEST(A[i][j][k] == *ptr);
|
||||
BOOST_TEST(B[i][j][k] == *ptr);
|
||||
BOOST_TEST(C[i][j][k] == *ptr++);
|
||||
BOOST_CHECK(A[i][j][k] == *ptr);
|
||||
BOOST_CHECK(B[i][j][k] == *ptr);
|
||||
BOOST_CHECK(C[i][j][k] == *ptr++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,13 +60,13 @@ int test_main(int,char*[]) {
|
||||
0,0
|
||||
};
|
||||
|
||||
BOOST_TEST(std::equal(A_resize,A_resize+(4*3*2),A.data()));
|
||||
BOOST_CHECK(std::equal(A_resize,A_resize+(4*3*2),A.data()));
|
||||
|
||||
|
||||
{
|
||||
marray defaultA;
|
||||
defaultA.resize(boost::extents[2][3][4]);
|
||||
BOOST_TEST(std::accumulate(defaultA.data(),
|
||||
BOOST_CHECK(std::accumulate(defaultA.data(),
|
||||
defaultA.data()+(2*3*4),0) == 0);
|
||||
}
|
||||
return boost::exit_success;
|
||||
|
||||
@@ -71,10 +71,10 @@ void test_views(Array& A, const ViewTraits&) {
|
||||
for (index i = 0; i != 2; ++i)
|
||||
for (index j = 0; j != 2; ++j)
|
||||
for (index k = 0; k != 2; ++k) {
|
||||
BOOST_TEST(B[i][j][k] == A[idx0+i][idx1+j+1][idx2+k*2]);
|
||||
BOOST_CHECK(B[i][j][k] == A[idx0+i][idx1+j+1][idx2+k*2]);
|
||||
boost::array<index,3> elmts;
|
||||
elmts[0]=i; elmts[1]=j; elmts[2]=k;
|
||||
BOOST_TEST(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]);
|
||||
BOOST_CHECK(B(elmts) == A[idx0+i][idx1+j+1][idx2+k*2]);
|
||||
}
|
||||
}
|
||||
// Degenerate dimensions
|
||||
@@ -84,10 +84,10 @@ void test_views(Array& A, const ViewTraits&) {
|
||||
|
||||
for (index i = 0; i != 2; ++i)
|
||||
for (index j = 0; j != 2; ++j) {
|
||||
BOOST_TEST(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]);
|
||||
BOOST_CHECK(B[i][j] == A[idx0+i][idx1+1][idx2+j*2]);
|
||||
boost::array<index,2> elmts;
|
||||
elmts[0]=i; elmts[1]=j;
|
||||
BOOST_TEST(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]);
|
||||
BOOST_CHECK(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]);
|
||||
}
|
||||
}
|
||||
++tests_run;
|
||||
|
||||
@@ -51,7 +51,7 @@ test_main(int, char*[])
|
||||
myarray.assign(data,data+data_size);
|
||||
|
||||
array3vec myvec(5,myarray);
|
||||
BOOST_TEST(myarray == myvec[1]);
|
||||
BOOST_CHECK(myarray == myvec[1]);
|
||||
|
||||
array3::array_view<2>::type myview =
|
||||
myarray[indices[1][range(0,2)][range(1,3)]];
|
||||
@@ -65,8 +65,8 @@ test_main(int, char*[])
|
||||
|
||||
myvec.push_back(myarray);
|
||||
|
||||
BOOST_TEST(myarray != myvec[1]);
|
||||
BOOST_TEST(myarray == myvec[5]);
|
||||
BOOST_CHECK(myarray != myvec[1]);
|
||||
BOOST_CHECK(myarray == myvec[5]);
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,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_TEST(A[i][j][k] == *num++);
|
||||
BOOST_CHECK(A[i][j][k] == *num++);
|
||||
}
|
||||
|
||||
// Mimic fortran_storage_order using
|
||||
@@ -88,7 +88,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_TEST(A[i][j][k] == *num++);
|
||||
BOOST_CHECK(A[i][j][k] == *num++);
|
||||
}
|
||||
|
||||
// general_storage_order with arbitrary storage order
|
||||
@@ -119,7 +119,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_TEST(A[i][j][k] == *num++);
|
||||
BOOST_CHECK(A[i][j][k] == *num++);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,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_TEST(A[i][j][k] == *num++);
|
||||
BOOST_CHECK(A[i][j][k] == *num++);
|
||||
}
|
||||
|
||||
return boost::exit_success;
|
||||
|
||||
Reference in New Issue
Block a user