v0.14.0
src
ftensor
src
FTensor
Tensor2
Tensor2_constructor.hpp
Go to the documentation of this file.
1
/* A helper class that allows simple initialization of the Tensor2,
2
but only if it has the correct number of elements. There are
3
specializations for column-major and row-major orderings. */
4
5
#pragma once
6
7
namespace
FTensor
8
{
9
template
<
class
T,
int
Tensor_Dim0,
int
Tensor_Dim1, Layout layout>
10
class
Tensor2_constructor
;
11
12
/* Column major versions */
13
14
template
<
class
T>
class
Tensor2_constructor
<T, 1, 2,
column_major
>
15
{
16
public
:
17
Tensor2_constructor
(T data[1][2], T d00, T d01)
18
{
19
data[0][0] = d00;
20
data[0][1] = d01;
21
}
22
};
23
24
template
<
class
T>
class
Tensor2_constructor
<T, 2, 1,
column_major
>
25
{
26
public
:
27
Tensor2_constructor
(T data[2][1], T d00, T d10)
28
{
29
data[0][0] = d00;
30
data[1][0] = d10;
31
}
32
};
33
34
template
<
class
T>
class
Tensor2_constructor
<T, 2, 2,
column_major
>
35
{
36
public
:
37
Tensor2_constructor
(T data[2][2], T d00, T d01, T d10, T d11)
38
{
39
data[0][0] = d00;
40
data[0][1] = d01;
41
data[1][0] = d10;
42
data[1][1] = d11;
43
}
44
};
45
46
template
<
class
T>
class
Tensor2_constructor
<T, 3, 2,
column_major
>
47
{
48
public
:
49
Tensor2_constructor
(T data[3][2], T d00, T d01, T d10, T d11, T d20, T d21)
50
{
51
data[0][0] = d00;
52
data[0][1] = d01;
53
data[1][0] = d10;
54
data[1][1] = d11;
55
data[2][0] = d20;
56
data[2][1] = d21;
57
}
58
};
59
60
template
<
class
T>
class
Tensor2_constructor
<T, 3, 3,
column_major
>
61
{
62
public
:
63
Tensor2_constructor
(T data[3][3], T d00, T d01, T d02, T d10, T d11, T d12,
64
T d20, T d21, T d22)
65
{
66
data[0][0] = d00;
67
data[0][1] = d01;
68
data[0][2] = d02;
69
data[1][0] = d10;
70
data[1][1] = d11;
71
data[1][2] = d12;
72
data[2][0] = d20;
73
data[2][1] = d21;
74
data[2][2] = d22;
75
}
76
};
77
78
template
<
class
T>
class
Tensor2_constructor
<T, 4, 4,
column_major
>
79
{
80
public
:
81
Tensor2_constructor
(T data[4][4], T d00, T d01, T d02, T d03, T d10, T d11,
82
T d12, T d13, T d20, T d21, T d22, T d23, T d30, T d31,
83
T d32, T d33)
84
{
85
data[0][0] = d00;
86
data[0][1] = d01;
87
data[0][2] = d02;
88
data[0][3] = d03;
89
data[1][0] = d10;
90
data[1][1] = d11;
91
data[1][2] = d12;
92
data[1][3] = d13;
93
data[2][0] = d20;
94
data[2][1] = d21;
95
data[2][2] = d22;
96
data[2][3] = d23;
97
data[3][0] = d30;
98
data[3][1] = d31;
99
data[3][2] = d32;
100
data[3][3] = d33;
101
}
102
};
103
104
/* Row major versions */
105
106
template
<
class
T>
class
Tensor2_constructor
<T, 1, 2,
row_major
>
107
{
108
public
:
109
Tensor2_constructor
(T data[2][1], T d00, T d01)
110
{
111
data[0][0] = d00;
112
data[1][0] = d01;
113
}
114
};
115
116
template
<
class
T>
class
Tensor2_constructor
<T, 2, 2,
row_major
>
117
{
118
public
:
119
Tensor2_constructor
(T data[2][2], T d00, T d01, T d10, T d11)
120
{
121
data[0][0] = d00;
122
data[1][0] = d01;
123
data[0][1] = d10;
124
data[1][1] = d11;
125
}
126
};
127
128
template
<
class
T>
class
Tensor2_constructor
<T, 2, 1,
row_major
>
129
{
130
public
:
131
Tensor2_constructor
(T data[1][2], T d00, T d10)
132
{
133
data[0][0] = d00;
134
data[0][1] = d10;
135
}
136
};
137
138
template
<
class
T>
class
Tensor2_constructor
<T, 3, 2,
row_major
>
139
{
140
public
:
141
Tensor2_constructor
(T data[2][3], T d00, T d01, T d10, T d11, T d20, T d21)
142
{
143
data[0][0] = d00;
144
data[1][0] = d01;
145
data[0][1] = d10;
146
data[1][1] = d11;
147
data[0][2] = d20;
148
data[1][2] = d21;
149
}
150
};
151
152
template
<
class
T>
class
Tensor2_constructor
<T, 3, 3,
row_major
>
153
{
154
public
:
155
Tensor2_constructor
(T data[3][3], T d00, T d01, T d02, T d10, T d11, T d12,
156
T d20, T d21, T d22)
157
{
158
data[0][0] = d00;
159
data[1][0] = d01;
160
data[2][0] = d02;
161
data[0][1] = d10;
162
data[1][1] = d11;
163
data[2][1] = d12;
164
data[0][2] = d20;
165
data[1][2] = d21;
166
data[2][2] = d22;
167
}
168
};
169
170
template
<
class
T>
class
Tensor2_constructor
<T, 4, 4,
row_major
>
171
{
172
public
:
173
Tensor2_constructor
(T data[4][4], T d00, T d01, T d02, T d03, T d10, T d11,
174
T d12, T d13, T d20, T d21, T d22, T d23, T d30, T d31,
175
T d32, T d33)
176
{
177
data[0][0] = d00;
178
data[1][0] = d01;
179
data[2][0] = d02;
180
data[3][0] = d03;
181
data[0][1] = d10;
182
data[1][1] = d11;
183
data[2][1] = d12;
184
data[3][1] = d13;
185
data[0][2] = d20;
186
data[1][2] = d21;
187
data[2][2] = d22;
188
data[3][2] = d23;
189
data[0][3] = d30;
190
data[1][3] = d31;
191
data[2][3] = d32;
192
data[3][3] = d33;
193
}
194
};
195
}
FTensor
JSON compatible output.
Definition:
Christof_constructor.hpp:6
FTensor::Tensor2_constructor< T, 1, 2, column_major >::Tensor2_constructor
Tensor2_constructor(T data[1][2], T d00, T d01)
Definition:
Tensor2_constructor.hpp:17
FTensor::row_major
@ row_major
Definition:
Layout.hpp:13
FTensor::Tensor2_constructor< T, 4, 4, column_major >::Tensor2_constructor
Tensor2_constructor(T data[4][4], T d00, T d01, T d02, T d03, T d10, T d11, T d12, T d13, T d20, T d21, T d22, T d23, T d30, T d31, T d32, T d33)
Definition:
Tensor2_constructor.hpp:81
FTensor::Tensor2_constructor< T, 3, 3, row_major >::Tensor2_constructor
Tensor2_constructor(T data[3][3], T d00, T d01, T d02, T d10, T d11, T d12, T d20, T d21, T d22)
Definition:
Tensor2_constructor.hpp:155
FTensor::Tensor2_constructor
Definition:
Tensor2_constructor.hpp:10
FTensor::Tensor2_constructor< T, 4, 4, row_major >::Tensor2_constructor
Tensor2_constructor(T data[4][4], T d00, T d01, T d02, T d03, T d10, T d11, T d12, T d13, T d20, T d21, T d22, T d23, T d30, T d31, T d32, T d33)
Definition:
Tensor2_constructor.hpp:173
FTensor::Tensor2_constructor< T, 3, 2, column_major >::Tensor2_constructor
Tensor2_constructor(T data[3][2], T d00, T d01, T d10, T d11, T d20, T d21)
Definition:
Tensor2_constructor.hpp:49
FTensor::Tensor2_constructor< T, 2, 2, column_major >::Tensor2_constructor
Tensor2_constructor(T data[2][2], T d00, T d01, T d10, T d11)
Definition:
Tensor2_constructor.hpp:37
FTensor::Tensor2_constructor< T, 2, 1, row_major >::Tensor2_constructor
Tensor2_constructor(T data[1][2], T d00, T d10)
Definition:
Tensor2_constructor.hpp:131
FTensor::column_major
@ column_major
Definition:
Layout.hpp:12
FTensor::Tensor2_constructor< T, 3, 2, row_major >::Tensor2_constructor
Tensor2_constructor(T data[2][3], T d00, T d01, T d10, T d11, T d20, T d21)
Definition:
Tensor2_constructor.hpp:141
FTensor::Tensor2_constructor< T, 2, 1, column_major >::Tensor2_constructor
Tensor2_constructor(T data[2][1], T d00, T d10)
Definition:
Tensor2_constructor.hpp:27
FTensor::Tensor2_constructor< T, 2, 2, row_major >::Tensor2_constructor
Tensor2_constructor(T data[2][2], T d00, T d01, T d10, T d11)
Definition:
Tensor2_constructor.hpp:119
FTensor::Tensor2_constructor< T, 3, 3, column_major >::Tensor2_constructor
Tensor2_constructor(T data[3][3], T d00, T d01, T d02, T d10, T d11, T d12, T d20, T d21, T d22)
Definition:
Tensor2_constructor.hpp:63
FTensor::Tensor2_constructor< T, 1, 2, row_major >::Tensor2_constructor
Tensor2_constructor(T data[2][1], T d00, T d01)
Definition:
Tensor2_constructor.hpp:109
Generated by
Doxygen
1.8.17 and hosted at