Changeset 3ba84c in git


Ignore:
Timestamp:
Apr 6, 1998, 1:09:14 PM (26 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '3720ae8bfcff4a4649ee98a15552089151d2d59b')
Children:
a40e7b27cf6f5cba26e2f3aeecc7c3219181a5f7
Parents:
fa842032519085fea6da2813d2d35f50f4b93491
Message:
***** merge from branch `factory-gcd' to main trunk


git-svn-id: file:///usr/local/Singular/svn/trunk@1329 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory/ftest
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • factory/ftest/fbinops.m4

    rfa8420 r3ba84c  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fbinops.m4,v 1.4 1998-03-31 10:23:59 schmidt Exp $ */
     2/* $Id: fbinops.m4,v 1.5 1998-04-06 11:05:17 schmidt Exp $ */
    33
    44ftestSetNameOfGame( fbinops, `"
     
    161161ftestDivideTest( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm & quot )
    162162{
    163     if ( ! ((quot*g)+(f%g)-f).isZero() ) {
     163    CanonicalForm rem = f % g;
     164    if ( ! ((quot*g)+rem-f).isZero() ) {
    164165        ftestError( CheckError, "f != (f/g)*g+(f%%g)\n" );
    165166        return Failed;
     167    } else if ( f.inBaseDomain() && g.inBaseDomain() && getCharacteristic() == 0
     168                && (rem < 0 || rem > abs( g )) ) {
     169        // check euclidean division in Z
     170        ftestError( CheckError, "!(0 <= f%g < abs(g))\n" );
     171        return Failed;
     172    } else if ( f.inPolyDomain() || g.inPolyDomain() ) {
     173        // check euclidean division in R[x]
     174        Variable x = (mvar( f ) >= mvar( g )) ? mvar( f ) : mvar( g );
     175        if ( rem.isZero() || degree( rem, x ) < degree( g, x ) )
     176            return Passed;
     177        else {
     178            ftestError( CheckError, "degree(rem) >= degree(g)\n" );
     179            return Failed;
     180        }
    166181    } else
    167182        return Passed;
     
    187202        ftestError( CheckError, "f != (f/g)*g+(f%%g)\n" );
    188203        return Failed;
     204    } else if ( f.inBaseDomain() && g.inBaseDomain() && getCharacteristic() == 0
     205                && (rem < 0 || rem > abs( g )) ) {
     206        // check euclidean division in Z
     207        ftestError( CheckError, "!(0 <= f%g < abs(g))\n" );
     208        return Failed;
     209    } else if ( f.inPolyDomain() || g.inPolyDomain() ) {
     210        // check euclidean division in R[x]
     211        Variable x = (mvar( f ) >= mvar( g )) ? mvar( f ) : mvar( g );
     212        if ( rem.isZero() || degree( rem, x ) < degree( g, x ) )
     213            return Passed;
     214        else {
     215            ftestError( CheckError, "degree(rem) >= degree(g)\n" );
     216            return Failed;
     217        }
    189218    } else
    190219        return Passed;
  • factory/ftest/ftest_io.cc

    rfa8420 r3ba84c  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: ftest_io.cc,v 1.12 1998-03-31 10:36:02 schmidt Exp $ */
     2/* $Id: ftest_io.cc,v 1.13 1998-04-06 11:08:28 schmidt Exp $ */
    33
    44//{{{ docu
     
    2222//
    2323
    24 //{{{ CanonicalForm ftestGetCanonicalForm ( const char * canFormSpec )
    25 //{{{ docu
    26 //
    27 // ftestGetCanonicalForm() - read a canonical form from canFormSpec,
    28 //   return it.
    29 //
    30 //}}}
    31 CanonicalForm
    32 ftestGetCanonicalForm ( const char * canFormSpec )
    33 {
    34     const char * stringF = canFormSpec;
    35     stringF = ftestSkipBlancs( stringF );
    36 
    37     // check for a single minus
    38     if ( stringF[0] == '-' ) {
    39         const char * tokenCursor = ftestSkipBlancs( stringF+1 );
    40 
     24//{{{ void ftestReadString ( const char * canFormSpec, CanonicalForm & f )
     25//{{{ docu
     26//
     27// ftestReadString() - read canonical form `f' from `canFormSpec'.
     28//
     29//}}}
     30void
     31ftestReadString ( const char * canFormSpec, CanonicalForm & f )
     32{
     33    canFormSpec = ftestSkipBlancs( canFormSpec );
     34
     35    // check for a single minus and read from stdin
     36    if ( *canFormSpec == '-' ) {
     37        const char * tokenCursor = ftestSkipBlancs( canFormSpec+1 );
    4138        if ( ! *tokenCursor ) {
    42             CanonicalForm f;
    4339            cin >> f;
    44             return f;
     40            return;
    4541        }
    4642    }
    4743
    48     // get string to read canonical form from
    49     if ( *stringF == '$' ) {
    50         const char * tokenCursor = ftestSkipBlancs( stringF+1 );
    51         // read canonical form from environment
    52         stringF = getenv( tokenCursor );
    53         if ( ! stringF )
    54             ftestError( CanFormSpecError,
    55                         "no environment variable `$%s' set\n",
    56                         tokenCursor );
     44    // create terminated CanonicalForm
     45    char * terminatedSpec = new char[ strlen( canFormSpec )+2 ];
     46    char * cursor = terminatedSpec;
     47    while ( *canFormSpec ) {
     48        switch ( *canFormSpec ) {
     49        case '.': *cursor = '*'; break;
     50        case '{': *cursor = '('; break;
     51        case '}': *cursor = ')'; break;
     52        default: *cursor = *canFormSpec; break;
     53        }
     54        canFormSpec++; cursor++;
    5755    }
    58 
    59     // create terminated CanonicalForm
    60     int i = strlen( stringF );
    61     char * terminatedStringF = new char[i+2];
    62     char * stringCursor = terminatedStringF;
    63     while ( *stringF ) {
    64         switch ( *stringF ) {
    65         case '.': *stringCursor = '*'; break;
    66         case '{': *stringCursor = '('; break;
    67         case '}': *stringCursor = ')'; break;
    68         default: *stringCursor = *stringF; break;
    69         }
    70         stringF++; stringCursor++;
    71     }
    72     *stringCursor++ = ';';
    73     *stringCursor = '\0';
    74 
    75     // read f and return it
    76     CanonicalForm f;
    77     istrstream( terminatedStringF ) >> f;
    78     delete [] terminatedStringF;
    79     return f;
    80 }
    81 //}}}
    82 
    83 //{{{ Variable ftestGetVariable ( const char * stringVariable )
    84 //{{{ docu
    85 //
    86 // ftestGetVariable() - read a variable from stringVariable,
    87 //   return it.
    88 //
    89 //}}}
    90 Variable
    91 ftestGetVariable ( const char * stringVariable )
    92 {
    93     Variable v;
    94     stringVariable = ftestSkipBlancs( stringVariable );
    95 
    96     if ( isalpha( *stringVariable ) )
    97         v = Variable( *stringVariable );
    98     else if ( isdigit( *stringVariable ) )
     56    *cursor++ = ';';
     57    *cursor = '\0';
     58
     59    // read f from string
     60    istrstream( terminatedSpec ) >> f;
     61    delete [] terminatedSpec;
     62}
     63//}}}
     64
     65//{{{ void ftestReadString ( const char * varSpec, Variable & v )
     66//{{{ docu
     67//
     68// ftestReadString() - read variable `v' from `varSpec'.
     69//
     70//}}}
     71void
     72ftestReadString ( const char * varSpec, Variable & v )
     73{
     74    varSpec = ftestSkipBlancs( varSpec );
     75
     76    if ( isalpha( *varSpec ) )
     77        v = Variable( *varSpec );
     78    else if ( isdigit( *varSpec ) )
    9979        v = Variable();
    10080    else
    10181        ftestError( CommandlineError,
    102                     "variable expected at `%s'\n", stringVariable );
    103 
    104     stringVariable = ftestSkipBlancs( stringVariable+1 );
    105     if ( *stringVariable )
    106         ftestError( CommandlineError,
    107                     "extra characters after var spec `%s'\n", stringVariable );
    108 
    109     return v;
    110 }
    111 //}}}
    112 
    113 //{{{ int ftestGetint ( const char * stringInt )
    114 //{{{ docu
    115 //
    116 // ftestGetint() - read an integer from stringInt,
    117 //   return it.
    118 //
    119 //}}}
    120 int
    121 ftestGetint ( const char * stringInt )
     82                    "variable expected at `%s'\n", varSpec );
     83
     84    varSpec = ftestSkipBlancs( varSpec+1 );
     85    if ( *varSpec )
     86        ftestError( CommandlineError,
     87                    "extra characters after var spec `%s'\n", varSpec );
     88}
     89//}}}
     90
     91//{{{ void ftestReadString ( const char * intSpec, int & i )
     92//{{{ docu
     93//
     94// ftestReadString() - read integer `i' from `intSpec'.
     95//
     96//}}}
     97void
     98ftestReadString ( const char * intSpec, int & i )
    12299{
    123100    const char * tokenCursor;
    124101
    125     int i = (int)strtol( stringInt, (char**)&tokenCursor, 0 );
     102    i = (int)strtol( intSpec, (char**)&tokenCursor, 0 );
    126103
    127104    // do error checks
    128     if ( stringInt == tokenCursor )
    129         ftestError( CommandlineError,
    130                     "integer expected at `%s'\n", stringInt );
    131 
    132     stringInt = ftestSkipBlancs( tokenCursor );
    133     if ( *stringInt )
    134         ftestError( CommandlineError,
    135                     "extra characters after int spec `%s'\n", stringInt );
    136 
    137     return i;
    138 }
    139 //}}}
    140 
    141 //{{{ bool ftestGetbool ( const char * stringBool )
    142 //{{{ docu
    143 //
    144 // ftestGetbool() - read an boolean from stringBool,
    145 //   return it.
    146 //
    147 //}}}
    148 bool
    149 ftestGetbool ( const char * stringBool )
    150 {
    151     const char * tokenCursor;
    152 
    153     bool b;
     105    if ( intSpec == tokenCursor )
     106        ftestError( CommandlineError,
     107                    "integer expected at `%s'\n", intSpec );
     108
     109    // check for extra characters after skipping blancs
     110    intSpec = ftestSkipBlancs( tokenCursor );
     111    if ( *intSpec )
     112        ftestError( CommandlineError,
     113                    "extra characters after int spec `%s'\n", intSpec );
     114}
     115//}}}
     116
     117//{{{ void ftestReadString ( const char * boolSpec, bool & b )
     118//{{{ docu
     119//
     120// ftestReadString() - read boolean `b' from `boolSpec'.
     121//
     122//}}}
     123void
     124ftestReadString ( const char * boolSpec, bool & b )
     125{
    154126    // skip blancs
    155     stringBool = ftestSkipBlancs( stringBool );
     127    boolSpec = ftestSkipBlancs( boolSpec );
    156128
    157129    // look for "true" or "false"
    158     tokenCursor = ftestSubStr( "true", stringBool );
    159     if ( stringBool != tokenCursor )
     130    const char * tokenCursor = ftestSubStr( "true", boolSpec );
     131    if ( boolSpec != tokenCursor )
    160132        b = true;
    161133    else {
    162         tokenCursor = ftestSubStr( "false", stringBool );
     134        tokenCursor = ftestSubStr( "false", boolSpec );
    163135        b = false;
    164136    }
    165137
    166138    // do error checks
    167     if ( stringBool == tokenCursor )
    168         ftestError( CommandlineError,
    169                     "bool expected at `%s'\n", stringBool );
    170 
    171     // check for extra characters
    172     stringBool = ftestSkipBlancs( tokenCursor );
    173     if ( *stringBool )
    174         ftestError( CommandlineError,
    175                     "extra characters after bool spec `%s'\n", stringBool );
    176 
    177     return b;
     139    if ( boolSpec == tokenCursor )
     140        ftestError( CommandlineError,
     141                    "bool expected at `%s'\n", boolSpec );
     142
     143    // check for extra characters after skipping blancs
     144    boolSpec = ftestSkipBlancs( tokenCursor );
     145    if ( *boolSpec )
     146        ftestError( CommandlineError,
     147                    "extra characters after bool spec `%s'\n", boolSpec );
    178148}
    179149//}}}
     
    232202}
    233203//}}}
     204
     205//{{{ void ftestPrintResult ( const char * resultName, const bool result )
     206//{{{ docu
     207//
     208// ftestPrintResult() - print a boolean.
     209//
     210//}}}
     211void
     212ftestPrintResult ( const char * resultName, const bool result )
     213{
     214    const char * stringResult = result ? "true" : "false";
     215
     216    if ( ftestPrintResultFlag )
     217        cout << "Result:\t\t" << resultName << ": " << stringResult << endl;
     218    else if ( ! ftestPrintFlag )
     219        cout << stringResult << endl;
     220}
     221//}}}
  • factory/ftest/ftest_io.h

    rfa8420 r3ba84c  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: ftest_io.h,v 1.6 1998-03-11 16:11:01 schmidt Exp $ */
     2/* $Id: ftest_io.h,v 1.7 1998-04-06 11:08:44 schmidt Exp $ */
    33
    44#ifndef INCL_FTEST_IO_H
     
    1313#include <factory.h>
    1414
    15 CanonicalForm ftestGetCanonicalForm ( const char * canFormSpec );
    16 Variable ftestGetVariable ( const char * stringVariable );
    17 int ftestGetint ( const char * stringInt );
    18 bool ftestGetbool ( const char * stringBool );
     15// functions to read objects from strings
     16void ftestRead ( const char *, CanonicalForm & );
     17void ftestRead ( const char *, Variable & );
     18void ftestRead ( const char *, int & );
     19void ftestRead ( const char *, bool & );
    1920
    2021void ftestPrintResult ( const char * resultName, const CanonicalForm & result );
    2122void ftestPrintResult ( const char * resultName, const CFFList & result );
    2223void ftestPrintResult ( const char * resultName, const int result );
     24void ftestPrintResult ( const char * resultName, const bool result );
    2325
    2426#endif /* ! INCL_FTEST_IO_H */
  • factory/ftest/ftest_util.cc

    rfa8420 r3ba84c  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: ftest_util.cc,v 1.15 1998-03-11 16:11:06 schmidt Exp $ */
     2/* $Id: ftest_util.cc,v 1.16 1998-04-06 11:08:59 schmidt Exp $ */
    33
    44//{{{ docu
     
    410410            strncpy( mipoString, tokenString, mipoLen );
    411411            mipoString[mipoLen] = '\0';
    412             mipo = ftestGetCanonicalForm( mipoString );
     412            ftestRead( mipoString, mipo );
    413413            delete [] mipoString;
    414414
  • factory/ftest/ftest_util.m4

    rfa8420 r3ba84c  
    1 dnl $Id: ftest_util.m4,v 1.16 1998-03-11 16:11:17 schmidt Exp $
     1dnl $Id: ftest_util.m4,v 1.17 1998-04-06 11:09:14 schmidt Exp $
    22dnl
    33dnl ftest_util.m4 - m4 macros used by the factory test environment.
     
    200200  ``if ( argv[ optind ] ) {
    201201        ftestArgGiven$1= true;
    202         $1= ftestGet'_stripTWS(`_ftestInType_$1')`( argv[ optind++ ] );
     202        ftestRead( argv[ optind++ ], $1);
    203203    } else
    204204        ftestError( CommandlineError,
     
    207207  `$#', `2',
    208208  ``if ( argv[ optind ] ) {
    209         ftestArgGiven$1 = true;
    210         $1 = ftestGet'_stripTWS(`_ftestInType_$1')`( argv[ optind++ ] );
     209        ftestArgGiven$1= true;
     210        ftestRead( argv[ optind++ ], $1 );
    211211    } else
    212212        $1 = '_qstripTWS(`$2')`;'',
    213213  ``if ( ftestSearchTaggedArg( argc, argv, optind, $3) ) {
    214         ftestArgGiven$1 = true;
    215         $1 = ftestGet'_stripTWS(`_ftestInType_$1')`( argv[ optind++ ] );
     214        ftestArgGiven$1 = true;
     215        ftestRead( argv[ optind++ ], $1 );
    216216    } else
    217217        $1 = '_qstripTWS(`$2')`;'')
  • factory/ftest/norm.m4

    rfa8420 r3ba84c  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: norm.m4,v 1.1 1998-03-11 17:56:11 schmidt Exp $ */
     2/* $Id: norm.m4,v 1.2 1998-04-06 11:05:03 schmidt Exp $ */
    33
    44ftestSetNameOfGame( norm, `"
     
    4545
    4646    // do the test!
    47     ftestRun(
    48         if ( euclideanFlag )
    49             result = euclideanNorm( f );
    50         else
    51             result = maxNorm( f ); );
     47    if ( euclideanFlag ) {
     48        ftestRun( result = euclideanNorm( f ); );
     49    } else {
     50        ftestRun( result = maxNorm( f ); );
     51    }
    5252
    5353    // print results
Note: See TracChangeset for help on using the changeset viewer.