Changeset b938f4 in git for kernel/npolygon.cc


Ignore:
Timestamp:
Jul 19, 2011, 12:55:56 PM (13 years ago)
Author:
mlee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
22a09d7b2686f280e5afec3b39bd5e02739c9a40
Parents:
ed47edfe6cd330b5befd43ea05889c3359a9d64a
git-author:
mlee <martinlee84@web.de>2011-07-19 12:55:56+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:39:57+01:00
Message:
added const ring r argument to all ring dependend functions
commented out MAX_INT_VAL in mod2.h
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/npolygon.cc

    red47edf rb938f4  
    1919#endif
    2020
    21 #include <polys/polys.h>
     21//#include <polys/polys.h>
     22#include <polys/monomials/p_polys.h>
     23#include <polys/monomials/ring.h>
     24
    2225#include <kernel/GMPrat.h>
    2326#include <kernel/kmatrix.h>
    2427#include <kernel/npolygon.h>
     28#include <kernel/structs.h>
    2529
    2630// ----------------------------------------------------------------------------
     
    181185// ----------------------------------------------------------------------------
    182186
    183 Rational linearForm::weight( poly m ) const
     187Rational linearForm::weight( poly m, const ring r ) const
    184188{
    185189  Rational ret=(Rational)0;
     
    187191  for( int i=0,j=1; i<N; i++,j++ )
    188192  {
    189     ret += c[i]*(Rational)pGetExp( m,j );
     193    ret += c[i]*(Rational)p_GetExp( m,j,r );
    190194  }
    191195
     
    197201// ----------------------------------------------------------------------------
    198202
    199 Rational linearForm::pweight( poly m ) const
     203Rational linearForm::pweight( poly m, const ring r ) const
    200204{
    201205  if( m==(poly)NULL )
    202206    return  (Rational)0;
    203207
    204   Rational    ret = weight( m );
     208  Rational    ret = weight( m, r );
    205209  Rational    tmp;
    206210
    207211  for( m=pNext(m); m!=(poly)NULL; pIter(m) )
    208212  {
    209     tmp = weight( m );
     213    tmp = weight( m, r );
    210214    if( tmp<ret )
    211215    {
     
    221225// ----------------------------------------------------------------------------
    222226
    223 Rational linearForm::weight_shift( poly m ) const
     227Rational linearForm::weight_shift( poly m, const ring r ) const
    224228{
    225229  Rational ret=(Rational)0;
     
    227231  for( int i=0,j=1; i<N; i++,j++ )
    228232  {
    229     ret += c[i]*(Rational)( pGetExp( m,j ) + 1 );
     233    ret += c[i]*(Rational)( p_GetExp( m,j,r ) + 1 );
    230234  }
    231235
     
    237241// ----------------------------------------------------------------------------
    238242
    239 Rational linearForm::weight1( poly m ) const
     243Rational linearForm::weight1( poly m, const ring r ) const
    240244{
    241245  Rational ret=(Rational)0;
     
    243247  for( int i=0,j=2; i<N; i++,j++ )
    244248  {
    245     ret += c[i]*(Rational)pGetExp( m,j );
     249    ret += c[i]*(Rational)p_GetExp( m,j,r );
    246250  }
    247251
     
    254258// ----------------------------------------------------------------------------
    255259
    256 Rational linearForm::weight_shift1( poly m ) const
     260Rational linearForm::weight_shift1( poly m, const ring r ) const
    257261{
    258262  Rational ret=(Rational)0;
     
    260264  for( int i=0,j=2; i<N; i++,j++ )
    261265  {
    262     ret += c[i]*(Rational)( pGetExp( m,j ) + 1 );
     266    ret += c[i]*(Rational)( p_GetExp( m,j,r ) + 1 );
    263267  }
    264268
     
    389393// ----------------------------------------------------------------------------
    390394
    391 newtonPolygon::newtonPolygon( poly f )
     395newtonPolygon::newtonPolygon( poly f, const ring s )
    392396{
    393397  copy_zero( );
    394398
    395   int *r=new int[pVariables];
    396   poly *m=new poly[pVariables];
    397 
    398 
    399   KMatrix<Rational> mat( pVariables,pVariables+1 );
     399  int *r=new int[s->N];
     400  poly *m=new poly[s->N];
     401
     402
     403  KMatrix<Rational> mat(s->N,s->N+1 );
    400404
    401405  int i,j,stop=FALSE;
     
    406410  // ---------------
    407411
    408   for( i=0; i<pVariables; i++ )
     412  for( i=0; i<s->N; i++ )
    409413  {
    410414    r[i] = i;
     
    413417  m[0] = f;
    414418
    415   for( i=1; i<pVariables; i++ )
     419  for( i=1; i<s->N; i++ )
    416420  {
    417421    m[i] = pNext(m[i-1]);
     
    429433    // ---------------------------------------------------
    430434
    431     for( i=0; i<pVariables; i++ )
    432     {
    433       for( j=0; j<pVariables; j++ )
     435    for( i=0; i<s->N; i++ )
     436    {
     437      for( j=0; j<s->N; j++ )
    434438      {
    435439        //    mat.set( i,j,pGetExp( m[r[i]],j+1 ) );
    436         mat.set( i,j,pGetExp( m[i],j+1 ) );
     440        mat.set( i,j,p_GetExp( m[i],j+1,s ) );
    437441      }
    438442      mat.set( i,j,1 );
    439443    }
    440444
    441     if( mat.solve( &(sol.c),&(sol.N) ) == pVariables )
     445    if( mat.solve( &(sol.c),&(sol.N) ) == s->N )
    442446    {
    443447      // ---------------------------------
     
    446450      // ---------------------------------
    447451
    448       if( sol.positive( ) && sol.pweight( f ) >= (Rational)1 )
     452      if( sol.positive( ) && sol.pweight( f,s ) >= (Rational)1 )
    449453      {
    450454        // ----------------------------------
     
    462466    // --------------------
    463467
    464     for( i=1; r[i-1] + 1 == r[i] && i < pVariables; i++ );
     468    for( i=1; r[i-1] + 1 == r[i] && i < s->N; i++ );
    465469
    466470    for( j=0; j<i-1; j++ )
     
    480484    m[i-1]=pNext(m[i-1]);
    481485
    482     if( m[pVariables-1] == (poly)NULL )
     486    if( m[s->N-1] == (poly)NULL )
    483487    {
    484488      stop = TRUE;
     
    556560// ----------------------------------------------------------------------------
    557561
    558 Rational  newtonPolygon::weight( poly m ) const
    559 {
    560   Rational ret = l[0].weight( m );
     562Rational  newtonPolygon::weight( poly m, const ring r ) const
     563{
     564  Rational ret = l[0].weight( m,r );
    561565  Rational tmp;
    562566
    563567  for( int i=1; i<N; i++ )
    564568  {
    565     tmp = l[i].weight( m );
     569    tmp = l[i].weight( m,r );
    566570
    567571    if( tmp < ret )
     
    577581// ----------------------------------------------------------------------------
    578582
    579 Rational  newtonPolygon::weight_shift( poly m ) const
    580 {
    581   Rational ret = l[0].weight_shift( m );
     583Rational  newtonPolygon::weight_shift( poly m, const ring r ) const
     584{
     585  Rational ret = l[0].weight_shift( m, r );
    582586  Rational tmp;
    583587
    584588  for( int i=1; i<N; i++ )
    585589  {
    586     tmp = l[i].weight_shift( m );
     590    tmp = l[i].weight_shift( m, r );
    587591
    588592    if( tmp < ret )
     
    598602// ----------------------------------------------------------------------------
    599603
    600 Rational  newtonPolygon::weight1( poly m ) const
    601 {
    602   Rational ret = l[0].weight1( m );
     604Rational  newtonPolygon::weight1( poly m, const ring r ) const
     605{
     606  Rational ret = l[0].weight1( m, r );
    603607  Rational tmp;
    604608
    605609  for( int i=1; i<N; i++ )
    606610  {
    607     tmp = l[i].weight1( m );
     611    tmp = l[i].weight1( m, r );
    608612
    609613    if( tmp < ret )
     
    620624// ----------------------------------------------------------------------------
    621625
    622 Rational  newtonPolygon::weight_shift1( poly m ) const
    623 {
    624   Rational ret = l[0].weight_shift1( m );
     626Rational  newtonPolygon::weight_shift1( poly m, const ring r ) const
     627{
     628  Rational ret = l[0].weight_shift1( m, r );
    625629  Rational tmp;
    626630
    627631  for( int i=1; i<N; i++ )
    628632  {
    629     tmp = l[i].weight_shift1( m );
     633    tmp = l[i].weight_shift1( m, r );
    630634
    631635    if( tmp < ret )
Note: See TracChangeset for help on using the changeset viewer.