Index: kernel/gfan.cc
===================================================================
--- kernel/gfan.cc	(revision c292b2f02aae398d9441027fcf6031ee977365e1)
+++ kernel/gfan.cc	(revision 64b6c61b2c6edd68fabdb5696221daac90cd2c9f)
@@ -62,7 +62,7 @@
 
 #ifdef p800
-#include <../cddlib/include/setoper.h>
-#include <../cddlib/include/cdd.h>
-#include <../cddlib/include/cddmp.h>
+#include <../../cddlib/include/setoper.h>
+#include <../../cddlib/include/cdd.h>
+#include <../../cddlib/include/cddmp.h>
 #endif
 
@@ -3036,9 +3036,7 @@
 {	
 	facet *SearchListRoot = new facet(); //The list containing ALL facets we come across
-// 	vector<facet> stlRoot;
 	facet *SearchListAct;
 	SearchListAct = NULL;
-	//SearchListAct = SearchListRoot;
-			
+	//SearchListAct = SearchListRoot;			
 	gcone *gcAct;
 	gcAct = &gcRoot;
@@ -3048,14 +3046,10 @@
 	gcNext = &gcRoot;
 	gcone *gcHead;
-	gcHead = &gcRoot;
-			
+	gcHead = &gcRoot;			
 	facet *fAct;
-	fAct = gcAct->facetPtr;			
-			
+	fAct = gcAct->facetPtr;				
 	ring rAct;
 	rAct = currRing;
-						
-	int UCNcounter=gcAct->getUCN();
-	
+	int UCNcounter=gcAct->getUCN();	
 #ifdef gfan_DEBUG
 	printf("NoRevs\n");
@@ -3068,11 +3062,7 @@
 		dd_LinealitySpace = gcAct->computeLinealitySpace();
 	/*End of lineality space computation*/		
-// 	gcAct->getCodim2Normals(*gcAct);
+	//gcAct->getCodim2Normals(*gcAct);
 	if(fAct->codim2Ptr==NULL)
-		gcAct->getExtremalRays(*gcAct);
-				
-	//Compute unique representation of Facets and rays, i.e. primitive vectors
-// 	gcAct->normalize();
-			
+		gcAct->getExtremalRays(*gcAct);		
 	/* Make a copy of the facet list of first cone
 	   Since the operations getCodim2Normals and normalize affect the facets
@@ -3090,6 +3080,5 @@
 			if( ii==0 || (ii>0 && SearchListAct==NULL) ) //1st facet may be non-flippable
 			{
-				if(SearchListRoot!=NULL)
-					delete(SearchListRoot);
+				if(SearchListRoot!=NULL) delete(SearchListRoot);
 				SearchListRoot = fAct->shallowCopy(*fAct);
 				SearchListAct = SearchListRoot;	//SearchListRoot is already 'new'ed at beginning of method!
@@ -3119,5 +3108,5 @@
 			SearchListAct->isFlippable=TRUE;
 			//Copy int point as well
-			int64vec *ivIntPt;// = new int64vec(this->numVars);
+			int64vec *ivIntPt;
 			ivIntPt = fAct->getInteriorPoint();
 			SearchListAct->setInteriorPoint(ivIntPt);
@@ -3131,6 +3120,5 @@
 			SearchListAct->codim2Ptr = new facet(2);
 			sl2Root = SearchListAct->codim2Ptr;
-			sl2Act = sl2Root;
-					//while(codim2Act!=NULL)
+			sl2Act = sl2Root;			
 			for(int jj=0;jj<fAct->numCodim2Facets;jj++)
 // 			for(int jj=0;jj<fAct->numRays-1;jj++)
@@ -3176,6 +3164,4 @@
 		if(SearchListAct->next!=NULL){
 #endif
-// 		if(SearchListAct->next!=NULL)
-// 		{
 			SearchListAct->next->prev = SearchListAct;					
 		}
@@ -3202,5 +3188,4 @@
 			//NOTE rCopy needed?
 			ring rTmp=rCopy(fAct->flipRing);
-// 			ring rTmp=fAct->flipRing; //segfaults
 			rComplete(rTmp);
 			rChangeCurrRing(rTmp);
@@ -3215,7 +3200,6 @@
 			*/
  			idDelete((ideal *)&fAct->flipGB);
-			rDelete(fAct->flipRing);
-			
-			gcTmp->getConeNormals(gcTmp->gcBasis/*, FALSE*/);	//TODO FALSE is default, so should not be needed here
+			rDelete(fAct->flipRing);			
+			gcTmp->getConeNormals(gcTmp->gcBasis/*, FALSE*/);
 // 			gcTmp->getCodim2Normals(*gcTmp);
 			gcTmp->getExtremalRays(*gcTmp);
@@ -3233,17 +3217,21 @@
 			/*add facets to SLA here*/
 #ifdef SHALLOW
-// 			printf("fActUCN before enq2: %i\n",fAct->getUCN());
-			facet *tmp; tmp=gcTmp->enqueue2(SearchListRoot);
-// 			printf("\nheadUCN=%i\n",tmp->getUCN());
-// 			printf("fActUCN after enq2: %i\n",fAct->getUCN());			
+  #ifdef gfan_DEBUG
+			printf("fActUCN before enq2: %i\n",fAct->getUCN());
+  #endif
+			facet *tmp;
+			tmp=gcTmp->enqueue2(SearchListRoot);
+  #ifdef gfan_DEBUG
+			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->enqueue2/*NewFacets*/(SearchListRoot);
+#else 
 			SearchListRoot=gcTmp->enqueueNewFacets(SearchListRoot);
-#endif
+#endif //ifdef SHALLOW
 			gcTmp->writeConeToFile(*gcTmp);
  			if(gfanHeuristic==1)
  			{
-// 				gcTmp->writeConeToFile(*gcTmp);
  				idDelete((ideal*)&gcTmp->gcBasis);//Whonder why?
 				rDelete(gcTmp->baseRing);
@@ -3350,5 +3338,4 @@
 void gcone::makeInt(const dd_MatrixPtr &M, const int line, int64vec &n)
 {			
-// 	mpz_t denom[this->numVars];
 	mpz_t *denom = new mpz_t[this->numVars];
 	for(int ii=0;ii<this->numVars;ii++)
@@ -3390,5 +3377,5 @@
 	mpq_set_num(qkgV,kgV);
 			
-// 			mpq_canonicalize(qkgV);
+//	mpq_canonicalize(qkgV);
 // 	int ggT=1;
 	for (int ii=0;ii<(M->colsize)-1;ii++)
@@ -3401,5 +3388,5 @@
 	for(int ii=0;ii<this->numVars;ii++)
 		ggT=int64gcd(ggT,n[ii]);	
-	//Normalization
+	//Normalisation
 	if(ggT>1)
 	{
@@ -3514,5 +3501,5 @@
 	 * If slAct->next==NULL AND maybe==TRUE we know, that fAct must be added
 	 */
-// 	volatile bool maybe=FALSE;
+
 	/**A facet was removed, lengthOfSearchlist-- thus we must not rely on 
 	 * if(notParallelCtr==lengthOfSearchList) but rather
@@ -3520,11 +3507,7 @@
 	 */
 	volatile bool removalOccured=FALSE;
-// 	int ctr=0;	//encountered equalities in SLA
-// 	int notParallelCtr=0;
-// 	gcone::lengthOfSearchList=1;
 	while(slEnd->next!=NULL)
 	{
 		slEnd=slEnd->next;
-// 		gcone::lengthOfSearchList++;
 	}
 	/*1st step: compare facetNormals*/			
@@ -3536,5 +3519,4 @@
 			fNormal=fAct->getFacetNormal();			
 			slAct = slHead;
-			//notParallelCtr=0;
 			/*If slAct==NULL and fAct!=NULL 
 			we just copy all remaining facets into SLA*/
@@ -3689,5 +3671,5 @@
 }//addC2N
 
-/** Try using shallow copies*/
+/** Enqueuing using shallow copies*/
 facet * gcone::enqueue2(facet *f)
 {
@@ -3709,6 +3691,4 @@
 	facet *codim2Act;
 	codim2Act = this->facetPtr->codim2Ptr;
-// 	facet *sl2Act;
-// 	sl2Act = f->codim2Ptr;
 	volatile bool removalOccured=FALSE;
 	while(slEnd->next!=NULL)
@@ -3744,5 +3724,5 @@
 					fCopy = fCopy->next;
 				}
-				break;	
+				break;	//WTF?
 			}
 			/*Comparison starts here*/
@@ -3767,5 +3747,5 @@
 						}
 						fDeleteMarker->shallowDelete();
-// 						delete fDeleteMarker;//NOTE this messes up fAct in noRevS!
+ 						//delete fDeleteMarker;//NOTE this messes up fAct in noRevS!
 // 						printf("headUCN@enq=%i\n",slHead->getUCN());
 					}
@@ -3775,5 +3755,5 @@
 						slEnd->next = NULL;
 						fDeleteMarker->shallowDelete();
-// 						delete(fDeleteMarker);
+						delete(fDeleteMarker);
 					}								
 					else
@@ -3782,5 +3762,5 @@
 						slAct->next->prev = slAct->prev;
 						fDeleteMarker->shallowDelete();
-// 						delete(fDeleteMarker);
+						delete(fDeleteMarker);
 					}
 					removalOccured=TRUE;
@@ -3789,6 +3769,4 @@
 printf("Removing (");fAct->fNormal->show(1,1);printf(") from list\n");
 #endif
-					/*fDeleteMarker->shallowDelete();*///Sets everything to NULL
-// 					delete(fDeleteMarker);
 					break;//leave the while loop, since we found fAct=slAct thus delete slAct and do not add fAct
 				}
@@ -3855,5 +3833,5 @@
 	replacementRing->order[2]=ringorder_C;
 
-	int64vec *ivw = this->getIntPoint(TRUE);
+	int64vec *ivw = this->getIntPoint(TRUE);//returns a reference
 // 	assert(this->ivIntPt);	
 	int length=ivw->length();	
@@ -3864,5 +3842,5 @@
 		if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::replaceDouble_ringorder_a_ByASingleOne!\n");
 	}	
-// 	delete ivw;
+	//delete ivw; //Not needed if this->getIntPoint(TRUE)
 	replacementRing->wvhdl[0]=(int *)A;
 	replacementRing->block1[0]=length;
@@ -3873,6 +3851,5 @@
 	rDelete(this->baseRing);
 	this->baseRing=rCopy(replacementRing);
-	this->gcBasis=idCopy(temporaryGroebnerBasis);
-	//FIXME idDelete & rDelete!!! DONE!
+	this->gcBasis=idCopy(temporaryGroebnerBasis);	
 	/*And back to where we came from*/
 	rChangeCurrRing(srcRing);
@@ -3972,6 +3949,5 @@
 	filename.append(UCNstr);
 	filename.append(suffix);
-	
-	
+		
 // 	int thisPID = getpid();
 // 	ss << thisPID;
@@ -4016,30 +3992,25 @@
 			for (int ii=0;ii<iv->length();ii++)
 			{
-				if (ii<iv->length()-1)
-				{
-					gcOutputFile << (*iv)[ii] << ",";
-				}
-				else
-				{
-					gcOutputFile << (*iv)[ii] << " ";
-				}
+// 				if (ii<iv->length()-1)
+// 					gcOutputFile << (*iv)[ii] << ",";
+// 				else
+// 					gcOutputFile << (*iv)[ii] << " ";
+				gcOutputFile << (*iv)[ii];
+				(ii<iv->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
 			}
-// 			delete iv;
+			//delete iv;
 			while(f2Act!=NULL)
 			{
 				const int64vec *iv2;
-				iv2=f2Act->getRef2FacetNormal();//->getFacetNormal();	
+				iv2=f2Act->getRef2FacetNormal();
 				for(int jj=0;jj<iv2->length();jj++)
 				{
-					if (jj<iv2->length()-1)
-					{
-						gcOutputFile << (*iv2)[jj] << ",";
-					}
-					else
-					{
-						gcOutputFile << (*iv2)[jj] << " ";
-					}
+// 					if (jj<iv2->length()-1)
+// 						gcOutputFile << (*iv2)[jj] << ",";
+// 					else
+// 						gcOutputFile << (*iv2)[jj] << " ";
+					gcOutputFile << (*iv2)[jj];
+					(jj<iv2->length()-1) ? gcOutputFile << "," : gcOutputFile << " ";
 				}
-// 				delete iv2;
 				f2Act = f2Act->next;
 			}
@@ -4065,5 +4036,5 @@
 	string UCNstr = ss.str();
 	int gcBasisLength=0;
-	size_t found;			//used for find_first_(not)_of
+	size_t found;	//used for find_first_(not)_of
 
 	string prefix="/tmp/Singular/cone";
@@ -4411,5 +4382,4 @@
 		}
 		fAct = fAct->next;
-// 		delete fNormal;
 	}	
 	return *res;
@@ -4474,5 +4444,5 @@
 			gcAct = gcRoot;
 			gcone::numVars=pVariables;
-// 			gcAct->numVars=pVariables;//NOTE is now static
+			//gcAct->numVars=pVariables;//NOTE is now static
 			gcAct->getGB(inputIdeal);
 			/*Check whether input is homogeneous
@@ -4500,6 +4470,5 @@
 				dd_free_global_constants();
 				//This is filthy
-				goto pointOfNoReturn;
-				//return lResList;
+				goto pointOfNoReturn;				
 			}			
 			gcAct->getConeNormals(gcAct->gcBasis);
@@ -4530,28 +4499,28 @@
 		//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);
-		}
+// 		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;
 	}
@@ -4559,8 +4528,8 @@
 #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_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;
