Changeset 02a069e in git


Ignore:
Timestamp:
Aug 6, 2009, 12:18:33 PM (14 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
424cd646332e11e54c822873f6276ff3ddcb8751
Parents:
f60485dae160ea69a455571578bb2877fbc73226
Message:
*hannes: code cleanup


git-svn-id: file:///usr/local/Singular/svn/trunk@12047 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    rf60485d r02a069e  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.311 2009-07-28 15:16:04 Singular Exp $ */
     4/* $Id: extra.cc,v 1.312 2009-08-06 10:18:00 Singular Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    160160#endif
    161161
    162 
    163 // see clapsing.cc for a description of the `FACTORY_*' options
    164 
    165 #ifdef FACTORY_GCD_STAT
    166 #include "gcd_stat.h"
    167 #endif
    168 
    169 #ifdef FACTORY_GCD_TIMING
    170 #define TIMING
    171 #include "timing.h"
    172 TIMING_DEFINE_PRINTPROTO( contentTimer );
    173 TIMING_DEFINE_PRINTPROTO( algContentTimer );
    174 TIMING_DEFINE_PRINTPROTO( algLcmTimer );
    175 #endif
    176162
    177163void piShowProcList();
     
    22872273    else
    22882274#endif
    2289 /*=======================gcd Testerei ================================*/
    2290 #ifdef FACTORY_GCD_TEST
    2291     if ( ! strcmp( sys_cmd, "setgcd" ) )
    2292     {
    2293         if ( (h != NULL) && (h->Typ() == INT_CMD) )
    2294         {
    2295             CFPrimitiveGcdUtil::setAlgorithm( (int)h->Data() );
    2296             return FALSE;
    2297         } else
    2298             WerrorS("int expected");
    2299     }
    2300     else
    2301 #endif
    2302 
    2303 #ifdef FACTORY_GCD_TIMING
    2304     if ( ! strcmp( sys_cmd, "gcdtime" ) )
    2305     {
    2306         TIMING_PRINT( contentTimer, "time used for content: " );
    2307         TIMING_PRINT( algContentTimer, "time used for algContent: " );
    2308         TIMING_PRINT( algLcmTimer, "time used for algLcm: " );
    2309         TIMING_RESET( contentTimer );
    2310         TIMING_RESET( algContentTimer );
    2311         TIMING_RESET( algLcmTimer );
    2312         return FALSE;
    2313     }
    2314     else
    2315 #endif
    2316 
    2317 #ifdef FACTORY_GCD_STAT
    2318     if ( ! strcmp( sys_cmd, "gcdstat" ) )
    2319     {
    2320         printGcdTotal();
    2321         printContTotal();
    2322         resetGcdTotal();
    2323         resetContTotal();
    2324         return FALSE;
    2325     }
    2326     else
    2327 #endif
    23282275/*==================== listall ===================================*/
    23292276    if(strcmp(sys_cmd,"listall")==0)
  • kernel/clapsing.cc

    rf60485d r02a069e  
    33*  Computer Algebra System SINGULAR     *
    44****************************************/
    5 // $Id: clapsing.cc,v 1.39 2009-08-06 07:21:58 Singular Exp $
     5// $Id: clapsing.cc,v 1.40 2009-08-06 10:18:24 Singular Exp $
    66/*
    77* ABSTRACT: interface between Singular and factory
     
    2525#include "ring.h"
    2626
    27 //
    28 // FACTORY_GCD_TEST: use new gcd instead of old one.  Does not work
    29 //   without new gcd-implementation which is not publicly available.
    30 //
    31 // FACTORY_GCD_STAT: print statistics on polynomials.  Works only
    32 //   with the file `gcd_stat.cc' and `gcd_stat.h which may be found
    33 //   in the repository, module `factory-devel'.
    34 //   Overall statistics may printed using `system("gcdstat");'.
    35 //
    36 // FACTORY_GCD_TIMING: accumulate time used for gcd calculations.
    37 //   Time may be printed (and reset) with `system("gcdtime");'.
    38 //   For this define, `timing.h' from the factory source directory
    39 //   has to be copied to the Singular source directory.
    40 //   Note: for better readability, the macros `TIMING_START()' and
    41 //   `TIMING_END()' are used in any case.  However, they expand to
    42 //   nothing if `FACTORY_GCD_TIMING' is off.
    43 //
    44 // FACTORY_GCD_DEBOUT: print polynomials involved in gcd calculations.
    45 //   The polynomials are printed by means of the macros
    46 //   `FACTORY_*OUT_POLY' which are defined to be empty if
    47 //   `FACTORY_GCD_DEBOUT' is off.
    48 //
    49 // FACTORY_GCD_DEBOUT_PATTERN: print degree patterns of polynomials
    50 //   involved in gcd calculations.
    51 //   The patterns are printed by means of the macros
    52 //   `FACTORY_*OUT_PAT' which are defined to be empty if
    53 //   `FACTORY_GCD_DEBOUT_PATTERN' is off.
    54 //
    55 //   A degree pattern looks like this:
    56 //
    57 //   totDeg  size    deg(v1) deg(v2) ...
    58 //
    59 //   where "totDeg" means total degree, "size" the number of terms,
    60 //   and "deg(vi)" is the degree with respect to variable i.
    61 //   In univariate case, the "deg(vi)" are missing.  For this feature
    62 //   you need the files `gcd_stat.cc' and `gcd_stat.h'.
    63 //
    64 //
    65 // And here is what the functions print if `FACTORY_GCD_DEBOUT' (1),
    66 // `FACTORY_GCD_STAT' (2), or `FACTORY_GCD_DEBOUT_PATTERN' (3) is on:
    67 //
    68 // sinclap_divide_content:
    69 // (1) G = <firstCoeff>
    70 // (3) G#= <firstCoeff, pattern>
    71 // (1) h = <nextCoeff>
    72 // (3) h#= <nextCoeff, pattern>
    73 // (2) gcnt: <statistics on gcd as explained above>
    74 // (1) g = <intermediateResult>
    75 // (3) g#= <intermediateResult, pattern>
    76 // (1) h = <nextCoeff>
    77 // (3) h#= <nextCoeff, pattern>
    78 // (2) gcnt: <statistics on gcd as explained above>
    79 //  ...
    80 // (1) h = <lastCoeff>
    81 // (3) h#= <lastCoeff, pattern>
    82 // (1) g = <finalResult>
    83 // (3) g#= <finalResult, pattern>
    84 // (2) gcnt: <statistics on gcd as explained above>
    85 // (2) cont: <statistics on content as explained above>
    86 //
    87 // singclap_alglcm:
    88 // (1) f = <inputPolyF>
    89 // (3) f#= <inputPolyF, pattern>
    90 // (1) g = <inputPolyG>
    91 // (3) g#= <inputPolyG, pattern>
    92 // (1) d = <its gcd>
    93 // (3) d#= <its gcd, pattern>
    94 // (2) alcm: <statistics as explained above>
    95 //
    96 // singclap_algdividecontent:
    97 // (1) f = <inputPolyF>
    98 // (3) f#= <inputPolyF, pattern>
    99 // (1) g = <inputPolyG>
    100 // (3) g#= <inputPolyG, pattern>
    101 // (1) d = <its gcd>
    102 // (3) d#= <its gcd, pattern>
    103 // (2) acnt: <statistics as explained above>
    104 //
    105 
    106 #ifdef FACTORY_GCD_STAT
    107 #include "gcd_stat.h"
    108 #define FACTORY_GCDSTAT( tag, f, g, d ) \
    109   printGcdStat( tag, f, g, d )
    110 #define FACTORY_CONTSTAT( tag, f ) \
    111   printContStat( tag, f )
    112 #else
    113 #define FACTORY_GCDSTAT( tag, f, g, d )
    114 #define FACTORY_CONTSTAT( tag, f )
    115 #endif
    116 
    117 #ifdef FACTORY_GCD_TIMING
    118 #define TIMING
    119 #include "timing.h"
    120 TIMING_DEFINE_PRINT( contentTimer );
    121 TIMING_DEFINE_PRINT( algContentTimer );
    122 TIMING_DEFINE_PRINT( algLcmTimer );
    123 #else
    124 #define TIMING_START( timer )
    125 #define TIMING_END( timer )
    126 #endif
    127 
    128 #ifdef FACTORY_GCD_DEBOUT
    129 #include "longalg.h"
    130 #include "febase.h"
    131 // napoly f
    132 #define FACTORY_ALGOUT_POLY( tag, f ) \
    133   StringSetS( tag ); \
    134   napWrite( f ); \
    135   pRINtS(StringAppendS("\n"));
    136 // CanonicalForm f, represents transcendent extension
    137 #define FACTORY_CFTROUT_POLY( tag, f ) \
    138   { \
    139     napoly F=convFactoryPSingTr( f ); \
    140     StringSetS( tag ); \
    141     napWrite( F ); \
    142     PrintS(StringAppendS("\n")); \
    143     napDelete(&F); \
    144   }
    145 // CanonicalForm f, represents algebraic extension
    146 #define FACTORY_CFAOUT_POLY( tag, f ) \
    147   { \
    148     napoly F=convFactoryASingA( f ); \
    149     StringSetS( tag ); \
    150     napWrite( F ); \
    151     PrintS(StringAppendS("\n")); \
    152     napDelete(&F); \
    153   }
    154 #else /* ! FACTORY_GCD_DEBOUT */
    155 #define FACTORY_ALGOUT_POLY( tag, f )
    156 #define FACTORY_CFTROUT_POLY( tag, f )
    157 #define FACTORY_CFAOUT_POLY( tag, f )
    158 #endif /* ! FACTORY_GCD_DEBOUT */
    159 
    160 #ifdef FACTORY_GCD_DEBOUT_PATTERN
    161 // napoly f
    162 #define FACTORY_ALGOUT_PAT( tag, f ) \
    163   if (currRing->minpoly!=NULL) \
    164   { \
    165     CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); \
    166     Variable a=rootOf(mipo); \
    167     printPolyPattern( tag, convSingAFactoryA( f,a ), rPar( currRing ) ); \
    168   } \
    169   else \
    170   { \
    171     printPolyPattern( tag, convSingTrFactoryP( f ), rPar( currRing ) ); \
    172   }
    173 // CanonicalForm f, represents transcendent extension
    174 #define FACTORY_CFTROUT_PAT( tag, f ) printPolyPattern( tag, f, rPar( currRing ) )
    175 // CanonicalForm f, represents algebraic extension
    176 #define FACTORY_CFAOUT_PAT( tag, f ) printPolyPattern( tag, f, rPar( currRing ) )
    177 #else /* ! FACTORY_GCD_DEBOUT_PATTERN */
    178 #define FACTORY_ALGOUT_PAT( tag, f )
    179 #define FACTORY_CFTROUT_PAT( tag, f )
    180 #define FACTORY_CFAOUT_PAT( tag, f )
    181 #endif /* ! FACTORY_GCD_DEBOUT_PATTERN */
    182 
    183 // these macors combine both print macros
    184 #define FACTORY_ALGOUT( tag, f ) \
    185   FACTORY_ALGOUT_POLY( tag " = ", f ); \
    186   FACTORY_ALGOUT_PAT( tag "#= ", f )
    187 #define FACTORY_CFTROUT( tag, f ) \
    188   FACTORY_CFTROUT_POLY( tag " = ", f ); \
    189   FACTORY_CFTROUT_PAT( tag "#= ", f )
    190 #define FACTORY_CFAOUT( tag, f ) \
    191   FACTORY_CFAOUT_POLY( tag " = ", f ); \
    192   FACTORY_CFAOUT_PAT( tag "#= ", f )
    193 
    194 
    19527void out_cf(char *s1,const CanonicalForm &f,char *s2);
    196 
    19728
    19829poly singclap_gcd ( poly f, poly g )
     
    662493      pIter(p);
    663494    }
    664     FACTORY_ALGOUT( "G", ((lnumber)g1)->z );
    665495    g = convSingTrFactoryP( ((lnumber)g1)->z );
    666496    g = gcd( g, convSingTrFactoryP( ((lnumber)g2)->z ));
     
    669499
    670500    p = f;
    671     TIMING_START( contentTimer );
    672501    while ( (p != NULL) && (g != 1)  && ( g != 0))
    673502    {
    674       FACTORY_ALGOUT( "h", (((lnumber)pGetCoeff(p))->z) );
    675503      h = convSingTrFactoryP( ((lnumber)pGetCoeff(p))->z );
    676504      pIter( p );
    677 #ifdef FACTORY_GCD_STAT
    678       // save g
    679       CanonicalForm gOld = g;
    680 #endif
    681 
    682 #ifdef FACTORY_GCD_TEST
    683       g = CFPrimitiveGcdUtil::gcd( g, h );
    684 #else
     505
    685506      g = gcd( g, h );
    686 #endif
    687 
    688       FACTORY_GCDSTAT( "gcnt:", gOld, h, g );
    689       FACTORY_CFTROUT( "g", g );
     507
    690508      L.append( h );
    691509    }
    692     TIMING_END( contentTimer );
    693     FACTORY_CONTSTAT( "cont:", g );
    694510    if (( g == 1 ) || (g == 0))
    695511    {
     
    16741490napoly singclap_alglcm ( napoly f, napoly g )
    16751491{
    1676  FACTORY_ALGOUT( "f", f );
    1677  FACTORY_ALGOUT( "g", g );
    16781492
    16791493 // over Q(a) / Fp(a)
     
    16891503   CanonicalForm GCD;
    16901504
    1691    TIMING_START( algLcmTimer );
    16921505   // calculate gcd
    1693 #ifdef FACTORY_GCD_TEST
    1694    GCD = CFPrimitiveGcdUtil::gcd( F, G );
    1695 #else
    16961506   GCD = gcd( F, G );
    1697 #endif
    1698    TIMING_END( algLcmTimer );
    1699 
    1700    FACTORY_CFAOUT( "d", GCD );
    1701    FACTORY_GCDSTAT( "alcm:", F, G, GCD );
    17021507
    17031508   // calculate lcm
     
    17081513   CanonicalForm F( convSingTrFactoryP( f ) ), G( convSingTrFactoryP( g ) );
    17091514   CanonicalForm GCD;
    1710    TIMING_START( algLcmTimer );
    17111515   // calculate gcd
    1712 #ifdef FACTORY_GCD_TEST
    1713    GCD = CFPrimitiveGcdUtil::gcd( F, G );
    1714 #else
    17151516   GCD = gcd( F, G );
    1716 #endif
    1717    TIMING_END( algLcmTimer );
    1718 
    1719    FACTORY_CFTROUT( "d", GCD );
    1720    FACTORY_GCDSTAT( "alcm:", F, G, GCD );
    17211517
    17221518   // calculate lcm
     
    17301526void singclap_algdividecontent ( napoly f, napoly g, napoly &ff, napoly &gg )
    17311527{
    1732  FACTORY_ALGOUT( "f", f );
    1733  FACTORY_ALGOUT( "g", g );
    1734 
    17351528 // over Q(a) / Fp(a)
    17361529 if (nGetChar()==1) setCharacteristic( 0 );
     
    17461539   CanonicalForm GCD;
    17471540
    1748    TIMING_START( algContentTimer );
    1749 #ifdef FACTORY_GCD_TEST
    1750    GCD=CFPrimitiveGcdUtil::gcd( F, G );
    1751 #else
    17521541   GCD=gcd( F, G );
    1753 #endif
    1754    TIMING_END( algContentTimer );
    1755 
    1756    FACTORY_CFAOUT( "d", GCD );
    1757    FACTORY_GCDSTAT( "acnt:", F, G, GCD );
    17581542
    17591543   if ((GCD!=1) && (GCD!=0))
     
    17681552   CanonicalForm GCD;
    17691553
    1770    TIMING_START( algContentTimer );
    1771 #ifdef FACTORY_GCD_TEST
    1772    GCD=CFPrimitiveGcdUtil::gcd( F, G );
    1773 #else
    17741554   GCD=gcd( F, G );
    1775 #endif
    1776    TIMING_END( algContentTimer );
    1777 
    1778    FACTORY_CFTROUT( "d", GCD );
    1779    FACTORY_GCDSTAT( "acnt:", F, G, GCD );
    17801555
    17811556   if ((GCD!=1) && (GCD!=0))
  • kernel/longalg.cc

    rf60485d r02a069e  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: longalg.cc,v 1.39 2009-07-30 11:49:09 Singular Exp $ */
     4/* $Id: longalg.cc,v 1.40 2009-08-06 10:18:33 Singular Exp $ */
    55/*
    66* ABSTRACT:   algebraic numbers
     
    17291729* and enumerator  ?          naNumbOfPar != 1;
    17301730*
    1731 * #defines for Factory:
    1732 * FACTORY_GCD_TEST: do not apply built in gcd for
    1733 *   univariate polynomials, always use Factory
    1734 */
    1735 //#define FACTORY_GCD_TEST
     1731*/
    17361732void naNormalize(number &pp)
    17371733{
     
    18411837    return;
    18421838  }
    1843 #ifndef FACTORY_GCD_TEST
    18441839  if (naNumbOfPar == 1) /* apply built-in gcd */
    18451840  {
     
    19101905    }
    19111906  }
    1912 #endif /* FACTORY_GCD_TEST */
    19131907#ifdef HAVE_FACTORY
    1914 #ifndef FACTORY_GCD_TEST
    19151908  else
    1916 #endif
    19171909  {
    19181910    napoly xx,yy;
Note: See TracChangeset for help on using the changeset viewer.