-
Notifications
You must be signed in to change notification settings - Fork 106
/
vector_operations.h
38 lines (37 loc) · 1.05 KB
/
vector_operations.h
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
#pragma once
#include <vector_types.h> // float4
static __device__ float4 operator*(float4 a, float4 b) {
return make_float4(a.x*b.x,
a.y*b.y,
a.z*b.z,
0);
}
static __device__ float4 operator-(float4 a, float4 b) {
return make_float4(a.x-b.x,
a.y-b.y,
a.z-b.z,
0);
}
static __device__ float4 operator-(float4 a) {
return make_float4(-a.x,
-a.y,
-a.z,
0);
}
static __device__ float4 operator+(float4 a, float4 b) {
return make_float4(a.x+b.x,
a.y+b.y,
a.z+b.z,
0);
}
static __device__ float4 operator/(float4 a, float k) {
return make_float4(a.x/k,
a.y/k,
a.z/k,
0);
}
static __device__ float l1_float4 (float4 a) {
return ( fabsf (a.x) +
fabsf (a.y) +
fabsf (a.z))*0.3333333f;
}