|
|
@@ -76,15 +76,21 @@ lolunit_declare_fixture(MatrixTest) |
|
|
|
|
|
|
|
lolunit_declare_test(inverse_2x2) |
|
|
|
{ |
|
|
|
mat2 m0 = inv2; |
|
|
|
mat2 m1 = inverse(m0); |
|
|
|
mat2 m2 = m0 * m1; |
|
|
|
mat2 m(vec2(4, 3), |
|
|
|
vec2(3, 2)); |
|
|
|
|
|
|
|
mat2 m1 = inverse(m); |
|
|
|
for (int j = 0; j < 2; ++j) |
|
|
|
for (int i = 0; i < 2; ++i) |
|
|
|
lolunit_assert_equal(m1[i][j], m1[i][j]); |
|
|
|
|
|
|
|
mat2 m2 = m1 * m; |
|
|
|
for (int j = 0; j < 2; ++j) |
|
|
|
for (int i = 0; i < 2; ++i) |
|
|
|
lolunit_assert_doubles_equal(m2[i][j], mat2(1.f)[i][j], 1e-5); |
|
|
|
} |
|
|
|
|
|
|
|
#if 0 /* XXX: LU decomposition is currently broken */ |
|
|
|
lolunit_declare_test(lu_decomposition_3x3) |
|
|
|
{ |
|
|
|
mat3 m(vec3(2, 3, 5), |
|
|
@@ -226,14 +232,20 @@ lolunit_declare_fixture(MatrixTest) |
|
|
|
for (int i = 0; i < 4; ++i) |
|
|
|
lolunit_assert_doubles_equal(m2[i][j], mat4(1.f)[i][j], 1e-5); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
lolunit_declare_test(inverse_3x3) |
|
|
|
{ |
|
|
|
mat3 m(vec3(2, 3, 5), |
|
|
|
vec3(3, 2, 3), |
|
|
|
vec3(9, 5, 7)); |
|
|
|
mat3 m2 = inverse(m) * m; |
|
|
|
|
|
|
|
mat3 m1 = inverse(m); |
|
|
|
for (int j = 0; j < 3; ++j) |
|
|
|
for (int i = 0; i < 3; ++i) |
|
|
|
lolunit_assert_equal(m1[i][j], m1[i][j]); |
|
|
|
|
|
|
|
mat3 m2 = m1 * m; |
|
|
|
for (int j = 0; j < 3; ++j) |
|
|
|
for (int i = 0; i < 3; ++i) |
|
|
|
lolunit_assert_doubles_equal(m2[i][j], mat3(1.f)[i][j], 1e-5); |
|
|
@@ -245,8 +257,13 @@ lolunit_declare_fixture(MatrixTest) |
|
|
|
vec4(-2, -1, -2, 2), |
|
|
|
vec4( 4, 2, 5, -4), |
|
|
|
vec4( 5, -3, -7, -6)); |
|
|
|
mat4 m2 = inverse(m) * m; |
|
|
|
|
|
|
|
mat4 m1 = inverse(m); |
|
|
|
for (int j = 0; j < 4; ++j) |
|
|
|
for (int i = 0; i < 4; ++i) |
|
|
|
lolunit_assert_equal(m1[i][j], m1[i][j]); |
|
|
|
|
|
|
|
mat4 m2 = m1 * m; |
|
|
|
for (int j = 0; j < 4; ++j) |
|
|
|
for (int i = 0; i < 4; ++i) |
|
|
|
lolunit_assert_doubles_equal(m2[i][j], mat4(1.f)[i][j], 1e-5); |
|
|
@@ -258,8 +275,12 @@ lolunit_declare_fixture(MatrixTest) |
|
|
|
vec4(0, 0, 1, 0), |
|
|
|
vec4(0, -1, 0, 0), |
|
|
|
vec4(0, 0, -1, 1)); |
|
|
|
mat4 m2 = inverse(m) * m; |
|
|
|
mat4 m1 = inverse(m); |
|
|
|
for (int j = 0; j < 4; ++j) |
|
|
|
for (int i = 0; i < 4; ++i) |
|
|
|
lolunit_assert_equal(m1[i][j], m1[i][j]); |
|
|
|
|
|
|
|
mat4 m2 = m1 * m; |
|
|
|
for (int j = 0; j < 4; ++j) |
|
|
|
for (int i = 0; i < 4; ++i) |
|
|
|
lolunit_assert_doubles_equal(m2[i][j], mat4(1.f)[i][j], 1e-5); |
|
|
|