MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
operators.h
Go to the documentation of this file.
1 
12 #ifndef _MAGMA_OPERATORS_H_
13 #define _MAGMA_OPERATORS_H_
14 
15 /*************************************************************
16  * cuDoubleComplex
17  */
18 
19 __host__ __device__ static __inline__ cuDoubleComplex
20 operator-(const cuDoubleComplex &a)
21 {
22  return make_cuDoubleComplex(-a.x, -a.y);
23 }
24 
25 __host__ __device__ static __inline__ cuDoubleComplex
26 operator+(const cuDoubleComplex a, const cuDoubleComplex b)
27 {
28  return make_cuDoubleComplex(a.x + b.x, a.y + b.y);
29 }
30 
31 __host__ __device__ static __inline__ void
32 operator+=(cuDoubleComplex &a, const cuDoubleComplex b)
33 {
34  a.x += b.x; a.y += b.y;
35 }
36 
37 __host__ __device__ static __inline__ cuDoubleComplex
38 operator-(const cuDoubleComplex a, const cuDoubleComplex b)
39 {
40  return make_cuDoubleComplex(a.x - b.x, a.y - b.y);
41 }
42 
43 __host__ __device__ static __inline__ void
44 operator-=(cuDoubleComplex &a, const cuDoubleComplex b)
45 {
46  a.x -= b.x; a.y -= b.y;
47 }
48 
49 __host__ __device__ static __inline__ cuDoubleComplex
50 operator*(const cuDoubleComplex a, const cuDoubleComplex b)
51 {
52  return make_cuDoubleComplex(a.x * b.x - a.y * b.y, a.y * b.x + a.x * b.y);
53 }
54 
55 __host__ __device__ static __inline__ cuDoubleComplex
56 operator*(const cuDoubleComplex a, const double s)
57 {
58  return make_cuDoubleComplex(a.x * s, a.y * s);
59 }
60 
61 __host__ __device__ static __inline__ cuDoubleComplex
62 operator*(const double s, const cuDoubleComplex a)
63 {
64  return make_cuDoubleComplex(a.x * s, a.y * s);
65 }
66 
67 __host__ __device__ static __inline__ void
68 operator*=(cuDoubleComplex &a, const cuDoubleComplex b)
69 {
70  double tmp = a.y * b.x + a.x * b.y;
71  a.x = a.x * b.x - a.y * b.y;
72  a.y = tmp;
73 }
74 
75 __host__ __device__ static __inline__ void
76 operator*=(cuDoubleComplex &a, const double s)
77 {
78  a.x *= s; a.y *= s;
79 }
80 
81 /*************************************************************
82  * cuFloatComplex
83  */
84 
85 __host__ __device__ static __inline__ cuFloatComplex
86 operator-(const cuFloatComplex &a)
87 {
88  return make_cuFloatComplex(-a.x, -a.y);
89 }
90 
91 __host__ __device__ static __inline__ cuFloatComplex
92 operator+(const cuFloatComplex a, const cuFloatComplex b)
93 {
94  return make_cuFloatComplex(a.x + b.x, a.y + b.y);
95 }
96 
97 __host__ __device__ static __inline__ void
98 operator+=(cuFloatComplex &a, const cuFloatComplex b)
99 {
100  a.x += b.x; a.y += b.y;
101 }
102 
103 __host__ __device__ static __inline__ cuFloatComplex
104 operator-(const cuFloatComplex a, const cuFloatComplex b)
105 {
106  return make_cuFloatComplex(a.x - b.x, a.y - b.y);
107 }
108 
109 __host__ __device__ static __inline__ void
110 operator-=(cuFloatComplex &a, const cuFloatComplex b)
111 {
112  a.x -= b.x; a.y -= b.y;
113 }
114 
115 __host__ __device__ static __inline__ cuFloatComplex
116 operator*(const cuFloatComplex a, const cuFloatComplex b)
117 {
118  return make_cuFloatComplex(a.x * b.x - a.y * b.y, a.y * b.x + a.x * b.y);
119 }
120 
121 __host__ __device__ static __inline__ cuFloatComplex
122 operator*(const cuFloatComplex a, const float s)
123 {
124  return make_cuFloatComplex(a.x * s, a.y * s);
125 }
126 
127 __host__ __device__ static __inline__ cuFloatComplex
128 operator*(const float s, const cuFloatComplex a)
129 {
130  return make_cuFloatComplex(a.x * s, a.y * s);
131 }
132 
133 __host__ __device__ static __inline__ void
134 operator*=(cuFloatComplex &a, const cuFloatComplex b)
135 {
136  float tmp = a.y * b.x + a.x * b.y;
137  a.x = a.x * b.x - a.y * b.y;
138  a.y = tmp;
139 }
140 
141 __host__ __device__ static __inline__ void
142 operator*=(cuFloatComplex &a, const float s)
143 {
144  a.x *= s; a.y *= s;
145 }
146 
147 #endif
148 
149 
150