Changeset 9ebfb1b in git for Singular/LIB


Ignore:
Timestamp:
May 24, 1998, 11:04:13 AM (26 years ago)
Author:
Olaf Bachmann <obachman@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
96b804631b095d8928ec2c241293ce9015190de7
Parents:
4450163d09cf95a4bb144b396250a639a524f7a6
Message:
* changed version to 1.2.0


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/tst.lib

    r445016 r9ebfb1b  
    1 // $Id: tst.lib,v 1.6 1998-05-15 16:18:19 obachman Exp $
     1// $Id: tst.lib,v 1.7 1998-05-24 09:04:13 obachman Exp $
    22//(obachman, last modified 2/13/98)
    3 ///////////////////////////////////////////////////////////////////////////////
    4 
    5 version="$Id: tst.lib,v 1.6 1998-05-15 16:18:19 obachman Exp $";
     3/////////////////////////////////////////////////////////////////////////////
     4
     5version="$Id: tst.lib,v 1.7 1998-05-24 09:04:13 obachman Exp $";
    66info="
    77LIBRARY:  tst.lib      PROCEDURES FOR RUNNING AUTOMATIC TST TESTS
     8
    89
    910 tst_system(s)          returns string which is stdout of system(\"sh\", s)
     
    1213 tst_init()             writes some identification data to stdout
    1314                        with tst_ignore
     15 tst_groebnerTest(ideal i) 
     16                        tests groebner command
     17 tst_stdEqual(ideal i1, ideal i2)
     18                        test whether two std's are \"equal\"
    1419";
    1520
    16 ///////////////////////////////////////////////////////////////////////////////
     21/////////////////////////////////////////////////////////////////////////////
    1722
    1823proc tst_system(string s)
     
    149154}
    150155
    151 
    152 
     156///////////////////////////////////////////////////////////////////////
     157
     158proc tst_groebnerTest(ideal i, list #)
     159"USAGE: tst_groebnerTesti,[v]) : ideal i, [int v]
     160RETURN: 1, if groebner command produced \"equal\" std as std command
     161        0, otherwise
     162        Two std's are \"equal\" here, if their redSB's are element-wise equal,
     163        and if they reduce each other to zero, and if their leading ideals
     164        are equal
     165        On success, times of std - groebner is written with tst_ignore, and
     166        times are added to global variables tst_std_time and
     167        tst_groebner_time. If v given, and <= 0, short ideal
     168        characteristic is print, if v > 0, ideals are printed.
     169        On failure, Error message and ideals are printed.
     170EXAMPLE: example tst_groebner; shows an example
     171"
     172{
     173  int st = timer;
     174  ideal si = std(i);
     175  st = timer - st;
     176 
     177  int gt = timer;
     178  ideal gi = groebner(i);
     179  gt = timer - gt;
     180
     181  if (tst_stdEqual(si, gi))
     182  {
     183    tst_ignore(string(st) + " - " + string(gt) + " == " + string(st - gt));
     184    if (! defined(tst_groebner_time))
     185    {
     186      int tst_groebner_time;
     187      int tst_std_time;
     188      export tst_groebner_time, tst_std_time;
     189    }
     190    tst_std_time = tst_std_time + st;
     191    tst_groebner_time = tst_groebner_time + gt;
     192    if (size(#))
     193    {
     194      if (typeof(#[1] == "int"))
     195      {
     196        if (#[1] <= 0)
     197        {
     198          idPrintShort(si, "si");
     199          idPrintShort(gi, "gi");
     200        }
     201        else
     202        {
     203          si;
     204          gi;
     205        }
     206      }
     207    }
     208    return (1);
     209  }
     210  return (0);
     211}
     212example
     213{
     214  "EXAMPLE: "; echo = 2;
     215  ring r = 0, (a,b,c,d), lp;
     216  ideal i = a+b+c+d, ab+ad+bc+cd, abc+abd+acd+bcd, abcd-1; // cyclic 4
     217  tst_groebnerTest(i);
     218  tst_groebnerTest(i, 0);
     219  tst_groebnerTest(i, 1);
     220}
     221
     222 
     223//
     224// A routine which test for equality of "std-bases"
     225//
     226proc tst_stdEqual(ideal i1, ideal i2)
     227"USAGE: tst_stdEqual(i1, i2)  ideal i1, i2
     228RETURN 1, if i1 \"equald\" i2 as a std bases
     229       0, otherwise
     230       Two std's are \"equal\" here, if their redSB's are element-wise equal,
     231       and if they reduce each other to zero, and if their leading ideals
     232       are equal
     233       On failure, error message is printed.
     234EXAMPLE: example tst_stdEqual; shows an example
     235"
     236{
     237  int i;
     238  int back;
     239  intvec opts = option(get);
     240  option(redSB);
     241 
     242  ideal ri1 = simplify(interred(i1), 1);
     243  ideal ri2 = simplify(interred(i2), 1);
     244 
     245  option(set, opts);
     246
     247  if (size(ri1) != size(ri2))
     248  {
     249    "Error in tst_stdEqual: Reduced sizes differ";
     250    size(ri1);
     251    size(ri2);
     252    return(0);
     253  }
     254
     255  for (i=1; i<=size(ri1); i++)
     256  {
     257    if (ri1[i] != ri2[i])
     258    {
     259      "Error in tst_stdEqual: " + string(i) + " th poly differ";
     260      ri1[i];
     261      ri2[i];
     262      return(0);
     263    }
     264  }
     265
     266  // reduced SB are now equal
     267  if (size(reduce(i1, i2, 1)) == 0)
     268  {
     269    if (size(reduce(i2, i1, 1)) == 0)
     270    {
     271      poly p1, p2;
     272     
     273      ideal si1 = simplify(i1, 7);
     274      ideal si2 = simplify(i2, 7);
     275     
     276      if (size(si1) == size(si2))
     277      {
     278        for (i=1; i<=size(si1); i++)
     279        {
     280          p1 = p1 + lead(si1[i]);
     281          p2 = p2 + lead(si2[i]);
     282        }
     283        if (p1 != p2)
     284        {
     285          "Error in tst_stdEqual: Lead monoms differ:";
     286          p1;
     287          p2;
     288          return(0);
     289        }
     290      }
     291      else
     292      {
     293        "Error in tst_stdEqual: size differs:";
     294        size(si1);
     295        size(si2);
     296        return(0);
     297      }
     298    }
     299    else
     300    {
     301      "Error in tst_stdEqual: reduce(i2, i1) != 0";
     302      return(0);
     303    }
     304  }
     305  else
     306  {
     307    back = 1; "Error in tst_stdEqual: reduce(i1, i2) != 0";
     308    return(0);
     309  }
     310
     311  return (1);
     312}
     313example
     314{
     315  "EXAMPLE: "; echo = 2;
     316  ring r = 0, (a,b,c,d), lp;
     317  ideal i = a+b+c+d, ab+ad+bc+cd, abc+abd+acd+bcd, abcd-1; // cyclic 4
     318  tst_stdEqual(groebner(i), std(i));
     319  tst_stdEqual(std(i), i);
     320}
     321
     322static proc idPrintShort(ideal id, string name)
     323{
     324  "Summary of " + name + " (leading monoms and size of polys):";
     325  int i;
     326  for (i = 1; i<=size(id); i++)
     327  {
     328    "[" + string(i) + "]: #" + string(size(id[i])) + ":" + string(lead(id[i]));
     329  }
     330}
     331
     332 
     333
     334
Note: See TracChangeset for help on using the changeset viewer.