179 const std::string& name)
const {
183 H5::DataSet dataset = loc.openDataSet(name);
185 H5::DataSpace dp = dataset.getSpace();
188 dp.getSimpleExtentDims(dims,
nullptr);
190 hsize_t matRows = dims[0];
191 hsize_t matCols = dims[1];
193 matrix.derived().resize(matRows, matCols);
194 if (matrix.size() == 0) {
198 hsize_t matColSize = matrix.derived().outerStride();
200 hsize_t fileRows = matCols;
202 hsize_t fStride[2] = {1, fileRows};
203 hsize_t fCount[2] = {1, 1};
204 hsize_t fBlock[2] = {1, fileRows};
206 hsize_t mStride[2] = {matColSize, 1};
207 hsize_t mCount[2] = {1, 1};
208 hsize_t mBlock[2] = {matCols, 1};
210 hsize_t mDim[2] = {matCols, matColSize};
211 H5::DataSpace mspace(2, mDim);
213 for (hsize_t i = 0; i < matRows; i++) {
214 hsize_t fStart[2] = {i, 0};
215 hsize_t mStart[2] = {0, i};
216 dp.selectHyperslab(H5S_SELECT_SET, fCount, fStart, fStride, fBlock);
217 mspace.selectHyperslab(H5S_SELECT_SET, mCount, mStart, mStride, mBlock);
218 dataset.read(matrix.derived().data(), *dataType, mspace, dp);
223 typename std::enable_if<std::is_fundamental<T>::value>::type
ReadData(
224 const CptLoc& loc, std::vector<T>& v,
const std::string& name)
const {
226 H5::DataSet dataset = loc.openDataSet(name);
227 H5::DataSpace dp = dataset.getSpace();
232 dp.getSimpleExtentDims(dims,
nullptr);
239 dataset.read(&(v[0]), *dataType);
240 }
catch (H5::Exception&) {
241 std::stringstream message;
242 message <<
"Could not read " << name <<
" from " <<
loc_.getFileName()
243 <<
":" <<
path_ << std::endl;
244 throw std::runtime_error(message.str());
249 const std::string& name)
const {
251 H5::DataSet dataset = loc.openDataSet(name);
252 H5::DataSpace dp = dataset.getSpace();
257 dp.getSimpleExtentDims(dims,
nullptr);
259 std::vector<char*> temp(dims[0]);
264 dataset.read(temp.data(), *dataType);
265 }
catch (H5::Exception&) {
266 std::stringstream message;
267 message <<
"Could not read " << name <<
" from " <<
loc_.getFileName()
268 <<
":" <<
path_ << std::endl;
269 throw std::runtime_error(message.str());
272 for (
char* s : temp) {
273 v.push_back(std::string(s));