[DEV] add v1.66.0

This commit is contained in:
2018-01-12 21:47:58 +01:00
parent 87059bb1af
commit a97e9ae7d4
49032 changed files with 7668950 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
// 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.
#include <cassert>
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"
int main () {
// Create a 3D array that is 3 x 4 x 2
typedef boost::multi_array<double, 3> array;
array A(boost::extents[3][4][2]);
// Assign a value to an element in the array
A[0][0][0] = 3.14;
assert(A[0][0][0] == 3.14);
return boost::exit_success;
}

View File

@@ -0,0 +1,27 @@
// 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.
#include <cassert>
#include "boost/multi_array.hpp"
#include "boost/array.hpp"
#include "boost/cstdlib.hpp"
int main () {
// Create a 3D array that is 3 x 4 x 2
boost::array<int, 3> shape = {{ 3, 4, 2 }};
boost::multi_array<double, 3> A(shape);
// Assign a value to an element in the array
A[0][0][0] = 3.14;
assert(A[0][0][0] == 3.14);
return boost::exit_success;
}

View File

@@ -0,0 +1,52 @@
// 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.
#ifndef FOR_EACH_HPP
#define FOR_EACH_HPP
//
// for_each.hpp - Writing an algorithm to transform each element of
// a multi_array
//
#include "boost/type.hpp"
template <typename Array, typename Element, typename Functor>
void for_each (const boost::type<Element>& type_dispatch,
Array A, Functor& xform) {
for_each(type_dispatch,A.begin(),A.end(),xform);
}
template <typename Element, typename Functor>
void for_each (const boost::type<Element>&,Element& Val, Functor& xform) {
Val = xform(Val);
}
template <typename Element, typename Iterator, typename Functor>
void for_each (const boost::type<Element>& type_dispatch,
Iterator begin, Iterator end,
Functor& xform) {
while (begin != end) {
for_each(type_dispatch,*begin,xform);
++begin;
}
}
template <typename Array, typename Functor>
void for_each (Array& A, Functor xform) {
// Dispatch to the proper function
for_each(boost::type<typename Array::element>(),A.begin(),A.end(),xform);
}
#endif // FOR_EACH_HPP

View File

@@ -0,0 +1,54 @@
// 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.
// foreach_test.cpp
// Let's see if this stuff works
#include "boost/multi_array.hpp"
#include "for_each.hpp"
#include <algorithm>
struct times_five {
double operator()(const int& val) { return val*5.0; }
};
int main() {
typedef boost::multi_array<double,2> array;
double data[] = {
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
};
const int data_size=9;
array A(boost::extents[3][3]);
A.assign(data,data+data_size);
#if 0
std::copy(A.data(),A.data()+A.num_elements(),
std::ostream_iterator<double>(std::cout,","));
std::cout << "\n";
#endif
for_each(A,times_five());
#if 0
std::copy(A.data(),A.data()+A.num_elements(),
std::ostream_iterator<double>(std::cout,","));
std::cout << "\n";
#endif
return 0;
}

View File

@@ -0,0 +1,52 @@
// 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.
#include "boost/multi_array.hpp"
#include "for_each.hpp"
#include <algorithm>
struct times_five {
double operator()(const int& val) { return val*5.0; }
};
int main() {
typedef boost::multi_array<double,1> array;
double data[] = {
1.0, 2.0, 3.0,
4.0, 5.0, 6.0,
7.0, 8.0, 9.0
};
const int data_size=9;
array A(boost::extents[9]);
A.assign(data,data+data_size);
#if 0
std::copy(A.begin(),A.end(),
std::ostream_iterator<double>(std::cout,","));
std::cout << "\n";
#endif
for_each(A,times_five());
#if 0
std::copy(A.begin(),A.end(),
std::ostream_iterator<double>(std::cout,","));
std::cout << "\n";
#endif
return 0;
}

View File

@@ -0,0 +1,29 @@
// 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.
#include <cassert>
#include "boost/multi_array.hpp"
#include "boost/array.hpp"
#include "boost/cstdlib.hpp"
int main () {
// Create a 3D array that is 3 x 4 x 2
boost::array<int, 3> shape = {{ 3, 4, 2 }};
boost::multi_array<double, 3> A(shape);
typedef boost::multi_array<double, 3>::index index;
// Assign a value to an element in the array
boost::array<index, 3> idx = {{ 0, 0, 0 }};
A(idx) = 3.14;
assert(A(idx) == 3.14);
return boost::exit_success;
}

View File

@@ -0,0 +1,50 @@
// 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.
#include <iostream>
#include "boost/multi_array.hpp"
#include "boost/array.hpp"
#include "boost/cstdlib.hpp"
template <typename Array>
void print(std::ostream& os, const Array& A)
{
typename Array::const_iterator i;
os << "[";
for (i = A.begin(); i != A.end(); ++i) {
print(os, *i);
if (boost::next(i) != A.end())
os << ',';
}
os << "]";
}
void print(std::ostream& os, const double& x)
{
os << x;
}
int main()
{
typedef boost::multi_array<double, 2> array;
double values[] = {
0, 1, 2,
3, 4, 5
};
const int values_size=6;
array A(boost::extents[2][3]);
A.assign(values,values+values_size);
print(std::cout, A);
return boost::exit_success;
}
// The output is:
// [[0,1,2],[3,4,5]]

View File

@@ -0,0 +1,57 @@
// Copyright 2008 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.
//
// resize_from_other.cpp - an experiment in writing a resize function for
// multi_arrays that will use the extents from another to build itself.
//
#include <boost/multi_array.hpp>
#include <boost/static_assert.hpp>
#include <boost/array.hpp>
#include <algorithm>
template <typename T, typename U, std::size_t N>
void
resize_from_MultiArray(boost::multi_array<T,N>& marray, U& other) {
// U must be a model of MultiArray
boost::function_requires<
boost::multi_array_concepts::ConstMultiArrayConcept<U,U::dimensionality> >();
// U better have U::dimensionality == N
BOOST_STATIC_ASSERT(U::dimensionality == N);
boost::array<typename boost::multi_array<T,N>::size_type, N> shape;
std::copy(other.shape(), other.shape()+N, shape.begin());
marray.resize(shape);
}
#include <iostream>
int main () {
boost::multi_array<int,2> A(boost::extents[5][4]), B;
boost::multi_array<int,3> C;
resize_from_MultiArray(B,A);
#if 0
resize_from_MultiArray(C,A); // Compile-time error
#endif
std::cout << B.shape()[0] << ", " << B.shape()[1] << '\n';
}

View File

@@ -0,0 +1,53 @@
// 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.
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"
int
main()
{
const int ndims=3;
typedef boost::multi_array<int,ndims> array;
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
};
const int data_size=24;
array myarray(boost::extents[2][3][4]);
myarray.assign(data,data+data_size);
//
// array_view dims:
// [base,stride,bound)
// [0,1,2), [1,1,3), [0,2,4)
//
typedef array::index_range range;
array::array_view<ndims>::type myview =
myarray[boost::indices[range(0,2)][range(1,3)][range(0,4,2)]];
for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 2; ++j)
for (array::index k = 0; k != 2; ++k)
assert(myview[i][j][k] == myarray[i][j+1][k*2]);
return boost::exit_success;
}

View File

@@ -0,0 +1,54 @@
// 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.
#include "boost/multi_array.hpp"
#include "boost/cstdlib.hpp"
int
main()
{
using boost::extents;
using boost::indices;
typedef boost::multi_array<int,3> array;
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
};
const int data_size=24;
array myarray(extents[2][3][4]);
myarray.assign(data,data+data_size);
//
// array_view dims:
// [base,stride,bound)
// [0,1,2), [1,1,3), [0,2,4)
//
typedef boost::multi_array_types::index_range range;
array::array_view<3>::type myview =
myarray[indices[range(0,2)][range(1,3)][range(0,4,2)]];
for (array::index i = 0; i != 2; ++i)
for (array::index j = 0; j != 2; ++j)
for (array::index k = 0; k != 2; ++k)
assert(myview[i][j][k] == myarray[i][j+1][k*2]);
return boost::exit_success;
}