QMCPACK
container_traits_multi.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
9 // Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
10 //
11 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
12 //////////////////////////////////////////////////////////////////////////////////////
13 
14 
15 #ifndef QMCPLUSPLUS_CONTAINER_TRAITS_MULTI_H
16 #define QMCPLUSPLUS_CONTAINER_TRAITS_MULTI_H
17 
18 #include <multi/array.hpp>
19 #include <multi/array_ref.hpp>
21 
22 namespace qmcplusplus
23 {
24 // template specialization for functions in container_traits
25 template<typename T, boost::multi::dimensionality_type D, class Alloc>
26 struct container_traits<boost::multi::array<T, D, Alloc>>
27 {
28  using element_type = T;
29  using CT = boost::multi::array<T, D, Alloc>;
30 
31  template<typename I>
32  inline static void resize(CT& ref, I* n, int d)
33  {
34  if (d != D)
35  {
36  std::ostringstream err_msg;
37  err_msg << "boost::multi::array<T, " << D << ", Alloc> cannot be resized. Requested dimension = " << d
38  << std::endl;
39  throw std::runtime_error(err_msg.str());
40  }
41  std::array<I, 2> shape;
42  for (int i = 0; i < d; ++i)
43  shape[i] = n[i];
44  ref.reextent({static_cast<boost::multi::size_t>(shape[0]), static_cast<boost::multi::size_t>(shape[1])});
45  }
46 
47  inline static size_t getSize(const CT& ref) { return ref.num_elements(); }
48 
49  inline static auto getElementPtr(CT& ref) { return std::addressof(*ref.origin()); }
50 };
51 
52 template<typename T, boost::multi::dimensionality_type D>
53 struct container_traits<boost::multi::array_ref<T, D>>
54 {
55  using element_type = T;
56  using CT = boost::multi::array_ref<T, D>;
57 
58  template<typename I>
59  inline static void resize(CT& ref, I* n, int d)
60  {
61  throw std::runtime_error("Can not resize container_proxy<boost::multi::array_ref<T,D>>!\n");
62  }
63 
64  inline static size_t getSize(const CT& ref) { return ref.num_elements(); }
65 
66  inline static auto getElementPtr(CT& ref) { return std::addressof(*ref.origin()); }
67 };
68 
69 } // namespace qmcplusplus
70 
71 #endif
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
std::complex< double > I