OKlibrary  0.2.1.6
Conversions.mac
Go to the documentation of this file.
```00001 /* Matthew Gwynne, 5.4.2008 (Swansea) */
00002 /* Copyright 2008, 2010 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 kill(f)\$
00025
00027   assert(f("","x",0) = ""),
00028   assert(f("","x",-1) = ""),
00029   assert(f("","x",1) = "x"),
00030   assert(f("x","y",0) = "x"),
00031   assert(f("x","y",1) = "x"),
00032   assert(f("x","y",2) = "yx"),
00033   for n : -3 thru 4 do
00034     assert(f("test","c",n) = "test"),
00035   assert(f("","-",1) = "-"),
00036   assert(f("","-",2) = "--"),
00037   assert(f("abc","d",4) = "dabc"),
00038   true)\$
00039
00040
00041 okltest_int2poly(f) := block([x],
00042   for n : 1 thru 3 do
00043     assert(f(0,n) = 0),
00044   /*for n : -12 thru 12 do
00045     assert(f(n,abs(n)+1) = n),*/
00046   for n : 2 thru 10 do
00047     assert(f(n,n) = x),
00048   assert(f(275,2) = x^8+x^4+x+1),
00049   assert(f(423423,15) = 8*x^4+5*x^3+6*x^2+13*x+3),
00050   true)\$
00051
00052 okltest_poly2int(f) := block([x],
00053   for n : 1 thru 3 do
00054     assert(f(0,n,x) = 0),
00055   for n : -12 thru 12 do
00056     assert(f(n,abs(n)+1,x) = n),
00057   for n : 2 thru 10 do
00058     assert(f(x,n,x) = n),
00059   assert(f(x^8+x^4+x+1,2,x) = 275),
00060   assert(f(a^8+a^4+a+1,2,a) = 275),
00061   assert(f(8*x^4+5*x^3+6*x^2+13*x+3,15,x) = 423423),
00062   true)\$
00063
00064 okltest_hex2il(f) := block(
00065   assert(f("") = []),
00066   assert(f("00") = [0]),
00067   assert(f("32488853038D31734198AA2E0370D450") =
00068   [50,72,136,83,3,141,49,115,65,152,170,46,3,112,212,80]),
00069   true)\$
00070
00071 okltest_il2hex(f) := block(
00072   assert(f([]) = ""),
00073   assert(f([0]) = "00"),
00074   assert(f([50,72,136,83,3,141,49,115,65,152,170,46,3,112,212,80])
00075   = "32488853038D31734198AA2E0370D450"),
00076   true)\$
00077
```