Blame view

cudaMain.cu 967 Bytes
da3d4e0e   dmayerich   Initial commit.
1
2
3
4
5
6
7
  #include "cuComplex.h"
  #include "cudaHandleError.h"
  
  
  #define PI 3.14159
  #define BLOCK_SIZE 16
  
52a5fe9d   dmayerich   Added double supp...
8
  __device__ cuDoubleComplex cMult(cuDoubleComplex a, cuDoubleComplex b)
da3d4e0e   dmayerich   Initial commit.
9
  {
52a5fe9d   dmayerich   Added double supp...
10
  	cuDoubleComplex result;
da3d4e0e   dmayerich   Initial commit.
11
12
13
14
15
16
  	result.x = a.x * b.x - a.y * b.y;
  	result.y = a.x * b.y + a.y * b.x;
  
  	return result;
  }
  
52a5fe9d   dmayerich   Added double supp...
17
  __device__ cuDoubleComplex cMult(cuDoubleComplex a, float b)
da3d4e0e   dmayerich   Initial commit.
18
  {
52a5fe9d   dmayerich   Added double supp...
19
  	cuDoubleComplex result;
da3d4e0e   dmayerich   Initial commit.
20
21
22
23
24
25
  	result.x = a.x * b;
  	result.y = a.y * b;
  
  	return result;
  }
  
52a5fe9d   dmayerich   Added double supp...
26
  __device__ cuDoubleComplex cAdd(cuDoubleComplex a, cuDoubleComplex b)
da3d4e0e   dmayerich   Initial commit.
27
  {
52a5fe9d   dmayerich   Added double supp...
28
  	cuDoubleComplex r;
da3d4e0e   dmayerich   Initial commit.
29
30
31
32
33
34
  	r.x = a.x + b.x;
  	r.y = a.y + b.y;
  
  	return r;
  }
  
52a5fe9d   dmayerich   Added double supp...
35
  __device__ cuDoubleComplex cAdd(cuDoubleComplex a, float b)
da3d4e0e   dmayerich   Initial commit.
36
  {
52a5fe9d   dmayerich   Added double supp...
37
  	cuDoubleComplex r;
da3d4e0e   dmayerich   Initial commit.
38
39
40
41
42
43
  	r.x = a.x + b;
  	r.y = a.y;
  
  	return r;
  }
  
52a5fe9d   dmayerich   Added double supp...
44
  __device__ cuDoubleComplex cExp(cuDoubleComplex a)
da3d4e0e   dmayerich   Initial commit.
45
  {
52a5fe9d   dmayerich   Added double supp...
46
  	cuDoubleComplex r;
da3d4e0e   dmayerich   Initial commit.
47
48
49
50
51
52
53
  
  	r.x = exp(a.x) * cos(a.y);
  	r.y = exp(a.x) * sin(a.y);
  
  	return r;
  }
  
52a5fe9d   dmayerich   Added double supp...
54
  __device__ double cMag(cuDoubleComplex a)
da3d4e0e   dmayerich   Initial commit.
55
  {
52a5fe9d   dmayerich   Added double supp...
56
  	double r = sqrt(a.x * a.x + a.y * a.y);
da3d4e0e   dmayerich   Initial commit.
57
58
59
60
  	return r;
  }
  
  #include "cudaKK.h"