lizfcm/src/vector/norm.lisp

18 lines
359 B
Common Lisp
Raw Normal View History

2023-09-25 12:36:23 -04:00
(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))