summaryrefslogtreecommitdiff
path: root/linalg.h
diff options
context:
space:
mode:
Diffstat (limited to 'linalg.h')
-rw-r--r--linalg.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/linalg.h b/linalg.h
new file mode 100644
index 0000000..4d0344e
--- /dev/null
+++ b/linalg.h
@@ -0,0 +1,101 @@
+#ifndef __LINALG_H__
+#define __LINALG_H__
+
+__device__ __host__ float3 operator+ (const float3 &a, const float3 &b)
+{
+ return make_float3(a.x+b.x, a.y+b.y, a.z+b.y);
+}
+
+__device__ __host__ void operator+= (float3 &a, const float3 &b)
+{
+ a.x += b.x;
+ a.y += b.y;
+ a.z += b.z;
+}
+
+__device__ __host__ float3 operator- (const float3 &a, const float3 &b)
+{
+ return make_float3(a.x-b.x, a.y-b.y, a.z-b.z);
+}
+
+__device__ __host__ void operator-= (float3 &a, const float3 &b)
+{
+ a.x -= b.x;
+ a.y -= b.y;
+ a.z -= b.z;
+}
+
+__device__ __host__ float3 operator+ (const float3 &a, const float &c)
+{
+ return make_float3(a.x+c, a.y+c, a.z+c);
+}
+
+__device__ __host__ float3 operator+= (const float3 &a, const float &c)
+{
+ a.x += c;
+ a.y += c;
+ a.z += c;
+}
+
+__device__ __host__ float3 operator+ (const float &c, const float3 &a)
+{
+ return make_float3(c+a.x, c+a.y, c+a.z);
+}
+
+__device__ __host__ float3 operator- (const float3 &a, const float &c)
+{
+ return make_float3(a.x-c, a.y-c, a.z-c);
+}
+
+__device__ __host__ float3 operator-= (const float3 &a, const float &c)
+{
+ a.x -= c;
+ a.y -= c;
+ a.z -= c;
+}
+
+__device__ __host__ float3 operator- (const float &c, const float3& a)
+{
+ return make_float3(c-a.x, c-a.y, c-a.z);
+}
+
+__device__ __host__ float3 operator* (const float3 &a, const float &c)
+{
+ return make_float3(a.x*c, a.y*c, a.z*c);
+}
+
+__device__ __host__ float3 operator*= (const float3 &a, const float &c)
+{
+ a.x *= c;
+ a.y *= c;
+ a.z *= c;
+}
+
+__device__ __host__ float3 operator* (const float &c, const float3& a)
+{
+ return make_float3(c*a.x, c*a.y, c*a.z);
+}
+
+__device__ __host__ float3 operator/ (const float3 &a, const float &c)
+{
+ return make_float3(a.x/c, a.y/c, a.z/c);
+}
+
+__device__ __host__ float3 operator/= (const float3 &a, const float &c)
+{
+ a.x /= c;
+ a.y /= c;
+ a.z /= c;
+}
+
+__device__ __host__ float3 operator/ (const float &c, const float3 &a)
+{
+ return make_float3(c/a.x, c/a.y, c/a.z);
+}
+
+__device__ __host__ float dot(const float3 &a, const float3 &b)
+{
+ return a.x*b.x + a.y*b.y + a.z*b.z;
+}
+
+#endif