diff options
Diffstat (limited to 'cl')
-rw-r--r-- | cl/lizfcm.asd | 39 | ||||
-rw-r--r-- | cl/src/approx/derivative.lisp | 9 | ||||
-rw-r--r-- | cl/src/approx/maceps.lisp | 11 | ||||
-rw-r--r-- | cl/src/approx/package.lisp | 5 | ||||
-rw-r--r-- | cl/src/package.lisp | 7 | ||||
-rw-r--r-- | cl/src/utils/package.lisp | 5 | ||||
-rw-r--r-- | cl/src/utils/table.lisp | 11 | ||||
-rw-r--r-- | cl/src/utils/within-range.lisp | 5 | ||||
-rw-r--r-- | cl/src/vector/distance.lisp | 6 | ||||
-rw-r--r-- | cl/src/vector/norm.lisp | 17 | ||||
-rw-r--r-- | cl/src/vector/package.lisp | 7 | ||||
-rw-r--r-- | cl/tests/approx.lisp | 24 | ||||
-rw-r--r-- | cl/tests/maceps.lisp | 27 | ||||
-rw-r--r-- | cl/tests/suite.lisp | 10 | ||||
-rw-r--r-- | cl/tests/table.lisp | 31 | ||||
-rw-r--r-- | cl/tests/vector.lisp | 31 |
16 files changed, 0 insertions, 245 deletions
diff --git a/cl/lizfcm.asd b/cl/lizfcm.asd deleted file mode 100644 index 3e8c289..0000000 --- a/cl/lizfcm.asd +++ /dev/null @@ -1,39 +0,0 @@ -(asdf:defsystem "lizfcm" - :version "0.1.0" - :author "Elizabeth Hunt" - :license "MIT" - :components ((:module "src" - :components - ((:module "utils" - :components - ((:file "within-range" :depends-on ("package")) - (:file "table" :depends-on ("package")) - (:file "package"))) - (:module "approx" - :components - ((:file "maceps" :depends-on ("package")) - (:file "derivative" :depends-on ("package")) - (:file "package"))) - (:module "vector" - :components - ((:file "distance" :depends-on ("norm" "package")) - (:file "norm" :depends-on ("package")) - (:file "package"))))))) - - -(asdf:defsystem "lizfcm/tests" - :author "Elizabeth Hunt" - :license "MIT" - :depends-on (:fiveam - :lizfcm) - :components ((:module "tests" - :components - ((:file "table" :depends-on ("suite")) - (:file "maceps" :depends-on ("suite")) - (:file "approx" :depends-on ("suite")) - (:file "vector" :depends-on ("suite")) - (:file "suite")))) - :perform (asdf:test-op (o c) (uiop:symbol-call - :fiveam :run! - (uiop:find-symbol* :lizfcm-test-suite :lizfcm/tests)))) - diff --git a/cl/src/approx/derivative.lisp b/cl/src/approx/derivative.lisp deleted file mode 100644 index 02fcb4c..0000000 --- a/cl/src/approx/derivative.lisp +++ /dev/null @@ -1,9 +0,0 @@ -(in-package :lizfcm.approx) - -(defun derivative-at (f x &optional (delta 0.01)) - (let* ((x2 (+ x delta)) - (x1 (- x delta)) - (y2 (apply f (list x2))) - (y1 (apply f (list x1)))) - (/ (- y2 y1) - (- x2 x1)))) diff --git a/cl/src/approx/maceps.lisp b/cl/src/approx/maceps.lisp deleted file mode 100644 index ad234e8..0000000 --- a/cl/src/approx/maceps.lisp +++ /dev/null @@ -1,11 +0,0 @@ -(in-package :lizfcm.approx) - -(defun compute-maceps (f a init) - (let ((h init) - (err init)) - (loop while (> err 0) - do - (setf h (/ h 2) - err (abs (- (funcall f (+ a h)) - (funcall f a)))) - collect (list a h err)))) diff --git a/cl/src/approx/package.lisp b/cl/src/approx/package.lisp deleted file mode 100644 index c11eb60..0000000 --- a/cl/src/approx/package.lisp +++ /dev/null @@ -1,5 +0,0 @@ -(in-package :cl-user) -(defpackage lizfcm.approx - (:use :cl) - (:export :derivative-at - :compute-maceps)) diff --git a/cl/src/package.lisp b/cl/src/package.lisp deleted file mode 100644 index 88b10eb..0000000 --- a/cl/src/package.lisp +++ /dev/null @@ -1,7 +0,0 @@ -(in-package :cl-user) -(defpackage lizfcm.vector - (:use :cl) - (:export - :n-norm - :max-norm - :distance)) diff --git a/cl/src/utils/package.lisp b/cl/src/utils/package.lisp deleted file mode 100644 index bdd5589..0000000 --- a/cl/src/utils/package.lisp +++ /dev/null @@ -1,5 +0,0 @@ -(in-package :cl-user) -(defpackage lizfcm.utils - (:use :cl) - (:export :within-range-p - :table)) diff --git a/cl/src/utils/table.lisp b/cl/src/utils/table.lisp deleted file mode 100644 index e96f37b..0000000 --- a/cl/src/utils/table.lisp +++ /dev/null @@ -1,11 +0,0 @@ -(in-package :lizfcm.utils) - -(defmacro table ((&key headers domain-order domain-values) &body body) - `(cons - ,headers - (mapcar (lambda (tuple) - (destructuring-bind ,domain-order tuple - (append tuple - (list - ,@body)))) - ,domain-values))) diff --git a/cl/src/utils/within-range.lisp b/cl/src/utils/within-range.lisp deleted file mode 100644 index 9a0b762..0000000 --- a/cl/src/utils/within-range.lisp +++ /dev/null @@ -1,5 +0,0 @@ -(in-package :lizfcm.utils) - -(defun within-range-p (x true-value delta) - (and (< x (+ true-value delta)) - (> x (- true-value delta)))) diff --git a/cl/src/vector/distance.lisp b/cl/src/vector/distance.lisp deleted file mode 100644 index 74631ce..0000000 --- a/cl/src/vector/distance.lisp +++ /dev/null @@ -1,6 +0,0 @@ -(in-package :lizfcm.vector) - -(defun distance (v1 v2 norm) - (let* ((d (mapcar #'- v1 v2)) - (length (funcall norm d))) - length)) diff --git a/cl/src/vector/norm.lisp b/cl/src/vector/norm.lisp deleted file mode 100644 index 2158296..0000000 --- a/cl/src/vector/norm.lisp +++ /dev/null @@ -1,17 +0,0 @@ -(in-package :lizfcm.vector) - -(defun p-norm (p) - (lambda (v) - (expt - (reduce (lambda (acc x) - (+ acc x)) - (mapcar (lambda (x) - (abs - (expt x p))) - v)) - (/ 1 p)))) - -(defun max-norm (v) - (reduce (lambda (acc x) - (max acc x)) - v)) diff --git a/cl/src/vector/package.lisp b/cl/src/vector/package.lisp deleted file mode 100644 index 009b190..0000000 --- a/cl/src/vector/package.lisp +++ /dev/null @@ -1,7 +0,0 @@ -(in-package :cl-user) -(defpackage lizfcm.vector - (:use :cl) - (:export - :p-norm - :max-norm - :distance)) diff --git a/cl/tests/approx.lisp b/cl/tests/approx.lisp deleted file mode 100644 index 2fd8124..0000000 --- a/cl/tests/approx.lisp +++ /dev/null @@ -1,24 +0,0 @@ -(defpackage lizfcm/tests.approx - (:use :cl - :fiveam - :lizfcm.approx - :lizfcm.utils - :lizfcm/tests) - (:export :approx-suite)) -(in-package :lizfcm/tests.approx) - -(def-suite approx-suite - :in lizfcm-test-suite) -(in-suite approx-suite) - -(test derivative-at - :description "derivative at is within bounds" - (let ((f (lambda (x) (* x x))) - (x 2) - (accepted-delta 0.02) - (f-prime-at-x 4) - (delta 0.01)) - (is (within-range-p - (derivative-at f x delta) - f-prime-at-x - accepted-delta)))) diff --git a/cl/tests/maceps.lisp b/cl/tests/maceps.lisp deleted file mode 100644 index cd5ced9..0000000 --- a/cl/tests/maceps.lisp +++ /dev/null @@ -1,27 +0,0 @@ -(defpackage lizfcm/tests.maceps - (:use :cl - :fiveam - :lizfcm.approx - :lizfcm.utils - :lizfcm/tests) - (:export :approx-suite)) -(in-package :lizfcm/tests.maceps) - -(def-suite maceps-suite - :in lizfcm-test-suite) -(in-suite maceps-suite) - -(test maceps - :description "double precision provides precision about (mac eps of single precision) squared" - (let* ((maceps-computation-double (compute-maceps (lambda (x) x) - 1.0d0 - 1.0d0)) - (maceps-computation-single (compute-maceps (lambda (x) x) - 1.0 - 1.0)) - (last-double-h (cadar (last maceps-computation-double))) - (last-single-h (cadar (last maceps-computation-single)))) - (is (within-range-p - (- last-double-h (* last-single-h last-single-h)) - 0 - last-single-h)))) diff --git a/cl/tests/suite.lisp b/cl/tests/suite.lisp deleted file mode 100644 index e23cfaf..0000000 --- a/cl/tests/suite.lisp +++ /dev/null @@ -1,10 +0,0 @@ -(in-package :cl-user) -(defpackage lizfcm/tests - (:use :cl - :fiveam) - (:export :run! - :lizfcm-test-suite)) -(in-package :lizfcm/tests) - -(def-suite lizfcm-test-suite - :description "The ultimate parent test suite") diff --git a/cl/tests/table.lisp b/cl/tests/table.lisp deleted file mode 100644 index 33d4e86..0000000 --- a/cl/tests/table.lisp +++ /dev/null @@ -1,31 +0,0 @@ -(defpackage lizfcm/tests.table - (:use :cl - :fiveam - :lizfcm.utils - :lizfcm/tests) - (:export :approx-suite)) -(in-package :lizfcm/tests.table) - -(def-suite table-suite - :in lizfcm-test-suite) -(in-suite table-suite) - -(defun fib (n) - (cond ((< n 2) n) - (t (+ (fib (- n 1)) (fib (- n 2)))))) - -(test table-of-fib-vals - :description "table generates correctly" - (let* ((headers '("n" "fib(n)")) - (n-values '((1) (2) (3) (4))) - (expected `(("n" "fib(n)") - (1 ,(fib 1)) - (2 ,(fib 2)) - (3 ,(fib 3)) - (4 ,(fib 4)))) - (tabled (lizfcm.utils:table (:headers headers - :domain-order (n) - :domain-values n-values) - (fib n)))) - (is (equal expected tabled)))) - diff --git a/cl/tests/vector.lisp b/cl/tests/vector.lisp deleted file mode 100644 index 3ffe5a8..0000000 --- a/cl/tests/vector.lisp +++ /dev/null @@ -1,31 +0,0 @@ -(defpackage lizfcm/tests.vector - (:use :cl - :fiveam - :lizfcm.vector - :lizfcm.utils - :lizfcm/tests) - (:export :vector-suite)) -(in-package :lizfcm/tests.vector) - -(def-suite vector-suite - :in lizfcm-test-suite) -(in-suite vector-suite) - -(test p-norm - :description "computes p-norm" - (let ((v '(1 1)) - (length (sqrt 2)) - (2-norm (p-norm 2))) - (is (within-range-p (funcall 2-norm v) - length - 0.00001)))) - -(test vector-distance - :description "computes distance via norm" - (let ((v1 '(0 0)) - (v2 '(1 1)) - (dist (sqrt 2))) - (is (within-range-p (distance v1 v2 (p-norm 2)) - dist - 0.00001)))) - |