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/hdf5/hdf5.hpp"
6#include "ritsuko/ritsuko.hpp"
7
8#include <stdexcept>
9#include <vector>
10#include <string>
11
12#include "utils_public.hpp"
13#include "utils_arithmetic.hpp"
14#include "utils_misc.hpp"
15#include "utils_unary.hpp"
16
22namespace chihaya {
23
28namespace binary_arithmetic {
29
38inline ArrayDetails validate(const H5::Group& handle, const ritsuko::Version& version, Options& options) {
39 auto left_details = internal_arithmetic::fetch_seed(handle, "left", version, options);
40 auto right_details = internal_arithmetic::fetch_seed(handle, "right", version, options);
41
42 if (!options.details_only) {
43 if (!internal_misc::are_dimensions_equal(left_details.dimensions, right_details.dimensions)) {
44 throw std::runtime_error("'left' and 'right' should have the same dimensions");
45 }
46 }
47
48 auto method = internal_unary::load_method(handle);
49 if (!options.details_only) {
50 if (!internal_arithmetic::is_valid_operation(method)) {
51 throw std::runtime_error("unrecognized 'method' (" + method + ")");
52 }
53 }
54
55 left_details.type = internal_arithmetic::determine_output_type(left_details.type, right_details.type, method);
56 return left_details;
57}
58
59}
60
61}
62
63#endif
ArrayDetails validate(const H5::Group &handle, const ritsuko::Version &version, Options &options)
Definition: binary_arithmetic.hpp:38
Namespace for all chihaya functions.
Definition: binary_arithmetic.hpp:22
Details about an array.
Definition: utils_public.hpp:36
Validation options.
Definition: utils_public.hpp:66
bool details_only
Definition: utils_public.hpp:71
Various public utilities.