-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcuComplex_Op.h
More file actions
283 lines (216 loc) · 10 KB
/
cuComplex_Op.h
File metadata and controls
283 lines (216 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
/**
* Header file used in conjunction with the CUDA complex structures from "cuComplex.h" in order to overload the
* +, -, *, / arithmetic operators for the cuComplex structures. This way, two cuComplex structures of the same type,
* or one cuComplex and one standard data type, can be used in simple arithmetic without directly calling the
* arithmetic functions inside cuComplex.h.
*
*
* @author Travis W. Thompson
* @date 11/28/2017
*
* @file cuComplex_Op.h
* @version 1.0
*
*/
#include <cuComplex.h>
/**
* Complex float overloaded addition operator (cuFloatComplex + cuFloatComplex).
* @param a cuFloatComplex data type.
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex sum of a + b.
*/
template <class T>
cuFloatComplex operator+(cuFloatComplex a, cuFloatComplex b) { return cuCaddf(a, b); }
/**
* Complex float overloaded addition operator (cuFloatComplex + <T>).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a cuFloatComplex data type.
* @param b <T> Standard arithmetic data type (int, long, float, double).
* @return Returns the cuFloatComplex sum of a + b.
*/
template <class T>
cuFloatComplex operator+(cuFloatComplex a, T b) { return cuCaddf(a, make_cuFloatComplex(b, 0)); }
/**
* Complex float overloaded addition operator (<T> + cuFloatComplex).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a <T> Standard arithmetic data type (int, long, float, double).
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex sum of a + b.
*/
template <class T>
cuFloatComplex operator+(T a, cuFloatComplex b) { return cuCaddf(make_cuFloatComplex(a, 0), b); }
/**
* Complex float overloaded subtraction operator (cuFloatComplex - cuFloatComplex).
* @param a cuFloatComplex data type.
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex subtraction of a - b.
*/
cuFloatComplex operator-(cuFloatComplex a, cuFloatComplex b) { return cuCsubf(a, b); }
/**
* Complex float overloaded subtraction operator (cuFloatComplex - <T>).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a cuFloatComplex data type.
* @param b <T> Standard arithmetic data type (int, long, float, double).
* @return Returns the cuFloatComplex subtraction of a - b.
*/
template <class T>
cuFloatComplex operator-(cuFloatComplex a, T b) { return cuCsubf(a, make_cuFloatComplex(b, 0)); }
/**
* Complex float overloaded subtraction operator (<T> - cuFloatComplex).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a <T> Standard arithmetic data type (int, long, float, double).
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex subtraction of a - b.
*/
template <class T>
cuFloatComplex operator-(T a, cuFloatComplex b) { return cuCsubf(make_cuFloatComplex(a, 0), b); }
/**
* Complex float overloaded multiplication operator (cuFloatComplex * cuFloatComplex).
* @param a cuFloatComplex data type.
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex multiplication of a * b.
*/
cuFloatComplex operator*(cuFloatComplex a, cuFloatComplex b) { return cuCmulf(a, b); }
/**
* Complex float overloaded multiplication operator (cuFloatComplex * <T>).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a cuFloatComplex data type.
* @param b <T> Standard arithmetic data type (int, long, float, double).
* @return Returns the cuFloatComplex multiplication of a * b.
*/
template <class T>
cuFloatComplex operator*(cuFloatComplex a, T b) { return cuCmulf(a, make_cuFloatComplex(b, 0)); }
/**
* Complex float overloaded multiplication operator (<T> * cuFloatComplex).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a <T> Standard arithmetic data type (int, long, float, double).
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex multiplication of a * b.
*/
template <class T>
cuFloatComplex operator*(T a, cuFloatComplex b) { return cuCmulf(make_cuFloatComplex(a, 0), b); }
/**
* Complex float overloaded division operator (cuFloatComplex / cuFloatComplex).
* @param a cuFloatComplex data type.
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex division of a / b.
*/
cuFloatComplex operator/(cuFloatComplex a, cuFloatComplex b) { return cuCdivf(a, b); }
/**
* Complex float overloaded division operator (cuFloatComplex / <T>).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a cuFloatComplex data type.
* @param b <T> Standard arithmetic data type (int, long, float, double).
* @return Returns the cuFloatComplex division of a / b.
*/
template <class T>
cuFloatComplex operator/(cuFloatComplex a, T b) { return cuCdivf(a, make_cuFloatComplex(b, 0)); }
/**
* Complex float overloaded division operator (<T> / cuFloatComplex).
* @tparam <T> Standard arithmetic data type (int, long, float, double).
* @param a <T> Standard arithmetic data type (int, long, float, double).
* @param b cuFloatComplex data type.
* @return Returns the cuFloatComplex division of a / b.
*/
template <class T>
cuFloatComplex operator/(T a, cuFloatComplex b) { return cuCdivf(make_cuFloatComplex(a, 0), b); }
/**
* Complex double overloaded addition operator (cuDoubleComplex + cuDoubleComplex).
* @param a cuDoubleComplex data type.
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex sum of a + b.
*/
cuDoubleComplex operator+(cuDoubleComplex a, cuDoubleComplex b) { return cuCadd(a, b); }
/**
* Complex double overloaded addition operator (cuDoubleComplex + <T>).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a cuDoubleComplex data type.
* @param b <T> Standard arithmetic data type (int, long, double, double).
* @return Returns the cuDoubleComplex sum of a + b.
*/
template <class T>
cuDoubleComplex operator+(cuDoubleComplex a, T b) { return cuCadd(a, make_cuDoubleComplex(b, 0)); }
/**
* Complex double overloaded addition operator (<T> + cuDoubleComplex).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a <T> Standard arithmetic data type (int, long, double, double).
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex sum of a + b.
*/
template <class T>
cuDoubleComplex operator+(T a, cuDoubleComplex b) { return cuCadd(make_cuDoubleComplex(a, 0), b); }
/**
* Complex double overloaded subtraction operator (cuDoubleComplex - cuDoubleComplex).
* @param a cuDoubleComplex data type.
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex subtraction of a - b.
*/
cuDoubleComplex operator-(cuDoubleComplex a, cuDoubleComplex b) { return cuCsub(a, b); }
/**
* Complex double overloaded subtraction operator (cuDoubleComplex - <T>).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a cuDoubleComplex data type.
* @param b <T> Standard arithmetic data type (int, long, double, double).
* @return Returns the cuDoubleComplex subtraction of a - b.
*/
template <class T>
cuDoubleComplex operator-(cuDoubleComplex a, T b) { return cuCsub(a, make_cuDoubleComplex(b, 0)); }
/**
* Complex double overloaded subtraction operator (<T> - cuDoubleComplex).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a <T> Standard arithmetic data type (int, long, double, double).
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex subtraction of a - b.
*/
template <class T>
cuDoubleComplex operator-(T a, cuDoubleComplex b) { return cuCsub(make_cuDoubleComplex(a, 0), b); }
/**
* Complex double overloaded multiplication operator (cuDoubleComplex * cuDoubleComplex).
* @param a cuDoubleComplex data type.
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex multiplication of a * b.
*/
cuDoubleComplex operator*(cuDoubleComplex a, cuDoubleComplex b) { return cuCmul(a, b); }
/**
* Complex double overloaded multiplication operator (cuDoubleComplex * <T>).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a cuDoubleComplex data type.
* @param b <T> Standard arithmetic data type (int, long, double, double).
* @return Returns the cuDoubleComplex multiplication of a * b.
*/
template <class T>
cuDoubleComplex operator*(cuDoubleComplex a, T b) { return cuCmul(a, make_cuDoubleComplex(b, 0)); }
/**
* Complex double overloaded multiplication operator (<T> * cuDoubleComplex).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a <T> Standard arithmetic data type (int, long, double, double).
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex multiplication of a * b.
*/
template <class T>
cuDoubleComplex operator*(T a, cuDoubleComplex b) { return cuCmul(make_cuDoubleComplex(a, 0), b); }
/**
* Complex double overloaded division operator (cuDoubleComplex / cuDoubleComplex).
* @param a cuDoubleComplex data type.
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex division of a / b.
*/
cuDoubleComplex operator/(cuDoubleComplex a, cuDoubleComplex b) { return cuCdiv(a, b); }
/**
* Complex double overloaded division operator (cuDoubleComplex / <T>).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a cuDoubleComplex data type.
* @param b <T> Standard arithmetic data type (int, long, double, double).
* @return Returns the cuDoubleComplex division of a / b.
*/
template <class T>
cuDoubleComplex operator/(cuDoubleComplex a, T b) { return cuCdiv(a, make_cuDoubleComplex(b, 0)); }
/**
* Complex double overloaded division operator (<T> / cuDoubleComplex).
* @tparam <T> Standard arithmetic data type (int, long, double, double).
* @param a <T> Standard arithmetic data type (int, long, double, double).
* @param b cuDoubleComplex data type.
* @return Returns the cuDoubleComplex division of a / b.
*/
template <class T>
cuDoubleComplex operator/(T a, cuDoubleComplex b) { return cuCdiv(make_cuDoubleComplex(a, 0), b); }