Changeset 3835a88 in git


Ignore:
Timestamp:
Jul 19, 2011, 2:21:54 PM (12 years ago)
Author:
mlee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
7021758acc8d05ef28d445be496dbd3cca92007f
Parents:
31f1262751310d366c99e1a3d2914e859f8ea5c0
git-author:
mlee <martinlee84@web.de>2011-07-19 14:21:54+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:40:00+01:00
Message:
added const ring r to ring dependend functions
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/spectrum.cc

    r31f1262 r3835a88  
    2222
    2323#include <coeffs/numbers.h>
    24 #include <polys/polys.h>
    25 #include <kernel/ideals.h>
     24#include <polys/monomials/p_polys.h>
     25#include <polys/simpleideals.h>
     26#include <misc/intvec.h>
     27#include <polys/monomials/ring.h>
     28//extern ring currRing;
     29
    2630#include <kernel/kstd1.h>
    2731#include <kernel/stairc.h>
    28 #include <misc/intvec.h>
    29 #include <polys/monomials/ring.h>
    30 
    3132#include <kernel/multicnt.h>
    3233#include <kernel/GMPrat.h>
     
    4041// ----------------------------------------------------------------------------
    4142
    42 BOOLEAN hasTermOfDegree( poly h, int d )
     43BOOLEAN hasTermOfDegree( poly h, int d, const ring r )
    4344{
    4445  do
    4546  {
    46     if( pTotaldegree( h )== d )
     47    if( p_Totaldegree( h,r )== d )
    4748      return  TRUE;
    4849    pIter(h);
     
    5758// ----------------------------------------------------------------------------
    5859
    59 static BOOLEAN inline hasConstTerm( poly h )
    60 {
    61   return  hasTermOfDegree(h,0);
     60static BOOLEAN inline hasConstTerm( poly h, const ring r )
     61{
     62  return  hasTermOfDegree(h,0,r);
    6263}
    6364
     
    6667// ----------------------------------------------------------------------------
    6768
    68 static BOOLEAN inline hasLinearTerm( poly h )
    69 {
    70   return  hasTermOfDegree(h,1);
     69static BOOLEAN inline hasLinearTerm( poly h, const ring r )
     70{
     71  return  hasTermOfDegree(h,1,r);
    7172}
    7273
     
    7576// ----------------------------------------------------------------------------
    7677
    77 BOOLEAN hasAxis( ideal J,int k )
     78BOOLEAN hasAxis( ideal J,int k, const ring r )
    7879{
    7980  int i;
     
    8182  for( i=0; i<IDELEMS(J); i++ )
    8283  {
    83     if (pIsPurePower( J->m[i] ) == k) return TRUE;
     84    if (p_IsPurePower( J->m[i],r ) == k) return TRUE;
    8485  }
    8586  return  FALSE;
     
    9091// ----------------------------------------------------------------------------
    9192
    92 int     hasOne( ideal J )
     93int     hasOne( ideal J, const ring r )
    9394{
    9495  int i;
     
    9697  for( i=0; i<IDELEMS(J); i++ )
    9798  {
    98     if (pIsConstant(J->m[i])) return TRUE;
     99    if (p_IsConstant(J->m[i],r)) return TRUE;
    99100  }
    100101  return  FALSE;
     
    104105// ----------------------------------------------------------------------------
    105106
    106 int     isMultiple( poly f,poly m )
     107int     isMultiple( poly f,poly m, const ring r )
    107108{
    108109  while( f!=NULL )
     
    112113    // ---------------------------------------------------
    113114
    114     if( pLmCmp( f,m )>=0 )
    115     {
    116       if( pLmDivisibleByNoComp( f,m ) )
     115    if( p_LmCmp( f,m,r )>=0 )
     116    {
     117      if( p_LmDivisibleByNoComp( f,m,r ) )
    117118      {
    118119        return  TRUE;
     
    136137// ----------------------------------------------------------------------------
    137138
    138 poly    computeWC( const newtonPolygon &np,Rational max_weight )
    139 {
    140   poly m  = pOne();
     139poly    computeWC( const newtonPolygon &np,Rational max_weight, const ring r )
     140{
     141  poly m  = p_One(r);
    141142  poly wc = NULL;
    142143  int  mdegree;
    143144
    144   for( int i=1; i<=pVariables; i++ )
     145  for( int i=1; i<=r->N; i++ )
    145146  {
    146147    mdegree = 1;
    147     pSetExp( m,i,mdegree );
     148    p_SetExp( m,i,mdegree,r );
    148149    // pSetm( m );
    149150    // np.weight_shift does not need pSetm( m ), postpone it
    150151
    151     while(  np.weight_shift( m )<max_weight )
     152    while(  np.weight_shift( m,r )<max_weight )
    152153    {
    153154      mdegree++;
    154       pSetExp( m,i,mdegree );
     155      p_SetExp( m,i,mdegree,r );
    155156      // pSetm( m );
    156157      // np.weight_shift does not need pSetm( m ), postpone it
    157158    }
    158     pSetm( m );
    159 
    160     if( i==1 || pCmp( m,wc )<0 )
    161     {
    162       pDelete( &wc );
    163       wc = pHead( m );
    164     }
    165 
    166     pSetExp( m,i,0 );
    167   }
    168 
    169   pDelete( &m );
     159    p_Setm( m,r );
     160
     161    if( i==1 || p_Cmp( m,wc,r )<0 )
     162    {
     163      p_Delete( &wc,r );
     164      wc = p_Head( m,r );
     165    }
     166
     167    p_SetExp( m,i,0,r );
     168  }
     169
     170  p_Delete( &m,r );
    170171
    171172  return  wc;
     
    176177// ----------------------------------------------------------------------------
    177178
    178 static inline  poly    normalFormHC( poly f,poly hc )
     179static inline  poly    normalFormHC( poly f,poly hc, const ring r )
    179180{
    180181  poly    *ptr = &f;
     
    182183  while( (*ptr)!=NULL )
    183184  {
    184     if( pLmCmp( *ptr,hc )>=0 )
     185    if( p_LmCmp( *ptr,hc,r )>=0 )
    185186    {
    186187      ptr = &(pNext( *ptr ));
     
    188189    else
    189190    {
    190       pDelete( ptr );
     191      p_Delete( ptr,r );
    191192      return  f;
    192193    }
     
    200201// ----------------------------------------------------------------------------
    201202
    202 static inline  poly    normalFormZ( poly f,poly Z )
     203static inline  poly    normalFormZ( poly f,poly Z, const ring r )
    203204{
    204205  poly    *ptr = &f;
     
    206207  while( (*ptr)!=NULL )
    207208  {
    208     if( !isMultiple( Z,*ptr ) )
     209    if( !isMultiple( Z,*ptr,r ) )
    209210    {
    210211      ptr = &(pNext( *ptr ));
     
    212213    else
    213214    {
    214       pLmDelete(ptr);
     215      p_LmDelete(ptr,r);
    215216    }
    216217  }
     
    228229// ----------------------------------------------------------------------------
    229230
    230 static inline  int     isLeadMonomial( poly m,ideal stdJ )
     231static inline  int     isLeadMonomial( poly m,ideal stdJ, const ring r )
    231232{
    232233  int     length = INT_MAX;
     
    235236  for( int i=0; i<IDELEMS(stdJ); i++ )
    236237  {
    237     if( pCmp( stdJ->m[i],m )>=0 && pDivisibleBy( stdJ->m[i],m ) )
     238    if( p_Cmp( stdJ->m[i],m,r )>=0 && p_DivisibleBy( stdJ->m[i],m,r ) )
    238239    {
    239240      int     tmp = pLength( stdJ->m[i] );
     
    254255// ----------------------------------------------------------------------------
    255256
    256 static void    setExp( poly m,int *r )
    257 {
    258   for( int i=pVariables; i>0; i-- )
    259   {
    260     pSetExp( m,i,r[i-1] );
    261   }
    262   pSetm( m );
     257static void    setExp( poly m,int *r, const ring s )
     258{
     259  for( int i=s->N; i>0; i-- )
     260  {
     261    p_SetExp( m,i,r[i-1],s );
     262  }
     263  p_Setm( m,s );
    263264}
    264265
     
    268269// ----------------------------------------------------------------------------
    269270
    270 static BOOLEAN isWell( void )
    271 {
    272   int b = rBlocks( currRing );
     271static BOOLEAN isWell( const ring r )
     272{
     273  int b = rBlocks( r );
    273274
    274275  if( b==3 &&
    275       ( currRing->order[0] == ringorder_ds ||
    276         currRing->order[0] == ringorder_Ds ||
    277         currRing->order[0] == ringorder_ws ||
    278         currRing->order[0] == ringorder_Ws ) )
     276      ( r->order[0] == ringorder_ds ||
     277        r->order[0] == ringorder_Ds ||
     278        r->order[0] == ringorder_ws ||
     279        r->order[0] == ringorder_Ws ) )
    279280  {
    280281    return  TRUE;
    281282  }
    282283  else if( b>=3
    283   && (( currRing->order[0] ==ringorder_a
    284         && currRing->block1[0]==pVariables )
    285     || (currRing->order[0]==ringorder_M
    286         && currRing->block1[0]==pVariables*pVariables )))
    287   {
    288     for( int i=pVariables-1; i>=0; i-- )
    289     {
    290       if( currRing->wvhdl[0][i]>=0 )
     284  && (( r->order[0] ==ringorder_a
     285        && r->block1[0]==r->N )
     286    || (r->order[0]==ringorder_M
     287        && r->block1[0]==r->N*r->N )))
     288  {
     289    for( int i=r->N-1; i>=0; i-- )
     290    {
     291      if( r->wvhdl[0][i]>=0 )
    291292      {
    292293        return  FALSE;
     
    303304// ----------------------------------------------------------------------------
    304305
    305 void    computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF )
     306void    computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF, const ring r )
    306307{
    307308  int         carry,k;
    308   multiCnt    C( pVariables,0 );
     309  multiCnt    C( r->N,0 );
    309310  poly        Z = NULL;
    310311
    311   int         well = isWell( );
     312  int         well = isWell(r);
    312313
    313314  do
    314315  {
    315     poly    m = pOne();
    316     setExp( m,C.cnt );
     316    poly    m = p_One(r);
     317    setExp( m,C.cnt,r );
    317318
    318319    carry = FALSE;
    319320
    320     k = isLeadMonomial( m,stdJ );
     321    k = isLeadMonomial( m,stdJ,r );
    321322
    322323    if( k < 0 )
     
    328329      NF->insert_node( m,NULL );
    329330    }
    330     else if( isMultiple( Z,m ) )
     331    else if( isMultiple( Z,m,r ) )
    331332    {
    332333      // ------------------------------------
     
    334335      // ------------------------------------
    335336
    336       pDelete( &m );
     337      p_Delete( &m,r );
    337338      carry = TRUE;
    338339    }
    339     else if( pCmp( m,hc ) < 0 || pCmp( m,wc ) < 0 )
     340    else if( p_Cmp( m,hc,r ) < 0 || p_Cmp( m,wc,r ) < 0 )
    340341    {
    341342      // -------------------
     
    343344      // -------------------
    344345
    345       pDelete( &m );
     346      p_Delete( &m,r );
    346347      carry = TRUE;
    347348    }
     
    352353      // --------------------------
    353354
    354       poly    multiplicant = pDivide( m,stdJ->m[k] );
    355       pGetCoeff( multiplicant ) = nInit(1);
    356 
    357       poly    nf = pMult_mm( pCopy( stdJ->m[k] ), multiplicant );
    358 
    359       pDelete( &multiplicant );
    360 
    361       nf = normalFormHC( nf,hc );
     355      poly    multiplicant = p_Divide( m,stdJ->m[k],r );
     356      pGetCoeff( multiplicant ) = n_Init(1,r->cf);
     357
     358      poly    nf = p_Mult_mm( p_Copy( stdJ->m[k],r ), multiplicant,r );
     359
     360      p_Delete( &multiplicant,r );
     361
     362      nf = normalFormHC( nf,hc,r );
    362363
    363364      if( pNext( nf )==NULL )
     
    367368        // ----------------------------------
    368369
    369         pDelete( &nf );
     370        p_Delete( &nf,r );
    370371        NF->delete_monomial( m );
    371         Z = pAdd( Z,m );
     372        Z = p_Add_q( Z,m,r );
    372373        carry = TRUE;
    373374      }
    374375      else
    375376      {
    376         nf = normalFormZ( nf,Z );
     377        nf = normalFormZ( nf,Z,r );
    377378
    378379        if( pNext( nf )==NULL )
     
    382383          // ----------------------------------
    383384
    384           pDelete( &nf );
     385          p_Delete( &nf,r );
    385386          NF->delete_monomial( m );
    386           Z = pAdd( Z,m );
     387          Z = p_Add_q( Z,m,r );
    387388          carry = TRUE;
    388389        }
     
    393394          // ------------------------------------
    394395
    395           pNorm( nf );
     396          p_Norm( nf,r );
    396397          if( well==TRUE )
    397398          {
     
    401402          {
    402403            poly    nfhard = kNF( stdJ,(ideal)NULL,pNext( nf ),0,0 );
    403             nfhard = normalFormHC( nfhard,hc );
    404             nfhard = normalFormZ ( nfhard,Z );
     404            nfhard = normalFormHC( nfhard,hc,r );
     405            nfhard = normalFormZ ( nfhard,Z,r );
    405406
    406407            if( nfhard==NULL )
    407408            {
    408409              NF->delete_monomial( m );
    409               Z = pAdd( Z,m );
     410              Z = p_Add_q( Z,m,r );
    410411              carry = TRUE;
    411412            }
    412413            else
    413414            {
    414               pDelete( &pNext( nf ) );
     415              p_Delete( &pNext( nf ),r );
    415416              pNext( nf ) = nfhard;
    416417              NF->insert_node( m,nf );
     
    448449  } while( not_finished );
    449450
    450   pDelete( &Z );
     451  p_Delete( &Z,r );
    451452}
    452453
     
    455456// ----------------------------------------------------------------------------
    456457
    457 BOOLEAN ringIsLocal( void )
    458 {
    459   poly    m   = pOne();
    460   poly    one = pOne();
     458BOOLEAN ringIsLocal( const ring r )
     459{
     460  poly    m   = p_One(r);
     461  poly    one = p_One(r);
    461462  BOOLEAN res=TRUE;
    462463
    463   for( int i=pVariables; i>0; i-- )
    464   {
    465     pSetExp( m,i,1 );
    466     pSetm( m );
    467 
    468     if( pCmp( m,one )>0 )
     464  for( int i=r->N; i>0; i-- )
     465  {
     466    p_SetExp( m,i,1,r );
     467    p_Setm( m,r );
     468
     469    if( p_Cmp( m,one,r )>0 )
    469470    {
    470471      res=FALSE;
    471472      break;
    472473    }
    473     pSetExp( m,i,0 );
    474   }
    475 
    476   pDelete( &m );
    477   pDelete( &one );
     474    p_SetExp( m,i,0,r );
     475  }
     476
     477  p_Delete( &m,r );
     478  p_Delete( &one,r );
    478479
    479480  return  res;
  • kernel/spectrum.h

    r31f1262 r3835a88  
    1717BOOLEAN    semicProc   ( leftv,leftv,leftv );
    1818BOOLEAN    semicProc3   ( leftv,leftv,leftv,leftv );
    19 BOOLEAN    hasTermOfDegree( poly h, int d );
    20 int        hasOne( ideal J );
    21 BOOLEAN    hasAxis( ideal J,int k );
    22 poly       computeWC( const newtonPolygon &np,Rational max_weight );
    23 void       computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF );
     19BOOLEAN    hasTermOfDegree( poly h, int d, const ring r );
     20int        hasOne( ideal J, const ring r );
     21BOOLEAN    hasAxis( ideal J,int k, const ring r );
     22poly       computeWC( const newtonPolygon &np,Rational max_weight, const ring r );
     23void       computeNF( ideal stdJ,poly hc,poly wc,spectrumPolyList *NF, const ring r );
    2424void       spectrumPrintError(spectrumState state);
    25 BOOLEAN    ringIsLocal( void );
     25BOOLEAN    ringIsLocal( const ring r);
    2626
    27 BOOLEAN inline hasConstTerm( poly h )
    28 { return  hasTermOfDegree(h,0); }
    29 BOOLEAN inline hasLinearTerm( poly h )
    30 { return  hasTermOfDegree(h,1); }
     27BOOLEAN inline hasConstTerm( poly h, const ring r )
     28{ return  hasTermOfDegree(h,0,r); }
     29BOOLEAN inline hasLinearTerm( poly h, const ring r )
     30{ return  hasTermOfDegree(h,1,r); }
    3131
    3232
Note: See TracChangeset for help on using the changeset viewer.