My Project
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Private Member Functions | Private Attributes
pointSet Class Reference

Public Member Functions

 pointSet (const int _dim, const int _index=0, const int count=MAXINITELEMS)
 
 ~pointSet ()
 
onePointP operator[] (const int index)
 
bool addPoint (const onePointP vert)
 Adds a point to pointSet, copy vert[0,...,dim] to point[num+1][0,...,dim]. More...
 
bool addPoint (const int *vert)
 Adds a point to pointSet, copy vert[0,...,dim] to point[num+1][0,...,dim]. More...
 
bool addPoint (const Coord_t *vert)
 Adds a point to pointSet, copy vert[0,...,dim] to point[num+1][0,...,dim]. More...
 
bool removePoint (const int indx)
 
bool mergeWithExp (const onePointP vert)
 Adds point to pointSet, iff pointSet \cap point = \emptyset. More...
 
bool mergeWithExp (const int *vert)
 Adds point to pointSet, iff pointSet \cap point = \emptyset. More...
 
void mergeWithPoly (const poly p)
 
void getRowMP (const int indx, int *vert)
 
int getExpPos (const poly p)
 
void sort ()
 sort lex More...
 
void lift (int *l=NULL)
 Lifts the point set using sufficiently generic linear lifting homogeneous forms l[1]..l[dim] in Z. More...
 
void unlift ()
 

Data Fields

int num
 
int max
 
int dim
 
int index
 

Private Member Functions

 pointSet (const pointSet &)
 
bool smaller (int, int)
 points[a] < points[b] ? More...
 
bool larger (int, int)
 points[a] > points[b] ? More...
 
bool checkMem ()
 Checks, if more mem is needed ( i.e. More...
 

Private Attributes

onePointP * points
 
bool lifted
 

Detailed Description

Definition at line 160 of file mpr_base.cc.

Constructor & Destructor Documentation

◆ pointSet() [1/2]

pointSet::pointSet ( const int  _dim,
const int  _index = 0,
const int  count = MAXINITELEMS 
)

Definition at line 412 of file mpr_base.cc.

413 : num(0), max(count), dim(_dim), index(_index)
414{
415 int i;
416 points = (onePointP *)omAlloc( (count+1) * sizeof(onePointP) );
417 for ( i= 0; i <= max; i++ )
418 {
419 points[i]= (onePointP)omAlloc( sizeof(onePoint) );
420 points[i]->point= (Coord_t *)omAlloc0( (dim+2) * sizeof(Coord_t) );
421 }
422 lifted= false;
423}
int i
Definition: cfEzgcd.cc:132
bool lifted
Definition: mpr_base.cc:164
int num
Definition: mpr_base.cc:167
int dim
Definition: mpr_base.cc:169
int index
Definition: mpr_base.cc:170
onePointP * points
Definition: mpr_base.cc:163
int max
Definition: mpr_base.cc:168
unsigned int Coord_t
Definition: mpr_base.cc:131
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int status int void size_t count
Definition: si_signals.h:59

◆ ~pointSet()

pointSet::~pointSet ( )

Definition at line 425 of file mpr_base.cc.

426{
427 int i;
428 int fdim= lifted ? dim+1 : dim+2;
429 for ( i= 0; i <= max; i++ )
430 {
431 omFreeSize( (void *) points[i]->point, fdim * sizeof(Coord_t) );
432 omFreeSize( (void *) points[i], sizeof(onePoint) );
433 }
434 omFreeSize( (void *) points, (max+1) * sizeof(onePointP) );
435}
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260

◆ pointSet() [2/2]

pointSet::pointSet ( const pointSet )
private

Member Function Documentation

◆ addPoint() [1/3]

bool pointSet::addPoint ( const Coord_t vert)

Adds a point to pointSet, copy vert[0,...,dim] to point[num+1][0,...,dim].

Returns false, iff additional memory was allocated ( i.e. num >= max ) else returns true

Definition at line 486 of file mpr_base.cc.

487{
488 int i;
489 bool ret;
490 num++;
491 ret= checkMem();
492 points[num]->rcPnt= NULL;
493 for ( i= 0; i < dim; i++ ) points[num]->point[i+1]= vert[i];
494 return ret;
495}
bool checkMem()
Checks, if more mem is needed ( i.e.
Definition: mpr_base.cc:443
#define NULL
Definition: omList.c:12

◆ addPoint() [2/3]

bool pointSet::addPoint ( const int *  vert)

Adds a point to pointSet, copy vert[0,...,dim] to point[num+1][0,...,dim].

Returns false, iff additional memory was allocated ( i.e. num >= max ) else returns true

Definition at line 475 of file mpr_base.cc.

476{
477 int i;
478 bool ret;
479 num++;
480 ret= checkMem();
481 points[num]->rcPnt= NULL;
482 for ( i= 1; i <= dim; i++ ) points[num]->point[i]= (Coord_t) vert[i];
483 return ret;
484}

◆ addPoint() [3/3]

bool pointSet::addPoint ( const onePointP  vert)

Adds a point to pointSet, copy vert[0,...,dim] to point[num+1][0,...,dim].

Returns false, iff additional memory was allocated ( i.e. num >= max ) else returns true

Definition at line 464 of file mpr_base.cc.

465{
466 int i;
467 bool ret;
468 num++;
469 ret= checkMem();
470 points[num]->rcPnt= NULL;
471 for ( i= 1; i <= dim; i++ ) points[num]->point[i]= vert->point[i];
472 return ret;
473}

◆ checkMem()

bool pointSet::checkMem ( )
inlineprivate

Checks, if more mem is needed ( i.e.

num >= max ), returns false, if more mem was allocated, else true

Definition at line 443 of file mpr_base.cc.

444{
445 if ( num >= max )
446 {
447 int i;
448 int fdim= lifted ? dim+1 : dim+2;
449 points= (onePointP*)omReallocSize( points,
450 (max+1) * sizeof(onePointP),
451 (2*max + 1) * sizeof(onePointP) );
452 for ( i= max+1; i <= max*2; i++ )
453 {
454 points[i]= (onePointP)omAlloc( sizeof(struct onePoint) );
455 points[i]->point= (Coord_t *)omAlloc0( fdim * sizeof(Coord_t) );
456 }
457 max*= 2;
459 return false;
460 }
461 return true;
462}
#define mprSTICKYPROT(msg)
Definition: mpr_global.h:54
#define ST_SPARSE_MEM
Definition: mpr_global.h:69
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220

◆ getExpPos()

int pointSet::getExpPos ( const poly  p)

Definition at line 578 of file mpr_base.cc.

579{
580 int * vert;
581 int i,j;
582
583 // hier unschoen...
584 vert= (int *)omAlloc( (dim+1) * sizeof(int) );
585
586 p_GetExpV( p, vert, currRing );
587 for ( i= 1; i <= num; i++ )
588 {
589 for ( j= 1; j <= dim; j++ )
590 if ( points[i]->point[j] != (Coord_t) vert[j] ) break;
591 if ( j > dim ) break;
592 }
593 omFreeSize( (void *) vert, (dim+1) * sizeof(int) );
594
595 if ( i > num ) return 0;
596 else return i;
597}
int p
Definition: cfModGcd.cc:4078
int j
Definition: facHensel.cc:110
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1518
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13

◆ getRowMP()

void pointSet::getRowMP ( const int  indx,
int *  vert 
)

Definition at line 599 of file mpr_base.cc.

600{
601 assume( indx > 0 && indx <= num && points[indx]->rcPnt );
602 int i;
603
604 vert[0]= 0;
605 for ( i= 1; i <= dim; i++ )
606 vert[i]= (int)(points[indx]->point[i] - points[indx]->rcPnt->point[i]);
607}
#define assume(x)
Definition: mod2.h:389

◆ larger()

bool pointSet::larger ( int  a,
int  b 
)
inlineprivate

points[a] > points[b] ?

Definition at line 628 of file mpr_base.cc.

629{
630 int i;
631
632 for ( i= 1; i <= dim; i++ )
633 {
634 if ( points[a]->point[i] < points[b]->point[i] )
635 {
636 return false;
637 }
638 if ( points[a]->point[i] > points[b]->point[i] )
639 {
640 return true;
641 }
642 }
643
644 return false; // they are equal
645}
CanonicalForm b
Definition: cfModGcd.cc:4103

◆ lift()

void pointSet::lift ( int *  l = NULL)

Lifts the point set using sufficiently generic linear lifting homogeneous forms l[1]..l[dim] in Z.

Every l[i] is of the form L1x1+...+Lnxn, for generic L1..Ln in Z.

Lifting raises dimension by one!

Definition at line 670 of file mpr_base.cc.

671{
672 bool outerL= true;
673 int i, j;
674 int sum;
675
676 dim++;
677
678 if ( l==NULL )
679 {
680 outerL= false;
681 l= (int *)omAlloc( (dim+1) * sizeof(int) ); // [1..dim-1]
682
683 for(i = 1; i < dim; i++)
684 {
685 l[i]= 1 + siRand() % LIFT_COOR;
686 }
687 }
688 for ( j=1; j <= num; j++ )
689 {
690 sum= 0;
691 for ( i=1; i < dim; i++ )
692 {
693 sum += (int)points[j]->point[i] * l[i];
694 }
695 points[j]->point[dim]= sum;
696 }
697
698#ifdef mprDEBUG_ALL
699 PrintS(" lift vector: ");
700 for ( j=1; j < dim; j++ ) Print(" %d ",l[j] );
701 PrintLn();
702#ifdef mprDEBUG_ALL
703 PrintS(" lifted points: \n");
704 for ( j=1; j <= num; j++ )
705 {
706 Print("%d: <",j);print_exp(points[j],dim);PrintS(">\n");
707 }
708 PrintLn();
709#endif
710#endif
711
712 lifted= true;
713
714 if ( !outerL ) omFreeSize( (void *) l, (dim+1) * sizeof(int) );
715}
int l
Definition: cfEzgcd.cc:100
#define Print
Definition: emacs.cc:80
#define LIFT_COOR
Definition: mpr_base.cc:50
void PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310
int siRand()
Definition: sirandom.c:42

◆ mergeWithExp() [1/2]

bool pointSet::mergeWithExp ( const int *  vert)

Adds point to pointSet, iff pointSet \cap point = \emptyset.

Returns true, iff added, else false.

Definition at line 531 of file mpr_base.cc.

532{
533 int i,j;
534
535 for ( i= 1; i <= num; i++ )
536 {
537 for ( j= 1; j <= dim; j++ )
538 if ( points[i]->point[j] != (Coord_t) vert[j] ) break;
539 if ( j > dim ) break;
540 }
541
542 if ( i > num )
543 {
544 addPoint( vert );
545 return true;
546 }
547 return false;
548}
bool addPoint(const onePointP vert)
Adds a point to pointSet, copy vert[0,...,dim] to point[num+1][0,...,dim].
Definition: mpr_base.cc:464

◆ mergeWithExp() [2/2]

bool pointSet::mergeWithExp ( const onePointP  vert)

Adds point to pointSet, iff pointSet \cap point = \emptyset.

Returns true, iff added, else false.

Definition at line 512 of file mpr_base.cc.

513{
514 int i,j;
515
516 for ( i= 1; i <= num; i++ )
517 {
518 for ( j= 1; j <= dim; j++ )
519 if ( points[i]->point[j] != vert->point[j] ) break;
520 if ( j > dim ) break;
521 }
522
523 if ( i > num )
524 {
525 addPoint( vert );
526 return true;
527 }
528 return false;
529}

◆ mergeWithPoly()

void pointSet::mergeWithPoly ( const poly  p)

Definition at line 550 of file mpr_base.cc.

551{
552 int i,j;
553 poly piter= p;
554 int * vert;
555 vert= (int *)omAlloc( (dim+1) * sizeof(int) );
556
557 while ( piter )
558 {
559 p_GetExpV( piter, vert, currRing );
560
561 for ( i= 1; i <= num; i++ )
562 {
563 for ( j= 1; j <= dim; j++ )
564 if ( points[i]->point[j] != (Coord_t) vert[j] ) break;
565 if ( j > dim ) break;
566 }
567
568 if ( i > num )
569 {
570 addPoint( vert );
571 }
572
573 pIter( piter );
574 }
575 omFreeSize( (void *) vert, (dim+1) * sizeof(int) );
576}
#define pIter(p)
Definition: monomials.h:37

◆ operator[]()

onePointP pointSet::operator[] ( const int  index)
inline

Definition at line 437 of file mpr_base.cc.

438{
439 assume( index_i > 0 && index_i <= num );
440 return points[index_i];
441}

◆ removePoint()

bool pointSet::removePoint ( const int  indx)

Definition at line 497 of file mpr_base.cc.

498{
499 assume( indx > 0 && indx <= num );
500 if ( indx != num )
501 {
502 onePointP tmp;
503 tmp= points[indx];
504 points[indx]= points[num];
505 points[num]= tmp;
506 }
507 num--;
508
509 return true;
510}

◆ smaller()

bool pointSet::smaller ( int  a,
int  b 
)
inlineprivate

points[a] < points[b] ?

Definition at line 609 of file mpr_base.cc.

610{
611 int i;
612
613 for ( i= 1; i <= dim; i++ )
614 {
615 if ( points[a]->point[i] > points[b]->point[i] )
616 {
617 return false;
618 }
619 if ( points[a]->point[i] < points[b]->point[i] )
620 {
621 return true;
622 }
623 }
624
625 return false; // they are equal
626}

◆ sort()

void pointSet::sort ( )

sort lex

Definition at line 647 of file mpr_base.cc.

648{
649 int i;
650 bool found= true;
651 onePointP tmp;
652
653 while ( found )
654 {
655 found= false;
656 for ( i= 1; i < num; i++ )
657 {
658 if ( larger( i, i+1 ) )
659 {
660 tmp= points[i];
661 points[i]= points[i+1];
662 points[i+1]= tmp;
663
664 found= true;
665 }
666 }
667 }
668}
bool larger(int, int)
points[a] > points[b] ?
Definition: mpr_base.cc:628
bool found
Definition: facFactorize.cc:55

◆ unlift()

void pointSet::unlift ( )
inline

Definition at line 229 of file mpr_base.cc.

229{ dim--; lifted= false; }

Field Documentation

◆ dim

int pointSet::dim

Definition at line 169 of file mpr_base.cc.

◆ index

int pointSet::index

Definition at line 170 of file mpr_base.cc.

◆ lifted

bool pointSet::lifted
private

Definition at line 164 of file mpr_base.cc.

◆ max

int pointSet::max

Definition at line 168 of file mpr_base.cc.

◆ num

int pointSet::num

Definition at line 167 of file mpr_base.cc.

◆ points

onePointP* pointSet::points
private

Definition at line 163 of file mpr_base.cc.


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