cudaMain.cu
1 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
#include "cuComplex.h"
#include "cudaHandleError.h"
#define PI 3.14159
#define BLOCK_SIZE 16
__device__ cuDoubleComplex cMult(cuDoubleComplex a, cuDoubleComplex b)
{
cuDoubleComplex result;
result.x = a.x * b.x - a.y * b.y;
result.y = a.x * b.y + a.y * b.x;
return result;
}
__device__ cuDoubleComplex cMult(cuDoubleComplex a, float b)
{
cuDoubleComplex result;
result.x = a.x * b;
result.y = a.y * b;
return result;
}
__device__ cuDoubleComplex cAdd(cuDoubleComplex a, cuDoubleComplex b)
{
cuDoubleComplex r;
r.x = a.x + b.x;
r.y = a.y + b.y;
return r;
}
__device__ cuDoubleComplex cAdd(cuDoubleComplex a, float b)
{
cuDoubleComplex r;
r.x = a.x + b;
r.y = a.y;
return r;
}
__device__ cuDoubleComplex cExp(cuDoubleComplex a)
{
cuDoubleComplex r;
r.x = exp(a.x) * cos(a.y);
r.y = exp(a.x) * sin(a.y);
return r;
}
__device__ double cMag(cuDoubleComplex a)
{
double r = sqrt(a.x * a.x + a.y * a.y);
return r;
}
#include "cudaKK.h"