# HG changeset patch # User Nolan Prescott # Date 1584727234 14400 # Fri Mar 20 14:00:34 2020 -0400 # Node ID 15e9ba623ebd4bb236506cbb7d30304199d7bd86 # Parent c9136f86c700ea76e2b4154b0928ebd5e2d428db a few more matrix inverse tests diff --git a/tracer.lisp b/tracer.lisp --- a/tracer.lisp +++ b/tracer.lisp @@ -489,6 +489,26 @@ ( -3/38 -17/76 -1/19 15/76) (-139/266 -433/532 -40/133 163/532)))))) +(deftest inverse-is-reversible + (let* ((a #2A((-5 2 6 -8) + ( 1 -5 1 8) + ( 7 7 -6 -7) + ( 1 -3 7 4))) + (b (inverse a))) + (check (equalp (inverse b) a)))) + +(deftest inverse-undoes-multiplication + (let* ((a #2A(( 3 -9 7 3) + ( 3 -8 2 -9) + (-4 4 4 1) + (-6 5 -1 1))) + (b #2A((8 2 2 2) + (3 -1 7 0) + (7 0 5 4) + (6 -2 0 5))) + (c (matrix*matrix a b))) + (check (equalp (matrix*matrix c (inverse b)) a)))) + (deftest matrix-basics (multiply-4x4-matrices) (multiply-matrix-with-vector) @@ -505,7 +525,9 @@ (4x4-matrix-determinant) (invertibility-predicate) (invertibility-negative-case) - (calculate-matrix-inverse)) + (calculate-matrix-inverse) + (inverse-is-reversible) + (inverse-undoes-multiplication)) (deftest suite (vector-basics)