| 580 | |
| 581 | |
| 582 | int matrix::hosten_shapiro(int*& sat_var) |
| 583 | { |
| 584 | |
| 585 | if(_kernel_dimension==-2) |
| 586 | // lattice basis not yet computed |
| 587 | LLL_kernel_basis(); |
| 588 | |
| 589 | if(_kernel_dimension==-1) |
| 590 | { |
| 591 | cerr<<"\nWARNING: int matrix::hosten_shapiro(int*&):\n" |
| 592 | "error in kernel basis, cannot compute the saturation variables"<<endl; |
| 593 | return 0; |
| 594 | } |
| 595 | |
| 596 | if(_kernel_dimension==0) |
| 597 | // the toric ideal corresponding to the kernel lattice is the zero ideal, |
| 598 | // no saturation variables necessary |
| 599 | return 0; |
| 600 | |
| 601 | // Now, the kernel dimension is positive. |
| 602 | |
| 603 | if(columns==1) |
| 604 | // matrix consists of one zero column, kernel is generated by the vector |
| 605 | // (1) corresponding to the toric ideal <x-1> which is already staurated |
| 606 | return 0; |
| 607 | |
| 608 | int number_of_sat_var=0; |
| 609 | sat_var=new int[columns/2]; |
| 610 | memset(sat_var,0,sizeof(int)*(columns/2)); |
| 611 | |
| 612 | BOOLEAN* ideal_saturated_by_var=new BOOLEAN[columns]; |
| 613 | // auxiliary array used to remember by which variables the ideal has still to |
| 614 | // be saturated |
| 615 | for(int j=0;j<columns;j++) |
| 616 | ideal_saturated_by_var[j]=FALSE; |
| 617 | |
| 618 | for(int k=0;k<_kernel_dimension;k++) |
| 619 | { |
| 620 | // determine number of positive and negative components in H[k] |
| 621 | // corresponding to variables by which the ideal has still to be saturated |
| 622 | int pos_sat_var=0; |
| 623 | int neg_sat_var=0; |
| 624 | |
| 625 | for(int j=0;j<columns;j++) |
| 626 | { |
| 627 | if(ideal_saturated_by_var[j]==FALSE) |
| 628 | { |
| 629 | if(H[k][j]> BigInt(0)) |
| 630 | pos_sat_var++; |
| 631 | else |
| 632 | if(H[k][j]< BigInt(0)) |
| 633 | neg_sat_var++; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | |
| 638 | // now add the smaller set to the saturation variables |
| 639 | if(pos_sat_var<=neg_sat_var) |
no test coverage detected