summaryrefslogtreecommitdiff
path: root/matrix.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 /matrix.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 'matrix.h')
-rw-r--r--matrix.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/matrix.h b/matrix.h
index b363571..14e04a4 100644
--- a/matrix.h
+++ b/matrix.h
@@ -14,6 +14,11 @@ __device__ __host__ Matrix make_matrix(float a00, float a01, float a02,
return m;
}
+__device__ __host__ Matrix make_matrix(float3 &u1, float3 &u2, float3 &u3)
+{
+ Matrix m = {u1.x, u2.x, u3.x, u1.y, u2.y, u3.y, u1.z, u2.z, u3.z};
+}
+
__device__ __host__ float3 operator* (const Matrix &m, const float3 &a)
{
return make_float3(m.a00*a.x + m.a01*a.y + m.a02*a.z,
@@ -202,6 +207,19 @@ __device__ __host__ Matrix inv(const Matrix &m)
m.a00*m.a11 - m.a01*m.a10)/det(m);
}
+__device__ __host__ Matrix inv(const Matrix&m, const float determinant)
+{
+ return make_matrix(m.a11*m.a22 - m.a12*m.a21,
+ m.a02*m.a21 - m.a01*m.a22,
+ m.a01*m.a12 - m.a02*m.a11,
+ m.a12*m.a20 - m.a10*m.a22,
+ m.a00*m.a22 - m.a02*m.a20,
+ m.a02*m.a10 - m.a00*m.a12,
+ m.a10*m.a21 - m.a11*m.a20,
+ m.a01*m.a20 - m.a00*m.a21,
+ m.a00*m.a11 - m.a01*m.a10)/determinant;
+}
+
__device__ __host__ Matrix outer(const float3 &a, const float3 &b)
{
return make_matrix(a.x*b.x, a.x*b.y, a.x*b.z,