[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:53:59 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit cae44af148ed6606591a213aebfb4681bf40c2bd
Author: Hans Schoenemann <hannes at mathematik.uni-kl.de>
Date: Mon Mar 5 11:34:19 2012 +0100
spelling: (tr 406, patch by Bernhard R. Link)
diff --git a/IntegerProgramming/binomial.cc b/IntegerProgramming/binomial.cc
index 34a69be..62cbc2a 100644
--- a/IntegerProgramming/binomial.cc
+++ b/IntegerProgramming/binomial.cc
@@ -298,7 +298,7 @@ binomial& binomial::operator=(const binomial& b)
if(_number_of_variables<=0)
{
cerr<<"\nWARNING: binomial& binomial::operator=(const binomial&):\n"
- "assigment from corrupt binomial"<<endl;
+ "assignment from corrupt binomial"<<endl;
exponent_vector=NULL;
return (*this);
}
diff --git a/IntegerProgramming/binomial.h b/IntegerProgramming/binomial.h
index e3f031c..1104950 100644
--- a/IntegerProgramming/binomial.h
+++ b/IntegerProgramming/binomial.h
@@ -114,7 +114,7 @@ public:
-// assigment and access operators
+// assignment and access operators
binomial& operator=(const binomial&);
// assignment operator with memory control
diff --git a/IntegerProgramming/list.cc b/IntegerProgramming/list.cc
index 9b68962..96afea8 100644
--- a/IntegerProgramming/list.cc
+++ b/IntegerProgramming/list.cc
@@ -962,7 +962,7 @@ BOOLEAN list_iterator::is_at_end() const
-////////////////////////// assigment ///////////////////////////////////////
+////////////////////////// assignment ///////////////////////////////////////
diff --git a/Singular/LIB/alexpoly.lib b/Singular/LIB/alexpoly.lib
index 13c3978..ffe161c 100644
--- a/Singular/LIB/alexpoly.lib
+++ b/Singular/LIB/alexpoly.lib
@@ -1745,7 +1745,7 @@ NOTE: This procedure is only for internal use; it is called by resgraph.
// End of the smooth case
int initial_tm=0; // total multipl. of the endpoint of Puiseux chain P_i-1
int g=size(charexp);
- list es=divsequence(charexp[2],charexp[1]); // keeps the lenghts of the Puiseuxchainparts s_i,j
+ list es=divsequence(charexp[2],charexp[1]); // keeps the lengths of the Puiseuxchainparts s_i,j
intvec divseq=es[1];
int r=es[2];
int initial=0;
diff --git a/Singular/LIB/algebra.lib b/Singular/LIB/algebra.lib
index e552728..452dea9 100644
--- a/Singular/LIB/algebra.lib
+++ b/Singular/LIB/algebra.lib
@@ -328,7 +328,7 @@ RETURN:
K[y(1),...,y(m)] ---> basering, y(i) --> fi.
@end format
NOTE: Three different algorithms are used depending on c = 1,2,3.
- If c is not given or c=0, a heuristically best method is choosen.
+ If c is not given or c=0, a heuristically best method is chosen.
The basering may be a quotient ring.
To access to the ring l[2] and see ker you must give the ring a name,
e.g. def S=l[2]; setring S; ker;
@@ -531,7 +531,7 @@ RETURN:
ideal 'ker', depending only on the y(i), the kernel of the given map
@end format
NOTE: Three differnt algorithms are used depending on c = 1,2,3.
- If c is not given or c=0, a heuristically best method is choosen.
+ If c is not given or c=0, a heuristically best method is chosen.
The basering may be a quotient ring. However, if the preimage ring is
a quotient ring, say pr = P/I, consider phi as a map from P and then
the algorithm returns 1 if the kernel of phi is 0 mod I.
diff --git a/Singular/LIB/arcpoint.lib b/Singular/LIB/arcpoint.lib
index 2e9244a..a69d67b 100644
--- a/Singular/LIB/arcpoint.lib
+++ b/Singular/LIB/arcpoint.lib
@@ -127,7 +127,7 @@ EXAMPLE: example nashmult; shows an example"
kill rplug;
- // consider all sequences of lenght <step-1> giving rise to a
+ // consider all sequences of length <step-1> giving rise to a
// family...
for(loop=1;loop<=setsize;loop++)
diff --git a/Singular/LIB/assprimeszerodim.lib b/Singular/LIB/assprimeszerodim.lib
index 6ff4b57..10b5518 100755
--- a/Singular/LIB/assprimeszerodim.lib
+++ b/Singular/LIB/assprimeszerodim.lib
@@ -242,7 +242,7 @@ EXAMPLE: example assPrimes; shows an example
int n1 = #[2];
int alg = 1;
if(n1 >= 10)
- {
+ {
int n2 = n1 + 1;
int n3 = n1;
}
@@ -257,7 +257,7 @@ EXAMPLE: example assPrimes; shows an example
int n1 = #[2];
int alg = #[3];
if(n1 >= 10)
- {
+ {
int n2 = n1 + 1;
int n3 = n1;
}
@@ -275,7 +275,7 @@ EXAMPLE: example assPrimes; shows an example
int n2 = 10;
int n3 = 10;
}
-
+
if(printlevel >= 10)
{
"n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3);
@@ -291,7 +291,7 @@ EXAMPLE: example assPrimes; shows an example
list H = ideal(0);
ideal F;
poly F1;
-
+
if(printlevel >= 10) { "========== Start modStd =========="; }
I = modStd(I,n1);
if(printlevel >= 10) { "=========== End modStd ==========="; }
@@ -414,14 +414,14 @@ EXAMPLE: example assPrimes; shows an example
int tt = timer;
int rt = rtimer;
-
+
while(1)
{
tt = timer;
rt = rtimer;
-
+
if(printlevel >= 9) { "size(L) = "+string(size(L)); }
-
+
if(n1 > 1)
{
while(j <= size(L) + 1)
@@ -470,7 +470,7 @@ EXAMPLE: example assPrimes; shows an example
j++;
}
}
-
+
if(printlevel >= 9)
{
"Real-time for computing list in assPrimes is "+string(rtimer - rt)+
@@ -489,7 +489,7 @@ EXAMPLE: example assPrimes; shows an example
if(printlevel >= 10) { "Lifting-process takes "+string(timer - tt)
+" seconds"; }
- if(pTestPoly(F[1], ringL, alg, L))
+ if(pTestPoly(F[1], ringL, alg, L))
{
F = cleardenom(F[1]);
@@ -512,13 +512,13 @@ EXAMPLE: example assPrimes; shows an example
setring SPR;
phi = rHelp,var(nvars(SPR));
H = phi(H);
-
+
if(printlevel >= 9)
{
"Real-time without test is "+string(rtimer - RT)+" seconds.";
"CPU-time without test is "+string(timer - T)+" seconds.";
}
-
+
T = timer;
RT = rtimer;
@@ -727,7 +727,7 @@ static proc findGen(ideal J, list #)
//=== try to find a sparse linear form r such that
//=== vector space dim(basering/J)=deg(F),
//=== F a poly in Q[T] such that <F>=kernel(Q[T]--->basering) mapping T to r
-//=== if not found returns a generic (randomly choosen) r
+//=== if not found returns a generic (randomly chosen) r
int d = vdim(J);
def R = basering;
int n = nvars(R);
@@ -918,7 +918,7 @@ static proc pTestPoly(poly testF, list ringL, int alg, list L)
{
int i,j,p;
def R0 = basering;
-
+
while(!i)
{
i = 1;
@@ -928,7 +928,7 @@ static proc pTestPoly(poly testF, list ringL, int alg, list L)
if(p == L[j]) { i = 0; break; }
}
}
-
+
ringL[1] = p;
def @R = ring(ringL);
setring @R;
@@ -941,7 +941,7 @@ static proc pTestPoly(poly testF, list ringL, int alg, list L)
setring @S;
poly testF = fetch(R0,testF);
int k = (testF == F);
-
+
setring R0;
return(k);
}
diff --git a/Singular/LIB/binresol.lib b/Singular/LIB/binresol.lib
index 30c2116..fed7a84 100644
--- a/Singular/LIB/binresol.lib
+++ b/Singular/LIB/binresol.lib
@@ -17,7 +17,7 @@ PROCEDURES:
Nonhyp(Coef,expJ,sJ,n,flag,sums); computes the ideal generated by the non hyperbolic generators of expJ
inidata(K,k); verifies input data, a binomial ideal K of k generators
identifyvar(); identifies status of variables
- data(K,k,n); transforms data on lists of lenght n
+ data(K,k,n); transforms data on lists of length n
Edatalist(Coef,Exp,k,n,flag); gives the E-order of each term in Exp
EOrdlist(Coef,Exp,k,n,flag); computes the E-order of an ideal (giving in the language of lists)
maxEord(Coef,Exp,k,n,flag); computes de maximum E-order of an ideal given by Coef and Exp
diff --git a/Singular/LIB/classify.lib b/Singular/LIB/classify.lib
index 62b836d..7eca104 100644
--- a/Singular/LIB/classify.lib
+++ b/Singular/LIB/classify.lib
@@ -2743,7 +2743,7 @@ static proc DecodeNormalFormString (string S_in)
}
s2 = Typ + s3 +"]";
} // es kommt mindestens ein komma vor...
- //----------------------- more than 1 paramater -----------------------------
+ //----------------------- more than 1 parameter -----------------------------
else {
b = find(s1, ",");
s2 = "k = ",s1[1..b-1],";";
diff --git a/Singular/LIB/elim.lib b/Singular/LIB/elim.lib
index 9032f4f..29c95d0 100644
--- a/Singular/LIB/elim.lib
+++ b/Singular/LIB/elim.lib
@@ -405,7 +405,7 @@ RETURN: ideal/module obtained from id by eliminating either the variables
Works also in a qring.
METHOD: elim uses elimRing to create a ring with an elimination ordering for
the variables to be eliminated and then applies std if \"std\"
- is given, or slimgb if \"slimgb\" is given, or a heuristically choosen
+ is given, or slimgb if \"slimgb\" is given, or a heuristically chosen
method.
@* If the variables in the basering have weights these weights are used
in elimRing. If a string \"withWeigts\" as (optional) argument is given
diff --git a/Singular/LIB/grobcov.lib b/Singular/LIB/grobcov.lib
index dc3d56e..2bf8a18 100644
--- a/Singular/LIB/grobcov.lib
+++ b/Singular/LIB/grobcov.lib
@@ -6751,7 +6751,7 @@ proc comb(int n, int p)
// Output: S=(w_1,..,w_j)
// where the w_l=(n_l1,..,n_ls) are intvec of length size(L), where
// n_lt fixes which element of (v_t1,..,v_tk_t) is to be
-// choosen to form the tth (Q,P) for the lth element of the sheaf
+// chosen to form the tth (Q,P) for the lth element of the sheaf
// representing the I-regular function.
// The selection is done to obtian the minimal number of elements
// of the sheaf that specializes to non-null everywhere.
diff --git a/Singular/LIB/homolog.lib b/Singular/LIB/homolog.lib
index 5687cab..e521921 100644
--- a/Singular/LIB/homolog.lib
+++ b/Singular/LIB/homolog.lib
@@ -232,7 +232,7 @@ ASSUME: all Ext's are of finite dimension
RETURN: - if called with 5 arguments: matrix of the associated linear map
Ext^p (tensor) Ext^q --> Ext^(p+q), i.e. the columns of <matrix>
present the coordinates of the cup products (b_i & c_j) with respect
- to a kbase of Ext^p+q (b_i resp. c_j are the choosen bases of Ext^p,
+ to a kbase of Ext^p+q (b_i resp. c_j are the chosen bases of Ext^p,
resp. Ext^q).@*
- if called with 6 arguments: list L,
@format
diff --git a/Singular/LIB/normal.lib b/Singular/LIB/normal.lib
index 73faa6c..886207f 100644
--- a/Singular/LIB/normal.lib
+++ b/Singular/LIB/normal.lib
@@ -181,7 +181,7 @@ EXAMPLE: example normal; shows an example
{
if ( typeof(#[i]) == "string" )
{
-//--------------------------- choosen methods -----------------------
+//--------------------------- chosen methods -----------------------
if ( (#[i]=="isprim") or (#[i]=="isPrim") )
{decomp = 0;}
@@ -377,11 +377,11 @@ EXAMPLE: example normal; shows an example
for(j = 1; j <= size(norComp); j++)
{
newR = norComp[j][3];
- if(!defined(savebasering)) { def savebasering;}
+ if(!defined(savebasering)) { def savebasering;}
savebasering=basering;
setring newR; // must be in a compatible ring to newR
// as ringlist may produce ring-dep. stuff
- if(!defined(newRList)) { list newRList;}
+ if(!defined(newRList)) { list newRList;}
newRList = ringlist(newR);
setring savebasering;
U = norComp[j][1];
@@ -5593,7 +5593,7 @@ EXAMPLE: example normalC; shows an example
}
}
- //--------------------------- choosen methods -----------------------
+ //--------------------------- chosen methods -----------------------
// "withGens": computes algebra generators for each irreducible component
// ### the extra code for withGens should be incorporated in the general case
diff --git a/Singular/LIB/random.lib b/Singular/LIB/random.lib
index 657865a..90afe95 100644
--- a/Singular/LIB/random.lib
+++ b/Singular/LIB/random.lib
@@ -410,7 +410,7 @@ example
proc randomBinomial(int k, int u, list #)
"USAGE: randomBinomial(k,u[,o,b]); k,u,o,b integers
RETURN: binomial ideal, k homogeneous generators of degree d, u<=d<=o, with
- randomly choosen monomials and coefficients in the interval [-b,b]
+ randomly chosen monomials and coefficients in the interval [-b,b]
(default: u=o, b=10).
EXAMPLE: example randomBinomial; shows an example
"
diff --git a/Singular/LIB/resbinomial.lib b/Singular/LIB/resbinomial.lib
index 36cc15a..2d410bd 100644
--- a/Singular/LIB/resbinomial.lib
+++ b/Singular/LIB/resbinomial.lib
@@ -52,7 +52,7 @@ PROCEDURES:
createlist(L1,L2); creates a list of lists of two elements
";
// inidata(K,k); verifies input data, a binomial ideal K of k generators
-// data(K,k,n); transforms data on lists of lenght n
+// data(K,k,n); transforms data on lists of length n
// list0(n); creates a list of zeros of size n
LIB "general.lib";
diff --git a/Singular/LIB/sagbi.lib b/Singular/LIB/sagbi.lib
index 534d059..2e3a689 100644
--- a/Singular/LIB/sagbi.lib
+++ b/Singular/LIB/sagbi.lib
@@ -167,7 +167,7 @@ static proc spolynomialsGB(ideal algebra,r,int method)
{
kernNew[i-nvars(r)+nvars(br)]=leadTermsAlgebra[i]-listOfVariables[i+nvars(br)];
}
- //--------------- calculate kernel of Phi depending on method choosen ---------------
+ //--------------- calculate kernel of Phi depending on method chosen ---------------
dbprint(ppl,"//Spoly-2- Groebner basis computation");
attrib(kernOld,"isSB",1);
ideal kern=stdKernPhi(kernNew,kernOld,leadTermsAlgebra,method);
@@ -345,7 +345,7 @@ static proc reductionGB(ideal F, ideal algebra,r, int tailreduction,int method,i
p=reduce(leadF,kern);
if (leadmonom(p)<varsBasering[numVarsBasering])
{
- //as choosen ordering is a block ordering,
+ //as chosen ordering is a block ordering,
//lm(p) in K[y_1...y_m] is equivalent to lm(p)<x_n
//Needs to be changed, if no block ordering is used!
setring br;
diff --git a/Singular/fehelp.cc b/Singular/fehelp.cc
index 16f750d..5ad2561 100644
--- a/Singular/fehelp.cc
+++ b/Singular/fehelp.cc
@@ -86,7 +86,7 @@ static int heCurrentHelpBrowserIndex= -1;
* Definition: available help browsers
*
*****************************************************************/
-// order is improtant -- first possible help is choosen
+// order is improtant -- first possible help is chosen
// moved to LIB/help.cnf
static heBrowser_s *heHelpBrowsers=NULL;
@@ -871,14 +871,14 @@ static BOOLEAN heGenInit(int warn, int br)
case 'h': /* html dir */
if (feResource(*p, warn) == NULL)
{
- if (warn) Warn("ressource `%c` not found",*p);
+ if (warn) Warn("resource `%c` not found",*p);
return FALSE;
}
break;
case 'D': /* DISPLAY */
if (getenv("DISPLAY") == NULL)
{
- if (warn) WarnS("ressource `D` not found");
+ if (warn) WarnS("resource `D` not found");
return FALSE;
}
break;
diff --git a/Singular/fglm.cc b/Singular/fglm.cc
index d940ade..24892fc 100644
--- a/Singular/fglm.cc
+++ b/Singular/fglm.cc
@@ -1,5 +1,4 @@
// emacs edit mode for this file is -*- C++ -*-
-// $Id$
/****************************************
* Computer Algebra System SINGULAR *
@@ -165,7 +164,7 @@ fglmConsistency( idhdl sringHdl, idhdl dringHdl, int * vperm )
for ( k= npar-1; (k >= 0) && (state == FglmOk); k-- )
if ( pperm[k] >= 0 )
{
- WerrorS( "paramater names do not agree" );
+ WerrorS( "parameter names do not agree" );
state= FglmIncompatibleRings;
}
if (pperm != NULL) // OB: ????
diff --git a/Singular/ipassign.cc b/Singular/ipassign.cc
index 3309b0e..4f926f6 100644
--- a/Singular/ipassign.cc
+++ b/Singular/ipassign.cc
@@ -1379,7 +1379,7 @@ BOOLEAN iiAssign(leftv l, leftv r)
}
if(like_lists)
{
- if (TEST_V_ALLWARN) PrintS("assign list[..]=...or similiar\n");
+ if (TEST_V_ALLWARN) PrintS("assign list[..]=...or similar\n");
b=jiAssign_list(l,r);
if((!b) && (like_lists==2))
{
@@ -1407,7 +1407,7 @@ BOOLEAN iiAssign(leftv l, leftv r)
return b;
}
}
- // end of handling elems of list and similiar
+ // end of handling elems of list and similar
rl=r->listLength();
if (rl==1)
{
diff --git a/Singular/misc_ip.cc b/Singular/misc_ip.cc
index 43c1629..c42eb06 100644
--- a/Singular/misc_ip.cc
+++ b/Singular/misc_ip.cc
@@ -258,7 +258,7 @@ lists primeFactorisation(const number n, const number pBound)
}
p_ui +=add;
//add += 2; if (add == 6) add = 2;
- add =2+2*(add==2);
+ add =2+2*(add==2);
}
mpz_set_ui(nn,nn_ui);
break;
@@ -1128,7 +1128,7 @@ void siInit(char *name)
siRandomStart=t;
feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
-// ressource table: ----------------------------------------------------
+// resource table: ----------------------------------------------------
// Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
// hack such that all shared' libs in the bindir are loaded correctly
feInitResources(name);
diff --git a/Tst/Buch/Example_4_6_26.tst b/Tst/Buch/Example_4_6_26.tst
index 7a20110..7ce5937 100644
--- a/Tst/Buch/Example_4_6_26.tst
+++ b/Tst/Buch/Example_4_6_26.tst
@@ -10,7 +10,7 @@ ideal I=-x(1)*x(2)+x(1)*x(4)+x(3),
+x(4)^2+3*x(2);
matrix M=char_series(I);
ring S=(0,x(4)),x(1..3),dp;//to see the result with re-
-matrix M=imap(R,M); //spect to the choosen ordering
+matrix M=imap(R,M); //spect to the chosen ordering
M;
tst_status(1);$
diff --git a/Tst/Short/bug_54.tst b/Tst/Short/bug_54.tst
index 262fc94..98c597c 100644
--- a/Tst/Short/bug_54.tst
+++ b/Tst/Short/bug_54.tst
@@ -16,7 +16,7 @@ matrix TT;
matrix MM = coeffs(I,y);
print (MM);
matrix NN = coeffs(I,y,TT);
-// should be similiar:
+// should be similar:
TT*NN;
I;
diff --git a/callgfanlib/gfan.cc b/callgfanlib/gfan.cc
index a9b4bb7..ac43c0f 100644
--- a/callgfanlib/gfan.cc
+++ b/callgfanlib/gfan.cc
@@ -1,9 +1,7 @@
/*
Compute the Groebner fan of an ideal
-$Author: monerjan $
-$Date: 2009/11/03 06:57:32 $
-$Header: /usr/local/Singular/cvsroot/kernel/gfan.cc,v 1.103 2009/11/03 06:57:32 monerjan Exp $
-$Id: gfan.cc 14271 2011-06-10 08:00:12Z monerjan $
+Author: monerjan
+Date: 2009/11/03 06:57:32
*/
#include <kernel/mod2.h>
@@ -17,11 +15,11 @@ $Id: gfan.cc 14271 2011-06-10 08:00:12Z monerjan $
#include <kernel/kmatrix.h>
#include <kernel/GMPrat.h>
-//#include "ring.h" //apparently not needed
+//#include "ring.h" //apparently not needed
#include <Singular/lists.h>
#include <kernel/prCopy.h>
#include <kernel/stairc.h>
-#include <fstream> //read-write cones to files
+#include <fstream> //read-write cones to files
#include <string>
#include <sstream>
#include <stdlib.h>
@@ -68,99 +66,99 @@ using namespace std;
/**
*\brief Class facet
-* Implements the facet structure as a linked list
+* Implements the facet structure as a linked list
*
*/
-
+
/** \brief The default constructor for facets
*/
-facet::facet()
+facet::facet()
{
- // Pointer to next facet. */
- /* Defaults to NULL. This way there is no need to check explicitly */
- this->fNormal=NULL;
- this->interiorPoint=NULL;
- this->UCN=0;
- this->codim2Ptr=NULL;
- this->codim=1; //default for (codim-1)-facets
- this->numCodim2Facets=0;
- this->numRays=0;
- this->flipGB=NULL;
- this->next=NULL;
- this->prev=NULL;
- this->flipRing=NULL; //the ring on the other side
- this->isFlippable=FALSE;
+ // Pointer to next facet. */
+ /* Defaults to NULL. This way there is no need to check explicitly */
+ this->fNormal=NULL;
+ this->interiorPoint=NULL;
+ this->UCN=0;
+ this->codim2Ptr=NULL;
+ this->codim=1; //default for (codim-1)-facets
+ this->numCodim2Facets=0;
+ this->numRays=0;
+ this->flipGB=NULL;
+ this->next=NULL;
+ this->prev=NULL;
+ this->flipRing=NULL; //the ring on the other side
+ this->isFlippable=FALSE;
}
-
+
/** \brief Constructor for facets of codim == 2
* Note that as of now the code of the constructors is only for facets and codim2-faces. One
* could easily change that by renaming numCodim2Facets to numCodimNminusOneFacets or similar
*/
facet::facet(const int &n)
{
- this->fNormal=NULL;
- this->interiorPoint=NULL;
- this->UCN=0;
- this->codim2Ptr=NULL;
- if(n==2)
- {
- this->codim=n;
- }//NOTE Handle exception here!
- this->numCodim2Facets=0;
- this->numRays=0;
- this->flipGB=NULL;
- this->next=NULL;
- this->prev=NULL;
- this->flipRing=NULL;
- this->isFlippable=FALSE;
+ this->fNormal=NULL;
+ this->interiorPoint=NULL;
+ this->UCN=0;
+ this->codim2Ptr=NULL;
+ if(n==2)
+ {
+ this->codim=n;
+ }//NOTE Handle exception here!
+ this->numCodim2Facets=0;
+ this->numRays=0;
+ this->flipGB=NULL;
+ this->next=NULL;
+ this->prev=NULL;
+ this->flipRing=NULL;
+ this->isFlippable=FALSE;
}
-
+
/** \brief The copy constructor
* By default only copies the fNormal, f2Normals and UCN
*/
facet::facet(const facet& f)
{
- this->fNormal=iv64Copy(f.fNormal);
- this->UCN=f.UCN;
- this->isFlippable=f.isFlippable;
- //Needed for flip2
- //NOTE ONLY REFERENCE
- this->interiorPoint=iv64Copy(f.interiorPoint);//only referencing is prolly not the best thing to do in a copy constructor
- facet* f2Copy;
- f2Copy=f.codim2Ptr;
- facet* f2Act;
- f2Act=this->codim2Ptr;
- while(f2Copy!=NULL)
- {
- if(f2Act==NULL
+ this->fNormal=iv64Copy(f.fNormal);
+ this->UCN=f.UCN;
+ this->isFlippable=f.isFlippable;
+ //Needed for flip2
+ //NOTE ONLY REFERENCE
+ this->interiorPoint=iv64Copy(f.interiorPoint);//only referencing is prolly not the best thing to do in a copy constructor
+ facet* f2Copy;
+ f2Copy=f.codim2Ptr;
+ facet* f2Act;
+ f2Act=this->codim2Ptr;
+ while(f2Copy!=NULL)
+ {
+ if(f2Act==NULL
#ifndef NDEBUG
#if SIZEOF_LONG==8
- || f2Act==(facet*)0xfefefefefefefefe
+ || f2Act==(facet*)0xfefefefefefefefe
#elif SIZEOF_LONG==4
- || f2Act==(facet*)0xfefefefe
+ || f2Act==(facet*)0xfefefefe
#endif
#endif
- )
- {
- f2Act=new facet(2);
- this->codim2Ptr=f2Act;
- }
- else
- {
- facet* marker;
- marker = f2Act;
- f2Act->next = new facet(2);
- f2Act = f2Act->next;
- f2Act->prev = marker;
- }
- int64vec *f2Normal;
- f2Normal = f2Copy->getFacetNormal();
-// f2Act->setFacetNormal(f2Copy->getFacetNormal());
- f2Act->setFacetNormal(f2Normal);
- delete f2Normal;
- f2Act->setUCN(f2Copy->getUCN());
- f2Copy = f2Copy->next;
- }
+ )
+ {
+ f2Act=new facet(2);
+ this->codim2Ptr=f2Act;
+ }
+ else
+ {
+ facet* marker;
+ marker = f2Act;
+ f2Act->next = new facet(2);
+ f2Act = f2Act->next;
+ f2Act->prev = marker;
+ }
+ int64vec *f2Normal;
+ f2Normal = f2Copy->getFacetNormal();
+// f2Act->setFacetNormal(f2Copy->getFacetNormal());
+ f2Act->setFacetNormal(f2Normal);
+ delete f2Normal;
+ f2Act->setUCN(f2Copy->getUCN());
+ f2Copy = f2Copy->next;
+ }
}
/** \brief Shallow copy constructor for facets
@@ -168,100 +166,100 @@ facet::facet(const facet& f)
*/
facet* facet::shallowCopy(const facet& f)
{
- facet *res = new facet();
- res->fNormal=(int64vec * const)f.fNormal;
- res->UCN=f.UCN;
- res->isFlippable=f.isFlippable;
- res->interiorPoint=(int64vec * const)f.interiorPoint;
- res->codim2Ptr=(facet * const)f.codim2Ptr;
- res->prev=NULL;
- res->next=NULL;
- res->flipGB=NULL;
- res->flipRing=NULL;
- return res;
+ facet *res = new facet();
+ res->fNormal=(int64vec * const)f.fNormal;
+ res->UCN=f.UCN;
+ res->isFlippable=f.isFlippable;
+ res->interiorPoint=(int64vec * const)f.interiorPoint;
+ res->codim2Ptr=(facet * const)f.codim2Ptr;
+ res->prev=NULL;
+ res->next=NULL;
+ res->flipGB=NULL;
+ res->flipRing=NULL;
+ return res;
}
void facet::shallowDelete()
{
#ifndef NDEBUG
-// printf("shallowdel at UCN %i\n", this->getUCN());
+// printf("shallowdel at UCN %i\n", this->getUCN());
#endif
- this->fNormal=NULL;
-// this->UCN=0;
- this->interiorPoint=NULL;
- this->codim2Ptr=NULL;
- this->prev=NULL;
- this->next=NULL;
- this->flipGB=NULL;
- this->flipRing=NULL;
- assert(this->fNormal==NULL);
-// delete(this);
+ this->fNormal=NULL;
+// this->UCN=0;
+ this->interiorPoint=NULL;
+ this->codim2Ptr=NULL;
+ this->prev=NULL;
+ this->next=NULL;
+ this->flipGB=NULL;
+ this->flipRing=NULL;
+ assert(this->fNormal==NULL);
+// delete(this);
}
-
+
/** The default destructor */
facet::~facet()
{
#ifndef NDEBUG
-// printf("~facet at UCN %i\n",this->getUCN());
+// printf("~facet at UCN %i\n",this->getUCN());
#endif
- if(this->fNormal!=NULL)
- delete this->fNormal;
- if(this->interiorPoint!=NULL)
- delete this->interiorPoint;
- /* Cleanup the codim2-structure */
-// if(this->codim==2)
-// {
-// facet *codim2Ptr;
-// codim2Ptr = this->codim2Ptr;
-// while(codim2Ptr!=NULL)
-// {
-// if(codim2Ptr->fNormal!=NULL)
-// {
-// delete codim2Ptr->fNormal;//NOTE Do not want this anymore since the rays are now in gcone!
-// codim2Ptr = codim2Ptr->next;
-// }
-// }
-// }
- //The rays are stored in the cone!
- if(this->flipGB!=NULL)
- idDelete((ideal *)&this->flipGB);
-// if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb)
-// rDelete(this->flipRing); //See vol II/134
-// this->flipRing=NULL;
- this->prev=NULL;
- this->next=NULL;
+ if(this->fNormal!=NULL)
+ delete this->fNormal;
+ if(this->interiorPoint!=NULL)
+ delete this->interiorPoint;
+ /* Cleanup the codim2-structure */
+// if(this->codim==2)
+// {
+// facet *codim2Ptr;
+// codim2Ptr = this->codim2Ptr;
+// while(codim2Ptr!=NULL)
+// {
+// if(codim2Ptr->fNormal!=NULL)
+// {
+// delete codim2Ptr->fNormal;//NOTE Do not want this anymore since the rays are now in gcone!
+// codim2Ptr = codim2Ptr->next;
+// }
+// }
+// }
+ //The rays are stored in the cone!
+ if(this->flipGB!=NULL)
+ idDelete((ideal *)&this->flipGB);
+// if(this->flipRing!=NULL && this->flipRing->idroot!=(idhdl)0xfbfbfbfbfbfbfbfb)
+// rDelete(this->flipRing); //See vol II/134
+// this->flipRing=NULL;
+ this->prev=NULL;
+ this->next=NULL;
}
-
+
inline const int64vec *facet::getRef2FacetNormal() const
{
- return(this->fNormal);
-}
+ return(this->fNormal);
+}
/** Equality check for facets based on unique interior points*/
static bool areEqual2(facet* f, facet *g)
{
#ifdef gfanp
- gcone::numberOfFacetChecks++;
- timeval start, end;
- gettimeofday(&start, 0);
+ gcone::numberOfFacetChecks++;
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- bool res = TRUE;
- const int64vec *fIntP = f->getRef2InteriorPoint();
- const int64vec *gIntP = g->getRef2InteriorPoint();
- for(int ii=0;ii<pVariables;ii++)
- {
- if( (*fIntP)[ii] != (*gIntP)[ii] )
- {
- res=FALSE;
- break;
- }
- }
-// if( fIntP->compare(gIntP)!=0) res=FALSE;
+ bool res = TRUE;
+ const int64vec *fIntP = f->getRef2InteriorPoint();
+ const int64vec *gIntP = g->getRef2InteriorPoint();
+ for(int ii=0;ii<pVariables;ii++)
+ {
+ if( (*fIntP)[ii] != (*gIntP)[ii] )
+ {
+ res=FALSE;
+ break;
+ }
+ }
+// if( fIntP->compare(gIntP)!=0) res=FALSE;
#ifdef gfanp
- gettimeofday(&end, 0);
- gcone::t_areEqual += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-#endif
- return res;
+ gettimeofday(&end, 0);
+ gcone::t_areEqual += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+#endif
+ return res;
}
/** \brief Comparison of facets
@@ -276,77 +274,77 @@ static bool areEqual2(facet* f, facet *g)
static bool areEqual(facet *f, facet *s)
{
#ifdef gfanp
- gcone::numberOfFacetChecks++;
- timeval start, end;
- gettimeofday(&start, 0);
+ gcone::numberOfFacetChecks++;
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- bool res = TRUE;
- int notParallelCtr=0;
- int ctr=0;
- const int64vec* fNormal; //No new since iv64Copy and therefore getFacetNormal return a new
- const int64vec* sNormal;
- fNormal = f->getRef2FacetNormal();
- sNormal = s->getRef2FacetNormal();
+ bool res = TRUE;
+ int notParallelCtr=0;
+ int ctr=0;
+ const int64vec* fNormal; //No new since iv64Copy and therefore getFacetNormal return a new
+ const int64vec* sNormal;
+ fNormal = f->getRef2FacetNormal();
+ sNormal = s->getRef2FacetNormal();
#include <kernel/intvec.h>
- //Do not need parallelity. Too time consuming
-// if(!isParallel(*fNormal,*sNormal))
-// if(fNormal->compare(ivNeg(sNormal))!=0)//This results in a Mandelbug
- // notParallelCtr++;
-// else//parallelity, so we check the codim2-facets
- int64vec *fNRef=const_cast<int64vec*>(fNormal);
- int64vec *sNRef=const_cast<int64vec*>(sNormal);
- if(isParallel(*fNRef,*sNRef))
-// if(fNormal->compare((sNormal))!=0)//Behold! Teh definitive Mandelbug
- {
- facet* f2Act;
- facet* s2Act;
- f2Act = f->codim2Ptr;
- ctr=0;
- while(f2Act!=NULL)
- {
- const int64vec* f2Normal;
- f2Normal = f2Act->getRef2FacetNormal();
-// int64vec *f2Ref=const_cast<int64vec*>(f2Normal);
- s2Act = s->codim2Ptr;
- while(s2Act!=NULL)
- {
- const int64vec* s2Normal;
- s2Normal = s2Act->getRef2FacetNormal();
-// bool foo=areEqual(f2Normal,s2Normal);
-// int64vec *s2Ref=const_cast<int64vec*>(s2Normal);
- int foo=f2Normal->compare(s2Normal);
- if(foo==0)
- ctr++;
- s2Act = s2Act->next;
- }
- f2Act = f2Act->next;
- }
- }
- if(ctr==f->numCodim2Facets)
- res=TRUE;
- else
- {
+ //Do not need parallelity. Too time consuming
+// if(!isParallel(*fNormal,*sNormal))
+// if(fNormal->compare(ivNeg(sNormal))!=0)//This results in a Mandelbug
+ // notParallelCtr++;
+// else//parallelity, so we check the codim2-facets
+ int64vec *fNRef=const_cast<int64vec*>(fNormal);
+ int64vec *sNRef=const_cast<int64vec*>(sNormal);
+ if(isParallel(*fNRef,*sNRef))
+// if(fNormal->compare((sNormal))!=0)//Behold! Teh definitive Mandelbug
+ {
+ facet* f2Act;
+ facet* s2Act;
+ f2Act = f->codim2Ptr;
+ ctr=0;
+ while(f2Act!=NULL)
+ {
+ const int64vec* f2Normal;
+ f2Normal = f2Act->getRef2FacetNormal();
+// int64vec *f2Ref=const_cast<int64vec*>(f2Normal);
+ s2Act = s->codim2Ptr;
+ while(s2Act!=NULL)
+ {
+ const int64vec* s2Normal;
+ s2Normal = s2Act->getRef2FacetNormal();
+// bool foo=areEqual(f2Normal,s2Normal);
+// int64vec *s2Ref=const_cast<int64vec*>(s2Normal);
+ int foo=f2Normal->compare(s2Normal);
+ if(foo==0)
+ ctr++;
+ s2Act = s2Act->next;
+ }
+ f2Act = f2Act->next;
+ }
+ }
+ if(ctr==f->numCodim2Facets)
+ res=TRUE;
+ else
+ {
#ifdef gfanp
- gcone::parallelButNotEqual++;
+ gcone::parallelButNotEqual++;
#endif
- res=FALSE;
- }
+ res=FALSE;
+ }
#ifdef gfanp
- gettimeofday(&end, 0);
- gcone::t_areEqual += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+ gettimeofday(&end, 0);
+ gcone::t_areEqual += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
#endif
- return res;
-}
-
+ return res;
+}
+
/** Stores the facet normal \param int64vec*/
inline void facet::setFacetNormal(int64vec *iv)
{
- if(this->fNormal!=NULL)
- delete this->fNormal;
- this->fNormal = iv64Copy(iv);
+ if(this->fNormal!=NULL)
+ delete this->fNormal;
+ this->fNormal = iv64Copy(iv);
}
-
-/** Hopefully returns the facet normal
+
+/** Hopefully returns the facet normal
* Mind: iv64Copy returns a new int64vec, so use this in the following way:
* int64vec *iv;
* iv = this->getFacetNormal();
@@ -354,111 +352,111 @@ inline void facet::setFacetNormal(int64vec *iv)
* delete(iv);
*/
inline int64vec *facet::getFacetNormal() const
-{
- return iv64Copy(this->fNormal);
+{
+ return iv64Copy(this->fNormal);
}
/** Method to print the facet normal*/
inline void facet::printNormal() const
{
- fNormal->show();
+ fNormal->show();
}
-
+
/** Store the flipped GB*/
inline void facet::setFlipGB(ideal I)
{
- this->flipGB=idCopy(I);
+ this->flipGB=idCopy(I);
}
-
+
/** Returns a pointer to the flipped GB
Seems not be used
Anyhow idCopy would make sense here.
*/
inline ideal facet::getFlipGB()
{
- return this->flipGB;
+ return this->flipGB;
}
-
+
/** Print the flipped GB*/
inline void facet::printFlipGB()
{
#ifndef NDEBUG
- idShow(this->flipGB);
+ idShow(this->flipGB);
#endif
}
-
+
/** Set the UCN */
inline void facet::setUCN(int n)
{
- this->UCN=n;
+ this->UCN=n;
}
-
-/** \brief Get the UCN
+
+/** \brief Get the UCN
* Returns the UCN iff this != NULL, else -1
*/
inline int facet::getUCN()
{
#ifndef NDEBUG
#if SIZEOF_LONG==8
- if((this!=NULL && this!=(facet * const)0xfbfbfbfbfbfbfbfb))
+ if((this!=NULL && this!=(facet * const)0xfbfbfbfbfbfbfbfb))
#elif SIZEOF_LONG==4
- if((this!=NULL && this!=(facet * const)0xfbfbfbfb))
+ if((this!=NULL && this!=(facet * const)0xfbfbfbfb))
#endif
#endif
#ifdef NDEBUG
- if(this!=NULL)
-#endif
- return this->UCN;
- else
- return -1;
+ if(this!=NULL)
+#endif
+ return this->UCN;
+ else
+ return -1;
}
-
+
/** Store an interior point of the facet */
inline void facet::setInteriorPoint(int64vec *iv)
{
- if(this->interiorPoint!=NULL)
- delete this->interiorPoint;
- this->interiorPoint = iv64Copy(iv);
+ if(this->interiorPoint!=NULL)
+ delete this->interiorPoint;
+ this->interiorPoint = iv64Copy(iv);
}
-
+
/** Returns a pointer to this->interiorPoint
* MIND: iv64Copy returns a new int64vec
* @see facet::getFacetNormal
*/
inline int64vec *facet::getInteriorPoint()
{
- return iv64Copy(this->interiorPoint);
+ return iv64Copy(this->interiorPoint);
}
inline const int64vec *facet::getRef2InteriorPoint()
{
- return (this->interiorPoint);
+ return (this->interiorPoint);
}
-
+
/** \brief Debugging function
* prints the facet normal an all (codim-2)-facets that belong to it
*/
volatile void facet::fDebugPrint()
{
#ifndef NDEBUG
- facet *codim2Act;
- codim2Act = this->codim2Ptr;
- int64vec *fNormal;
- fNormal = this->getFacetNormal();
- printf("=======================\n");
- printf("Facet normal = (");fNormal->show(1,1);printf(")\n");
- printf("-----------------------\n");
- printf("Codim2 facets:\n");
- while(codim2Act!=NULL)
- {
- int64vec *f2Normal;
- f2Normal = codim2Act->getFacetNormal();
- printf("(");f2Normal->show(1,0);printf(")\n");
- codim2Act = codim2Act->next;
- delete f2Normal;
- }
- printf("=======================\n");
- delete fNormal;
+ facet *codim2Act;
+ codim2Act = this->codim2Ptr;
+ int64vec *fNormal;
+ fNormal = this->getFacetNormal();
+ printf("=======================\n");
+ printf("Facet normal = (");fNormal->show(1,1);printf(")\n");
+ printf("-----------------------\n");
+ printf("Codim2 facets:\n");
+ while(codim2Act!=NULL)
+ {
+ int64vec *f2Normal;
+ f2Normal = codim2Act->getFacetNormal();
+ printf("(");f2Normal->show(1,0);printf(")\n");
+ codim2Act = codim2Act->next;
+ delete f2Normal;
+ }
+ printf("=======================\n");
+ delete fNormal;
#endif
}
@@ -471,26 +469,26 @@ volatile void facet::fDebugPrint()
*/
-/** \brief Default constructor.
+/** \brief Default constructor.
*
* Initialises this->next=NULL and this->facetPtr=NULL
*/
gcone::gcone()
{
- this->next=NULL;
- this->prev=NULL;
- this->facetPtr=NULL; //maybe this->facetPtr = new facet();
- this->baseRing=currRing;
- this->counter++;
- this->UCN=this->counter;
- this->numFacets=0;
- this->ivIntPt=NULL;
- this->gcRays=NULL;
+ this->next=NULL;
+ this->prev=NULL;
+ this->facetPtr=NULL; //maybe this->facetPtr = new facet();
+ this->baseRing=currRing;
+ this->counter++;
+ this->UCN=this->counter;
+ this->numFacets=0;
+ this->ivIntPt=NULL;
+ this->gcRays=NULL;
}
-
+
/** \brief Constructor with ring and ideal
*
- * This constructor takes the root ring and the root ideal as parameters and stores
+ * This constructor takes the root ring and the root ideal as parameters and stores
* them in the private members gcone::rootRing and gcone::inputIdeal
* This constructor is only called once in the computation of the Gröbner fan,
* namely for the very first cone. Therefore pred is set to 1.
@@ -500,267 +498,267 @@ gcone::gcone()
*/
gcone::gcone(ring r, ideal I)
{
- this->next=NULL;
- this->prev=NULL;
- this->facetPtr=NULL;
- this->inputIdeal=I;
- this->baseRing=currRing;
- this->counter++;
- this->UCN=this->counter;
- this->pred=1;
- this->numFacets=0;
- this->ivIntPt=NULL;
- this->gcRays=NULL;
+ this->next=NULL;
+ this->prev=NULL;
+ this->facetPtr=NULL;
+ this->inputIdeal=I;
+ this->baseRing=currRing;
+ this->counter++;
+ this->UCN=this->counter;
+ this->pred=1;
+ this->numFacets=0;
+ this->ivIntPt=NULL;
+ this->gcRays=NULL;
}
-
-/** \brief Copy constructor
+
+/** \brief Copy constructor
*
* Copies a cone, sets this->gcBasis to the flipped GB
* Call this only after a successful call to gcone::flip which sets facet::flipGB
-*/
+*/
gcone::gcone(const gcone& gc, const facet &f)
{
- this->next=NULL;
-// this->prev=(gcone *)&gc; //comment in to get a tree
- this->prev=NULL;
- this->numVars=gc.numVars;
- this->counter++;
- this->UCN=this->counter;
- this->pred=gc.UCN;
- this->facetPtr=NULL;
- this->gcBasis=idrCopyR(f.flipGB, f.flipRing);
-// this->inputIdeal=idCopy(this->gcBasis);
- this->baseRing=rCopy(f.flipRing);
- this->numFacets=0;
- this->ivIntPt=NULL;
- this->gcRays=NULL;
+ this->next=NULL;
+// this->prev=(gcone *)&gc; //comment in to get a tree
+ this->prev=NULL;
+ this->numVars=gc.numVars;
+ this->counter++;
+ this->UCN=this->counter;
+ this->pred=gc.UCN;
+ this->facetPtr=NULL;
+ this->gcBasis=idrCopyR(f.flipGB, f.flipRing);
+// this->inputIdeal=idCopy(this->gcBasis);
+ this->baseRing=rCopy(f.flipRing);
+ this->numFacets=0;
+ this->ivIntPt=NULL;
+ this->gcRays=NULL;
}
-
-/** \brief Default destructor
+
+/** \brief Default destructor
*/
gcone::~gcone()
{
#ifndef NDEBUG
#if SIZEOF_LONG==8
- if( ( this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb) ) && (this->gcBasis!=NULL) )
- idDelete((ideal*)&this->gcBasis);
+ if( ( this->gcBasis!=(ideal)(0xfbfbfbfbfbfbfbfb) ) && (this->gcBasis!=NULL) )
+ idDelete((ideal*)&this->gcBasis);
#elif SIZEOF_LONG!=8
- if(this->gcBasis!=(ideal)0xfbfbfbfb)
- idDelete((ideal *)&this->gcBasis);
+ if(this->gcBasis!=(ideal)0xfbfbfbfb)
+ idDelete((ideal *)&this->gcBasis);
#endif
#else
- if(this->gcBasis!=NULL)
- idDelete((ideal *)&this->gcBasis);
+ if(this->gcBasis!=NULL)
+ idDelete((ideal *)&this->gcBasis);
#endif
-// idDelete((ideal *)&this->gcBasis);
-// if(this->inputIdeal!=NULL)
-// idDelete((ideal *)&this->inputIdeal);
-// if (this->rootRing!=NULL && this->rootRing!=(ip_sring *)0xfefefefefefefefe)
-// rDelete(this->rootRing);
- if(this->UCN!=1 && this->baseRing!=NULL)
- rDelete(this->baseRing);
- facet *fAct;
- facet *fDel;
- /*Delete the facet structure*/
- fAct=this->facetPtr;
- fDel=fAct;
- while(fAct!=NULL)
- {
- fDel=fAct;
- fAct=fAct->next;
- delete fDel;
- }
- this->counter--;
- //should be deleted in noRevS
-// dd_FreeMatrix(this->ddFacets);
- //dd_FreeMatrix(this->ddFacets);
- for(int ii=0;ii<this->numRays;ii++)
- delete(gcRays[ii]);
- omFree(gcRays);
-}
+// idDelete((ideal *)&this->gcBasis);
+// if(this->inputIdeal!=NULL)
+// idDelete((ideal *)&this->inputIdeal);
+// if (this->rootRing!=NULL && this->rootRing!=(ip_sring *)0xfefefefefefefefe)
+// rDelete(this->rootRing);
+ if(this->UCN!=1 && this->baseRing!=NULL)
+ rDelete(this->baseRing);
+ facet *fAct;
+ facet *fDel;
+ /*Delete the facet structure*/
+ fAct=this->facetPtr;
+ fDel=fAct;
+ while(fAct!=NULL)
+ {
+ fDel=fAct;
+ fAct=fAct->next;
+ delete fDel;
+ }
+ this->counter--;
+ //should be deleted in noRevS
+// dd_FreeMatrix(this->ddFacets);
+ //dd_FreeMatrix(this->ddFacets);
+ for(int ii=0;ii<this->numRays;ii++)
+ delete(gcRays[ii]);
+ omFree(gcRays);
+}
/** Returns the number of cones existing at the time*/
inline int gcone::getCounter()
{
- return this->counter;
+ return this->counter;
}
-
+
/** \brief Set the interior point of a cone */
inline void gcone::setIntPoint(int64vec *iv)
{
- if(this->ivIntPt!=NULL)
- delete this->ivIntPt;
- this->ivIntPt=iv64Copy(iv);
+ if(this->ivIntPt!=NULL)
+ delete this->ivIntPt;
+ this->ivIntPt=iv64Copy(iv);
}
-
+
/** \brief Returns either a physical copy the interior point of a cone or just a reference to it.*/
inline int64vec *gcone::getIntPoint(bool shallow)
{
- if(shallow==TRUE)
- return this->ivIntPt;
- else
- return iv64Copy(this->ivIntPt);
+ if(shallow==TRUE)
+ return this->ivIntPt;
+ else
+ return iv64Copy(this->ivIntPt);
}
-
+
/** \brief Print the interior point */
inline void gcone::showIntPoint()
{
- ivIntPt->show();
+ ivIntPt->show();
}
-
+
/** \brief Print facets
* This is mainly for debugging purposes. Usually called from within gdb
*/
volatile void gcone::showFacets(const short codim)
{
#ifndef NDEBUG
- facet *f=this->facetPtr;
- facet *f2=NULL;
- if(codim==2)
- f2=this->facetPtr->codim2Ptr;
- while(f!=NULL)
- {
- int64vec *iv;
- iv = f->getFacetNormal();
- printf("(");iv->show(1,0);
- if(f->isFlippable==FALSE)
- printf(")* ");
- else
- printf(") ");
- delete iv;
- if(codim==2)
- {
- f2=f->codim2Ptr;
- while(f2!=NULL)
- {
- printf("[");f2->getFacetNormal()->show(1,0);printf("]");
- f2 = f2->next;
- }
- printf("\n");
- }
- f=f->next;
- }
- printf("\n");
+ facet *f=this->facetPtr;
+ facet *f2=NULL;
+ if(codim==2)
+ f2=this->facetPtr->codim2Ptr;
+ while(f!=NULL)
+ {
+ int64vec *iv;
+ iv = f->getFacetNormal();
+ printf("(");iv->show(1,0);
+ if(f->isFlippable==FALSE)
+ printf(")* ");
+ else
+ printf(") ");
+ delete iv;
+ if(codim==2)
+ {
+ f2=f->codim2Ptr;
+ while(f2!=NULL)
+ {
+ printf("[");f2->getFacetNormal()->show(1,0);printf("]");
+ f2 = f2->next;
+ }
+ printf("\n");
+ }
+ f=f->next;
+ }
+ printf("\n");
#endif
}
-
+
/** For debugging purposes only */
static volatile void showSLA(facet &f)
{
#ifndef NDEBUG
- facet *fAct;
- fAct = &f;
- if(fAct!=NULL)
- {
- facet *codim2Act;
- codim2Act = fAct->codim2Ptr;
-
- printf("\n");
- while(fAct!=NULL)
- {
- int64vec *fNormal;
- fNormal=fAct->getFacetNormal();
- printf("(");fNormal->show(1,0);
- if(fAct->isFlippable==TRUE)
- printf(") ");
- else
- printf(")* ");
- delete fNormal;
- codim2Act = fAct->codim2Ptr;
- printf(" Codim2: ");
- while(codim2Act!=NULL)
- {
- int64vec *f2Normal;
- f2Normal = codim2Act->getFacetNormal();
- printf("(");f2Normal->show(1,0);printf(") ");
- delete f2Normal;
- codim2Act = codim2Act->next;
- }
- printf("UCN = %i\n",fAct->getUCN());
- fAct = fAct->next;
- }
- }
+ facet *fAct;
+ fAct = &f;
+ if(fAct!=NULL)
+ {
+ facet *codim2Act;
+ codim2Act = fAct->codim2Ptr;
+
+ printf("\n");
+ while(fAct!=NULL)
+ {
+ int64vec *fNormal;
+ fNormal=fAct->getFacetNormal();
+ printf("(");fNormal->show(1,0);
+ if(fAct->isFlippable==TRUE)
+ printf(") ");
+ else
+ printf(")* ");
+ delete fNormal;
+ codim2Act = fAct->codim2Ptr;
+ printf(" Codim2: ");
+ while(codim2Act!=NULL)
+ {
+ int64vec *f2Normal;
+ f2Normal = codim2Act->getFacetNormal();
+ printf("(");f2Normal->show(1,0);printf(") ");
+ delete f2Normal;
+ codim2Act = codim2Act->next;
+ }
+ printf("UCN = %i\n",fAct->getUCN());
+ fAct = fAct->next;
+ }
+ }
#endif
}
-
+
static void idDebugPrint(const ideal &I)
{
#ifndef NDEBUG
- int numElts=IDELEMS(I);
- printf("Ideal with %i generators\n", numElts);
- printf("Leading terms: ");
- for (int ii=0;ii<numElts;ii++)
- {
- pWrite0(pHead(I->m[ii]));
- printf(",");
- }
- printf("\n");
+ int numElts=IDELEMS(I);
+ printf("Ideal with %i generators\n", numElts);
+ printf("Leading terms: ");
+ for (int ii=0;ii<numElts;ii++)
+ {
+ pWrite0(pHead(I->m[ii]));
+ printf(",");
+ }
+ printf("\n");
#endif
}
static void invPrint(const ideal &I)
{
-// int numElts=IDELEMS(I);
-// cout << "inv = ";
-// for(int ii=0;ii<numElts;ii++);
-// {
-// pWrite0(pHead(I->m[ii]));
-// cout << ",";
-// }
-// cout << endl;
+// int numElts=IDELEMS(I);
+// cout << "inv = ";
+// for(int ii=0;ii<numElts;ii++);
+// {
+// pWrite0(pHead(I->m[ii]));
+// cout << ",";
+// }
+// cout << endl;
}
static bool isMonomial(const ideal &I)
{
- bool res = TRUE;
- for(int ii=0;ii<IDELEMS(I);ii++)
- {
- if(pLength((poly)I->m[ii])>1)
- {
- res = FALSE;
- break;
- }
- }
- return res;
+ bool res = TRUE;
+ for(int ii=0;ii<IDELEMS(I);ii++)
+ {
+ if(pLength((poly)I->m[ii])>1)
+ {
+ res = FALSE;
+ break;
+ }
+ }
+ return res;
}
-
+
/** \brief Set gcone::numFacets */
inline void gcone::setNumFacets()
{
}
-
+
/** \brief Get gcone::numFacets */
inline int gcone::getNumFacets()
{
- return this->numFacets;
+ return this->numFacets;
}
-
+
inline int gcone::getUCN()
{
- if( this!=NULL)// && ( this!=(gcone * const)0xfbfbfbfbfbfbfbfb && this!=(gcone * const)0xfbfbfbfb ) )
- return this->UCN;
- else
- return -1;
+ if( this!=NULL)// && ( this!=(gcone * const)0xfbfbfbfbfbfbfbfb && this!=(gcone * const)0xfbfbfbfb ) )
+ return this->UCN;
+ else
+ return -1;
}
inline int gcone::getPredUCN()
{
- return this->pred;
+ return this->pred;
}
/** Returns a copy of the this->baseRing */
inline ring gcone::getBaseRing()
{
- return rCopy(this->baseRing);
+ return rCopy(this->baseRing);
}
inline void gcone::setBaseRing(ring r)
{
- this->baseRing=rCopy(r);
+ this->baseRing=rCopy(r);
}
inline ring gcone::getRef2BaseRing()
{
- return this->baseRing;
+ return this->baseRing;
}
/** \brief Compute the normals of the cone
@@ -768,395 +766,395 @@ inline ring gcone::getRef2BaseRing()
* This method computes a representation of the cone in terms of facet normals. It takes an ideal
* as its input. Redundancies are automatically removed using cddlib's dd_MatrixCanonicalize.
* Other methods for redundancy checkings might be implemented later. See Anders' diss p.44.
- * Note that in order to use cddlib a 0-th column has to be added to the matrix since cddlib expects
+ * Note that in order to use cddlib a 0-th column has to be added to the matrix since cddlib expects
* each row to represent an inequality of type const+x1+...+xn <= 0. While computing the normals we come across
* the set \f$ \partial\mathcal{G} \f$ which we might store for later use. C.f p71 of journal
* As a result of this procedure the pointer facetPtr points to the first facet of the cone.
*
* Optionally, if the parameter bool compIntPoint is set to TRUE the method will also compute
* an interior point of the cone.
- */
+ */
void gcone::getConeNormals(const ideal &I, bool compIntPoint)
{
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- poly aktpoly;
- int rows; // will contain the dimensions of the ineq matrix - deprecated by
- dd_rowrange ddrows;
- dd_colrange ddcols;
- dd_rowset ddredrows; // # of redundant rows in ddineq
- dd_rowset ddlinset; // the opposite
- dd_rowindex ddnewpos=NULL; // all to make dd_Canonicalize happy
- dd_NumberType ddnumb=dd_Integer; //Number type
- dd_ErrorType dderr=dd_NoError;
- //Compute the # inequalities i.e. rows of the matrix
- rows=0; //Initialization
- for (int ii=0;ii<IDELEMS(I);ii++)
- {
-// aktpoly=(poly)I->m[ii];
-// rows=rows+pLength(aktpoly)-1;
- rows=rows+pLength((poly)I->m[ii])-1;
- }
-
- dd_rowrange aktmatrixrow=0; // needed to store the diffs of the expvects in the rows of ddineq
- ddrows=rows;
- ddcols=this->numVars;
- dd_MatrixPtr ddineq; //Matrix to store the inequalities
- ddineq=dd_CreateMatrix(ddrows,ddcols+1); //The first col has to be 0 since cddlib checks for additive consts there
-
- // We loop through each g\in GB and compute the resulting inequalities
- for (int i=0; i<IDELEMS(I); i++)
- {
- aktpoly=(poly)I->m[i]; //get aktpoly as i-th component of I
- //simpler version of storing expvect diffs
- int *leadexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
- pGetExpV(aktpoly,leadexpv);
- poly pNextTerm=aktpoly;
- while(pNext(pNextTerm)/*pNext(aktpoly)*/!=NULL)
- {
- pNextTerm/*aktpoly*/=pNext(pNextTerm);
- int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
- pGetExpV(pNextTerm,tailexpv);
- for(int kk=1;kk<=this->numVars;kk++)
- {
- dd_set_si(ddineq->matrix[(dd_rowrange)aktmatrixrow][kk],leadexpv[kk]-tailexpv[kk]);
- }
- aktmatrixrow += 1;
- omFree(tailexpv);
- }
- omFree(leadexpv);
- } //for
+ poly aktpoly;
+ int rows; // will contain the dimensions of the ineq matrix - deprecated by
+ dd_rowrange ddrows;
+ dd_colrange ddcols;
+ dd_rowset ddredrows; // # of redundant rows in ddineq
+ dd_rowset ddlinset; // the opposite
+ dd_rowindex ddnewpos=NULL; // all to make dd_Canonicalize happy
+ dd_NumberType ddnumb=dd_Integer; //Number type
+ dd_ErrorType dderr=dd_NoError;
+ //Compute the # inequalities i.e. rows of the matrix
+ rows=0; //Initialization
+ for (int ii=0;ii<IDELEMS(I);ii++)
+ {
+// aktpoly=(poly)I->m[ii];
+// rows=rows+pLength(aktpoly)-1;
+ rows=rows+pLength((poly)I->m[ii])-1;
+ }
+
+ dd_rowrange aktmatrixrow=0; // needed to store the diffs of the expvects in the rows of ddineq
+ ddrows=rows;
+ ddcols=this->numVars;
+ dd_MatrixPtr ddineq; //Matrix to store the inequalities
+ ddineq=dd_CreateMatrix(ddrows,ddcols+1); //The first col has to be 0 since cddlib checks for additive consts there
+
+ // We loop through each g\in GB and compute the resulting inequalities
+ for (int i=0; i<IDELEMS(I); i++)
+ {
+ aktpoly=(poly)I->m[i]; //get aktpoly as i-th component of I
+ //simpler version of storing expvect diffs
+ int *leadexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
+ pGetExpV(aktpoly,leadexpv);
+ poly pNextTerm=aktpoly;
+ while(pNext(pNextTerm)/*pNext(aktpoly)*/!=NULL)
+ {
+ pNextTerm/*aktpoly*/=pNext(pNextTerm);
+ int *tailexpv=(int*)omAlloc(((this->numVars)+1)*sizeof(int));
+ pGetExpV(pNextTerm,tailexpv);
+ for(int kk=1;kk<=this->numVars;kk++)
+ {
+ dd_set_si(ddineq->matrix[(dd_rowrange)aktmatrixrow][kk],leadexpv[kk]-tailexpv[kk]);
+ }
+ aktmatrixrow += 1;
+ omFree(tailexpv);
+ }
+ omFree(leadexpv);
+ } //for
#if true
- /*Let's make the preprocessing here. This could already be done in the above for-loop,
- * but for a start it is more convenient here.
- * We check the necessary condition of FJT p.18
- * Quote: [...] every non-zero spoly should have at least one of its terms in inv(G)
- */
-// ideal initialForm=idInit(IDELEMS(I),1);
-// int64vec *gamma=new int64vec(this->numVars);
- int falseGammaCounter=0;
- int *redRowsArray=NULL;
- int num_alloc=0;
- int num_elts=0;
- for(int ii=0;ii<ddineq->rowsize;ii++)
- {
- ideal initialForm=idInit(IDELEMS(I),I->rank);
- //read row ii into gamma
-// int64 tmp;
- int64vec *gamma=new int64vec(this->numVars);
- for(int jj=1;jj<=this->numVars;jj++)
- {
- int64 tmp;
- tmp=(int64)mpq_get_d(ddineq->matrix[ii][jj]);
- (*gamma)[jj-1]=(int64)tmp;
- }
- computeInv((ideal&)I,initialForm,*gamma);
- delete gamma;
- //Create leading ideal
- ideal L=idInit(IDELEMS(initialForm),1);
- for(int jj=0;jj<IDELEMS(initialForm);jj++)
- {
- poly p=pHead(initialForm->m[jj]);
- L->m[jj]=pCopy(/*pHead(initialForm->m[jj]))*/p);
- pDelete(&p);
- }
-
- LObject *P = new sLObject();//TODO What's the difference between sLObject and LObject?
- memset(P,0,sizeof(LObject));
-
- for(int jj=0;jj<=IDELEMS(initialForm)-2;jj++)
- {
- bool isMaybeFacet=FALSE;
- P->p1=initialForm->m[jj]; //build spolys of initialForm in_v
-
- for(int kk=jj+1;kk<=IDELEMS(initialForm)-1;kk++)
- {
- P->p2=initialForm->m[kk];
- ksCreateSpoly(P);
- if(P->p!=NULL) //spoly non zero=?
- {
- poly p;//NOTE Don't use pInit here. Evil memleak will follow
- poly q;
- poly pDel,qDel;
- p=pCopy(P->p);
- q=pHead(p); //Monomial q
- pDelete(&q);
- pDel=p; qDel=q;
- isMaybeFacet=FALSE;
- //TODO: Suffices to check LTs here
- while(p!=NULL)
- {
- q=pHead(p);
- for(int ll=0;ll<IDELEMS(L);ll++)
- {
- if(pLmEqual(L->m[ll],q) || pDivisibleBy(L->m[ll],q))
- {
- isMaybeFacet=TRUE;
- break;//for
- }
- }
- pDelete(&q);
- if(isMaybeFacet==TRUE)
- {
- break;//while(p!=NULL)
- }
- p=pNext(p);
- }//while
-// pDelete(&p);//NOTE Better to use pDel and qDel. Commenting in this line will not work!
- if(q!=NULL) pDelete(&q);
- pDelete(&pDel);
- pDelete(&qDel);
- if(isMaybeFacet==FALSE)
- {
- dd_set_si(ddineq->matrix[ii][0],1);
-// if(num_alloc==0)
-// num_alloc += 1;
-// else
-// num_alloc += 1;
- if(num_alloc==num_elts) num_alloc==0 ? num_alloc=1 : num_alloc*=2;
-
- void *tmp = realloc(redRowsArray,(num_alloc*sizeof(int)));
- if(!tmp)
- {
- WerrorS("Woah dude! Couldn't realloc memory\n");
- exit(-1);
- }
- redRowsArray = (int*)tmp;
- redRowsArray[num_elts]=ii;
- num_elts++;
- //break;//for(int kk, since we have found one that is not in L
- goto _start; //mea culpa, mea culpa, mea maxima culpa
- }
- }//if(P->p!=NULL)
- pDelete(&(P->p));
- }//for k
- }//for jj
- _start:;
- idDelete(&L);
- delete P;
- idDelete(&initialForm);
- }//for(ii<ddineq-rowsize
-// delete gamma;
- int offset=0;//needed for correction of redRowsArray[ii]
+ /*Let's make the preprocessing here. This could already be done in the above for-loop,
+ * but for a start it is more convenient here.
+ * We check the necessary condition of FJT p.18
+ * Quote: [...] every non-zero spoly should have at least one of its terms in inv(G)
+ */
+// ideal initialForm=idInit(IDELEMS(I),1);
+// int64vec *gamma=new int64vec(this->numVars);
+ int falseGammaCounter=0;
+ int *redRowsArray=NULL;
+ int num_alloc=0;
+ int num_elts=0;
+ for(int ii=0;ii<ddineq->rowsize;ii++)
+ {
+ ideal initialForm=idInit(IDELEMS(I),I->rank);
+ //read row ii into gamma
+// int64 tmp;
+ int64vec *gamma=new int64vec(this->numVars);
+ for(int jj=1;jj<=this->numVars;jj++)
+ {
+ int64 tmp;
+ tmp=(int64)mpq_get_d(ddineq->matrix[ii][jj]);
+ (*gamma)[jj-1]=(int64)tmp;
+ }
+ computeInv((ideal&)I,initialForm,*gamma);
+ delete gamma;
+ //Create leading ideal
+ ideal L=idInit(IDELEMS(initialForm),1);
+ for(int jj=0;jj<IDELEMS(initialForm);jj++)
+ {
+ poly p=pHead(initialForm->m[jj]);
+ L->m[jj]=pCopy(/*pHead(initialForm->m[jj]))*/p);
+ pDelete(&p);
+ }
+
+ LObject *P = new sLObject();//TODO What's the difference between sLObject and LObject?
+ memset(P,0,sizeof(LObject));
+
+ for(int jj=0;jj<=IDELEMS(initialForm)-2;jj++)
+ {
+ bool isMaybeFacet=FALSE;
+ P->p1=initialForm->m[jj]; //build spolys of initialForm in_v
+
+ for(int kk=jj+1;kk<=IDELEMS(initialForm)-1;kk++)
+ {
+ P->p2=initialForm->m[kk];
+ ksCreateSpoly(P);
+ if(P->p!=NULL) //spoly non zero=?
+ {
+ poly p;//NOTE Don't use pInit here. Evil memleak will follow
+ poly q;
+ poly pDel,qDel;
+ p=pCopy(P->p);
+ q=pHead(p); //Monomial q
+ pDelete(&q);
+ pDel=p; qDel=q;
+ isMaybeFacet=FALSE;
+ //TODO: Suffices to check LTs here
+ while(p!=NULL)
+ {
+ q=pHead(p);
+ for(int ll=0;ll<IDELEMS(L);ll++)
+ {
+ if(pLmEqual(L->m[ll],q) || pDivisibleBy(L->m[ll],q))
+ {
+ isMaybeFacet=TRUE;
+ break;//for
+ }
+ }
+ pDelete(&q);
+ if(isMaybeFacet==TRUE)
+ {
+ break;//while(p!=NULL)
+ }
+ p=pNext(p);
+ }//while
+// pDelete(&p);//NOTE Better to use pDel and qDel. Commenting in this line will not work!
+ if(q!=NULL) pDelete(&q);
+ pDelete(&pDel);
+ pDelete(&qDel);
+ if(isMaybeFacet==FALSE)
+ {
+ dd_set_si(ddineq->matrix[ii][0],1);
+// if(num_alloc==0)
+// num_alloc += 1;
+// else
+// num_alloc += 1;
+ if(num_alloc==num_elts) num_alloc==0 ? num_alloc=1 : num_alloc*=2;
+
+ void *tmp = realloc(redRowsArray,(num_alloc*sizeof(int)));
+ if(!tmp)
+ {
+ WerrorS("Woah dude! Couldn't realloc memory\n");
+ exit(-1);
+ }
+ redRowsArray = (int*)tmp;
+ redRowsArray[num_elts]=ii;
+ num_elts++;
+ //break;//for(int kk, since we have found one that is not in L
+ goto _start; //mea culpa, mea culpa, mea maxima culpa
+ }
+ }//if(P->p!=NULL)
+ pDelete(&(P->p));
+ }//for k
+ }//for jj
+ _start:;
+ idDelete(&L);
+ delete P;
+ idDelete(&initialForm);
+ }//for(ii<ddineq-rowsize
+// delete gamma;
+ int offset=0;//needed for correction of redRowsArray[ii]
#ifndef NDEBUG
- printf("Removed %i of %i in preprocessing step\n",num_elts,ddineq->rowsize);
+ printf("Removed %i of %i in preprocessing step\n",num_elts,ddineq->rowsize);
#endif
- for( int ii=0;ii<num_elts;ii++ )
- {
- dd_MatrixRowRemove(&ddineq,redRowsArray[ii]+1-offset);//cddlib sucks at enumeration
- offset++;
- }
- free(redRowsArray);//NOTE May crash on some machines.
- /*And now for the strictly positive rows
- * Doesn't gain significant speedup
- */
- /*int *posRowsArray=NULL;
- num_alloc=0;
- num_elts=0;
- for(int ii=0;ii<ddineq->rowsize;ii++)
- {
- int64vec *ivPos = new int64vec(this->numVars);
- for(int jj=0;jj<this->numVars;jj++)
- (*ivPos)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
- bool isStrictlyPos=FALSE;
- int posCtr=0;
- for(int jj=0;jj<this->numVars;jj++)
- {
- int64vec *ivCanonical = new int64vec(this->numVars);
- jj==0 ? (*ivCanonical)[ivPos->length()-1]=1 : (*ivCanonical)[jj-1]=1;
- if(dotProduct(*ivCanonical,*ivPos)!=0)
- {
- if ((*ivPos)[jj]>=0)
- {
- posCtr++;
- }
- }
- delete ivCanonical;
- }
- if(posCtr==ivPos->length())
- isStrictlyPos=TRUE;
- if(isStrictlyPos==TRUE)
- {
- if(num_alloc==0)
- num_alloc += 1;
- else
- num_alloc += 1;
- void *tmp = realloc(posRowsArray,(num_alloc*sizeof(int)));
- if(!tmp)
- {
- WerrorS("Woah dude! Couldn't realloc memory\n");
- exit(-1);
- }
- posRowsArray = (int*)tmp;
- posRowsArray[num_elts]=ii;
- num_elts++;
- }
- delete ivPos;
- }
- offset=0;
- for(int ii=0;ii<num_elts;ii++)
- {
- dd_MatrixRowRemove(&ddineq,posRowsArray[ii]+1-offset);
- offset++;
- }
- free(posRowsArray);*/
+ for( int ii=0;ii<num_elts;ii++ )
+ {
+ dd_MatrixRowRemove(&ddineq,redRowsArray[ii]+1-offset);//cddlib sucks at enumeration
+ offset++;
+ }
+ free(redRowsArray);//NOTE May crash on some machines.
+ /*And now for the strictly positive rows
+ * Doesn't gain significant speedup
+ */
+ /*int *posRowsArray=NULL;
+ num_alloc=0;
+ num_elts=0;
+ for(int ii=0;ii<ddineq->rowsize;ii++)
+ {
+ int64vec *ivPos = new int64vec(this->numVars);
+ for(int jj=0;jj<this->numVars;jj++)
+ (*ivPos)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
+ bool isStrictlyPos=FALSE;
+ int posCtr=0;
+ for(int jj=0;jj<this->numVars;jj++)
+ {
+ int64vec *ivCanonical = new int64vec(this->numVars);
+ jj==0 ? (*ivCanonical)[ivPos->length()-1]=1 : (*ivCanonical)[jj-1]=1;
+ if(dotProduct(*ivCanonical,*ivPos)!=0)
+ {
+ if ((*ivPos)[jj]>=0)
+ {
+ posCtr++;
+ }
+ }
+ delete ivCanonical;
+ }
+ if(posCtr==ivPos->length())
+ isStrictlyPos=TRUE;
+ if(isStrictlyPos==TRUE)
+ {
+ if(num_alloc==0)
+ num_alloc += 1;
+ else
+ num_alloc += 1;
+ void *tmp = realloc(posRowsArray,(num_alloc*sizeof(int)));
+ if(!tmp)
+ {
+ WerrorS("Woah dude! Couldn't realloc memory\n");
+ exit(-1);
+ }
+ posRowsArray = (int*)tmp;
+ posRowsArray[num_elts]=ii;
+ num_elts++;
+ }
+ delete ivPos;
+ }
+ offset=0;
+ for(int ii=0;ii<num_elts;ii++)
+ {
+ dd_MatrixRowRemove(&ddineq,posRowsArray[ii]+1-offset);
+ offset++;
+ }
+ free(posRowsArray);*/
#endif
- dd_MatrixCanonicalize(&ddineq, &ddlinset, &ddredrows, &ddnewpos, &dderr);
- ddrows = ddineq->rowsize; //Size of the matrix with redundancies removed
- ddcols = ddineq->colsize;
-
- this->ddFacets = dd_CopyMatrix(ddineq);
-
- /*Write the normals into class facet*/
- facet *fAct; //pointer to active facet
- int numNonFlip=0;
- for (int kk = 0; kk<ddrows; kk++)
- {
- int64 ggT=1;//NOTE Why does (int)mpq_get_d(ddineq->matrix[kk][1]) not work?
- int64vec *load = new int64vec(this->numVars);//int64vec to store a single facet normal that will then be stored via setFacetNormal
- for (int jj = 1; jj <ddcols; jj++)
- {
- int64 val;
- val = (int64)mpq_get_d(ddineq->matrix[kk][jj]);
- (*load)[jj-1] = val; //store typecasted entry at pos jj-1 of load
- ggT = int64gcd(ggT,/*(int64&)foo*/val);
- }//for (int jj = 1; jj <ddcols; jj++)
- if(ggT>1)
- {
- for(int ll=0;ll<this->numVars;ll++)
- (*load)[ll] /= ggT;//make primitive vector
- }
- /*Quick'n'dirty hack for flippability. Executed only if gcone::hasHomInput==FALSE
- * Otherwise every facet intersects the positive orthant
- */
- if(gcone::hasHomInput==FALSE)
- {
- //TODO: No dP needed
- bool isFlip=FALSE;
- for(int jj = 0; jj<load->length(); jj++)
- {
-// int64vec *ivCanonical = new int64vec(load->length());
-// (*ivCanonical)[jj]=1;
-// if (dotProduct(*load,*ivCanonical)<0)
-// {
-// isFlip=TRUE;
-// break; //URGHS
-// }
-// delete ivCanonical;
- if((*load)[jj]<0)
- {
- isFlip=TRUE;
- break;
- }
- }/*End of check for flippability*/
-// if(iv64isStrictlyPositive(load))
-// isFlip=TRUE;
- if(isFlip==FALSE)
- {
- this->numFacets++;
- numNonFlip++;
- if(this->numFacets==1)
- {
- facet *fRoot = new facet();
- this->facetPtr = fRoot;
- fAct = fRoot;
- }
- else
- {
- fAct->next = new facet();
- fAct = fAct->next;
- }
- fAct->isFlippable=FALSE;
- fAct->setFacetNormal(load);
- fAct->setUCN(this->getUCN());
+ dd_MatrixCanonicalize(&ddineq, &ddlinset, &ddredrows, &ddnewpos, &dderr);
+ ddrows = ddineq->rowsize; //Size of the matrix with redundancies removed
+ ddcols = ddineq->colsize;
+
+ this->ddFacets = dd_CopyMatrix(ddineq);
+
+ /*Write the normals into class facet*/
+ facet *fAct; //pointer to active facet
+ int numNonFlip=0;
+ for (int kk = 0; kk<ddrows; kk++)
+ {
+ int64 ggT=1;//NOTE Why does (int)mpq_get_d(ddineq->matrix[kk][1]) not work?
+ int64vec *load = new int64vec(this->numVars);//int64vec to store a single facet normal that will then be stored via setFacetNormal
+ for (int jj = 1; jj <ddcols; jj++)
+ {
+ int64 val;
+ val = (int64)mpq_get_d(ddineq->matrix[kk][jj]);
+ (*load)[jj-1] = val; //store typecasted entry at pos jj-1 of load
+ ggT = int64gcd(ggT,/*(int64&)foo*/val);
+ }//for (int jj = 1; jj <ddcols; jj++)
+ if(ggT>1)
+ {
+ for(int ll=0;ll<this->numVars;ll++)
+ (*load)[ll] /= ggT;//make primitive vector
+ }
+ /*Quick'n'dirty hack for flippability. Executed only if gcone::hasHomInput==FALSE
+ * Otherwise every facet intersects the positive orthant
+ */
+ if(gcone::hasHomInput==FALSE)
+ {
+ //TODO: No dP needed
+ bool isFlip=FALSE;
+ for(int jj = 0; jj<load->length(); jj++)
+ {
+// int64vec *ivCanonical = new int64vec(load->length());
+// (*ivCanonical)[jj]=1;
+// if (dotProduct(*load,*ivCanonical)<0)
+// {
+// isFlip=TRUE;
+// break; //URGHS
+// }
+// delete ivCanonical;
+ if((*load)[jj]<0)
+ {
+ isFlip=TRUE;
+ break;
+ }
+ }/*End of check for flippability*/
+// if(iv64isStrictlyPositive(load))
+// isFlip=TRUE;
+ if(isFlip==FALSE)
+ {
+ this->numFacets++;
+ numNonFlip++;
+ if(this->numFacets==1)
+ {
+ facet *fRoot = new facet();
+ this->facetPtr = fRoot;
+ fAct = fRoot;
+ }
+ else
+ {
+ fAct->next = new facet();
+ fAct = fAct->next;
+ }
+ fAct->isFlippable=FALSE;
+ fAct->setFacetNormal(load);
+ fAct->setUCN(this->getUCN());
#ifndef NDEBUG
- printf("Marking facet (");load->show(1,0);printf(") as non flippable\n");
+ printf("Marking facet (");load->show(1,0);printf(") as non flippable\n");
#endif
- }
- else
- {
- this->numFacets++;
- if(this->numFacets==1)
- {
- facet *fRoot = new facet();
- this->facetPtr = fRoot;
- fAct = fRoot;
- }
- else
- {
- fAct->next = new facet();
- fAct = fAct->next;
- }
- fAct->isFlippable=TRUE;
- fAct->setFacetNormal(load);
- fAct->setUCN(this->getUCN());
- }
- }//hasHomInput==FALSE
- else //Every facet is flippable
- { /*Now load should be full and we can call setFacetNormal*/
- this->numFacets++;
- if(this->numFacets==1)
- {
- facet *fRoot = new facet();
- this->facetPtr = fRoot;
- fAct = fRoot;
- }
- else
- {
- fAct->next = new facet();
- fAct = fAct->next;
- }
- fAct->isFlippable=TRUE;
- fAct->setFacetNormal(load);
- fAct->setUCN(this->getUCN());
- }//if (isFlippable==FALSE)
- delete load;
- }//for (int kk = 0; kk<ddrows; kk++)
-
- //In cases like I=<x-1,y-1> there are only non-flippable facets...
- if(numNonFlip==this->numFacets)
- {
- WerrorS ("Only non-flippable facets. Terminating...\n");
-// exit(-1);//Bit harsh maybe...
- }
-
- /*
- Now we should have a linked list containing the facet normals of those facets that are
- -irredundant
- -flipable
- Adressing is done via *facetPtr
- */
- if (compIntPoint==TRUE)
- {
- int64vec *iv = new int64vec(this->numVars);
- dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
- int jj=1;
- for (int ii=0;ii<=this->numVars;ii++)
- {
- dd_set_si(posRestr->matrix[ii][jj],1);
- jj++;
- }
- dd_MatrixAppendTo(&ddineq,posRestr);
- interiorPoint(ddineq, *iv); //NOTE ddineq contains non-flippable facets
- this->setIntPoint(iv); //stores the interior point in gcone::ivIntPt
- delete iv;
- dd_FreeMatrix(posRestr);
- }
- //Clean up but don't delete the return value!
- //dd_FreeMatrix(ddineq);
- set_free(ddredrows);//check
- set_free(ddlinset);//check
- //free(ddnewpos);//<-- NOTE Here the crash occurs omAlloc issue?
+ }
+ else
+ {
+ this->numFacets++;
+ if(this->numFacets==1)
+ {
+ facet *fRoot = new facet();
+ this->facetPtr = fRoot;
+ fAct = fRoot;
+ }
+ else
+ {
+ fAct->next = new facet();
+ fAct = fAct->next;
+ }
+ fAct->isFlippable=TRUE;
+ fAct->setFacetNormal(load);
+ fAct->setUCN(this->getUCN());
+ }
+ }//hasHomInput==FALSE
+ else //Every facet is flippable
+ { /*Now load should be full and we can call setFacetNormal*/
+ this->numFacets++;
+ if(this->numFacets==1)
+ {
+ facet *fRoot = new facet();
+ this->facetPtr = fRoot;
+ fAct = fRoot;
+ }
+ else
+ {
+ fAct->next = new facet();
+ fAct = fAct->next;
+ }
+ fAct->isFlippable=TRUE;
+ fAct->setFacetNormal(load);
+ fAct->setUCN(this->getUCN());
+ }//if (isFlippable==FALSE)
+ delete load;
+ }//for (int kk = 0; kk<ddrows; kk++)
+
+ //In cases like I=<x-1,y-1> there are only non-flippable facets...
+ if(numNonFlip==this->numFacets)
+ {
+ WerrorS ("Only non-flippable facets. Terminating...\n");
+// exit(-1);//Bit harsh maybe...
+ }
+
+ /*
+ Now we should have a linked list containing the facet normals of those facets that are
+ -irredundant
+ -flipable
+ Adressing is done via *facetPtr
+ */
+ if (compIntPoint==TRUE)
+ {
+ int64vec *iv = new int64vec(this->numVars);
+ dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
+ int jj=1;
+ for (int ii=0;ii<=this->numVars;ii++)
+ {
+ dd_set_si(posRestr->matrix[ii][jj],1);
+ jj++;
+ }
+ dd_MatrixAppendTo(&ddineq,posRestr);
+ interiorPoint(ddineq, *iv); //NOTE ddineq contains non-flippable facets
+ this->setIntPoint(iv); //stores the interior point in gcone::ivIntPt
+ delete iv;
+ dd_FreeMatrix(posRestr);
+ }
+ //Clean up but don't delete the return value!
+ //dd_FreeMatrix(ddineq);
+ set_free(ddredrows);//check
+ set_free(ddlinset);//check
+ //free(ddnewpos);//<-- NOTE Here the crash occurs omAlloc issue?
#ifdef gfanp
- gettimeofday(&end, 0);
- time_getConeNormals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+ gettimeofday(&end, 0);
+ time_getConeNormals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
#endif
}//gcone::getConeNormals(ideal I)
-
+
/** \brief Compute the (codim-2)-facets of a given cone
* This method is used during noRevS
* Additionally we check whether the codim2-facet normal is strictly positive. Otherwise
@@ -1165,156 +1163,156 @@ void gcone::getConeNormals(const ideal &I, bool compIntPoint)
void gcone::getCodim2Normals(const gcone &gc)
{
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- //this->facetPtr->codim2Ptr = new facet(2); //instantiate a (codim-2)-facet
- facet *fAct;
- fAct = this->facetPtr;
- facet *codim2Act;
- //codim2Act = this->facetPtr->codim2Ptr;
- dd_MatrixPtr ddineq;//,P,ddakt;
- dd_ErrorType err;
- //ddineq = facets2Matrix(gc); //get a matrix representation of the cone
- ddineq = dd_CopyMatrix(gc.ddFacets);
- /*Now set appropriate linearity*/
- for (int ii=0; ii<this->numFacets; ii++)
- {
- dd_rowset impl_linset, redset;
- dd_rowindex newpos;
- dd_MatrixPtr ddakt;
- ddakt = dd_CopyMatrix(ddineq);
-// ddakt->representation=dd_Inequality; //Not using this makes it faster. But why does the quick check below still work?
-// ddakt->representation=dd_Generator;
- set_addelem(ddakt->linset,ii+1);/*Now set appropriate linearity*/
+ //this->facetPtr->codim2Ptr = new facet(2); //instantiate a (codim-2)-facet
+ facet *fAct;
+ fAct = this->facetPtr;
+ facet *codim2Act;
+ //codim2Act = this->facetPtr->codim2Ptr;
+ dd_MatrixPtr ddineq;//,P,ddakt;
+ dd_ErrorType err;
+ //ddineq = facets2Matrix(gc); //get a matrix representation of the cone
+ ddineq = dd_CopyMatrix(gc.ddFacets);
+ /*Now set appropriate linearity*/
+ for (int ii=0; ii<this->numFacets; ii++)
+ {
+ dd_rowset impl_linset, redset;
+ dd_rowindex newpos;
+ dd_MatrixPtr ddakt;
+ ddakt = dd_CopyMatrix(ddineq);
+// ddakt->representation=dd_Inequality; //Not using this makes it faster. But why does the quick check below still work?
+// ddakt->representation=dd_Generator;
+ set_addelem(ddakt->linset,ii+1);/*Now set appropriate linearity*/
#ifdef gfanp
- timeval t_ddMC_start, t_ddMC_end;
- gettimeofday(&t_ddMC_start,0);
-#endif
- //dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err);
- dd_PolyhedraPtr ddpolyh;
- ddpolyh=dd_DDMatrix2Poly(ddakt, &err);
-// ddpolyh=dd_DDMatrix2Poly2(ddakt, dd_MaxCutoff, &err);
- dd_MatrixPtr P;
- P=dd_CopyGenerators(ddpolyh);
- dd_FreePolyhedra(ddpolyh);
- //TODO Call for one cone , normalize - check equalities - plus lineality -done
+ timeval t_ddMC_start, t_ddMC_end;
+ gettimeofday(&t_ddMC_start,0);
+#endif
+ //dd_MatrixCanonicalize(&ddakt, &impl_linset, &redset, &newpos, &err);
+ dd_PolyhedraPtr ddpolyh;
+ ddpolyh=dd_DDMatrix2Poly(ddakt, &err);
+// ddpolyh=dd_DDMatrix2Poly2(ddakt, dd_MaxCutoff, &err);
+ dd_MatrixPtr P;
+ P=dd_CopyGenerators(ddpolyh);
+ dd_FreePolyhedra(ddpolyh);
+ //TODO Call for one cone , normalize - check equalities - plus lineality -done
#ifdef gfanp
- gettimeofday(&t_ddMC_end,0);
- t_ddMC += (t_ddMC_end.tv_sec - t_ddMC_start.tv_sec + 1e-6*(t_ddMC_end.tv_usec - t_ddMC_start.tv_usec));
-#endif
- /* We loop through each row of P normalize it by making all
- * entries integer ones and add the resulting vector to the
- * int matrix facet::codim2Facets */
- for (int jj=1;jj<=/*ddakt*/P->rowsize;jj++)
- {
- fAct->numCodim2Facets++;
- if(fAct->numCodim2Facets==1)
- {
- fAct->codim2Ptr = new facet(2);
- codim2Act = fAct->codim2Ptr;
- }
- else
- {
- codim2Act->next = new facet(2);
- codim2Act = codim2Act->next;
- }
- int64vec *n = new int64vec(this->numVars);
+ gettimeofday(&t_ddMC_end,0);
+ t_ddMC += (t_ddMC_end.tv_sec - t_ddMC_start.tv_sec + 1e-6*(t_ddMC_end.tv_usec - t_ddMC_start.tv_usec));
+#endif
+ /* We loop through each row of P normalize it by making all
+ * entries integer ones and add the resulting vector to the
+ * int matrix facet::codim2Facets */
+ for (int jj=1;jj<=/*ddakt*/P->rowsize;jj++)
+ {
+ fAct->numCodim2Facets++;
+ if(fAct->numCodim2Facets==1)
+ {
+ fAct->codim2Ptr = new facet(2);
+ codim2Act = fAct->codim2Ptr;
+ }
+ else
+ {
+ codim2Act->next = new facet(2);
+ codim2Act = codim2Act->next;
+ }
+ int64vec *n = new int64vec(this->numVars);
#ifdef gfanp
- timeval t_mI_start, t_mI_end;
- gettimeofday(&t_mI_start,0);
+ timeval t_mI_start, t_mI_end;
+ gettimeofday(&t_mI_start,0);
#endif
- makeInt(P,jj,*n);
- /*for(int kk=0;kk<this->numVars;kk++)
- {
- int foo;
- foo = (int)mpq_get_d(ddakt->matrix[ii][kk+1]);
- (*n)[kk]=foo;
- }*/
+ makeInt(P,jj,*n);
+ /*for(int kk=0;kk<this->numVars;kk++)
+ {
+ int foo;
+ foo = (int)mpq_get_d(ddakt->matrix[ii][kk+1]);
+ (*n)[kk]=foo;
+ }*/
#ifdef gfanp
- gettimeofday(&t_mI_end,0);
- t_mI += (t_mI_end.tv_sec - t_mI_start.tv_sec + 1e-6*(t_mI_end.tv_usec - t_mI_start.tv_usec));
+ gettimeofday(&t_mI_end,0);
+ t_mI += (t_mI_end.tv_sec - t_mI_start.tv_sec + 1e-6*(t_mI_end.tv_usec - t_mI_start.tv_usec));
#endif
- codim2Act->setFacetNormal(n);
- delete n;
- }
- /*We check whether the facet spanned by the codim-2 facets
- * intersects with the positive orthant. Otherwise we define this
- * facet to be non-flippable. Works since we set the appropriate
- * linearity for ddakt above.
- */
- //TODO It might be faster to compute jus the implied equations instead of a relative interior point
-// int64vec *iv_intPoint = new int64vec(this->numVars);
-// dd_MatrixPtr shiftMatrix;
-// dd_MatrixPtr intPointMatrix;
-// shiftMatrix = dd_CreateMatrix(this->numVars,this->numVars+1);
-// for(int kk=0;kk<this->numVars;kk++)
-// {
-// dd_set_si(shiftMatrix->matrix[kk][0],1);
-// dd_set_si(shiftMatrix->matrix[kk][kk+1],1);
-// }
-// intPointMatrix=dd_MatrixAppend(ddakt,shiftMatrix);
+ codim2Act->setFacetNormal(n);
+ delete n;
+ }
+ /*We check whether the facet spanned by the codim-2 facets
+ * intersects with the positive orthant. Otherwise we define this
+ * facet to be non-flippable. Works since we set the appropriate
+ * linearity for ddakt above.
+ */
+ //TODO It might be faster to compute jus the implied equations instead of a relative interior point
+// int64vec *iv_intPoint = new int64vec(this->numVars);
+// dd_MatrixPtr shiftMatrix;
+// dd_MatrixPtr intPointMatrix;
+// shiftMatrix = dd_CreateMatrix(this->numVars,this->numVars+1);
+// for(int kk=0;kk<this->numVars;kk++)
+// {
+// dd_set_si(shiftMatrix->matrix[kk][0],1);
+// dd_set_si(shiftMatrix->matrix[kk][kk+1],1);
+// }
+// intPointMatrix=dd_MatrixAppend(ddakt,shiftMatrix);
// #ifdef gfanp
-// timeval t_iP_start, t_iP_end;
-// gettimeofday(&t_iP_start, 0);
-// #endif
-// interiorPoint(intPointMatrix,*iv_intPoint);
-// // dd_rowset impl_linste,lbasis;
-// // dd_LPSolutionPtr lps=NULL;
-// // dd_ErrorType err;
-// // dd_FindRelativeInterior(intPointMatrix, &impl_linset, &lbasis, &lps, &err);
+// timeval t_iP_start, t_iP_end;
+// gettimeofday(&t_iP_start, 0);
+// #endif
+// interiorPoint(intPointMatrix,*iv_intPoint);
+// // dd_rowset impl_linste,lbasis;
+// // dd_LPSolutionPtr lps=NULL;
+// // dd_ErrorType err;
+// // dd_FindRelativeInterior(intPointMatrix, &impl_linset, &lbasis, &lps, &err);
// #ifdef gfanp
-// gettimeofday(&t_iP_end, 0);
-// t_iP += (t_iP_end.tv_sec - t_iP_start.tv_sec + 1e-6*(t_iP_end.tv_usec - t_iP_start.tv_usec));
+// gettimeofday(&t_iP_end, 0);
+// t_iP += (t_iP_end.tv_sec - t_iP_start.tv_sec + 1e-6*(t_iP_end.tv_usec - t_iP_start.tv_usec));
// #endif
-// for(int ll=0;ll<this->numVars;ll++)
-// {
-// if( (*iv_intPoint)[ll] < 0 )
-// {
-// fAct->isFlippable=FALSE;
-// break;
-// }
-// }
- /*End of check*/
- /*This test should be way less time consuming*/
+// for(int ll=0;ll<this->numVars;ll++)
+// {
+// if( (*iv_intPoint)[ll] < 0 )
+// {
+// fAct->isFlippable=FALSE;
+// break;
+// }
+// }
+ /*End of check*/
+ /*This test should be way less time consuming*/
#ifdef gfanp
- timeval t_iP_start, t_iP_end;
- gettimeofday(&t_iP_start, 0);
+ timeval t_iP_start, t_iP_end;
+ gettimeofday(&t_iP_start, 0);
#endif
- bool containsStrictlyPosRay=TRUE;
- for(int ii=0;ii<ddakt->rowsize;ii++)
- {
- containsStrictlyPosRay=TRUE;
- for(int jj=1;jj<this->numVars;jj++)
- {
- if(ddakt->matrix[ii][jj]<=0)
- {
- containsStrictlyPosRay=FALSE;
- break;
- }
- }
- if(containsStrictlyPosRay==TRUE)
- break;
- }
- if(containsStrictlyPosRay==FALSE)
- //TODO Not sufficient. Intersect with pos orthant for pos int
- fAct->isFlippable=FALSE;
+ bool containsStrictlyPosRay=TRUE;
+ for(int ii=0;ii<ddakt->rowsize;ii++)
+ {
+ containsStrictlyPosRay=TRUE;
+ for(int jj=1;jj<this->numVars;jj++)
+ {
+ if(ddakt->matrix[ii][jj]<=0)
+ {
+ containsStrictlyPosRay=FALSE;
+ break;
+ }
+ }
+ if(containsStrictlyPosRay==TRUE)
+ break;
+ }
+ if(containsStrictlyPosRay==FALSE)
+ //TODO Not sufficient. Intersect with pos orthant for pos int
+ fAct->isFlippable=FALSE;
#ifdef gfanp
- gettimeofday(&t_iP_end, 0);
- t_iP += (t_iP_end.tv_sec - t_iP_start.tv_sec + 1e-6*(t_iP_end.tv_usec - t_iP_start.tv_usec));
+ gettimeofday(&t_iP_end, 0);
+ t_iP += (t_iP_end.tv_sec - t_iP_start.tv_sec + 1e-6*(t_iP_end.tv_usec - t_iP_start.tv_usec));
#endif
- /**/
- fAct = fAct->next;
- dd_FreeMatrix(ddakt);
- dd_FreeMatrix(P);
- }//for
- dd_FreeMatrix(ddineq);
+ /**/
+ fAct = fAct->next;
+ dd_FreeMatrix(ddakt);
+ dd_FreeMatrix(P);
+ }//for
+ dd_FreeMatrix(ddineq);
#ifdef gfanp
- gettimeofday(&end, 0);
- time_getCodim2Normals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+ gettimeofday(&end, 0);
+ time_getCodim2Normals += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
#endif
}
-
+
/** Really extremal rays this time ;)
* Extremal rays are unique modulo the homogeneity space.
* Therefore we dd_MatrixAppend gc->ddFacets and gcone::dd_LinealitySpace
@@ -1322,279 +1320,279 @@ void gcone::getCodim2Normals(const gcone &gc)
* Figuring out whether a ray belongs to a given facet(normal) is done by
* checking whether the inner product of the ray with the normal is zero.
* We use ivAdd here which returns a new int64vec. Therefore we need to avoid
-* a memory leak which would be cause by the line
+* a memory leak which would be cause by the line
* iv=ivAdd(iv,b)
-* So we keep pointer tmp to iv and delete(tmp), so there should not occur a
+* So we keep pointer tmp to iv and delete(tmp), so there should not occur a
* memleak
* TODO normalization
*/
void gcone::getExtremalRays(const gcone &gc)
{
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
- timeval poly_start, poly_end;
- gettimeofday(&poly_start,0);
+ timeval start, end;
+ gettimeofday(&start, 0);
+ timeval poly_start, poly_end;
+ gettimeofday(&poly_start,0);
#endif
- //Add lineality space - dd_LinealitySpace
- dd_MatrixPtr ddineq;
- dd_ErrorType err;
- ddineq = (dd_LinealitySpace->rowsize>0) ? dd_AppendMatrix(gc.ddFacets,gcone::dd_LinealitySpace) : dd_CopyMatrix(gc.ddFacets);
- /* In case the input is non-homogeneous we add constrains for the positive orthant.
- * This is justified by the fact that for non-homog ideals we only consider the
- * restricted fan. This way we can be sure to find strictly positive interior points.
- * This in turn makes life easy when checking for flippability!
- * Drawback: Makes the LP larger so probably slows down computations a wee bit.
- */
- dd_MatrixPtr ddPosRestr;
- if(hasHomInput==FALSE)
- {
- dd_MatrixPtr tmp;
- ddPosRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
- for(int ii=0;ii<this->numVars;ii++)
- dd_set_si(ddPosRestr->matrix[ii][ii+1],1);
- dd_MatrixAppendTo(&ddineq,ddPosRestr);
- assert(ddineq);
- dd_FreeMatrix(ddPosRestr);
- }
- dd_PolyhedraPtr ddPolyh;
- ddPolyh = dd_DDMatrix2Poly(ddineq, &err);
- dd_MatrixPtr P;
- P=dd_CopyGenerators(ddPolyh);//Here we actually compute the rays!
- dd_FreePolyhedra(ddPolyh);
- dd_FreeMatrix(ddineq);
+ //Add lineality space - dd_LinealitySpace
+ dd_MatrixPtr ddineq;
+ dd_ErrorType err;
+ ddineq = (dd_LinealitySpace->rowsize>0) ? dd_AppendMatrix(gc.ddFacets,gcone::dd_LinealitySpace) : dd_CopyMatrix(gc.ddFacets);
+ /* In case the input is non-homogeneous we add constrains for the positive orthant.
+ * This is justified by the fact that for non-homog ideals we only consider the
+ * restricted fan. This way we can be sure to find strictly positive interior points.
+ * This in turn makes life easy when checking for flippability!
+ * Drawback: Makes the LP larger so probably slows down computations a wee bit.
+ */
+ dd_MatrixPtr ddPosRestr;
+ if(hasHomInput==FALSE)
+ {
+ dd_MatrixPtr tmp;
+ ddPosRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
+ for(int ii=0;ii<this->numVars;ii++)
+ dd_set_si(ddPosRestr->matrix[ii][ii+1],1);
+ dd_MatrixAppendTo(&ddineq,ddPosRestr);
+ assert(ddineq);
+ dd_FreeMatrix(ddPosRestr);
+ }
+ dd_PolyhedraPtr ddPolyh;
+ ddPolyh = dd_DDMatrix2Poly(ddineq, &err);
+ dd_MatrixPtr P;
+ P=dd_CopyGenerators(ddPolyh);//Here we actually compute the rays!
+ dd_FreePolyhedra(ddPolyh);
+ dd_FreeMatrix(ddineq);
#ifdef gfanp
- gettimeofday(&poly_end,0);
- t_ddPolyh += (poly_end.tv_sec - poly_start.tv_sec + 1e-6*(poly_end.tv_usec - poly_start.tv_usec));
+ gettimeofday(&poly_end,0);
+ t_ddPolyh += (poly_end.tv_sec - poly_start.tv_sec + 1e-6*(poly_end.tv_usec - poly_start.tv_usec));
#endif
- /* Compute interior point on the fly*/
- int64vec *ivIntPointOfCone = new int64vec(this->numVars);
- int64vec *foo = new int64vec(this->numVars);
- for(int ii=0;ii<P->rowsize;ii++)
- {
- int64vec *tmp = ivIntPointOfCone;
- makeInt(P,ii+1,*foo);
- ivIntPointOfCone = iv64Add(ivIntPointOfCone,foo);
- delete tmp;
- }
- delete foo;
- int64 ggT=(*ivIntPointOfCone)[0];
- for (int ii=0;ii<(this->numVars);ii++)
- {
- if( (*ivIntPointOfCone)[ii]>INT_MAX )
- WarnS("Interior point exceeds INT_MAX!\n");
- //Compute intgcd
- ggT=int64gcd(ggT,(*ivIntPointOfCone)[ii]);
- }
-
- //Divide out a common gcd > 1
- if(ggT>1)
- {
- for(int ii=0;ii<this->numVars;ii++)
- {
- (*ivIntPointOfCone)[ii] /= ggT;
- if( (*ivIntPointOfCone)[ii]>INT_MAX ) WarnS("Interior point still exceeds INT_MAX after GCD!\n");
- }
- }
-
- /*For homogeneous input (like Det3,3,5) the int points may be negative. So add a suitable multiple of (1,_,1)*/
- if(hasHomInput==TRUE && iv64isStrictlyPositive(ivIntPointOfCone)==FALSE)
- {
- int64vec *ivOne = new int64vec(this->numVars);
- int maxNegEntry=0;
- for(int ii=0;ii<this->numVars;ii++)
- {
-// (*ivOne)[ii]=1;
- if ((*ivIntPointOfCone)[ii]<maxNegEntry) maxNegEntry=(*ivIntPointOfCone)[ii];
- }
- maxNegEntry *= -1;
- maxNegEntry++;//To be on the safe side
- for(int ii=0;ii<this->numVars;ii++)
- (*ivOne)[ii]=maxNegEntry;
- int64vec *tmp=ivIntPointOfCone;
- ivIntPointOfCone=iv64Add(ivIntPointOfCone,ivOne);
- delete(tmp);
-// while( !iv64isStrictlyPositive(ivIntPointOfCone) )
-// {
-// int64vec *tmp = ivIntPointOfCone;
-// for(int jj=0;jj<this->numVars;jj++)
-// (*ivOne)[jj] = (*ivOne)[jj] << 1; //times 2
-// ivIntPointOfCone = ivAdd(ivIntPointOfCone,ivOne);
-// delete tmp;
-// }
- delete ivOne;
- int64 ggT=(*ivIntPointOfCone)[0];
- for(int ii=0;ii<this->numVars;ii++)
- ggT=int64gcd( ggT, (*ivIntPointOfCone)[ii]);
- if(ggT>1)
- {
- for(int jj=0;jj<this->numVars;jj++)
- (*ivIntPointOfCone)[jj] /= ggT;
- }
- }
-// assert(iv64isStrictlyPositive(ivIntPointOfCone));
-
- this->setIntPoint(ivIntPointOfCone);
- delete(ivIntPointOfCone);
- /* end of interior point computation*/
-
- //Loop through the rows of P and check whether fNormal*row[i]=0 => row[i] belongs to fNormal
- int rows=P->rowsize;
- facet *fAct=gc.facetPtr;
- //Construct an array to hold the extremal rays of the cone
- this->gcRays = (int64vec**)omAlloc0(sizeof(int64vec*)*P->rowsize);
- for(int ii=0;ii<P->rowsize;ii++)
- {
- int64vec *rowvec = new int64vec(this->numVars);
- makeInt(P,ii+1,*rowvec);//get an integer entry instead of rational, rowvec is primitve
- this->gcRays[ii] = iv64Copy(rowvec);
- delete rowvec;
- }
- this->numRays=P->rowsize;
- //Check which rays belong to which facet
- while(fAct!=NULL)
- {
- const int64vec *fNormal;// = new int64vec(this->numVars);
- fNormal = fAct->getRef2FacetNormal();//->getFacetNormal();
- int64vec *ivIntPointOfFacet = new int64vec(this->numVars);
- for(int ii=0;ii<rows;ii++)
- {
- if(dotProduct(*fNormal,this->gcRays[ii])==0)
- {
- int64vec *tmp = ivIntPointOfFacet;//Prevent memleak
- fAct->numCodim2Facets++;
- facet *codim2Act;
- if(fAct->numCodim2Facets==1)
- {
- fAct->codim2Ptr = new facet(2);
- codim2Act = fAct->codim2Ptr;
- }
- else
- {
- codim2Act->next = new facet(2);
- codim2Act = codim2Act->next;
- }
- //codim2Act->setFacetNormal(rowvec);
- //Rather just let codim2Act point to the corresponding int64vec of gcRays
- codim2Act->fNormal=this->gcRays[ii];
- fAct->numRays++;
- //Memleak avoided via tmp
- ivIntPointOfFacet=iv64Add(ivIntPointOfFacet,this->gcRays[ii]);
- //Now tmp still points to the OLD address of ivIntPointOfFacet
- delete(tmp);
-
- }
- }//For non-homog input ivIntPointOfFacet should already be >0 here
-// if(!hasHomInput) {assert(iv64isStrictlyPositive(ivIntPointOfFacet));}
- //if we have no strictly pos ray but the input is homogeneous
- //then add a suitable multiple of (1,...,1)
- if( !iv64isStrictlyPositive(ivIntPointOfFacet) && hasHomInput==TRUE)
- {
- int64vec *ivOne = new int64vec(this->numVars);
- for(int ii=0;ii<this->numVars;ii++)
- (*ivOne)[ii]=1;
- while( !iv64isStrictlyPositive(ivIntPointOfFacet) )
- {
- int64vec *tmp = ivIntPointOfFacet;
- for(int jj=0;jj<this->numVars;jj++)
- {
- (*ivOne)[jj] = (*ivOne)[jj] << 1; //times 2
- }
- ivIntPointOfFacet = iv64Add(ivIntPointOfFacet/*diff*/,ivOne);
- delete tmp;
- }
- delete ivOne;
- }
- int64 ggT=(*ivIntPointOfFacet)[0];
- for(int ii=0;ii<this->numVars;ii++)
- ggT=int64gcd(ggT,(*ivIntPointOfFacet)[ii]);
- if(ggT>1)
- {
- for(int ii=0;ii<this->numVars;ii++)
- (*ivIntPointOfFacet)[ii] /= ggT;
- }
- fAct->setInteriorPoint(ivIntPointOfFacet);
-
- delete(ivIntPointOfFacet);
- //Now (if we have at least 3 variables) do a bubblesort on the rays
- /*if(this->numVars>2)
- {
- facet *A[fAct->numRays-1];
- facet *f2Act=fAct->codim2Ptr;
- for(unsigned ii=0;ii<fAct->numRays;ii++)
- {
- A[ii]=f2Act;
- f2Act=f2Act->next;
- }
- bool exchanged=FALSE;
- unsigned n=fAct->numRays-1;
- do
- {
- exchanged=FALSE;//n=fAct->numRays-1;
- for(unsigned ii=0;ii<=n-1;ii++)
- {
- if((A[ii]->fNormal)->compare((A[ii+1]->fNormal))==1)
- {
- //Swap rays
- cout << "Swapping ";
- A[ii]->fNormal->show(1,0); cout << " with "; A[ii+1]->fNormal->show(1,0); cout << endl;
- A[ii]->next=A[ii+1]->next;
- if(ii>0)
- A[ii-1]->next=A[ii+1];
- A[ii+1]->next=A[ii];
- if(ii==0)
- fAct->codim2Ptr=A[ii+1];
- //end swap
- facet *tmp=A[ii];//swap in list
- A[ii+1]=A[ii];
- A[ii]=tmp;
-// tmp=NULL;
- }
- }
- n--;
- }while(exchanged==TRUE && n>=0);
- }*///if pVariables>2
-// delete fNormal;
- fAct = fAct->next;
- }//end of facet checking
- dd_FreeMatrix(P);
- //Now all extremal rays should be set w.r.t their respective fNormal
- //TODO Not sufficient -> vol2 II/125&127
- //NOTE Sufficient according to cddlibs doc. These ARE rays
- //What the hell... let's just take interior points
- if(gcone::hasHomInput==FALSE)
- {
- fAct=gc.facetPtr;
- while(fAct!=NULL)
- {
-// bool containsStrictlyPosRay=FALSE;
-// facet *codim2Act;
-// codim2Act = fAct->codim2Ptr;
-// while(codim2Act!=NULL)
-// {
-// int64vec *rayvec;
-// rayvec = codim2Act->getFacetNormal();//Mind this is no normal but a ray!
-// //int negCtr=0;
-// if(iv64isStrictlyPositive(rayvec))
-// {
-// containsStrictlyPosRay=TRUE;
-// delete(rayvec);
-// break;
-// }
-// delete(rayvec);
-// codim2Act = codim2Act->next;
-// }
-// if(containsStrictlyPosRay==FALSE)
-// fAct->isFlippable=FALSE;
- if(!iv64isStrictlyPositive(fAct->interiorPoint))
- fAct->isFlippable=FALSE;
- fAct = fAct->next;
- }
- }//hasHomInput?
+ /* Compute interior point on the fly*/
+ int64vec *ivIntPointOfCone = new int64vec(this->numVars);
+ int64vec *foo = new int64vec(this->numVars);
+ for(int ii=0;ii<P->rowsize;ii++)
+ {
+ int64vec *tmp = ivIntPointOfCone;
+ makeInt(P,ii+1,*foo);
+ ivIntPointOfCone = iv64Add(ivIntPointOfCone,foo);
+ delete tmp;
+ }
+ delete foo;
+ int64 ggT=(*ivIntPointOfCone)[0];
+ for (int ii=0;ii<(this->numVars);ii++)
+ {
+ if( (*ivIntPointOfCone)[ii]>INT_MAX )
+ WarnS("Interior point exceeds INT_MAX!\n");
+ //Compute intgcd
+ ggT=int64gcd(ggT,(*ivIntPointOfCone)[ii]);
+ }
+
+ //Divide out a common gcd > 1
+ if(ggT>1)
+ {
+ for(int ii=0;ii<this->numVars;ii++)
+ {
+ (*ivIntPointOfCone)[ii] /= ggT;
+ if( (*ivIntPointOfCone)[ii]>INT_MAX ) WarnS("Interior point still exceeds INT_MAX after GCD!\n");
+ }
+ }
+
+ /*For homogeneous input (like Det3,3,5) the int points may be negative. So add a suitable multiple of (1,_,1)*/
+ if(hasHomInput==TRUE && iv64isStrictlyPositive(ivIntPointOfCone)==FALSE)
+ {
+ int64vec *ivOne = new int64vec(this->numVars);
+ int maxNegEntry=0;
+ for(int ii=0;ii<this->numVars;ii++)
+ {
+// (*ivOne)[ii]=1;
+ if ((*ivIntPointOfCone)[ii]<maxNegEntry) maxNegEntry=(*ivIntPointOfCone)[ii];
+ }
+ maxNegEntry *= -1;
+ maxNegEntry++;//To be on the safe side
+ for(int ii=0;ii<this->numVars;ii++)
+ (*ivOne)[ii]=maxNegEntry;
+ int64vec *tmp=ivIntPointOfCone;
+ ivIntPointOfCone=iv64Add(ivIntPointOfCone,ivOne);
+ delete(tmp);
+// while( !iv64isStrictlyPositive(ivIntPointOfCone) )
+// {
+// int64vec *tmp = ivIntPointOfCone;
+// for(int jj=0;jj<this->numVars;jj++)
+// (*ivOne)[jj] = (*ivOne)[jj] << 1; //times 2
+// ivIntPointOfCone = ivAdd(ivIntPointOfCone,ivOne);
+// delete tmp;
+// }
+ delete ivOne;
+ int64 ggT=(*ivIntPointOfCone)[0];
+ for(int ii=0;ii<this->numVars;ii++)
+ ggT=int64gcd( ggT, (*ivIntPointOfCone)[ii]);
+ if(ggT>1)
+ {
+ for(int jj=0;jj<this->numVars;jj++)
+ (*ivIntPointOfCone)[jj] /= ggT;
+ }
+ }
+// assert(iv64isStrictlyPositive(ivIntPointOfCone));
+
+ this->setIntPoint(ivIntPointOfCone);
+ delete(ivIntPointOfCone);
+ /* end of interior point computation*/
+
+ //Loop through the rows of P and check whether fNormal*row[i]=0 => row[i] belongs to fNormal
+ int rows=P->rowsize;
+ facet *fAct=gc.facetPtr;
+ //Construct an array to hold the extremal rays of the cone
+ this->gcRays = (int64vec**)omAlloc0(sizeof(int64vec*)*P->rowsize);
+ for(int ii=0;ii<P->rowsize;ii++)
+ {
+ int64vec *rowvec = new int64vec(this->numVars);
+ makeInt(P,ii+1,*rowvec);//get an integer entry instead of rational, rowvec is primitve
+ this->gcRays[ii] = iv64Copy(rowvec);
+ delete rowvec;
+ }
+ this->numRays=P->rowsize;
+ //Check which rays belong to which facet
+ while(fAct!=NULL)
+ {
+ const int64vec *fNormal;// = new int64vec(this->numVars);
+ fNormal = fAct->getRef2FacetNormal();//->getFacetNormal();
+ int64vec *ivIntPointOfFacet = new int64vec(this->numVars);
+ for(int ii=0;ii<rows;ii++)
+ {
+ if(dotProduct(*fNormal,this->gcRays[ii])==0)
+ {
+ int64vec *tmp = ivIntPointOfFacet;//Prevent memleak
+ fAct->numCodim2Facets++;
+ facet *codim2Act;
+ if(fAct->numCodim2Facets==1)
+ {
+ fAct->codim2Ptr = new facet(2);
+ codim2Act = fAct->codim2Ptr;
+ }
+ else
+ {
+ codim2Act->next = new facet(2);
+ codim2Act = codim2Act->next;
+ }
+ //codim2Act->setFacetNormal(rowvec);
+ //Rather just let codim2Act point to the corresponding int64vec of gcRays
+ codim2Act->fNormal=this->gcRays[ii];
+ fAct->numRays++;
+ //Memleak avoided via tmp
+ ivIntPointOfFacet=iv64Add(ivIntPointOfFacet,this->gcRays[ii]);
+ //Now tmp still points to the OLD address of ivIntPointOfFacet
+ delete(tmp);
+
+ }
+ }//For non-homog input ivIntPointOfFacet should already be >0 here
+// if(!hasHomInput) {assert(iv64isStrictlyPositive(ivIntPointOfFacet));}
+ //if we have no strictly pos ray but the input is homogeneous
+ //then add a suitable multiple of (1,...,1)
+ if( !iv64isStrictlyPositive(ivIntPointOfFacet) && hasHomInput==TRUE)
+ {
+ int64vec *ivOne = new int64vec(this->numVars);
+ for(int ii=0;ii<this->numVars;ii++)
+ (*ivOne)[ii]=1;
+ while( !iv64isStrictlyPositive(ivIntPointOfFacet) )
+ {
+ int64vec *tmp = ivIntPointOfFacet;
+ for(int jj=0;jj<this->numVars;jj++)
+ {
+ (*ivOne)[jj] = (*ivOne)[jj] << 1; //times 2
+ }
+ ivIntPointOfFacet = iv64Add(ivIntPointOfFacet/*diff*/,ivOne);
+ delete tmp;
+ }
+ delete ivOne;
+ }
+ int64 ggT=(*ivIntPointOfFacet)[0];
+ for(int ii=0;ii<this->numVars;ii++)
+ ggT=int64gcd(ggT,(*ivIntPointOfFacet)[ii]);
+ if(ggT>1)
+ {
+ for(int ii=0;ii<this->numVars;ii++)
+ (*ivIntPointOfFacet)[ii] /= ggT;
+ }
+ fAct->setInteriorPoint(ivIntPointOfFacet);
+
+ delete(ivIntPointOfFacet);
+ //Now (if we have at least 3 variables) do a bubblesort on the rays
+ /*if(this->numVars>2)
+ {
+ facet *A[fAct->numRays-1];
+ facet *f2Act=fAct->codim2Ptr;
+ for(unsigned ii=0;ii<fAct->numRays;ii++)
+ {
+ A[ii]=f2Act;
+ f2Act=f2Act->next;
+ }
+ bool exchanged=FALSE;
+ unsigned n=fAct->numRays-1;
+ do
+ {
+ exchanged=FALSE;//n=fAct->numRays-1;
+ for(unsigned ii=0;ii<=n-1;ii++)
+ {
+ if((A[ii]->fNormal)->compare((A[ii+1]->fNormal))==1)
+ {
+ //Swap rays
+ cout << "Swapping ";
+ A[ii]->fNormal->show(1,0); cout << " with "; A[ii+1]->fNormal->show(1,0); cout << endl;
+ A[ii]->next=A[ii+1]->next;
+ if(ii>0)
+ A[ii-1]->next=A[ii+1];
+ A[ii+1]->next=A[ii];
+ if(ii==0)
+ fAct->codim2Ptr=A[ii+1];
+ //end swap
+ facet *tmp=A[ii];//swap in list
+ A[ii+1]=A[ii];
+ A[ii]=tmp;
+// tmp=NULL;
+ }
+ }
+ n--;
+ }while(exchanged==TRUE && n>=0);
+ }*///if pVariables>2
+// delete fNormal;
+ fAct = fAct->next;
+ }//end of facet checking
+ dd_FreeMatrix(P);
+ //Now all extremal rays should be set w.r.t their respective fNormal
+ //TODO Not sufficient -> vol2 II/125&127
+ //NOTE Sufficient according to cddlibs doc. These ARE rays
+ //What the hell... let's just take interior points
+ if(gcone::hasHomInput==FALSE)
+ {
+ fAct=gc.facetPtr;
+ while(fAct!=NULL)
+ {
+// bool containsStrictlyPosRay=FALSE;
+// facet *codim2Act;
+// codim2Act = fAct->codim2Ptr;
+// while(codim2Act!=NULL)
+// {
+// int64vec *rayvec;
+// rayvec = codim2Act->getFacetNormal();//Mind this is no normal but a ray!
+// //int negCtr=0;
+// if(iv64isStrictlyPositive(rayvec))
+// {
+// containsStrictlyPosRay=TRUE;
+// delete(rayvec);
+// break;
+// }
+// delete(rayvec);
+// codim2Act = codim2Act->next;
+// }
+// if(containsStrictlyPosRay==FALSE)
+// fAct->isFlippable=FALSE;
+ if(!iv64isStrictlyPositive(fAct->interiorPoint))
+ fAct->isFlippable=FALSE;
+ fAct = fAct->next;
+ }
+ }//hasHomInput?
#ifdef gfanp
- gettimeofday(&end, 0);
- t_getExtremalRays += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-#endif
+ gettimeofday(&end, 0);
+ t_getExtremalRays += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+#endif
}
/** Order the spanning rays in a lex way hopefully using qsort()*/
@@ -1602,22 +1600,22 @@ void gcone::orderRays()
{
// qsort(gcRays,sizeof(int64vec),int64vec::compare);
}
-
+
inline bool gcone::iv64isStrictlyPositive(const int64vec * iv64)
{
- bool res=TRUE;
- for(int ii=0;ii<iv64->length();ii++)
- {
- if((*iv64)[ii]<=0)
- {
- res=FALSE;
- break;
- }
- }
- return res;
+ bool res=TRUE;
+ for(int ii=0;ii<iv64->length();ii++)
+ {
+ if((*iv64)[ii]<=0)
+ {
+ res=FALSE;
+ break;
+ }
+ }
+ return res;
}
-/** \brief Compute the Groebner Basis on the other side of a shared facet
+/** \brief Compute the Groebner Basis on the other side of a shared facet
*
* Implements algorithm 4.3.2 from Anders' thesis.
* As shown there it is not necessary to compute an interior point. The knowledge of the facet normal
@@ -1625,368 +1623,368 @@ inline bool gcone::iv64isStrictlyPositive(const int64vec * iv64)
* is parallel to \f$ leadexp(g) \f$
* Parallelity is checked using basic linear algebra. See gcone::isParallel.
* Other possibilities include computing the rank of the matrix consisting of the vectors in question and
- * computing an interior point of the facet and taking all terms having the same weight with respect
+ * computing an interior point of the facet and taking all terms having the same weight with respect
* to this interior point.
*\param ideal, facet
* Input: a marked,reduced Groebner basis and a facet
*/
-inline void gcone::flip(ideal gb, facet *f) //Compute "the other side"
-{
+inline void gcone::flip(ideal gb, facet *f) //Compute "the other side"
+{
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
-#endif
- int64vec *fNormal;// = new int64vec(this->numVars); //facet normal, check for parallelity
- fNormal = f->getFacetNormal(); //read this->fNormal;
+ timeval start, end;
+ gettimeofday(&start, 0);
+#endif
+ int64vec *fNormal;// = new int64vec(this->numVars); //facet normal, check for parallelity
+ fNormal = f->getFacetNormal(); //read this->fNormal;
#ifndef NDEBUG
-// std::cout << "running gcone::flip" << std::endl;
- printf("flipping UCN %i over facet",this->getUCN());
- fNormal->show(1,0);
- printf(") with UCN %i\n",f->getUCN() );
+// std::cout << "running gcone::flip" << std::endl;
+ printf("flipping UCN %i over facet",this->getUCN());
+ fNormal->show(1,0);
+ printf(") with UCN %i\n",f->getUCN() );
#endif
- if(this->getUCN() != f->getUCN())
- {
- WerrorS("Uh oh... Trying to flip over facet with incompatible UCN");
- exit(-1);
- }
- /*1st step: Compute the initial ideal*/
- /*poly initialFormElement[IDELEMS(gb)];*/ //array of #polys in GB to store initial form
- ideal initialForm=idInit(IDELEMS(gb),this->gcBasis->rank);
-
- computeInv(gb,initialForm,*fNormal);
+ if(this->getUCN() != f->getUCN())
+ {
+ WerrorS("Uh oh... Trying to flip over facet with incompatible UCN");
+ exit(-1);
+ }
+ /*1st step: Compute the initial ideal*/
+ /*poly initialFormElement[IDELEMS(gb)];*/ //array of #polys in GB to store initial form
+ ideal initialForm=idInit(IDELEMS(gb),this->gcBasis->rank);
+
+ computeInv(gb,initialForm,*fNormal);
#ifndef NDEBUG
-/* cout << "Initial ideal is: " << endl;
- idShow(initialForm);
- //f->printFlipGB();*/
-// cout << "===" << endl;
-#endif
- /*2nd step: lift initial ideal to a GB of the neighbouring cone using minus alpha as weight*/
- /*Substep 2.1
- compute $G_{-\alpha}(in_v(I))
- see journal p. 66
- NOTE Check for different rings. Prolly it will not always be necessary to add a weight, if the
- srcRing already has a weighted ordering
- */
- ring srcRing=currRing;
- ring tmpRing;
-
- if( (srcRing->order[0]!=ringorder_a))
- {
- int64vec *iv;// = new int64vec(this->numVars);
- iv = ivNeg(fNormal);//ivNeg uses iv64Copy -> new
-// tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal));
- tmpRing=rCopyAndAddWeight(srcRing,iv);
- delete iv;
- }
- else
- {
- tmpRing=rCopy0(srcRing);
- int length=fNormal->length();
- int *A=(int *)omAlloc0(length*sizeof(int));
- for(int jj=0;jj<length;jj++)
- {
- A[jj]=-(*fNormal)[jj];
- }
- omFree(tmpRing->wvhdl[0]);
- tmpRing->wvhdl[0]=(int*)A;
- tmpRing->block1[0]=length;
- rComplete(tmpRing);
- //omFree(A);
- }
- delete fNormal;
- rChangeCurrRing(tmpRing);
-
- ideal ina;
- ina=idrCopyR(initialForm,srcRing);
- idDelete(&initialForm);
- ideal H;
-// H=kStd(ina,NULL,isHomog,NULL); //we know it is homogeneous
+/* cout << "Initial ideal is: " << endl;
+ idShow(initialForm);
+ //f->printFlipGB();*/
+// cout << "===" << endl;
+#endif
+ /*2nd step: lift initial ideal to a GB of the neighbouring cone using minus alpha as weight*/
+ /*Substep 2.1
+ compute $G_{-\alpha}(in_v(I))
+ see journal p. 66
+ NOTE Check for different rings. Prolly it will not always be necessary to add a weight, if the
+ srcRing already has a weighted ordering
+ */
+ ring srcRing=currRing;
+ ring tmpRing;
+
+ if( (srcRing->order[0]!=ringorder_a))
+ {
+ int64vec *iv;// = new int64vec(this->numVars);
+ iv = ivNeg(fNormal);//ivNeg uses iv64Copy -> new
+// tmpRing=rCopyAndAddWeight(srcRing,ivNeg(fNormal));
+ tmpRing=rCopyAndAddWeight(srcRing,iv);
+ delete iv;
+ }
+ else
+ {
+ tmpRing=rCopy0(srcRing);
+ int length=fNormal->length();
+ int *A=(int *)omAlloc0(length*sizeof(int));
+ for(int jj=0;jj<length;jj++)
+ {
+ A[jj]=-(*fNormal)[jj];
+ }
+ omFree(tmpRing->wvhdl[0]);
+ tmpRing->wvhdl[0]=(int*)A;
+ tmpRing->block1[0]=length;
+ rComplete(tmpRing);
+ //omFree(A);
+ }
+ delete fNormal;
+ rChangeCurrRing(tmpRing);
+
+ ideal ina;
+ ina=idrCopyR(initialForm,srcRing);
+ idDelete(&initialForm);
+ ideal H;
+// H=kStd(ina,NULL,isHomog,NULL); //we know it is homogeneous
#ifdef gfanp
- timeval t_kStd_start, t_kStd_end;
- gettimeofday(&t_kStd_start,0);
+ timeval t_kStd_start, t_kStd_end;
+ gettimeofday(&t_kStd_start,0);
#endif
- if(gcone::hasHomInput==TRUE)
- H=kStd(ina,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
- else
- H=kStd(ina,NULL,isNotHomog,NULL); //This is \mathcal(G)_{>_-\alpha}(in_v(I))
+ if(gcone::hasHomInput==TRUE)
+ H=kStd(ina,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
+ else
+ H=kStd(ina,NULL,isNotHomog,NULL); //This is \mathcal(G)_{>_-\alpha}(in_v(I))
#ifdef gfanp
- gettimeofday(&t_kStd_end, 0);
- t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
+ gettimeofday(&t_kStd_end, 0);
+ t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
#endif
- idSkipZeroes(H);
- idDelete(&ina);
-
- /*Substep 2.2
- do the lifting and mark according to H
- */
- rChangeCurrRing(srcRing);
- ideal srcRing_H;
- ideal srcRing_HH;
- srcRing_H=idrCopyR(H,tmpRing);
- //H is needed further below, so don't idDelete here
- srcRing_HH=ffG(srcRing_H,this->gcBasis);
- idDelete(&srcRing_H);
-
- /*Substep 2.2.1
- * Mark according to G_-\alpha
- * Here we have a minimal basis srcRing_HH. In order to turn this basis into a reduced basis
- * we have to compute an interior point of C(srcRing_HH). For this we need to know the cone
- * represented by srcRing_HH MARKED ACCORDING TO G_{-\alpha}
- * Thus we check whether the leading monomials of srcRing_HH and srcRing_H coincide. If not we
- * compute the difference accordingly
- */
+ idSkipZeroes(H);
+ idDelete(&ina);
+
+ /*Substep 2.2
+ do the lifting and mark according to H
+ */
+ rChangeCurrRing(srcRing);
+ ideal srcRing_H;
+ ideal srcRing_HH;
+ srcRing_H=idrCopyR(H,tmpRing);
+ //H is needed further below, so don't idDelete here
+ srcRing_HH=ffG(srcRing_H,this->gcBasis);
+ idDelete(&srcRing_H);
+
+ /*Substep 2.2.1
+ * Mark according to G_-\alpha
+ * Here we have a minimal basis srcRing_HH. In order to turn this basis into a reduced basis
+ * we have to compute an interior point of C(srcRing_HH). For this we need to know the cone
+ * represented by srcRing_HH MARKED ACCORDING TO G_{-\alpha}
+ * Thus we check whether the leading monomials of srcRing_HH and srcRing_H coincide. If not we
+ * compute the difference accordingly
+ */
#ifdef gfanp
- timeval t_markings_start, t_markings_end;
- gettimeofday(&t_markings_start, 0);
-#endif
- bool markingsAreCorrect=FALSE;
- dd_MatrixPtr intPointMatrix;
- int iPMatrixRows=0;
- dd_rowrange aktrow=0;
- for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
- {
- poly aktpoly=(poly)srcRing_HH->m[ii];//This is a pointer, so don't pDelete
- iPMatrixRows = iPMatrixRows+pLength(aktpoly);
- }
- /* additionally one row for the standard-simplex and another for a row that becomes 0 during
- * construction of the differences
- */
- intPointMatrix = dd_CreateMatrix(iPMatrixRows+2,this->numVars+1);
- intPointMatrix->numbtype=dd_Integer; //NOTE: DO NOT REMOVE OR CHANGE TO dd_Rational
-
- for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
- {
- markingsAreCorrect=FALSE; //crucial to initialise here
- poly aktpoly=srcRing_HH->m[ii]; //Only a pointer, so don't pDelete
- /*Comparison of leading monomials is done via exponent vectors*/
- for (int jj=0;jj<IDELEMS(H);jj++)
- {
- int *src_ExpV = (int *)omAlloc((this->numVars+1)*sizeof(int));
- int *dst_ExpV = (int *)omAlloc((this->numVars+1)*sizeof(int));
- pGetExpV(aktpoly,src_ExpV);
- rChangeCurrRing(tmpRing); //this ring change is crucial!
- poly p=pCopy(H->m[ii]);
- pGetExpV(p/*pCopy(H->m[ii])*/,dst_ExpV);
- pDelete(&p);
- rChangeCurrRing(srcRing);
- bool expVAreEqual=TRUE;
- for (int kk=1;kk<=this->numVars;kk++)
- {
+ timeval t_markings_start, t_markings_end;
+ gettimeofday(&t_markings_start, 0);
+#endif
+ bool markingsAreCorrect=FALSE;
+ dd_MatrixPtr intPointMatrix;
+ int iPMatrixRows=0;
+ dd_rowrange aktrow=0;
+ for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
+ {
+ poly aktpoly=(poly)srcRing_HH->m[ii];//This is a pointer, so don't pDelete
+ iPMatrixRows = iPMatrixRows+pLength(aktpoly);
+ }
+ /* additionally one row for the standard-simplex and another for a row that becomes 0 during
+ * construction of the differences
+ */
+ intPointMatrix = dd_CreateMatrix(iPMatrixRows+2,this->numVars+1);
+ intPointMatrix->numbtype=dd_Integer; //NOTE: DO NOT REMOVE OR CHANGE TO dd_Rational
+
+ for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
+ {
+ markingsAreCorrect=FALSE; //crucial to initialise here
+ poly aktpoly=srcRing_HH->m[ii]; //Only a pointer, so don't pDelete
+ /*Comparison of leading monomials is done via exponent vectors*/
+ for (int jj=0;jj<IDELEMS(H);jj++)
+ {
+ int *src_ExpV = (int *)omAlloc((this->numVars+1)*sizeof(int));
+ int *dst_ExpV = (int *)omAlloc((this->numVars+1)*sizeof(int));
+ pGetExpV(aktpoly,src_ExpV);
+ rChangeCurrRing(tmpRing); //this ring change is crucial!
+ poly p=pCopy(H->m[ii]);
+ pGetExpV(p/*pCopy(H->m[ii])*/,dst_ExpV);
+ pDelete(&p);
+ rChangeCurrRing(srcRing);
+ bool expVAreEqual=TRUE;
+ for (int kk=1;kk<=this->numVars;kk++)
+ {
#ifndef NDEBUG
-// cout << src_ExpV[kk] << "," << dst_ExpV[kk] << endl;
+// cout << src_ExpV[kk] << "," << dst_ExpV[kk] << endl;
#endif
- if (src_ExpV[kk]!=dst_ExpV[kk])
- {
- expVAreEqual=FALSE;
- }
- }
- if (expVAreEqual==TRUE)
- {
- markingsAreCorrect=TRUE; //everything is fine
+ if (src_ExpV[kk]!=dst_ExpV[kk])
+ {
+ expVAreEqual=FALSE;
+ }
+ }
+ if (expVAreEqual==TRUE)
+ {
+ markingsAreCorrect=TRUE; //everything is fine
#ifndef NDEBUG
-// cout << "correct markings" << endl;
+// cout << "correct markings" << endl;
#endif
- }//if (pHead(aktpoly)==pHead(H->m[jj])
- omFree(src_ExpV);
- omFree(dst_ExpV);
- }//for (int jj=0;jj<IDELEMS(H);jj++)
-
- int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
- if (markingsAreCorrect==TRUE)
- {
- pGetExpV(aktpoly,leadExpV);
- }
- else
- {
- rChangeCurrRing(tmpRing);
- pGetExpV(pHead(H->m[ii]),leadExpV); //We use H->m[ii] as leading monomial
- rChangeCurrRing(srcRing);
- }
- /*compute differences of the expvects*/
- while (pNext(aktpoly)!=NULL)
- {
- int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
- /*The following if-else-block makes sure the first term (i.e. the wrongly marked term)
- is not omitted when computing the differences*/
- if(markingsAreCorrect==TRUE)
- {
- aktpoly=pNext(aktpoly);
- pGetExpV(aktpoly,v);
- }
- else
- {
- pGetExpV(pHead(aktpoly),v);
- markingsAreCorrect=TRUE;
- }
- int ctr=0;
- for (int jj=0;jj<this->numVars;jj++)
- {
- /*Store into ddMatrix*/
- if(leadExpV[jj+1]-v[jj+1])
- ctr++;
- dd_set_si(intPointMatrix->matrix[aktrow][jj+1],leadExpV[jj+1]-v[jj+1]);
- }
- /*It ought to be more sensible to avoid 0-rows in the first place*/
-// if(ctr==this->numVars)//We have a 0-row
-// dd_MatrixRowRemove(&intPointMatrix,aktrow);
-// else
- aktrow +=1;
- omFree(v);
- }
- omFree(leadExpV);
- }//for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
+ }//if (pHead(aktpoly)==pHead(H->m[jj])
+ omFree(src_ExpV);
+ omFree(dst_ExpV);
+ }//for (int jj=0;jj<IDELEMS(H);jj++)
+
+ int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
+ if (markingsAreCorrect==TRUE)
+ {
+ pGetExpV(aktpoly,leadExpV);
+ }
+ else
+ {
+ rChangeCurrRing(tmpRing);
+ pGetExpV(pHead(H->m[ii]),leadExpV); //We use H->m[ii] as leading monomial
+ rChangeCurrRing(srcRing);
+ }
+ /*compute differences of the expvects*/
+ while (pNext(aktpoly)!=NULL)
+ {
+ int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
+ /*The following if-else-block makes sure the first term (i.e. the wrongly marked term)
+ is not omitted when computing the differences*/
+ if(markingsAreCorrect==TRUE)
+ {
+ aktpoly=pNext(aktpoly);
+ pGetExpV(aktpoly,v);
+ }
+ else
+ {
+ pGetExpV(pHead(aktpoly),v);
+ markingsAreCorrect=TRUE;
+ }
+ int ctr=0;
+ for (int jj=0;jj<this->numVars;jj++)
+ {
+ /*Store into ddMatrix*/
+ if(leadExpV[jj+1]-v[jj+1])
+ ctr++;
+ dd_set_si(intPointMatrix->matrix[aktrow][jj+1],leadExpV[jj+1]-v[jj+1]);
+ }
+ /*It ought to be more sensible to avoid 0-rows in the first place*/
+// if(ctr==this->numVars)//We have a 0-row
+// dd_MatrixRowRemove(&intPointMatrix,aktrow);
+// else
+ aktrow +=1;
+ omFree(v);
+ }
+ omFree(leadExpV);
+ }//for (int ii=0;ii<IDELEMS(srcRing_HH);ii++)
#ifdef gfanp
- gettimeofday(&t_markings_end, 0);
- t_markings += (t_markings_end.tv_sec - t_markings_start.tv_sec + 1e-6*(t_markings_end.tv_usec - t_markings_start.tv_usec));
+ gettimeofday(&t_markings_end, 0);
+ t_markings += (t_markings_end.tv_sec - t_markings_start.tv_sec + 1e-6*(t_markings_end.tv_usec - t_markings_start.tv_usec));
#endif
- /*Now it is safe to idDelete(H)*/
- idDelete(&H);
- /*Preprocessing goes here since otherwise we would delete the constraint
- * for the standard simplex.
- */
- preprocessInequalities(intPointMatrix);
- /*Now we add the constraint for the standard simplex*/
-// dd_set_si(intPointMatrix->matrix[aktrow][0],-1);
-// for (int jj=1;jj<=this->numVars;jj++)
-// {
-// dd_set_si(intPointMatrix->matrix[aktrow][jj],1);
-// }
- //Let's make sure we compute interior points from the positive orthant
-// dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
-//
-// int jj=1;
-// for (int ii=0;ii<this->numVars;ii++)
-// {
-// dd_set_si(posRestr->matrix[ii][jj],1);
-// jj++;
-// }
- /*We create a matrix containing the standard simplex
- * and constraints to assure a strictly positive point
- * is computed */
- dd_MatrixPtr posRestr = dd_CreateMatrix(this->numVars+1, this->numVars+1);
- for(int ii=0;ii<posRestr->rowsize;ii++)
- {
- if(ii==0)
- {
- dd_set_si(posRestr->matrix[ii][0],-1);
- for(int jj=1;jj<=this->numVars;jj++)
- dd_set_si(posRestr->matrix[ii][jj],1);
- }
- else
- {
- /** Set all variables to \geq 1/10. YMMV but this choice is pretty equal*/
- dd_set_si2(posRestr->matrix[ii][0],-1,2);
- dd_set_si(posRestr->matrix[ii][ii],1);
- }
- }
- dd_MatrixAppendTo(&intPointMatrix,posRestr);
- dd_FreeMatrix(posRestr);
-
- int64vec *iv_weight = new int64vec(this->numVars);
+ /*Now it is safe to idDelete(H)*/
+ idDelete(&H);
+ /*Preprocessing goes here since otherwise we would delete the constraint
+ * for the standard simplex.
+ */
+ preprocessInequalities(intPointMatrix);
+ /*Now we add the constraint for the standard simplex*/
+// dd_set_si(intPointMatrix->matrix[aktrow][0],-1);
+// for (int jj=1;jj<=this->numVars;jj++)
+// {
+// dd_set_si(intPointMatrix->matrix[aktrow][jj],1);
+// }
+ //Let's make sure we compute interior points from the positive orthant
+// dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
+//
+// int jj=1;
+// for (int ii=0;ii<this->numVars;ii++)
+// {
+// dd_set_si(posRestr->matrix[ii][jj],1);
+// jj++;
+// }
+ /*We create a matrix containing the standard simplex
+ * and constraints to assure a strictly positive point
+ * is computed */
+ dd_MatrixPtr posRestr = dd_CreateMatrix(this->numVars+1, this->numVars+1);
+ for(int ii=0;ii<posRestr->rowsize;ii++)
+ {
+ if(ii==0)
+ {
+ dd_set_si(posRestr->matrix[ii][0],-1);
+ for(int jj=1;jj<=this->numVars;jj++)
+ dd_set_si(posRestr->matrix[ii][jj],1);
+ }
+ else
+ {
+ /** Set all variables to \geq 1/10. YMMV but this choice is pretty equal*/
+ dd_set_si2(posRestr->matrix[ii][0],-1,2);
+ dd_set_si(posRestr->matrix[ii][ii],1);
+ }
+ }
+ dd_MatrixAppendTo(&intPointMatrix,posRestr);
+ dd_FreeMatrix(posRestr);
+
+ int64vec *iv_weight = new int64vec(this->numVars);
#ifdef gfanp
- timeval t_dd_start, t_dd_end;
- gettimeofday(&t_dd_start, 0);
+ timeval t_dd_start, t_dd_end;
+ gettimeofday(&t_dd_start, 0);
#endif
- dd_ErrorType err;
- dd_rowset implLin, redrows;
- dd_rowindex newpos;
-
- //NOTE Here we should remove interiorPoint and instead
- // create and ordering like (a(omega),a(fNormal),dp)
-// if(this->ivIntPt==NULL)
- interiorPoint(intPointMatrix, *iv_weight); //iv_weight now contains the interior point
-// else
-// iv_weight=this->getIntPoint();
- dd_FreeMatrix(intPointMatrix);
- /*Crude attempt for interior point */
- /*dd_PolyhedraPtr ddpolyh;
- dd_ErrorType err;
- dd_rowset impl_linset,redset;
- dd_rowindex newpos;
- dd_MatrixCanonicalize(&intPointMatrix, &impl_linset, &redset, &newpos, &err);
- ddpolyh=dd_DDMatrix2Poly(intPointMatrix, &err);
- dd_MatrixPtr P;
- P=dd_CopyGenerators(ddpolyh);
- dd_FreePolyhedra(ddpolyh);
- for(int ii=0;ii<P->rowsize;ii++)
- {
- int64vec *iv_row=new int64vec(this->numVars);
- makeInt(P,ii+1,*iv_row);
- iv_weight =ivAdd(iv_weight, iv_row);
- delete iv_row;
- }
- dd_FreeMatrix(P);
- dd_FreeMatrix(intPointMatrix);*/
+ dd_ErrorType err;
+ dd_rowset implLin, redrows;
+ dd_rowindex newpos;
+
+ //NOTE Here we should remove interiorPoint and instead
+ // create and ordering like (a(omega),a(fNormal),dp)
+// if(this->ivIntPt==NULL)
+ interiorPoint(intPointMatrix, *iv_weight); //iv_weight now contains the interior point
+// else
+// iv_weight=this->getIntPoint();
+ dd_FreeMatrix(intPointMatrix);
+ /*Crude attempt for interior point */
+ /*dd_PolyhedraPtr ddpolyh;
+ dd_ErrorType err;
+ dd_rowset impl_linset,redset;
+ dd_rowindex newpos;
+ dd_MatrixCanonicalize(&intPointMatrix, &impl_linset, &redset, &newpos, &err);
+ ddpolyh=dd_DDMatrix2Poly(intPointMatrix, &err);
+ dd_MatrixPtr P;
+ P=dd_CopyGenerators(ddpolyh);
+ dd_FreePolyhedra(ddpolyh);
+ for(int ii=0;ii<P->rowsize;ii++)
+ {
+ int64vec *iv_row=new int64vec(this->numVars);
+ makeInt(P,ii+1,*iv_row);
+ iv_weight =ivAdd(iv_weight, iv_row);
+ delete iv_row;
+ }
+ dd_FreeMatrix(P);
+ dd_FreeMatrix(intPointMatrix);*/
#ifdef gfanp
- gettimeofday(&t_dd_end, 0);
- t_dd += (t_dd_end.tv_sec - t_dd_start.tv_sec + 1e-6*(t_dd_end.tv_usec - t_dd_start.tv_usec));
-#endif
-
- /*Step 3
- * turn the minimal basis into a reduced one */
- // NOTE May assume that at this point srcRing already has 3 blocks of orderins, starting with a
- // Thus:
- //ring dstRing=rCopyAndChangeWeight(srcRing,iv_weight);
- ring dstRing=rCopy0(tmpRing);
- int length=iv_weight->length();
- int *A=(int *)omAlloc0(length*sizeof(int));
- for(int jj=0;jj<length;jj++)
- {
- A[jj]=(*iv_weight)[jj];
- }
- dstRing->wvhdl[0]=(int*)A;
- rComplete(dstRing);
- rChangeCurrRing(dstRing);
- rDelete(tmpRing);
- delete iv_weight;
-
- ideal dstRing_I;
- dstRing_I=idrCopyR(srcRing_HH,srcRing);
- idDelete(&srcRing_HH); //Hmm.... causes trouble - no more
- //dstRing_I=idrCopyR(inputIdeal,srcRing);
- BITSET save=test;
- test|=Sy_bit(OPT_REDSB);
- test|=Sy_bit(OPT_REDTAIL);
+ gettimeofday(&t_dd_end, 0);
+ t_dd += (t_dd_end.tv_sec - t_dd_start.tv_sec + 1e-6*(t_dd_end.tv_usec - t_dd_start.tv_usec));
+#endif
+
+ /*Step 3
+ * turn the minimal basis into a reduced one */
+ // NOTE May assume that at this point srcRing already has 3 blocks of orderins, starting with a
+ // Thus:
+ //ring dstRing=rCopyAndChangeWeight(srcRing,iv_weight);
+ ring dstRing=rCopy0(tmpRing);
+ int length=iv_weight->length();
+ int *A=(int *)omAlloc0(length*sizeof(int));
+ for(int jj=0;jj<length;jj++)
+ {
+ A[jj]=(*iv_weight)[jj];
+ }
+ dstRing->wvhdl[0]=(int*)A;
+ rComplete(dstRing);
+ rChangeCurrRing(dstRing);
+ rDelete(tmpRing);
+ delete iv_weight;
+
+ ideal dstRing_I;
+ dstRing_I=idrCopyR(srcRing_HH,srcRing);
+ idDelete(&srcRing_HH); //Hmm.... causes trouble - no more
+ //dstRing_I=idrCopyR(inputIdeal,srcRing);
+ BITSET save=test;
+ test|=Sy_bit(OPT_REDSB);
+ test|=Sy_bit(OPT_REDTAIL);
#ifndef NDEBUG
-// test|=Sy_bit(6); //OPT_DEBUG
+// test|=Sy_bit(6); //OPT_DEBUG
#endif
- ideal tmpI;
- //NOTE Any of the two variants of tmpI={idrCopy(),dstRing_I} does the trick
- //tmpI = idrCopyR(this->inputIdeal,this->baseRing);
- tmpI = dstRing_I;
+ ideal tmpI;
+ //NOTE Any of the two variants of tmpI={idrCopy(),dstRing_I} does the trick
+ //tmpI = idrCopyR(this->inputIdeal,this->baseRing);
+ tmpI = dstRing_I;
#ifdef gfanp
- gettimeofday(&t_kStd_start,0);
+ gettimeofday(&t_kStd_start,0);
#endif
- if(gcone::hasHomInput==TRUE)
- dstRing_I=kStd(tmpI,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
- else
- dstRing_I=kStd(tmpI,NULL,isNotHomog,NULL);
+ if(gcone::hasHomInput==TRUE)
+ dstRing_I=kStd(tmpI,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
+ else
+ dstRing_I=kStd(tmpI,NULL,isNotHomog,NULL);
#ifdef gfanp
- gettimeofday(&t_kStd_end, 0);
- t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
+ gettimeofday(&t_kStd_end, 0);
+ t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
#endif
- idDelete(&tmpI);
- idNorm(dstRing_I);
-// kInterRed(dstRing_I);
- idSkipZeroes(dstRing_I);
- test=save;
- /*End of step 3 - reduction*/
-
- f->setFlipGB(dstRing_I);//store the flipped GB
-// idDelete(&dstRing_I);
- f->flipRing=rCopy(dstRing); //store the ring on the other side
+ idDelete(&tmpI);
+ idNorm(dstRing_I);
+// kInterRed(dstRing_I);
+ idSkipZeroes(dstRing_I);
+ test=save;
+ /*End of step 3 - reduction*/
+
+ f->setFlipGB(dstRing_I);//store the flipped GB
+// idDelete(&dstRing_I);
+ f->flipRing=rCopy(dstRing); //store the ring on the other side
#ifndef NDEBUG
- printf("Flipped GB is UCN %i:\n",counter+1);
- idDebugPrint(dstRing_I);
- printf("\n");
-#endif
- idDelete(&dstRing_I);
- rChangeCurrRing(srcRing); //return to the ring we started the computation of flipGB in
- rDelete(dstRing);
+ printf("Flipped GB is UCN %i:\n",counter+1);
+ idDebugPrint(dstRing_I);
+ printf("\n");
+#endif
+ idDelete(&dstRing_I);
+ rChangeCurrRing(srcRing); //return to the ring we started the computation of flipGB in
+ rDelete(dstRing);
#ifdef gfanp
- gettimeofday(&end, 0);
- time_flip += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+ gettimeofday(&end, 0);
+ time_flip += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
#endif
}//void flip(ideal gb, facet *f)
@@ -1998,9 +1996,9 @@ inline void gcone::flip(ideal gb, facet *f) //Compute "the other side"
* Problem: Assume we start in a cone with ordering (dp,C). Then \f$ in_\omega(I) \f$
* will be from a ring with (a(),dp,C) and our resulting cone from (a(),a(),dp,C). Hence a way
* must be found to circumvent the sequence of a()'s growing to a ridiculous size.
-* Therefore: We use (a(),a(),dp,C) for the computation of the reduced basis. But then we
-* do have an interior point of the cone by adding the extremal rays. So we replace
-* the latter cone by a cone with (a(sum_of_rays),dp,C).
+* Therefore: We use (a(),a(),dp,C) for the computation of the reduced basis. But then we
+* do have an interior point of the cone by adding the extremal rays. So we replace
+* the latter cone by a cone with (a(sum_of_rays),dp,C).
* Con: It's incredibly ugly
* Pro: No messing around with readConeFromFile()
* Is there a way to construct a vector from \f$ \omega \f$ and the facet normal?
@@ -2008,155 +2006,155 @@ inline void gcone::flip(ideal gb, facet *f) //Compute "the other side"
inline void gcone::flip2(const ideal &gb, facet *f)
{
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- const int64vec *fNormal;
- fNormal = f->getRef2FacetNormal();/*->getFacetNormal();*/ //read this->fNormal;
+ const int64vec *fNormal;
+ fNormal = f->getRef2FacetNormal();/*->getFacetNormal();*/ //read this->fNormal;
#ifndef NDEBUG
-// printf("flipping UCN %i over facet(",this->getUCN());
-// fNormal->show(1,0);
-// printf(") with UCN %i\n",f->getUCN());
+// printf("flipping UCN %i over facet(",this->getUCN());
+// fNormal->show(1,0);
+// printf(") with UCN %i\n",f->getUCN());
#endif
- if(this->getUCN() != f->getUCN())
- { printf("%i vs %i\n",this->getUCN(), f->getUCN() );
- WerrorS("Uh oh... Trying to flip over facet with incompatible UCN");
- exit(-1);
- }
- /*1st step: Compute the initial ideal*/
- ideal initialForm=idInit(IDELEMS(gb),this->gcBasis->rank);
- computeInv( gb, initialForm, *fNormal );
- ring srcRing=currRing;
- ring tmpRing;
-
- const int64vec *intPointOfFacet;
- intPointOfFacet=f->getInteriorPoint();
- //Now we need two blocks of ringorder_a!
- //May assume the same situation as in flip() here
- if( (srcRing->order[0]!=ringorder_a/*64*/) && (srcRing->order[1]!=ringorder_a/*64*/) )
- {
- int64vec *iv = new int64vec(this->numVars);//init with 1s, since we do not need a 2nd block here but later
-// int64vec *iv_foo = new int64vec(this->numVars,1);//placeholder
- int64vec *ivw = ivNeg(const_cast<int64vec*>(fNormal));
- tmpRing=rCopyAndAddWeight2(srcRing,ivw/*intPointOfFacet*/,iv);
- delete iv;delete ivw;
-// delete iv_foo;
- }
- else
- {
- int64vec *iv=new int64vec(this->numVars);
- int64vec *ivw=ivNeg(const_cast<int64vec*>(fNormal));
- tmpRing=rCopyAndAddWeight2(srcRing,ivw,iv);
- delete iv; delete ivw;
- /*tmpRing=rCopy0(srcRing);
- int length=fNormal->length();
- int *A1=(int *)omAlloc0(length*sizeof(int));
- int *A2=(int *)omAlloc0(length*sizeof(int));
- for(int jj=0;jj<length;jj++)
- {
- A1[jj] = -(*fNormal)[jj];
- A2[jj] = 1;//-(*fNormal)[jj];//NOTE Do we need this here? This is only the facet ideal
- }
- omFree(tmpRing->wvhdl[0]);
- if(tmpRing->wvhdl[1]!=NULL)
- omFree(tmpRing->wvhdl[1]);
- tmpRing->wvhdl[0]=(int*)A1;
- tmpRing->block1[0]=length;
- tmpRing->wvhdl[1]=(int*)A2;
- tmpRing->block1[1]=length;
- rComplete(tmpRing);*/
- }
-// delete fNormal; //NOTE Do not delete when using getRef2FacetNormal();
- rChangeCurrRing(tmpRing);
- //Now currRing should have (a(),a(),dp,C)
- ideal ina;
- ina=idrCopyR(initialForm,srcRing);
- idDelete(&initialForm);
- ideal H;
+ if(this->getUCN() != f->getUCN())
+ { printf("%i vs %i\n",this->getUCN(), f->getUCN() );
+ WerrorS("Uh oh... Trying to flip over facet with incompatible UCN");
+ exit(-1);
+ }
+ /*1st step: Compute the initial ideal*/
+ ideal initialForm=idInit(IDELEMS(gb),this->gcBasis->rank);
+ computeInv( gb, initialForm, *fNormal );
+ ring srcRing=currRing;
+ ring tmpRing;
+
+ const int64vec *intPointOfFacet;
+ intPointOfFacet=f->getInteriorPoint();
+ //Now we need two blocks of ringorder_a!
+ //May assume the same situation as in flip() here
+ if( (srcRing->order[0]!=ringorder_a/*64*/) && (srcRing->order[1]!=ringorder_a/*64*/) )
+ {
+ int64vec *iv = new int64vec(this->numVars);//init with 1s, since we do not need a 2nd block here but later
+// int64vec *iv_foo = new int64vec(this->numVars,1);//placeholder
+ int64vec *ivw = ivNeg(const_cast<int64vec*>(fNormal));
+ tmpRing=rCopyAndAddWeight2(srcRing,ivw/*intPointOfFacet*/,iv);
+ delete iv;delete ivw;
+// delete iv_foo;
+ }
+ else
+ {
+ int64vec *iv=new int64vec(this->numVars);
+ int64vec *ivw=ivNeg(const_cast<int64vec*>(fNormal));
+ tmpRing=rCopyAndAddWeight2(srcRing,ivw,iv);
+ delete iv; delete ivw;
+ /*tmpRing=rCopy0(srcRing);
+ int length=fNormal->length();
+ int *A1=(int *)omAlloc0(length*sizeof(int));
+ int *A2=(int *)omAlloc0(length*sizeof(int));
+ for(int jj=0;jj<length;jj++)
+ {
+ A1[jj] = -(*fNormal)[jj];
+ A2[jj] = 1;//-(*fNormal)[jj];//NOTE Do we need this here? This is only the facet ideal
+ }
+ omFree(tmpRing->wvhdl[0]);
+ if(tmpRing->wvhdl[1]!=NULL)
+ omFree(tmpRing->wvhdl[1]);
+ tmpRing->wvhdl[0]=(int*)A1;
+ tmpRing->block1[0]=length;
+ tmpRing->wvhdl[1]=(int*)A2;
+ tmpRing->block1[1]=length;
+ rComplete(tmpRing);*/
+ }
+// delete fNormal; //NOTE Do not delete when using getRef2FacetNormal();
+ rChangeCurrRing(tmpRing);
+ //Now currRing should have (a(),a(),dp,C)
+ ideal ina;
+ ina=idrCopyR(initialForm,srcRing);
+ idDelete(&initialForm);
+ ideal H;
#ifdef gfanp
- timeval t_kStd_start, t_kStd_end;
- gettimeofday(&t_kStd_start,0);
+ timeval t_kStd_start, t_kStd_end;
+ gettimeofday(&t_kStd_start,0);
#endif
- BITSET save=test;
- test|=Sy_bit(OPT_REDSB);
- test|=Sy_bit(OPT_REDTAIL);
-// if(gcone::hasHomInput==TRUE)
- H=kStd(ina,NULL,testHomog/*isHomog*/,NULL/*,gcone::hilbertFunction*/);
-// else
-// H=kStd(ina,NULL,isNotHomog,NULL); //This is \mathcal(G)_{>_-\alpha}(in_v(I))
- test=save;
+ BITSET save=test;
+ test|=Sy_bit(OPT_REDSB);
+ test|=Sy_bit(OPT_REDTAIL);
+// if(gcone::hasHomInput==TRUE)
+ H=kStd(ina,NULL,testHomog/*isHomog*/,NULL/*,gcone::hilbertFunction*/);
+// else
+// H=kStd(ina,NULL,isNotHomog,NULL); //This is \mathcal(G)_{>_-\alpha}(in_v(I))
+ test=save;
#ifdef gfanp
- gettimeofday(&t_kStd_end, 0);
- t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
+ gettimeofday(&t_kStd_end, 0);
+ t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
#endif
- idSkipZeroes(H);
- idDelete(&ina);
-
- rChangeCurrRing(srcRing);
- ideal srcRing_H;
- ideal srcRing_HH;
- srcRing_H=idrCopyR(H,tmpRing);
- //H is needed further below, so don't idDelete here
- srcRing_HH=ffG(srcRing_H,this->gcBasis);
- idDelete(&srcRing_H);
- //Now BBA(srcRing_HH) with (a(),a(),dp)
- /* Evil modification of currRing */
- ring dstRing=rCopy0(tmpRing);
- int length=this->numVars;
- int *A1=(int *)omAlloc0(length*sizeof(int));
- int *A2=(int *)omAlloc0(length*sizeof(int));
- const int64vec *ivw=f->getRef2FacetNormal();
- for(int jj=0;jj<length;jj++)
- {
- A1[jj] = (*intPointOfFacet)[jj];
- A2[jj] = -(*ivw)[jj];//TODO Or minus (*ivw)[ii] ??? NOTE minus
- }
- omFree(dstRing->wvhdl[0]);
- if(dstRing->wvhdl[1]!=NULL)
- omFree(dstRing->wvhdl[1]);
- dstRing->wvhdl[0]=(int*)A1;
- dstRing->block1[0]=length;
- dstRing->wvhdl[1]=(int*)A2;
- dstRing->block1[1]=length;
- rComplete(dstRing);
- rChangeCurrRing(dstRing);
- ideal dstRing_I;
- dstRing_I=idrCopyR(srcRing_HH,srcRing);
- idDelete(&srcRing_HH); //Hmm.... causes trouble - no more
- save=test;
- test|=Sy_bit(OPT_REDSB);
- test|=Sy_bit(OPT_REDTAIL);
- ideal tmpI;
- tmpI = dstRing_I;
+ idSkipZeroes(H);
+ idDelete(&ina);
+
+ rChangeCurrRing(srcRing);
+ ideal srcRing_H;
+ ideal srcRing_HH;
+ srcRing_H=idrCopyR(H,tmpRing);
+ //H is needed further below, so don't idDelete here
+ srcRing_HH=ffG(srcRing_H,this->gcBasis);
+ idDelete(&srcRing_H);
+ //Now BBA(srcRing_HH) with (a(),a(),dp)
+ /* Evil modification of currRing */
+ ring dstRing=rCopy0(tmpRing);
+ int length=this->numVars;
+ int *A1=(int *)omAlloc0(length*sizeof(int));
+ int *A2=(int *)omAlloc0(length*sizeof(int));
+ const int64vec *ivw=f->getRef2FacetNormal();
+ for(int jj=0;jj<length;jj++)
+ {
+ A1[jj] = (*intPointOfFacet)[jj];
+ A2[jj] = -(*ivw)[jj];//TODO Or minus (*ivw)[ii] ??? NOTE minus
+ }
+ omFree(dstRing->wvhdl[0]);
+ if(dstRing->wvhdl[1]!=NULL)
+ omFree(dstRing->wvhdl[1]);
+ dstRing->wvhdl[0]=(int*)A1;
+ dstRing->block1[0]=length;
+ dstRing->wvhdl[1]=(int*)A2;
+ dstRing->block1[1]=length;
+ rComplete(dstRing);
+ rChangeCurrRing(dstRing);
+ ideal dstRing_I;
+ dstRing_I=idrCopyR(srcRing_HH,srcRing);
+ idDelete(&srcRing_HH); //Hmm.... causes trouble - no more
+ save=test;
+ test|=Sy_bit(OPT_REDSB);
+ test|=Sy_bit(OPT_REDTAIL);
+ ideal tmpI;
+ tmpI = dstRing_I;
#ifdef gfanp
-// timeval t_kStd_start, t_kStd_end;
- gettimeofday(&t_kStd_start,0);
+// timeval t_kStd_start, t_kStd_end;
+ gettimeofday(&t_kStd_start,0);
#endif
-// if(gcone::hasHomInput==TRUE)
-// dstRing_I=kStd(tmpI,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
-// else
- dstRing_I=kStd(tmpI,NULL,testHomog,NULL);
+// if(gcone::hasHomInput==TRUE)
+// dstRing_I=kStd(tmpI,NULL,isHomog,NULL/*,gcone::hilbertFunction*/);
+// else
+ dstRing_I=kStd(tmpI,NULL,testHomog,NULL);
#ifdef gfanp
- gettimeofday(&t_kStd_end, 0);
- t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
+ gettimeofday(&t_kStd_end, 0);
+ t_kStd += (t_kStd_end.tv_sec - t_kStd_start.tv_sec + 1e-6*(t_kStd_end.tv_usec - t_kStd_start.tv_usec));
#endif
- idDelete(&tmpI);
- idNorm(dstRing_I);
- idSkipZeroes(dstRing_I);
- test=save;
- /*End of step 3 - reduction*/
-
- f->setFlipGB(dstRing_I);
- f->flipRing=rCopy(dstRing);
- rDelete(tmpRing);
- rDelete(dstRing);
- //Now we should have dstRing with (a(),a(),dp,C)
- //This must be replaced with (a(),dp,C) BEFORE gcTmp is actually added to the list
- //of cones in noRevS
- rChangeCurrRing(srcRing);
+ idDelete(&tmpI);
+ idNorm(dstRing_I);
+ idSkipZeroes(dstRing_I);
+ test=save;
+ /*End of step 3 - reduction*/
+
+ f->setFlipGB(dstRing_I);
+ f->flipRing=rCopy(dstRing);
+ rDelete(tmpRing);
+ rDelete(dstRing);
+ //Now we should have dstRing with (a(),a(),dp,C)
+ //This must be replaced with (a(),dp,C) BEFORE gcTmp is actually added to the list
+ //of cones in noRevS
+ rChangeCurrRing(srcRing);
#ifdef gfanp
- gettimeofday(&end, 0);
- time_flip2 += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+ gettimeofday(&end, 0);
+ time_flip2 += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
#endif
}//flip2
@@ -2168,58 +2166,58 @@ inline void gcone::flip2(const ideal &gb, facet *f)
/*inline*/ void gcone::computeInv(const ideal &gb, ideal &initialForm, const int64vec &fNormal)
{
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- for (int ii=0;ii<IDELEMS(gb);ii++)
- {
- poly initialFormElement;
- poly aktpoly = (poly)gb->m[ii];//Ptr, so don't pDelete(aktpoly)
- int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
- pGetExpV(aktpoly,leadExpV); //find the leading exponent in leadExpV[1],...,leadExpV[n], use pNext(p)
- initialFormElement=pHead(aktpoly);
-// int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
- while(pNext(aktpoly)!=NULL) /*loop trough terms and check for parallelity*/
- {
- int64vec *check = new int64vec(this->numVars);
- aktpoly=pNext(aktpoly); //next term
- int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
- pGetExpV(aktpoly,v);
- /* Convert (int)v into (int64vec)check */
-// bool notPar=FALSE;
- for (int jj=0;jj<this->numVars;jj++)
- {
- (*check)[jj]=v[jj+1]-leadExpV[jj+1];
-// register int64 foo=(fNormal)[jj];
-// if( ( (*check)[jj] == /*fNormal[jj]*/foo )
-// || ( (/*fNormal[jj]*/foo!=0) && ( ( (*check)[jj] % /*fNormal[jj]*/foo ) !=0 ) ) )
-// {
-// notPar=TRUE;
-// break;
-// }
- }
- omFree(v);
- if (isParallel(*check,fNormal))//Found a parallel vector. Add it
-// if(notPar==FALSE)
- {
- initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly));//pAdd = p_Add_q destroys args
- }
- delete check;
- }//while
-// omFree(v);
+ for (int ii=0;ii<IDELEMS(gb);ii++)
+ {
+ poly initialFormElement;
+ poly aktpoly = (poly)gb->m[ii];//Ptr, so don't pDelete(aktpoly)
+ int *leadExpV=(int *)omAlloc((this->numVars+1)*sizeof(int));
+ pGetExpV(aktpoly,leadExpV); //find the leading exponent in leadExpV[1],...,leadExpV[n], use pNext(p)
+ initialFormElement=pHead(aktpoly);
+// int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
+ while(pNext(aktpoly)!=NULL) /*loop trough terms and check for parallelity*/
+ {
+ int64vec *check = new int64vec(this->numVars);
+ aktpoly=pNext(aktpoly); //next term
+ int *v=(int *)omAlloc((this->numVars+1)*sizeof(int));
+ pGetExpV(aktpoly,v);
+ /* Convert (int)v into (int64vec)check */
+// bool notPar=FALSE;
+ for (int jj=0;jj<this->numVars;jj++)
+ {
+ (*check)[jj]=v[jj+1]-leadExpV[jj+1];
+// register int64 foo=(fNormal)[jj];
+// if( ( (*check)[jj] == /*fNormal[jj]*/foo )
+// || ( (/*fNormal[jj]*/foo!=0) && ( ( (*check)[jj] % /*fNormal[jj]*/foo ) !=0 ) ) )
+// {
+// notPar=TRUE;
+// break;
+// }
+ }
+ omFree(v);
+ if (isParallel(*check,fNormal))//Found a parallel vector. Add it
+// if(notPar==FALSE)
+ {
+ initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly));//pAdd = p_Add_q destroys args
+ }
+ delete check;
+ }//while
+// omFree(v);
#ifndef NDEBUG
-// cout << "Initial Form=";
-// pWrite(initialFormElement[ii]);
-// cout << "---" << endl;
+// cout << "Initial Form=";
+// pWrite(initialFormElement[ii]);
+// cout << "---" << endl;
#endif
- /*Now initialFormElement must be added to (ideal)initialForm */
- initialForm->m[ii]=pCopy(initialFormElement);
- pDelete(&initialFormElement);
- omFree(leadExpV);
- }//for
+ /*Now initialFormElement must be added to (ideal)initialForm */
+ initialForm->m[ii]=pCopy(initialFormElement);
+ pDelete(&initialFormElement);
+ omFree(leadExpV);
+ }//for
#ifdef gfanp
- gettimeofday(&end, 0);
- time_computeInv += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+ gettimeofday(&end, 0);
+ time_computeInv += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
#endif
}
@@ -2233,36 +2231,36 @@ inline void gcone::flip2(const ideal &gb, facet *f)
//NOTE: Should be replaced by kNF or kNF2
//NOTE: Done
//NOTE: removed with r12286
-
+
/** \brief Compute \f$ f-f^{\mathcal{G}} \f$
*/
//NOTE: use kNF or kNF2 instead of restOfDivision
inline ideal gcone::ffG(const ideal &H, const ideal &G)
{
- int size=IDELEMS(H);
- ideal res=idInit(size,1);
- for (int ii=0;ii<size;ii++)
- {
-// poly temp1;//=pInit();
-// poly temp2;//=pInit();
- poly temp3;//=pInit();//polys to temporarily store values for pSub
-// res->m[ii]=pCopy(kNF(G, NULL,H->m[ii],0,0));
-// temp1=pCopy(H->m[ii]);//TRY
-// temp2=pCopy(res->m[ii]);
- //NOTE if gfanHeuristic=0 (sic!) this results in dPolyErrors - mon from wrong ring
-// temp2=pCopy(kNF(G, NULL,H->m[ii],0,0));//TRY
-// temp3=pSub(temp1, temp2);//TRY
- temp3=pSub(pCopy(H->m[ii]),pCopy(kNF(G,NULL,H->m[ii],0,0)));//NOTRY
- res->m[ii]=pCopy(temp3);
- //res->m[ii]=pSub(temp1,temp2); //buggy
- //cout << "res->m["<<ii<<"]=";pWrite(res->m[ii]);
-// pDelete(&temp1);//TRY
-// pDelete(&temp2);
- pDelete(&temp3);
- }
- return res;
+ int size=IDELEMS(H);
+ ideal res=idInit(size,1);
+ for (int ii=0;ii<size;ii++)
+ {
+// poly temp1;//=pInit();
+// poly temp2;//=pInit();
+ poly temp3;//=pInit();//polys to temporarily store values for pSub
+// res->m[ii]=pCopy(kNF(G, NULL,H->m[ii],0,0));
+// temp1=pCopy(H->m[ii]);//TRY
+// temp2=pCopy(res->m[ii]);
+ //NOTE if gfanHeuristic=0 (sic!) this results in dPolyErrors - mon from wrong ring
+// temp2=pCopy(kNF(G, NULL,H->m[ii],0,0));//TRY
+// temp3=pSub(temp1, temp2);//TRY
+ temp3=pSub(pCopy(H->m[ii]),pCopy(kNF(G,NULL,H->m[ii],0,0)));//NOTRY
+ res->m[ii]=pCopy(temp3);
+ //res->m[ii]=pSub(temp1,temp2); //buggy
+ //cout << "res->m["<<ii<<"]=";pWrite(res->m[ii]);
+// pDelete(&temp1);//TRY
+// pDelete(&temp2);
+ pDelete(&temp3);
+ }
+ return res;
}
-
+
/** \brief Preprocessing of inequlities
* Do some preprocessing on the matrix of inequalities
* 1) Replace several constraints on the pos. orthants by just one for each orthant
@@ -2271,242 +2269,242 @@ inline ideal gcone::ffG(const ideal &H, const ideal &G)
*/
void gcone::preprocessInequalities(dd_MatrixPtr &ddineq)
{
-/* int *posRowsArray=NULL;
- int num_alloc=0;
- int num_elts=0;
- int offset=0;*/
- //Remove zeroes (and strictly pos rows?)
- for(int ii=0;ii<ddineq->rowsize;ii++)
- {
- int64vec *iv = new int64vec(this->numVars);
- int64vec *ivNull = new int64vec(this->numVars);//Needed for intvec64::compare(*int64vec)
- int posCtr=0;
- for(int jj=0;jj<this->numVars;jj++)
- {
- (*iv)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
- if((*iv)[jj]>0)//check for strictly pos rows
- posCtr++;
- //Behold! This will delete the row for the standard simplex!
- }
-// if( (iv->compare(0)==0) || (posCtr==iv->length()) )
- if( (posCtr==iv->length()) || (iv->compare(ivNull)==0) )
- {
- dd_MatrixRowRemove(&ddineq,ii+1);
- ii--;//Yes. This is on purpose
- }
- delete iv;
- delete ivNull;
- }
- //Remove duplicates of rows
-// posRowsArray=NULL;
-// num_alloc=0;
-// num_elts=0;
-// offset=0;
-// int num_newRows = ddineq->rowsize;
-// for(int ii=0;ii<ddineq->rowsize-1;ii++)
-// for(int ii=0;ii<num_newRows-1;ii++)
-// {
-// int64vec *iv = new int64vec(this->numVars);//1st vector to check against
-// for(int jj=0;jj<this->numVars;jj++)
-// (*iv)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
-// for(int jj=ii+1;jj</*ddineq->rowsize*/num_newRows;jj++)
-// {
-// int64vec *ivCheck = new int64vec(this->numVars);//Checked against iv
-// for(int kk=0;kk<this->numVars;kk++)
-// (*ivCheck)[kk]=(int)mpq_get_d(ddineq->matrix[jj][kk+1]);
-// if (iv->compare(ivCheck)==0)
-// {
-// // cout << "=" << endl;
-// // num_alloc++;
-// // void *tmp=realloc(posRowsArray,(num_alloc*sizeof(int)));
-// // if(!tmp)
-// // {
-// // WerrorS("Woah dude! Couldn't realloc memory\n");
-// // exit(-1);
-// // }
-// // posRowsArray = (int*)tmp;
-// // posRowsArray[num_elts]=jj;
-// // num_elts++;
-// dd_MatrixRowRemove(&ddineq,jj+1);
-// num_newRows = ddineq->rowsize;
-// }
-// delete ivCheck;
-// }
-// delete iv;
-// }
-// for(int ii=0;ii<num_elts;ii++)
-// {
-// dd_MatrixRowRemove(&ddineq,posRowsArray[ii]+1-offset);
-// offset++;
-// }
-// free(posRowsArray);
- //Apply Thm 2.1 of JOTA Vol 53 No 1 April 1987*/
+/* int *posRowsArray=NULL;
+ int num_alloc=0;
+ int num_elts=0;
+ int offset=0;*/
+ //Remove zeroes (and strictly pos rows?)
+ for(int ii=0;ii<ddineq->rowsize;ii++)
+ {
+ int64vec *iv = new int64vec(this->numVars);
+ int64vec *ivNull = new int64vec(this->numVars);//Needed for intvec64::compare(*int64vec)
+ int posCtr=0;
+ for(int jj=0;jj<this->numVars;jj++)
+ {
+ (*iv)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
+ if((*iv)[jj]>0)//check for strictly pos rows
+ posCtr++;
+ //Behold! This will delete the row for the standard simplex!
+ }
+// if( (iv->compare(0)==0) || (posCtr==iv->length()) )
+ if( (posCtr==iv->length()) || (iv->compare(ivNull)==0) )
+ {
+ dd_MatrixRowRemove(&ddineq,ii+1);
+ ii--;//Yes. This is on purpose
+ }
+ delete iv;
+ delete ivNull;
+ }
+ //Remove duplicates of rows
+// posRowsArray=NULL;
+// num_alloc=0;
+// num_elts=0;
+// offset=0;
+// int num_newRows = ddineq->rowsize;
+// for(int ii=0;ii<ddineq->rowsize-1;ii++)
+// for(int ii=0;ii<num_newRows-1;ii++)
+// {
+// int64vec *iv = new int64vec(this->numVars);//1st vector to check against
+// for(int jj=0;jj<this->numVars;jj++)
+// (*iv)[jj]=(int)mpq_get_d(ddineq->matrix[ii][jj+1]);
+// for(int jj=ii+1;jj</*ddineq->rowsize*/num_newRows;jj++)
+// {
+// int64vec *ivCheck = new int64vec(this->numVars);//Checked against iv
+// for(int kk=0;kk<this->numVars;kk++)
+// (*ivCheck)[kk]=(int)mpq_get_d(ddineq->matrix[jj][kk+1]);
+// if (iv->compare(ivCheck)==0)
+// {
+// // cout << "=" << endl;
+// // num_alloc++;
+// // void *tmp=realloc(posRowsArray,(num_alloc*sizeof(int)));
+// // if(!tmp)
+// // {
+// // WerrorS("Woah dude! Couldn't realloc memory\n");
+// // exit(-1);
+// // }
+// // posRowsArray = (int*)tmp;
+// // posRowsArray[num_elts]=jj;
+// // num_elts++;
+// dd_MatrixRowRemove(&ddineq,jj+1);
+// num_newRows = ddineq->rowsize;
+// }
+// delete ivCheck;
+// }
+// delete iv;
+// }
+// for(int ii=0;ii<num_elts;ii++)
+// {
+// dd_MatrixRowRemove(&ddineq,posRowsArray[ii]+1-offset);
+// offset++;
+// }
+// free(posRowsArray);
+ //Apply Thm 2.1 of JOTA Vol 53 No 1 April 1987*/
}//preprocessInequalities
-
+
/** \brief Compute a Groebner Basis
*
* Computes the Groebner basis and stores the result in gcone::gcBasis
*\param ideal
*\return void
*/
-inline void gcone::getGB(const ideal &inputIdeal)
+inline void gcone::getGB(const ideal &inputIdeal)
{
- BITSET save=test;
- test|=Sy_bit(OPT_REDSB);
- test|=Sy_bit(OPT_REDTAIL);
- ideal gb;
- gb=kStd(inputIdeal,NULL,testHomog,NULL);
- idNorm(gb);
- idSkipZeroes(gb);
- this->gcBasis=gb; //write the GB into gcBasis
- test=save;
+ BITSET save=test;
+ test|=Sy_bit(OPT_REDSB);
+ test|=Sy_bit(OPT_REDTAIL);
+ ideal gb;
+ gb=kStd(inputIdeal,NULL,testHomog,NULL);
+ idNorm(gb);
+ idSkipZeroes(gb);
+ this->gcBasis=gb; //write the GB into gcBasis
+ test=save;
}//void getGB
-
+
/** \brief Compute the negative of a given int64vec
- */
+ */
static int64vec* ivNeg(/*const*/int64vec *iv)
-{ //Hm, switching to int64vec const int64vec does no longer work
- int64vec *res;// = new int64vec(iv->length());
- res=iv64Copy(iv);
- *res *= (int)-1;
- return res;
+{ //Hm, switching to int64vec const int64vec does no longer work
+ int64vec *res;// = new int64vec(iv->length());
+ res=iv64Copy(iv);
+ *res *= (int)-1;
+ return res;
}
/** \brief Compute the dot product of two intvecs
*
*/
-static int dotProduct(const int64vec &iva, const int64vec &ivb)
-{
- int res=0;
- for (int i=0;i<pVariables;i++)
- {
+static int dotProduct(const int64vec &iva, const int64vec &ivb)
+{
+ int res=0;
+ for (int i=0;i<pVariables;i++)
+ {
// #ifndef NDEBUG
-// (const_cast<int64vec*>(&iva))->show(1,0); (const_cast<int64vec*>(&ivb))->show(1,0);
+// (const_cast<int64vec*>(&iva))->show(1,0); (const_cast<int64vec*>(&ivb))->show(1,0);
// #endif
- res = res+(iva[i]*ivb[i]);
- }
- return res;
+ res = res+(iva[i]*ivb[i]);
+ }
+ return res;
}
/** \brief Check whether two intvecs are parallel
*
* \f$ \alpha\parallel\beta\Leftrightarrow\langle\alpha,\beta\rangle^2=\langle\alpha,\alpha\rangle\langle\beta,\beta\rangle \f$
*/
static bool isParallel(const int64vec &a,const int64vec &b)
-{
- bool res;
- int lhs=dotProduct(a,b)*dotProduct(a,b);
- int rhs=dotProduct(a,a)*dotProduct(b,b);
- return res = (lhs==rhs)?TRUE:FALSE;
+{
+ bool res;
+ int lhs=dotProduct(a,b)*dotProduct(a,b);
+ int rhs=dotProduct(a,a)*dotProduct(b,b);
+ return res = (lhs==rhs)?TRUE:FALSE;
}
/** \brief Compute an interior point of a given cone
- * Result will be written into int64vec iv.
+ * Result will be written into int64vec iv.
* Any rational point is automatically converted into an integer.
*/
void gcone::interiorPoint( dd_MatrixPtr &M, int64vec &iv) //no const &M here since we want to remove redundant rows
{
- dd_LPPtr lp,lpInt;
- dd_ErrorType err=dd_NoError;
- dd_LPSolverType solver=dd_DualSimplex;
- dd_LPSolutionPtr lpSol=NULL;
-// dd_rowset ddlinset,ddredrows; //needed for dd_FindRelativeInterior
-// dd_rowindex ddnewpos;
- dd_NumberType numb;
- //M->representation=dd_Inequality;
-
- //NOTE: Make this n-dimensional!
- //dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1);
-
- /*NOTE: Leave the following line commented out!
- * Otherwise it will slow down computations a great deal
- * */
-// dd_MatrixCanonicalizeLinearity(&M, &ddlinset, &ddnewpos, &err);
- //if (err!=dd_NoError){cout << "Error during dd_MatrixCanonicalize" << endl;}
- dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
- int jj=1;
- for (int ii=0;ii<this->numVars;ii++)
- {
- dd_set_si(posRestr->matrix[ii][jj],1);
- jj++;
- }
- dd_MatrixAppendTo(&M,posRestr);
- dd_FreeMatrix(posRestr);
- lp=dd_Matrix2LP(M, &err);
- if (err!=dd_NoError){WerrorS("Error during dd_Matrix2LP in gcone::interiorPoint");}
- if (lp==NULL){WerrorS("LP is NULL");}
+ dd_LPPtr lp,lpInt;
+ dd_ErrorType err=dd_NoError;
+ dd_LPSolverType solver=dd_DualSimplex;
+ dd_LPSolutionPtr lpSol=NULL;
+// dd_rowset ddlinset,ddredrows; //needed for dd_FindRelativeInterior
+// dd_rowindex ddnewpos;
+ dd_NumberType numb;
+ //M->representation=dd_Inequality;
+
+ //NOTE: Make this n-dimensional!
+ //dd_set_si(M->rowvec[0],1);dd_set_si(M->rowvec[1],1);dd_set_si(M->rowvec[2],1);
+
+ /*NOTE: Leave the following line commented out!
+ * Otherwise it will slow down computations a great deal
+ * */
+// dd_MatrixCanonicalizeLinearity(&M, &ddlinset, &ddnewpos, &err);
+ //if (err!=dd_NoError){cout << "Error during dd_MatrixCanonicalize" << endl;}
+ dd_MatrixPtr posRestr=dd_CreateMatrix(this->numVars,this->numVars+1);
+ int jj=1;
+ for (int ii=0;ii<this->numVars;ii++)
+ {
+ dd_set_si(posRestr->matrix[ii][jj],1);
+ jj++;
+ }
+ dd_MatrixAppendTo(&M,posRestr);
+ dd_FreeMatrix(posRestr);
+ lp=dd_Matrix2LP(M, &err);
+ if (err!=dd_NoError){WerrorS("Error during dd_Matrix2LP in gcone::interiorPoint");}
+ if (lp==NULL){WerrorS("LP is NULL");}
#ifndef NDEBUG
-// dd_WriteLP(stdout,lp);
-#endif
-
- lpInt=dd_MakeLPforInteriorFinding(lp);
- if (err!=dd_NoError){WerrorS("Error during dd_MakeLPForInteriorFinding in gcone::interiorPoint");}
+// dd_WriteLP(stdout,lp);
+#endif
+
+ lpInt=dd_MakeLPforInteriorFinding(lp);
+ if (err!=dd_NoError){WerrorS("Error during dd_MakeLPForInteriorFinding in gcone::interiorPoint");}
#ifndef NDEBUG
-// dd_WriteLP(stdout,lpInt);
-#endif
-// dd_FindRelativeInterior(M,&ddlinset,&ddredrows,&lpSol,&err);
- if (err!=dd_NoError)
- {
- WerrorS("Error during dd_FindRelativeInterior in gcone::interiorPoint");
- dd_WriteErrorMessages(stdout, err);
- }
- dd_LPSolve(lpInt,solver,&err); //This will not result in a point from the relative interior
-// if (err!=dd_NoError){WerrorS("Error during dd_LPSolve");}
- lpSol=dd_CopyLPSolution(lpInt);
-// if (err!=dd_NoError){WerrorS("Error during dd_CopyLPSolution");}
+// dd_WriteLP(stdout,lpInt);
+#endif
+// dd_FindRelativeInterior(M,&ddlinset,&ddredrows,&lpSol,&err);
+ if (err!=dd_NoError)
+ {
+ WerrorS("Error during dd_FindRelativeInterior in gcone::interiorPoint");
+ dd_WriteErrorMessages(stdout, err);
+ }
+ dd_LPSolve(lpInt,solver,&err); //This will not result in a point from the relative interior
+// if (err!=dd_NoError){WerrorS("Error during dd_LPSolve");}
+ lpSol=dd_CopyLPSolution(lpInt);
+// if (err!=dd_NoError){WerrorS("Error during dd_CopyLPSolution");}
#ifndef NDEBUG
- printf("Interior point: ");
- for (int ii=1; ii<(lpSol->d)-1;ii++)
- {
- dd_WriteNumber(stdout,lpSol->sol[ii]);
- }
- printf("\n");
-#endif
- //NOTE The following strongly resembles parts of makeInt.
- //Maybe merge sometimes
- mpz_t kgV; mpz_init(kgV);
- mpz_set_str(kgV,"1",10);
- mpz_t den; mpz_init(den);
- mpz_t tmp; mpz_init(tmp);
- mpq_get_den(tmp,lpSol->sol[1]);
- for (int ii=1;ii<(lpSol->d)-1;ii++)
- {
- mpq_get_den(den,lpSol->sol[ii+1]);
- mpz_lcm(kgV,tmp,den);
- mpz_set(tmp, kgV);
- }
- mpq_t qkgV;
- mpq_init(qkgV);
- mpq_set_z(qkgV,kgV);
- for (int ii=1;ii<(lpSol->d)-1;ii++)
- {
- mpq_t product;
- mpq_init(product);
- mpq_mul(product,qkgV,lpSol->sol[ii]);
- iv[ii-1]=(int)mpz_get_d(mpq_numref(product));
- mpq_clear(product);
- }
+ printf("Interior point: ");
+ for (int ii=1; ii<(lpSol->d)-1;ii++)
+ {
+ dd_WriteNumber(stdout,lpSol->sol[ii]);
+ }
+ printf("\n");
+#endif
+ //NOTE The following strongly resembles parts of makeInt.
+ //Maybe merge sometimes
+ mpz_t kgV; mpz_init(kgV);
+ mpz_set_str(kgV,"1",10);
+ mpz_t den; mpz_init(den);
+ mpz_t tmp; mpz_init(tmp);
+ mpq_get_den(tmp,lpSol->sol[1]);
+ for (int ii=1;ii<(lpSol->d)-1;ii++)
+ {
+ mpq_get_den(den,lpSol->sol[ii+1]);
+ mpz_lcm(kgV,tmp,den);
+ mpz_set(tmp, kgV);
+ }
+ mpq_t qkgV;
+ mpq_init(qkgV);
+ mpq_set_z(qkgV,kgV);
+ for (int ii=1;ii<(lpSol->d)-1;ii++)
+ {
+ mpq_t product;
+ mpq_init(product);
+ mpq_mul(product,qkgV,lpSol->sol[ii]);
+ iv[ii-1]=(int)mpz_get_d(mpq_numref(product));
+ mpq_clear(product);
+ }
#ifndef NDEBUG
-// iv.show();
-// cout << endl;
+// iv.show();
+// cout << endl;
#endif
- mpq_clear(qkgV);
- mpz_clear(tmp);
- mpz_clear(den);
- mpz_clear(kgV);
-
- dd_FreeLPSolution(lpSol);
- dd_FreeLPData(lpInt);
- dd_FreeLPData(lp);
-// set_free(ddlinset);
-// set_free(ddredrows);
-
+ mpq_clear(qkgV);
+ mpz_clear(tmp);
+ mpz_clear(den);
+ mpz_clear(kgV);
+
+ dd_FreeLPSolution(lpSol);
+ dd_FreeLPData(lpInt);
+ dd_FreeLPData(lp);
+// set_free(ddlinset);
+// set_free(ddredrows);
+
}//void interiorPoint(dd_MatrixPtr const &M)
/** Computes an interior point of a cone by taking two interior points a,b from two different facets
* and then computing b+(a-b)/2
-* Of course this only works for flippable facets
-* Two cases may occur:
+* Of course this only works for flippable facets
+* Two cases may occur:
* 1st: There are only two facets who share the only strictly positive ray
* 2nd: There are at least two facets which have a distinct positive ray
* In the former case we use linear algebra to determine an interior point,
@@ -2515,279 +2513,279 @@ void gcone::interiorPoint( dd_MatrixPtr &M, int64vec &iv) //no const &M here sin
* Way too bad! The case may occur that the cone is spanned by three rays, of which only two are strictly
* positive => these lie in a plane and thus their sum is not from relative interior.
* So let's just sum up all rays, find one strictly positive and shift the point along that ray
-*
+*
* Used by noRevS
*NOTE no longer used nor maintained. MM Mar 9, 2010
*/
// void gcone::interiorPoint2()
// {//idPrint(this->gcBasis);
// #ifndef NDEBUG
-// if(this->ivIntPt!=NULL)
-// WarnS("Interior point already exists - ovrewriting!");
+// if(this->ivIntPt!=NULL)
+// WarnS("Interior point already exists - ovrewriting!");
// #endif
-// facet *f1 = this->facetPtr;
-// facet *f2 = NULL;
-// int64vec *intF1=NULL;
-// while(f1!=NULL)
-// {
-// if(f1->isFlippable)
-// {
-// facet *f1Ray = f1->codim2Ptr;
-// while(f1Ray!=NULL)
-// {
-// const int64vec *check=f1Ray->getRef2FacetNormal();
-// if(iv64isStrictlyPositive(check))
-// {
-// intF1=iv64Copy(check);
-// break;
-// }
-// f1Ray=f1Ray->next;
-// }
-// }
-// if(intF1!=NULL)
-// break;
-// f1=f1->next;
-// }
-// if(f1!=NULL && f1->next!=NULL)//Choose another facet, different from f1
-// f2=f1->next;
-// else
-// f2=this->facetPtr;
-// if(intF1==NULL && hasHomInput==TRUE)
-// {
-// intF1 = new int64vec(this->numVars);
-// for(int ii=0;ii<this->numVars;ii++)
-// (*intF1)[ii]=1;
-// }
-// assert(f1); assert(f2);
-// int64vec *intF2=f2->getInteriorPoint();
-// mpq_t *qPosRay = new mpq_t[this->numVars];//The positive ray from above
-// mpq_t *qIntPt = new mpq_t[this->numVars];//starting vector a+((b-a)/2)
-// mpq_t *qPosIntPt = new mpq_t[this->numVars];//This should be >0 eventually
-// for(int ii=0;ii<this->numVars;ii++)
-// {
-// mpq_init(qPosRay[ii]);
-// mpq_init(qIntPt[ii]);
-// mpq_init(qPosIntPt[ii]);
-// }
-// //Compute a+((b-a)/2) && Convert intF1 to mpq
-// for(int ii=0;ii<this->numVars;ii++)
-// {
-// mpq_t a,b;
-// mpq_init(a); mpq_init(b);
-// mpq_set_si(a,(*intF1)[ii],1);
-// mpq_set_si(b,(*intF2)[ii],1);
-// mpq_t diff;
-// mpq_init(diff);
-// mpq_sub(diff,b,a); //diff=b-a
-// mpq_t quot;
-// mpq_init(quot);
-// mpq_div_2exp(quot,diff,1); //quot=diff/2=(b-a)/2
-// mpq_clear(diff);
-// //Don't be clever and reuse diff here
-// mpq_t sum; mpq_init(sum);
-// mpq_add(sum,b,quot); //sum=b+quot=a+(b-a)/2
-// mpq_set(qIntPt[ii],sum);
-// mpq_clear(sum);
-// mpq_clear(quot);
-// mpq_clear(a); mpq_clear(b);
-// //Now for intF1
-// mpq_set_si(qPosRay[ii],(*intF1)[ii],1);
-// }
-// //Now add: qPosIntPt=qPosRay+qIntPt until qPosIntPt >0
-// while(TRUE)
-// {
-// bool success=FALSE;
-// int posCtr=0;
-// for(int ii=0;ii<this->numVars;ii++)
-// {
-// mpq_t sum; mpq_init(sum);
-// mpq_add(sum,qPosRay[ii],qIntPt[ii]);
-// mpq_set(qPosIntPt[ii],sum);
-// mpq_clear(sum);
-// if(mpq_sgn(qPosIntPt[ii])==1)
-// posCtr++;
-// }
-// if(posCtr==this->numVars)//qPosIntPt > 0
-// break;
-// else
-// {
-// mpq_t qTwo; mpq_init(qTwo);
-// mpq_set_ui(qTwo,2,1);
-// for(int jj=0;jj<this->numVars;jj++)
-// {
-// mpq_t tmp; mpq_init(tmp);
-// mpq_mul(tmp,qPosRay[jj],qTwo);
-// mpq_set( qPosRay[jj], tmp);
-// mpq_clear(tmp);
-// }
-// mpq_clear(qTwo);
-// }
-// }//while
-// //Now qPosIntPt ought to be >0, so convert back to int :D
-// /*Compute lcm of the denominators*/
-// mpz_t *denom = new mpz_t[this->numVars];
-// mpz_t tmp,kgV;
-// mpz_init(tmp); mpz_init(kgV);
-// for (int ii=0;ii<this->numVars;ii++)
-// {
-// mpz_t z;
-// mpz_init(z);
-// mpq_get_den(z,qPosIntPt[ii]);
-// mpz_init(denom[ii]);
-// mpz_set( denom[ii], z);
-// mpz_clear(z);
-// }
-//
-// mpz_set(tmp,denom[0]);
-// for (int ii=0;ii<this->numVars;ii++)
-// {
-// mpz_lcm(kgV,tmp,denom[ii]);
-// mpz_set(tmp,kgV);
-// }
-// mpz_clear(tmp);
-// /*Multiply the nominators by kgV*/
-// mpq_t qkgV,res;
-// mpq_init(qkgV);
-// mpq_canonicalize(qkgV);
-// mpq_init(res);
-// mpq_canonicalize(res);
-//
-// mpq_set_num(qkgV,kgV);
-// int64vec *n=new int64vec(this->numVars);
-// for (int ii=0;ii<this->numVars;ii++)
-// {
-// mpq_canonicalize(qPosIntPt[ii]);
-// mpq_mul(res,qkgV,qPosIntPt[ii]);
-// (*n)[ii]=(int)mpz_get_d(mpq_numref(res));
-// }
-// this->setIntPoint(n);
-// delete n;
-// delete [] qPosIntPt;
-// delete [] denom;
-// delete [] qPosRay;
-// delete [] qIntPt;
-// mpz_clear(kgV);
-// mpq_clear(qkgV); mpq_clear(res);
+// facet *f1 = this->facetPtr;
+// facet *f2 = NULL;
+// int64vec *intF1=NULL;
+// while(f1!=NULL)
+// {
+// if(f1->isFlippable)
+// {
+// facet *f1Ray = f1->codim2Ptr;
+// while(f1Ray!=NULL)
+// {
+// const int64vec *check=f1Ray->getRef2FacetNormal();
+// if(iv64isStrictlyPositive(check))
+// {
+// intF1=iv64Copy(check);
+// break;
+// }
+// f1Ray=f1Ray->next;
+// }
+// }
+// if(intF1!=NULL)
+// break;
+// f1=f1->next;
+// }
+// if(f1!=NULL && f1->next!=NULL)//Choose another facet, different from f1
+// f2=f1->next;
+// else
+// f2=this->facetPtr;
+// if(intF1==NULL && hasHomInput==TRUE)
+// {
+// intF1 = new int64vec(this->numVars);
+// for(int ii=0;ii<this->numVars;ii++)
+// (*intF1)[ii]=1;
+// }
+// assert(f1); assert(f2);
+// int64vec *intF2=f2->getInteriorPoint();
+// mpq_t *qPosRay = new mpq_t[this->numVars];//The positive ray from above
+// mpq_t *qIntPt = new mpq_t[this->numVars];//starting vector a+((b-a)/2)
+// mpq_t *qPosIntPt = new mpq_t[this->numVars];//This should be >0 eventually
+// for(int ii=0;ii<this->numVars;ii++)
+// {
+// mpq_init(qPosRay[ii]);
+// mpq_init(qIntPt[ii]);
+// mpq_init(qPosIntPt[ii]);
+// }
+// //Compute a+((b-a)/2) && Convert intF1 to mpq
+// for(int ii=0;ii<this->numVars;ii++)
+// {
+// mpq_t a,b;
+// mpq_init(a); mpq_init(b);
+// mpq_set_si(a,(*intF1)[ii],1);
+// mpq_set_si(b,(*intF2)[ii],1);
+// mpq_t diff;
+// mpq_init(diff);
+// mpq_sub(diff,b,a); //diff=b-a
+// mpq_t quot;
+// mpq_init(quot);
+// mpq_div_2exp(quot,diff,1); //quot=diff/2=(b-a)/2
+// mpq_clear(diff);
+// //Don't be clever and reuse diff here
+// mpq_t sum; mpq_init(sum);
+// mpq_add(sum,b,quot); //sum=b+quot=a+(b-a)/2
+// mpq_set(qIntPt[ii],sum);
+// mpq_clear(sum);
+// mpq_clear(quot);
+// mpq_clear(a); mpq_clear(b);
+// //Now for intF1
+// mpq_set_si(qPosRay[ii],(*intF1)[ii],1);
+// }
+// //Now add: qPosIntPt=qPosRay+qIntPt until qPosIntPt >0
+// while(TRUE)
+// {
+// bool success=FALSE;
+// int posCtr=0;
+// for(int ii=0;ii<this->numVars;ii++)
+// {
+// mpq_t sum; mpq_init(sum);
+// mpq_add(sum,qPosRay[ii],qIntPt[ii]);
+// mpq_set(qPosIntPt[ii],sum);
+// mpq_clear(sum);
+// if(mpq_sgn(qPosIntPt[ii])==1)
+// posCtr++;
+// }
+// if(posCtr==this->numVars)//qPosIntPt > 0
+// break;
+// else
+// {
+// mpq_t qTwo; mpq_init(qTwo);
+// mpq_set_ui(qTwo,2,1);
+// for(int jj=0;jj<this->numVars;jj++)
+// {
+// mpq_t tmp; mpq_init(tmp);
+// mpq_mul(tmp,qPosRay[jj],qTwo);
+// mpq_set( qPosRay[jj], tmp);
+// mpq_clear(tmp);
+// }
+// mpq_clear(qTwo);
+// }
+// }//while
+// //Now qPosIntPt ought to be >0, so convert back to int :D
+// /*Compute lcm of the denominators*/
+// mpz_t *denom = new mpz_t[this->numVars];
+// mpz_t tmp,kgV;
+// mpz_init(tmp); mpz_init(kgV);
+// for (int ii=0;ii<this->numVars;ii++)
+// {
+// mpz_t z;
+// mpz_init(z);
+// mpq_get_den(z,qPosIntPt[ii]);
+// mpz_init(denom[ii]);
+// mpz_set( denom[ii], z);
+// mpz_clear(z);
+// }
+//
+// mpz_set(tmp,denom[0]);
+// for (int ii=0;ii<this->numVars;ii++)
+// {
+// mpz_lcm(kgV,tmp,denom[ii]);
+// mpz_set(tmp,kgV);
+// }
+// mpz_clear(tmp);
+// /*Multiply the nominators by kgV*/
+// mpq_t qkgV,res;
+// mpq_init(qkgV);
+// mpq_canonicalize(qkgV);
+// mpq_init(res);
+// mpq_canonicalize(res);
+//
+// mpq_set_num(qkgV,kgV);
+// int64vec *n=new int64vec(this->numVars);
+// for (int ii=0;ii<this->numVars;ii++)
+// {
+// mpq_canonicalize(qPosIntPt[ii]);
+// mpq_mul(res,qkgV,qPosIntPt[ii]);
+// (*n)[ii]=(int)mpz_get_d(mpq_numref(res));
+// }
+// this->setIntPoint(n);
+// delete n;
+// delete [] qPosIntPt;
+// delete [] denom;
+// delete [] qPosRay;
+// delete [] qIntPt;
+// mpz_clear(kgV);
+// mpq_clear(qkgV); mpq_clear(res);
// }
-
+
/** \brief Copy a ring and add a weighted ordering in first place
- *
+ *
*/
-ring gcone::rCopyAndAddWeight(const ring &r, int64vec *ivw)
+ring gcone::rCopyAndAddWeight(const ring &r, int64vec *ivw)
{
- ring res=rCopy0(r);
- int jj;
-
- omFree(res->order);
- res->order =(int *)omAlloc0(4*sizeof(int/*64*/));
- omFree(res->block0);
- res->block0=(int *)omAlloc0(4*sizeof(int/*64*/));
- omFree(res->block1);
- res->block1=(int *)omAlloc0(4*sizeof(int/*64*/));
- omfree(res->wvhdl);
- res->wvhdl =(int **)omAlloc0(4*sizeof(int/*64*/**));
-
- res->order[0]=ringorder_a/*64*/;
- res->block0[0]=1;
- res->block1[0]=res->N;
- res->order[1]=ringorder_dp; //basically useless, since that should never be used
- res->block0[1]=1;
- res->block1[1]=res->N;
- res->order[2]=ringorder_C;
-
- int length=ivw->length();
- int/*64*/ *A=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
- for (jj=0;jj<length;jj++)
- {
- A[jj]=(*ivw)[jj];
- if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight!\n");
- }
- res->wvhdl[0]=(int *)A;
- res->block1[0]=length;
-
- rComplete(res);
- return res;
+ ring res=rCopy0(r);
+ int jj;
+
+ omFree(res->order);
+ res->order =(int *)omAlloc0(4*sizeof(int/*64*/));
+ omFree(res->block0);
+ res->block0=(int *)omAlloc0(4*sizeof(int/*64*/));
+ omFree(res->block1);
+ res->block1=(int *)omAlloc0(4*sizeof(int/*64*/));
+ omfree(res->wvhdl);
+ res->wvhdl =(int **)omAlloc0(4*sizeof(int/*64*/**));
+
+ res->order[0]=ringorder_a/*64*/;
+ res->block0[0]=1;
+ res->block1[0]=res->N;
+ res->order[1]=ringorder_dp; //basically useless, since that should never be used
+ res->block0[1]=1;
+ res->block1[1]=res->N;
+ res->order[2]=ringorder_C;
+
+ int length=ivw->length();
+ int/*64*/ *A=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
+ for (jj=0;jj<length;jj++)
+ {
+ A[jj]=(*ivw)[jj];
+ if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight!\n");
+ }
+ res->wvhdl[0]=(int *)A;
+ res->block1[0]=length;
+
+ rComplete(res);
+ return res;
}//rCopyAndAdd
-
-ring gcone::rCopyAndAddWeight2(const ring &r,const int64vec *ivw, const int64vec *fNormal)
+
+ring gcone::rCopyAndAddWeight2(const ring &r,const int64vec *ivw, const int64vec *fNormal)
{
- ring res=rCopy0(r);
-
- omFree(res->order);
- res->order =(int *)omAlloc0(5*sizeof(int/*64*/));
- omFree(res->block0);
- res->block0=(int *)omAlloc0(5*sizeof(int/*64*/));
- omFree(res->block1);
- res->block1=(int *)omAlloc0(5*sizeof(int/*64*/));
- omfree(res->wvhdl);
- res->wvhdl =(int **)omAlloc0(5*sizeof(int/*64*/**));
-
- res->order[0]=ringorder_a/*64*/;
- res->block0[0]=1;
- res->block1[0]=res->N;
- res->order[1]=ringorder_a/*64*/;
- res->block0[1]=1;
- res->block1[1]=res->N;
-
- res->order[2]=ringorder_dp;
- res->block0[2]=1;
- res->block1[2]=res->N;
-
- res->order[3]=ringorder_C;
-
- int length=ivw->length();
- int/*64*/ *A1=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
- int/*64*/ *A2=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
- for (int jj=0;jj<length;jj++)
- {
- A1[jj]=(*ivw)[jj];
- A2[jj]=-(*fNormal)[jj];
- if((*ivw)[jj]>=INT_MAX || (*fNormal)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight2!\n");
- }
- res->wvhdl[0]=(int *)A1;
- res->block1[0]=length;
- res->wvhdl[1]=(int *)A2;
- res->block1[1]=length;
- rComplete(res);
- return res;
+ ring res=rCopy0(r);
+
+ omFree(res->order);
+ res->order =(int *)omAlloc0(5*sizeof(int/*64*/));
+ omFree(res->block0);
+ res->block0=(int *)omAlloc0(5*sizeof(int/*64*/));
+ omFree(res->block1);
+ res->block1=(int *)omAlloc0(5*sizeof(int/*64*/));
+ omfree(res->wvhdl);
+ res->wvhdl =(int **)omAlloc0(5*sizeof(int/*64*/**));
+
+ res->order[0]=ringorder_a/*64*/;
+ res->block0[0]=1;
+ res->block1[0]=res->N;
+ res->order[1]=ringorder_a/*64*/;
+ res->block0[1]=1;
+ res->block1[1]=res->N;
+
+ res->order[2]=ringorder_dp;
+ res->block0[2]=1;
+ res->block1[2]=res->N;
+
+ res->order[3]=ringorder_C;
+
+ int length=ivw->length();
+ int/*64*/ *A1=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
+ int/*64*/ *A2=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
+ for (int jj=0;jj<length;jj++)
+ {
+ A1[jj]=(*ivw)[jj];
+ A2[jj]=-(*fNormal)[jj];
+ if((*ivw)[jj]>=INT_MAX || (*fNormal)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight2!\n");
+ }
+ res->wvhdl[0]=(int *)A1;
+ res->block1[0]=length;
+ res->wvhdl[1]=(int *)A2;
+ res->block1[1]=length;
+ rComplete(res);
+ return res;
}
-
+
//NOTE not needed anywhere
// ring rCopyAndChangeWeight(ring const &r, int64vec *ivw)
// {
-// ring res=rCopy0(currRing);
-// rComplete(res);
-// rSetWeightVec(res,(int64*)ivw);
-// //rChangeCurrRing(rnew);
-// return res;
+// ring res=rCopy0(currRing);
+// rComplete(res);
+// rSetWeightVec(res,(int64*)ivw);
+// //rChangeCurrRing(rnew);
+// return res;
// }
-
+
/** \brief Checks whether a given facet is a search facet
* Determines whether a given facet of a cone is the search facet of a neighbouring cone
* This is done in the following way:
* We loop through all facets of the cone and find the "smallest" facet, i.e. the unique facet
* that is first crossed during the generic walk.
* We then check whether the fNormal of this facet is parallel to the fNormal of our testfacet.
- * If this is the case, then our facet is indeed a search facet and TRUE is retuned.
+ * If this is the case, then our facet is indeed a search facet and TRUE is retuned.
*/
//removed with r12286
-
+
/** \brief Check for equality of two intvecs
*/
static bool ivAreEqual(const int64vec &a, const int64vec &b)
{
- bool res=TRUE;
- for(int ii=0;ii<pVariables;ii++)
- {
- if(a[ii]!=b[ii])
- {
- res=FALSE;
- break;
- }
- }
- return res;
+ bool res=TRUE;
+ for(int ii=0;ii<pVariables;ii++)
+ {
+ if(a[ii]!=b[ii])
+ {
+ res=FALSE;
+ break;
+ }
+ }
+ return res;
}
-
+
/** \brief The reverse search algorithm
*/
//removed with r12286
@@ -2797,111 +2795,111 @@ static bool ivAreEqual(const int64vec &a, const int64vec &b)
*/
dd_MatrixPtr gcone::computeLinealitySpace()
{
- dd_MatrixPtr res;
- dd_MatrixPtr ddineq;
- ddineq=dd_CopyMatrix(this->ddFacets);
- //Add a row of 0s in 0th place
- dd_MatrixPtr ddAppendRowOfZeroes=dd_CreateMatrix(1,this->numVars+1);
- dd_MatrixPtr ddFoo=dd_AppendMatrix(ddAppendRowOfZeroes,ddineq);
- dd_FreeMatrix(ddAppendRowOfZeroes);
- dd_FreeMatrix(ddineq);
- ddineq=dd_CopyMatrix(ddFoo);
- dd_FreeMatrix(ddFoo);
- //Cohen starts here
- int dimKer=0;//Cohen calls this r
- int m=ddineq->rowsize;//Rows
- int n=ddineq->colsize;//Cols
- int c[m+1];
- int d[n+1];
- for(int ii=0;ii<m;ii++)
- c[ii]=0;
- for(int ii=0;ii<n;ii++)
- d[ii]=0;
-
- for(int k=1;k<n;k++)
- {
- //Let's find a j s.t. m[j][k]!=0 && c[j]=0
- int condCtr=0;//Check each row for zeroness
- for(int j=1;j<m;j++)
- {
- if(mpq_sgn(ddineq->matrix[j][k])!=0 && c[j]==0)
- {
- mpq_t quot; mpq_init(quot);
- mpq_t one; mpq_init(one); mpq_set_str(one,"-1",10);
- mpq_t ratd; mpq_init(ratd);
- if((int)mpq_get_d(ddineq->matrix[j][k])!=0)
- mpq_div(quot,one,ddineq->matrix[j][k]);
- mpq_set(ratd,quot);
- mpq_canonicalize(ratd);
-
- mpq_set_str(ddineq->matrix[j][k],"-1",10);
- for(int ss=k+1;ss<n;ss++)
- {
- mpq_t prod; mpq_init(prod);
- mpq_mul(prod, ratd, ddineq->matrix[j][ss]);
- mpq_set(ddineq->matrix[j][ss],prod);
- mpq_canonicalize(ddineq->matrix[j][ss]);
- mpq_clear(prod);
- }
- for(int ii=1;ii<m;ii++)
- {
- if(ii!=j)
- {
- mpq_set(ratd,ddineq->matrix[ii][k]);
- mpq_set_str(ddineq->matrix[ii][k],"0",10);
- for(int ss=k+1;ss<n;ss++)
- {
- mpq_t prod; mpq_init(prod);
- mpq_mul(prod, ratd, ddineq->matrix[j][ss]);
- mpq_t sum; mpq_init(sum);
- mpq_add(sum, ddineq->matrix[ii][ss], prod);
- mpq_set(ddineq->matrix[ii][ss], sum);
- mpq_canonicalize(ddineq->matrix[ii][ss]);
- mpq_clear(prod);
- mpq_clear(sum);
- }
- }
- }
- c[j]=k;
- d[k]=j;
- mpq_clear(quot); mpq_clear(ratd); mpq_clear(one);
- }
- else
- condCtr++;
- }
- if(condCtr==m-1) //Why -1 ???
- {
- dimKer++;
- d[k]=0;
-// break;//goto _4;
- }//else{
- /*Eliminate*/
- }//for(k
- /*Output kernel, i.e. set gcone::dd_LinealitySpace here*/
-// gcone::dd_LinealitySpace = dd_CreateMatrix(dimKer,this->numVars+1);
- res = dd_CreateMatrix(dimKer,this->numVars+1);
- int row=-1;
- for(int kk=1;kk<n;kk++)
- {
- if(d[kk]==0)
- {
- row++;
- for(int ii=1;ii<n;ii++)
- {
- if(d[ii]>0)
- mpq_set(res->matrix[row][ii],ddineq->matrix[d[ii]][kk]);
- else if(ii==kk)
- mpq_set_str(res->matrix[row][ii],"1",10);
- mpq_canonicalize(res->matrix[row][ii]);
- }
- }
- }
- dd_FreeMatrix(ddineq);
- return(res);
- //Better safe than sorry:
- //NOTE dd_LinealitySpace contains RATIONAL ENTRIES
- //Therefore if you need integer ones: CALL gcone::makeInt(...) method
-}
+ dd_MatrixPtr res;
+ dd_MatrixPtr ddineq;
+ ddineq=dd_CopyMatrix(this->ddFacets);
+ //Add a row of 0s in 0th place
+ dd_MatrixPtr ddAppendRowOfZeroes=dd_CreateMatrix(1,this->numVars+1);
+ dd_MatrixPtr ddFoo=dd_AppendMatrix(ddAppendRowOfZeroes,ddineq);
+ dd_FreeMatrix(ddAppendRowOfZeroes);
+ dd_FreeMatrix(ddineq);
+ ddineq=dd_CopyMatrix(ddFoo);
+ dd_FreeMatrix(ddFoo);
+ //Cohen starts here
+ int dimKer=0;//Cohen calls this r
+ int m=ddineq->rowsize;//Rows
+ int n=ddineq->colsize;//Cols
+ int c[m+1];
+ int d[n+1];
+ for(int ii=0;ii<m;ii++)
+ c[ii]=0;
+ for(int ii=0;ii<n;ii++)
+ d[ii]=0;
+
+ for(int k=1;k<n;k++)
+ {
+ //Let's find a j s.t. m[j][k]!=0 && c[j]=0
+ int condCtr=0;//Check each row for zeroness
+ for(int j=1;j<m;j++)
+ {
+ if(mpq_sgn(ddineq->matrix[j][k])!=0 && c[j]==0)
+ {
+ mpq_t quot; mpq_init(quot);
+ mpq_t one; mpq_init(one); mpq_set_str(one,"-1",10);
+ mpq_t ratd; mpq_init(ratd);
+ if((int)mpq_get_d(ddineq->matrix[j][k])!=0)
+ mpq_div(quot,one,ddineq->matrix[j][k]);
+ mpq_set(ratd,quot);
+ mpq_canonicalize(ratd);
+
+ mpq_set_str(ddineq->matrix[j][k],"-1",10);
+ for(int ss=k+1;ss<n;ss++)
+ {
+ mpq_t prod; mpq_init(prod);
+ mpq_mul(prod, ratd, ddineq->matrix[j][ss]);
+ mpq_set(ddineq->matrix[j][ss],prod);
+ mpq_canonicalize(ddineq->matrix[j][ss]);
+ mpq_clear(prod);
+ }
+ for(int ii=1;ii<m;ii++)
+ {
+ if(ii!=j)
+ {
+ mpq_set(ratd,ddineq->matrix[ii][k]);
+ mpq_set_str(ddineq->matrix[ii][k],"0",10);
+ for(int ss=k+1;ss<n;ss++)
+ {
+ mpq_t prod; mpq_init(prod);
+ mpq_mul(prod, ratd, ddineq->matrix[j][ss]);
+ mpq_t sum; mpq_init(sum);
+ mpq_add(sum, ddineq->matrix[ii][ss], prod);
+ mpq_set(ddineq->matrix[ii][ss], sum);
+ mpq_canonicalize(ddineq->matrix[ii][ss]);
+ mpq_clear(prod);
+ mpq_clear(sum);
+ }
+ }
+ }
+ c[j]=k;
+ d[k]=j;
+ mpq_clear(quot); mpq_clear(ratd); mpq_clear(one);
+ }
+ else
+ condCtr++;
+ }
+ if(condCtr==m-1) //Why -1 ???
+ {
+ dimKer++;
+ d[k]=0;
+// break;//goto _4;
+ }//else{
+ /*Eliminate*/
+ }//for(k
+ /*Output kernel, i.e. set gcone::dd_LinealitySpace here*/
+// gcone::dd_LinealitySpace = dd_CreateMatrix(dimKer,this->numVars+1);
+ res = dd_CreateMatrix(dimKer,this->numVars+1);
+ int row=-1;
+ for(int kk=1;kk<n;kk++)
+ {
+ if(d[kk]==0)
+ {
+ row++;
+ for(int ii=1;ii<n;ii++)
+ {
+ if(d[ii]>0)
+ mpq_set(res->matrix[row][ii],ddineq->matrix[d[ii]][kk]);
+ else if(ii==kk)
+ mpq_set_str(res->matrix[row][ii],"1",10);
+ mpq_canonicalize(res->matrix[row][ii]);
+ }
+ }
+ }
+ dd_FreeMatrix(ddineq);
+ return(res);
+ //Better safe than sorry:
+ //NOTE dd_LinealitySpace contains RATIONAL ENTRIES
+ //Therefore if you need integer ones: CALL gcone::makeInt(...) method
+}
/** \brief The new method of Markwig and Jensen
@@ -2912,303 +2910,303 @@ dd_MatrixPtr gcone::computeLinealitySpace()
* soon as we compute this facet again. Comparison of facets is done by...
*/
void gcone::noRevS(gcone &gcRoot, bool usingIntPoint)
-{
- facet *SearchListRoot = new facet(); //The list containing ALL facets we come across
- facet *SearchListAct;
- SearchListAct = NULL;
- //SearchListAct = SearchListRoot;
- gcone *gcAct;
- gcAct = &gcRoot;
- gcone *gcPtr; //Pointer to end of linked list of cones
- gcPtr = &gcRoot;
- gcone *gcNext; //Pointer to next cone to be visited
- gcNext = &gcRoot;
- gcone *gcHead;
- gcHead = &gcRoot;
- facet *fAct;
- fAct = gcAct->facetPtr;
- ring rAct;
- rAct = currRing;
- int UCNcounter=gcAct->getUCN();
+{
+ facet *SearchListRoot = new facet(); //The list containing ALL facets we come across
+ facet *SearchListAct;
+ SearchListAct = NULL;
+ //SearchListAct = SearchListRoot;
+ gcone *gcAct;
+ gcAct = &gcRoot;
+ gcone *gcPtr; //Pointer to end of linked list of cones
+ gcPtr = &gcRoot;
+ gcone *gcNext; //Pointer to next cone to be visited
+ gcNext = &gcRoot;
+ gcone *gcHead;
+ gcHead = &gcRoot;
+ facet *fAct;
+ fAct = gcAct->facetPtr;
+ ring rAct;
+ rAct = currRing;
+ int UCNcounter=gcAct->getUCN();
#ifndef NDEBUG
- printf("NoRevs\n");
- printf("Facets are:\n");
- gcAct->showFacets();
-#endif
- /*Compute lineality space here
- * Afterwards static dd_MatrixPtr gcone::dd_LinealitySpace is set*/
- if(dd_LinealitySpace==NULL)
- dd_LinealitySpace = gcAct->computeLinealitySpace();
- /*End of lineality space computation*/
- //gcAct->getCodim2Normals(*gcAct);
- if(fAct->codim2Ptr==NULL)
- gcAct->getExtremalRays(*gcAct);
- /* Make a copy of the facet list of first cone
- Since the operations getCodim2Normals and normalize affect the facets
- we must not memcpy them before these ops! */
- /*facet *codim2Act; codim2Act = NULL;
- facet *sl2Root;
- facet *sl2Act;*/
- for(int ii=0;ii<this->numFacets;ii++)
- {
- //only copy flippable facets! NOTE: We do not need flipRing or any such information.
- if(fAct->isFlippable==TRUE)
- {
- /*Using shallow copy here*/
+ printf("NoRevs\n");
+ printf("Facets are:\n");
+ gcAct->showFacets();
+#endif
+ /*Compute lineality space here
+ * Afterwards static dd_MatrixPtr gcone::dd_LinealitySpace is set*/
+ if(dd_LinealitySpace==NULL)
+ dd_LinealitySpace = gcAct->computeLinealitySpace();
+ /*End of lineality space computation*/
+ //gcAct->getCodim2Normals(*gcAct);
+ if(fAct->codim2Ptr==NULL)
+ gcAct->getExtremalRays(*gcAct);
+ /* Make a copy of the facet list of first cone
+ Since the operations getCodim2Normals and normalize affect the facets
+ we must not memcpy them before these ops! */
+ /*facet *codim2Act; codim2Act = NULL;
+ facet *sl2Root;
+ facet *sl2Act;*/
+ for(int ii=0;ii<this->numFacets;ii++)
+ {
+ //only copy flippable facets! NOTE: We do not need flipRing or any such information.
+ if(fAct->isFlippable==TRUE)
+ {
+ /*Using shallow copy here*/
#ifdef SHALLOW
- if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
- {
- if(SearchListRoot!=NULL) delete(SearchListRoot);
- SearchListRoot = fAct->shallowCopy(*fAct);
- SearchListAct = SearchListRoot; //SearchListRoot is already 'new'ed at beginning of method!
- }
- else
- {
- SearchListAct->next = fAct->shallowCopy(*fAct);
- SearchListAct = SearchListAct->next;
- }
- fAct=fAct->next;
+ if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
+ {
+ if(SearchListRoot!=NULL) delete(SearchListRoot);
+ SearchListRoot = fAct->shallowCopy(*fAct);
+ SearchListAct = SearchListRoot; //SearchListRoot is already 'new'ed at beginning of method!
+ }
+ else
+ {
+ SearchListAct->next = fAct->shallowCopy(*fAct);
+ SearchListAct = SearchListAct->next;
+ }
+ fAct=fAct->next;
#else
- /*End of shallow copy*/
- int64vec *fNormal;
- fNormal = fAct->getFacetNormal();
- if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
- {
- SearchListAct = SearchListRoot; //SearchListRoot is already 'new'ed at beginning of method!
- }
- else
- {
- SearchListAct->next = new facet();
- SearchListAct = SearchListAct->next;
- }
- SearchListAct->setFacetNormal(fNormal);
- SearchListAct->setUCN(this->getUCN());
- SearchListAct->numCodim2Facets=fAct->numCodim2Facets;
- SearchListAct->isFlippable=TRUE;
- //Copy int point as well
- int64vec *ivIntPt;
- ivIntPt = fAct->getInteriorPoint();
- SearchListAct->setInteriorPoint(ivIntPt);
- delete(ivIntPt);
- //Copy codim2-facets
- facet *codim2Act;
- codim2Act = NULL;
- facet *sl2Root;
- facet *sl2Act;
- codim2Act=fAct->codim2Ptr;
- SearchListAct->codim2Ptr = new facet(2);
- sl2Root = SearchListAct->codim2Ptr;
- sl2Act = sl2Root;
- for(int jj=0;jj<fAct->numCodim2Facets;jj++)
-// for(int jj=0;jj<fAct->numRays-1;jj++)
- {
- int64vec *f2Normal;
- f2Normal = codim2Act->getFacetNormal();
- if(jj==0)
- {
- sl2Act = sl2Root;
- sl2Act->setFacetNormal(f2Normal);
- }
- else
- {
- sl2Act->next = new facet(2);
- sl2Act = sl2Act->next;
- sl2Act->setFacetNormal(f2Normal);
- }
- delete f2Normal;
- codim2Act = codim2Act->next;
- }
- fAct = fAct->next;
- delete fNormal;
+ /*End of shallow copy*/
+ int64vec *fNormal;
+ fNormal = fAct->getFacetNormal();
+ if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
+ {
+ SearchListAct = SearchListRoot; //SearchListRoot is already 'new'ed at beginning of method!
+ }
+ else
+ {
+ SearchListAct->next = new facet();
+ SearchListAct = SearchListAct->next;
+ }
+ SearchListAct->setFacetNormal(fNormal);
+ SearchListAct->setUCN(this->getUCN());
+ SearchListAct->numCodim2Facets=fAct->numCodim2Facets;
+ SearchListAct->isFlippable=TRUE;
+ //Copy int point as well
+ int64vec *ivIntPt;
+ ivIntPt = fAct->getInteriorPoint();
+ SearchListAct->setInteriorPoint(ivIntPt);
+ delete(ivIntPt);
+ //Copy codim2-facets
+ facet *codim2Act;
+ codim2Act = NULL;
+ facet *sl2Root;
+ facet *sl2Act;
+ codim2Act=fAct->codim2Ptr;
+ SearchListAct->codim2Ptr = new facet(2);
+ sl2Root = SearchListAct->codim2Ptr;
+ sl2Act = sl2Root;
+ for(int jj=0;jj<fAct->numCodim2Facets;jj++)
+// for(int jj=0;jj<fAct->numRays-1;jj++)
+ {
+ int64vec *f2Normal;
+ f2Normal = codim2Act->getFacetNormal();
+ if(jj==0)
+ {
+ sl2Act = sl2Root;
+ sl2Act->setFacetNormal(f2Normal);
+ }
+ else
+ {
+ sl2Act->next = new facet(2);
+ sl2Act = sl2Act->next;
+ sl2Act->setFacetNormal(f2Normal);
+ }
+ delete f2Normal;
+ codim2Act = codim2Act->next;
+ }
+ fAct = fAct->next;
+ delete fNormal;
#endif
- }//if(fAct->isFlippable==TRUE)
- else {fAct = fAct->next;}
- }//End of copying facets into SLA
-
- SearchListAct = SearchListRoot; //Set to beginning of list
- /*Make SearchList doubly linked*/
+ }//if(fAct->isFlippable==TRUE)
+ else {fAct = fAct->next;}
+ }//End of copying facets into SLA
+
+ SearchListAct = SearchListRoot; //Set to beginning of list
+ /*Make SearchList doubly linked*/
#ifndef NDEBUG
#if SIZEOF_LONG==8
- while(SearchListAct!=(facet*)0xfefefefefefefefe && SearchListAct!=NULL)
- {
- if(SearchListAct->next!=(facet*)0xfefefefefefefefe && SearchListAct->next!=NULL){
+ while(SearchListAct!=(facet*)0xfefefefefefefefe && SearchListAct!=NULL)
+ {
+ if(SearchListAct->next!=(facet*)0xfefefefefefefefe && SearchListAct->next!=NULL){
#elif SIZEOF_LONG!=8
- while(SearchListAct!=(facet*)0xfefefefe)
- {
- if(SearchListAct->next!=(facet*)0xfefefefe){
+ while(SearchListAct!=(facet*)0xfefefefe)
+ {
+ if(SearchListAct->next!=(facet*)0xfefefefe){
#endif
#else
- while(SearchListAct!=NULL)
- {
- if(SearchListAct->next!=NULL){
+ while(SearchListAct!=NULL)
+ {
+ if(SearchListAct->next!=NULL){
#endif
- SearchListAct->next->prev = SearchListAct;
- }
- SearchListAct = SearchListAct->next;
- }
- SearchListAct = SearchListRoot; //Set to beginning of List
-
-// fAct = gcAct->facetPtr;//???
- gcAct->writeConeToFile(*gcAct);
- /*End of initialisation*/
-
- fAct = SearchListAct;
- /*2nd step
- Choose a facet from SearchList, flip it and forget the previous cone
- We always choose the first facet from SearchList as facet to be flipped
- */
- while( (SearchListAct!=NULL))//&& counter<490)
- {//NOTE See to it that the cone is only changed after ALL facets have been flipped!
- fAct = SearchListAct;
- while(fAct!=NULL)
-// while( (fAct->getUCN() == fAct->next->getUCN()) )
- { //Since SLA should only contain flippables there should be no need to check for that
- gcAct->flip2(gcAct->gcBasis,fAct);
- //NOTE rCopy needed?
- ring rTmp=rCopy(fAct->flipRing);
- rComplete(rTmp);
- rChangeCurrRing(rTmp);
- gcone *gcTmp = new gcone(*gcAct,*fAct);//copy constructor!
- /* Now gcTmp->gcBasis and gcTmp->baseRing are set from fAct->flipGB and fAct->flipRing.
- * Since we come at most once across a given facet from gcAct->facetPtr we can delete them.
- * NOTE: Can this cause trouble with the destructor?
- * Answer: Yes it bloody well does!
- * However I'd like to delete this data here, since if we have a cone with many many facets it
- * should pay to get rid of the flipGB as soon as possible.
- * Destructor must be equipped with necessary checks.
- */
- idDelete((ideal *)&fAct->flipGB);
- rDelete(fAct->flipRing);
- gcTmp->getConeNormals(gcTmp->gcBasis/*, FALSE*/);
-// gcTmp->getCodim2Normals(*gcTmp);
- gcTmp->getExtremalRays(*gcTmp);
- //NOTE Order rays lex here
- gcTmp->orderRays();
-// //NOTE If flip2 is used we need to get an interior point of gcTmp
-// // and replace gcTmp->baseRing with an appropriate ring with only
-// // one weight
-// gcTmp->interiorPoint2();
- gcTmp->replaceDouble_ringorder_a_ByASingleOne();
- //gcTmp->ddFacets should not be needed anymore, so
- dd_FreeMatrix(gcTmp->ddFacets);
+ SearchListAct->next->prev = SearchListAct;
+ }
+ SearchListAct = SearchListAct->next;
+ }
+ SearchListAct = SearchListRoot; //Set to beginning of List
+
+// fAct = gcAct->facetPtr;//???
+ gcAct->writeConeToFile(*gcAct);
+ /*End of initialisation*/
+
+ fAct = SearchListAct;
+ /*2nd step
+ Choose a facet from SearchList, flip it and forget the previous cone
+ We always choose the first facet from SearchList as facet to be flipped
+ */
+ while( (SearchListAct!=NULL))//&& counter<490)
+ {//NOTE See to it that the cone is only changed after ALL facets have been flipped!
+ fAct = SearchListAct;
+ while(fAct!=NULL)
+// while( (fAct->getUCN() == fAct->next->getUCN()) )
+ { //Since SLA should only contain flippables there should be no need to check for that
+ gcAct->flip2(gcAct->gcBasis,fAct);
+ //NOTE rCopy needed?
+ ring rTmp=rCopy(fAct->flipRing);
+ rComplete(rTmp);
+ rChangeCurrRing(rTmp);
+ gcone *gcTmp = new gcone(*gcAct,*fAct);//copy constructor!
+ /* Now gcTmp->gcBasis and gcTmp->baseRing are set from fAct->flipGB and fAct->flipRing.
+ * Since we come at most once across a given facet from gcAct->facetPtr we can delete them.
+ * NOTE: Can this cause trouble with the destructor?
+ * Answer: Yes it bloody well does!
+ * However I'd like to delete this data here, since if we have a cone with many many facets it
+ * should pay to get rid of the flipGB as soon as possible.
+ * Destructor must be equipped with necessary checks.
+ */
+ idDelete((ideal *)&fAct->flipGB);
+ rDelete(fAct->flipRing);
+ gcTmp->getConeNormals(gcTmp->gcBasis/*, FALSE*/);
+// gcTmp->getCodim2Normals(*gcTmp);
+ gcTmp->getExtremalRays(*gcTmp);
+ //NOTE Order rays lex here
+ gcTmp->orderRays();
+// //NOTE If flip2 is used we need to get an interior point of gcTmp
+// // and replace gcTmp->baseRing with an appropriate ring with only
+// // one weight
+// gcTmp->interiorPoint2();
+ gcTmp->replaceDouble_ringorder_a_ByASingleOne();
+ //gcTmp->ddFacets should not be needed anymore, so
+ dd_FreeMatrix(gcTmp->ddFacets);
#ifndef NDEBUG
-// gcTmp->showFacets(1);
+// gcTmp->showFacets(1);
#endif
- /*add facets to SLA here*/
+ /*add facets to SLA here*/
#ifdef SHALLOW
#ifndef NDEBUG
- printf("fActUCN before enq2: %i\n",fAct->getUCN());
+ printf("fActUCN before enq2: %i\n",fAct->getUCN());
#endif
- facet *tmp;
- tmp=gcTmp->enqueue2(SearchListRoot);
+ facet *tmp;
+ tmp=gcTmp->enqueue2(SearchListRoot);
#ifndef NDEBUG
- printf("\nheadUCN=%i\n",tmp->getUCN());
- printf("fActUCN after enq2: %i\n",fAct->getUCN());
+ printf("\nheadUCN=%i\n",tmp->getUCN());
+ printf("fActUCN after enq2: %i\n",fAct->getUCN());
#endif
- SearchListRoot=tmp;
- //SearchListRoot=gcTmp->enqueue2/*NewFacets*/(SearchListRoot);
-#else
- SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot);
+ SearchListRoot=tmp;
+ //SearchListRoot=gcTmp->enqueue2/*NewFacets*/(SearchListRoot);
+#else
+ SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot);
#endif //ifdef SHALLOW
-// gcTmp->writeConeToFile(*gcTmp);
- if(gfanHeuristic==1)
- {
- gcTmp->writeConeToFile(*gcTmp);
- idDelete((ideal*)&gcTmp->gcBasis);//Whonder why?
- rDelete(gcTmp->baseRing);
- }
+// gcTmp->writeConeToFile(*gcTmp);
+ if(gfanHeuristic==1)
+ {
+ gcTmp->writeConeToFile(*gcTmp);
+ idDelete((ideal*)&gcTmp->gcBasis);//Whonder why?
+ rDelete(gcTmp->baseRing);
+ }
#ifndef NDEBUG
- if(SearchListRoot!=NULL)
- showSLA(*SearchListRoot);
-#endif
- rChangeCurrRing(gcAct->baseRing);
- rDelete(rTmp);
- //doubly linked for easier removal
- gcTmp->prev = gcPtr;
- gcPtr->next=gcTmp;
- gcPtr=gcPtr->next;
- //Cleverly disguised exit condition follows
- if(fAct->getUCN() == fAct->next->getUCN())
- {
- printf("Switching UCN from %i to %i\n",fAct->getUCN(),fAct->next->getUCN());
- fAct=fAct->next;
- }
- else
- {
- //rDelete(gcAct->baseRing);
-// printf("break\n");
- break;
- }
-// fAct=fAct->next;
- }//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) );
- //Search for cone with smallest UCN
+ if(SearchListRoot!=NULL)
+ showSLA(*SearchListRoot);
+#endif
+ rChangeCurrRing(gcAct->baseRing);
+ rDelete(rTmp);
+ //doubly linked for easier removal
+ gcTmp->prev = gcPtr;
+ gcPtr->next=gcTmp;
+ gcPtr=gcPtr->next;
+ //Cleverly disguised exit condition follows
+ if(fAct->getUCN() == fAct->next->getUCN())
+ {
+ printf("Switching UCN from %i to %i\n",fAct->getUCN(),fAct->next->getUCN());
+ fAct=fAct->next;
+ }
+ else
+ {
+ //rDelete(gcAct->baseRing);
+// printf("break\n");
+ break;
+ }
+// fAct=fAct->next;
+ }//while( ( (fAct->next!=NULL) && (fAct->getUCN()==fAct->next->getUCN() ) ) );
+ //Search for cone with smallest UCN
#ifndef NDEBUG
- #if SIZEOF_LONG==8 //64 bit
- while(gcNext!=(gcone * const)0xfbfbfbfbfbfbfbfb && SearchListRoot!=NULL)
+ #if SIZEOF_LONG==8 //64 bit
+ while(gcNext!=(gcone * const)0xfbfbfbfbfbfbfbfb && SearchListRoot!=NULL)
#elif SIZEOF_LONG == 4
- while(gcNext!=(gcone * const)0xfbfbfbfb && SearchListRoot!=NULL)
+ while(gcNext!=(gcone * const)0xfbfbfbfb && SearchListRoot!=NULL)
#endif
#endif
#ifdef NDEBUG
- while(gcNext!=NULL && SearchListRoot!=NULL)
+ while(gcNext!=NULL && SearchListRoot!=NULL)
#endif
- {
- if( gcNext->getUCN() == SearchListRoot->getUCN() )
- {
- if(gfanHeuristic==0)
- {
- gcAct = gcNext;
- //Seems better to not to use rCopy here
-// rAct=rCopy(gcAct->baseRing);
- rAct=gcAct->baseRing;
- rComplete(rAct);
- rChangeCurrRing(rAct);
- break;
- }
- else if(gfanHeuristic==1)
- {
- gcone *gcDel;
- gcDel = gcAct;
- gcAct = gcNext;
- //Read st00f from file &
- //implant the GB into gcAct
- readConeFromFile(gcAct->getUCN(), gcAct);
- //Kill the baseRing but ONLY if it is not the ring the computation started in!
-// if(gcDel->getUCN()!=1)//WTF!? This causes the Mandelbug in gcone::areEqual(facet, facet)
-// rDelete(gcDel->baseRing);
-// rAct=rCopy(gcAct->baseRing);
- /*The ring change occurs in readConeFromFile, so as to
- assure that gcAct->gcBasis belongs to the right ring*/
- rAct=gcAct->baseRing;
- rComplete(rAct);
- rChangeCurrRing(rAct);
- break;
- }
- }
- else if(gcNext->getUCN() < SearchListRoot->getUCN() )
- {
- idDelete( (ideal*)&gcNext->gcBasis );
-// rDelete(gcNext->baseRing);//TODO Why does this crash?
- }
- /*else
- {
- if(gfanHeuristic==1)
- {
- gcone *gcDel;
- gcDel = gcNext;
- if(gcDel->getUCN()!=1)
- rDelete(gcDel->baseRing);
- }
- }*/
- gcNext = gcNext->next;
- }
- UCNcounter++;
- SearchListAct = SearchListRoot;
- }
- printf("\nFound %i cones - terminating\n", counter);
-}//void noRevS(gcone &gc)
-
-
+ {
+ if( gcNext->getUCN() == SearchListRoot->getUCN() )
+ {
+ if(gfanHeuristic==0)
+ {
+ gcAct = gcNext;
+ //Seems better to not to use rCopy here
+// rAct=rCopy(gcAct->baseRing);
+ rAct=gcAct->baseRing;
+ rComplete(rAct);
+ rChangeCurrRing(rAct);
+ break;
+ }
+ else if(gfanHeuristic==1)
+ {
+ gcone *gcDel;
+ gcDel = gcAct;
+ gcAct = gcNext;
+ //Read st00f from file &
+ //implant the GB into gcAct
+ readConeFromFile(gcAct->getUCN(), gcAct);
+ //Kill the baseRing but ONLY if it is not the ring the computation started in!
+// if(gcDel->getUCN()!=1)//WTF!? This causes the Mandelbug in gcone::areEqual(facet, facet)
+// rDelete(gcDel->baseRing);
+// rAct=rCopy(gcAct->baseRing);
+ /*The ring change occurs in readConeFromFile, so as to
+ assure that gcAct->gcBasis belongs to the right ring*/
+ rAct=gcAct->baseRing;
+ rComplete(rAct);
+ rChangeCurrRing(rAct);
+ break;
+ }
+ }
+ else if(gcNext->getUCN() < SearchListRoot->getUCN() )
+ {
+ idDelete( (ideal*)&gcNext->gcBasis );
+// rDelete(gcNext->baseRing);//TODO Why does this crash?
+ }
+ /*else
+ {
+ if(gfanHeuristic==1)
+ {
+ gcone *gcDel;
+ gcDel = gcNext;
+ if(gcDel->getUCN()!=1)
+ rDelete(gcDel->baseRing);
+ }
+ }*/
+ gcNext = gcNext->next;
+ }
+ UCNcounter++;
+ SearchListAct = SearchListRoot;
+ }
+ printf("\nFound %i cones - terminating\n", counter);
+}//void noRevS(gcone &gc)
+
+
/** \brief Make a set of rational vectors into integers
*
* We compute the lcm of the denominators and multiply with this to get integer values.
@@ -3217,134 +3215,134 @@ void gcone::noRevS(gcone &gcRoot, bool usingIntPoint)
* \param dd_MatrixPtr,int64vec
*/
void gcone::makeInt(const dd_MatrixPtr &M, const int line, int64vec &n)
-{
- mpz_t *denom = new mpz_t[this->numVars];
- for(int ii=0;ii<this->numVars;ii++)
- {
- mpz_init_set_str(denom[ii],"0",10);
- }
-
- mpz_t kgV,tmp;
- mpz_init(kgV);
- mpz_init(tmp);
-
- for (int ii=0;ii<(M->colsize)-1;ii++)
- {
- mpz_t z;
- mpz_init(z);
- mpq_get_den(z,M->matrix[line-1][ii+1]);
- mpz_set( denom[ii], z);
- mpz_clear(z);
- }
-
- /*Compute lcm of the denominators*/
- mpz_set(tmp,denom[0]);
- for (int ii=0;ii<(M->colsize)-1;ii++)
- {
- mpz_lcm(kgV,tmp,denom[ii]);
- mpz_set(tmp,kgV);
- }
- mpz_clear(tmp);
- /*Multiply the nominators by kgV*/
- mpq_t qkgV,res;
- mpq_init(qkgV);
- mpq_set_str(qkgV,"1",10);
- mpq_canonicalize(qkgV);
-
- mpq_init(res);
- mpq_set_str(res,"1",10);
- mpq_canonicalize(res);
-
- mpq_set_num(qkgV,kgV);
-
-// mpq_canonicalize(qkgV);
-// int ggT=1;
- for (int ii=0;ii<(M->colsize)-1;ii++)
- {
- mpq_mul(res,qkgV,M->matrix[line-1][ii+1]);
- n[ii]=(int64)mpz_get_d(mpq_numref(res));
-// ggT=int64gcd(ggT,n[ii]);
- }
- int64 ggT=n[0];
- for(int ii=0;ii<this->numVars;ii++)
- ggT=int64gcd(ggT,n[ii]);
- //Normalisation
- if(ggT>1)
- {
- for(int ii=0;ii<this->numVars;ii++)
- n[ii] /= ggT;
- }
- delete [] denom;
- mpz_clear(kgV);
- mpq_clear(qkgV); mpq_clear(res);
-
+{
+ mpz_t *denom = new mpz_t[this->numVars];
+ for(int ii=0;ii<this->numVars;ii++)
+ {
+ mpz_init_set_str(denom[ii],"0",10);
+ }
+
+ mpz_t kgV,tmp;
+ mpz_init(kgV);
+ mpz_init(tmp);
+
+ for (int ii=0;ii<(M->colsize)-1;ii++)
+ {
+ mpz_t z;
+ mpz_init(z);
+ mpq_get_den(z,M->matrix[line-1][ii+1]);
+ mpz_set( denom[ii], z);
+ mpz_clear(z);
+ }
+
+ /*Compute lcm of the denominators*/
+ mpz_set(tmp,denom[0]);
+ for (int ii=0;ii<(M->colsize)-1;ii++)
+ {
+ mpz_lcm(kgV,tmp,denom[ii]);
+ mpz_set(tmp,kgV);
+ }
+ mpz_clear(tmp);
+ /*Multiply the nominators by kgV*/
+ mpq_t qkgV,res;
+ mpq_init(qkgV);
+ mpq_set_str(qkgV,"1",10);
+ mpq_canonicalize(qkgV);
+
+ mpq_init(res);
+ mpq_set_str(res,"1",10);
+ mpq_canonicalize(res);
+
+ mpq_set_num(qkgV,kgV);
+
+// mpq_canonicalize(qkgV);
+// int ggT=1;
+ for (int ii=0;ii<(M->colsize)-1;ii++)
+ {
+ mpq_mul(res,qkgV,M->matrix[line-1][ii+1]);
+ n[ii]=(int64)mpz_get_d(mpq_numref(res));
+// ggT=int64gcd(ggT,n[ii]);
+ }
+ int64 ggT=n[0];
+ for(int ii=0;ii<this->numVars;ii++)
+ ggT=int64gcd(ggT,n[ii]);
+ //Normalisation
+ if(ggT>1)
+ {
+ for(int ii=0;ii<this->numVars;ii++)
+ n[ii] /= ggT;
+ }
+ delete [] denom;
+ mpz_clear(kgV);
+ mpq_clear(qkgV); mpq_clear(res);
+
}
/**
- * For all codim-2-facets we compute the gcd of the components of the facet normal and
+ * For all codim-2-facets we compute the gcd of the components of the facet normal and
* divide it out. Thus we get a normalized representation of each
* (codim-2)-facet normal, i.e. a primitive vector
* Actually we now also normalize the facet normals.
*/
// void gcone::normalize()
// {
-// int *ggT = new int;
-// *ggT=1;
-// facet *fAct;
-// facet *codim2Act;
-// fAct = this->facetPtr;
-// codim2Act = fAct->codim2Ptr;
-// while(fAct!=NULL)
-// {
-// int64vec *fNormal;
-// fNormal = fAct->getFacetNormal();
-// int *ggT = new int;
-// *ggT=1;
-// for(int ii=0;ii<this->numVars;ii++)
-// {
-// *ggT=intgcd((*ggT),(*fNormal)[ii]);
-// }
-// if(*ggT>1)//We only need to do this if the ggT is non-trivial
-// {
-// // int64vec *fCopy = fAct->getFacetNormal();
-// for(int ii=0;ii<this->numVars;ii++)
-// (*fNormal)[ii] = ((*fNormal)[ii])/(*ggT);
-// fAct->setFacetNormal(fNormal);
-// }
-// delete fNormal;
-// delete ggT;
-// /*And now for the codim2*/
-// while(codim2Act!=NULL)
-// {
-// int64vec *n;
-// n=codim2Act->getFacetNormal();
-// int *ggT=new int;
-// *ggT=1;
-// for(int ii=0;ii<this->numVars;ii++)
-// {
-// *ggT = intgcd((*ggT),(*n)[ii]);
-// }
-// if(*ggT>1)
-// {
-// for(int ii=0;ii<this->numVars;ii++)
-// {
-// (*n)[ii] = ((*n)[ii])/(*ggT);
-// }
-// codim2Act->setFacetNormal(n);
-// }
-// codim2Act = codim2Act->next;
-// delete n;
-// delete ggT;
-// }
-// fAct = fAct->next;
-// }
+// int *ggT = new int;
+// *ggT=1;
+// facet *fAct;
+// facet *codim2Act;
+// fAct = this->facetPtr;
+// codim2Act = fAct->codim2Ptr;
+// while(fAct!=NULL)
+// {
+// int64vec *fNormal;
+// fNormal = fAct->getFacetNormal();
+// int *ggT = new int;
+// *ggT=1;
+// for(int ii=0;ii<this->numVars;ii++)
+// {
+// *ggT=intgcd((*ggT),(*fNormal)[ii]);
+// }
+// if(*ggT>1)//We only need to do this if the ggT is non-trivial
+// {
+// // int64vec *fCopy = fAct->getFacetNormal();
+// for(int ii=0;ii<this->numVars;ii++)
+// (*fNormal)[ii] = ((*fNormal)[ii])/(*ggT);
+// fAct->setFacetNormal(fNormal);
+// }
+// delete fNormal;
+// delete ggT;
+// /*And now for the codim2*/
+// while(codim2Act!=NULL)
+// {
+// int64vec *n;
+// n=codim2Act->getFacetNormal();
+// int *ggT=new int;
+// *ggT=1;
+// for(int ii=0;ii<this->numVars;ii++)
+// {
+// *ggT = intgcd((*ggT),(*n)[ii]);
+// }
+// if(*ggT>1)
+// {
+// for(int ii=0;ii<this->numVars;ii++)
+// {
+// (*n)[ii] = ((*n)[ii])/(*ggT);
+// }
+// codim2Act->setFacetNormal(n);
+// }
+// codim2Act = codim2Act->next;
+// delete n;
+// delete ggT;
+// }
+// fAct = fAct->next;
+// }
// }
-/** \brief Enqueue new facets into the searchlist
+/** \brief Enqueue new facets into the searchlist
* The searchlist (SLA for short) is implemented as a FIFO
* Checks are done as follows:
* 1) Check facet fAct against all facets in SLA for parallelity. If it is not parallel to any one add it.
- * 2) If it is parallel compare the codim2 facets. If they coincide the facets are equal and we delete the
- * facet from SLA and do not add fAct.
+ * 2) If it is parallel compare the codim2 facets. If they coincide the facets are equal and we delete the
+ * facet from SLA and do not add fAct.
* It may very well happen, that SLA=\f$ \emptyset \f$ but we do not have checked all fActs yet. In this case we
* can be sure, that none of the facets that are still there already were in SLA once, so we just dump them into SLA.
* Takes ptr to search list root
@@ -3353,335 +3351,335 @@ void gcone::makeInt(const dd_MatrixPtr &M, const int line, int64vec &n)
facet * gcone::enqueueNewFacets(facet *f)
{
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- facet *slHead;
- slHead = f;
- facet *slAct; //called with f=SearchListRoot
- slAct = f;
- facet *slEnd; //Pointer to end of SLA
- slEnd = f;
-// facet *slEndStatic; //marks the end before a new facet is added
- facet *fAct;
- fAct = this->facetPtr;
- facet *codim2Act;
- codim2Act = this->facetPtr->codim2Ptr;
- facet *sl2Act;
- sl2Act = f->codim2Ptr;
- /** Pointer to a facet that will be deleted */
- volatile facet *deleteMarker;
- deleteMarker = NULL;
-
- /** \brief Flag to mark a facet that might be added
- * The following case may occur:
- * A facet fAct is found to be parallel but not equal to the current facet slAct from SLA.
- * This does however not mean that there does not exist a facet behind the current slAct that is actually equal
- * to fAct. In this case we set the boolean flag maybe to TRUE. If we encounter an equality lateron, it is reset to
- * FALSE and the according slAct is deleted.
- * If slAct->next==NULL AND maybe==TRUE we know, that fAct must be added
- */
-
- /**A facet was removed, lengthOfSearchlist-- thus we must not rely on
- * if(notParallelCtr==lengthOfSearchList) but rather
- * if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE)
- */
- volatile bool removalOccured=FALSE;
- while(slEnd->next!=NULL)
- {
- slEnd=slEnd->next;
- }
- /*1st step: compare facetNormals*/
- while(fAct!=NULL)
- {
- if(fAct->isFlippable==TRUE)
- {
- int64vec *fNormal=NULL;
- fNormal=fAct->getFacetNormal();
- slAct = slHead;
- /*If slAct==NULL and fAct!=NULL
- we just copy all remaining facets into SLA*/
- if(slAct==NULL)
- {
- facet *fCopy;
- fCopy = fAct;
- while(fCopy!=NULL)
- {
- if(fCopy->isFlippable==TRUE)//We must assure fCopy is also flippable
- {
- if(slAct==NULL)
- {
- slAct = new facet(*fCopy/*,TRUE*/);//copy constructor
- slHead = slAct;
- }
- else
- {
- slAct->next = new facet(*fCopy/*,TRUE*/);
- slAct = slAct->next;
- }
- }
- fCopy = fCopy->next;
- }
- break;//Where does this lead to?
- }
- /*End of dumping into SLA*/
- while(slAct!=NULL)
- {
- int64vec *slNormal=NULL;
- removalOccured=FALSE;
- slNormal = slAct->getFacetNormal();
+ facet *slHead;
+ slHead = f;
+ facet *slAct; //called with f=SearchListRoot
+ slAct = f;
+ facet *slEnd; //Pointer to end of SLA
+ slEnd = f;
+// facet *slEndStatic; //marks the end before a new facet is added
+ facet *fAct;
+ fAct = this->facetPtr;
+ facet *codim2Act;
+ codim2Act = this->facetPtr->codim2Ptr;
+ facet *sl2Act;
+ sl2Act = f->codim2Ptr;
+ /** Pointer to a facet that will be deleted */
+ volatile facet *deleteMarker;
+ deleteMarker = NULL;
+
+ /** \brief Flag to mark a facet that might be added
+ * The following case may occur:
+ * A facet fAct is found to be parallel but not equal to the current facet slAct from SLA.
+ * This does however not mean that there does not exist a facet behind the current slAct that is actually equal
+ * to fAct. In this case we set the boolean flag maybe to TRUE. If we encounter an equality lateron, it is reset to
+ * FALSE and the according slAct is deleted.
+ * If slAct->next==NULL AND maybe==TRUE we know, that fAct must be added
+ */
+
+ /**A facet was removed, lengthOfSearchlist-- thus we must not rely on
+ * if(notParallelCtr==lengthOfSearchList) but rather
+ * if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE)
+ */
+ volatile bool removalOccured=FALSE;
+ while(slEnd->next!=NULL)
+ {
+ slEnd=slEnd->next;
+ }
+ /*1st step: compare facetNormals*/
+ while(fAct!=NULL)
+ {
+ if(fAct->isFlippable==TRUE)
+ {
+ int64vec *fNormal=NULL;
+ fNormal=fAct->getFacetNormal();
+ slAct = slHead;
+ /*If slAct==NULL and fAct!=NULL
+ we just copy all remaining facets into SLA*/
+ if(slAct==NULL)
+ {
+ facet *fCopy;
+ fCopy = fAct;
+ while(fCopy!=NULL)
+ {
+ if(fCopy->isFlippable==TRUE)//We must assure fCopy is also flippable
+ {
+ if(slAct==NULL)
+ {
+ slAct = new facet(*fCopy/*,TRUE*/);//copy constructor
+ slHead = slAct;
+ }
+ else
+ {
+ slAct->next = new facet(*fCopy/*,TRUE*/);
+ slAct = slAct->next;
+ }
+ }
+ fCopy = fCopy->next;
+ }
+ break;//Where does this lead to?
+ }
+ /*End of dumping into SLA*/
+ while(slAct!=NULL)
+ {
+ int64vec *slNormal=NULL;
+ removalOccured=FALSE;
+ slNormal = slAct->getFacetNormal();
#ifndef NDEBUG
- printf("Checking facet (");fNormal->show(1,1);printf(") against (");slNormal->show(1,1);printf(")\n");
-#endif
-// if( (areEqual(fAct,slAct) && (!areEqual2(fAct,slAct)) ))
-// exit(-1);
- if(areEqual2(fAct,slAct))
- {
- deleteMarker = slAct;
- if(slAct==slHead)
- {
- slHead = slAct->next;
- if(slHead!=NULL)
- slHead->prev = NULL;
- }
- else if (slAct==slEnd)
- {
- slEnd=slEnd->prev;
- slEnd->next = NULL;
- }
- else
- {
- slAct->prev->next = slAct->next;
- slAct->next->prev = slAct->prev;
- }
- removalOccured=TRUE;
- gcone::lengthOfSearchList--;
- if(deleteMarker!=NULL)
- {
-// delete deleteMarker;
-// deleteMarker=NULL;
- }
+ printf("Checking facet (");fNormal->show(1,1);printf(") against (");slNormal->show(1,1);printf(")\n");
+#endif
+// if( (areEqual(fAct,slAct) && (!areEqual2(fAct,slAct)) ))
+// exit(-1);
+ if(areEqual2(fAct,slAct))
+ {
+ deleteMarker = slAct;
+ if(slAct==slHead)
+ {
+ slHead = slAct->next;
+ if(slHead!=NULL)
+ slHead->prev = NULL;
+ }
+ else if (slAct==slEnd)
+ {
+ slEnd=slEnd->prev;
+ slEnd->next = NULL;
+ }
+ else
+ {
+ slAct->prev->next = slAct->next;
+ slAct->next->prev = slAct->prev;
+ }
+ removalOccured=TRUE;
+ gcone::lengthOfSearchList--;
+ if(deleteMarker!=NULL)
+ {
+// delete deleteMarker;
+// deleteMarker=NULL;
+ }
#ifndef NDEBUG
- printf("Removing (");fNormal->show(1,1);printf(") from list\n");
+ printf("Removing (");fNormal->show(1,1);printf(") from list\n");
#endif
- delete slNormal;
- break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
- }
- slAct = slAct->next;
- /* NOTE The following lines must not be here but rather called inside the if-block above.
- Otherwise results get crappy. Unfortunately there are two slAct=slAct->next calls now,
- (not nice!) but since they are in seperate branches of the if-statement there should not
- be a way it gets called twice thus ommiting one facet:
- slAct = slAct->next;*/
- if(deleteMarker!=NULL)
- {
-// delete deleteMarker;
-// deleteMarker=NULL;
- }
- delete slNormal;
- //if slAct was marked as to be deleted, delete it here!
- }//while(slAct!=NULL)
- if(removalOccured==FALSE)
- {
+ delete slNormal;
+ break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
+ }
+ slAct = slAct->next;
+ /* NOTE The following lines must not be here but rather called inside the if-block above.
+ Otherwise results get crappy. Unfortunately there are two slAct=slAct->next calls now,
+ (not nice!) but since they are in seperate branches of the if-statement there should not
+ be a way it gets called twice thus ommiting one facet:
+ slAct = slAct->next;*/
+ if(deleteMarker!=NULL)
+ {
+// delete deleteMarker;
+// deleteMarker=NULL;
+ }
+ delete slNormal;
+ //if slAct was marked as to be deleted, delete it here!
+ }//while(slAct!=NULL)
+ if(removalOccured==FALSE)
+ {
#ifndef NDEBUG
-// cout << "Adding facet (";fNormal->show(1,0);cout << ") to SLA " << endl;
+// cout << "Adding facet (";fNormal->show(1,0);cout << ") to SLA " << endl;
#endif
- //Add fAct to SLA
- facet *marker;
- marker = slEnd;
- facet *f2Act;
- f2Act = fAct->codim2Ptr;
-
- slEnd->next = new facet();
- slEnd = slEnd->next;//Update slEnd
- facet *slEndCodim2Root;
- facet *slEndCodim2Act;
- slEndCodim2Root = slEnd->codim2Ptr;
- slEndCodim2Act = slEndCodim2Root;
-
- slEnd->setUCN(this->getUCN());
- slEnd->isFlippable = TRUE;
- slEnd->setFacetNormal(fNormal);
- //NOTE Add interior point here
- //This is ugly but needed for flip2
- //Better: have slEnd->interiorPoint point to fAct->interiorPoint
- //NOTE Only reference -> c.f. copy constructor
- //slEnd->setInteriorPoint(fAct->getInteriorPoint());
- slEnd->interiorPoint = fAct->interiorPoint;
- slEnd->prev = marker;
- //Copy codim2-facets
- //int64vec *f2Normal=new int64vec(this->numVars);
- while(f2Act!=NULL)
- {
- int64vec *f2Normal;
- f2Normal=f2Act->getFacetNormal();
- if(slEndCodim2Root==NULL)
- {
- slEndCodim2Root = new facet(2);
- slEnd->codim2Ptr = slEndCodim2Root;
- slEndCodim2Root->setFacetNormal(f2Normal);
- slEndCodim2Act = slEndCodim2Root;
- }
- else
- {
- slEndCodim2Act->next = new facet(2);
- slEndCodim2Act = slEndCodim2Act->next;
- slEndCodim2Act->setFacetNormal(f2Normal);
- }
- f2Act = f2Act->next;
- delete f2Normal;
- }
- gcone::lengthOfSearchList++;
- }//if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE) ||
- fAct = fAct->next;
- delete fNormal;
-// delete slNormal;
- }//if(fAct->isFlippable==TRUE)
- else
- {
- fAct = fAct->next;
- }
- if(gcone::maxSize<gcone::lengthOfSearchList)
- gcone::maxSize= gcone::lengthOfSearchList;
- }//while(fAct!=NULL)
+ //Add fAct to SLA
+ facet *marker;
+ marker = slEnd;
+ facet *f2Act;
+ f2Act = fAct->codim2Ptr;
+
+ slEnd->next = new facet();
+ slEnd = slEnd->next;//Update slEnd
+ facet *slEndCodim2Root;
+ facet *slEndCodim2Act;
+ slEndCodim2Root = slEnd->codim2Ptr;
+ slEndCodim2Act = slEndCodim2Root;
+
+ slEnd->setUCN(this->getUCN());
+ slEnd->isFlippable = TRUE;
+ slEnd->setFacetNormal(fNormal);
+ //NOTE Add interior point here
+ //This is ugly but needed for flip2
+ //Better: have slEnd->interiorPoint point to fAct->interiorPoint
+ //NOTE Only reference -> c.f. copy constructor
+ //slEnd->setInteriorPoint(fAct->getInteriorPoint());
+ slEnd->interiorPoint = fAct->interiorPoint;
+ slEnd->prev = marker;
+ //Copy codim2-facets
+ //int64vec *f2Normal=new int64vec(this->numVars);
+ while(f2Act!=NULL)
+ {
+ int64vec *f2Normal;
+ f2Normal=f2Act->getFacetNormal();
+ if(slEndCodim2Root==NULL)
+ {
+ slEndCodim2Root = new facet(2);
+ slEnd->codim2Ptr = slEndCodim2Root;
+ slEndCodim2Root->setFacetNormal(f2Normal);
+ slEndCodim2Act = slEndCodim2Root;
+ }
+ else
+ {
+ slEndCodim2Act->next = new facet(2);
+ slEndCodim2Act = slEndCodim2Act->next;
+ slEndCodim2Act->setFacetNormal(f2Normal);
+ }
+ f2Act = f2Act->next;
+ delete f2Normal;
+ }
+ gcone::lengthOfSearchList++;
+ }//if( (notParallelCtr==lengthOfSearchList && removalOccured==FALSE) ||
+ fAct = fAct->next;
+ delete fNormal;
+// delete slNormal;
+ }//if(fAct->isFlippable==TRUE)
+ else
+ {
+ fAct = fAct->next;
+ }
+ if(gcone::maxSize<gcone::lengthOfSearchList)
+ gcone::maxSize= gcone::lengthOfSearchList;
+ }//while(fAct!=NULL)
#ifdef gfanp
- gettimeofday(&end, 0);
- time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-#endif
- return slHead;
+ gettimeofday(&end, 0);
+ time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+#endif
+ return slHead;
}//addC2N
/** Enqueuing using shallow copies*/
facet * gcone::enqueue2(facet *f)
{
- assert(f!=NULL);
+ assert(f!=NULL);
#ifdef gfanp
- timeval start, end;
- gettimeofday(&start, 0);
+ timeval start, end;
+ gettimeofday(&start, 0);
#endif
- facet *slHead;
- slHead = f;
- facet *slAct; //called with f=SearchListRoot
- slAct = f;
- static facet *slEnd; //Pointer to end of SLA
- if(slEnd==NULL)
- slEnd = f;
-
- facet *fAct;
- fAct = this->facetPtr;//New facets to compare
- facet *codim2Act;
- codim2Act = this->facetPtr->codim2Ptr;
- volatile bool removalOccured=FALSE;
- while(slEnd->next!=NULL)
- {
- slEnd=slEnd->next;
- }
- while(fAct!=NULL)
- {
- if(fAct->isFlippable)
- {
- facet *fDeleteMarker=NULL;
- slAct = slHead;
- if(slAct==NULL)
- {
- printf("Zero length SLA\n");
- facet *fCopy;
- fCopy = fAct;
- while(fCopy!=NULL)
- {
- if(fCopy->isFlippable==TRUE)//We must assure fCopy is also flippable
- {
- if(slAct==NULL)
- {
- slAct = slAct->shallowCopy(*fCopy);//shallow copy constructor
- slHead = slAct;
- }
- else
- {
- slAct->next = slAct->shallowCopy(*fCopy);
- slAct = slAct->next;
- }
- }
- fCopy = fCopy->next;
- }
- break; //WTF?
- }
- /*Comparison starts here*/
- while(slAct!=NULL)
- {
- removalOccured=FALSE;
+ facet *slHead;
+ slHead = f;
+ facet *slAct; //called with f=SearchListRoot
+ slAct = f;
+ static facet *slEnd; //Pointer to end of SLA
+ if(slEnd==NULL)
+ slEnd = f;
+
+ facet *fAct;
+ fAct = this->facetPtr;//New facets to compare
+ facet *codim2Act;
+ codim2Act = this->facetPtr->codim2Ptr;
+ volatile bool removalOccured=FALSE;
+ while(slEnd->next!=NULL)
+ {
+ slEnd=slEnd->next;
+ }
+ while(fAct!=NULL)
+ {
+ if(fAct->isFlippable)
+ {
+ facet *fDeleteMarker=NULL;
+ slAct = slHead;
+ if(slAct==NULL)
+ {
+ printf("Zero length SLA\n");
+ facet *fCopy;
+ fCopy = fAct;
+ while(fCopy!=NULL)
+ {
+ if(fCopy->isFlippable==TRUE)//We must assure fCopy is also flippable
+ {
+ if(slAct==NULL)
+ {
+ slAct = slAct->shallowCopy(*fCopy);//shallow copy constructor
+ slHead = slAct;
+ }
+ else
+ {
+ slAct->next = slAct->shallowCopy(*fCopy);
+ slAct = slAct->next;
+ }
+ }
+ fCopy = fCopy->next;
+ }
+ break; //WTF?
+ }
+ /*Comparison starts here*/
+ while(slAct!=NULL)
+ {
+ removalOccured=FALSE;
#ifndef NDEBUG
- printf("Checking facet (");fAct->fNormal->show(1,1);printf(") against (");slAct->fNormal->show(1,1);printf(")\n");
-#endif
- if(areEqual2(fAct,slAct))
- {
- fDeleteMarker=slAct;
- if(slAct==slHead)
- {
-// fDeleteMarker=slHead;
-// printf("headUCN at enq=%i\n",slHead->getUCN());
- slHead = slAct->next;
-// printf("headUCN at enq=%i\n",slHead->getUCN());
- if(slHead!=NULL)
- {
- slHead->prev = NULL;
- }
- fDeleteMarker->shallowDelete();
- //delete fDeleteMarker;//NOTE this messes up fAct in noRevS!
-// printf("headUCN at enq=%i\n",slHead->getUCN());
- }
- else if (slAct==slEnd)
- {
- slEnd=slEnd->prev;
- slEnd->next = NULL;
- fDeleteMarker->shallowDelete();
- delete(fDeleteMarker);
- }
- else
- {
- slAct->prev->next = slAct->next;
- slAct->next->prev = slAct->prev;
- fDeleteMarker->shallowDelete();
- delete(fDeleteMarker);
- }
- removalOccured=TRUE;
- gcone::lengthOfSearchList--;
+ printf("Checking facet (");fAct->fNormal->show(1,1);printf(") against (");slAct->fNormal->show(1,1);printf(")\n");
+#endif
+ if(areEqual2(fAct,slAct))
+ {
+ fDeleteMarker=slAct;
+ if(slAct==slHead)
+ {
+// fDeleteMarker=slHead;
+// printf("headUCN at enq=%i\n",slHead->getUCN());
+ slHead = slAct->next;
+// printf("headUCN at enq=%i\n",slHead->getUCN());
+ if(slHead!=NULL)
+ {
+ slHead->prev = NULL;
+ }
+ fDeleteMarker->shallowDelete();
+ //delete fDeleteMarker;//NOTE this messes up fAct in noRevS!
+// printf("headUCN at enq=%i\n",slHead->getUCN());
+ }
+ else if (slAct==slEnd)
+ {
+ slEnd=slEnd->prev;
+ slEnd->next = NULL;
+ fDeleteMarker->shallowDelete();
+ delete(fDeleteMarker);
+ }
+ else
+ {
+ slAct->prev->next = slAct->next;
+ slAct->next->prev = slAct->prev;
+ fDeleteMarker->shallowDelete();
+ delete(fDeleteMarker);
+ }
+ removalOccured=TRUE;
+ gcone::lengthOfSearchList--;
#ifndef NDEBUG
printf("Removing (");fAct->fNormal->show(1,1);printf(") from list\n");
#endif
- break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
- }
- slAct = slAct->next;
- }//while(slAct!=NULL)
- if(removalOccured==FALSE)
- {
- facet *marker=slEnd;
- slEnd->next = fAct->shallowCopy(*fAct);
- slEnd = slEnd->next;
- slEnd->prev=marker;
- gcone::lengthOfSearchList++;
- }
- fAct = fAct->next;
-// if(fDeleteMarker!=NULL)
-// {
-// fDeleteMarker->shallowDelete();
-// delete(fDeleteMarker);
-// fDeleteMarker=NULL;
-// }
- }
- else
- fAct = fAct->next;
- }//while(fAct!=NULL)
-
+ break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
+ }
+ slAct = slAct->next;
+ }//while(slAct!=NULL)
+ if(removalOccured==FALSE)
+ {
+ facet *marker=slEnd;
+ slEnd->next = fAct->shallowCopy(*fAct);
+ slEnd = slEnd->next;
+ slEnd->prev=marker;
+ gcone::lengthOfSearchList++;
+ }
+ fAct = fAct->next;
+// if(fDeleteMarker!=NULL)
+// {
+// fDeleteMarker->shallowDelete();
+// delete(fDeleteMarker);
+// fDeleteMarker=NULL;
+// }
+ }
+ else
+ fAct = fAct->next;
+ }//while(fAct!=NULL)
+
#ifdef gfanp
- gettimeofday(&end, 0);
- time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
-#endif
-// printf("headUCN at enq=%i\n",slHead->getUCN());
- return slHead;
+ gettimeofday(&end, 0);
+ time_enqueue += (end.tv_sec - start.tv_sec + 1e-6*(end.tv_usec - start.tv_usec));
+#endif
+// printf("headUCN at enq=%i\n",slHead->getUCN());
+ return slHead;
}
-/**
+/**
* During flip2 every gc->baseRing gets two ringorder_a
* To avoid having an awful lot of those in the end we endow
* gc->baseRing by a suitable ring with (a,dp,C) and copy all
@@ -3691,120 +3689,120 @@ printf("Removing (");fAct->fNormal->show(1,1);printf(") from list\n");
*/
void gcone::replaceDouble_ringorder_a_ByASingleOne()
{
- ring srcRing=currRing;
- ring replacementRing=rCopy0((ring)this->baseRing);
- /*We assume we have (a(),a(),dp) here*/
- omFree(replacementRing->order);
- replacementRing->order =(int *)omAlloc0(4*sizeof(int/*64*/));
- omFree(replacementRing->block0);
- replacementRing->block0=(int *)omAlloc0(4*sizeof(int/*64*/));
- omFree(replacementRing->block1);
- replacementRing->block1=(int *)omAlloc0(4*sizeof(int/*64*/));
- omfree(replacementRing->wvhdl);
- replacementRing->wvhdl =(int **)omAlloc0(4*sizeof(int/*64*/**));
-
- replacementRing->order[0]=ringorder_a/*64*/;
- replacementRing->block0[0]=1;
- replacementRing->block1[0]=replacementRing->N;
-
- replacementRing->order[1]=ringorder_dp;
- replacementRing->block0[1]=1;
- replacementRing->block1[1]=replacementRing->N;
-
- replacementRing->order[2]=ringorder_C;
-
- int64vec *ivw = this->getIntPoint(TRUE);//returns a reference
-// assert(this->ivIntPt);
- int length=ivw->length();
- int/*64*/ *A=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
- for (int jj=0;jj<length;jj++)
- {
- A[jj]=(*ivw)[jj];
- if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::replaceDouble_ringorder_a_ByASingleOne!\n");
- }
- //delete ivw; //Not needed if this->getIntPoint(TRUE)
- replacementRing->wvhdl[0]=(int *)A;
- replacementRing->block1[0]=length;
- /*Finish*/
- rComplete(replacementRing);
- rChangeCurrRing(replacementRing);
- ideal temporaryGroebnerBasis=idrCopyR(this->gcBasis,this->baseRing);
- rDelete(this->baseRing);
- this->baseRing=rCopy(replacementRing);
- this->gcBasis=idCopy(temporaryGroebnerBasis);
- /*And back to where we came from*/
- rChangeCurrRing(srcRing);
- idDelete( (ideal*)&temporaryGroebnerBasis );
- rDelete(replacementRing);
+ ring srcRing=currRing;
+ ring replacementRing=rCopy0((ring)this->baseRing);
+ /*We assume we have (a(),a(),dp) here*/
+ omFree(replacementRing->order);
+ replacementRing->order =(int *)omAlloc0(4*sizeof(int/*64*/));
+ omFree(replacementRing->block0);
+ replacementRing->block0=(int *)omAlloc0(4*sizeof(int/*64*/));
+ omFree(replacementRing->block1);
+ replacementRing->block1=(int *)omAlloc0(4*sizeof(int/*64*/));
+ omfree(replacementRing->wvhdl);
+ replacementRing->wvhdl =(int **)omAlloc0(4*sizeof(int/*64*/**));
+
+ replacementRing->order[0]=ringorder_a/*64*/;
+ replacementRing->block0[0]=1;
+ replacementRing->block1[0]=replacementRing->N;
+
+ replacementRing->order[1]=ringorder_dp;
+ replacementRing->block0[1]=1;
+ replacementRing->block1[1]=replacementRing->N;
+
+ replacementRing->order[2]=ringorder_C;
+
+ int64vec *ivw = this->getIntPoint(TRUE);//returns a reference
+// assert(this->ivIntPt);
+ int length=ivw->length();
+ int/*64*/ *A=(int/*64*/ *)omAlloc0(length*sizeof(int/*64*/));
+ for (int jj=0;jj<length;jj++)
+ {
+ A[jj]=(*ivw)[jj];
+ if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::replaceDouble_ringorder_a_ByASingleOne!\n");
+ }
+ //delete ivw; //Not needed if this->getIntPoint(TRUE)
+ replacementRing->wvhdl[0]=(int *)A;
+ replacementRing->block1[0]=length;
+ /*Finish*/
+ rComplete(replacementRing);
+ rChangeCurrRing(replacementRing);
+ ideal temporaryGroebnerBasis=idrCopyR(this->gcBasis,this->baseRing);
+ rDelete(this->baseRing);
+ this->baseRing=rCopy(replacementRing);
+ this->gcBasis=idCopy(temporaryGroebnerBasis);
+ /*And back to where we came from*/
+ rChangeCurrRing(srcRing);
+ idDelete( (ideal*)&temporaryGroebnerBasis );
+ rDelete(replacementRing);
}
/** \brief Compute the gcd of two ints
*/
static int64 int64gcd(const int64 &a, const int64 &b)
{
- int64 r, p=a, q=b;
- if(p < 0)
- p = -p;
- if(q < 0)
- q = -q;
- while(q != 0)
- {
- r = p % q;
- p = q;
- q = r;
- }
- return p;
+ int64 r, p=a, q=b;
+ if(p < 0)
+ p = -p;
+ if(q < 0)
+ q = -q;
+ while(q != 0)
+ {
+ r = p % q;
+ p = q;
+ q = r;
+ }
+ return p;
}
-
+
static int intgcd(const int &a, const int &b)
{
- int r, p=a, q=b;
- if(p < 0)
- p = -p;
- if(q < 0)
- q = -q;
- while(q != 0)
- {
- r = p % q;
- p = q;
- q = r;
- }
- return p;
+ int r, p=a, q=b;
+ if(p < 0)
+ p = -p;
+ if(q < 0)
+ q = -q;
+ while(q != 0)
+ {
+ r = p % q;
+ p = q;
+ q = r;
+ }
+ return p;
}
-
+
/** \brief Construct a dd_MatrixPtr from a cone's list of facets
* NO LONGER USED
*/
// inline dd_MatrixPtr gcone::facets2Matrix(const gcone &gc)
// {
-// facet *fAct;
-// fAct = gc.facetPtr;
-//
-// dd_MatrixPtr M;
-// dd_rowrange ddrows;
-// dd_colrange ddcols;
-// ddcols=(this->numVars)+1;
-// ddrows=this->numFacets;
-// dd_NumberType numb = dd_Integer;
-// M=dd_CreateMatrix(ddrows,ddcols);
-//
-// int jj=0;
-//
-// while(fAct!=NULL)
-// {
-// int64vec *comp;
-// comp = fAct->getFacetNormal();
-// for(int ii=0;ii<this->numVars;ii++)
-// {
-// dd_set_si(M->matrix[jj][ii+1],(*comp)[ii]);
-// }
-// jj++;
-// delete comp;
-// fAct=fAct->next;
-// }
-// return M;
+// facet *fAct;
+// fAct = gc.facetPtr;
+//
+// dd_MatrixPtr M;
+// dd_rowrange ddrows;
+// dd_colrange ddcols;
+// ddcols=(this->numVars)+1;
+// ddrows=this->numFacets;
+// dd_NumberType numb = dd_Integer;
+// M=dd_CreateMatrix(ddrows,ddcols);
+//
+// int jj=0;
+//
+// while(fAct!=NULL)
+// {
+// int64vec *comp;
+// comp = fAct->getFacetNormal();
+// for(int ii=0;ii<this->numVars;ii++)
+// {
+// dd_set_si(M->matrix[jj][ii+1],(*comp)[ii]);
+// }
+// jj++;
+// delete comp;
+// fAct=fAct->next;
+// }
+// return M;
// }
-
+
/** \brief Write information about a cone into a file on disk
*
* This methods writes the information needed for the "second" method into a file.
@@ -3817,93 +3815,93 @@ static int intgcd(const int &a, const int &b)
*/
void gcone::writeConeToFile(const gcone &gc, bool usingIntPoints)
{
- int UCN=gc.UCN;
- stringstream ss;
- ss << UCN;
- string UCNstr = ss.str();
-
- string prefix="/tmp/Singular/cone";
-// string prefix="./"; //crude hack -> run tests in separate directories
- string suffix=".sg";
- string filename;
- filename.append(prefix);
- filename.append(UCNstr);
- filename.append(suffix);
-
-// int thisPID = getpid();
-// ss << thisPID;
-// string strPID = ss.str();
-// string prefix="./";
-
- ofstream gcOutputFile(filename.c_str());
- assert(gcOutputFile);
- facet *fAct;
- fAct = gc.facetPtr;
- facet *f2Act;
- f2Act=fAct->codim2Ptr;
-
- char *ringString = rString(gc.baseRing);
-
- if (!gcOutputFile)
- {
- WerrorS("Error opening file for writing in writeConeToFile\n");
- }
- else
- {
- gcOutputFile << "UCN" << endl;
- gcOutputFile << this->UCN << endl;
- gcOutputFile << "RING" << endl;
- gcOutputFile << ringString << endl;
- gcOutputFile << "GCBASISLENGTH" << endl;
- gcOutputFile << IDELEMS(gc.gcBasis) << endl;
- //Write this->gcBasis into file
- gcOutputFile << "GCBASIS" << endl;
- for (int ii=0;ii<IDELEMS(gc.gcBasis);ii++)
- {
- gcOutputFile << p_String((poly)gc.gcBasis->m[ii],gc.baseRing) << endl;
- }
-
- gcOutputFile << "FACETS" << endl;
-
- while(fAct!=NULL)
- {
- const int64vec *iv=fAct->getRef2FacetNormal();
-// iv=fAct->getRef2FacetNormal();//->getFacetNormal();
- f2Act=fAct->codim2Ptr;
- for (int ii=0;ii<iv->length();ii++)
- {
-// if (ii<iv->length()-1)
-// gcOutputFile << (*iv)[ii] << ",";
-// else
-// gcOutputFile << (*iv)[ii] << " ";
- gcOutputFile << (*iv)[ii];
- (ii<iv->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
- }
- //delete iv;
- while(f2Act!=NULL)
- {
- const int64vec *iv2;
- iv2=f2Act->getRef2FacetNormal();
- for(int jj=0;jj<iv2->length();jj++)
- {
-// if (jj<iv2->length()-1)
-// gcOutputFile << (*iv2)[jj] << ",";
-// else
-// gcOutputFile << (*iv2)[jj] << " ";
- gcOutputFile << (*iv2)[jj];
- (jj<iv2->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
- }
- f2Act = f2Act->next;
- }
- gcOutputFile << endl;
- fAct=fAct->next;
- }
- gcOutputFile.close();
- }
- delete [] ringString;
-
+ int UCN=gc.UCN;
+ stringstream ss;
+ ss << UCN;
+ string UCNstr = ss.str();
+
+ string prefix="/tmp/Singular/cone";
+// string prefix="./"; //crude hack -> run tests in separate directories
+ string suffix=".sg";
+ string filename;
+ filename.append(prefix);
+ filename.append(UCNstr);
+ filename.append(suffix);
+
+// int thisPID = getpid();
+// ss << thisPID;
+// string strPID = ss.str();
+// string prefix="./";
+
+ ofstream gcOutputFile(filename.c_str());
+ assert(gcOutputFile);
+ facet *fAct;
+ fAct = gc.facetPtr;
+ facet *f2Act;
+ f2Act=fAct->codim2Ptr;
+
+ char *ringString = rString(gc.baseRing);
+
+ if (!gcOutputFile)
+ {
+ WerrorS("Error opening file for writing in writeConeToFile\n");
+ }
+ else
+ {
+ gcOutputFile << "UCN" << endl;
+ gcOutputFile << this->UCN << endl;
+ gcOutputFile << "RING" << endl;
+ gcOutputFile << ringString << endl;
+ gcOutputFile << "GCBASISLENGTH" << endl;
+ gcOutputFile << IDELEMS(gc.gcBasis) << endl;
+ //Write this->gcBasis into file
+ gcOutputFile << "GCBASIS" << endl;
+ for (int ii=0;ii<IDELEMS(gc.gcBasis);ii++)
+ {
+ gcOutputFile << p_String((poly)gc.gcBasis->m[ii],gc.baseRing) << endl;
+ }
+
+ gcOutputFile << "FACETS" << endl;
+
+ while(fAct!=NULL)
+ {
+ const int64vec *iv=fAct->getRef2FacetNormal();
+// iv=fAct->getRef2FacetNormal();//->getFacetNormal();
+ f2Act=fAct->codim2Ptr;
+ for (int ii=0;ii<iv->length();ii++)
+ {
+// if (ii<iv->length()-1)
+// gcOutputFile << (*iv)[ii] << ",";
+// else
+// gcOutputFile << (*iv)[ii] << " ";
+ gcOutputFile << (*iv)[ii];
+ (ii<iv->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
+ }
+ //delete iv;
+ while(f2Act!=NULL)
+ {
+ const int64vec *iv2;
+ iv2=f2Act->getRef2FacetNormal();
+ for(int jj=0;jj<iv2->length();jj++)
+ {
+// if (jj<iv2->length()-1)
+// gcOutputFile << (*iv2)[jj] << ",";
+// else
+// gcOutputFile << (*iv2)[jj] << " ";
+ gcOutputFile << (*iv2)[jj];
+ (jj<iv2->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
+ }
+ f2Act = f2Act->next;
+ }
+ gcOutputFile << endl;
+ fAct=fAct->next;
+ }
+ gcOutputFile.close();
+ }
+ delete [] ringString;
+
}//writeConeToFile(gcone const &gc)
-
+
/** \brief Reads a cone from a file identified by its number
* ||depending on whether flip or flip2 is used, switch the flag flipFlag
* ||defaults to 0 => flip
@@ -3911,241 +3909,241 @@ void gcone::writeConeToFile(const gcone &gc, bool usingIntPoints)
*/
void gcone::readConeFromFile(int UCN, gcone *gc)
{
- //int UCN=gc.UCN;
- stringstream ss;
- ss << UCN;
- string UCNstr = ss.str();
- int gcBasisLength=0;
- size_t found; //used for find_first_(not)_of
-
- string prefix="/tmp/Singular/cone";
- string suffix=".sg";
- string filename;
- filename.append(prefix);
- filename.append(UCNstr);
- filename.append(suffix);
-
- ifstream gcInputFile(filename.c_str(), ifstream::in);
-
- ring saveRing=currRing;
- //Comment the following if you uncomment the if(line=="RING") part below
-// rChangeCurrRing(gc->baseRing);
-
- while( !gcInputFile.eof() )
- {
- string line;
- getline(gcInputFile,line);
- if(line=="RING")
- {
- getline(gcInputFile,line);
- found = line.find("a(");
- line.erase(0,found+2);
- string strweight;
- strweight=line.substr(0,line.find_first_of(")"));
-
- int64vec *iv=new int64vec(this->numVars);//
- for(int ii=0;ii<this->numVars;ii++)
- {
- string weight;
- weight=line.substr(0,line.find_first_of(",)"));
- char *w=new char[weight.size()+1];
- strcpy(w,weight.c_str());
- (*iv)[ii]=atol(w/*weight.c_str()*/);//Better to long. Weight bound in Singular:2147483647
- delete[] w;
- line.erase(0,line.find_first_of(",)")+1);
- }
- found = line.find("a(");
-
- ring newRing;
- if(currRing->order[0]!=ringorder_a/*64*/)
- {
- newRing=rCopyAndAddWeight(currRing,iv);
- }
- else
- {
- newRing=rCopy0(currRing);
- int length=this->numVars;
- int *A=(int *)omAlloc0(length*sizeof(int));
- for(int jj=0;jj<length;jj++)
- {
- A[jj]=(*iv)[jj];
- }
- omFree(newRing->wvhdl[0]);
- newRing->wvhdl[0]=(int*)A;
- newRing->block1[0]=length;
- }
- delete iv;
- rComplete(newRing);
- gc->baseRing=rCopy(newRing);
- rDelete(newRing);
- rComplete(gc->baseRing);
- if(currRing!=gc->baseRing)
- rChangeCurrRing(gc->baseRing);
- }
-
- if(line=="GCBASISLENGTH")
- {
- string strGcBasisLength;
- getline(gcInputFile, line);
- strGcBasisLength = line;
- char *s=new char[strGcBasisLength.size()+1];
- strcpy(s,strGcBasisLength.c_str());
- int size=atoi(s/*strGcBasisLength.c_str()*/);
- delete[] s;
- gcBasisLength=size;
- gc->gcBasis=idInit(size,1);
- }
- if(line=="GCBASIS")
- {
- for(int jj=0;jj<gcBasisLength;jj++)
- {
- getline(gcInputFile,line);
- //magically convert strings into polynomials
- //polys.cc:p_Read
- //check until first occurance of + or -
- //data or c_str
-// poly strPoly;//=pInit();//Ought to be inside the while loop, but that will eat your memory
- poly resPoly=pInit(); //The poly to be read in
- while(!line.empty())
- {
- poly strPoly;//=pInit();
-
- string strMonom, strCoeff, strCoeffNom, strCoeffDenom;
- bool hasCoeffInQ = FALSE; //does the polynomial have rational coeff?
- bool hasNegCoeff = FALSE; //or a negative one?
- found = line.find_first_of("+-"); //get the first monomial
- string tmp;
- tmp=line[found];
-// if(found!=0 && (tmp.compare("-")==0) )
-// hasNegCoeff = TRUE; //We have a coeff < 0
- if(found==0)
- {
- if(tmp.compare("-")==0)
- hasNegCoeff = TRUE;
- line.erase(0,1); //remove leading + or -
- found = line.find_first_of("+-"); //adjust found
- }
- strMonom = line.substr(0,found);
- line.erase(0,found);
- number nCoeff=nInit(1);
- number nCoeffNom=nInit(1);
- number nCoeffDenom=nInit(1);
- found = strMonom.find_first_of("/");
- if(found!=string::npos) //i.e. "/" exists in strMonom
- {
- hasCoeffInQ = TRUE;
- strCoeffNom=strMonom.substr(0,found);
- strCoeffDenom=strMonom.substr(found+1,strMonom.find_first_not_of("1234567890",found+1));
- strMonom.erase(0,found);
- strMonom.erase(0,strMonom.find_first_not_of("1234567890/"));
- char *Nom=new char[strCoeffNom.size()+1];
- char *Denom=new char[strCoeffDenom.size()+1];
- strcpy(Nom,strCoeffNom.c_str());
- strcpy(Denom,strCoeffDenom.c_str());
- nRead(Nom/*strCoeffNom.c_str()*/, &nCoeffNom);
- nRead(Denom/*strCoeffDenom.c_str()*/, &nCoeffDenom);
- delete[] Nom;
- delete[] Denom;
- }
- else
- {
- found = strMonom.find_first_not_of("1234567890");
- strCoeff = strMonom.substr(0,found);
- if(!strCoeff.empty())
- {
- char *coeff = new char[strCoeff.size()+1];
- strcpy(coeff, strCoeff.c_str());
- nRead(coeff/*strCoeff.c_str()*/,&nCoeff);
- delete[] coeff;
- }
- }
- char* monom = new char[strMonom.size()+1];
- strcpy(monom, strMonom.c_str());
- p_Read(monom,strPoly,currRing); //strPoly:=monom
- delete[] monom;
- switch (hasCoeffInQ)
- {
- case TRUE:
- if(hasNegCoeff)
- nCoeffNom=nNeg(nCoeffNom);
- pSetCoeff(strPoly, nDiv(nCoeffNom, nCoeffDenom));
- break;
- case FALSE:
- if(hasNegCoeff)
- nCoeff=nNeg(nCoeff);
- if(!nIsOne(nCoeff))
- {
- pSetCoeff(strPoly, nCoeff );
- }
- break;
- }
- //pSetCoeff(strPoly, (number) intCoeff);//Why is this set to zero instead of 1???
- if(pIsConstantComp(resPoly))
- {
- resPoly=pCopy(strPoly);
- pDelete(&strPoly);
- }
- else
- {
-// poly tmp=pAdd(pCopy(resPoly),strPoly);//foo is destroyed
-// pDelete(&resPoly);
-// resPoly=tmp;
-// pDelete(&tmp);
- resPoly=pAdd(resPoly,strPoly);//pAdd = p_Add_q, destroys args
- }
- /*if(nCoeff!=NULL)
- nDelete(&nCoeff);*/ //NOTE This may cause a crash on certain examples...
- nDelete(&nCoeffNom);
- nDelete(&nCoeffDenom);
- }//while(!line.empty())
- gc->gcBasis->m[jj]=pCopy(resPoly);
- pDelete(&resPoly); //reset
- }
-// break;
- }//if(line=="GCBASIS")
- if(line=="FACETS")
- {
- facet *fAct=gc->facetPtr;
- while(fAct!=NULL)
- {
- getline(gcInputFile,line);
- found = line.find("\t");
- string normalString=line.substr(0,found);
- int64vec *fN = new int64vec(this->numVars);
- for(int ii=0;ii<this->numVars;ii++)
- {
- string component;
- found = normalString.find(",");
- component=normalString.substr(0,found);
- char *sComp = new char[component.size()+1];
- strcpy(sComp,component.c_str());
- (*fN)[ii]=atol(sComp/*component.c_str()*/);
- delete[] sComp;
- normalString.erase(0,found+1);
- }
- /*Only the following line needs to be commented out if you decide not to delete fNormals*/
-// fAct->setFacetNormal(fN);
- delete(fN);
- fAct = fAct->next; //Booh, this is ugly
- }
- break; //NOTE Must always be in the last if-block!
- }
- }//while(!gcInputFile.eof())
- gcInputFile.close();
- rChangeCurrRing(saveRing);
+ //int UCN=gc.UCN;
+ stringstream ss;
+ ss << UCN;
+ string UCNstr = ss.str();
+ int gcBasisLength=0;
+ size_t found; //used for find_first_(not)_of
+
+ string prefix="/tmp/Singular/cone";
+ string suffix=".sg";
+ string filename;
+ filename.append(prefix);
+ filename.append(UCNstr);
+ filename.append(suffix);
+
+ ifstream gcInputFile(filename.c_str(), ifstream::in);
+
+ ring saveRing=currRing;
+ //Comment the following if you uncomment the if(line=="RING") part below
+// rChangeCurrRing(gc->baseRing);
+
+ while( !gcInputFile.eof() )
+ {
+ string line;
+ getline(gcInputFile,line);
+ if(line=="RING")
+ {
+ getline(gcInputFile,line);
+ found = line.find("a(");
+ line.erase(0,found+2);
+ string strweight;
+ strweight=line.substr(0,line.find_first_of(")"));
+
+ int64vec *iv=new int64vec(this->numVars);//
+ for(int ii=0;ii<this->numVars;ii++)
+ {
+ string weight;
+ weight=line.substr(0,line.find_first_of(",)"));
+ char *w=new char[weight.size()+1];
+ strcpy(w,weight.c_str());
+ (*iv)[ii]=atol(w/*weight.c_str()*/);//Better to long. Weight bound in Singular:2147483647
+ delete[] w;
+ line.erase(0,line.find_first_of(",)")+1);
+ }
+ found = line.find("a(");
+
+ ring newRing;
+ if(currRing->order[0]!=ringorder_a/*64*/)
+ {
+ newRing=rCopyAndAddWeight(currRing,iv);
+ }
+ else
+ {
+ newRing=rCopy0(currRing);
+ int length=this->numVars;
+ int *A=(int *)omAlloc0(length*sizeof(int));
+ for(int jj=0;jj<length;jj++)
+ {
+ A[jj]=(*iv)[jj];
+ }
+ omFree(newRing->wvhdl[0]);
+ newRing->wvhdl[0]=(int*)A;
+ newRing->block1[0]=length;
+ }
+ delete iv;
+ rComplete(newRing);
+ gc->baseRing=rCopy(newRing);
+ rDelete(newRing);
+ rComplete(gc->baseRing);
+ if(currRing!=gc->baseRing)
+ rChangeCurrRing(gc->baseRing);
+ }
+
+ if(line=="GCBASISLENGTH")
+ {
+ string strGcBasisLength;
+ getline(gcInputFile, line);
+ strGcBasisLength = line;
+ char *s=new char[strGcBasisLength.size()+1];
+ strcpy(s,strGcBasisLength.c_str());
+ int size=atoi(s/*strGcBasisLength.c_str()*/);
+ delete[] s;
+ gcBasisLength=size;
+ gc->gcBasis=idInit(size,1);
+ }
+ if(line=="GCBASIS")
+ {
+ for(int jj=0;jj<gcBasisLength;jj++)
+ {
+ getline(gcInputFile,line);
+ //magically convert strings into polynomials
+ //polys.cc:p_Read
+ //check until first occurance of + or -
+ //data or c_str
+// poly strPoly;//=pInit();//Ought to be inside the while loop, but that will eat your memory
+ poly resPoly=pInit(); //The poly to be read in
+ while(!line.empty())
+ {
+ poly strPoly;//=pInit();
+
+ string strMonom, strCoeff, strCoeffNom, strCoeffDenom;
+ bool hasCoeffInQ = FALSE; //does the polynomial have rational coeff?
+ bool hasNegCoeff = FALSE; //or a negative one?
+ found = line.find_first_of("+-"); //get the first monomial
+ string tmp;
+ tmp=line[found];
+// if(found!=0 && (tmp.compare("-")==0) )
+// hasNegCoeff = TRUE; //We have a coeff < 0
+ if(found==0)
+ {
+ if(tmp.compare("-")==0)
+ hasNegCoeff = TRUE;
+ line.erase(0,1); //remove leading + or -
+ found = line.find_first_of("+-"); //adjust found
+ }
+ strMonom = line.substr(0,found);
+ line.erase(0,found);
+ number nCoeff=nInit(1);
+ number nCoeffNom=nInit(1);
+ number nCoeffDenom=nInit(1);
+ found = strMonom.find_first_of("/");
+ if(found!=string::npos) //i.e. "/" exists in strMonom
+ {
+ hasCoeffInQ = TRUE;
+ strCoeffNom=strMonom.substr(0,found);
+ strCoeffDenom=strMonom.substr(found+1,strMonom.find_first_not_of("1234567890",found+1));
+ strMonom.erase(0,found);
+ strMonom.erase(0,strMonom.find_first_not_of("1234567890/"));
+ char *Nom=new char[strCoeffNom.size()+1];
+ char *Denom=new char[strCoeffDenom.size()+1];
+ strcpy(Nom,strCoeffNom.c_str());
+ strcpy(Denom,strCoeffDenom.c_str());
+ nRead(Nom/*strCoeffNom.c_str()*/, &nCoeffNom);
+ nRead(Denom/*strCoeffDenom.c_str()*/, &nCoeffDenom);
+ delete[] Nom;
+ delete[] Denom;
+ }
+ else
+ {
+ found = strMonom.find_first_not_of("1234567890");
+ strCoeff = strMonom.substr(0,found);
+ if(!strCoeff.empty())
+ {
+ char *coeff = new char[strCoeff.size()+1];
+ strcpy(coeff, strCoeff.c_str());
+ nRead(coeff/*strCoeff.c_str()*/,&nCoeff);
+ delete[] coeff;
+ }
+ }
+ char* monom = new char[strMonom.size()+1];
+ strcpy(monom, strMonom.c_str());
+ p_Read(monom,strPoly,currRing); //strPoly:=monom
+ delete[] monom;
+ switch (hasCoeffInQ)
+ {
+ case TRUE:
+ if(hasNegCoeff)
+ nCoeffNom=nNeg(nCoeffNom);
+ pSetCoeff(strPoly, nDiv(nCoeffNom, nCoeffDenom));
+ break;
+ case FALSE:
+ if(hasNegCoeff)
+ nCoeff=nNeg(nCoeff);
+ if(!nIsOne(nCoeff))
+ {
+ pSetCoeff(strPoly, nCoeff );
+ }
+ break;
+ }
+ //pSetCoeff(strPoly, (number) intCoeff);//Why is this set to zero instead of 1???
+ if(pIsConstantComp(resPoly))
+ {
+ resPoly=pCopy(strPoly);
+ pDelete(&strPoly);
+ }
+ else
+ {
+// poly tmp=pAdd(pCopy(resPoly),strPoly);//foo is destroyed
+// pDelete(&resPoly);
+// resPoly=tmp;
+// pDelete(&tmp);
+ resPoly=pAdd(resPoly,strPoly);//pAdd = p_Add_q, destroys args
+ }
+ /*if(nCoeff!=NULL)
+ nDelete(&nCoeff);*/ //NOTE This may cause a crash on certain examples...
+ nDelete(&nCoeffNom);
+ nDelete(&nCoeffDenom);
+ }//while(!line.empty())
+ gc->gcBasis->m[jj]=pCopy(resPoly);
+ pDelete(&resPoly); //reset
+ }
+// break;
+ }//if(line=="GCBASIS")
+ if(line=="FACETS")
+ {
+ facet *fAct=gc->facetPtr;
+ while(fAct!=NULL)
+ {
+ getline(gcInputFile,line);
+ found = line.find("\t");
+ string normalString=line.substr(0,found);
+ int64vec *fN = new int64vec(this->numVars);
+ for(int ii=0;ii<this->numVars;ii++)
+ {
+ string component;
+ found = normalString.find(",");
+ component=normalString.substr(0,found);
+ char *sComp = new char[component.size()+1];
+ strcpy(sComp,component.c_str());
+ (*fN)[ii]=atol(sComp/*component.c_str()*/);
+ delete[] sComp;
+ normalString.erase(0,found+1);
+ }
+ /*Only the following line needs to be commented out if you decide not to delete fNormals*/
+// fAct->setFacetNormal(fN);
+ delete(fN);
+ fAct = fAct->next; //Booh, this is ugly
+ }
+ break; //NOTE Must always be in the last if-block!
+ }
+ }//while(!gcInputFile.eof())
+ gcInputFile.close();
+ rChangeCurrRing(saveRing);
}
-
+
/** \brief Sort the rays of a facet lexicographically
*/
// void gcone::sortRays(gcone *gc)
// {
-// facet *fAct;
-// fAct = this->facetPtr->codim2Ptr;
-// while(fAct->next!=NULL)
-// {
-// if(fAct->fNormal->compare(fAct->fNormal->next)==-1
-// }
+// facet *fAct;
+// fAct = this->facetPtr->codim2Ptr;
+// while(fAct->next!=NULL)
+// {
+// if(fAct->fNormal->compare(fAct->fNormal->next)==-1
+// }
// }
/** \brief Gather the output
@@ -4158,68 +4156,68 @@ void gcone::readConeFromFile(int UCN, gcone *gc)
*/
lists lprepareResult(gcone *gc, const int n)
{
- gcone *gcAct;
- gcAct = gc;
- facet *fAct;
- fAct = gc->facetPtr;
-
- lists res=(lists)omAllocBin(slists_bin);
- res->Init(n); //initialize to store n cones
- for(int ii=0;ii<n;ii++)
- {
- if(gfanHeuristic==1)// && gcAct->getUCN()>1)
- {
- gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
-// rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak?
- }
- rChangeCurrRing(gcAct->getRef2BaseRing());
- res->m[ii].rtyp=LIST_CMD;
- lists l=(lists)omAllocBin(slists_bin);
- l->Init(6);
- l->m[0].rtyp=INT_CMD;
- l->m[0].data=(void*)gcAct->getUCN();
- l->m[1].rtyp=IDEAL_CMD;
- /*The following is necessary for leaves in the tree of cones
- * Since we don't use them in the computation and gcBasis is
- * set to (poly)NULL in noRevS we need to get this back here.
- */
-// if(gcAct->gcBasis->m[0]==(poly)NULL)
-// if(gfanHeuristic==1 && gcAct->getUCN()>1)
-// gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
-// ring saveRing=currRing;
-// ring tmpRing=gcAct->getBaseRing;
-// rChangeCurrRing(tmpRing);
-// l->m[1].data=(void*)idrCopyR_NoSort(gcAct->gcBasis,gcAct->getBaseRing());
-// l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getBaseRing());//NOTE memleak?
- l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getRef2BaseRing());
-// rChangeCurrRing(saveRing);
-
- l->m[2].rtyp=INTVEC_CMD;
- int64vec iv=(gcAct->f2M(gcAct,gcAct->facetPtr));//NOTE memleak?
- l->m[2].data=(void*)iv64Copy(&iv);
-
- l->m[3].rtyp=LIST_CMD;
- lists lCodim2List = (lists)omAllocBin(slists_bin);
- lCodim2List->Init(gcAct->numFacets);
- fAct = gcAct->facetPtr;//fAct->codim2Ptr;
- int jj=0;
- while(fAct!=NULL && jj<gcAct->numFacets)
- {
- lCodim2List->m[jj].rtyp=INTVEC_CMD;
- int64vec ivC2=(gcAct->f2M(gcAct,fAct,2));
- lCodim2List->m[jj].data=(void*)iv64Copy(&ivC2);
- jj++;
- fAct = fAct->next;
- }
- l->m[3].data=(void*)lCodim2List;
- l->m[4].rtyp=INTVEC_CMD/*RING_CMD*/;
- l->m[4].data=(void*)(gcAct->getIntPoint/*BaseRing*/());
- l->m[5].rtyp=INT_CMD;
- l->m[5].data=(void*)gcAct->getPredUCN();
- res->m[ii].data=(void*)l;
- gcAct = gcAct->next;
- }
- return res;
+ gcone *gcAct;
+ gcAct = gc;
+ facet *fAct;
+ fAct = gc->facetPtr;
+
+ lists res=(lists)omAllocBin(slists_bin);
+ res->Init(n); //initialize to store n cones
+ for(int ii=0;ii<n;ii++)
+ {
+ if(gfanHeuristic==1)// && gcAct->getUCN()>1)
+ {
+ gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
+// rChangeCurrRing(gcAct->getBaseRing());//NOTE memleak?
+ }
+ rChangeCurrRing(gcAct->getRef2BaseRing());
+ res->m[ii].rtyp=LIST_CMD;
+ lists l=(lists)omAllocBin(slists_bin);
+ l->Init(6);
+ l->m[0].rtyp=INT_CMD;
+ l->m[0].data=(void*)gcAct->getUCN();
+ l->m[1].rtyp=IDEAL_CMD;
+ /*The following is necessary for leaves in the tree of cones
+ * Since we don't use them in the computation and gcBasis is
+ * set to (poly)NULL in noRevS we need to get this back here.
+ */
+// if(gcAct->gcBasis->m[0]==(poly)NULL)
+// if(gfanHeuristic==1 && gcAct->getUCN()>1)
+// gcAct->readConeFromFile(gcAct->getUCN(),gcAct);
+// ring saveRing=currRing;
+// ring tmpRing=gcAct->getBaseRing;
+// rChangeCurrRing(tmpRing);
+// l->m[1].data=(void*)idrCopyR_NoSort(gcAct->gcBasis,gcAct->getBaseRing());
+// l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getBaseRing());//NOTE memleak?
+ l->m[1].data=(void*)idrCopyR(gcAct->gcBasis,gcAct->getRef2BaseRing());
+// rChangeCurrRing(saveRing);
+
+ l->m[2].rtyp=INTVEC_CMD;
+ int64vec iv=(gcAct->f2M(gcAct,gcAct->facetPtr));//NOTE memleak?
+ l->m[2].data=(void*)iv64Copy(&iv);
+
+ l->m[3].rtyp=LIST_CMD;
+ lists lCodim2List = (lists)omAllocBin(slists_bin);
+ lCodim2List->Init(gcAct->numFacets);
+ fAct = gcAct->facetPtr;//fAct->codim2Ptr;
+ int jj=0;
+ while(fAct!=NULL && jj<gcAct->numFacets)
+ {
+ lCodim2List->m[jj].rtyp=INTVEC_CMD;
+ int64vec ivC2=(gcAct->f2M(gcAct,fAct,2));
+ lCodim2List->m[jj].data=(void*)iv64Copy(&ivC2);
+ jj++;
+ fAct = fAct->next;
+ }
+ l->m[3].data=(void*)lCodim2List;
+ l->m[4].rtyp=INTVEC_CMD/*RING_CMD*/;
+ l->m[4].data=(void*)(gcAct->getIntPoint/*BaseRing*/());
+ l->m[5].rtyp=INT_CMD;
+ l->m[5].data=(void*)gcAct->getPredUCN();
+ res->m[ii].data=(void*)l;
+ gcAct = gcAct->next;
+ }
+ return res;
}
/** Convert gc->gcRays into an intvec in order to be used with bbcone stuff*/
@@ -4228,7 +4226,7 @@ intvec *gcRays2Intmat(gcone *gc)
int r = gc->numRays;
int c = gc->numVars; //Spalten
intvec *res = new intvec(r,c,(int)0);
-
+
int offset=0;
for(int ii=0;ii<gc->numRays;ii++)
{
@@ -4252,7 +4250,7 @@ void prepareGfanLib(gcone *gc, gfan::ZFan *fan)
//Iterate over all cones and adjoin to PolyhedralFan
while(gcAct!=NULL)
- {
+ {
intvec *rays=gcRays2Intmat(gcAct);
ZMatrix zm = intmat2ZMatrix(rays);
delete rays;
@@ -4267,48 +4265,48 @@ void prepareGfanLib(gcone *gc, gfan::ZFan *fan)
}
/** \brief Write facets of a cone into a matrix
-* Takes a pointer to a facet as 2nd arg
+* Takes a pointer to a facet as 2nd arg
* f should always point to gc->facetPtr
* param n is used to determine whether it operates in codim 1 or 2
* We have to cast the int64vecs to int64vec due to issues with list structure
*/
inline int64vec gcone::f2M(gcone *gc, facet *f, int n)
{
- facet *fAct;
- int64vec *res;//=new int64vec(this->numVars);
-// int codim=n;
-// int bound;
-// if(f==gc->facetPtr)
- if(n==1)
- {
- int64vec *m1Res=new int64vec(gc->numFacets,gc->numVars,0);
- res = iv64Copy(m1Res);
- fAct = gc->facetPtr;
- delete m1Res;
-// bound = gc->numFacets*(this->numVars);
- }
- else
- {
- fAct = f->codim2Ptr;
- int64vec *m2Res = new int64vec(f->numCodim2Facets,gc->numVars,0);
- res = iv64Copy(m2Res);
- delete m2Res;
-// bound = fAct->numCodim2Facets*(this->numVars);
-
- }
- int ii=0;
- while(fAct!=NULL )//&& ii < bound )
- {
- const int64vec *fNormal;
- fNormal = fAct->getRef2FacetNormal();//->getFacetNormal();
- for(int jj=0;jj<this->numVars;jj++)
- {
- (*res)[ii]=(int)(*fNormal)[jj];//This is ugly and prone to overflow
- ii++;
- }
- fAct = fAct->next;
- }
- return *res;
+ facet *fAct;
+ int64vec *res;//=new int64vec(this->numVars);
+// int codim=n;
+// int bound;
+// if(f==gc->facetPtr)
+ if(n==1)
+ {
+ int64vec *m1Res=new int64vec(gc->numFacets,gc->numVars,0);
+ res = iv64Copy(m1Res);
+ fAct = gc->facetPtr;
+ delete m1Res;
+// bound = gc->numFacets*(this->numVars);
+ }
+ else
+ {
+ fAct = f->codim2Ptr;
+ int64vec *m2Res = new int64vec(f->numCodim2Facets,gc->numVars,0);
+ res = iv64Copy(m2Res);
+ delete m2Res;
+// bound = fAct->numCodim2Facets*(this->numVars);
+
+ }
+ int ii=0;
+ while(fAct!=NULL )//&& ii < bound )
+ {
+ const int64vec *fNormal;
+ fNormal = fAct->getRef2FacetNormal();//->getFacetNormal();
+ for(int jj=0;jj<this->numVars;jj++)
+ {
+ (*res)[ii]=(int)(*fNormal)[jj];//This is ugly and prone to overflow
+ ii++;
+ }
+ fAct = fAct->next;
+ }
+ return *res;
}
int gcone::counter=0;
@@ -4342,7 +4340,7 @@ int gcone::numVars;
bool gcone::hasHomInput=FALSE;
int64vec *gcone::ivZeroVector;
// ideal gfan(ideal inputIdeal, int h)
-/** Main routine
+/** Main routine
* The first and second parameter are mandatory. The third (and maybe fourth) parameter is for Janko :)
*/
#ifndef USE_ZFAN
@@ -4351,147 +4349,147 @@ lists grfan(ideal inputIdeal, int h, bool singleCone=FALSE)
gfan::ZFan* grfan(ideal inputIdeal, int h, bool singleCone=FALSE)
#endif
{
- lists lResList; //this is the object we return
- gfan::ZFan *zResFan = new gfan::ZFan(pVariables);
-
- if(rHasGlobalOrdering(currRing))
- {
-// int numvar = pVariables;
- gfanHeuristic = h;
-
- enum searchMethod {
- reverseSearch,
- noRevS
- };
-
- searchMethod method;
- method = noRevS;
-
- ring inputRing=currRing; // The ring the user entered
-// ring rootRing; // The ring associated to the target ordering
-
- dd_set_global_constants();
- if(method==noRevS)
- {
- gcone *gcRoot = new gcone(currRing,inputIdeal);
- gcone *gcAct;
- gcAct = gcRoot;
- gcone::numVars=pVariables;
- //gcAct->numVars=pVariables;//NOTE is now static
- gcAct->getGB(inputIdeal);
- /*Check whether input is homogeneous
- if TRUE each facet intersects the positive orthant, so we don't need the
- flippability test in getConeNormals & getExtremalRays
- */
- if(idHomIdeal(gcAct->gcBasis,NULL))//disabled for tests
- {
- gcone::hasHomInput=TRUE;
-// gcone::hilbertFunction=hHstdSeries(inputIdeal,NULL,NULL,NULL,currRing);
- }
- else
- {
- gcone::ivZeroVector = new int64vec(pVariables);
- for(int ii=0;ii<pVariables;ii++)
- (*gcone::ivZeroVector)[ii]=0;
- }
-
- if(isMonomial(gcAct->gcBasis))
- {//FIXME
- WerrorS("Monomial input - terminating");
- dd_free_global_constants();
- //This is filthy
- goto pointOfNoReturn;
- }
- gcAct->getConeNormals(gcAct->gcBasis);
- gcone::dd_LinealitySpace = gcAct->computeLinealitySpace();
- gcAct->getExtremalRays(*gcAct);
- if(singleCone==FALSE)//Is Janko here?
- {//Compute the whole fan
- gcAct->noRevS(*gcAct); //Here we go!
- }
- //Switch back to the ring the computation was started in
- rChangeCurrRing(inputRing);
- //res=gcAct->gcBasis;
- //Below is a workaround, since gcAct->gcBasis gets deleted in noRevS
+ lists lResList; //this is the object we return
+ gfan::ZFan *zResFan = new gfan::ZFan(pVariables);
+
+ if(rHasGlobalOrdering(currRing))
+ {
+// int numvar = pVariables;
+ gfanHeuristic = h;
+
+ enum searchMethod {
+ reverseSearch,
+ noRevS
+ };
+
+ searchMethod method;
+ method = noRevS;
+
+ ring inputRing=currRing; // The ring the user entered
+// ring rootRing; // The ring associated to the target ordering
+
+ dd_set_global_constants();
+ if(method==noRevS)
+ {
+ gcone *gcRoot = new gcone(currRing,inputIdeal);
+ gcone *gcAct;
+ gcAct = gcRoot;
+ gcone::numVars=pVariables;
+ //gcAct->numVars=pVariables;//NOTE is now static
+ gcAct->getGB(inputIdeal);
+ /*Check whether input is homogeneous
+ if TRUE each facet intersects the positive orthant, so we don't need the
+ flippability test in getConeNormals & getExtremalRays
+ */
+ if(idHomIdeal(gcAct->gcBasis,NULL))//disabled for tests
+ {
+ gcone::hasHomInput=TRUE;
+// gcone::hilbertFunction=hHstdSeries(inputIdeal,NULL,NULL,NULL,currRing);
+ }
+ else
+ {
+ gcone::ivZeroVector = new int64vec(pVariables);
+ for(int ii=0;ii<pVariables;ii++)
+ (*gcone::ivZeroVector)[ii]=0;
+ }
+
+ if(isMonomial(gcAct->gcBasis))
+ {//FIXME
+ WerrorS("Monomial input - terminating");
+ dd_free_global_constants();
+ //This is filthy
+ goto pointOfNoReturn;
+ }
+ gcAct->getConeNormals(gcAct->gcBasis);
+ gcone::dd_LinealitySpace = gcAct->computeLinealitySpace();
+ gcAct->getExtremalRays(*gcAct);
+ if(singleCone==FALSE)//Is Janko here?
+ {//Compute the whole fan
+ gcAct->noRevS(*gcAct); //Here we go!
+ }
+ //Switch back to the ring the computation was started in
+ rChangeCurrRing(inputRing);
+ //res=gcAct->gcBasis;
+ //Below is a workaround, since gcAct->gcBasis gets deleted in noRevS
#ifndef USE_ZFAN
- lResList=lprepareResult(gcRoot,gcRoot->getCounter());
+ lResList=lprepareResult(gcRoot,gcRoot->getCounter());
#else
- prepareGfanLib(gcRoot,zResFan);
+ prepareGfanLib(gcRoot,zResFan);
#endif
- /*Cleanup*/
- gcone *gcDel;
- gcDel = gcRoot;
- gcAct = gcRoot;
- while(gcAct!=NULL)
- {
- gcDel = gcAct;
- gcAct = gcAct->next;
-// delete gcDel;
- }
- }//method==noRevS
- dd_FreeMatrix(gcone::dd_LinealitySpace);
- dd_free_global_constants();
- }//rHasGlobalOrdering
- else
- {
- //Simply return an empty list
- WerrorS("Ring has non-global ordering.\nThis function requires your current ring to be endowed with a global ordering.\n Now terminating!");
-// gcone *gcRoot=new gcone();
-// gcone *gcPtr = gcRoot;
-// for(int ii=0;ii<10000;ii++)
-// {
-// gcPtr->setBaseRing(currRing);
-// facet *fPtr=gcPtr->facetPtr=new facet();
-// for(int jj=0;jj<5;jj++)
-// {
-// int64vec *iv=new int64vec(pVariables);
-// fPtr->setFacetNormal(iv);
-// delete(iv);
-// fPtr->next=new facet();
-// fPtr=fPtr->next;
-// }
-// gcPtr->next=new gcone();
-// gcPtr->next->prev=gcPtr;
-// gcPtr=gcPtr->next;
-// }
-// gcPtr=gcRoot;
-// while(gcPtr!=NULL)
-// {
-// gcPtr=gcPtr->next;
-// // delete(gcPtr->prev);
-// }
- goto pointOfNoReturn;
- }
- /*Return result*/
+ /*Cleanup*/
+ gcone *gcDel;
+ gcDel = gcRoot;
+ gcAct = gcRoot;
+ while(gcAct!=NULL)
+ {
+ gcDel = gcAct;
+ gcAct = gcAct->next;
+// delete gcDel;
+ }
+ }//method==noRevS
+ dd_FreeMatrix(gcone::dd_LinealitySpace);
+ dd_free_global_constants();
+ }//rHasGlobalOrdering
+ else
+ {
+ //Simply return an empty list
+ WerrorS("Ring has non-global ordering.\nThis function requires your current ring to be endowed with a global ordering.\n Now terminating!");
+// gcone *gcRoot=new gcone();
+// gcone *gcPtr = gcRoot;
+// for(int ii=0;ii<10000;ii++)
+// {
+// gcPtr->setBaseRing(currRing);
+// facet *fPtr=gcPtr->facetPtr=new facet();
+// for(int jj=0;jj<5;jj++)
+// {
+// int64vec *iv=new int64vec(pVariables);
+// fPtr->setFacetNormal(iv);
+// delete(iv);
+// fPtr->next=new facet();
+// fPtr=fPtr->next;
+// }
+// gcPtr->next=new gcone();
+// gcPtr->next->prev=gcPtr;
+// gcPtr=gcPtr->next;
+// }
+// gcPtr=gcRoot;
+// while(gcPtr!=NULL)
+// {
+// gcPtr=gcPtr->next;
+// // delete(gcPtr->prev);
+// }
+ goto pointOfNoReturn;
+ }
+ /*Return result*/
#ifdef gfanp
- cout << endl << "t_getConeNormals:" << gcone::time_getConeNormals << endl;
- /*cout << "t_getCodim2Normals:" << gcone::time_getCodim2Normals << endl;
- cout << " t_ddMC:" << gcone::t_ddMC << endl;
- cout << " t_mI:" << gcone::t_mI << endl;
- cout << " t_iP:" << gcone::t_iP << endl;*/
- cout << "t_getExtremalRays:" << gcone::t_getExtremalRays << endl;
- cout << " t_ddPolyh:" << gcone::t_ddPolyh << endl;
- cout << "t_Flip:" << gcone::time_flip << endl;
- cout << " t_markings:" << gcone::t_markings << endl;
- cout << " t_dd:" << gcone::t_dd << endl;
- cout << " t_kStd:" << gcone::t_kStd << endl;
- cout << "t_Flip2:" << gcone::time_flip2 << endl;
- cout << " t_dd:" << gcone::t_dd << endl;
- cout << " t_kStd:" << gcone::t_kStd << endl;
- cout << "t_computeInv:" << gcone::time_computeInv << endl;
- cout << "t_enqueue:" << gcone::time_enqueue << endl;
- cout << " t_areEqual:" <<gcone::t_areEqual << endl;
- cout << "t_isParallel:" <<gcone::t_isParallel << endl;
- cout << endl;
- cout << "Checked " << gcone::numberOfFacetChecks << " Facets" << endl;
- cout << " out of which there were " << gcone::parallelButNotEqual << " parallel but not equal." << endl;
+ cout << endl << "t_getConeNormals:" << gcone::time_getConeNormals << endl;
+ /*cout << "t_getCodim2Normals:" << gcone::time_getCodim2Normals << endl;
+ cout << " t_ddMC:" << gcone::t_ddMC << endl;
+ cout << " t_mI:" << gcone::t_mI << endl;
+ cout << " t_iP:" << gcone::t_iP << endl;*/
+ cout << "t_getExtremalRays:" << gcone::t_getExtremalRays << endl;
+ cout << " t_ddPolyh:" << gcone::t_ddPolyh << endl;
+ cout << "t_Flip:" << gcone::time_flip << endl;
+ cout << " t_markings:" << gcone::t_markings << endl;
+ cout << " t_dd:" << gcone::t_dd << endl;
+ cout << " t_kStd:" << gcone::t_kStd << endl;
+ cout << "t_Flip2:" << gcone::time_flip2 << endl;
+ cout << " t_dd:" << gcone::t_dd << endl;
+ cout << " t_kStd:" << gcone::t_kStd << endl;
+ cout << "t_computeInv:" << gcone::time_computeInv << endl;
+ cout << "t_enqueue:" << gcone::time_enqueue << endl;
+ cout << " t_areEqual:" <<gcone::t_areEqual << endl;
+ cout << "t_isParallel:" <<gcone::t_isParallel << endl;
+ cout << endl;
+ cout << "Checked " << gcone::numberOfFacetChecks << " Facets" << endl;
+ cout << " out of which there were " << gcone::parallelButNotEqual << " parallel but not equal." << endl;
#endif
- printf("Maximum lenght of list of facets: %i", gcone::maxSize);
+ printf("Maximum length of list of facets: %i", gcone::maxSize);
pointOfNoReturn:
#ifndef USE_ZFAN
- return lResList;
+ return lResList;
#else
- return zResFan;
+ return zResFan;
#endif
}
diff --git a/kernel/Poly.h b/kernel/Poly.h
index d119593..de7d2b9 100644
--- a/kernel/Poly.h
+++ b/kernel/Poly.h
@@ -1,7 +1,3 @@
-//$Id$
-
-
-
#ifndef POLYCPP_HEADER
#define POLYCPP_HEADER
#include <kernel/mod2.h>
@@ -100,7 +96,7 @@ class PolyImpl{
return *this;
}
p=p_Add_q(p,p_Copy(p2.p,p2.r.get()),r.get());
-
+
return *this;
}
PolyImpl& operator*=(const PolyImpl & p2){
@@ -121,7 +117,7 @@ class PolyImpl{
Werror("not the same ring");
return *this;
}
-
+
p=p_Mult_nn(p,n.n,r.get());
return *this;
}
@@ -140,19 +136,19 @@ class PolyImpl{
pc=p_Neg(pc,r.get());
p=p_Add_q(p,pc,r.get());
-
+
return *this;
}
PolyImpl& operator=(int n){
-
+
p_Delete(&p,r.get());
p=p_ISet(n,r.get());
return *this;
-
+
}
-
+
PolyImpl(){
r=currRing;
@@ -175,10 +171,10 @@ class PolyImpl{
this->r=r;
}
PolyImpl(const Number & n){
-
+
r=n.r.get();
this->p=p_NSet(n_Copy(n.n,r.get()),r.get());
-
+
}
explicit PolyImpl(int n){
r=currRing;
@@ -262,14 +258,14 @@ template<class T> class ConstTermReference{
bool isConstant() const{
return p_LmIsConstant(t,r);
}
-
+
};
template<class T> class PolyInputIterator:
public std::iterator<std::input_iterator_tag,T,int, shared_ptr<const T>,ConstTermReference<T> >
{
-
+
private:
poly t;
ring r;
@@ -332,7 +328,7 @@ template<poly_variant variant, class create_type_input, class error_handle_trait
res[i]=p_GetExp(ptr->p,i+1,ptr->getRing());
}
return res;
- }
+ }
void copy_on_write(){
if (!ptr.unique()){
ptr.reset(new PolyImpl(*ptr));
@@ -341,7 +337,7 @@ template<poly_variant variant, class create_type_input, class error_handle_trait
void print() const {
ptr->print();
}
- //* ressource managed by Singular
+ //* resource managed by Singular
char* c_string() const{
return p_String(ptr->p,ptr->getRing(),ptr->getRing());
@@ -366,14 +362,14 @@ template<poly_variant variant, class create_type_input, class error_handle_trait
checkIsSameRing(p2);
copy_on_write();
*ptr += *p2.ptr;
-
+
return *this;
}
PolyBase& operator*=(const Poly & p2);
PolyBase& operator*=(Number n){
copy_on_write();
*ptr *=n;
-
+
return *this;
}
/* void print(){
@@ -411,9 +407,9 @@ template<poly_variant variant, class create_type_input, class error_handle_trait
return erg;
}
protected:
-
+
PolyBase(PolyImpl& impl):ptr(&impl){
-
+
}
poly getInternalReference(){
return ptr->getInternalReference();
@@ -434,19 +430,19 @@ class Poly: public PolyBase<POLY_VARIANT_RING, Poly, MyErrorHandler>{
Poly(ring r=currRing):Base ((poly)NULL,r,0){
}
Poly(int n, ring r=currRing):Base(*(new PolyImpl(n,r))){
-
+
}
Poly(const char* c, ring r=currRing):Base(c,r){
}
Poly(const Base& p):Base(p){
}
-
+
Poly(const Number& n):Base(*(new PolyImpl(n))){
-
+
}
Poly(poly p, ring r):Base(p,r){
-
+
}
Poly(poly p, ring r, int):Base(p,r,0){
}
@@ -486,17 +482,17 @@ class Vector: public PolyBase<POLY_VARIANT_MODUL, Vector, MyErrorHandler>{
Vector(ring r=currRing):Base ((poly)NULL,r,0){
}
Vector(int n, ring r=currRing):Base(*(new PolyImpl(n,r))){
-
+
}
Vector(const char* c, ring r=currRing):Base(c,r){
}
Vector(const Base& p):Base(p){
}
-
+
Vector(poly p, ring r):Base(p,r){
-
+
}
Vector(poly p, ring r, int):Base(p,r,0){
}
@@ -556,10 +552,10 @@ inline Vector operator*(const Number& n, const Vector& v){
}
//assumes monomials commute with numbers
-template <poly_variant variant, class create_type, class error_traits>
- inline typename PolyBase<variant,create_type, error_traits>::create_type
+template <poly_variant variant, class create_type, class error_traits>
+ inline typename PolyBase<variant,create_type, error_traits>::create_type
operator*
- (const Number& n,
+ (const Number& n,
const PolyBase<variant,create_type, class error_tratis>& p)
{
typename PolyBase<variant, create_type,error_traits>::create_type erg(p);
@@ -589,10 +585,10 @@ inline bool operator==(const Vector& p1, const Vector& p2){
if (r1!=r2) return false;
return p_EqualPolys(p1.ptr->p,p2.ptr->p,r1);
}
-template <poly_variant variant, class create_type,class error_traits>
- inline typename PolyBase<variant,create_type,error_traits>::create_type
+template <poly_variant variant, class create_type,class error_traits>
+ inline typename PolyBase<variant,create_type,error_traits>::create_type
operator+
- (const PolyBase<variant,create_type,error_traits>& b1,
+ (const PolyBase<variant,create_type,error_traits>& b1,
const PolyBase<variant,create_type,error_traits>& b2)
{
typename PolyBase<variant, create_type, error_traits>::create_type erg(b1);
@@ -609,13 +605,13 @@ inline Poly operator*(const Number& n, const Poly & p){
res*=n;
return res;
}
-template <poly_variant variant, class create_type, class error_traits>
-
-inline PolyBase<variant, create_type, error_traits>&
+template <poly_variant variant, class create_type, class error_traits>
+
+inline PolyBase<variant, create_type, error_traits>&
PolyBase<variant, create_type, error_traits>::operator*=(const Poly & p2){
copy_on_write();
*ptr *= *p2.ptr;
-
+
return *this;
}
#endif
diff --git a/kernel/fast_mult.cc b/kernel/fast_mult.cc
index c77868e..120a29a 100644
--- a/kernel/fast_mult.cc
+++ b/kernel/fast_mult.cc
@@ -1,7 +1,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
#include <kernel/mod2.h>
#include <kernel/ring.h>
#include <kernel/fast_mult.h>
@@ -590,7 +589,7 @@ poly pFastPowerMC(poly f, int n, ring r)
if (n<=1)
Werror("not implemented for so small n, recursion fails");//should be length(f)
if (pLength(f)<=1)
- Werror("not implemented for so small lenght of f, recursion fails");
+ Werror("not implemented for so small length of f, recursion fails");
// number null_number=n_Init(0,r);
number* facult=(number*) omAlloc((n+1)*sizeof(number));
facult[0]=n_Init(1,r);
diff --git a/kernel/febase.cc b/kernel/febase.cc
index 676ef45..865c9d7 100644
--- a/kernel/febase.cc
+++ b/kernel/febase.cc
@@ -1,7 +1,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
/*
* ABSTRACT: i/o system
*/
@@ -112,7 +111,7 @@ void VoiceBackTrack()
}
/*2
-* init a new voice similiar to the current
+* init a new voice similar to the current
*/
void Voice::Next()
{
diff --git a/kernel/kstd1.cc b/kernel/kstd1.cc
index 67fb567..dd98db2 100644
--- a/kernel/kstd1.cc
+++ b/kernel/kstd1.cc
@@ -1,7 +1,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
/*
* ABSTRACT:
*/
@@ -2363,7 +2362,7 @@ ideal kInterRedBba (ideal F, ideal Q, int &need_retry)
message(strat->P.pFDeg(),
&olddeg,&reduc,strat, red_result);
- /* reduction of the element choosen from L */
+ /* reduction of the element chosen from L */
red_result = strat->red(&strat->P,strat);
}
diff --git a/kernel/kstd2.cc b/kernel/kstd2.cc
index acc9a9f..6a8a1b7 100644
--- a/kernel/kstd2.cc
+++ b/kernel/kstd2.cc
@@ -1,7 +1,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
/*
* ABSTRACT - Kernel: alg. of Buchberger
*/
@@ -1111,7 +1110,7 @@ ideal bba (ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat)
message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
&olddeg,&reduc,strat, red_result);
- /* reduction of the element choosen from L */
+ /* reduction of the element chosen from L */
red_result = strat->red(&strat->P,strat);
if (errorreported) break;
}
@@ -1604,7 +1603,7 @@ ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat, int upto
message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
&olddeg,&reduc,strat, red_result);
- /* reduction of the element choosen from L */
+ /* reduction of the element chosen from L */
red_result = strat->red(&strat->P,strat);
}
diff --git a/kernel/kstdfac.cc b/kernel/kstdfac.cc
index 572bdab..437a9d5 100644
--- a/kernel/kstdfac.cc
+++ b/kernel/kstdfac.cc
@@ -1,7 +1,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
/*
* ABSTRACT - Kernel: factorizing alg. of Buchberger
*/
@@ -600,7 +599,7 @@ ideal bbafac (ideal F, ideal Q,intvec *w,kStrategy strat, ideal_list FL)
if (TEST_OPT_PROT)
message(pFDeg(strat->P.p,currRing),&olddeg,&reduc,strat, red_result);
}
- /* reduction of the element choosen from L */
+ /* reduction of the element chosen from L */
kTest_TS(strat);
red_result = strat->red(&strat->P,strat);
if (strat->P.p != NULL)
diff --git a/kernel/mpr_base.cc b/kernel/mpr_base.cc
index e67757c..100b670 100644
--- a/kernel/mpr_base.cc
+++ b/kernel/mpr_base.cc
@@ -1452,7 +1452,7 @@ int resMatrixSparse::createMatrix( pointSet *E )
if ( epos == 0 )
{
// this can happen, if the shift vektor or the lift funktions
- // are not generically choosen.
+ // are not generically chosen.
Werror("resMatrixSparse::createMatrix: Found exponent not in E, id %d, set [%d, %d]!",
i,(*E)[i]->rc.set,(*E)[i]->rc.pnt);
return i;
@@ -2708,7 +2708,7 @@ uResultant::uResultant( const ideal _gls, const resMatType _rmt, BOOLEAN extIdea
break;
#endif
default:
- WerrorS("uResultant::uResultant: Unknown resultant matrix type choosen!");
+ WerrorS("uResultant::uResultant: Unknown resultant matrix type chosen!");
}
}
@@ -2739,7 +2739,7 @@ ideal uResultant::extendIdeal( const ideal igls, poly linPoly, const resMatType
}
break;
default:
- WerrorS("uResultant::extendIdeal: Unknown resultant matrix type choosen!");
+ WerrorS("uResultant::extendIdeal: Unknown resultant matrix type chosen!");
}
return( newGls );
diff --git a/kernel/mpr_inout.cc b/kernel/mpr_inout.cc
index a741905..f8c9b7e 100644
--- a/kernel/mpr_inout.cc
+++ b/kernel/mpr_inout.cc
@@ -2,8 +2,6 @@
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
-
/*
* ABSTRACT - multipolynomial resultant
*/
@@ -64,7 +62,7 @@ void mprPrintError( mprState state, const char * name )
switch (state)
{
case mprWrongRType:
- WerrorS("Unknown resultant matrix type choosen!");
+ WerrorS("Unknown resultant matrix type chosen!");
break;
case mprHasOne:
Werror("One element of the ideal %s is constant!",name);
diff --git a/kernel/p_Procs_Impl.h b/kernel/p_Procs_Impl.h
index 6a7d8a2..7a009bb 100644
--- a/kernel/p_Procs_Impl.h
+++ b/kernel/p_Procs_Impl.h
@@ -6,33 +6,32 @@
* Purpose: implementation of primitive procs for polys
* Author: obachman (Olaf Bachmann)
* Created: 12/00
- * Version: $Id$
*******************************************************************/
#ifndef P_PROCS_IMPL_H
#define P_PROCS_IMPL_H
/***************************************************************
- *
+ *
* Configurations
- *
+ *
*******************************************************************/
/***************************************************************
Here is how it works:
- At run-time, SetProcs is used to choose the appropriate PolyProcs
+ At run-time, SetProcs is used to choose the appropriate PolyProcs
based on the ring properies.
- At generate-time, SetProcs is used to generate all
+ At generate-time, SetProcs is used to generate all
possible PolyProcs.
- Which PolyProcs are generated/used can be controled by values of
+ Which PolyProcs are generated/used can be controled by values of
HAVE_FAST_P_PROCS, HAVE_FAST_LENGTH, HAVE_FAST_ORD, and FAST_FIELD
-
+
At generate-time, the file p_Procs.inc is generated,
which provides implementations of the p_Procs, based on
the p_*_Templates.cc and header files which provide the respective
macros.
- At run-time, a fast proc is set/choosen if found/generated, else
- a general proc is set/choosen.
+ At run-time, a fast proc is set/chosen if found/generated, else
+ a general proc is set/chosen.
*******************************************************************/
// Define HAVE_FAST_P_PROCS to:
@@ -51,7 +50,7 @@
// 1 -- special cases for FieldZp
// 2 -- plus special cases for FieldQ
// nothing else is implemented, yet
-#ifndef HAVE_FAST_FIELD
+#ifndef HAVE_FAST_FIELD
#define HAVE_FAST_FIELD 0
#endif
@@ -61,7 +60,7 @@
// 2 -- special cases for length <= 2
// 3 -- special cases for length <= 4
// 4 -- special cases for length <= 8
-#ifndef HAVE_FAST_LENGTH
+#ifndef HAVE_FAST_LENGTH
#define HAVE_FAST_LENGTH 0
#endif
@@ -71,15 +70,15 @@
// 2 -- special for ords with n_min <= 2
// 3 -- special ords for with n_min <= 3
// 4 -- special for all ords
-#ifndef HAVE_FAST_ORD
+#ifndef HAVE_FAST_ORD
#define HAVE_FAST_ORD 0
#endif
// Define HAVE_FAST_ZERO_ORD to:
-// 0 -- no zero ords are considered
+// 0 -- no zero ords are considered
// 1 -- only ZeroOrds for OrdPosNomogPosZero, OrdNomogPosZero, OrdPomogNegZero
// 2 -- ZeroOrds for all
-#ifndef HAVE_FAST_ZERO_ORD
+#ifndef HAVE_FAST_ZERO_ORD
#define HAVE_FAST_ZERO_ORD 0
#endif
@@ -128,7 +127,7 @@ typedef enum p_Field
typedef enum p_Length // Length of exponent vector in words
{
LengthGeneral = 0, // n >= 1
- LengthEight, // n == 8
+ LengthEight, // n == 8
LengthSeven,
LengthSix,
LengthFive,
@@ -138,10 +137,10 @@ typedef enum p_Length // Length of exponent vector in words
LengthOne,
LengthUnknown
} p_Length;
-typedef enum p_Ord
-{
- OrdGeneral = 0,
- // ordsgn
+typedef enum p_Ord
+{
+ OrdGeneral = 0,
+ // ordsgn
// 0 1 i n-1 n n_min Example
OrdPomog, // + + + + + 1 (lp,C)
OrdNomog, // - - - - - 1 (ls, c), (ds, c)
@@ -206,7 +205,7 @@ static inline const char* p_FieldEnum_2_String(p_Field field)
switch(field)
{
case FieldGeneral: return "FieldGeneral";
- case FieldZp: return "FieldZp";
+ case FieldZp: return "FieldZp";
case FieldQ: return "FieldQ";
case FieldR: return "FieldR";
case FieldGF: return "FieldGF";
@@ -228,8 +227,8 @@ static inline const char* p_LengthEnum_2_String(p_Length length)
{
switch(length)
{
- case LengthGeneral: return "LengthGeneral";
- case LengthEight: return "LengthEight";
+ case LengthGeneral: return "LengthGeneral";
+ case LengthEight: return "LengthEight";
case LengthSeven: return "LengthSeven";
case LengthSix: return "LengthSix";
case LengthFive: return "LengthFive";
@@ -246,23 +245,23 @@ static inline const char* p_OrdEnum_2_String(p_Ord ord)
{
switch(ord)
{
- case OrdGeneral: return "OrdGeneral";
- case OrdPomog: return "OrdPomog";
- case OrdNomog: return "OrdNomog";
- case OrdNegPomog: return "OrdNegPomog";
- case OrdPomogNeg: return "OrdPomogNeg";
- case OrdPosNomog: return "OrdPosNomog";
- case OrdNomogPos: return "OrdNomogPos";
- case OrdPosPosNomog: return "OrdPosPosNomog";
- case OrdPosNomogPos: return "OrdPosNomogPos";
- case OrdNegPosNomog: return "OrdNegPosNomog";
+ case OrdGeneral: return "OrdGeneral";
+ case OrdPomog: return "OrdPomog";
+ case OrdNomog: return "OrdNomog";
+ case OrdNegPomog: return "OrdNegPomog";
+ case OrdPomogNeg: return "OrdPomogNeg";
+ case OrdPosNomog: return "OrdPosNomog";
+ case OrdNomogPos: return "OrdNomogPos";
+ case OrdPosPosNomog: return "OrdPosPosNomog";
+ case OrdPosNomogPos: return "OrdPosNomogPos";
+ case OrdNegPosNomog: return "OrdNegPosNomog";
#ifdef HAVE_LENGTH_DIFF
- case OrdNegPomogZero: return "OrdNegPomogZero";
- case OrdPomogNegZero: return "OrdPomogNegZero";
- case OrdPomogZero: return "OrdPomogZero";
- case OrdNomogZero: return "OrdNomogZero";
- case OrdNomogPosZero: return "OrdNomogPosZero";
- case OrdPosNomogZero: return "OrdPosNomogZero";
+ case OrdNegPomogZero: return "OrdNegPomogZero";
+ case OrdPomogNegZero: return "OrdPomogNegZero";
+ case OrdPomogZero: return "OrdPomogZero";
+ case OrdNomogZero: return "OrdNomogZero";
+ case OrdNomogPosZero: return "OrdNomogPosZero";
+ case OrdPosNomogZero: return "OrdPosNomogZero";
case OrdPosPosNomogZero: return "OrdPosPosNomogZero";
case OrdPosNomogPosZero: return "OrdPosNomogPosZero";
case OrdNegPosNomogZero: return "OrdNegPosNomogZero";
@@ -314,7 +313,7 @@ static inline int p_ProcDependsOn_Ord(p_Proc proc)
case p_kBucketSetLm_Proc:
case p_Merge_q_Proc:
return 1;
-
+
default:
return 0;
}
@@ -328,12 +327,12 @@ static inline int p_ProcDependsOn_Length(p_Proc proc)
case p_Mult_nn_Proc:
case p_Neg_Proc:
return 0;
-
+
default:
return 1;
}
}
-
+
// returns string specifying the module into which the p_Proc
// should go
static inline const char* p_ProcField_2_Module(p_Proc proc, p_Field field)
@@ -348,10 +347,10 @@ static inline const char* p_ProcField_2_Module(p_Proc proc, p_Field field)
}
/***************************************************************
- *
- *
+ *
+ *
* Deal with OrdZero
- *
+ *
*******************************************************************/
#ifdef HAVE_LENGTH_DIFF
static inline int IsZeroOrd(p_Ord ord)
@@ -375,7 +374,7 @@ static inline p_Ord ZeroOrd_2_NonZeroOrd(p_Ord ord, int strict)
case OrdPosNomogZero: return OrdPosNomog;
case OrdPosPosNomogZero: return OrdPosPosNomog;
case OrdNegPosNomogZero: return OrdNegPosNomog;
- default:
+ default:
if (strict) return OrdGeneral;
else if (ord == OrdPomogNegZero) return OrdPomogNeg;
else if (ord == OrdNomogPosZero) return OrdNomogPos;
@@ -394,13 +393,13 @@ static inline p_Ord ZeroOrd_2_NonZeroOrd(p_Ord ord, int strict)
#endif
/***************************************************************
- *
- * Filters which are applied to field/length/ord, before a proc is
- * choosen
- *
+ *
+ * Filters which are applied to field/length/ord, before a proc is
+ * chosen
+ *
*******************************************************************/
#ifdef p_Procs_Static
-static inline void StaticKernelFilter(p_Field &field, p_Length &length,
+static inline void StaticKernelFilter(p_Field &field, p_Length &length,
p_Ord &ord, const p_Proc proc)
{
// simply exclude some things
@@ -503,12 +502,12 @@ static inline void p_Add_q__Filter(p_Length &length, p_Ord &ord)
}
}
-static inline void pp_Mult_mm_Noether_Filter(p_Field &field,
+static inline void pp_Mult_mm_Noether_Filter(p_Field &field,
p_Length &length, p_Ord &ord)
{
- if (ord == OrdPomog
+ if (ord == OrdPomog
|| ord == OrdPomogZero
- || (ord == OrdPomogNeg && length > LengthTwo)
+ || (ord == OrdPomogNeg && length > LengthTwo)
#ifdef HAVE_LENGTH_DIFF
|| (ord == OrdPomogZero)
|| (ord == OrdPomogNegZero && length > LengthThree)
@@ -648,8 +647,8 @@ static inline int index(p_Proc proc, p_Field field, p_Length length, p_Ord ord)
/***************************************************************
- *
- * Macros for setting procs -- these are used for
+ *
+ * Macros for setting procs -- these are used for
* generation and setting
*
***************************************************************/
@@ -664,7 +663,7 @@ do \
DoSetProc(what, t_field, t_length, t_ord); \
} \
while (0) \
-
+
#define SetProcs(field, length, ord) \
do \
{ \
diff --git a/kernel/sca.cc b/kernel/sca.cc
index 0db4c10..e28496f 100644
--- a/kernel/sca.cc
+++ b/kernel/sca.cc
@@ -6,7 +6,6 @@
* Purpose: supercommutative kernel procedures
* Author: motsak (Oleksandr Motsak)
* Created: 2006/12/18
- * Version: $Id$
*******************************************************************/
// set it here if needed.
@@ -1738,7 +1737,7 @@ ideal sca_bba (const ideal F, const ideal Q, const intvec *w, const intvec * /*h
if (test_PosInL!=NULL) strat->posInL=test_PosInL;
kDebugPrint(strat);
}
-
+
///////////////////////////////////////////////////////////////
// SCA:
@@ -1873,7 +1872,7 @@ ideal sca_bba (const ideal F, const ideal Q, const intvec *w, const intvec * /*h
message((strat->honey ? strat->P.ecart : 0) + strat->P.pFDeg(),
&olddeg,&reduc,strat, red_result);
- /* reduction of the element choosen from L */
+ /* reduction of the element chosen from L */
red_result = strat->red(&strat->P,strat);
@@ -1996,7 +1995,7 @@ ideal sca_bba (const ideal F, const ideal Q, const intvec *w, const intvec * /*h
h.PrepareRed(strat->use_buckets);
- // reduction of the element choosen from L(?)
+ // reduction of the element chosen from L(?)
red_result = strat->red(&h,strat);
// reduction to non-zero new poly
diff --git a/kernel/walkProc.cc b/kernel/walkProc.cc
index 1f2e614..18945b7 100644
--- a/kernel/walkProc.cc
+++ b/kernel/walkProc.cc
@@ -1,7 +1,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
#include <kernel/mod2.h>
#include <kernel/structs.h>
@@ -106,7 +105,7 @@ walkConsistency( ring sring, ring dring, int * vperm )
for ( k= npar-1; (k >= 0) && (state == WalkOk); k-- )
if ( pperm[k] >= 0 )
{
- WerrorS( "paramater names do not agree" );
+ WerrorS( "parameter names do not agree" );
state= WalkIncompatibleRings;
}
diff --git a/libfac/charset/algfactor.cc b/libfac/charset/algfactor.cc
index 808b803..22e1dbd 100644
--- a/libfac/charset/algfactor.cc
+++ b/libfac/charset/algfactor.cc
@@ -1,7 +1,6 @@
////////////////////////////////////////////////////////////
// emacs edit mode for this file is -*- C++ -*-
////////////////////////////////////////////////////////////
-/* $Id$ */
////////////////////////////////////////////////////////////
// FACTORY - Includes
#include <factory.h>
@@ -142,7 +141,7 @@ algcd(const CanonicalForm & F, const CanonicalForm & g, const CFList & as, const
DEBOUTLN(CERR, " g= ", g);
DEBOUTLN(CERR, " as= ", as);
DEBOUTLN(CERR, " order= ", order);
- DEBOUTLN(CERR, " choosen vf= ", vf);
+ DEBOUTLN(CERR, " chosen vf= ", vf);
// check trivial case:
if ( degree(f, order.getLast())==0 || degree(g, order.getLast())==0)
diff --git a/libfac/factor/Factor.cc b/libfac/factor/Factor.cc
index 8094186..bece7a8 100644
--- a/libfac/factor/Factor.cc
+++ b/libfac/factor/Factor.cc
@@ -1,5 +1,4 @@
///////////////////////////////////////////////////////////////////////////////
-/* $Id$ */
static const char * errmsg = "\nYou found a bug!\nPlease inform singular at mathematik.uni-kl.de\nPlease include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
///////////////////////////////////////////////////////////////////////////////
// FACTORY - Includes
@@ -121,7 +120,7 @@ choose_main_variable( const CanonicalForm & f, int Mainvar=0){
///////////////////////////////////////////////////////////////
// Check if the derivative is nonzero for oldmainvar. //
-// Returns the level of the choosen main variable. //
+// Returns the level of the chosen main variable. //
///////////////////////////////////////////////////////////////
static int
necessary_condition( const CanonicalForm & F, int oldmainvar){
@@ -631,7 +630,7 @@ Factorized( const CanonicalForm & F, const CanonicalForm & alpha, int Mainvar)
mainvar = choose_main_variable(F);
// Let`s look if @f/@mainvar is nonzero
mainvar = necessary_condition(F,mainvar);
- // Now we have definetly choosen a main variable
+ // Now we have definetly chosen a main variable
// swap poly such that the mainvar has highest level
f=swapvar(F,mainvar,level(F));
--
an open source computer algebra system
More information about the debian-science-commits
mailing list