chihaya
Validating delayed array operations in HDF5
Loading...
Searching...
No Matches
binary_arithmetic.hpp
Go to the documentation of this file.
1#ifndef CHIHAYA_BINARY_ARITHMETIC_HPP
2#define CHIHAYA_BINARY_ARITHMETIC_HPP
3
4#include "H5Cpp.h"
5#include "ritsuko/ritsuko.hpp"
6
7#include <stdexcept>
8#include <vector>
9#include <string>
10
11#include "utils_public.hpp"
12#include "utils_misc.hpp"
13#include "utils_nary.hpp"
14
20namespace chihaya {
21
30inline ArrayDetails validate_binary_arithmetic(const H5::Group& group, const ritsuko::Version& version, const Options& options) {
31 auto left_details = fetch_numeric_seed(group, "left", version, options);
32 auto right_details = fetch_numeric_seed(group, "right", version, options);
33
34 if (!options.details_only) {
35 if (!are_dimensions_equal(left_details.dimensions, right_details.dimensions)) {
36 throw std::runtime_error("'left' and 'right' should have the same dimensions");
37 }
38 }
39
40 auto method = load_scalar_string_dataset(group, "method");
41 if (!options.details_only) {
42 if (!is_valid_arithmetic_operation(method)) {
43 throw std::runtime_error("unrecognized 'method' (" + method + ")");
44 }
45 }
46
47 left_details.type = determine_arithmetic_output_type(left_details.type, right_details.type, method);
48 return left_details;
49}
50
51}
52
53#endif
Namespace for all chihaya functions.
Definition binary_arithmetic.hpp:20
ArrayDetails validate_binary_arithmetic(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition binary_arithmetic.hpp:30
Details about an array.
Definition utils_public.hpp:37
Validation options.
Definition utils_public.hpp:67
bool details_only
Definition utils_public.hpp:72
Various public utilities.