summaryrefslogtreecommitdiff
path: root/cl/src/vector/norm.lisp
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-09-25 10:36:23 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-09-25 10:36:23 -0600
commit58c73fd511b77cb94124b71a4bb75c7ab6a6d8bc (patch)
tree25ae52afe365de29973efbb10fdecf2712deb430 /cl/src/vector/norm.lisp
parent2e284b71500a1f8dc6cc46ecf21eb1e9389ea780 (diff)
downloadcmath-58c73fd511b77cb94124b71a4bb75c7ab6a6d8bc.tar.gz
cmath-58c73fd511b77cb94124b71a4bb75c7ab6a6d8bc.zip
add september notes & hw2 code / pdf
Diffstat (limited to 'cl/src/vector/norm.lisp')
-rw-r--r--cl/src/vector/norm.lisp17
1 files changed, 17 insertions, 0 deletions
diff --git a/cl/src/vector/norm.lisp b/cl/src/vector/norm.lisp
new file mode 100644
index 0000000..2158296
--- /dev/null
+++ b/cl/src/vector/norm.lisp
@@ -0,0 +1,17 @@
+(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))