sisi4s
Loading...
Searching...
No Matches
BinaryTensorFormat.hpp
Go to the documentation of this file.
1#ifndef BINARY_TENSOR_FORMAT_DEFINED
2#define BINARY_TENSOR_FORMAT_DEFINED
3
4#include <math/Complex.hpp>
5#include <cstring>
6#include <util/Tensor.hpp>
7
8namespace sisi4s {
10public:
11 char magic[4];
12 int32_t version;
13 char numberType[4];
16 int32_t order;
17 int32_t flags;
18 int32_t reserved;
19
20 static constexpr char const *MAGIC = "TENS";
21 static constexpr int32_t VERSION = 0x09000;
22 static constexpr char const *IEEE = "IEEE";
23
24protected:
26 BinaryTensorHeaderBase(int32_t bytesPerNumber_,
27 int32_t numsPerElement_,
28 int32_t order_)
30 , bytesPerNumber(bytesPerNumber_)
31 , numbersPerElement(numsPerElement_)
32 , order(order_)
33 , flags(0)
34 , reserved(0) {
35 std::strncpy(magic, MAGIC, sizeof(magic));
36 std::strncpy(numberType, IEEE, sizeof(numberType));
37 }
38};
39
41public:
44 template <typename Real>
46 : BinaryTensorHeaderBase(sizeof(Real), 1, T.order) {}
47 template <typename Real>
49 : BinaryTensorHeaderBase(sizeof(Complex<Real>), 2, T.order) {}
50};
51
53public:
54 int32_t length;
55 char indexName[1];
56 int8_t flags;
57 int16_t reserved;
58
60 BinaryTensorDimensionHeader(int32_t length_, char indexName_)
61 : length(length_) {
62 indexName[0] = indexName_;
63 }
64};
65} // namespace sisi4s
66
67#endif
Definition BinaryTensorFormat.hpp:52
int32_t length
Definition BinaryTensorFormat.hpp:54
int8_t flags
Definition BinaryTensorFormat.hpp:56
BinaryTensorDimensionHeader()
Definition BinaryTensorFormat.hpp:59
int16_t reserved
Definition BinaryTensorFormat.hpp:57
BinaryTensorDimensionHeader(int32_t length_, char indexName_)
Definition BinaryTensorFormat.hpp:60
char indexName[1]
Definition BinaryTensorFormat.hpp:55
Definition BinaryTensorFormat.hpp:9
char magic[4]
Definition BinaryTensorFormat.hpp:11
int32_t numbersPerElement
Definition BinaryTensorFormat.hpp:15
static constexpr char const * IEEE
Definition BinaryTensorFormat.hpp:22
int32_t version
Definition BinaryTensorFormat.hpp:12
int32_t reserved
Definition BinaryTensorFormat.hpp:18
BinaryTensorHeaderBase()
Definition BinaryTensorFormat.hpp:25
int32_t order
Definition BinaryTensorFormat.hpp:16
char numberType[4]
Definition BinaryTensorFormat.hpp:13
static constexpr int32_t VERSION
Definition BinaryTensorFormat.hpp:21
int32_t bytesPerNumber
Definition BinaryTensorFormat.hpp:14
BinaryTensorHeaderBase(int32_t bytesPerNumber_, int32_t numsPerElement_, int32_t order_)
Definition BinaryTensorFormat.hpp:26
static constexpr char const * MAGIC
Definition BinaryTensorFormat.hpp:20
int32_t flags
Definition BinaryTensorFormat.hpp:17
Definition BinaryTensorFormat.hpp:40
BinaryTensorHeader(Tensor< Real > const &T)
Definition BinaryTensorFormat.hpp:45
BinaryTensorHeader()
Definition BinaryTensorFormat.hpp:42
BinaryTensorHeader(Tensor< Complex< Real > > const &T)
Definition BinaryTensorFormat.hpp:48
Definition Algorithm.hpp:10
CTF::Tensor< F > Tensor
Definition Tensor.hpp:9
std::complex< Real > Complex
Definition Complex.hpp:10