summaryrefslogtreecommitdiff
path: root/test/linalg_test.cu
blob: 4e9c98347dd692e33ab09b66a02de7290abb3685 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//-*-c-*-

#include "linalg.h"

extern "C"
{

__global__ void float3add(float3 *a, float3 *b, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = a[idx] + b[idx];
}

__global__ void float3addequal(float3 *a, float3 *b)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	a[idx] += b[idx];
}

__global__ void float3sub(float3 *a, float3 *b, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = a[idx] - b[idx];
}

__global__ void float3subequal(float3 *a, float3 *b)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	a[idx] -= b[idx];
}

__global__ void float3addfloat(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = a[idx] + c;
}

__global__ void float3addfloatequal(float3 *a, float c)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	a[idx] += c;
}

__global__ void floataddfloat3(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = c + a[idx];
}

__global__ void float3subfloat(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = a[idx] - c;
}

__global__ void float3subfloatequal(float3 *a, float c)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	a[idx] -= c;
}

__global__ void floatsubfloat3(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = c - a[idx];
}

__global__ void float3mulfloat(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = a[idx]*c;
}

__global__ void float3mulfloatequal(float3 *a, float c)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	a[idx] *= c;
}

__global__ void floatmulfloat3(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = c*a[idx];
}

__global__ void float3divfloat(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = a[idx]/c;
}

__global__ void float3divfloatequal(float3 *a, float c)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	a[idx] /= c;
}

__global__ void floatdivfloat3(float3 *a, float c, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = c/a[idx];
}

__global__ void dot(float3 *a, float3 *b, float *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = dot(a[idx],b[idx]);
}

__global__ void cross(float3 *a, float3 *b, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = cross(a[idx],b[idx]);
}

__global__ void norm(float3 *a, float *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = norm(a[idx]);
}

__global__ void minusfloat3(float3 *a, float3 *dest)
{
	int idx = blockIdx.x*blockDim.x + threadIdx.x;
	dest[idx] = -a[idx];
}

} // extern "c"