Line data Source code
1 1 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : /// \file
5 : /// `blaze::StaticMatrix` is a general-purpose fixed size matrix type. This file
6 : /// implements interoperability of `blaze::StaticMatrix` with our data
7 : /// structures.
8 :
9 : #pragma once
10 :
11 : #include <array>
12 : #include <blaze/math/StaticMatrix.h>
13 : #include <cstddef>
14 : #include <pup.h>
15 : #include <type_traits>
16 :
17 : #include "Options/ParseOptions.hpp"
18 :
19 : namespace PUP {
20 : /// @{
21 : /// Serialization of blaze::StaticMatrix
22 : template <typename Type, size_t M, size_t N, bool SO, blaze::AlignmentFlag AF,
23 : blaze::PaddingFlag PF, typename Tag>
24 : void pup(er& p, blaze::StaticMatrix<Type, M, N, SO, AF, PF, Tag>& t) {
25 : const size_t spacing = t.spacing();
26 : const size_t data_size = spacing * (SO == blaze::rowMajor ? M : N);
27 : if (std::is_fundamental_v<Type>) {
28 : PUParray(p, t.data(), data_size);
29 : } else {
30 : for (size_t i = 0; i < data_size; ++i) {
31 : p | t.data()[i];
32 : }
33 : }
34 : }
35 : template <typename Type, size_t M, size_t N, bool SO, blaze::AlignmentFlag AF,
36 : blaze::PaddingFlag PF, typename Tag>
37 : void operator|(er& p, blaze::StaticMatrix<Type, M, N, SO, AF, PF, Tag>& t) {
38 : pup(p, t);
39 : }
40 : /// @}
41 : } // namespace PUP
42 :
43 : template <typename Type, size_t M, size_t N, bool SO, blaze::AlignmentFlag AF,
44 : blaze::PaddingFlag PF, typename Tag>
45 0 : struct Options::create_from_yaml<
46 : blaze::StaticMatrix<Type, M, N, SO, AF, PF, Tag>> {
47 : template <typename Metavariables>
48 0 : static blaze::StaticMatrix<Type, M, N, SO, AF, PF, Tag> create(
49 : const Options::Option& options) {
50 : return {options.parse_as<std::array<std::array<Type, N>, M>>()};
51 : }
52 : };
|