/* Copyright (c) 2019, Anthony Latorre * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) * any later version. * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * You should have received a copy of the GNU General Public License along with * this program. If not, see . */ #ifndef SORT_H #define SORT_H #include /* for size_t */ void fargsort(double *base, size_t num, size_t *index_array); void argsort(int *base, size_t num, size_t *index_array); #endif elected='selected'>master Chroma is a high performance optical photon simulation for particle physics detectorsAnthony LaTorre
summaryrefslogtreecommitdiff
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"