diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..f174fbe --- /dev/null +++ b/compile.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +ar rcs lizfcm.a src/* diff --git a/lizfcm.a b/lizfcm.a new file mode 100644 index 0000000..1d27463 Binary files /dev/null and b/lizfcm.a differ diff --git a/lizfcm.asd b/lizfcm.asd deleted file mode 100644 index 3e8c289..0000000 --- a/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/src/approx/derivative.lisp b/src/approx,derivative.lisp similarity index 59% rename from src/approx/derivative.lisp rename to src/approx,derivative.lisp index 8aa171a..631a5c0 100644 --- a/src/approx/derivative.lisp +++ b/src/approx,derivative.lisp @@ -8,10 +8,18 @@ (/ (- y2 y1) (- x2 x1)))) -(defun fwd-derivative-at (f x &optional (delta 0.01)) +(defun forward-derivative-at (f x &optional (delta 0.01)) (let* ((x2 (+ x delta)) (x1 x) (y2 (apply f (list x2))) (y1 (apply f (list x1)))) (/ (- y2 y1) (- x2 x1)))) + +(defun backward-derivative-at (f x &optional (delta 0.01)) + (let* ((x2 x) + (x1 (- x delta)) + (y2 (apply f (list x2))) + (y1 (apply f (list x1)))) + (/ (- y2 y1) + (- x2 x1)))) diff --git a/src/approx/maceps.lisp b/src/approx,maceps.lisp similarity index 100% rename from src/approx/maceps.lisp rename to src/approx,maceps.lisp diff --git a/src/approx/package.lisp b/src/approx,package.lisp similarity index 64% rename from src/approx/package.lisp rename to src/approx,package.lisp index 67c6a90..a0eac80 100644 --- a/src/approx/package.lisp +++ b/src/approx,package.lisp @@ -2,5 +2,6 @@ (defpackage lizfcm.approx (:use :cl) (:export :central-derivative-at - :fwd-derivative-at + :forward-derivative-at + :backward-derivative-at :compute-maceps)) diff --git a/src/lizfcm.asd b/src/lizfcm.asd new file mode 100644 index 0000000..ee8beb0 --- /dev/null +++ b/src/lizfcm.asd @@ -0,0 +1,32 @@ +(asdf:defsystem "lizfcm" + :version "0.1.0" + :author "Elizabeth Hunt" + :license "MIT" + :components + ((:file "utils,within-range" :depends-on ("utils,package")) + (:file "utils,table" :depends-on ("utils,package")) + (:file "utils,package") + (:file "approx,maceps" :depends-on ("approx,package")) + (:file "approx,derivative" :depends-on ("approx,package")) + (:file "approx,package") + (:file "vector,distance" :depends-on ("vector,norm" "vector,package")) + (:file "vector,norm" :depends-on ("vector,package")) + (:file "vector,package"))) + + +(asdf:defsystem "lizfcm/tests" + :author "Elizabeth Hunt" + :license "MIT" + :depends-on + (:fiveam + :lizfcm) + :components + ((:file "tests,table" :depends-on ("tests,suite")) + (:file "tests,maceps" :depends-on ("tests,suite")) + (:file "tests,approx" :depends-on ("tests,suite")) + (:file "tests,vector" :depends-on ("tests,suite")) + (:file "tests,suite")) + :perform + (asdf:test-op (o c) (uiop:symbol-call + :fiveam :run! + (uiop:find-symbol* :lizfcm-test-suite :lizfcm/tests)))) diff --git a/src/package.lisp b/src/package.lisp deleted file mode 100644 index 88b10eb..0000000 --- a/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/tests/approx.lisp b/src/tests,approx.lisp similarity index 73% rename from tests/approx.lisp rename to src/tests,approx.lisp index 588b16d..678ff8c 100644 --- a/tests/approx.lisp +++ b/src/tests,approx.lisp @@ -34,3 +34,15 @@ (forward-derivative-at f x delta) f-prime-at-x accepted-delta)))) + +(test bwd-derivative-at + :description "backward 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 + (backward-derivative-at f x delta) + f-prime-at-x + accepted-delta)))) diff --git a/tests/maceps.lisp b/src/tests,maceps.lisp similarity index 100% rename from tests/maceps.lisp rename to src/tests,maceps.lisp diff --git a/tests/suite.lisp b/src/tests,suite.lisp similarity index 100% rename from tests/suite.lisp rename to src/tests,suite.lisp diff --git a/tests/table.lisp b/src/tests,table.lisp similarity index 100% rename from tests/table.lisp rename to src/tests,table.lisp diff --git a/tests/vector.lisp b/src/tests,vector.lisp similarity index 100% rename from tests/vector.lisp rename to src/tests,vector.lisp diff --git a/src/utils/package.lisp b/src/utils,package.lisp similarity index 100% rename from src/utils/package.lisp rename to src/utils,package.lisp diff --git a/src/utils/table.lisp b/src/utils,table.lisp similarity index 100% rename from src/utils/table.lisp rename to src/utils,table.lisp diff --git a/src/utils/within-range.lisp b/src/utils,within-range.lisp similarity index 100% rename from src/utils/within-range.lisp rename to src/utils,within-range.lisp diff --git a/src/vector/distance.lisp b/src/vector,distance.lisp similarity index 100% rename from src/vector/distance.lisp rename to src/vector,distance.lisp diff --git a/src/vector/norm.lisp b/src/vector,norm.lisp similarity index 100% rename from src/vector/norm.lisp rename to src/vector,norm.lisp diff --git a/src/vector/package.lisp b/src/vector,package.lisp similarity index 100% rename from src/vector/package.lisp rename to src/vector,package.lisp