flatten directory structure to appease dr koebbe

This commit is contained in:
Elizabeth Hunt 2023-10-09 21:37:44 -06:00
parent adda6869cb
commit e46e5eee74
Signed by: simponic
GPG Key ID: 52B3774857EB24B1
19 changed files with 58 additions and 48 deletions

3
compile.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
ar rcs lizfcm.a src/*

BIN
lizfcm.a Normal file

Binary file not shown.

View File

@ -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))))

View File

@ -8,10 +8,18 @@
(/ (- y2 y1) (/ (- y2 y1)
(- x2 x1)))) (- 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)) (let* ((x2 (+ x delta))
(x1 x) (x1 x)
(y2 (apply f (list x2))) (y2 (apply f (list x2)))
(y1 (apply f (list x1)))) (y1 (apply f (list x1))))
(/ (- y2 y1) (/ (- y2 y1)
(- x2 x1)))) (- 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))))

View File

@ -2,5 +2,6 @@
(defpackage lizfcm.approx (defpackage lizfcm.approx
(:use :cl) (:use :cl)
(:export :central-derivative-at (:export :central-derivative-at
:fwd-derivative-at :forward-derivative-at
:backward-derivative-at
:compute-maceps)) :compute-maceps))

32
src/lizfcm.asd Normal file
View File

@ -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))))

View File

@ -1,7 +0,0 @@
(in-package :cl-user)
(defpackage lizfcm.vector
(:use :cl)
(:export
:n-norm
:max-norm
:distance))

View File

@ -34,3 +34,15 @@
(forward-derivative-at f x delta) (forward-derivative-at f x delta)
f-prime-at-x f-prime-at-x
accepted-delta)))) 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))))