Changeset 6555d4 in git


Ignore:
Timestamp:
Nov 23, 1999, 3:13:21 PM (24 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
Children:
9c72f1557a4e178282a833fd0b0e1157c9be9447
Parents:
554cc12c045d22add0c2db3e6302e34f78c5d91a
Message:
* added procedures from Tst/lib


git-svn-id: file:///usr/local/Singular/svn/trunk@3891 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/tst.lib

    r554cc12 r6555d4  
    1 // $Id: tst.lib,v 1.20 1999-10-25 08:32:20 obachman Exp $
     1// $Id: tst.lib,v 1.21 1999-11-23 14:13:21 obachman Exp $
    22//(obachman, last modified 6/30/98)
    33/////////////////////////////////////////////////////////////////////////////
    44
    5 version="$Id: tst.lib,v 1.20 1999-10-25 08:32:20 obachman Exp $";
     5version="$Id: tst.lib,v 1.21 1999-11-23 14:13:21 obachman Exp $";
    66info="
    77LIBRARY:  tst.lib      PROCEDURES FOR RUNNING AUTOMATIC TST TESTS
     
    529529}
    530530
     531/////////////////////////////////////////////////////////////////////////////
     532//
     533// Here are still a couple of procedures which used to be in
     534// Tst/Old
     535proc prideal (ideal id)
     536{
     537  "// ideal";
     538  for (int @i=1; @i<=nrows(id); @i=@i+1)
     539  {
     540    "//id[" +  string(@i) + "] : "+  string(id[@i]);
     541  }
     542  "// dim  :", dim(id);
     543  "// mult :", multiplicity(id);
     544  return();
     545}
     546
     547proc formmat (matrix m)
     548{
     549  int @elems = 0;
     550  int @mlen  = 0;
     551  int @slen  = 0;
     552  int @c;
     553  for (int @r=1; @r<=nrows(m); @r=@r+1)
     554  {
     555    for (@c=1; @c<=ncols(m); @c=@c+1)
     556    {
     557      @elems = @elems + 1;
     558      string @s(@elems) = string(m[@r,@c]);
     559      @slen = size(@s(@elems));
     560      if (@slen > @mlen)
     561      {
     562        @mlen = @slen;
     563      }
     564    }
     565  }
     566  @elems = 0;
     567  string @aus = "";
     568  string @sep = " ";
     569  if (@mlen * ncols(m) >= pagewidth)
     570  {
     571    @sep = newline;
     572  }
     573  for (@r=1; @r<=nrows(m); @r=@r+1)
     574  {
     575    for (@c=1; @c<=ncols(m); @c=@c+1)
     576    {
     577      @elems = @elems + 1;
     578      @slen = size(@s(@elems));
     579      @aus = @aus + @s(@elems)[1,@mlen] + @sep;
     580    }
     581    @aus = @aus + newline;
     582//    @aus = "";
     583  }
     584  return(@aus);
     585}
     586proc fixmat (matrix m,int l)
     587{
     588  string @aus;
     589  string @tmp;
     590  int @ll;
     591  int @c;
     592  for (int @r=1; @r<=nrows(m); @r=@r+1)
     593  {
     594    @aus = "";
     595    for (@c=1; @c<=ncols(m); @c=@c+1)
     596    {
     597      @tmp = string(m[@r,@c]);
     598      @aus = @aus + @tmp[1,l] + " ";
     599    }
     600    @aus;
     601  }
     602}
     603proc stransp (int r, int c, list #)
     604{
     605  // transpose a submatrix
     606  matrix @m[r][c];
     607  int @ii = 1;
     608  int @j;
     609  for (int @i = 1; @i<=r; @i=@i+1)
     610  {
     611    for (@j = 1; @j<=c; @j=@j+1)
     612    {
     613      @m[@i,@j] = #[@ii];
     614      @ii=@ii+1;
     615    }
     616  }
     617  return(transpose(@m));
     618}
     619proc unitmat (int r, list #)
     620{
     621  // create an unit matrix, # is optional
     622  poly @p = 1;
     623  if (size(#) == 1)
     624  {
     625    @p = #[1];
     626  }
     627  matrix @m[r][r];
     628  return (@m + @p);
     629}
     630//
     631// declare a ring with a different dialog
     632// using defaults etc;
     633//
     634
     635proc permute (int n, list #)
     636{
     637  //if (#ARGS == 2)
     638  //{
     639  //  string @actionstring = #action +"();";
     640  //}
     641  if (defined(PERMUTE_DATA) or defined(PERMUTE_WORK))
     642  {
     643    "permute: PERMUTE_WORK/DATA already defined, please kill them!";
     644    return();
     645  }
     646  //
     647  // initialize global data
     648  //
     649  intvec PERMUTE_DATA = n;  // must be global
     650  intvec PERMUTE_WORK = 1;   // must be global
     651  export PERMUTE_DATA, PERMUTE_WORK;
     652  for (int @i=#n-1; @i>0; @i=@i-1)
     653  {
     654    PERMUTE_DATA = PERMUTE_DATA, @i;
     655    PERMUTE_WORK = PERMUTE_WORK, 1;
     656  }
     657  int @done = 0;
     658  while (@done == 0)
     659  {
     660    "permute", PERMUTE_DATA;  // this could be an action call
     661    //if (#ARGS == 2)
     662    //{
     663    //  execute @actionstring;
     664    //}
     665    @done = next_permute(n);
     666  }
     667  kill PERMUTE_DATA, PERMUTE_WORK;
     668  return ("-----------");
     669}
     670
     671proc next_permute (int n)
     672{
     673  int @rc = 1;
     674  if (n > 1)
     675  {
     676    if(PERMUTE_WORK[n] < n)
     677    {
     678      PERMUTE_DATA[PERMUTE_WORK[n]] = PERMUTE_DATA[PERMUTE_WORK[n] + 1];
     679      PERMUTE_DATA[PERMUTE_WORK[n] + 1] = n;
     680      PERMUTE_WORK[n] = PERMUTE_WORK[n] + 1;
     681      return(0);
     682    }
     683    @rc = next_permute(n-1);
     684    for(int @i=n-1; @i>=1; @i=@i-1)
     685    {
     686      PERMUTE_DATA[@i+1] = PERMUTE_DATA[@i];
     687    }
     688    PERMUTE_DATA[1] = n;
     689    PERMUTE_WORK[n] = 1;
     690    return(@rc);
     691  }
     692  return (@rc);
     693}
     694//
     695// permutations as described in:
     696//   data structures, algorithms, and program style using c
     697//   james f. korsh
     698//   leonard j. garrett
     699//   pp. 162
     700//
     701proc permute1 (int n)
     702{
     703  int @done = 0;
     704  while (@done == 0)
     705  {
     706    "permute", all;  // this could be an action call
     707    @done = next(n);
     708  }
     709  return ("-----------");
     710}
     711proc next (int n)
     712{
     713  int @rc = 1;
     714  if (n > 1)
     715  {
     716    if(l[n] < n)
     717    {
     718      all[l[n]] = all[l[n] + 1];
     719      all[l[n] + 1] = n;
     720      l[n] = l[n] + 1;
     721      return(0);
     722    }
     723    @rc = next(n-1);
     724    for(int @i=n-1; @i>=1; @i=@i-1)
     725    {
     726      all[@i+1] = all[@i];
     727    }
     728    all[1] = n;
     729    l[n] = 1;
     730    return(@rc);
     731  }
     732  return (@rc);
     733}
Note: See TracChangeset for help on using the changeset viewer.