;; Simple test routines. Just calls the methods and ;; prints if there are errors or conditions. ;; The purpose of just to look for obvious flaws. ;; Just run an instpect the output. ;; ;; (Ideally the output should be zero, but it isn't) (in-package :lisplab-user) (defun simple-non-nil-check (fun args) (multiple-value-bind (ok err) (ignore-errors (apply fun args)) (if ok (format t "~&OK : (~a ~s) ~%" fun (mapcar #'type-of args)) (progn (format t "~&FAILED: (~a ~s) ~%" fun (mapcar #'type-of args)) (format t "~& - ~s~%" err))) ok)) (defun test-level0-methods () (let* ((a 1) (b 1d0) (c %i) (x #md((1 2 ) (3 4))) (y #md((1 2 3) (3 4 3))) (w #mm((1 2 2) (3 4 3) (1 100000 1000000))) (args (list a b c x y w))) (mapc (lambda (fun) (mapc (lambda (x) (simple-non-nil-check fun (list x))) args)) ;; The following list is hard coded to make ;; the test independent of Lisplab. '(.sin .cos .tan .asin .acos .atan .sinh .cosh .tanh .asinh .acosh .atanh .exp .sqr .sqrt .conj .re .im .abs .erf .erfc .gamma )) (mapc (lambda (x) (simple-non-nil-check '.besj (list 1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besy (list 1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besi (list 1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besk (list 1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besh1 (list 1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besh2 (list 1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besj (list 5 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besy (list 5 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besi (list 5 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besk (list 5 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besh1 (list 5 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besh2 (list 5 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besj (list 7.1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besy (list 7.1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besi (list 7.1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besk (list 7.1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besh1 (list 7.1 x))) args) (mapc (lambda (x) (simple-non-nil-check '.besh2 (list 7.1 x))) args) 'done)) (defun test-level3-fft () (let ((a #md((1 2) (3 4))) (b #mz((1 2) (3 5))) (c #md((1 2 -1) (3 4 9) (1 1 1))) (d #mz((1 2 2.1) (3 5 %i) (-%i -%i -%i)))) (simple-non-nil-check #'fft1 (list a)) (simple-non-nil-check #'fft1 (list b)) (simple-non-nil-check #'fft2 (list a)) (simple-non-nil-check #'fft2 (list b)) (simple-non-nil-check #'fft1 (list c)) (simple-non-nil-check #'fft1 (list d)) (simple-non-nil-check #'fft2 (list c)) (simple-non-nil-check #'fft2 (list d)) (simple-non-nil-check #'ifft1 (list a)) (simple-non-nil-check #'ifft1 (list b)) (simple-non-nil-check #'ifft2 (list a)) (simple-non-nil-check #'ifft2 (list b)) (simple-non-nil-check #'ifft1 (list c)) (simple-non-nil-check #'ifft1 (list d)) (simple-non-nil-check #'ifft2 (list c)) (simple-non-nil-check #'ifft2 (list d)) (simple-non-nil-check #'fft-shift (list a)) (simple-non-nil-check #'fft-shift (list b)) (simple-non-nil-check #'fft-shift (list c)) (simple-non-nil-check #'fft-shift (list d)) (simple-non-nil-check #'ifft-shift (list a)) (simple-non-nil-check #'ifft-shift (list b)) (simple-non-nil-check #'ifft-shift (list c)) (simple-non-nil-check #'ifft-shift (list d)) 'done)) (defun test-level3-linalg () (let* ((a #md((1 2) (3 4))) (b #mz((1 2) (3 5))) (c #md((1 2 -1) (3 4 9) (1 1 1))) (d #mz((1 2 2.1) (3 5 %i) (-%i %i -%i))) (x #mm((1 2 2.1) (3 5 %i) (-%i %i -%i))) (args (list a b c d x)) (vec1 (mcol 'matrix-ge 1 2 3)) (vec2 (dcol 1 2 3))) (simple-non-nil-check #'lin-solve (list x vec1)) (simple-non-nil-check #'lin-solve (list c vec2)) (mapc (lambda (x) (simple-non-nil-check #'mtp (list x))) args) (mapc (lambda (x) (simple-non-nil-check #'mct (list x))) args) (mapc (lambda (x) (simple-non-nil-check #'minv (list x))) args) (mapc (lambda (x) (simple-non-nil-check #'mdet (list x))) args) (mapc (lambda (x) (simple-non-nil-check #'mtr (list x))) args) (mapc (lambda (x) (simple-non-nil-check #'LU-factor (list x))) args) (mapc (lambda (x) (simple-non-nil-check #'m* (list x x))) args) (mapc (lambda (x) (simple-non-nil-check #'m/ (list x x))) args) ) 'done) (defun test-all () (test-level0-methods) (test-level3-fft) (test-level3-linalg))