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
8
namespace
sisi4s
{
9
class
BinaryTensorHeaderBase
{
10
public
:
11
char
magic
[4];
12
int32_t
version
;
13
char
numberType
[4];
14
int32_t
bytesPerNumber
;
15
int32_t
numbersPerElement
;
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
24
protected
:
25
BinaryTensorHeaderBase
() {}
26
BinaryTensorHeaderBase
(int32_t bytesPerNumber_,
27
int32_t numsPerElement_,
28
int32_t order_)
29
:
version
(
VERSION
)
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
40
class
BinaryTensorHeader
:
public
BinaryTensorHeaderBase
{
41
public
:
42
BinaryTensorHeader
()
43
:
BinaryTensorHeaderBase
() {}
44
template
<
typename
Real>
45
BinaryTensorHeader
(
Tensor<Real>
const
&T)
46
:
BinaryTensorHeaderBase
(sizeof(Real), 1, T.
order
) {}
47
template
<
typename
Real>
48
BinaryTensorHeader
(
Tensor
<
Complex<Real>
>
const
&T)
49
:
BinaryTensorHeaderBase
(sizeof(
Complex
<Real>), 2, T.
order
) {}
50
};
51
52
class
BinaryTensorDimensionHeader
{
53
public
:
54
int32_t
length
;
55
char
indexName
[1];
56
int8_t
flags
;
57
int16_t
reserved
;
58
59
BinaryTensorDimensionHeader
() {}
60
BinaryTensorDimensionHeader
(int32_t length_,
char
indexName_)
61
:
length
(length_) {
62
indexName
[0] = indexName_;
63
}
64
};
65
}
// namespace sisi4s
66
67
#endif
Complex.hpp
Tensor.hpp
sisi4s::BinaryTensorDimensionHeader
Definition
BinaryTensorFormat.hpp:52
sisi4s::BinaryTensorDimensionHeader::length
int32_t length
Definition
BinaryTensorFormat.hpp:54
sisi4s::BinaryTensorDimensionHeader::flags
int8_t flags
Definition
BinaryTensorFormat.hpp:56
sisi4s::BinaryTensorDimensionHeader::BinaryTensorDimensionHeader
BinaryTensorDimensionHeader()
Definition
BinaryTensorFormat.hpp:59
sisi4s::BinaryTensorDimensionHeader::reserved
int16_t reserved
Definition
BinaryTensorFormat.hpp:57
sisi4s::BinaryTensorDimensionHeader::BinaryTensorDimensionHeader
BinaryTensorDimensionHeader(int32_t length_, char indexName_)
Definition
BinaryTensorFormat.hpp:60
sisi4s::BinaryTensorDimensionHeader::indexName
char indexName[1]
Definition
BinaryTensorFormat.hpp:55
sisi4s::BinaryTensorHeaderBase
Definition
BinaryTensorFormat.hpp:9
sisi4s::BinaryTensorHeaderBase::magic
char magic[4]
Definition
BinaryTensorFormat.hpp:11
sisi4s::BinaryTensorHeaderBase::numbersPerElement
int32_t numbersPerElement
Definition
BinaryTensorFormat.hpp:15
sisi4s::BinaryTensorHeaderBase::IEEE
static constexpr char const * IEEE
Definition
BinaryTensorFormat.hpp:22
sisi4s::BinaryTensorHeaderBase::version
int32_t version
Definition
BinaryTensorFormat.hpp:12
sisi4s::BinaryTensorHeaderBase::reserved
int32_t reserved
Definition
BinaryTensorFormat.hpp:18
sisi4s::BinaryTensorHeaderBase::BinaryTensorHeaderBase
BinaryTensorHeaderBase()
Definition
BinaryTensorFormat.hpp:25
sisi4s::BinaryTensorHeaderBase::order
int32_t order
Definition
BinaryTensorFormat.hpp:16
sisi4s::BinaryTensorHeaderBase::numberType
char numberType[4]
Definition
BinaryTensorFormat.hpp:13
sisi4s::BinaryTensorHeaderBase::VERSION
static constexpr int32_t VERSION
Definition
BinaryTensorFormat.hpp:21
sisi4s::BinaryTensorHeaderBase::bytesPerNumber
int32_t bytesPerNumber
Definition
BinaryTensorFormat.hpp:14
sisi4s::BinaryTensorHeaderBase::BinaryTensorHeaderBase
BinaryTensorHeaderBase(int32_t bytesPerNumber_, int32_t numsPerElement_, int32_t order_)
Definition
BinaryTensorFormat.hpp:26
sisi4s::BinaryTensorHeaderBase::MAGIC
static constexpr char const * MAGIC
Definition
BinaryTensorFormat.hpp:20
sisi4s::BinaryTensorHeaderBase::flags
int32_t flags
Definition
BinaryTensorFormat.hpp:17
sisi4s::BinaryTensorHeader
Definition
BinaryTensorFormat.hpp:40
sisi4s::BinaryTensorHeader::BinaryTensorHeader
BinaryTensorHeader(Tensor< Real > const &T)
Definition
BinaryTensorFormat.hpp:45
sisi4s::BinaryTensorHeader::BinaryTensorHeader
BinaryTensorHeader()
Definition
BinaryTensorFormat.hpp:42
sisi4s::BinaryTensorHeader::BinaryTensorHeader
BinaryTensorHeader(Tensor< Complex< Real > > const &T)
Definition
BinaryTensorFormat.hpp:48
sisi4s
Definition
Algorithm.hpp:10
sisi4s::Tensor
CTF::Tensor< F > Tensor
Definition
Tensor.hpp:9
sisi4s::Complex
std::complex< Real > Complex
Definition
Complex.hpp:10
src
util
BinaryTensorFormat.hpp
Generated on Tue Jan 1 1980 00:00:00 for sisi4s by
1.9.7