; Copyright (C) 2006 Will M. Farr ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License along ; with this program; if not, write to the Free Software Foundation, Inc., ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. (module maps-test "generics.ss" (require "maps.ss") (require "tuples.ss") (require "manifolds.ss") (require (planet "test.ss" ("schematics" "schemeunit.plt" 2))) (provide maps-test-suite) (define rectangular (make :chi (lambda (x) x) :chiinv (lambda (x) x) :dim 3)) (define chi (slot-ref rectangular 'chi)) (define chiinv (slot-ref rectangular 'chiinv)) (define R3 (make :standard-chart rectangular :dim 3)) (define-named-coordinates (x y z) rectangular) (define (mu m) (let ((r (chi m))) (let ((x (ref r 0)) (y (ref r 1)) (z (ref r 2))) (chiinv (up (* x 2) (* y 3) (* z 4)))))) (define (mu^-1 m) (let ((r (chi m))) (let ((x (ref r 0)) (y (ref r 1)) (z (ref r 2))) (chiinv (up (/ x 2) (/ y 3) (/ z 4)))))) (define (mu2 m) (let ((r (chi m))) (let ((x (ref r 0)) (y (ref r 1)) (z (ref r 2))) (chiinv (up (+ x y) (- x y) z))))) (define (mu2^-1 m) (let ((r (chi m))) (let ((x (ref r 0)) (y (ref r 1)) (z (ref r 2))) (chiinv (up (/ (+ x y) 2) (/ (- x y) 2) z))))) (define ((close? eps) a b) (< (abs (- a b)) eps)) (define maps-test-suite (test-suite "maps.ss" (test-case "Pushforward under dilation." (check (close? 1e-6) ((((pushforward mu mu^-1) d/dz) z) (chiinv (up 1 2 3))) 4)) (test-case "Pullback under dilation." (check (close? 1e-6) ((((pullback mu mu^-1) dy) d/dy) (chiinv (up 2 5 6))) 3)) (test-case "Pushforward under rotation." (check = ((((pushforward mu2 mu2^-1) d/dx) x) (chiinv (up 8 9 10))) 1)) (test-case "Pullback under rotation" (check = ((((pullback mu2 mu2^-1) dy) d/dy) (chiinv (up 11 23 4))) -1)))))