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/TestSystem/Lisp/Asserts.mac")$
00023 
00024 
00025 kill(f)$
00026 
00027 
00028 okltest_norm_vec(f) := block([x,y,z,p],
00029   assert(f([],p) = 0),
00030   assert(f([x],1) = abs(x)),
00031   assert(f([x,y],1) = abs(x) + abs(y)),
00032   assert(f([x,y,z],1) = abs(x) + abs(y) + abs(z)),
00033   assert(f([x],inf) = abs(x)),
00034   assert(f([x,y],inf) = max(abs(x), abs(y))),
00035   assert(f([x,y,z],inf) = max(abs(x), abs(y), abs(z))),
00036   assert(f([x],2) = abs(x)),
00037   assert(f([x,y],2) = sqrt(abs(x)^2 + abs(y)^2)),
00038   assert(f([x,y,z],2) = sqrt(abs(x)^2 + abs(y)^2 + abs(z)^2)),
00039   true)$
00040 
00041 okltest_dist_vec(f) := block([x1,x2,x3,y1,y2,y3,p],
00042   assert(f([],[],p) = 0),
00043   assert(f([x1],[x2],1) = abs(x1-x2)),
00044   assert(f([x1,y1],[x2,y2],1) = abs(x1-x2) + abs(y1-y2)),
00045   assert(f([x1,y1,z1],[x2,y2,z2],1) = abs(x1-x2) + abs(y1-y2) + abs(z1-z2)),
00046   assert(f([x1],[x2],inf) = abs(x1-x2)),
00047   assert(f([x1,y1],[x2,y2],inf) = max(abs(x1-x2), abs(y1-y2))),
00048   assert(f([x1,y1,z1],[x2,y2,z2],inf) = max(abs(x1-x2), abs(y1-y2), abs(z1-z2))),
00049   assert(f([x1],[x2],2) = abs(x1-x2)),
00050   assert(expand(f([x1,y1],[x2,y2],2) = sqrt(abs(x1-x2)^2 + abs(y1-y2)^2))),
00051   assert(expand(f([x1,y1,z1],[x2,y2,z2],2) = sqrt(abs(x1-x2)^2 + abs(y1-y2)^2 + abs(z1-z2)^2))),
00052   true)$
00053