ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
multi_array.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef UTILS_SERIALIZATION_MULTI_ARRAY_HPP
20#define UTILS_SERIALIZATION_MULTI_ARRAY_HPP
21
22#include <boost/multi_array.hpp>
23
24#include <boost/serialization/array.hpp>
25#include <boost/serialization/vector.hpp>
26
27#include <cstddef>
28
29namespace boost {
30namespace serialization {
31
32template <typename Archive, class T, std::size_t N, class Allocator>
33void load(Archive &ar, boost::multi_array<T, N, Allocator> &marray, unsigned) {
34 boost::array<std::size_t, N> shape;
35 ar &make_array(shape.data(), N);
36
37 marray.resize(shape);
38
39 ar &make_array(marray.data(), marray.num_elements());
40}
41
42template <typename Archive, class T, std::size_t N, class Allocator>
43void save(Archive &ar, const boost::multi_array<T, N, Allocator> &marray,
44 unsigned) {
45 ar &make_array(marray.shape(), marray.num_dimensions());
46
47 ar &make_array(marray.data(), marray.num_elements());
48}
49
50template <typename Archive, class T, std::size_t N, class Allocator>
51void serialize(Archive &ar, boost::multi_array<T, N, Allocator> &v,
52 const unsigned int version) {
53 split_free(ar, v, version);
54}
55} // namespace serialization
56} // namespace boost
57
58#endif
void serialize(Archive &ar, std::tuple< T... > &pack, unsigned int const)
Serialize std::tuple.
void load(Archive &ar, GpuParticleData::GpuParticle &p, unsigned const)
void save(Archive &ar, GpuParticleData::GpuParticle const &p, unsigned const)