Public Member Functions | Private Attributes
newtonPolygon Class Reference

#include <npolygon.h>

Public Member Functions

 newtonPolygon ()
 
 newtonPolygon (const newtonPolygon &)
 
 newtonPolygon (poly, const ring r)
 
 ~newtonPolygon ()
 
newtonPolygonoperator= (const newtonPolygon &)
 
void copy_new (int)
 
void copy_delete (void)
 
void copy_zero (void)
 
void copy_shallow (newtonPolygon &)
 
void copy_deep (const newtonPolygon &)
 
void add_linearForm (const linearForm &)
 
Rational weight (poly, const ring r) const
 
Rational weight_shift (poly, const ring r) const
 
Rational weight1 (poly, const ring r) const
 
Rational weight_shift1 (poly, const ring r) const
 

Private Attributes

linearForml
 
int N
 

Detailed Description

Definition at line 61 of file npolygon.h.

Constructor & Destructor Documentation

◆ newtonPolygon() [1/3]

newtonPolygon::newtonPolygon ( )
inline

Definition at line 165 of file npolygon.h.

166 {
167  copy_zero( );
168 }
void copy_zero(void)
Definition: npolygon.h:144

◆ newtonPolygon() [2/3]

newtonPolygon::newtonPolygon ( const newtonPolygon np)

Definition at line 367 of file npolygon.cc.

368 {
369  copy_deep( np );
370 }
void copy_deep(const newtonPolygon &)
Definition: npolygon.cc:353

◆ newtonPolygon() [3/3]

newtonPolygon::newtonPolygon ( poly  f,
const ring  r 
)

Definition at line 397 of file npolygon.cc.

398 {
399  copy_zero( );
400 
401  int *r=new int[s->N];
402  poly *m=new poly[s->N];
403 
404 
405  KMatrix<Rational> mat(s->N,s->N+1 );
406 
407  int i,j,stop=FALSE;
408  linearForm sol;
409 
410  // ---------------
411  // init counters
412  // ---------------
413 
414  for( i=0; i<s->N; i++ )
415  {
416  r[i] = i;
417  }
418 
419  m[0] = f;
420 
421  for( i=1; i<s->N; i++ )
422  {
423  m[i] = pNext(m[i-1]);
424  }
425 
426  // -----------------------------
427  // find faces (= linear forms)
428  // -----------------------------
429 
430  do
431  {
432  // ---------------------------------------------------
433  // test if monomials p.m[r[0]]m,...,p.m[r[p.vars-1]]
434  // are linearely independent
435  // ---------------------------------------------------
436 
437  for( i=0; i<s->N; i++ )
438  {
439  for( j=0; j<s->N; j++ )
440  {
441  // mat.set( i,j,pGetExp( m[r[i]],j+1 ) );
442  mat.set( i,j,p_GetExp( m[i],j+1,s ) );
443  }
444  mat.set( i,j,1 );
445  }
446 
447  if( mat.solve( &(sol.c),&(sol.N) ) == s->N )
448  {
449  // ---------------------------------
450  // check if linearForm is positive
451  // check if linearForm is extremal
452  // ---------------------------------
453 
454  if( sol.positive( ) && sol.pweight( f,s ) >= (Rational)1 )
455  {
456  // ----------------------------------
457  // this is a face or the polyhedron
458  // ----------------------------------
459 
460  add_linearForm( sol );
461  sol.c = (Rational*)NULL;
462  sol.N = 0;
463  }
464  }
465 
466  // --------------------
467  // increment counters
468  // --------------------
469 
470  for( i=1; r[i-1] + 1 == r[i] && i < s->N; i++ );
471 
472  for( j=0; j<i-1; j++ )
473  {
474  r[j]=j;
475  }
476 
477  if( i>1 )
478  {
479  m[0]=f;
480  for( j=1; j<i-1; j++ )
481  {
482  m[j]=pNext(m[j-1]);
483  }
484  }
485  r[i-1]++;
486  m[i-1]=pNext(m[i-1]);
487 
488  if( m[s->N-1] == (poly)NULL )
489  {
490  stop = TRUE;
491  }
492  } while( stop == FALSE );
493 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
#define FALSE
Definition: auxiliary.h:94
int positive(void)
Definition: npolygon.cc:279
#define TRUE
Definition: auxiliary.h:98
Rational * c
Definition: npolygon.h:22
Rational pweight(poly, const ring r) const
Definition: npolygon.cc:205
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:468
int m
Definition: cfEzgcd.cc:121
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:12
void add_linearForm(const linearForm &)
Definition: npolygon.cc:525
#define pNext(p)
Definition: monomials.h:36
void copy_zero(void)
Definition: npolygon.h:144

◆ ~newtonPolygon()

newtonPolygon::~newtonPolygon ( )

Definition at line 376 of file npolygon.cc.

377 {
378  copy_delete( );
379 }
void copy_delete(void)
Definition: npolygon.cc:342

Member Function Documentation

◆ add_linearForm()

void newtonPolygon::add_linearForm ( const linearForm l0)

Definition at line 525 of file npolygon.cc.

526 {
527  int i;
528  newtonPolygon np;
529 
530  // -------------------------------------
531  // test if linear form is already here
532  // -------------------------------------
533 
534  for( i=0; i<N; i++ )
535  {
536  if( l0==l[i] )
537  {
538  return;
539  }
540  }
541 
542  np.copy_new( N+1 );
543  np.N = N+1;
544 
545  for( i=0; i<N; i++ )
546  {
547  np.l[i].copy_shallow( l[i] );
548  l[i].copy_zero( );
549  }
550 
551  np.l[N] = l0;
552 
553  copy_delete( );
554  copy_shallow( np );
555  np.copy_zero( );
556 
557  return;
558 }
void copy_zero(void)
Definition: npolygon.h:109
void copy_shallow(linearForm &)
Definition: npolygon.h:119
void copy_new(int)
Definition: npolygon.cc:296
void copy_delete(void)
Definition: npolygon.cc:342
void copy_shallow(newtonPolygon &)
Definition: npolygon.h:154
int i
Definition: cfEzgcd.cc:125
linearForm * l
Definition: npolygon.h:66
void copy_zero(void)
Definition: npolygon.h:144

◆ copy_deep()

void newtonPolygon::copy_deep ( const newtonPolygon np)

Definition at line 353 of file npolygon.cc.

354 {
355  copy_new( np.N );
356  for( int i=0; i<np.N; i++ )
357  {
358  l[i] = np.l[i];
359  }
360  N = np.N;
361 }
void copy_new(int)
Definition: npolygon.cc:296
int i
Definition: cfEzgcd.cc:125
linearForm * l
Definition: npolygon.h:66

◆ copy_delete()

void newtonPolygon::copy_delete ( void  )

Definition at line 342 of file npolygon.cc.

343 {
344  if( l != (linearForm*)NULL && N > 0 )
345  delete [] l;
346  copy_zero( );
347 }
#define NULL
Definition: omList.c:12
linearForm * l
Definition: npolygon.h:66
void copy_zero(void)
Definition: npolygon.h:144

◆ copy_new()

void newtonPolygon::copy_new ( int  k)

Definition at line 296 of file npolygon.cc.

297 {
298  if( k > 0 )
299  {
300  l = new linearForm[k];
301 
302  #ifndef SING_NDEBUG
303  if( l == (linearForm*)NULL )
304  {
305  #ifdef NPOLYGON_PRINT
306  #ifdef NPOLYGON_IOSTREAM
307  cerr <<
308  "void newtonPolygon::copy_new( int k ): no memory left ...\n";
309  #else
310  fprintf( stderr,
311  "void newtonPolygon::copy_new( int k ): no memory left ...\n" );
312  #endif
313  #endif
314 
315  HALT();
316  }
317  #endif
318  }
319  else if( k == 0 )
320  {
321  l = (linearForm*)NULL;
322  }
323  else if( k < 0 )
324  {
325  #ifdef NPOLYGON_PRINT
326  #ifdef NPOLYGON_IOSTREAM
327  cerr << "void newtonPolygon::copy_new( int k ): k < 0 ...\n";
328  #else
329  fprintf( stderr,
330  "void newtonPolygon::copy_new( int k ): k < 0 ...\n" );
331  #endif
332  #endif
333 
334  HALT();
335  }
336 }
int k
Definition: cfEzgcd.cc:92
static void HALT()
Definition: mod2.h:127
#define NULL
Definition: omList.c:12
linearForm * l
Definition: npolygon.h:66

◆ copy_shallow()

void newtonPolygon::copy_shallow ( newtonPolygon np)
inline

Definition at line 154 of file npolygon.h.

155 {
156  l = np.l;
157  N = np.N;
158 }
linearForm * l
Definition: npolygon.h:66

◆ copy_zero()

void newtonPolygon::copy_zero ( void  )
inline

Definition at line 144 of file npolygon.h.

145 {
146  l = (linearForm*)NULL;
147  N = 0;
148 }
#define NULL
Definition: omList.c:12
linearForm * l
Definition: npolygon.h:66

◆ operator=()

newtonPolygon & newtonPolygon::operator= ( const newtonPolygon np)

Definition at line 385 of file npolygon.cc.

386 {
387  copy_delete( );
388  copy_deep( np );
389 
390  return *this;
391 }
void copy_deep(const newtonPolygon &)
Definition: npolygon.cc:353
void copy_delete(void)
Definition: npolygon.cc:342

◆ weight()

Rational newtonPolygon::weight ( poly  m,
const ring  r 
) const

Definition at line 564 of file npolygon.cc.

565 {
566  Rational ret = l[0].weight( m,r );
567  Rational tmp;
568 
569  for( int i=1; i<N; i++ )
570  {
571  tmp = l[i].weight( m,r );
572 
573  if( tmp < ret )
574  {
575  ret = tmp;
576  }
577  }
578  return ret;
579 }
Rational weight(poly, const ring r) const
Definition: npolygon.cc:189
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
linearForm * l
Definition: npolygon.h:66

◆ weight1()

Rational newtonPolygon::weight1 ( poly  m,
const ring  r 
) const

Definition at line 606 of file npolygon.cc.

607 {
608  Rational ret = l[0].weight1( m, r );
609  Rational tmp;
610 
611  for( int i=1; i<N; i++ )
612  {
613  tmp = l[i].weight1( m, r );
614 
615  if( tmp < ret )
616  {
617  ret = tmp;
618  }
619  }
620  return ret;
621 }
Rational weight1(poly, const ring r) const
Definition: npolygon.cc:245
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
linearForm * l
Definition: npolygon.h:66

◆ weight_shift()

Rational newtonPolygon::weight_shift ( poly  m,
const ring  r 
) const

Definition at line 585 of file npolygon.cc.

586 {
587  Rational ret = l[0].weight_shift( m, r );
588  Rational tmp;
589 
590  for( int i=1; i<N; i++ )
591  {
592  tmp = l[i].weight_shift( m, r );
593 
594  if( tmp < ret )
595  {
596  ret = tmp;
597  }
598  }
599  return ret;
600 }
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
Rational weight_shift(poly, const ring r) const
Definition: npolygon.cc:229
linearForm * l
Definition: npolygon.h:66

◆ weight_shift1()

Rational newtonPolygon::weight_shift1 ( poly  m,
const ring  r 
) const

Definition at line 628 of file npolygon.cc.

629 {
630  Rational ret = l[0].weight_shift1( m, r );
631  Rational tmp;
632 
633  for( int i=1; i<N; i++ )
634  {
635  tmp = l[i].weight_shift1( m, r );
636 
637  if( tmp < ret )
638  {
639  ret = tmp;
640  }
641  }
642  return ret;
643 }
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
linearForm * l
Definition: npolygon.h:66
Rational weight_shift1(poly, const ring r) const
Definition: npolygon.cc:262

Field Documentation

◆ l

linearForm* newtonPolygon::l
private

Definition at line 66 of file npolygon.h.

◆ N

int newtonPolygon::N
private

Definition at line 67 of file npolygon.h.


The documentation for this class was generated from the following files: