summaryrefslogtreecommitdiff
path: root/matrix.h
diff options
context:
space:
mode:
authorAnthony LaTorre <telatorre@gmail.com>2011-05-06 18:00:03 -0400
committerAnthony LaTorre <telatorre@gmail.com>2011-05-06 18:00:03 -0400
commit53c20f9b347e9aa3b1844f194d86eb056afc2341 (patch)
tree9685434cfa3a42943760c8fed47b0c2f11594bce /matrix.h
parent61a7a1ebdc028517db22f33741b31f63018979c2 (diff)
downloadchroma-53c20f9b347e9aa3b1844f194d86eb056afc2341.tar.gz
chroma-53c20f9b347e9aa3b1844f194d86eb056afc2341.tar.bz2
chroma-53c20f9b347e9aa3b1844f194d86eb056afc2341.zip
added unary minus matrix; updated test
Diffstat (limited to 'matrix.h')
-rw-r--r--matrix.h20
1 files changed, 7 insertions, 13 deletions
diff --git a/matrix.h b/matrix.h
index 14e04a4..1de8e8c 100644
--- a/matrix.h
+++ b/matrix.h
@@ -19,6 +19,13 @@ __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__ Matrix operator- (const Matrix &m)
+{
+ return make_matrix(-m.a00, -m.a01, -m.a02,
+ -m.a10, -m.a11, -m.a12,
+ -m.a20, -m.a21, -m.a22);
+}
+
__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,
@@ -207,19 +214,6 @@ __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,