1
0
mirror of https://github.com/paboyle/Grid.git synced 2026-01-09 03:19:34 +00:00

more general implementation of the precision interface for serialisers

This commit is contained in:
2018-05-07 21:17:46 +01:00
parent 25828746f3
commit 54d789204f
2 changed files with 40 additions and 3 deletions

View File

@@ -60,8 +60,14 @@ namespace Grid {
void write(const std::string &s, const iVector<U, N> &output);
template <typename U, int N>
void write(const std::string &s, const iMatrix<U, N> &output);
void scientificFormat(const bool set);
bool isScientific(void);
void setPrecision(const unsigned int prec);
unsigned int getPrecision(void);
private:
T *upcast;
T *upcast;
bool scientific_{false};
unsigned int prec_{0};
};
// Static abstract reader
@@ -155,6 +161,30 @@ namespace Grid {
{
upcast->writeDefault(s, tensorToVec(output));
}
template <typename T>
void Writer<T>::scientificFormat(const bool set)
{
scientific_ = set;
}
template <typename T>
bool Writer<T>::isScientific(void)
{
return scientific_;
}
template <typename T>
void Writer<T>::setPrecision(const unsigned int prec)
{
prec_ = prec;
}
template <typename T>
unsigned int Writer<T>::getPrecision(void)
{
return prec_;
}
// Reader template implementation
template <typename T>