-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcuVec3.h
More file actions
52 lines (41 loc) · 1.83 KB
/
cuVec3.h
File metadata and controls
52 lines (41 loc) · 1.83 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
#ifndef _CUVEC3_H_
#define _CUVEC3_H_
template<class REAL>
struct cuVec3
{
REAL x, y, z;
__host__ __device__ cuVec3() {}
__host__ __device__ cuVec3(const REAL v) : x(v), y(v), z(v) {}
__host__ __device__ cuVec3(const REAL _x, const REAL _y, const REAL _z) : x(_x), y(_y), z(_z) {}
__host__ __device__ cuVec3 operator=(const cuVec3<float> v) {x = v.x; y = v.y; z = v.z; return *this;};
__host__ __device__ cuVec3 operator=(const cuVec3<double > v) {x = v.x; y = v.y; z = v.z; return *this;};
__host__ __device__ REAL operator*(const cuVec3<REAL> v) const {return (x*v.x + y*v.y + z*v.z);}
__host__ __device__ cuVec3 operator*(const REAL v) const {return cuVec3(x*v, y*v, z*v);}
// __host__ __device__ cuVec3 operator+(const cuVec3<REAL> v) const {return cuVec3(x+v.x, y+v.y, z+v.z);}
__host__ __device__ cuVec3 operator-(const cuVec3<REAL> v) const {return cuVec3(x-v.x, y-v.y, z-v.z);}
__host__ __device__ cuVec3 operator%(const cuVec3<REAL> v) const {return cuVec3(x*v.y - y*v.x, y*v.z-z*v.y, z*v.x - x*v.z);}
__host__ __device__ cuVec3 operator-() const {return cuVec3(-x, -y, -z);}
__host__ __device__ cuVec3 operator+(const cuVec3<float> v) const {return cuVec3(x+v.x, y+v.y, z+v.z);}
__host__ __device__ cuVec3 operator+(const cuVec3<double > v) const {return cuVec3(x+v.x, y+v.y, z+v.z);}
__host__ __device__ cuVec3 operator += (const cuVec3<REAL> v)
{
*this = *this + v;
return *this;
}
__host__ __device__ cuVec3 operator -= (const cuVec3<REAL> v)
{
*this = *this - v;
return *this;
}
__host__ __device__ cuVec3 operator *= (const REAL s)
{
*this = *this * s;
return *this;
}
__host__ __device__ friend cuVec3 operator * (const REAL s ,const cuVec3<REAL> v)
{
return v*s;
}
__host__ __device__ REAL norm2() const {return (*this)*(*this);};
};
#endif /* _CUVEC3_H_ */