OKlibrary  0.2.1.6
Norms.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 26.11.2011 (Swansea) */
00002 /* Copyright 2011 Oliver Kullmann
00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute
00004 it and/or modify it under the terms of the GNU General Public License as published by
00005 the Free Software Foundation and included in this library; either version 3 of the
00006 License, or any later version. */
00007 
00022 oklib_include("OKlib/ComputerAlgebra/DataStructures/Lisp/Lists.mac")$
00023 
00024 
00025 norm_vec(L,p) :=
00026  if p=1 then sum_l(map(abs,L))
00027  elseif p=2 then sqrt(sum_l(map(lambda([x],x^2),L)))
00028  elseif p=inf then lmax(map(abs,L))
00029  else sum_l(map(lambda([x],abs(x)^p),L))^(1/p)$
00030 
00031 dist_vec(A,B,p) := norm_vec(A-B,p)$
00032