Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:05

0001 // Copyright 2002 The Trustees of Indiana University.
0002 
0003 // Use, modification and distribution is subject to the Boost Software 
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 //  Boost.MultiArray Library
0008 //  Authors: Ronald Garcia
0009 //           Jeremy Siek
0010 //           Andrew Lumsdaine
0011 //  See http://www.boost.org/libs/multi_array for documentation.
0012 
0013 #ifndef BOOST_MULTI_ARRAY_INDEX_GEN_HPP
0014 #define BOOST_MULTI_ARRAY_INDEX_GEN_HPP
0015 
0016 #include "boost/array.hpp"
0017 #include "boost/multi_array/index_range.hpp"
0018 #include "boost/multi_array/range_list.hpp"
0019 #include "boost/multi_array/types.hpp"
0020 #include <algorithm> 
0021 #include <cstddef>
0022 
0023 namespace boost {
0024 namespace detail {
0025 namespace multi_array {
0026 
0027 
0028 template <int NumRanges, int NumDims>
0029 struct index_gen {
0030 private:
0031   typedef ::boost::detail::multi_array::index index;
0032   typedef ::boost::detail::multi_array::size_type size_type;
0033   typedef index_range<index,size_type> range;
0034 public:
0035   template <int Dims, int Ranges>
0036   struct gen_type {
0037     typedef index_gen<Ranges,Dims> type;
0038   };
0039 
0040   typedef typename range_list_generator<range,NumRanges>::type range_list;
0041   range_list ranges_;
0042 
0043   index_gen() { }
0044 
0045   template <int ND>
0046   explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
0047             const range& r)
0048   {
0049     std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
0050     *ranges_.rbegin() = r;
0051   }
0052 
0053   index_gen<NumRanges+1,NumDims+1>
0054   operator[](const range& r) const
0055   {
0056     index_gen<NumRanges+1,NumDims+1> tmp;
0057     std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
0058     *tmp.ranges_.rbegin() = r;
0059     return tmp;
0060   }
0061 
0062   index_gen<NumRanges+1,NumDims>
0063   operator[](index idx) const
0064   {
0065     index_gen<NumRanges+1,NumDims> tmp;
0066     std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
0067     *tmp.ranges_.rbegin() = range(idx);
0068     return tmp;
0069   }    
0070 
0071   static index_gen<0,0> indices() {
0072     return index_gen<0,0>();
0073   }
0074 };
0075 
0076 } // namespace multi_array
0077 } // namespace detail
0078 } // namespace boost
0079 
0080 
0081 #endif