1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-12-21 13:14:29 +00:00

Lattice serialisation, just HDF5 for the moment

This commit is contained in:
2018-03-26 19:16:16 +01:00
parent 1c680d4b7a
commit 8a0cf0194f
3 changed files with 199 additions and 2 deletions

View File

@@ -2,7 +2,7 @@
#define GRID_SERIALISATION_VECTORUTILS_H
#include <type_traits>
#include <Grid/tensors/Tensors.h>
#include <Grid/tensors/Tensors.h>
namespace Grid {
// Pair IO utilities /////////////////////////////////////////////////////////
@@ -78,6 +78,48 @@ namespace Grid {
typedef typename std::vector<std::vector<typename TensorToVec<T>::type>> type;
};
template <typename T>
void tensorDim(std::vector<size_t> &dim, const T &t, const bool wipe = true)
{
if (wipe)
{
dim.clear();
}
}
template <typename T>
void tensorDim(std::vector<size_t> &dim, const iScalar<T> &t, const bool wipe = true)
{
if (wipe)
{
dim.clear();
}
tensorDim(dim, t._internal, false);
}
template <typename T, int N>
void tensorDim(std::vector<size_t> &dim, const iVector<T, N> &t, const bool wipe = true)
{
if (wipe)
{
dim.clear();
}
dim.push_back(N);
tensorDim(dim, t._internal[0], false);
}
template <typename T, int N>
void tensorDim(std::vector<size_t> &dim, const iMatrix<T, N> &t, const bool wipe = true)
{
if (wipe)
{
dim.clear();
}
dim.push_back(N);
dim.push_back(N);
tensorDim(dim, t._internal[0][0], false);
}
template <typename T>
typename TensorToVec<T>::type tensorToVec(const T &t)
{