"Fossies" - the Fresh Open Source Software Archive

Member "KASH3-lib-archindep-2008-07-31/lib/init.g" (3 Sep 2008, 14355 Bytes) of package /linux/misc/old/KASH3-lib-archindep-2008-07-31.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 VERLIB := "KANT V4 2005-10-10 ; GAP v3r3p0 1993-11-09";
    2 if not IsBound( VERSRC ) then  VERSRC := "unknown";  fi;
    3 if not IsBound( VERSYS ) then  VERSYS := "unknwon";  fi;
    4 
    5 if not IsBound(VERBUILD) then 
    6   VERBUILD := Replace(Pipe("uname -s","")+" unknown","\n",""); 
    7 fi;
    8 
    9 VERSION := [];
   10 Append_( VERSION,   "lib: " );   Append_( VERSION, VERLIB );
   11 Append_( VERSION, ", src: " );   Append_( VERSION, VERSRC );
   12 Append_( VERSION, ", sys: " );   Append_( VERSION, VERSYS );
   13 Append_( VERSION, ", build: " ); Append_( VERSION, VERBUILD );
   14 Print("\c");
   15 
   16 ######################################################################
   17 ##Print(_USE_DOC_DUMP_P,"\n");
   18 ######################################################################
   19 if not QUIET and BANNER then
   20 PR := function ( str )  Print("     ",str,"\n");  end;
   21 PR("                                                                    ");
   22 PR("                                                           ooooqp   ");
   23 PR("   oooo    oooo       .o.        .oooooo..o ooooo   ooooo    .dP'   ");
   24 PR("   `888   .8P'       .888.      d8P'    `Y8 `888'   `888'   d88b.   ");
   25 PR("    888  d8'        .8'888.     Y88bo.       888     888   o.  )8   ");
   26 PR("    88888K         .8' `888.     `'Y8888o.   888ooooo888   `888P'   ");
   27 PR("    888`88b.      .88ooo8888.        `'Y88b  888     888            ");
   28 PR("    888  `88b.   .8'     `888.  oo     .d8P  888     888            ");
   29 PR("   o888o  o888o o88o     o8888o 8''88888P'  o888o   o888o           ");
   30 PR("                                                                    ");
   31 Print("     Shell of the KANT V4 Software, Version 3, build: ",VERBUILD,"\n");
   32 PR("                                                                    ");
   33 PR("Copyright (c) 1994-2005 Prof. Dr. M. E. Pohst,                      ");
   34 PR("Technische Universitaet Berlin. All rights reserved.                ");
   35 PR("                                                                    ");
   36 PR("For registration and support send an email to kant@math.tu-berlin.de");
   37 PR("--------------------------------------------------------------------");
   38 PR("KANT V4 is based on Magma developed by Prof. J. Cannon,                ");
   39 PR("Copyright (c) 2002 Prof. J. Cannon, University of Sydney.           ");
   40 PR("Shell is based on GAP developed by Lehrstuhl D Mathematik, RWTH Aachen,");
   41 PR("Copyright (c) 1992 Lehrstuhl D Mathematik, RWTH Aachen.             ");
   42 PR("                                                                    ");
   43 PR("Enter \"?\" for help and \"quit;\" to leave KASH                    ");
   44 PR("                                                                    ");
   45 fi;
   46 ReadIndent := "";
   47 ######################################################################
   48 ######################################################################
   49 # Auxiliary global vars
   50 #
   51 
   52 Unbind(Ignore);
   53 
   54 _Ignore_Me:=
   55   function(arg)
   56     return VOID;
   57   end;
   58 
   59 Ignore := _Ignore_Me;
   60 
   61 if not IsBound( InfoRead1 )  then InfoRead1 := _Ignore_Me; fi;
   62 if not IsBound( InfoRead2 )  then InfoRead2 := _Ignore_Me; fi;
   63 
   64 __ARGREC:=rec();
   65 
   66 __CURRENT_LIB := "init.g";
   67 __PREVIOUS_LIB := "init.g";
   68 _PackageBanner := "";
   69 
   70 #############################################################################
   71 ##
   72 #F  CheckArgs( <record> )
   73 ##
   74 ## see init-methods for documentation
   75 CheckArgs:=
   76   function(argl,bind,defaults)
   77     local i,lim,argrec;
   78     argrec:=rec();
   79     for i in [1..Length(bind)] do
   80       if IsBound(defaults[i]) then
   81         __ARGREC.(bind[i]):=defaults[i];
   82         argrec.(bind[i]):=defaults[i];
   83       else
   84         __ARGREC.(bind[i]):=FAILURE;
   85         argrec.(bind[i]):=FAILURE;
   86       fi;
   87     od;
   88     if Length(bind)<Length(argl) then
   89       lim := Length(bind);
   90     else
   91       lim := Length(argl);
   92     fi;
   93     for i in [1..lim] do
   94       if IsBound(argl[i]) then
   95         __ARGREC.(bind[i]):=argl[i];
   96         argrec.(bind[i]):=argl[i];
   97       fi;
   98     od;
   99     return argrec;
  100   end;
  101 
  102 IsSuccess:=i->not(i=FAILURE);
  103 IsFailure:=i->i=FAILURE;
  104 
  105 
  106 HasOptarg:=
  107   function(argl)
  108     if IsList(argl) and Length(argl)>0 and
  109        Type(argl[Length(argl)])=record then
  110       return TRUE;
  111     else
  112       return FALSE;
  113     fi;
  114   end;
  115 
  116 ExtractOptarg:=
  117   function(argl)
  118     local optarg;
  119     if HasOptarg(argl) then
  120       return argl[Length(argl)];
  121     else
  122       # return empty record if not optarg was found
  123       return FAILURE; #rec();
  124     fi;
  125   end;
  126 
  127 ExtractOptarg_:=
  128   function(argl)
  129     local optarg;
  130     optarg := ExtractOptarg(argl);
  131     if IsSuccess(optarg) then
  132       _Remove__list_eor(argl,Length(argl));
  133     fi;
  134     return optarg;
  135   end;
  136 
  137 Optarg :=
  138   function(argl,bind,defaults)
  139     local i,optarg;
  140     optarg := ExtractOptarg_(argl);
  141     if optarg=FAILURE then
  142       optarg:=rec();
  143     fi;
  144     for i in [1..Length(bind)] do
  145       if not IsBound(optarg.(bind[i])) then
  146         optarg.(bind[i]):=defaults[i];
  147       fi;
  148     od;
  149    
  150     return optarg;
  151   end;
  152 
  153 
  154 __FAILUREDOC:=[any,"Fail","Determines what to return in case of failure.",rec(Default:=FAILURE)];
  155 __SUCCESSDOC:=[any,"Success","Determines what to return in case of success.",rec(Default:=SUCCESS)];
  156 __FAILUREREC:=rec(Fail:=FAILURE,Failure:=FAILURE);
  157 __SUCCESSREC:=rec(Success:=SUCCESS);
  158 __FAILSUCCREC:=rec(Fail:=FAILURE,Success:=SUCCESS);
  159 
  160 
  161 ### wtf? thought we had this :(
  162 StringSplit := function( string, separator )
  163   local mpos, result, j, tmpstring, startpos, endpos, length;
  164   mpos := StringMatchPositions(separator, string);
  165 
  166   if Length(mpos) = 0 then
  167     return [string];
  168   fi;
  169 
  170   result := [];
  171   for j in [1..Length(mpos)] do
  172     if j>1 then
  173       startpos := mpos[j-1][2];
  174     else
  175       startpos := 1;
  176     fi;
  177     endpos := mpos[j][1];
  178     length := endpos-startpos;
  179     tmpstring := Substring(string, startpos, length);
  180     _Add__list_any(result,tmpstring);
  181   od;
  182   endpos:=mpos[Length(mpos)][2];
  183   length:=Length(string)+1-endpos;
  184   if length>0 then
  185     _Add__list_any(result,Substring(string,endpos,length));
  186   elif length=0 then
  187     _Add__list_any(result,"");
  188   fi;
  189 
  190   return result;
  191   end;
  192 
  193 
  194 ReadPath := function ( paths, name, exts, infomsg )
  195     local readIndent, pathlist, path, file, found, ext, i;
  196 
  197     ## what's this ReadIndent stupidity?
  198     readIndent := Copy( ReadIndent );
  199     Append_( ReadIndent, "  " );
  200     found := false;
  201 
  202     ## now we expect paths to be a list, if not regard it as string and split
  203     ## accordingly
  204     if Type(paths)=string then
  205       pathlist := StringSplit(paths,";");
  206     else
  207       pathlist := paths;
  208     fi;
  209 
  210     ## now we expect exts to be a list, if not it's a single string atom which
  211     ## in turn is wrapped into a list
  212     if Type(exts)=string then
  213       exts := [exts];
  214     fi;
  215 
  216     ## now recurse on pathlist and try combinations of any element in path with
  217     ## any element in ext
  218     while found=FALSE and Length(pathlist) > 0 do
  219       path := pathlist[1];
  220       file := path + name;
  221       i := 1;
  222       while found=FALSE and i<=Length(exts) do
  223         ext := exts[i];
  224         __PREVIOUS_LIB := __CURRENT_LIB;
  225         __CURRENT_LIB := name+ext;
  226         found := READ( file+ext );
  227         __CURRENT_LIB := __PREVIOUS_LIB;
  228         i := i+1;
  229       od;
  230       Remove_(pathlist,1);
  231     od;
  232     ReadIndent := readIndent;
  233     return found;
  234 end;
  235 
  236 
  237 
  238 FindPath := function ( paths, name, exts )
  239     local pathlist, path, file, found, ext, i;
  240     found := false;
  241     
  242     ## now we expect paths to be a list, if not regard it as string and split
  243     ## accordingly
  244     if Type(paths)=string then
  245       pathlist := StringSplit(paths,";");
  246     else
  247       pathlist := paths;
  248     fi;
  249 
  250     ## now we expect exts to be a list, if not it's a single string atom which
  251     ## in turn is wrapped into a list
  252     if Type(exts)=string then
  253       exts := [exts];
  254     fi;
  255 
  256     ## now recurse on pathlist and try combinations of any element in path with
  257     ## any element in ext
  258     ## now recurse on pathlist and try combinations of any element in path with
  259     ## any element in ext
  260     while found=FALSE  and Length(pathlist) > 0 do
  261       path := pathlist[1];
  262       file := path + name;
  263       i := 1;
  264       while found=FALSE and i<=Length(exts) do
  265         ext := exts[i];
  266         __PREVIOUS_LIB := __CURRENT_LIB;
  267         __CURRENT_LIB := name+ext;
  268         found := Open( file+ext, "r");
  269         __CURRENT_LIB := __PREVIOUS_LIB;
  270         i := i+1;
  271       od;
  272       Remove_(pathlist,1);
  273     od;
  274     if found=FALSE then
  275       return FALSE;
  276     else
  277       Close(found);
  278       return file+ext;
  279     fi;
  280 end;
  281 
  282 #/*TEX**TEX|***TEX***TEX***TEX***TEX**TEX***TEX***TEX***TEX***TEX***TEX***TEX**
  283 #FXN       Read
  284 #CALLING   Read(name);
  285 #SHORTDOC  Read a file containing \KASH\ commands.
  286 #LONGDOC   The file "name" must be both existing and readable.
  287 #          \KASH\ looks first in the given path, then in the current directory
  288 #          and finally in {\tt LIBNAME../src}. 
  289 #ARGUS     name @ string
  290 #EXAMPLE   Assume that we have a file named "in" in our current
  291 #          working directory. First, we take a look at its contents: @ 
  292 #          kash> Exec("cat in");
  293 #          Time(true);
  294 #          x := Poly(Zx, [1,0]);
  295 #          Palg := function(O)
  296 #            local px;
  297 #            px := PolyAlg(O);
  298 #            x := Poly(px, [1,0]);
  299 #            return px;
  300 #          end;
  301 #
  302 #          kash> Read("in");
  303 #          kash> x;
  304 #          x
  305 #          Time: 0 ms
  306 #
  307 #
  308 #**HISTORY*|*HISTORY***HISTORY***HISTORY**HISTORY***HISTORY***HISTORY***HISTORY
  309 #
  310 #**C***C***|***C***C***C***C***C***C**C***C***C***C***C***C***C***C***C***C***/
  311 Read := function ( filename )
  312   ## Banner handling
  313   _PackageBanner := "";
  314 
  315   if not ReadPath( ";./;"+ LIBNAME + ";"+ LIBNAME + "../src/", filename,
  316                    ["",".g",".k"], "Read" ) then
  317     Error("the file '",filename,"' must exist and be readable");
  318   fi;
  319 
  320   Print(_PackageBanner);
  321 end;
  322 
  323 
  324 #/*TEX**TEX|***TEX***TEX***TEX***TEX**TEX***TEX***TEX***TEX***TEX***TEX***TEX**
  325 #FXN       ReadLib
  326 #CALLING   ReadLib(name);
  327 #SHORTDOC  The same as Read, but here the file should be in the
  328 #          \KASH\ lib directory and it must have the extension ``.g''.
  329 #ARGUS     name @ string
  330 #XREF      Read
  331 #EXAMPLE   We will read the neq.g library. This will define a function
  332 #          solving norm equations by suitable principal ideal tests. @ 
  333 #          kash> ReadLib("neq");
  334 #          kash> Neq(o, 7);
  335 #          Prime 7: 1 [ 2 ]
  336 #          No solution
  337 #          false
  338 #          Time: 40 ms
  339 #          kash> Neq(o, 11);
  340 #          Prime 11: 1 [ 1, 1 ]
  341 #          [ [ [ [ <11, [5, 2]>, 1 ], [ <11, [8, 2]>, 1 ] ], [ 0, 1 ], [ 1, 0 ] ] ]
  342 #          at most 2 different solutions! 
  343 #          Ideals : [ [ <11, [5, 2]>, 1 ], [ <11, [8, 2]>, 1 ] ]
  344 #          Ideal Basis of all (possible) solutions: [ [ <11, [8, 2]>, <11, [5, 2]> ] ] 
  345 #          [ [1, 3], [-2, -3] ]
  346 #          Time: 260 ms
  347 #          kash> OrderNormEquation(o, 11, -1);
  348 #          [ [-2, -3], [-1, -3] ]
  349 #          Time: 180 ms
  350 #**HISTORY*|*HISTORY***HISTORY***HISTORY**HISTORY***HISTORY***HISTORY***HISTORY
  351 #
  352 #**C***C***|***C***C***C***C***C***C**C***C***C***C***C***C***C***C***C***C***/
  353 ReadLib:=
  354   function(arg)
  355     local name, optarg,
  356       ## Profiling
  357       stime,etime;
  358 
  359     ## Banner handling
  360     _PackageBanner := "";
  361 
  362     ## now check args >8)
  363     CheckArgs(arg,["name","optarg"],[,rec(IgnoreErrors:=FALSE,Fail:=FAILURE)]);
  364     name:=__ARGREC.("name");
  365     optarg:=__ARGREC.("optarg");
  366 
  367     if not(QUIET) and BANNER then
  368       stime:=UTime();
  369       Print(name);
  370     fi;
  371     if not(ReadPath(LIBNAME+ ";"+ LIBNAME + "../src/", name, [".g", ".k"], "ReadLib"))  then
  372       Print("(m) ");
  373       if IsBound(optarg.("IgnoreErrors")) and optarg.("IgnoreErrors") then
  374         return SUCCESS;
  375       elif IsBound(optarg.("Fail")) then
  376         return optarg.("Fail");
  377       else
  378         Error("the library file '",name,"' must exist and be readable");
  379       fi;
  380     fi;
  381     if not(QUIET) and BANNER then
  382       Print(" ");
  383       etime:=UTime();
  384       Print("[",etime-stime,"] ");
  385       Print(_PackageBanner);
  386     fi;
  387 
  388     return SUCCESS;
  389   end;
  390 
  391 
  392 ##############################################################################
  393 
  394 ## Type Atom definitions must occur early.  Put all of them here.
  395 ## The Type Atoms must be defined before __DOC is read.
  396 
  397 ## Read list utils very first lest circular dependencies occur -SF
  398 ReadLib("list",rec(IgnoreErrors:=TRUE));
  399 ReadLib("alist",rec(IgnoreErrors:=TRUE));
  400 ReadLib("term",rec(IgnoreErrors:=TRUE));
  401 
  402 ## Read documentation utils first lest circular dependencies occur -SF
  403 ReadLib("__DOC",rec(IgnoreErrors:=TRUE));
  404 
  405 ReadLib("doc",rec(IgnoreErrors:=TRUE));
  406 ReadLib("docui",rec(IgnoreErrors:=TRUE));
  407 ## stupid but necessary due to double linked forward declarations
  408 ReadLib("docui",rec(IgnoreErrors:=TRUE));  
  409 
  410 ReadLib("method",rec(IgnoreErrors:=TRUE));
  411 ## here follows documentation and definition of overloaded functions
  412 ReadLib("init-methods",rec(IgnoreErrors:=TRUE));
  413 
  414 ReadLib("constants",rec(IgnoreErrors:=TRUE));
  415 ReadLib("kash",rec(IgnoreErrors:=TRUE));
  416 ReadLib("matrix",rec(IgnoreErrors:=TRUE));
  417 ReadLib("map",rec(IgnoreErrors:=TRUE));
  418 
  419 _QaosBannerShown:=TRUE;
  420 ReadLib("qaos",rec(IgnoreErrors:=TRUE));
  421 
  422 #ReadLib("powerSer",rec(IgnoreErrors:=TRUE));
  423 ReadLib("locFact",rec(IgnoreErrors:=TRUE));
  424 ReadLib("unit_group_res",rec(IgnoreErrors:=TRUE));
  425 
  426 #####################################################################
  427 # some default settings
  428 #####################################################################
  429 
  430 Colors(true);
  431 Colors("prompt",  "green");
  432 Colors("normal",  "magenta");
  433 Colors("error",   "red");
  434 #Colors("command", "black");
  435 if "Windows" in VERBUILD then 
  436 # the background of the DOS window is black by default
  437   Colors("result",  "cyan");
  438 else
  439 Colors("result",  "blue");
  440 fi;
  441 Time(true);
  442 Print("\n");
  443 
  444 ######################################################################
  445 # global variable indicating that the doc dump should not be used
  446 ######################################################################
  447 
  448 _USE_DOC_DUMP_P := FALSE;
  449 
  450 ######################################################################
  451 
  452 ## have to be AFTER definitions of GetVerbose and SetVerbose --
  453 ## they are defined in kash.g
  454 
  455 AUTO(ReadLib("elliptic"),EllipticCurve);
  456 #AUTO(ReadLib("unit_group_res/unit_group_res"),UnitGroup,Intersection);
  457 #AUTO(ReadLib("zetaMod"),ZetaMod);
  458 
  459 ##########################################################################
  460 
  461 __CURRENT_LIB := "<interactive environment>";
  462