Update contrib.
1 // Copyright 2002 The Trustees of Indiana University.
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
11 // See http://www.boost.org/libs/multi_array for documentation.
14 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
18 #include "boost/multi_array.hpp"
20 #include "boost/test/minimal.hpp"
26 #include "std_log_result.h"
27 #define LOG_FILENAME_LINE __FILE__, __LINE__
32 test_main(int, char*[])
34 typedef boost::multi_array<double, 3> array;
35 typedef array::size_type size_type;
36 boost::array<size_type,3> sizes = { { 3, 3, 3 } };
37 const size_type num_elements = 27;
42 std::vector<double> vals(num_elements, 4.5);
43 A.assign(vals.begin(),vals.end());
47 BOOST_CHECK(A[0] == B[0]);
49 // Assignment Operator
51 array A(sizes), B(sizes);
52 std::vector<double> vals(num_elements, 4.5);
53 A.assign(vals.begin(),vals.end());
57 BOOST_CHECK(B[0] == A[0]);
59 typedef array::index_range range;
60 array::index_gen indices;
61 array::array_view<2>::type C = A[indices[2][range()][range()]];
62 array::array_view<2>::type D = B[indices[2][range()][range()]];
67 array A(sizes), B(sizes);
68 std::vector<double> valsA(num_elements, 4.5);
69 std::vector<double> valsB(num_elements, 2.5);
70 A.assign(valsA.begin(),valsA.end());
71 B.assign(valsB.begin(),valsB.end());
75 BOOST_CHECK(A[0] != B[0]);
77 typedef array::index_range range;
78 array::index_gen indices;
79 array::array_view<2>::type C = A[indices[2][range()][range()]];
80 array::array_view<2>::type D = B[indices[2][range()][range()]];
84 // Comparisons galore!
86 array A(sizes), B(sizes);
116 A.assign(valsA,valsA+num_elements);
117 B.assign(valsB,valsB+num_elements);
125 BOOST_CHECK(B[0] == A[0]);
126 BOOST_CHECK(B[2] < A[2]);
133 BOOST_CHECK(!(C < A));
134 BOOST_CHECK(!(C > A));
136 typedef array::index_range range;
137 array::index_gen indices;
138 array::array_view<2>::type D = A[indices[2][range()][range()]];
139 array::array_view<2>::type E = B[indices[2][range()][range()]];
146 if(boost::minimal_test::errors_counter() != 0)
147 assert_failed = true;
148 testResultXml("compare");
153 return boost::exit_success;