OKlibrary  0.2.1.6
Conversions.mac
Go to the documentation of this file.
00001 /* Oliver Kullmann, 21.7.2008 (Swansea) */
00002 /* Copyright 2008, 2009 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    * Handling symbols *
00029    ********************
00030 */
00031
00032 okltest_indexed_symbol(f) := block(
00033  [special_symbol : "x", x1, y, xy],
00034   assert(f(1) = x1),
00035   assert(f(y) = xy),
00036   true)\$
00037
00038
00039 /* ********************************************
00040    * Auxiliary functions handling "equations" *
00041    ********************************************
00042 */
00043
00044 okltest_translate_vector_lincomb(f) := block(
00045  [special_symbol : "x", x1,x2,x3,x4],
00046   assert(f([]) = 0),
00047   assert(f([1,4,7]) = 1 * x1 + 4 * x2 + 7 * x3),
00048   assert(f([0,1,2,-3]) = x2 + 2*x3 + -3*x4),
00049   true)\$
00050
00051 okltest_translate_matrix_ineq(f) := block(
00052  [special_symbol : "x", x1,x2],
00053   assert(f(matrix()) = []),
00054   assert(f(matrix([])) = [0 >= 0]),
00055   assert(f(matrix([],[])) = [0 >= 0, 0 >= 0]),
00056   assert(f(matrix([1],[2])) = [x1 >= 0, 2*x1 >= 0]),
00057   assert(f(matrix([2,3],[4,5])) = [2*x1 + 3*x2 >= 0, 4*x1 + 5*x2 >= 0]),
00058   true)\$
00059
00060 okltest_interprete_poscond(f) := block(
00061  [special_symbol : "x", x0],
00062   assert(f(0) = '(x0 >= 1)),
00063   true)\$
00064 okltest_interprete_negcond(f) := block(
00065  [special_symbol : "x", x1],
00066   assert(f(1) = '(x1 <= -1)),
00067   true)\$
00068 okltest_interprete_zerocond(f) := block(
00069  [special_symbol : "x", x2],
00070   assert(f(2) = '(x2 = 0)),
00071   true)\$
00072
00073