Changeset 142b7b in git for Singular


Ignore:
Timestamp:
Apr 21, 1998, 12:42:57 PM (26 years ago)
Author:
Jens Schmidt <schmidt@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
54c713f739f37f3004843d2f9162eed12ffe61a3
Parents:
2e92629c5af08f58ee4c2f8cf151daf6dd2edbd1
Message:
	* clapsing.cc  (singclap_gcd): checks for `NULL' removed

	* clapsing.cc (singclap_divide_content, singclap_alglcm,
	  singclap_algdividecontent): code added for factory testing.
  	  Wrapped by #defines `FACTORY_GCD_TEST', `FACTORY_GCD_STAT',
 	  `FACTORY_GCD_DEBOUT', and `FACTORY_GCD_TIMING'.


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

Legend:

Unmodified
Added
Removed
  • Singular/clapsing.cc

    r2e9262 r142b7b  
    33*  Computer Algebra System SINGULAR     *
    44****************************************/
    5 // $Id: clapsing.cc,v 1.28 1998-04-16 09:40:39 Singular Exp $
     5// $Id: clapsing.cc,v 1.29 1998-04-21 10:42:57 schmidt Exp $
    66/*
    77* ABSTRACT: interface between Singular and factory
    88*/
    9 
    109
    1110#include "mod2.h"
     
    2423#include <factor.h>
    2524#endif
     25#include "ring.h"
     26
     27// FACTORY_GCD_TEST: use new gcd instead of old one.
     28// FACTORY_GCD_STAT: print statistics on polynomials.  Works only
     29//   with appropriately translated new gcd.
     30// FACTORY_GCD_TIMING: accumulate time used for gcd calculations.
     31//   For this option, the file `timing.h' from the Factory
     32//   distribution has to be copied to the Singular source directory.
     33//   Works only with new gcd.
     34// FACTORY_GCD_DEBOUT: print polynomials involved in gcd calculations
     35
     36#ifdef FACTORY_GCD_STAT
     37#define FACTORY_GCD_TEST
     38#endif
     39
     40#ifdef FACTORY_GCD_TIMING
     41#define FACTORY_GCD_TEST
     42#define TIMING
     43#include "timing.h"
     44TIMING_DEFINE_PRINT( contentTimer );
     45TIMING_DEFINE_PRINT( algContentTimer );
     46TIMING_DEFINE_PRINT( algLcmTimer );
     47#endif
     48
     49#ifdef FACTORY_GCD_DEBOUT
     50#include "longalg.h"
     51#include "febase.h"
     52#endif
    2653
    2754poly singclap_gcd ( poly f, poly g )
    2855{
    29   if (f==NULL)
    30   {
    31     if(g==NULL)
    32       return NULL;
    33     else
    34       return pCopy(g);
    35   }
    36   else if (g==NULL)
    37     return pCopy(f);
    38 
    3956  poly res=NULL;
    4057 
    41   pCleardenom(f);
    42   pCleardenom(g);
     58  if (f) pCleardenom(f);
     59  if (g) pCleardenom(g);
    4360 
    4461  // for now there is only the possibility to handle polynomials over
     
    341358    poly p = pNext(f);
    342359    nTest(pGetCoeff(f));
     360#ifdef FACTORY_GCD_DEBOUT
     361    StringSetS("g0 = ");
     362    if (f) napWrite(((lnumber)pGetCoeff(f))->z);
     363    PrintS(StringAppend("\n"));
     364#endif
    343365    g = convSingTrClapP( ((lnumber)pGetCoeff(f))->z );
    344366    L.append( g );
     367#ifdef FACTORY_GCD_TIMING
     368    TIMING_START( contentTimer );
     369#endif
    345370    while ( p && (g != 1) )
    346371    {
    347372      nTest(pGetCoeff(p));
     373#ifdef FACTORY_GCD_DEBOUT
     374      StringSetS("h = ");
     375      if (p) napWrite(((lnumber)pGetCoeff(p))->z);
     376      PrintS(StringAppend("\n"));
     377#endif
    348378      h = convSingTrClapP( ((lnumber)pGetCoeff(p))->z );
    349379      p = pNext( p );
     380#ifdef FACTORY_GCD_STAT
     381      fprintf( stderr, "cont:\t" );
     382#endif
     383#ifdef FACTORY_GCD_TEST
     384      g = CFPrimitiveGcdUtil::gcd( g, h );
     385#else
     386
     387      // this part is translated if there are not any options at all
    350388      g = gcd( g, h );
     389
     390#endif
     391#ifdef FACTORY_GCD_DEBOUT
     392      StringSetS("g = ");
     393      napWrite(convClapPSingTr(g));
     394      PrintS(StringAppend("\n"));
     395#endif
    351396      L.append( h );
    352397    }
     398#ifdef FACTORY_GCD_TIMING
     399    TIMING_END( contentTimer );
     400#endif
    353401    if ( g == 1 )
    354402    {
     
    900948alg singclap_alglcm ( alg f, alg g )
    901949{
    902   // over Q(a) / Fp(a)
    903  if (nGetChar()==1) setCharacteristic( 0 );
    904  else               setCharacteristic( -nGetChar() );
    905  alg res;
    906  if (currRing->minpoly!=NULL)
    907  {
    908    CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
    909    Variable a=rootOf(mipo);
    910    CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) );
    911    res= convClapASingA( (F/ gcd( F, G ))*G );
    912  }
    913  else
    914  {
    915    CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) );
    916    res= convClapPSingTr( (F/gcd( F, G ))*G );
    917  }
    918  Off(SW_RATIONAL);
    919  return res;
    920 }
    921 
    922 #ifdef FACTORY_DEBUG_OUT
    923 #include "longalg.h"
    924 #include "febase.h"
    925 #endif
    926 
    927 void singclap_algdividecontent ( alg f, alg g, alg &ff, alg &gg )
    928 {
    929 #ifdef FACTORY_DEBUG_OUT
     950#ifdef FACTORY_GCD_DEBOUT
    930951    StringSetS("f = ");
    931952    napWrite(f);
     
    938959 if (nGetChar()==1) setCharacteristic( 0 );
    939960 else               setCharacteristic( -nGetChar() );
    940  ff=gg=NULL;
     961 alg res;
     962#ifdef FACTORY_GCD_STAT
     963 fprintf( stderr, "algLcm:\t" );
     964#endif
    941965 if (currRing->minpoly!=NULL)
    942966 {
     
    944968   Variable a=rootOf(mipo);
    945969   CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) );
     970#ifdef FACTORY_GCD_TIMING
     971   CanonicalForm GCD;
     972   TIMING_START( algLcmTimer );
     973   GCD = CFPrimitiveGcdUtil::gcd( F, G );
     974   TIMING_END( algLcmTimer );
     975   res= convClapASingA( (F/ GCD)*G );
     976#elif defined( FACTORY_GCD_TEST )
     977   res= convClapASingA( (F/ CFPrimitiveGcdUtil::gcd( F, G ))*G );
     978#else
     979
     980   // this part is translated if there are not any options at all
     981   res= convClapASingA( (F/ gcd( F, G ))*G );
     982
     983#endif
     984 }
     985 else
     986 {
     987   CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) );
     988#ifdef FACTORY_GCD_TIMING
     989   CanonicalForm GCD;
     990   TIMING_START( algLcmTimer );
     991   GCD = CFPrimitiveGcdUtil::gcd( F, G );
     992   TIMING_END( algLcmTimer );
     993   res= convClapPSingTr( (F/GCD)*G );
     994#elif defined( FACTORY_GCD_TEST )
     995   res= convClapPSingTr( (F/CFPrimitiveGcdUtil::gcd( F, G ))*G );
     996#else
     997
     998   // this part is translated if there are not any options at all
     999   res= convClapPSingTr( (F/gcd( F, G ))*G );
     1000
     1001#endif
     1002 }
     1003 Off(SW_RATIONAL);
     1004#ifdef FACTORY_GCD_DEBOUT
     1005    StringSetS("res = ");
     1006    napWrite(res);
     1007    PrintS(StringAppend("\n"));
     1008#endif
     1009 return res;
     1010}
     1011
     1012void singclap_algdividecontent ( alg f, alg g, alg &ff, alg &gg )
     1013{
     1014#ifdef FACTORY_GCD_DEBOUT
     1015  alg algGcd;
     1016  StringSetS("f = ");
     1017  napWrite(f);
     1018  PrintS(StringAppend("\n"));
     1019  StringSetS("g = ");
     1020  napWrite(g);
     1021  PrintS(StringAppend("\n"));
     1022#endif
     1023  // over Q(a) / Fp(a)
     1024 if (nGetChar()==1) setCharacteristic( 0 );
     1025 else               setCharacteristic( -nGetChar() );
     1026 ff=gg=NULL;
     1027#ifdef FACTORY_GCD_STAT
     1028 fprintf( stderr, "alCont:\t" );
     1029#endif
     1030 if (currRing->minpoly!=NULL)
     1031 {
     1032   CanonicalForm mipo=convSingTrClapP(((lnumber)currRing->minpoly)->z);
     1033   Variable a=rootOf(mipo);
     1034   CanonicalForm F( convSingAClapA( f,a ) ), G( convSingAClapA( g,a ) );
     1035#ifdef FACTORY_GCD_TIMING
     1036   CanonicalForm GCD;
     1037   TIMING_START( algContentTimer );
     1038   GCD=CFPrimitiveGcdUtil::gcd( F, G );
     1039   TIMING_END( algContentTimer );
     1040#elif defined( FACTORY_GCD_TEST )
     1041   CanonicalForm GCD=CFPrimitiveGcdUtil::gcd( F, G );
     1042#else
     1043
     1044   // this part is translated if there are not any options at all
    9461045   CanonicalForm GCD=gcd( F, G );
     1046
     1047#endif
    9471048   if (GCD!=1)
    9481049   {
     
    9501051     gg= convClapASingA( G/ GCD );
    9511052   }
     1053#ifdef FACTORY_GCD_DEBOUT
     1054   algGcd=convClapASingA( GCD );
     1055#endif
    9521056 }
    9531057 else
    9541058 {
    9551059   CanonicalForm F( convSingTrClapP( f ) ), G( convSingTrClapP( g ) );
     1060#ifdef FACTORY_GCD_TIMING
     1061   CanonicalForm GCD;
     1062   TIMING_START( algContentTimer );
     1063   GCD=CFPrimitiveGcdUtil::gcd( F, G );
     1064   TIMING_END( algContentTimer );
     1065#elif defined( FACTORY_GCD_TEST )
     1066   CanonicalForm GCD=CFPrimitiveGcdUtil::gcd( F, G );
     1067#else
     1068
     1069   // this part is translated if there are not any options at all
    9561070   CanonicalForm GCD=gcd( F, G );
     1071
     1072#endif
    9571073   if (GCD!=1)
    9581074   {
     
    9601076     gg= convClapPSingTr( G/ GCD );
    9611077   }
     1078#ifdef FACTORY_GCD_DEBOUT
     1079   algGcd=convClapPSingTr( GCD );
     1080#endif
    9621081 }
    9631082 Off(SW_RATIONAL);
    964 #ifdef FACTORY_DEBUG_OUT
    965     StringSetS("ff = ");
    966     napWrite(ff);
    967     PrintS(StringAppend("\n"));
    968     StringSetS("gg = ");
    969     napWrite(gg);
    970     PrintS(StringAppend("\n"));
     1083#ifdef FACTORY_GCD_DEBOUT
     1084  StringSetS("gcd = ");
     1085  napWrite(algGcd);
     1086  PrintS(StringAppend("\n"));
     1087  napDelete(&algGcd);
    9711088#endif
    9721089}
Note: See TracChangeset for help on using the changeset viewer.