diff options
author | Pekka Paalanen <ppaalanen@gmail.com> | 2012-01-16 15:04:28 +0200 |
---|---|---|
committer | Pekka Paalanen <ppaalanen@gmail.com> | 2012-01-27 10:44:22 +0200 |
commit | 4520d5cafbb26732922127fc8fb3b25241215a0a (patch) | |
tree | 969c64cdf891b451129386282e7a051759037ccd /src/matrix.c | |
parent | 75b47ec45d8076732b3f30c1b3ebc3d35e6ed7fe (diff) | |
download | weston-4520d5cafbb26732922127fc8fb3b25241215a0a.tar.gz weston-4520d5cafbb26732922127fc8fb3b25241215a0a.tar.bz2 weston-4520d5cafbb26732922127fc8fb3b25241215a0a.zip |
tests: add matrix-test
Add a new directory tests/ for unit test applications. This directory
will be built only if --enable-tests is given to ./configure.
Add matrix-test application. It excercises especially the
weston_matrix_invert() and weston_matrix_inverse_transform() functions.
It has one test for correctness and precision, and other tests for
measuring the speed of various matrix operations.
For the record, the correctness test prints:
a random matrix:
1.112418e-02 2.628150e+00 8.205844e+02 -1.147526e-04
4.943677e-04 -1.117819e-04 -9.158849e-06 3.678122e-02
7.915063e-03 -3.093254e-04 -4.376583e+02 3.424706e-02
-2.504038e+02 2.481788e+03 -7.545445e+01 1.752909e-03
The matrix multiplied by its inverse, error:
0.000000e+00 -0.000000e+00 -0.000000e+00 -0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
-0.000000e+00 -0.000000e+00 0.000000e+00 -0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
max abs error: 0, original determinant 11595.2
Running a test loop for 10 seconds...
test fail, det: -0.00464805, error sup: inf
test fail, det: -0.0424053, error sup: 1.30787e-06
test fail, det: 5.15191, error sup: 1.15956e-06
tests: 6791767 ok, 1 not invertible but ok, 3 failed.
Total: 6791771 iterations.
These results are expected with the current precision thresholds in
src/matrix.c and tests/matrix-test.c. The random number generator is
seeded with a constant, so the random numbers should be the same on
every run. Machine speed and scheduling affect how many iterations are
run.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Diffstat (limited to 'src/matrix.c')
-rw-r--r-- | src/matrix.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/matrix.c b/src/matrix.c index 06cdc5e4..46ce56a8 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -184,7 +184,7 @@ weston_matrix_inverse_transform(struct weston_inverse_matrix *inverse, unsigned *p = inverse->p; double *LU = inverse->LU; double b[4]; - unsigned k, j; + unsigned j; /* Forward substitution, column version, solves L * b = P * v */ /* The diagonal of L is all ones, and not explicitly stored. */ @@ -214,6 +214,7 @@ weston_matrix_inverse_transform(struct weston_inverse_matrix *inverse, b[0] /= LU[0 + 0 * 4]; #else for (j = 3; j > 0; --j) { + unsigned k; b[j] /= LU[j + j * 4]; for (k = 0; k < j; ++k) b[k] -= b[j] * LU[k + j * 4]; |