Upgraded boost
This commit is contained in:
1 parent
10da2cde64
commit
a737c4ecf6
15332 files changed
+3057188
-2380045
No files matched your search
@@ -1,103 +1,103 @@
|
||||
#ifndef BOOST_ALGORITHM_RG071801_HPP
|
||||
#define BOOST_ALGORITHM_RG071801_HPP
|
||||
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1994
|
||||
// Hewlett-Packard Company
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear
|
||||
// in supporting documentation. Hewlett-Packard Company makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1996-1998
|
||||
// Silicon Graphics Computer Systems, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear
|
||||
// in supporting documentation. Silicon Graphics makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
|
||||
// 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/iterator.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
#if 1
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
OutputIter copy_n(InputIter first, Size count,
|
||||
OutputIter result) {
|
||||
for ( ; count > 0; --count) {
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#else // !1
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
OutputIter copy_n__(InputIter first, Size count,
|
||||
OutputIter result,
|
||||
std::input_iterator_tag) {
|
||||
for ( ; count > 0; --count) {
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class RAIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n__(RAIter first, Size count,
|
||||
OutputIter result,
|
||||
std::random_access_iterator_tag) {
|
||||
RAIter last = first + count;
|
||||
return std::copy(first, last, result);
|
||||
}
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n__(InputIter first, Size count, OutputIter result) {
|
||||
typedef typename std::iterator_traits<InputIter>::iterator_category cat;
|
||||
return copy_n__(first, count, result, cat());
|
||||
}
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n(InputIter first, Size count, OutputIter result) {
|
||||
return copy_n__(first, count, result);
|
||||
}
|
||||
|
||||
#endif // 1
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ALGORITHM_RG071801_HPP
|
||||
#ifndef BOOST_MULTI_ARRAY_ALGORITHM_HPP
|
||||
#define BOOST_MULTI_ARRAY_ALGORITHM_HPP
|
||||
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1994
|
||||
// Hewlett-Packard Company
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear
|
||||
// in supporting documentation. Hewlett-Packard Company makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 1996-1998
|
||||
// Silicon Graphics Computer Systems, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, distribute and sell this software
|
||||
// and its documentation for any purpose is hereby granted without fee,
|
||||
// provided that the above copyright notice appear in all copies and
|
||||
// that both that copyright notice and this permission notice appear
|
||||
// in supporting documentation. Silicon Graphics makes no
|
||||
// representations about the suitability of this software for any
|
||||
// purpose. It is provided "as is" without express or implied warranty.
|
||||
//
|
||||
|
||||
// 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 <iterator>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
//--------------------------------------------------
|
||||
// copy_n (not part of the C++ standard)
|
||||
#if 1
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
OutputIter copy_n(InputIter first, Size count,
|
||||
OutputIter result) {
|
||||
for ( ; count > 0; --count) {
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#else // !1
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
OutputIter copy_n__(InputIter first, Size count,
|
||||
OutputIter result,
|
||||
std::input_iterator_tag) {
|
||||
for ( ; count > 0; --count) {
|
||||
*result = *first;
|
||||
++first;
|
||||
++result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class RAIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n__(RAIter first, Size count,
|
||||
OutputIter result,
|
||||
std::random_access_iterator_tag) {
|
||||
RAIter last = first + count;
|
||||
return std::copy(first, last, result);
|
||||
}
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n__(InputIter first, Size count, OutputIter result) {
|
||||
typedef typename std::iterator_traits<InputIter>::iterator_category cat;
|
||||
return copy_n__(first, count, result, cat());
|
||||
}
|
||||
|
||||
template <class InputIter, class Size, class OutputIter>
|
||||
inline OutputIter
|
||||
copy_n(InputIter first, Size count, OutputIter result) {
|
||||
return copy_n__(first, count, result);
|
||||
}
|
||||
|
||||
#endif // 1
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,26 +1,26 @@
|
||||
// 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 COLLECTION_CONCEPT_RG103101_HPP
|
||||
#define COLLECTION_CONCEPT_RG103101_HPP
|
||||
|
||||
#include "boost/concept_check.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array { // Old location for this
|
||||
using boost::CollectionConcept;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif // COLLECTION_CONCEPT_RG103101_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_COLLECTION_CONCEPT_HPP
|
||||
#define BOOST_MULTI_ARRAY_COLLECTION_CONCEPT_HPP
|
||||
|
||||
#include "boost/concept_check.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array { // Old location for this
|
||||
using boost::CollectionConcept;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,225 +1,221 @@
|
||||
// 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 BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
|
||||
#define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_HPP
|
||||
|
||||
//
|
||||
// concept-checks.hpp - Checks out Const MultiArray and MultiArray
|
||||
// concepts
|
||||
//
|
||||
|
||||
#include "boost/concept_check.hpp"
|
||||
#include "boost/iterator/iterator_concepts.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace multi_array_concepts {
|
||||
|
||||
namespace detail {
|
||||
//
|
||||
// idgen_helper -
|
||||
// This is a helper for generating index_gen instantiations with
|
||||
// the right type in order to test the call to
|
||||
// operator[](index_gen). Since one would normally write:
|
||||
// A[ indices[range1][range2] ]; // or
|
||||
// B[ indices[index1][index2][range1] ];
|
||||
// idgen helper allows us to generate the "indices" type by
|
||||
// creating it through recursive calls.
|
||||
template <std::size_t N>
|
||||
struct idgen_helper {
|
||||
|
||||
template <typename Array, typename IdxGen, typename Call_Type>
|
||||
static void call(Array& a, const IdxGen& idgen, Call_Type c) {
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::index index;
|
||||
idgen_helper<N-1>::call(a,idgen[c],c);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct idgen_helper<0> {
|
||||
|
||||
template <typename Array, typename IdxGen, typename Call_Type>
|
||||
static void call(Array& a, const IdxGen& idgen, Call_Type) {
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::index index;
|
||||
a[ idgen ];
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
template <typename Array, std::size_t NumDims >
|
||||
struct ConstMultiArrayConcept
|
||||
{
|
||||
void constraints() {
|
||||
// function_requires< CopyConstructibleConcept<Array> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
||||
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
a[ id ];
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = Array::dimensionality;
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
cit = a.begin();
|
||||
cit = a.end();
|
||||
crit = a.rbegin();
|
||||
crit = a.rend();
|
||||
eltp = a.origin();
|
||||
}
|
||||
|
||||
typedef typename Array::value_type value_type;
|
||||
typedef typename Array::reference reference;
|
||||
typedef typename Array::const_reference const_reference;
|
||||
typedef typename Array::size_type size_type;
|
||||
typedef typename Array::difference_type difference_type;
|
||||
typedef typename Array::iterator iterator;
|
||||
typedef typename Array::const_iterator const_iterator;
|
||||
typedef typename Array::reverse_iterator reverse_iterator;
|
||||
typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename Array::element element;
|
||||
typedef typename Array::index index;
|
||||
typedef typename Array::index_gen index_gen;
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::extent_gen extent_gen;
|
||||
typedef typename Array::extent_range extent_range;
|
||||
|
||||
Array a;
|
||||
size_type st;
|
||||
const size_type* stp;
|
||||
index id;
|
||||
const index* idp;
|
||||
const_iterator cit;
|
||||
const_reverse_iterator crit;
|
||||
const element* eltp;
|
||||
index_gen idgen;
|
||||
index_range range;
|
||||
};
|
||||
|
||||
|
||||
template <typename Array, std::size_t NumDims >
|
||||
struct MutableMultiArrayConcept
|
||||
{
|
||||
void constraints() {
|
||||
// function_requires< CopyConstructibleConcept<Array> >();
|
||||
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
||||
function_requires< boost::OutputIterator<iterator,value_type> >();
|
||||
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
it = a.begin();
|
||||
it = a.end();
|
||||
rit = a.rbegin();
|
||||
rit = a.rend();
|
||||
eltp = a.origin();
|
||||
const_constraints(a);
|
||||
}
|
||||
|
||||
void const_constraints(const Array& a) {
|
||||
|
||||
// value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
cit = a.begin();
|
||||
cit = a.end();
|
||||
crit = a.rbegin();
|
||||
crit = a.rend();
|
||||
eltp = a.origin();
|
||||
}
|
||||
|
||||
typedef typename Array::value_type value_type;
|
||||
typedef typename Array::reference reference;
|
||||
typedef typename Array::const_reference const_reference;
|
||||
typedef typename Array::size_type size_type;
|
||||
typedef typename Array::difference_type difference_type;
|
||||
typedef typename Array::iterator iterator;
|
||||
typedef typename Array::const_iterator const_iterator;
|
||||
typedef typename Array::reverse_iterator reverse_iterator;
|
||||
typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename Array::element element;
|
||||
typedef typename Array::index index;
|
||||
typedef typename Array::index_gen index_gen;
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::extent_gen extent_gen;
|
||||
typedef typename Array::extent_range extent_range;
|
||||
|
||||
Array a;
|
||||
size_type st;
|
||||
const size_type* stp;
|
||||
index id;
|
||||
const index* idp;
|
||||
iterator it;
|
||||
const_iterator cit;
|
||||
reverse_iterator rit;
|
||||
const_reverse_iterator crit;
|
||||
const element* eltp;
|
||||
index_gen idgen;
|
||||
index_range range;
|
||||
};
|
||||
|
||||
|
||||
} // namespace multi_array
|
||||
|
||||
namespace detail {
|
||||
namespace multi_array { // Old locations for these
|
||||
using boost::multi_array_concepts::ConstMultiArrayConcept;
|
||||
using boost::multi_array_concepts::MutableMultiArrayConcept;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_MULTI_ARRAY_CONCEPT_CHECKS_RG110101_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_CONCEPT_CHECKS_HPP
|
||||
#define BOOST_MULTI_ARRAY_CONCEPT_CHECKS_HPP
|
||||
|
||||
//
|
||||
// concept-checks.hpp - Checks out Const MultiArray and MultiArray
|
||||
// concepts
|
||||
//
|
||||
|
||||
#include "boost/concept_check.hpp"
|
||||
#include "boost/iterator/iterator_concepts.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace multi_array_concepts {
|
||||
|
||||
namespace detail {
|
||||
//
|
||||
// idgen_helper -
|
||||
// This is a helper for generating index_gen instantiations with
|
||||
// the right type in order to test the call to
|
||||
// operator[](index_gen). Since one would normally write:
|
||||
// A[ indices[range1][range2] ]; // or
|
||||
// B[ indices[index1][index2][range1] ];
|
||||
// idgen helper allows us to generate the "indices" type by
|
||||
// creating it through recursive calls.
|
||||
template <std::size_t N>
|
||||
struct idgen_helper {
|
||||
|
||||
template <typename Array, typename IdxGen, typename Call_Type>
|
||||
static void call(Array& a, const IdxGen& idgen, Call_Type c) {
|
||||
idgen_helper<N-1>::call(a,idgen[c],c);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct idgen_helper<0> {
|
||||
|
||||
template <typename Array, typename IdxGen, typename Call_Type>
|
||||
static void call(Array& a, const IdxGen& idgen, Call_Type) {
|
||||
a[ idgen ];
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
template <typename Array, std::size_t NumDims >
|
||||
struct ConstMultiArrayConcept
|
||||
{
|
||||
void constraints() {
|
||||
// function_requires< CopyConstructibleConcept<Array> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
||||
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
a[ id ];
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = Array::dimensionality;
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
cit = a.begin();
|
||||
cit = a.end();
|
||||
crit = a.rbegin();
|
||||
crit = a.rend();
|
||||
eltp = a.origin();
|
||||
}
|
||||
|
||||
typedef typename Array::value_type value_type;
|
||||
typedef typename Array::reference reference;
|
||||
typedef typename Array::const_reference const_reference;
|
||||
typedef typename Array::size_type size_type;
|
||||
typedef typename Array::difference_type difference_type;
|
||||
typedef typename Array::iterator iterator;
|
||||
typedef typename Array::const_iterator const_iterator;
|
||||
typedef typename Array::reverse_iterator reverse_iterator;
|
||||
typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename Array::element element;
|
||||
typedef typename Array::index index;
|
||||
typedef typename Array::index_gen index_gen;
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::extent_gen extent_gen;
|
||||
typedef typename Array::extent_range extent_range;
|
||||
|
||||
Array a;
|
||||
size_type st;
|
||||
const size_type* stp;
|
||||
index id;
|
||||
const index* idp;
|
||||
const_iterator cit;
|
||||
const_reverse_iterator crit;
|
||||
const element* eltp;
|
||||
index_gen idgen;
|
||||
index_range range;
|
||||
};
|
||||
|
||||
|
||||
template <typename Array, std::size_t NumDims >
|
||||
struct MutableMultiArrayConcept
|
||||
{
|
||||
void constraints() {
|
||||
// function_requires< CopyConstructibleConcept<Array> >();
|
||||
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::WritableIteratorConcept<iterator> >();
|
||||
function_requires< boost_concepts::ForwardTraversalConcept<const_iterator> >();
|
||||
function_requires< boost_concepts::ReadableIteratorConcept<const_iterator> >();
|
||||
function_requires< boost::OutputIterator<iterator,value_type> >();
|
||||
|
||||
// RG - a( CollectionArchetype) when available...
|
||||
value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
it = a.begin();
|
||||
it = a.end();
|
||||
rit = a.rbegin();
|
||||
rit = a.rend();
|
||||
eltp = a.origin();
|
||||
const_constraints(a);
|
||||
}
|
||||
|
||||
void const_constraints(const Array& a) {
|
||||
|
||||
// value_type vt = a[ id ];
|
||||
|
||||
// Test slicing, keeping only the first dimension, losing the rest
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],id);
|
||||
|
||||
// Test slicing, keeping all dimensions.
|
||||
detail::idgen_helper<NumDims-1>::call(a,idgen[range],range);
|
||||
|
||||
st = a.size();
|
||||
st = a.num_dimensions();
|
||||
st = a.num_elements();
|
||||
stp = a.shape();
|
||||
idp = a.strides();
|
||||
idp = a.index_bases();
|
||||
cit = a.begin();
|
||||
cit = a.end();
|
||||
crit = a.rbegin();
|
||||
crit = a.rend();
|
||||
eltp = a.origin();
|
||||
}
|
||||
|
||||
typedef typename Array::value_type value_type;
|
||||
typedef typename Array::reference reference;
|
||||
typedef typename Array::const_reference const_reference;
|
||||
typedef typename Array::size_type size_type;
|
||||
typedef typename Array::difference_type difference_type;
|
||||
typedef typename Array::iterator iterator;
|
||||
typedef typename Array::const_iterator const_iterator;
|
||||
typedef typename Array::reverse_iterator reverse_iterator;
|
||||
typedef typename Array::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename Array::element element;
|
||||
typedef typename Array::index index;
|
||||
typedef typename Array::index_gen index_gen;
|
||||
typedef typename Array::index_range index_range;
|
||||
typedef typename Array::extent_gen extent_gen;
|
||||
typedef typename Array::extent_range extent_range;
|
||||
|
||||
Array a;
|
||||
size_type st;
|
||||
const size_type* stp;
|
||||
index id;
|
||||
const index* idp;
|
||||
iterator it;
|
||||
const_iterator cit;
|
||||
reverse_iterator rit;
|
||||
const_reverse_iterator crit;
|
||||
const element* eltp;
|
||||
index_gen idgen;
|
||||
index_range range;
|
||||
};
|
||||
|
||||
|
||||
} // namespace multi_array
|
||||
|
||||
namespace detail {
|
||||
namespace multi_array { // Old locations for these
|
||||
using boost::multi_array_concepts::ConstMultiArrayConcept;
|
||||
using boost::multi_array_concepts::MutableMultiArrayConcept;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,68 +1,68 @@
|
||||
// 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 COPY_ARRAY_RG092101_HPP
|
||||
#define COPY_ARRAY_RG092101_HPP
|
||||
|
||||
//
|
||||
// copy_array.hpp - generic code for copying the contents of one
|
||||
// Basic_MultiArray to another. We assume that they are of the same
|
||||
// shape
|
||||
//
|
||||
#include "boost/type.hpp"
|
||||
#include "boost/assert.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Element>
|
||||
class copy_dispatch {
|
||||
public:
|
||||
template <typename SourceIterator, typename DestIterator>
|
||||
static void copy_array (SourceIterator first, SourceIterator last,
|
||||
DestIterator result) {
|
||||
while (first != last) {
|
||||
copy_array(*first++,*result++);
|
||||
}
|
||||
}
|
||||
private:
|
||||
// Array2 has to be passed by VALUE here because subarray
|
||||
// pseudo-references are temporaries created by iterator::operator*()
|
||||
template <typename Array1, typename Array2>
|
||||
static void copy_array (const Array1& source, Array2 dest) {
|
||||
copy_array(source.begin(),source.end(),dest.begin());
|
||||
}
|
||||
|
||||
static void copy_array (const Element& source, Element& dest) {
|
||||
dest = source;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <typename Array1, typename Array2>
|
||||
void copy_array (Array1& source, Array2& dest) {
|
||||
BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
|
||||
dest.shape()));
|
||||
// Dispatch to the proper function
|
||||
typedef typename Array1::element element_type;
|
||||
copy_dispatch<element_type>::
|
||||
copy_array(source.begin(),source.end(),dest.begin());
|
||||
}
|
||||
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // COPY_ARRAY_RG092101_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_COPY_ARRAY_HPP
|
||||
#define BOOST_MULTI_ARRAY_COPY_ARRAY_HPP
|
||||
|
||||
//
|
||||
// copy_array.hpp - generic code for copying the contents of one
|
||||
// Basic_MultiArray to another. We assume that they are of the same
|
||||
// shape
|
||||
//
|
||||
#include "boost/type.hpp"
|
||||
#include "boost/assert.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Element>
|
||||
class copy_dispatch {
|
||||
public:
|
||||
template <typename SourceIterator, typename DestIterator>
|
||||
static void copy_array (SourceIterator first, SourceIterator last,
|
||||
DestIterator result) {
|
||||
while (first != last) {
|
||||
copy_array(*first++,*result++);
|
||||
}
|
||||
}
|
||||
private:
|
||||
// Array2 has to be passed by VALUE here because subarray
|
||||
// pseudo-references are temporaries created by iterator::operator*()
|
||||
template <typename Array1, typename Array2>
|
||||
static void copy_array (const Array1& source, Array2 dest) {
|
||||
copy_array(source.begin(),source.end(),dest.begin());
|
||||
}
|
||||
|
||||
static void copy_array (const Element& source, Element& dest) {
|
||||
dest = source;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <typename Array1, typename Array2>
|
||||
void copy_array (Array1& source, Array2& dest) {
|
||||
BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
|
||||
dest.shape()));
|
||||
// Dispatch to the proper function
|
||||
typedef typename Array1::element element_type;
|
||||
copy_dispatch<element_type>::
|
||||
copy_array(source.begin(),source.end(),dest.begin());
|
||||
}
|
||||
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -1,75 +1,75 @@
|
||||
// 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 BOOST_EXTENT_GEN_RG071801_HPP
|
||||
#define BOOST_EXTENT_GEN_RG071801_HPP
|
||||
|
||||
#include "boost/multi_array/extent_range.hpp"
|
||||
#include "boost/multi_array/range_list.hpp"
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
|
||||
template <std::size_t NumRanges>
|
||||
class extent_gen {
|
||||
public:
|
||||
typedef boost::detail::multi_array::index index;
|
||||
typedef boost::detail::multi_array::size_type size_type;
|
||||
typedef extent_range<index,size_type> range;
|
||||
private:
|
||||
typedef typename range_list_generator<range,NumRanges>::type range_list;
|
||||
public:
|
||||
template <std::size_t Ranges>
|
||||
struct gen_type {
|
||||
typedef extent_gen<Ranges> type;
|
||||
};
|
||||
|
||||
range_list ranges_;
|
||||
|
||||
extent_gen() { }
|
||||
|
||||
// Used by operator[] to expand extent_gens
|
||||
extent_gen(const extent_gen<NumRanges-1>& rhs,
|
||||
const range& a_range)
|
||||
{
|
||||
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
|
||||
*ranges_.rbegin() = a_range;
|
||||
}
|
||||
|
||||
extent_gen<NumRanges+1>
|
||||
operator[](const range& a_range)
|
||||
{
|
||||
return extent_gen<NumRanges+1>(*this,a_range);
|
||||
}
|
||||
|
||||
extent_gen<NumRanges+1>
|
||||
operator[](index idx)
|
||||
{
|
||||
return extent_gen<NumRanges+1>(*this,range(0,idx));
|
||||
}
|
||||
|
||||
static extent_gen<0> extents() {
|
||||
return extent_gen<0>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_EXTENT_GEN_RG071801_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_EXTENT_GEN_HPP
|
||||
#define BOOST_MULTI_ARRAY_EXTENT_GEN_HPP
|
||||
|
||||
#include "boost/multi_array/extent_range.hpp"
|
||||
#include "boost/multi_array/range_list.hpp"
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
|
||||
template <std::size_t NumRanges>
|
||||
class extent_gen {
|
||||
public:
|
||||
typedef boost::detail::multi_array::index index;
|
||||
typedef boost::detail::multi_array::size_type size_type;
|
||||
typedef extent_range<index,size_type> range;
|
||||
private:
|
||||
typedef typename range_list_generator<range,NumRanges>::type range_list;
|
||||
public:
|
||||
template <std::size_t Ranges>
|
||||
struct gen_type {
|
||||
typedef extent_gen<Ranges> type;
|
||||
};
|
||||
|
||||
range_list ranges_;
|
||||
|
||||
extent_gen() { }
|
||||
|
||||
// Used by operator[] to expand extent_gens
|
||||
extent_gen(const extent_gen<NumRanges-1>& rhs,
|
||||
const range& a_range)
|
||||
{
|
||||
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
|
||||
*ranges_.rbegin() = a_range;
|
||||
}
|
||||
|
||||
extent_gen<NumRanges+1>
|
||||
operator[](const range& a_range)
|
||||
{
|
||||
return extent_gen<NumRanges+1>(*this,a_range);
|
||||
}
|
||||
|
||||
extent_gen<NumRanges+1>
|
||||
operator[](index idx)
|
||||
{
|
||||
return extent_gen<NumRanges+1>(*this,range(0,idx));
|
||||
}
|
||||
|
||||
static extent_gen<0> extents() {
|
||||
return extent_gen<0>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,49 +1,49 @@
|
||||
// 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 BOOST_EXTENT_RANGE_RG071801_HPP
|
||||
#define BOOST_EXTENT_RANGE_RG071801_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Extent, typename SizeType>
|
||||
class extent_range : private std::pair<Extent,Extent> {
|
||||
typedef std::pair<Extent,Extent> super_type;
|
||||
public:
|
||||
typedef Extent index;
|
||||
typedef SizeType size_type;
|
||||
|
||||
extent_range(index start, index finish) :
|
||||
super_type(start,finish) { }
|
||||
|
||||
extent_range(index finish) :
|
||||
super_type(0,finish) { }
|
||||
|
||||
extent_range() : super_type(0,0) { }
|
||||
|
||||
index start() const { return super_type::first; }
|
||||
|
||||
index finish() const { return super_type::second; }
|
||||
|
||||
size_type size() const { return super_type::second - super_type::first; }
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_EXTENT_RANGE_RG071801_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_EXTENT_RANGE_HPP
|
||||
#define BOOST_MULTI_ARRAY_EXTENT_RANGE_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Extent, typename SizeType>
|
||||
class extent_range : private std::pair<Extent,Extent> {
|
||||
typedef std::pair<Extent,Extent> super_type;
|
||||
public:
|
||||
typedef Extent index;
|
||||
typedef SizeType size_type;
|
||||
|
||||
extent_range(index start, index finish) :
|
||||
super_type(start,finish) { }
|
||||
|
||||
extent_range(index finish) :
|
||||
super_type(0,finish) { }
|
||||
|
||||
extent_range() : super_type(0,0) { }
|
||||
|
||||
index start() const { return super_type::first; }
|
||||
|
||||
index finish() const { return super_type::second; }
|
||||
|
||||
size_type size() const { return super_type::second - super_type::first; }
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,81 +1,81 @@
|
||||
// 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 BOOST_INDEX_GEN_RG071801_HPP
|
||||
#define BOOST_INDEX_GEN_RG071801_HPP
|
||||
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/multi_array/index_range.hpp"
|
||||
#include "boost/multi_array/range_list.hpp"
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
|
||||
template <int NumRanges, int NumDims>
|
||||
struct index_gen {
|
||||
private:
|
||||
typedef ::boost::detail::multi_array::index index;
|
||||
typedef ::boost::detail::multi_array::size_type size_type;
|
||||
typedef index_range<index,size_type> range;
|
||||
public:
|
||||
template <int Dims, int Ranges>
|
||||
struct gen_type {
|
||||
typedef index_gen<Ranges,Dims> type;
|
||||
};
|
||||
|
||||
typedef typename range_list_generator<range,NumRanges>::type range_list;
|
||||
range_list ranges_;
|
||||
|
||||
index_gen() { }
|
||||
|
||||
template <int ND>
|
||||
explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
|
||||
const range& r)
|
||||
{
|
||||
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
|
||||
*ranges_.rbegin() = r;
|
||||
}
|
||||
|
||||
index_gen<NumRanges+1,NumDims+1>
|
||||
operator[](const range& r) const
|
||||
{
|
||||
index_gen<NumRanges+1,NumDims+1> tmp;
|
||||
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
|
||||
*tmp.ranges_.rbegin() = r;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
index_gen<NumRanges+1,NumDims>
|
||||
operator[](index idx) const
|
||||
{
|
||||
index_gen<NumRanges+1,NumDims> tmp;
|
||||
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
|
||||
*tmp.ranges_.rbegin() = range(idx);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static index_gen<0,0> indices() {
|
||||
return index_gen<0,0>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif // BOOST_INDEX_GEN_RG071801_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_INDEX_GEN_HPP
|
||||
#define BOOST_MULTI_ARRAY_INDEX_GEN_HPP
|
||||
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/multi_array/index_range.hpp"
|
||||
#include "boost/multi_array/range_list.hpp"
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
|
||||
template <int NumRanges, int NumDims>
|
||||
struct index_gen {
|
||||
private:
|
||||
typedef ::boost::detail::multi_array::index index;
|
||||
typedef ::boost::detail::multi_array::size_type size_type;
|
||||
typedef index_range<index,size_type> range;
|
||||
public:
|
||||
template <int Dims, int Ranges>
|
||||
struct gen_type {
|
||||
typedef index_gen<Ranges,Dims> type;
|
||||
};
|
||||
|
||||
typedef typename range_list_generator<range,NumRanges>::type range_list;
|
||||
range_list ranges_;
|
||||
|
||||
index_gen() { }
|
||||
|
||||
template <int ND>
|
||||
explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
|
||||
const range& r)
|
||||
{
|
||||
std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
|
||||
*ranges_.rbegin() = r;
|
||||
}
|
||||
|
||||
index_gen<NumRanges+1,NumDims+1>
|
||||
operator[](const range& r) const
|
||||
{
|
||||
index_gen<NumRanges+1,NumDims+1> tmp;
|
||||
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
|
||||
*tmp.ranges_.rbegin() = r;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
index_gen<NumRanges+1,NumDims>
|
||||
operator[](index idx) const
|
||||
{
|
||||
index_gen<NumRanges+1,NumDims> tmp;
|
||||
std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
|
||||
*tmp.ranges_.rbegin() = range(idx);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static index_gen<0,0> indices() {
|
||||
return index_gen<0,0>();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,188 +1,194 @@
|
||||
// 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 BOOST_INDEX_RANGE_RG071801_HPP
|
||||
#define BOOST_INDEX_RANGE_RG071801_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <utility>
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
// For representing intervals, also with stride.
|
||||
// A degenerate range is a range with one element.
|
||||
|
||||
// Thanks to Doug Gregor for the really cool idea of using the
|
||||
// comparison operators to express various interval types!
|
||||
|
||||
// Internally, we represent the interval as half-open.
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Index,typename SizeType>
|
||||
class index_range {
|
||||
public:
|
||||
typedef Index index;
|
||||
typedef SizeType size_type;
|
||||
|
||||
private:
|
||||
static index from_start()
|
||||
{ return (std::numeric_limits<index>::min)(); }
|
||||
|
||||
static index to_end()
|
||||
{ return (std::numeric_limits<index>::max)(); }
|
||||
|
||||
public:
|
||||
|
||||
index_range()
|
||||
{
|
||||
start_ = from_start();
|
||||
finish_ = to_end();
|
||||
stride_ = 1;
|
||||
degenerate_ = false;
|
||||
}
|
||||
|
||||
explicit index_range(index pos)
|
||||
{
|
||||
start_ = pos;
|
||||
finish_ = pos+1;
|
||||
stride_ = 1;
|
||||
degenerate_ = true;
|
||||
}
|
||||
|
||||
explicit index_range(index start, index finish, index stride=1)
|
||||
: start_(start), finish_(finish), stride_(stride),
|
||||
degenerate_(false)
|
||||
{ }
|
||||
|
||||
|
||||
// These are for chaining assignments to an index_range
|
||||
index_range& start(index s) {
|
||||
start_ = s;
|
||||
degenerate_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
index_range& finish(index f) {
|
||||
finish_ = f;
|
||||
degenerate_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
index_range& stride(index s) { stride_ = s; return *this; }
|
||||
|
||||
index start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
index get_start(index low_index_range = index_range::from_start()) const
|
||||
{
|
||||
if (start_ == from_start())
|
||||
return low_index_range;
|
||||
return start_;
|
||||
}
|
||||
|
||||
index finish() const
|
||||
{
|
||||
return finish_;
|
||||
}
|
||||
|
||||
index get_finish(index high_index_range = index_range::to_end()) const
|
||||
{
|
||||
if (finish_ == to_end())
|
||||
return high_index_range;
|
||||
return finish_;
|
||||
}
|
||||
|
||||
index stride() const { return stride_; }
|
||||
|
||||
void set_index_range(index start, index finish, index stride=1)
|
||||
{
|
||||
start_ = start;
|
||||
finish_ = finish;
|
||||
stride_ = stride;
|
||||
}
|
||||
|
||||
static index_range all()
|
||||
{ return index_range(from_start(), to_end(), 1); }
|
||||
|
||||
bool is_degenerate() const { return degenerate_; }
|
||||
|
||||
index_range operator-(index shift) const
|
||||
{
|
||||
return index_range(start_ - shift, finish_ - shift, stride_);
|
||||
}
|
||||
|
||||
index_range operator+(index shift) const
|
||||
{
|
||||
return index_range(start_ + shift, finish_ + shift, stride_);
|
||||
}
|
||||
|
||||
index operator[](unsigned i) const
|
||||
{
|
||||
return start_ + i * stride_;
|
||||
}
|
||||
|
||||
index operator()(unsigned i) const
|
||||
{
|
||||
return start_ + i * stride_;
|
||||
}
|
||||
|
||||
// add conversion to std::slice?
|
||||
|
||||
public:
|
||||
index start_, finish_, stride_;
|
||||
bool degenerate_;
|
||||
};
|
||||
|
||||
// Express open and closed interval end-points using the comparison
|
||||
// operators.
|
||||
|
||||
// left closed
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<=(Index s, const index_range<Index,SizeType>& r)
|
||||
{
|
||||
return index_range<Index,SizeType>(s, r.finish(), r.stride());
|
||||
}
|
||||
|
||||
// left open
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<(Index s, const index_range<Index,SizeType>& r)
|
||||
{
|
||||
return index_range<Index,SizeType>(s + 1, r.finish(), r.stride());
|
||||
}
|
||||
|
||||
// right open
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<(const index_range<Index,SizeType>& r, Index f)
|
||||
{
|
||||
return index_range<Index,SizeType>(r.start(), f, r.stride());
|
||||
}
|
||||
|
||||
// right closed
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<=(const index_range<Index,SizeType>& r, Index f)
|
||||
{
|
||||
return index_range<Index,SizeType>(r.start(), f + 1, r.stride());
|
||||
}
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_INDEX_RANGE_RG071801_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_INDEX_RANGE_HPP
|
||||
#define BOOST_MULTI_ARRAY_INDEX_RANGE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <utility>
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
// For representing intervals, also with stride.
|
||||
// A degenerate range is a range with one element.
|
||||
|
||||
// Thanks to Doug Gregor for the really cool idea of using the
|
||||
// comparison operators to express various interval types!
|
||||
|
||||
// Internally, we represent the interval as half-open.
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
template <typename Index,typename SizeType>
|
||||
class index_range {
|
||||
public:
|
||||
typedef Index index;
|
||||
typedef SizeType size_type;
|
||||
|
||||
private:
|
||||
static index from_start()
|
||||
{ return (std::numeric_limits<index>::min)(); }
|
||||
|
||||
static index to_end()
|
||||
{ return (std::numeric_limits<index>::max)(); }
|
||||
|
||||
public:
|
||||
|
||||
index_range()
|
||||
{
|
||||
start_ = from_start();
|
||||
finish_ = to_end();
|
||||
stride_ = 1;
|
||||
degenerate_ = false;
|
||||
}
|
||||
|
||||
explicit index_range(index pos)
|
||||
{
|
||||
start_ = pos;
|
||||
finish_ = pos+1;
|
||||
stride_ = 1;
|
||||
degenerate_ = true;
|
||||
}
|
||||
|
||||
explicit index_range(index start, index finish, index stride=1)
|
||||
: start_(start), finish_(finish), stride_(stride),
|
||||
degenerate_(false)
|
||||
{ }
|
||||
|
||||
|
||||
// These are for chaining assignments to an index_range
|
||||
index_range& start(index s) {
|
||||
start_ = s;
|
||||
degenerate_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
index_range& finish(index f) {
|
||||
finish_ = f;
|
||||
degenerate_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
index_range& stride(index s) { stride_ = s; return *this; }
|
||||
|
||||
index start() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
index get_start(index low_index_range = index_range::from_start()) const
|
||||
{
|
||||
if (start_ == from_start())
|
||||
return low_index_range;
|
||||
return start_;
|
||||
}
|
||||
|
||||
index finish() const
|
||||
{
|
||||
return finish_;
|
||||
}
|
||||
|
||||
index get_finish(index high_index_range = index_range::to_end()) const
|
||||
{
|
||||
if (finish_ == to_end())
|
||||
return high_index_range;
|
||||
return finish_;
|
||||
}
|
||||
|
||||
index stride() const { return stride_; }
|
||||
|
||||
size_type size(index idx) const
|
||||
{
|
||||
return (start_ == from_start() || finish_ == to_end())
|
||||
? idx : ((finish_ - start_) / stride_);
|
||||
}
|
||||
|
||||
void set_index_range(index start, index finish, index stride=1)
|
||||
{
|
||||
start_ = start;
|
||||
finish_ = finish;
|
||||
stride_ = stride;
|
||||
}
|
||||
|
||||
static index_range all()
|
||||
{ return index_range(from_start(), to_end(), 1); }
|
||||
|
||||
bool is_degenerate() const { return degenerate_; }
|
||||
|
||||
index_range operator-(index shift) const
|
||||
{
|
||||
return index_range(start_ - shift, finish_ - shift, stride_);
|
||||
}
|
||||
|
||||
index_range operator+(index shift) const
|
||||
{
|
||||
return index_range(start_ + shift, finish_ + shift, stride_);
|
||||
}
|
||||
|
||||
index operator[](unsigned i) const
|
||||
{
|
||||
return start_ + i * stride_;
|
||||
}
|
||||
|
||||
index operator()(unsigned i) const
|
||||
{
|
||||
return start_ + i * stride_;
|
||||
}
|
||||
|
||||
// add conversion to std::slice?
|
||||
|
||||
public:
|
||||
index start_, finish_, stride_;
|
||||
bool degenerate_;
|
||||
};
|
||||
|
||||
// Express open and closed interval end-points using the comparison
|
||||
// operators.
|
||||
|
||||
// left closed
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<=(Index s, const index_range<Index,SizeType>& r)
|
||||
{
|
||||
return index_range<Index,SizeType>(s, r.finish(), r.stride());
|
||||
}
|
||||
|
||||
// left open
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<(Index s, const index_range<Index,SizeType>& r)
|
||||
{
|
||||
return index_range<Index,SizeType>(s + 1, r.finish(), r.stride());
|
||||
}
|
||||
|
||||
// right open
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<(const index_range<Index,SizeType>& r, Index f)
|
||||
{
|
||||
return index_range<Index,SizeType>(r.start(), f, r.stride());
|
||||
}
|
||||
|
||||
// right closed
|
||||
template <typename Index, typename SizeType>
|
||||
inline index_range<Index,SizeType>
|
||||
operator<=(const index_range<Index,SizeType>& r, Index f)
|
||||
{
|
||||
return index_range<Index,SizeType>(r.start(), f + 1, r.stride());
|
||||
}
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -1,165 +1,165 @@
|
||||
// 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 ITERATOR_RG071801_HPP
|
||||
#define ITERATOR_RG071801_HPP
|
||||
|
||||
//
|
||||
// iterator.hpp - implementation of iterators for the
|
||||
// multi-dimensional array class
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/iterator/iterator_facade.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// iterator components
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class T>
|
||||
struct operator_arrow_proxy
|
||||
{
|
||||
operator_arrow_proxy(T const& px) : value_(px) {}
|
||||
T* operator->() const { return &value_; }
|
||||
// This function is needed for MWCW and BCC, which won't call operator->
|
||||
// again automatically per 13.3.1.2 para 8
|
||||
operator T*() const { return &value_; }
|
||||
mutable T value_;
|
||||
};
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference,
|
||||
typename IteratorCategory>
|
||||
class array_iterator;
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference,
|
||||
typename IteratorCategory>
|
||||
class array_iterator
|
||||
: public
|
||||
iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
|
||||
, typename associated_types<T,NumDims>::value_type
|
||||
, IteratorCategory
|
||||
, Reference
|
||||
>
|
||||
, private
|
||||
value_accessor_generator<T,NumDims>::type
|
||||
{
|
||||
friend class iterator_core_access;
|
||||
typedef detail::multi_array::associated_types<T,NumDims> access_t;
|
||||
|
||||
typedef iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
|
||||
, typename detail::multi_array::associated_types<T,NumDims>::value_type
|
||||
, boost::random_access_traversal_tag
|
||||
, Reference
|
||||
> facade_type;
|
||||
|
||||
typedef typename access_t::index index;
|
||||
typedef typename access_t::size_type size_type;
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
template <typename, typename, typename, typename, typename>
|
||||
friend class array_iterator;
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
|
||||
index idx_;
|
||||
TPtr base_;
|
||||
const size_type* extents_;
|
||||
const index* strides_;
|
||||
const index* index_base_;
|
||||
|
||||
public:
|
||||
// Typedefs to circumvent ambiguities between parent classes
|
||||
typedef typename facade_type::reference reference;
|
||||
typedef typename facade_type::value_type value_type;
|
||||
typedef typename facade_type::difference_type difference_type;
|
||||
|
||||
array_iterator() {}
|
||||
|
||||
array_iterator(index idx, TPtr base, const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
idx_(idx), base_(base), extents_(extents),
|
||||
strides_(strides), index_base_(index_base) { }
|
||||
|
||||
template <typename OPtr, typename ORef, typename Cat>
|
||||
array_iterator(
|
||||
const array_iterator<T,OPtr,NumDims,ORef,Cat>& rhs
|
||||
, typename boost::enable_if_convertible<OPtr,TPtr>::type* = 0
|
||||
)
|
||||
: idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),
|
||||
strides_(rhs.strides_), index_base_(rhs.index_base_) { }
|
||||
|
||||
|
||||
// RG - we make our own operator->
|
||||
operator_arrow_proxy<reference>
|
||||
operator->() const
|
||||
{
|
||||
return operator_arrow_proxy<reference>(this->dereference());
|
||||
}
|
||||
|
||||
|
||||
reference dereference() const
|
||||
{
|
||||
typedef typename value_accessor_generator<T,NumDims>::type accessor;
|
||||
return accessor::access(boost::type<reference>(),
|
||||
idx_,
|
||||
base_,
|
||||
extents_,
|
||||
strides_,
|
||||
index_base_);
|
||||
}
|
||||
|
||||
void increment() { ++idx_; }
|
||||
void decrement() { --idx_; }
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
bool equal(IteratorAdaptor& rhs) const {
|
||||
const std::size_t N = NumDims::value;
|
||||
return (idx_ == rhs.idx_) &&
|
||||
(base_ == rhs.base_) &&
|
||||
( (extents_ == rhs.extents_) ||
|
||||
std::equal(extents_,extents_+N,rhs.extents_) ) &&
|
||||
( (strides_ == rhs.strides_) ||
|
||||
std::equal(strides_,strides_+N,rhs.strides_) ) &&
|
||||
( (index_base_ == rhs.index_base_) ||
|
||||
std::equal(index_base_,index_base_+N,rhs.index_base_) );
|
||||
}
|
||||
|
||||
template <class DifferenceType>
|
||||
void advance(DifferenceType n) {
|
||||
idx_ += n;
|
||||
}
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
typename facade_type::difference_type
|
||||
distance_to(IteratorAdaptor& rhs) const {
|
||||
return rhs.idx_ - idx_;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // ITERATOR_RG071801_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_ITERATOR_HPP
|
||||
#define BOOST_MULTI_ARRAY_ITERATOR_HPP
|
||||
|
||||
//
|
||||
// iterator.hpp - implementation of iterators for the
|
||||
// multi-dimensional array class
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/iterator/iterator_facade.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// iterator components
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class T>
|
||||
struct operator_arrow_proxy
|
||||
{
|
||||
operator_arrow_proxy(T const& px) : value_(px) {}
|
||||
T* operator->() const { return &value_; }
|
||||
// This function is needed for MWCW and BCC, which won't call operator->
|
||||
// again automatically per 13.3.1.2 para 8
|
||||
operator T*() const { return &value_; }
|
||||
mutable T value_;
|
||||
};
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference,
|
||||
typename IteratorCategory>
|
||||
class array_iterator;
|
||||
|
||||
template <typename T, typename TPtr, typename NumDims, typename Reference,
|
||||
typename IteratorCategory>
|
||||
class array_iterator
|
||||
: public
|
||||
iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
|
||||
, typename associated_types<T,NumDims>::value_type
|
||||
, IteratorCategory
|
||||
, Reference
|
||||
>
|
||||
, private
|
||||
value_accessor_generator<T,NumDims>::type
|
||||
{
|
||||
friend class ::boost::iterator_core_access;
|
||||
typedef detail::multi_array::associated_types<T,NumDims> access_t;
|
||||
|
||||
typedef iterator_facade<
|
||||
array_iterator<T,TPtr,NumDims,Reference,IteratorCategory>
|
||||
, typename detail::multi_array::associated_types<T,NumDims>::value_type
|
||||
, boost::random_access_traversal_tag
|
||||
, Reference
|
||||
> facade_type;
|
||||
|
||||
typedef typename access_t::index index;
|
||||
typedef typename access_t::size_type size_type;
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
template <typename, typename, typename, typename, typename>
|
||||
friend class array_iterator;
|
||||
#else
|
||||
public:
|
||||
#endif
|
||||
|
||||
index idx_;
|
||||
TPtr base_;
|
||||
const size_type* extents_;
|
||||
const index* strides_;
|
||||
const index* index_base_;
|
||||
|
||||
public:
|
||||
// Typedefs to circumvent ambiguities between parent classes
|
||||
typedef typename facade_type::reference reference;
|
||||
typedef typename facade_type::value_type value_type;
|
||||
typedef typename facade_type::difference_type difference_type;
|
||||
|
||||
array_iterator() {}
|
||||
|
||||
array_iterator(index idx, TPtr base, const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
idx_(idx), base_(base), extents_(extents),
|
||||
strides_(strides), index_base_(index_base) { }
|
||||
|
||||
template <typename OPtr, typename ORef, typename Cat>
|
||||
array_iterator(
|
||||
const array_iterator<T,OPtr,NumDims,ORef,Cat>& rhs
|
||||
, typename boost::enable_if_convertible<OPtr,TPtr>::type* = 0
|
||||
)
|
||||
: idx_(rhs.idx_), base_(rhs.base_), extents_(rhs.extents_),
|
||||
strides_(rhs.strides_), index_base_(rhs.index_base_) { }
|
||||
|
||||
|
||||
// RG - we make our own operator->
|
||||
operator_arrow_proxy<reference>
|
||||
operator->() const
|
||||
{
|
||||
return operator_arrow_proxy<reference>(this->dereference());
|
||||
}
|
||||
|
||||
|
||||
reference dereference() const
|
||||
{
|
||||
typedef typename value_accessor_generator<T,NumDims>::type accessor;
|
||||
return accessor::access(boost::type<reference>(),
|
||||
idx_,
|
||||
base_,
|
||||
extents_,
|
||||
strides_,
|
||||
index_base_);
|
||||
}
|
||||
|
||||
void increment() { ++idx_; }
|
||||
void decrement() { --idx_; }
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
bool equal(IteratorAdaptor& rhs) const {
|
||||
const std::size_t N = NumDims::value;
|
||||
return (idx_ == rhs.idx_) &&
|
||||
(base_ == rhs.base_) &&
|
||||
( (extents_ == rhs.extents_) ||
|
||||
std::equal(extents_,extents_+N,rhs.extents_) ) &&
|
||||
( (strides_ == rhs.strides_) ||
|
||||
std::equal(strides_,strides_+N,rhs.strides_) ) &&
|
||||
( (index_base_ == rhs.index_base_) ||
|
||||
std::equal(index_base_,index_base_+N,rhs.index_base_) );
|
||||
}
|
||||
|
||||
template <class DifferenceType>
|
||||
void advance(DifferenceType n) {
|
||||
idx_ += n;
|
||||
}
|
||||
|
||||
template <class IteratorAdaptor>
|
||||
typename facade_type::difference_type
|
||||
distance_to(IteratorAdaptor& rhs) const {
|
||||
return rhs.idx_ - idx_;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,70 +1,70 @@
|
||||
// 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 RANGE_LIST_RG072501_HPP
|
||||
#define RANGE_LIST_RG072501_HPP
|
||||
//
|
||||
// range_list.hpp - helper to build boost::arrays for *_set types
|
||||
//
|
||||
|
||||
#include "boost/array.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// choose range list begins
|
||||
//
|
||||
|
||||
struct choose_range_list_n {
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct bind {
|
||||
typedef boost::array<T,NumRanges> type;
|
||||
};
|
||||
};
|
||||
|
||||
struct choose_range_list_zero {
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct bind {
|
||||
typedef boost::array<T,1> type;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <std::size_t NumRanges>
|
||||
struct range_list_gen_helper {
|
||||
typedef choose_range_list_n choice;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct range_list_gen_helper<0> {
|
||||
typedef choose_range_list_zero choice;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct range_list_generator {
|
||||
private:
|
||||
typedef typename range_list_gen_helper<NumRanges>::choice Choice;
|
||||
public:
|
||||
typedef typename Choice::template bind<T,NumRanges>::type type;
|
||||
};
|
||||
|
||||
//
|
||||
// choose range list ends
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // RANGE_LIST_RG072501_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_RANGE_LIST_HPP
|
||||
#define BOOST_MULTI_ARRAY_RANGE_LIST_HPP
|
||||
//
|
||||
// range_list.hpp - helper to build boost::arrays for *_set types
|
||||
//
|
||||
|
||||
#include "boost/array.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// choose range list begins
|
||||
//
|
||||
|
||||
struct choose_range_list_n {
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct bind {
|
||||
typedef boost::array<T,NumRanges> type;
|
||||
};
|
||||
};
|
||||
|
||||
struct choose_range_list_zero {
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct bind {
|
||||
typedef boost::array<T,1> type;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <std::size_t NumRanges>
|
||||
struct range_list_gen_helper {
|
||||
typedef choose_range_list_n choice;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct range_list_gen_helper<0> {
|
||||
typedef choose_range_list_zero choice;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t NumRanges>
|
||||
struct range_list_generator {
|
||||
private:
|
||||
typedef typename range_list_gen_helper<NumRanges>::choice Choice;
|
||||
public:
|
||||
typedef typename Choice::template bind<T,NumRanges>::type type;
|
||||
};
|
||||
|
||||
//
|
||||
// choose range list ends
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -1,125 +1,125 @@
|
||||
// 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 BOOST_STORAGE_ORDER_RG071801_HPP
|
||||
#define BOOST_STORAGE_ORDER_RG071801_HPP
|
||||
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// RG - This is to make things work with VC++. So sad, so sad.
|
||||
class c_storage_order;
|
||||
class fortran_storage_order;
|
||||
|
||||
template <std::size_t NumDims>
|
||||
class general_storage_order
|
||||
{
|
||||
public:
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
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());
|
||||
}
|
||||
|
||||
// RG - ideally these would not be necessary, but some compilers
|
||||
// don't like template conversion operators. I suspect that not
|
||||
// too many folk will feel the need to use customized
|
||||
// storage_order objects, I sacrifice that feature for compiler support.
|
||||
general_storage_order(const c_storage_order&) {
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering_[i] = NumDims - 1 - i;
|
||||
}
|
||||
ascending_.assign(true);
|
||||
}
|
||||
|
||||
general_storage_order(const fortran_storage_order&) {
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering_[i] = i;
|
||||
}
|
||||
ascending_.assign(true);
|
||||
}
|
||||
|
||||
size_type ordering(size_type dim) const { return ordering_[dim]; }
|
||||
bool ascending(size_type dim) const { return ascending_[dim]; }
|
||||
|
||||
bool all_dims_ascending() const {
|
||||
return std::accumulate(ascending_.begin(),ascending_.end(),true,
|
||||
std::logical_and<bool>());
|
||||
}
|
||||
|
||||
bool operator==(general_storage_order const& rhs) const {
|
||||
return (ordering_ == rhs.ordering_) &&
|
||||
(ascending_ == rhs.ascending_);
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::array<size_type,NumDims> ordering_;
|
||||
boost::array<bool,NumDims> ascending_;
|
||||
};
|
||||
|
||||
class c_storage_order
|
||||
{
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
public:
|
||||
// This is the idiom for creating your own custom storage orders.
|
||||
// Not supported by all compilers though!
|
||||
#ifndef __MWERKS__ // Metrowerks screams "ambiguity!"
|
||||
template <std::size_t NumDims>
|
||||
operator general_storage_order<NumDims>() const {
|
||||
boost::array<size_type,NumDims> ordering;
|
||||
boost::array<bool,NumDims> ascending;
|
||||
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering[i] = NumDims - 1 - i;
|
||||
ascending[i] = true;
|
||||
}
|
||||
return general_storage_order<NumDims>(ordering.begin(),
|
||||
ascending.begin());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class fortran_storage_order
|
||||
{
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
public:
|
||||
// This is the idiom for creating your own custom storage orders.
|
||||
// Not supported by all compilers though!
|
||||
#ifndef __MWERKS__ // Metrowerks screams "ambiguity!"
|
||||
template <std::size_t NumDims>
|
||||
operator general_storage_order<NumDims>() const {
|
||||
boost::array<size_type,NumDims> ordering;
|
||||
boost::array<bool,NumDims> ascending;
|
||||
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering[i] = i;
|
||||
ascending[i] = true;
|
||||
}
|
||||
return general_storage_order<NumDims>(ordering.begin(),
|
||||
ascending.begin());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ARRAY_STORAGE_RG071801_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_STORAGE_ORDER_HPP
|
||||
#define BOOST_MULTI_ARRAY_STORAGE_ORDER_HPP
|
||||
|
||||
#include "boost/multi_array/types.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
|
||||
// RG - This is to make things work with VC++. So sad, so sad.
|
||||
class c_storage_order;
|
||||
class fortran_storage_order;
|
||||
|
||||
template <std::size_t NumDims>
|
||||
class general_storage_order
|
||||
{
|
||||
public:
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
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());
|
||||
}
|
||||
|
||||
// RG - ideally these would not be necessary, but some compilers
|
||||
// don't like template conversion operators. I suspect that not
|
||||
// too many folk will feel the need to use customized
|
||||
// storage_order objects, I sacrifice that feature for compiler support.
|
||||
general_storage_order(const c_storage_order&) {
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering_[i] = NumDims - 1 - i;
|
||||
}
|
||||
ascending_.assign(true);
|
||||
}
|
||||
|
||||
general_storage_order(const fortran_storage_order&) {
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering_[i] = i;
|
||||
}
|
||||
ascending_.assign(true);
|
||||
}
|
||||
|
||||
size_type ordering(size_type dim) const { return ordering_[dim]; }
|
||||
bool ascending(size_type dim) const { return ascending_[dim]; }
|
||||
|
||||
bool all_dims_ascending() const {
|
||||
return std::accumulate(ascending_.begin(),ascending_.end(),true,
|
||||
std::logical_and<bool>());
|
||||
}
|
||||
|
||||
bool operator==(general_storage_order const& rhs) const {
|
||||
return (ordering_ == rhs.ordering_) &&
|
||||
(ascending_ == rhs.ascending_);
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::array<size_type,NumDims> ordering_;
|
||||
boost::array<bool,NumDims> ascending_;
|
||||
};
|
||||
|
||||
class c_storage_order
|
||||
{
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
public:
|
||||
// This is the idiom for creating your own custom storage orders.
|
||||
// Not supported by all compilers though!
|
||||
#ifndef __MWERKS__ // Metrowerks screams "ambiguity!"
|
||||
template <std::size_t NumDims>
|
||||
operator general_storage_order<NumDims>() const {
|
||||
boost::array<size_type,NumDims> ordering;
|
||||
boost::array<bool,NumDims> ascending;
|
||||
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering[i] = NumDims - 1 - i;
|
||||
ascending[i] = true;
|
||||
}
|
||||
return general_storage_order<NumDims>(ordering.begin(),
|
||||
ascending.begin());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class fortran_storage_order
|
||||
{
|
||||
typedef detail::multi_array::size_type size_type;
|
||||
public:
|
||||
// This is the idiom for creating your own custom storage orders.
|
||||
// Not supported by all compilers though!
|
||||
#ifndef __MWERKS__ // Metrowerks screams "ambiguity!"
|
||||
template <std::size_t NumDims>
|
||||
operator general_storage_order<NumDims>() const {
|
||||
boost::array<size_type,NumDims> ordering;
|
||||
boost::array<bool,NumDims> ascending;
|
||||
|
||||
for (size_type i=0; i != NumDims; ++i) {
|
||||
ordering[i] = i;
|
||||
ascending[i] = true;
|
||||
}
|
||||
return general_storage_order<NumDims>(ordering.begin(),
|
||||
ascending.begin());
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -1,387 +1,387 @@
|
||||
// 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 SUBARRAY_RG071801_HPP
|
||||
#define SUBARRAY_RG071801_HPP
|
||||
|
||||
//
|
||||
// subarray.hpp - used to implement standard operator[] on
|
||||
// multi_arrays
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/type.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
//
|
||||
// const_sub_array
|
||||
// multi_array's proxy class to allow multiple overloads of
|
||||
// operator[] in order to provide a clean multi-dimensional array
|
||||
// interface.
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
class const_sub_array :
|
||||
public boost::detail::multi_array::multi_array_impl_base<T,NumDims>
|
||||
{
|
||||
typedef boost::detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Allow default copy constructor as well.
|
||||
|
||||
template <typename OPtr>
|
||||
const_sub_array (const const_sub_array<T,NumDims,OPtr>& rhs) :
|
||||
base_(rhs.base_), extents_(rhs.extents_), strides_(rhs.strides_),
|
||||
index_base_(rhs.index_base_) {
|
||||
}
|
||||
|
||||
// const_sub_array always returns const types, regardless of its own
|
||||
// constness.
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,base_,shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
template <typename IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
typedef typename const_array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
shape(),
|
||||
strides(),
|
||||
index_bases(),
|
||||
base_);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator==(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
if(std::equal(shape(),shape()+num_dimensions(),rhs.shape()))
|
||||
return std::equal(begin(),end(),rhs.begin());
|
||||
else return false;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator!=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return rhs < *this;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return const_iterator(*index_bases(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
TPtr origin() const { return base_; }
|
||||
size_type size() const { return extents_[0]; }
|
||||
size_type max_size() const { return num_elements(); }
|
||||
bool empty() const { return size() == 0; }
|
||||
size_type num_dimensions() const { return NumDims; }
|
||||
const size_type* shape() const { return extents_; }
|
||||
const index* strides() const { return strides_; }
|
||||
const index* index_bases() const { return index_base_; }
|
||||
|
||||
size_type num_elements() const {
|
||||
return std::accumulate(shape(),shape() + num_dimensions(),
|
||||
size_type(1), std::multiplies<size_type>());
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
template <typename,std::size_t> friend class value_accessor_n;
|
||||
template <typename,std::size_t,typename> friend class const_sub_array;
|
||||
#else
|
||||
public: // Should be protected
|
||||
#endif
|
||||
|
||||
const_sub_array (TPtr base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
base_(base), extents_(extents), strides_(strides),
|
||||
index_base_(index_base) {
|
||||
}
|
||||
|
||||
TPtr base_;
|
||||
const size_type* extents_;
|
||||
const index* strides_;
|
||||
const index* index_base_;
|
||||
private:
|
||||
// const_sub_array cannot be assigned to (no deep copies!)
|
||||
const_sub_array& operator=(const const_sub_array&);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// sub_array
|
||||
// multi_array's proxy class to allow multiple overloads of
|
||||
// operator[] in order to provide a clean multi-dimensional array
|
||||
// interface.
|
||||
template <typename T, std::size_t NumDims>
|
||||
class sub_array : public const_sub_array<T,NumDims,T*>
|
||||
{
|
||||
typedef const_sub_array<T,NumDims,T*> super_type;
|
||||
public:
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::reference reference;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::iterator iterator;
|
||||
typedef typename super_type::reverse_iterator reverse_iterator;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
sub_array& operator=(const ConstMultiArray& other) {
|
||||
function_requires< boost::multi_array_concepts::ConstMultiArrayConcept<
|
||||
ConstMultiArray, NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
sub_array& operator=(const sub_array& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T* origin() { return this->base_; }
|
||||
const T* origin() const { return this->base_; }
|
||||
|
||||
reference operator[](index idx) {
|
||||
return super_type::access(boost::type<reference>(),
|
||||
idx,this->base_,this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices) {
|
||||
typedef typename array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
this->shape(),
|
||||
this->strides(),
|
||||
this->index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return iterator(*this->index_bases(),origin(),
|
||||
this->shape(),this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
// RG - rbegin() and rend() written naively to thwart MSVC ICE.
|
||||
reverse_iterator rbegin() {
|
||||
reverse_iterator ri(end());
|
||||
return ri;
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
reverse_iterator ri(begin());
|
||||
return ri;
|
||||
}
|
||||
|
||||
//
|
||||
// proxies
|
||||
//
|
||||
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::operator[](idx);
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
return super_type::operator[](indices);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return super_type::begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return super_type::end();
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return super_type::rbegin();
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return super_type::rend();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private:
|
||||
template <typename,std::size_t> friend class value_accessor_n;
|
||||
#else
|
||||
public: // should be private
|
||||
#endif
|
||||
|
||||
sub_array (T* base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
super_type(base,extents,strides,index_base) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
//
|
||||
// traits classes to get sub_array types
|
||||
//
|
||||
template <typename Array, int N>
|
||||
class subarray_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::sub_array<element,N> type;
|
||||
};
|
||||
|
||||
template <typename Array, int N>
|
||||
class const_subarray_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::const_sub_array<element,N> type;
|
||||
};
|
||||
} // namespace boost
|
||||
|
||||
#endif // SUBARRAY_RG071801_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_SUBARRAY_HPP
|
||||
#define BOOST_MULTI_ARRAY_SUBARRAY_HPP
|
||||
|
||||
//
|
||||
// subarray.hpp - used to implement standard operator[] on
|
||||
// multi_arrays
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include "boost/type.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
//
|
||||
// const_sub_array
|
||||
// multi_array's proxy class to allow multiple overloads of
|
||||
// operator[] in order to provide a clean multi-dimensional array
|
||||
// interface.
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
class const_sub_array :
|
||||
public boost::detail::multi_array::multi_array_impl_base<T,NumDims>
|
||||
{
|
||||
typedef boost::detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Allow default copy constructor as well.
|
||||
|
||||
template <typename OPtr>
|
||||
const_sub_array (const const_sub_array<T,NumDims,OPtr>& rhs) :
|
||||
base_(rhs.base_), extents_(rhs.extents_), strides_(rhs.strides_),
|
||||
index_base_(rhs.index_base_) {
|
||||
}
|
||||
|
||||
// const_sub_array always returns const types, regardless of its own
|
||||
// constness.
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,base_,shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
template <typename IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
typedef typename const_array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
shape(),
|
||||
strides(),
|
||||
index_bases(),
|
||||
base_);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator==(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
if(std::equal(shape(),shape()+num_dimensions(),rhs.shape()))
|
||||
return std::equal(begin(),end(),rhs.begin());
|
||||
else return false;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator!=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return rhs < *this;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>=(const const_sub_array<T,NumDims,OPtr>& rhs) const {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return const_iterator(*index_bases(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
TPtr origin() const { return base_; }
|
||||
size_type size() const { return extents_[0]; }
|
||||
size_type max_size() const { return num_elements(); }
|
||||
bool empty() const { return size() == 0; }
|
||||
size_type num_dimensions() const { return NumDims; }
|
||||
const size_type* shape() const { return extents_; }
|
||||
const index* strides() const { return strides_; }
|
||||
const index* index_bases() const { return index_base_; }
|
||||
|
||||
size_type num_elements() const {
|
||||
return std::accumulate(shape(),shape() + num_dimensions(),
|
||||
size_type(1), std::multiplies<size_type>());
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
template <typename,std::size_t> friend class value_accessor_n;
|
||||
template <typename,std::size_t,typename> friend class const_sub_array;
|
||||
#else
|
||||
public: // Should be protected
|
||||
#endif
|
||||
|
||||
const_sub_array (TPtr base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
base_(base), extents_(extents), strides_(strides),
|
||||
index_base_(index_base) {
|
||||
}
|
||||
|
||||
TPtr base_;
|
||||
const size_type* extents_;
|
||||
const index* strides_;
|
||||
const index* index_base_;
|
||||
private:
|
||||
// const_sub_array cannot be assigned to (no deep copies!)
|
||||
const_sub_array& operator=(const const_sub_array&);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// sub_array
|
||||
// multi_array's proxy class to allow multiple overloads of
|
||||
// operator[] in order to provide a clean multi-dimensional array
|
||||
// interface.
|
||||
template <typename T, std::size_t NumDims>
|
||||
class sub_array : public const_sub_array<T,NumDims,T*>
|
||||
{
|
||||
typedef const_sub_array<T,NumDims,T*> super_type;
|
||||
public:
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::reference reference;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::iterator iterator;
|
||||
typedef typename super_type::reverse_iterator reverse_iterator;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
sub_array& operator=(const ConstMultiArray& other) {
|
||||
function_requires< boost::multi_array_concepts::ConstMultiArrayConcept<
|
||||
ConstMultiArray, NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
sub_array& operator=(const sub_array& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
T* origin() { return this->base_; }
|
||||
const T* origin() const { return this->base_; }
|
||||
|
||||
reference operator[](index idx) {
|
||||
return super_type::access(boost::type<reference>(),
|
||||
idx,this->base_,this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices) {
|
||||
typedef typename array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
this->shape(),
|
||||
this->strides(),
|
||||
this->index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return iterator(*this->index_bases(),origin(),
|
||||
this->shape(),this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),this->index_bases());
|
||||
}
|
||||
|
||||
// RG - rbegin() and rend() written naively to thwart MSVC ICE.
|
||||
reverse_iterator rbegin() {
|
||||
reverse_iterator ri(end());
|
||||
return ri;
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
reverse_iterator ri(begin());
|
||||
return ri;
|
||||
}
|
||||
|
||||
//
|
||||
// proxies
|
||||
//
|
||||
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::operator[](idx);
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
return super_type::operator[](indices);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return super_type::begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return super_type::end();
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return super_type::rbegin();
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return super_type::rend();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private:
|
||||
template <typename,std::size_t> friend class value_accessor_n;
|
||||
#else
|
||||
public: // should be private
|
||||
#endif
|
||||
|
||||
sub_array (T* base,
|
||||
const size_type* extents,
|
||||
const index* strides,
|
||||
const index* index_base) :
|
||||
super_type(base,extents,strides,index_base) {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
//
|
||||
// traits classes to get sub_array types
|
||||
//
|
||||
template <typename Array, int N>
|
||||
class subarray_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::sub_array<element,N> type;
|
||||
};
|
||||
|
||||
template <typename Array, int N>
|
||||
class const_subarray_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::const_sub_array<element,N> type;
|
||||
};
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
@@ -1,38 +1,38 @@
|
||||
// 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 BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
|
||||
#define BOOST_MULTI_ARRAY_TYPES_RG071801_HPP
|
||||
|
||||
//
|
||||
// types.hpp - supply types that are needed by several headers
|
||||
//
|
||||
#include "boost/config.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array{
|
||||
|
||||
// needed typedefs
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t index;
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // BOOST_MULTI_ARRAY_TYPES_RG071801_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.
|
||||
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_TYPES_HPP
|
||||
#define BOOST_MULTI_ARRAY_TYPES_HPP
|
||||
|
||||
//
|
||||
// types.hpp - supply types that are needed by several headers
|
||||
//
|
||||
#include "boost/config.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array{
|
||||
|
||||
// needed typedefs
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t index;
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,461 +1,460 @@
|
||||
// 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 BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
|
||||
#define BOOST_MULTI_ARRAY_VIEW_RG071301_HPP
|
||||
|
||||
//
|
||||
// view.hpp - code for creating "views" of array data.
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp"
|
||||
#include "boost/multi_array/iterator.hpp"
|
||||
#include "boost/multi_array/storage_order.hpp"
|
||||
#include "boost/multi_array/subarray.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/utility/enable_if.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
// TPtr = const T* defaulted in base.hpp
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
class const_multi_array_view :
|
||||
public boost::detail::multi_array::multi_array_impl_base<T,NumDims>
|
||||
{
|
||||
typedef boost::detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <typename OPtr>
|
||||
const_multi_array_view(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& other) :
|
||||
base_(other.base_), origin_offset_(other.origin_offset_),
|
||||
num_elements_(other.num_elements_), extent_list_(other.extent_list_),
|
||||
stride_list_(other.stride_list_), index_base_list_(other.index_base_list_)
|
||||
{ }
|
||||
|
||||
|
||||
template <class BaseList>
|
||||
#ifdef BOOST_NO_SFINAE
|
||||
void
|
||||
#else
|
||||
typename
|
||||
disable_if<typename boost::is_integral<BaseList>::type,void >::type
|
||||
#endif
|
||||
reindex(const BaseList& values) {
|
||||
boost::function_requires<
|
||||
CollectionConcept<BaseList> >();
|
||||
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_);
|
||||
}
|
||||
|
||||
void reindex(index value) {
|
||||
index_base_list_.assign(value);
|
||||
origin_offset_ =
|
||||
this->calculate_indexing_offset(stride_list_,index_base_list_);
|
||||
}
|
||||
|
||||
size_type num_dimensions() const { return NumDims; }
|
||||
|
||||
size_type size() const { return extent_list_.front(); }
|
||||
size_type max_size() const { return num_elements(); }
|
||||
bool empty() const { return size() == 0; }
|
||||
|
||||
const size_type* shape() const {
|
||||
return extent_list_.data();
|
||||
}
|
||||
|
||||
const index* strides() const {
|
||||
return stride_list_.data();
|
||||
}
|
||||
|
||||
const T* origin() const { return base_+origin_offset_; }
|
||||
|
||||
size_type num_elements() const { return num_elements_; }
|
||||
|
||||
const index* index_bases() const {
|
||||
return index_base_list_.data();
|
||||
}
|
||||
|
||||
template <typename IndexList>
|
||||
const element& operator()(IndexList indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// Only allow const element access
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,origin(),
|
||||
shape(),strides(),
|
||||
index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
typedef typename const_array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
shape(),
|
||||
strides(),
|
||||
index_bases(),
|
||||
origin());
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return const_iterator(*index_bases(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator==(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
if(std::equal(extent_list_.begin(),
|
||||
extent_list_.end(),
|
||||
rhs.extent_list_.begin()))
|
||||
return std::equal(begin(),end(),rhs.begin());
|
||||
else return false;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator!=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return rhs < *this;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
template <typename,std::size_t> friend class multi_array_impl_base;
|
||||
template <typename,std::size_t,typename> friend class const_multi_array_view;
|
||||
#else
|
||||
public: // should be protected
|
||||
#endif
|
||||
|
||||
// This constructor is used by multi_array_impl_base::generate_array_view
|
||||
// to create strides
|
||||
template <typename ExtentList, typename Index>
|
||||
explicit const_multi_array_view(TPtr base,
|
||||
const ExtentList& extents,
|
||||
const boost::array<Index,NumDims>& strides):
|
||||
base_(base), origin_offset_(0) {
|
||||
|
||||
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());
|
||||
|
||||
// Calculate the array size
|
||||
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
}
|
||||
|
||||
typedef boost::array<size_type,NumDims> size_list;
|
||||
typedef boost::array<index,NumDims> index_list;
|
||||
|
||||
TPtr base_;
|
||||
index origin_offset_;
|
||||
size_type num_elements_;
|
||||
size_list extent_list_;
|
||||
index_list stride_list_;
|
||||
index_list index_base_list_;
|
||||
|
||||
private:
|
||||
// const_multi_array_view cannot be assigned to (no deep copies!)
|
||||
const_multi_array_view& operator=(const const_multi_array_view& other);
|
||||
};
|
||||
|
||||
|
||||
template <typename T, std::size_t NumDims>
|
||||
class multi_array_view :
|
||||
public const_multi_array_view<T,NumDims,T*>
|
||||
{
|
||||
typedef const_multi_array_view<T,NumDims,T*> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::reference reference;
|
||||
typedef typename super_type::iterator iterator;
|
||||
typedef typename super_type::reverse_iterator reverse_iterator;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
multi_array_view& operator=(const ConstMultiArray& other) {
|
||||
function_requires<
|
||||
boost::multi_array_concepts::
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
multi_array_view& operator=(const multi_array_view& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
element* origin() { return this->base_+this->origin_offset_; }
|
||||
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
reference operator[](index idx) {
|
||||
return super_type::access(boost::type<reference>(),
|
||||
idx,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices) {
|
||||
typedef typename array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
this->shape(),
|
||||
this->strides(),
|
||||
this->index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
|
||||
iterator begin() {
|
||||
return iterator(*this->index_bases(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
reverse_iterator rbegin() {
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
// Using declarations don't seem to work for g++
|
||||
// These are the proxies to work around this.
|
||||
|
||||
const element* origin() const { return super_type::origin(); }
|
||||
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::operator[](idx);
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
return super_type::operator[](indices);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return super_type::begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return super_type::end();
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return super_type::rbegin();
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return super_type::rend();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private:
|
||||
template <typename,std::size_t> friend class multi_array_impl_base;
|
||||
#else
|
||||
public: // should be private
|
||||
#endif
|
||||
|
||||
// constructor used by multi_array_impl_base::generate_array_view to
|
||||
// generate array views
|
||||
template <typename ExtentList, typename Index>
|
||||
explicit multi_array_view(T* base,
|
||||
const ExtentList& extents,
|
||||
const boost::array<Index,NumDims>& strides) :
|
||||
super_type(base,extents,strides) { }
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
|
||||
//
|
||||
// traits classes to get array_view types
|
||||
//
|
||||
template <typename Array, int N>
|
||||
class array_view_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::multi_array_view<element,N> type;
|
||||
};
|
||||
|
||||
template <typename Array, int N>
|
||||
class const_array_view_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::const_multi_array_view<element,N> type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_MULTI_ARRAY_VIEW_RG071301_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.
|
||||
|
||||
#ifndef BOOST_MULTI_ARRAY_VIEW_HPP
|
||||
#define BOOST_MULTI_ARRAY_VIEW_HPP
|
||||
|
||||
//
|
||||
// view.hpp - code for creating "views" of array data.
|
||||
//
|
||||
|
||||
#include "boost/multi_array/base.hpp"
|
||||
#include "boost/multi_array/concept_checks.hpp"
|
||||
#include "boost/multi_array/iterator.hpp"
|
||||
#include "boost/multi_array/storage_order.hpp"
|
||||
#include "boost/multi_array/subarray.hpp"
|
||||
#include "boost/multi_array/algorithm.hpp"
|
||||
#include "boost/type_traits/is_integral.hpp"
|
||||
#include "boost/utility/enable_if.hpp"
|
||||
#include "boost/array.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
namespace multi_array {
|
||||
|
||||
// TPtr = const T* defaulted in base.hpp
|
||||
template <typename T, std::size_t NumDims, typename TPtr>
|
||||
class const_multi_array_view :
|
||||
public boost::detail::multi_array::multi_array_impl_base<T,NumDims>
|
||||
{
|
||||
typedef boost::detail::multi_array::multi_array_impl_base<T,NumDims> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <typename OPtr>
|
||||
const_multi_array_view(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& other) :
|
||||
base_(other.base_), origin_offset_(other.origin_offset_),
|
||||
num_elements_(other.num_elements_), extent_list_(other.extent_list_),
|
||||
stride_list_(other.stride_list_), index_base_list_(other.index_base_list_)
|
||||
{ }
|
||||
|
||||
|
||||
template <class BaseList>
|
||||
#ifdef BOOST_NO_SFINAE
|
||||
void
|
||||
#else
|
||||
typename
|
||||
disable_if<typename boost::is_integral<BaseList>::type,void >::type
|
||||
#endif
|
||||
reindex(const BaseList& values) {
|
||||
boost::function_requires<
|
||||
CollectionConcept<BaseList> >();
|
||||
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_);
|
||||
}
|
||||
|
||||
void reindex(index value) {
|
||||
index_base_list_.assign(value);
|
||||
origin_offset_ =
|
||||
this->calculate_indexing_offset(stride_list_,index_base_list_);
|
||||
}
|
||||
|
||||
size_type num_dimensions() const { return NumDims; }
|
||||
|
||||
size_type size() const { return extent_list_.front(); }
|
||||
size_type max_size() const { return num_elements(); }
|
||||
bool empty() const { return size() == 0; }
|
||||
|
||||
const size_type* shape() const {
|
||||
return extent_list_.data();
|
||||
}
|
||||
|
||||
const index* strides() const {
|
||||
return stride_list_.data();
|
||||
}
|
||||
|
||||
const T* origin() const { return base_+origin_offset_; }
|
||||
|
||||
size_type num_elements() const { return num_elements_; }
|
||||
|
||||
const index* index_bases() const {
|
||||
return index_base_list_.data();
|
||||
}
|
||||
|
||||
template <typename IndexList>
|
||||
const element& operator()(IndexList indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<const element&>(),
|
||||
indices,origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
// Only allow const element access
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::access(boost::type<const_reference>(),
|
||||
idx,origin(),
|
||||
shape(),strides(),
|
||||
index_bases());
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
typedef typename const_array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
shape(),
|
||||
strides(),
|
||||
index_bases(),
|
||||
origin());
|
||||
}
|
||||
const_iterator begin() const {
|
||||
return const_iterator(*index_bases(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return const_iterator(*index_bases()+(index)*shape(),origin(),
|
||||
shape(),strides(),index_bases());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator==(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
if(std::equal(extent_list_.begin(),
|
||||
extent_list_.end(),
|
||||
rhs.extent_list_.begin()))
|
||||
return std::equal(begin(),end(),rhs.begin());
|
||||
else return false;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return std::lexicographical_compare(begin(),end(),rhs.begin(),rhs.end());
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator!=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return rhs < *this;
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator<=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this > rhs);
|
||||
}
|
||||
|
||||
template <typename OPtr>
|
||||
bool operator>=(const
|
||||
const_multi_array_view<T,NumDims,OPtr>& rhs)
|
||||
const {
|
||||
return !(*this < rhs);
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
protected:
|
||||
template <typename,std::size_t> friend class multi_array_impl_base;
|
||||
template <typename,std::size_t,typename> friend class const_multi_array_view;
|
||||
#else
|
||||
public: // should be protected
|
||||
#endif
|
||||
|
||||
// This constructor is used by multi_array_impl_base::generate_array_view
|
||||
// to create strides
|
||||
template <typename ExtentList, typename Index>
|
||||
explicit const_multi_array_view(TPtr base,
|
||||
const ExtentList& extents,
|
||||
const boost::array<Index,NumDims>& strides):
|
||||
base_(base), origin_offset_(0) {
|
||||
|
||||
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());
|
||||
|
||||
// Calculate the array size
|
||||
num_elements_ = std::accumulate(extent_list_.begin(),extent_list_.end(),
|
||||
size_type(1),std::multiplies<size_type>());
|
||||
}
|
||||
|
||||
typedef boost::array<size_type,NumDims> size_list;
|
||||
typedef boost::array<index,NumDims> index_list;
|
||||
|
||||
TPtr base_;
|
||||
index origin_offset_;
|
||||
size_type num_elements_;
|
||||
size_list extent_list_;
|
||||
index_list stride_list_;
|
||||
index_list index_base_list_;
|
||||
|
||||
private:
|
||||
// const_multi_array_view cannot be assigned to (no deep copies!)
|
||||
const_multi_array_view& operator=(const const_multi_array_view& other);
|
||||
};
|
||||
|
||||
|
||||
template <typename T, std::size_t NumDims>
|
||||
class multi_array_view :
|
||||
public const_multi_array_view<T,NumDims,T*>
|
||||
{
|
||||
typedef const_multi_array_view<T,NumDims,T*> super_type;
|
||||
public:
|
||||
typedef typename super_type::value_type value_type;
|
||||
typedef typename super_type::reference reference;
|
||||
typedef typename super_type::iterator iterator;
|
||||
typedef typename super_type::reverse_iterator reverse_iterator;
|
||||
typedef typename super_type::const_reference const_reference;
|
||||
typedef typename super_type::const_iterator const_iterator;
|
||||
typedef typename super_type::const_reverse_iterator const_reverse_iterator;
|
||||
typedef typename super_type::element element;
|
||||
typedef typename super_type::size_type size_type;
|
||||
typedef typename super_type::difference_type difference_type;
|
||||
typedef typename super_type::index index;
|
||||
typedef typename super_type::extent_range extent_range;
|
||||
|
||||
// template typedefs
|
||||
template <std::size_t NDims>
|
||||
struct const_array_view {
|
||||
typedef boost::detail::multi_array::const_multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
template <std::size_t NDims>
|
||||
struct array_view {
|
||||
typedef boost::detail::multi_array::multi_array_view<T,NDims> type;
|
||||
};
|
||||
|
||||
// Assignment from other ConstMultiArray types.
|
||||
template <typename ConstMultiArray>
|
||||
multi_array_view& operator=(const ConstMultiArray& other) {
|
||||
function_requires<
|
||||
boost::multi_array_concepts::
|
||||
ConstMultiArrayConcept<ConstMultiArray,NumDims> >();
|
||||
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
multi_array_view& operator=(const multi_array_view& other) {
|
||||
if (&other != this) {
|
||||
// make sure the dimensions agree
|
||||
BOOST_ASSERT(other.num_dimensions() == this->num_dimensions());
|
||||
BOOST_ASSERT(std::equal(other.shape(),
|
||||
other.shape()+this->num_dimensions(),
|
||||
this->shape()));
|
||||
// iterator-based copy
|
||||
std::copy(other.begin(),other.end(),begin());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
element* origin() { return this->base_+this->origin_offset_; }
|
||||
|
||||
template <class IndexList>
|
||||
element& operator()(const IndexList& indices) {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::access_element(boost::type<element&>(),
|
||||
indices,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
reference operator[](index idx) {
|
||||
return super_type::access(boost::type<reference>(),
|
||||
idx,origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices) {
|
||||
typedef typename array_view<NDims>::type return_type;
|
||||
return
|
||||
super_type::generate_array_view(boost::type<return_type>(),
|
||||
indices,
|
||||
this->shape(),
|
||||
this->strides(),
|
||||
this->index_bases(),
|
||||
origin());
|
||||
}
|
||||
|
||||
|
||||
iterator begin() {
|
||||
return iterator(*this->index_bases(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return iterator(*this->index_bases()+(index)*this->shape(),origin(),
|
||||
this->shape(),this->strides(),
|
||||
this->index_bases());
|
||||
}
|
||||
|
||||
reverse_iterator rbegin() {
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
// Using declarations don't seem to work for g++
|
||||
// These are the proxies to work around this.
|
||||
|
||||
const element* origin() const { return super_type::origin(); }
|
||||
|
||||
template <class IndexList>
|
||||
const element& operator()(const IndexList& indices) const {
|
||||
boost::function_requires<
|
||||
CollectionConcept<IndexList> >();
|
||||
return super_type::operator()(indices);
|
||||
}
|
||||
|
||||
const_reference operator[](index idx) const {
|
||||
return super_type::operator[](idx);
|
||||
}
|
||||
|
||||
// see generate_array_view in base.hpp
|
||||
template <int NDims>
|
||||
typename const_array_view<NDims>::type
|
||||
operator[](const boost::detail::multi_array::
|
||||
index_gen<NumDims,NDims>& indices)
|
||||
const {
|
||||
return super_type::operator[](indices);
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return super_type::begin();
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return super_type::end();
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return super_type::rbegin();
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return super_type::rend();
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
|
||||
private:
|
||||
template <typename,std::size_t> friend class multi_array_impl_base;
|
||||
#else
|
||||
public: // should be private
|
||||
#endif
|
||||
|
||||
// constructor used by multi_array_impl_base::generate_array_view to
|
||||
// generate array views
|
||||
template <typename ExtentList, typename Index>
|
||||
explicit multi_array_view(T* base,
|
||||
const ExtentList& extents,
|
||||
const boost::array<Index,NumDims>& strides) :
|
||||
super_type(base,extents,strides) { }
|
||||
|
||||
};
|
||||
|
||||
} // namespace multi_array
|
||||
} // namespace detail
|
||||
|
||||
//
|
||||
// traits classes to get array_view types
|
||||
//
|
||||
template <typename Array, int N>
|
||||
class array_view_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::multi_array_view<element,N> type;
|
||||
};
|
||||
|
||||
template <typename Array, int N>
|
||||
class const_array_view_gen {
|
||||
typedef typename Array::element element;
|
||||
public:
|
||||
typedef boost::detail::multi_array::const_multi_array_view<element,N> type;
|
||||
};
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user