summaryrefslogtreecommitdiff
path: root/linalg.h
diff options
context:
space:
mode:
authorAnthony LaTorre <telatorre@gmail.com>2011-05-06 16:50:20 -0400
committerAnthony LaTorre <telatorre@gmail.com>2011-05-06 16:50:20 -0400
commit61a7a1ebdc028517db22f33741b31f63018979c2 (patch)
treeeae95a199de20258f654d16f8a34914dfecd4270 /linalg.h
parent4e2720ff56afff978acaf589218cee0122d2ae29 (diff)
downloadchroma-61a7a1ebdc028517db22f33741b31f63018979c2.tar.gz
chroma-61a7a1ebdc028517db22f33741b31f63018979c2.tar.bz2
chroma-61a7a1ebdc028517db22f33741b31f63018979c2.zip
added unary minus operator for matrix and float3; updated tests
Diffstat (limited to 'linalg.h')
-rw-r--r--linalg.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/linalg.h b/linalg.h
index 8362ab1..593aa9d 100644
--- a/linalg.h
+++ b/linalg.h
@@ -1,6 +1,11 @@
#ifndef __LINALG_H__
#define __LINALG_H__
+__device__ __host__ float3 operator- (const float3 &a)
+{
+ return make_float3(-a.x, -a.y, -a.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);
@@ -103,4 +108,9 @@ __device__ __host__ float3 cross(const float3 &a, const float3 &b)
return make_float3(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);
}
+__device__ __host__ float norm(const float3 &a)
+{
+ return sqrtf(dot(a,a));
+}
+
#endif