From bb5ccd2bfcb5d75e1ab4dc563d11864e9f274b48 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Sun, 9 Jun 2024 12:09:50 +0200 Subject: [PATCH] Limit broadcasting to Vectors in H5Easy_Eigen. --- include/highfive/h5easy_bits/H5Easy_Eigen.hpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/include/highfive/h5easy_bits/H5Easy_Eigen.hpp b/include/highfive/h5easy_bits/H5Easy_Eigen.hpp index 6adfc1127..794725436 100644 --- a/include/highfive/h5easy_bits/H5Easy_Eigen.hpp +++ b/include/highfive/h5easy_bits/H5Easy_Eigen.hpp @@ -45,14 +45,13 @@ struct io_impl, T template inline static std::vector mem_shape(const File& file, const std::string& path, - const D& dataset, - int RowsAtCompileTime) { + const D& dataset) { std::vector dims = dataset.getDimensions(); - if (dims.size() == 1 && RowsAtCompileTime == 1) { + if (dims.size() == 1 && T::RowsAtCompileTime == 1) { return std::vector{1, dims[0]}; } - if (dims.size() == 1) { + if (dims.size() == 1 && T::ColsAtCompileTime == 1) { return std::vector{dims[0], 1}; } if (dims.size() == 2) { @@ -80,7 +79,7 @@ struct io_impl, T inline static T load(const File& file, const std::string& path) { DataSet dataset = file.getDataSet(path); - std::vector dims = mem_shape(file, path, dataset, T::RowsAtCompileTime); + std::vector dims = mem_shape(file, path, dataset); return dataset.reshapeMemSpace(dims).template read(); } @@ -107,7 +106,7 @@ struct io_impl, T DataSet dataset = file.getDataSet(path); Attribute attribute = dataset.getAttribute(key); DataSpace dataspace = attribute.getSpace(); - std::vector dims = mem_shape(file, path, dataspace, T::RowsAtCompileTime); + std::vector dims = mem_shape(file, path, dataspace); return attribute.reshapeMemSpace(dims).template read(); } };