1#ifndef CHIHAYA_TRANSPOSE_HPP
2#define CHIHAYA_TRANSPOSE_HPP
5#include "ritsuko/ritsuko.hpp"
15#include "utils_misc.hpp"
16#include "utils_type.hpp"
28template<
typename Perm_>
29std::vector<std::size_t> check_permutation(
const H5::DataSet& phandle, hsize_t plen,
const std::vector<std::size_t>& input_dimensions,
bool details_only) {
31 throw std::runtime_error(
"length should match dimensionality of 'seed'");
35 phandle.read(permutation.data(), ritsuko::hdf5::as_numeric_datatype<Perm_>());
38 for (I<
decltype(plen)> p = 0; p < plen; ++p) {
39 const auto current = permutation[p];
41 throw std::runtime_error(
"expected non-negative indices");
44 throw std::runtime_error(
"detected out-of-bounds indices");
46 new_dimensions[p] = input_dimensions[permutation[p]];
50 std::sort(permutation.begin(), permutation.end());
51 for (I<
decltype(plen)> p = 0; p < plen; ++p) {
53 throw std::runtime_error(
"indices should be unique");
58 return new_dimensions;
79 auto shandle = group.openGroup(
"seed");
80 seed_details =
validate(shandle, version, options);
82 std::throw_with_nested(std::runtime_error(
"failed to validate 'seed'"));
86 auto phandle = group.openDataSet(
"permutation");
87 auto pspace = phandle.getSpace();
88 if (pspace.getSimpleExtentNdims() != 1) {
89 throw std::runtime_error(
"expected a 1-dimensional dataset");
92 pspace.getSimpleExtentDims(&plen);
94 if (version.lt(1, 1, 0)) {
96 if (!ritsuko::hdf5::exceeds_integer_limit(phandle, 64,
true)) {
98 }
else if (!ritsuko::hdf5::exceeds_integer_limit(phandle, 64,
false)) {
101 throw create_integer_error_0_99(phandle.getTypeClass());
104 if (ritsuko::hdf5::exceeds_integer_limit(phandle, 64,
false)) {
105 throw std::runtime_error(
"datatype should fit in a 64-bit unsigned integer");
110 std::throw_with_nested(std::runtime_error(
"failed to validate 'permutation'"));
Namespace for all chihaya functions.
Definition binary_arithmetic.hpp:21
ArrayDetails validate_transpose(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition transpose.hpp:76
ArrayDetails validate(const H5::Group &group, const ritsuko::Version &version, const Options &options)
Definition validate.hpp:96
Container_ create(Value_ x, Args_ &&... args)
constexpr bool is_equal(Left_ left, Right_ right)
constexpr bool is_greater_than_or_equal(Left_ left, Right_ right)
Details about an array.
Definition utils_public.hpp:38
std::vector< std::size_t > dimensions
Definition utils_public.hpp:58
Options for validate().
Definition utils_public.hpp:79
bool details_only
Definition utils_public.hpp:84
Various public utilities.