Removed tabs from files.

[SVN r14470]
This commit is contained in:
Ronald Garcia 2002-07-15 22:19:16 +00:00
parent 65def431aa
commit 501c5219e6
32 changed files with 136 additions and 136 deletions

View File

@ -10,7 +10,7 @@
template <typename Array, typename Element, typename Functor> template <typename Array, typename Element, typename Functor>
void for_each (const boost::type<Element>& type_dispatch, void for_each (const boost::type<Element>& type_dispatch,
Array A, Functor& xform) { Array A, Functor& xform) {
for_each(type_dispatch,A.begin(),A.end(),xform); for_each(type_dispatch,A.begin(),A.end(),xform);
} }
@ -21,8 +21,8 @@ void for_each (const boost::type<Element>&,Element& Val, Functor& xform) {
template <typename Element, typename Iterator, typename Functor> template <typename Element, typename Iterator, typename Functor>
void for_each (const boost::type<Element>& type_dispatch, void for_each (const boost::type<Element>& type_dispatch,
Iterator begin, Iterator end, Iterator begin, Iterator end,
Functor& xform) { Functor& xform) {
while (begin != end) { while (begin != end) {
for_each(type_dispatch,*begin,xform); for_each(type_dispatch,*begin,xform);
++begin; ++begin;

View File

@ -26,7 +26,7 @@ int main() {
#if 0 #if 0
std::copy(A.data(),A.data()+A.num_elements(), std::copy(A.data(),A.data()+A.num_elements(),
std::ostream_iterator<double>(std::cout,",")); std::ostream_iterator<double>(std::cout,","));
std::cout << "\n"; std::cout << "\n";
#endif #endif
@ -34,7 +34,7 @@ int main() {
#if 0 #if 0
std::copy(A.data(),A.data()+A.num_elements(), std::copy(A.data(),A.data()+A.num_elements(),
std::ostream_iterator<double>(std::cout,",")); std::ostream_iterator<double>(std::cout,","));
std::cout << "\n"; std::cout << "\n";
#endif #endif

View File

@ -23,7 +23,7 @@ int main() {
#if 0 #if 0
std::copy(A.begin(),A.end(), std::copy(A.begin(),A.end(),
std::ostream_iterator<double>(std::cout,",")); std::ostream_iterator<double>(std::cout,","));
std::cout << "\n"; std::cout << "\n";
#endif #endif
@ -32,7 +32,7 @@ int main() {
#if 0 #if 0
std::copy(A.begin(),A.end(), std::copy(A.begin(),A.end(),
std::ostream_iterator<double>(std::cout,",")); std::ostream_iterator<double>(std::cout,","));
std::cout << "\n"; std::cout << "\n";
#endif #endif

View File

@ -87,7 +87,7 @@ public:
template <class ExtentList> template <class ExtentList>
explicit multi_array(ExtentList const& extents, explicit multi_array(ExtentList const& extents,
const general_storage_order<NumDims>& so, const general_storage_order<NumDims>& so,
Allocator const& alloc) : Allocator const& alloc) :
super_type((T*)initial_base_,extents,so), allocator_(alloc) { super_type((T*)initial_base_,extents,so), allocator_(alloc) {
boost::function_requires< boost::function_requires<

View File

@ -29,18 +29,18 @@ void access(Array& A, const const_array_tag&) {
for (index i = idx0; i != idx0+2; ++i) for (index i = idx0; i != idx0+2; ++i)
for (index j = idx1; j != idx1+3; ++j) for (index j = idx1; j != idx1+3; ++j)
for (index k = idx2; k != idx2+4; ++k) { for (index k = idx2; k != idx2+4; ++k) {
BOOST_TEST(A[i][j][k] == cnum++); BOOST_TEST(A[i][j][k] == cnum++);
BOOST_TEST(CA[i][j][k] == A[i][j][k]); BOOST_TEST(CA[i][j][k] == A[i][j][k]);
} }
// operator() // operator()
for (index i2 = 0; i2 != 2; ++i2) for (index i2 = 0; i2 != 2; ++i2)
for (index j2 = 0; j2 != 3; ++j2) for (index j2 = 0; j2 != 3; ++j2)
for (index k2 = 0; k2 != 4; ++k2) { for (index k2 = 0; k2 != 4; ++k2) {
boost::array<index,ndims> indices; boost::array<index,ndims> indices;
indices[0] = i2; indices[1] = j2; indices[2] = k2; indices[0] = i2; indices[1] = j2; indices[2] = k2;
BOOST_TEST(A(indices) == A[i2][j2][k2]); BOOST_TEST(A(indices) == A[i2][j2][k2]);
BOOST_TEST(CA(indices) == A(indices)); BOOST_TEST(CA(indices) == A(indices));
} }
++tests_run; ++tests_run;
} }

View File

@ -68,30 +68,30 @@ test_main(int, char*[])
double valsA[] = { double valsA[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2,
2, 2, 2 2, 2, 2
}; };
double valsB[] = { double valsB[] = {
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2,
2, 2, 1 2, 2, 1
}; };
A.assign(valsA,valsA+num_elements); A.assign(valsA,valsA+num_elements);

View File

@ -12,9 +12,9 @@
template <class Array> template <class Array>
void check_shape(const Array& A, void check_shape(const Array& A,
unsigned int* sizes, unsigned int* sizes,
int* strides, int* strides,
unsigned int num_elements) unsigned int num_elements)
{ {
BOOST_TEST(A.num_elements() == num_elements); BOOST_TEST(A.num_elements() == num_elements);
BOOST_TEST(A.size() == *sizes); BOOST_TEST(A.size() == *sizes);

View File

@ -32,7 +32,7 @@ typedef std::size_t size_type;
explicit index_range(Index start, Index finish, Index stride=1) explicit index_range(Index start, Index finish, Index stride=1)
: start_(start), finish_(finish), stride_(stride), : start_(start), finish_(finish), stride_(stride),
degenerate_(start_ == finish_) degenerate_(start_ == finish_)
{ } { }
@ -59,7 +59,7 @@ typedef std::size_t size_type;
Index get_start(Index low_index_range = 0) const Index get_start(Index low_index_range = 0) const
{ {
if (start_ == from_start()) if (start_ == from_start())
return low_index_range; return low_index_range;
return start_; return start_;
} }
@ -71,16 +71,16 @@ typedef std::size_t size_type;
Index get_finish(Index high_index_range = 0) const Index get_finish(Index high_index_range = 0) const
{ {
if (finish_ == to_end()) if (finish_ == to_end())
return high_index_range; return high_index_range;
return finish_; return finish_;
} }
unsigned int size(Index recommended_length = 0) const unsigned int size(Index recommended_length = 0) const
{ {
if ((start_ == from_start()) || (finish_ == to_end())) if ((start_ == from_start()) || (finish_ == to_end()))
return recommended_length; return recommended_length;
else else
return (finish_ - start_) / stride_; return (finish_ - start_) / stride_;
} }
Index stride() const { return stride_; } Index stride() const { return stride_; }
@ -236,7 +236,7 @@ public:
template <int ND> template <int ND>
explicit index_gen(const index_gen<NumRanges-1,ND>& rhs, explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
const index_range<Index,SizeType>& range) const index_range<Index,SizeType>& range)
{ {
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin()); std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
*ranges_.rbegin() = range; *ranges_.rbegin() = range;

View File

@ -18,7 +18,7 @@ test_main(int,char**)
boost::array<array::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
const int data_size = 24; const int data_size = 24;
array sma(sma_dims); array sma(sma_dims);
sma.assign(data,data+data_size); sma.assign(data,data+data_size);

View File

@ -18,7 +18,7 @@ test_main(int,char**)
boost::array<array::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
const int data_size = 24; const int data_size = 24;
array sma(sma_dims); array sma(sma_dims);
sma.assign(data,data+data_size); sma.assign(data,data+data_size);

View File

@ -23,7 +23,7 @@ test_main(int,char**)
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
sma[i][j][k] = num++; sma[i][j][k] = num++;
array::const_subarray<ndims-1>::type csba = sma[0]; array::const_subarray<ndims-1>::type csba = sma[0];

View File

@ -23,7 +23,7 @@ test_main(int,char**)
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
sma[i][j][k] = num++; sma[i][j][k] = num++;
const array& sma_const = sma; const array& sma_const = sma;

View File

@ -23,7 +23,7 @@ test_main(int,char**)
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
sma[i][j][k] = num++; sma[i][j][k] = num++;
const array& sma_const = sma; const array& sma_const = sma;
@ -31,8 +31,8 @@ test_main(int,char**)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
// FAIL! sba cannot be assigned to. // FAIL! sba cannot be assigned to.
sba[j][k] = num++; sba[j][k] = num++;
return boost::exit_success; return boost::exit_success;
} }

View File

@ -20,7 +20,7 @@ test_main(int,char**)
boost::array<array::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
const int data_size = 24; const int data_size = 24;
array sma(sma_dims); array sma(sma_dims);

View File

@ -20,7 +20,7 @@ test_main(int,char**)
boost::array<array::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
const int data_size = 24; const int data_size = 24;
array sma(sma_dims); array sma(sma_dims);

View File

@ -20,7 +20,7 @@ test_main(int,char**)
boost::array<array::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
const int data_size = 24; const int data_size = 24;
array sma(sma_dims); array sma(sma_dims);
@ -41,8 +41,8 @@ test_main(int,char**)
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 2; ++j) for (array::index j = 0; j != 2; ++j)
for (array::index k = 0; k != 2; ++k) for (array::index k = 0; k != 2; ++k)
// FAIL! csma2 cannot be assigned to. // FAIL! csma2 cannot be assigned to.
csma2[i][j][k] = 0; csma2[i][j][k] = 0;
return boost::exit_success; return boost::exit_success;
} }

View File

@ -18,7 +18,7 @@ test_main(int,char**)
boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
array_ref sma(data,sma_dims); array_ref sma(data,sma_dims);
const array_ref& csma = sma; const array_ref& csma = sma;

View File

@ -19,7 +19,7 @@ test_main(int,char**)
boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
array_ref sma(data,sma_dims); array_ref sma(data,sma_dims);

View File

@ -27,7 +27,7 @@ test_main(int,char**)
for (array_ref::index i = 0; i != 2; ++i) for (array_ref::index i = 0; i != 2; ++i)
for (array_ref::index j = 0; j != 3; ++j) for (array_ref::index j = 0; j != 3; ++j)
for (array_ref::index k = 0; k != 4; ++k) for (array_ref::index k = 0; k != 4; ++k)
sma[i][j][k] = num++; sma[i][j][k] = num++;
array_ref::const_subarray<ndims-1>::type csba = sma[0]; array_ref::const_subarray<ndims-1>::type csba = sma[0];

View File

@ -27,12 +27,12 @@ test_main(int,char**)
for (array_ref::index i = 0; i != 2; ++i) for (array_ref::index i = 0; i != 2; ++i)
for (array_ref::index j = 0; j != 3; ++j) for (array_ref::index j = 0; j != 3; ++j)
for (array_ref::index k = 0; k != 4; ++k) for (array_ref::index k = 0; k != 4; ++k)
sma[i][j][k] = num++; sma[i][j][k] = num++;
const array_ref& sma_const = sma; const array_ref& sma_const = sma;
array_ref::subarray<ndims-1>::type sba = sma_const[0]; // FAIL! array_ref::subarray<ndims-1>::type sba = sma_const[0]; // FAIL!
// preserve constness // preserve constness
return boost::exit_success; return boost::exit_success;
} }

View File

@ -27,7 +27,7 @@ test_main(int,char**)
for (array_ref::index i = 0; i != 2; ++i) for (array_ref::index i = 0; i != 2; ++i)
for (array_ref::index j = 0; j != 3; ++j) for (array_ref::index j = 0; j != 3; ++j)
for (array_ref::index k = 0; k != 4; ++k) for (array_ref::index k = 0; k != 4; ++k)
sma[i][j][k] = num++; sma[i][j][k] = num++;
const array_ref& sma_const = sma; const array_ref& sma_const = sma;
@ -35,7 +35,7 @@ test_main(int,char**)
for (array_ref::index j = 0; j != 3; ++j) for (array_ref::index j = 0; j != 3; ++j)
for (array_ref::index k = 0; k != 4; ++k) for (array_ref::index k = 0; k != 4; ++k)
sba[j][k] = num++; // FAIL! can't assign to const_subarray. sba[j][k] = num++; // FAIL! can't assign to const_subarray.
return boost::exit_success; return boost::exit_success;
} }

View File

@ -20,7 +20,7 @@ test_main(int,char**)
boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
array_ref sma(data,sma_dims); array_ref sma(data,sma_dims);

View File

@ -20,7 +20,7 @@ test_main(int,char**)
boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
array_ref sma(data,sma_dims); array_ref sma(data,sma_dims);
@ -39,7 +39,7 @@ test_main(int,char**)
for (array_ref::index i = 0; i != 2; ++i) for (array_ref::index i = 0; i != 2; ++i)
for (array_ref::index j = 0; j != 2; ++j) for (array_ref::index j = 0; j != 2; ++j)
for (array_ref::index k = 0; k != 2; ++k) for (array_ref::index k = 0; k != 2; ++k)
csma2[i][j][k] = 0; // FAIL! csma2 is read only csma2[i][j][k] = 0; // FAIL! csma2 is read only
return boost::exit_success; return boost::exit_success;
} }

View File

@ -20,7 +20,7 @@ test_main(int,char**)
boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}}; boost::array<array_ref::size_type,ndims> sma_dims = {{2,3,4}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
array_ref sma(data,sma_dims); array_ref sma(data,sma_dims);
@ -40,7 +40,7 @@ test_main(int,char**)
for (array_ref::index i = 0; i != 2; ++i) for (array_ref::index i = 0; i != 2; ++i)
for (array_ref::index j = 0; j != 2; ++j) for (array_ref::index j = 0; j != 2; ++j)
for (array_ref::index k = 0; k != 2; ++k) for (array_ref::index k = 0; k != 2; ++k)
csma2[i][j][k] = 0; // FAIL! csma2 is read only. csma2[i][j][k] = 0; // FAIL! csma2 is read only.
return boost::exit_success; return boost::exit_success;
} }

View File

@ -72,7 +72,7 @@ void assign_if_not_const(Array& A, const mutable_array_tag&) {
for (index i = idx0; i != idx0 + 2; ++i) for (index i = idx0; i != idx0 + 2; ++i)
for (index j = idx1; j != idx1 + 3; ++j) for (index j = idx1; j != idx1 + 3; ++j)
for (index k = idx2; k != idx2 + 4; ++k) for (index k = idx2; k != idx2 + 4; ++k)
A[i][j][k] = num++; A[i][j][k] = num++;
} }
#endif // MULTIARRAY_TEST_ASSIGN #endif // MULTIARRAY_TEST_ASSIGN
@ -89,8 +89,8 @@ void access(Array& A, const const_array_tag&);
template <typename StorageOrder3,typename StorageOrder4,typename Modifier> template <typename StorageOrder3,typename StorageOrder4,typename Modifier>
int run_configuration(const StorageOrder3& so3, int run_configuration(const StorageOrder3& so3,
const StorageOrder4& so4, const StorageOrder4& so4,
const Modifier& modifier) { const Modifier& modifier) {
// multi_array // multi_array
{ {
typedef boost::multi_array<int,3> array; typedef boost::multi_array<int,3> array;
@ -169,8 +169,8 @@ int run_configuration(const StorageOrder3& so3,
typename array::template array_view<3>::type B =A[ typename array::template array_view<3>::type B =A[
indices[range(idx0+1,idx0+3)] indices[range(idx0+1,idx0+3)]
[range(idx1+1,idx1+4)] [range(idx1+1,idx1+4)]
[range(idx2+1,idx2+5)] [range(idx2+1,idx2+5)]
]; ];
access(B,mutable_array_tag()); access(B,mutable_array_tag());
} }
@ -192,8 +192,8 @@ int run_configuration(const StorageOrder3& so3,
typename array::template array_view<3>::type B =A[ typename array::template array_view<3>::type B =A[
indices[range(idx0+1,idx0+3)] indices[range(idx0+1,idx0+3)]
[range(idx1+1,idx1+4)] [range(idx1+1,idx1+4)]
[range(idx2+1,idx2+5)] [range(idx2+1,idx2+5)]
]; ];
assign(B); assign(B);
@ -207,15 +207,15 @@ int run_configuration(const StorageOrder3& so3,
template <typename ArrayModifier> template <typename ArrayModifier>
int run_storage_tests(const ArrayModifier& modifier) { int run_storage_tests(const ArrayModifier& modifier) {
run_configuration(boost::c_storage_order(), run_configuration(boost::c_storage_order(),
boost::c_storage_order(),modifier); boost::c_storage_order(),modifier);
run_configuration(boost::fortran_storage_order(), run_configuration(boost::fortran_storage_order(),
boost::fortran_storage_order(),modifier); boost::fortran_storage_order(),modifier);
std::size_t ordering[] = {2,0,1,3}; std::size_t ordering[] = {2,0,1,3};
bool ascending[] = {false,true,true,true}; bool ascending[] = {false,true,true,true};
run_configuration(boost::general_storage_order<3>(ordering,ascending), run_configuration(boost::general_storage_order<3>(ordering,ascending),
boost::general_storage_order<4>(ordering,ascending), boost::general_storage_order<4>(ordering,ascending),
modifier); modifier);
return boost::exit_success; return boost::exit_success;
} }

View File

@ -14,12 +14,12 @@
template <int NumRanges, int NumDims> template <int NumRanges, int NumDims>
void check(const boost::detail::multi_array:: void check(const boost::detail::multi_array::
index_gen<NumRanges,NumDims>&) { } index_gen<NumRanges,NumDims>&) { }
bool operator==(const boost::detail::multi_array:: bool operator==(const boost::detail::multi_array::
index_range<int,std::size_t>& lhs, index_range<int,std::size_t>& lhs,
const boost::detail::multi_array:: const boost::detail::multi_array::
index_range<int,std::size_t>& rhs) { index_range<int,std::size_t>& rhs) {
return lhs.start_ == rhs.start_ && return lhs.start_ == rhs.start_ &&
lhs.finish_ == rhs.finish_ && lhs.finish_ == rhs.finish_ &&
lhs.stride_ == rhs.stride_ && lhs.stride_ == rhs.stride_ &&

View File

@ -51,13 +51,13 @@ test_main(int,char**)
boost::array<int,3> bases = { { 1, 2, 3 } }; boost::array<int,3> bases = { { 1, 2, 3 } };
for (size_type a = 0; a < A.shape()[0]; ++a) for (size_type a = 0; a < A.shape()[0]; ++a)
for (size_type b = 0; b < A.shape()[1]; ++b) for (size_type b = 0; b < A.shape()[1]; ++b)
for (size_type c = 0; c < A[b].size(); ++c) { for (size_type c = 0; c < A[b].size(); ++c) {
BOOST_TEST(A[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]); BOOST_TEST(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(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(D[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
// Test that E does not inherit A's index_base // Test that E does not inherit A's index_base
BOOST_TEST(E[a][b][c] == B[a][b][c]); BOOST_TEST(E[a][b][c] == B[a][b][c]);
} }
} }
// Reindex // Reindex
@ -88,12 +88,12 @@ test_main(int,char**)
for (size_type a = 0; a < A.shape()[0]; ++a) for (size_type a = 0; a < A.shape()[0]; ++a)
for (size_type b = 0; b < A.shape()[1]; ++b) for (size_type b = 0; b < A.shape()[1]; ++b)
for (size_type c = 0; c < A.shape()[2]; ++c) { 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(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(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(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_TEST(E[a+bases[0]][b+bases[1]][c+bases[2]] == B[a][b][c]);
} }
} }
// Set Index Base // Set Index Base
@ -122,12 +122,12 @@ test_main(int,char**)
for (size_type a = 0; a < A.shape()[0]; ++a) for (size_type a = 0; a < A.shape()[0]; ++a)
for (size_type b = 0; b < A.shape()[1]; ++b) for (size_type b = 0; b < A.shape()[1]; ++b)
for (size_type c = 0; c < A.shape()[2]; ++c) { 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(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(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(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_TEST(E[a+1][b+1][c+1] == B[a][b][c]);
} }
} }
return boost::exit_success; return boost::exit_success;

View File

@ -19,7 +19,7 @@ void assign_if_not_const(Array& A, const mutable_array_tag&) {
for (iterator3 i = A.begin(); i != A.end(); ++i) for (iterator3 i = A.begin(); i != A.end(); ++i)
for(iterator2 ii = (*i).begin(); ii != (*i).end(); ++ii) for(iterator2 ii = (*i).begin(); ii != (*i).end(); ++ii)
for(iterator1 iii = (*ii).begin(); iii != (*ii).end(); ++iii) for(iterator1 iii = (*ii).begin(); iii != (*ii).end(); ++iii)
*iii = num++; *iii = num++;
} }
@ -136,8 +136,8 @@ void test_iterators(Array& A, const IterTraits&) {
int vals = 0; int vals = 0;
for (iterator3 i = A.begin(); i != A.end(); ++i) for (iterator3 i = A.begin(); i != A.end(); ++i)
for(iterator2 ii = (*i).begin(); ii != (*i).end(); ++ii) for(iterator2 ii = (*i).begin(); ii != (*i).end(); ++ii)
for(iterator1 iii = (*ii).begin(); iii != (*ii).end(); ++iii) for(iterator1 iii = (*ii).begin(); iii != (*ii).end(); ++iii)
BOOST_TEST(*iii == vals++); BOOST_TEST(*iii == vals++);
} }
// Using operator->() on iterators // Using operator->() on iterators
@ -149,8 +149,8 @@ void test_iterators(Array& A, const IterTraits&) {
int vals = 0; int vals = 0;
for (iterator3 i = A.begin(); i != A.end(); ++i) for (iterator3 i = A.begin(); i != A.end(); ++i)
for(iterator2 ii = i->begin(); ii != i->end(); ++ii) for(iterator2 ii = i->begin(); ii != i->end(); ++ii)
for(iterator1 iii = ii->begin(); iii != ii->end(); ++iii) for(iterator1 iii = ii->begin(); iii != ii->end(); ++iii)
BOOST_TEST(*iii == vals++); BOOST_TEST(*iii == vals++);
} }
// Reverse Iterator Hierarchy Test // Reverse Iterator Hierarchy Test
@ -162,9 +162,9 @@ void test_iterators(Array& A, const IterTraits&) {
int check_iter_val = A.num_elements()-1; int check_iter_val = A.num_elements()-1;
for (riterator3 i = A.rbegin(); i != (riterator3)A.rend(); ++i) for (riterator3 i = A.rbegin(); i != (riterator3)A.rend(); ++i)
for(riterator2 ii = (*i).rbegin(); ii != (riterator2)(*i).rend(); ++ii) for(riterator2 ii = (*i).rbegin(); ii != (riterator2)(*i).rend(); ++ii)
for(riterator1 iii = (*ii).rbegin(); iii != (riterator1)(*ii).rend(); for(riterator1 iii = (*ii).rbegin(); iii != (riterator1)(*ii).rend();
++iii) ++iii)
BOOST_TEST(*iii == check_iter_val--); BOOST_TEST(*iii == check_iter_val--);
} }
++tests_run; ++tests_run;
} }

View File

@ -22,7 +22,7 @@ test_main(int,char**)
boost::array<array::size_type,ndims> new_dims = {{4,3,2}}; boost::array<array::size_type,ndims> new_dims = {{4,3,2}};
int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13, int data[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23}; 14,15,16,17,18,19,20,21,22,23};
const int data_size=24; const int data_size=24;
// Basic reshape test // Basic reshape test
@ -40,11 +40,11 @@ test_main(int,char**)
int* ptr = data; int* ptr = data;
for (array::index i = 0; i != 4; ++i) for (array::index i = 0; i != 4; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 2; ++k) { for (array::index k = 0; k != 2; ++k) {
BOOST_TEST(A[i][j][k] == *ptr); BOOST_TEST(A[i][j][k] == *ptr);
BOOST_TEST(B[i][j][k] == *ptr); BOOST_TEST(B[i][j][k] == *ptr);
BOOST_TEST(C[i][j][k] == *ptr++); BOOST_TEST(C[i][j][k] == *ptr++);
} }
} }
// Ensure that index bases are preserved over reshape // Ensure that index bases are preserved over reshape
@ -68,11 +68,11 @@ test_main(int,char**)
int* ptr = data; int* ptr = data;
for (array::index i = 0; i != 4; ++i) for (array::index i = 0; i != 4; ++i)
for (array::index j = 1; j != 4; ++j) for (array::index j = 1; j != 4; ++j)
for (array::index k = -1; k != 1; ++k) { for (array::index k = -1; k != 1; ++k) {
BOOST_TEST(A[i][j][k] == *ptr); BOOST_TEST(A[i][j][k] == *ptr);
BOOST_TEST(B[i][j][k] == *ptr); BOOST_TEST(B[i][j][k] == *ptr);
BOOST_TEST(C[i][j][k] == *ptr++); BOOST_TEST(C[i][j][k] == *ptr++);
} }
} }
return boost::exit_success; return boost::exit_success;

View File

@ -88,12 +88,12 @@ void test_views(Array& A, const ViewTraits&) {
for (index i = 0; i != 2; ++i) for (index i = 0; i != 2; ++i)
for (index j = 0; j != 2; ++j) for (index j = 0; j != 2; ++j)
for (index k = 0; k != 2; ++k) { for (index k = 0; k != 2; ++k) {
BOOST_TEST(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; boost::array<index,3> elmts;
elmts[0]=i; elmts[1]=j; elmts[2]=k; elmts[0]=i; elmts[1]=j; elmts[2]=k;
BOOST_TEST(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 // Degenerate dimensions
{ {
@ -102,10 +102,10 @@ void test_views(Array& A, const ViewTraits&) {
for (index i = 0; i != 2; ++i) for (index i = 0; i != 2; ++i)
for (index j = 0; j != 2; ++j) { for (index j = 0; j != 2; ++j) {
BOOST_TEST(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; boost::array<index,2> elmts;
elmts[0]=i; elmts[1]=j; elmts[0]=i; elmts[1]=j;
BOOST_TEST(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]); BOOST_TEST(B(elmts) == A[idx0+i][idx1+1][idx2+j*2]);
} }
} }
++tests_run; ++tests_run;

View File

@ -23,7 +23,7 @@ test_main(int,char**)
16,17,18,19, 16,17,18,19,
20,21,22,23 20,21,22,23
}; };
int data_col[] = { int data_col[] = {
0,12, 0,12,
4,16, 4,16,
@ -56,7 +56,7 @@ test_main(int,char**)
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++); BOOST_TEST(A[i][j][k] == *num++);
} }
// Mimic fortran_storage_order using // Mimic fortran_storage_order using
@ -77,7 +77,7 @@ test_main(int,char**)
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++); BOOST_TEST(A[i][j][k] == *num++);
} }
// general_storage_order with arbitrary storage order // general_storage_order with arbitrary storage order
@ -107,8 +107,8 @@ test_main(int,char**)
int* num = data_row; int* num = data_row;
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++); BOOST_TEST(A[i][j][k] == *num++);
} }
@ -140,8 +140,8 @@ test_main(int,char**)
int* num = data_row; int* num = data_row;
for (array::index i = 0; i != 2; ++i) for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 3; ++j) for (array::index j = 0; j != 3; ++j)
for (array::index k = 0; k != 4; ++k) for (array::index k = 0; k != 4; ++k)
BOOST_TEST(A[i][j][k] == *num++); BOOST_TEST(A[i][j][k] == *num++);
} }
return boost::exit_success; return boost::exit_success;

View File

@ -16,13 +16,13 @@ test_main(int,char**) {
array<std::size_t,5> fortran_ordering = {{0,1,2,3,4}}; array<std::size_t,5> fortran_ordering = {{0,1,2,3,4}};
array<bool,5> ascending = {{true,true,true,true,true}}; array<bool,5> ascending = {{true,true,true,true,true}};
general_storage_order<5> c_storage(c_ordering.begin(), general_storage_order<5> c_storage(c_ordering.begin(),
ascending.begin()); ascending.begin());
general_storage_order<5> fortran_storage(fortran_ordering.begin(), general_storage_order<5> fortran_storage(fortran_ordering.begin(),
ascending.begin()); ascending.begin());
BOOST_TEST(c_storage == (general_storage_order<5>) c_storage_order()); BOOST_TEST(c_storage == (general_storage_order<5>) c_storage_order());
BOOST_TEST(fortran_storage == BOOST_TEST(fortran_storage ==
(general_storage_order<5>) fortran_storage_order()); (general_storage_order<5>) fortran_storage_order());
return boost::exit_success; return boost::exit_success;
} }