1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Grid tensor serialisation

This commit is contained in:
Antonin Portelli 2018-03-08 09:51:22 +00:00
parent 971c2379bd
commit c49be8988b

View File

@ -5,6 +5,7 @@
#include <string>
#include <vector>
#include <H5Cpp.h>
#include <Grid/tensors/Tensors.h>
#include "Hdf5Type.h"
#ifndef H5_NO_NAMESPACE
@ -37,6 +38,12 @@ namespace Grid
template <typename U>
typename std::enable_if<!element<std::vector<U>>::is_number, void>::type
writeDefault(const std::string &s, const std::vector<U> &x);
template <typename T>
void writeDefault(const std::string &s, const iScalar<T> &t);
template <typename T, int N>
void writeDefault(const std::string &s, const iVector<T, N> &t);
template <typename T, int N>
void writeDefault(const std::string &s, const iMatrix<T, N> &t);
private:
template <typename U>
void writeSingleAttribute(const U &x, const std::string &name,
@ -147,6 +154,24 @@ namespace Grid
}
pop();
}
template <typename T>
void Hdf5Writer::writeDefault(const std::string &s, const iScalar<T> &t)
{
writeDefault(s, tensorToVec(t));
}
template <typename T, int N>
void Hdf5Writer::writeDefault(const std::string &s, const iVector<T, N> &t)
{
writeDefault(s, tensorToVec(t));
}
template <typename T, int N>
void Hdf5Writer::writeDefault(const std::string &s, const iMatrix<T, N> &t)
{
writeDefault(s, tensorToVec(t));
}
// Reader template implementation ////////////////////////////////////////////
template <typename U>