Changeset dd6b1d in git
- Timestamp:
- Mar 31, 2010, 8:15:34 AM (14 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 69b4990f59641fb854b4b0c6b4c68f32a163ae9d
- Parents:
- 6184b1dc226c2756136736be02b9732d2388e385
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r6184b1 rdd6b1d 904 904 } 905 905 computeInv((ideal&)I,initialForm,*gamma); 906 delete gamma; 906 907 //Create leading ideal 907 908 ideal L=idInit(IDELEMS(initialForm),1); … … 911 912 } 912 913 913 LObject *P = new sLObject(); 914 LObject *P = new sLObject();//TODO What's the difference between sLObject and LObject? 914 915 memset(P,0,sizeof(LObject)); 915 916 … … 925 926 if(P->p!=NULL) //spoly non zero=? 926 927 { 927 poly p;//=pInit(); NOTE Evil memleak if pInit is used 928 poly q;//=pInit(); 928 poly p;//NOTE Don't use pInit here. Evil memleak will follow 929 poly q; 930 poly pDel,qDel; 929 931 p=pCopy(P->p); 930 932 q=pHead(p); //Monomial q 933 pDelete(&q); 934 pDel=p; qDel=q; 931 935 isMaybeFacet=FALSE; 932 936 //TODO: Suffices to check LTs here 933 937 while(p!=NULL) 934 { 938 { 935 939 q=pHead(p); 936 940 for(int ll=0;ll<IDELEMS(L);ll++) … … 946 950 break;//while(p!=NULL) 947 951 } 948 p=pNext(p); 952 p=pNext(p); 953 pDelete(&q); 949 954 }//while 950 pDelete(&p); 955 // pDelete(&p);//NOTE Better to use pDel and qDel. Commenting in this line will not work! 951 956 pDelete(&q); 957 pDelete(&pDel); 958 pDelete(&qDel); 952 959 if(isMaybeFacet==FALSE) 953 960 { … … 969 976 goto _start; //mea culpa, mea culpa, mea maxima culpa 970 977 } 971 }//if(P->p!=NULL) 978 }//if(P->p!=NULL) 979 pDelete(&(P->p)); 972 980 }//for k 973 981 }//for jj … … 976 984 delete P; 977 985 idDelete(&initialForm); 978 //idDelete(L);979 delete gamma;980 986 }//for(ii<ddineq-rowsize 981 987 // delete gamma; … … 1410 1416 /* Compute interior point on the fly*/ 1411 1417 int64vec *ivIntPointOfCone = new int64vec(this->numVars); 1412 mpq_t *colSum = new mpq_t[this->numVars];1413 int denom[this->numVars];//denominators of colSum1418 // mpq_t *colSum = new mpq_t[this->numVars]; 1419 // int denom[this->numVars];//denominators of colSum 1414 1420 //NOTE TODO need to gcd of rows and factor out! -> makeInt 1415 1421 /*for(int jj=0;jj<this->numVars;jj++) … … 1450 1456 mpz_clear(den); 1451 1457 mpz_clear(tmp);*/ 1458 int64vec *foo = new int64vec(this->numVars); 1452 1459 for(int ii=0;ii<P->rowsize;ii++) 1453 1460 { 1454 int64vec *foo = new int64vec(this->numVars);1461 // int64vec *foo = new int64vec(this->numVars); 1455 1462 int64vec *tmp = ivIntPointOfCone; 1456 1463 makeInt(P,ii+1,*foo); 1457 1464 ivIntPointOfCone = iv64Add(ivIntPointOfCone,foo); 1458 1465 delete tmp; 1459 delete foo; 1460 } 1466 // delete foo; 1467 } 1468 delete foo; 1461 1469 int64 ggT=(*ivIntPointOfCone)[0]; 1462 1470 for (int ii=0;ii<(this->numVars);ii++) … … 1483 1491 } 1484 1492 // mpq_clear(qkgV); 1485 delete [] colSum;1493 // delete [] colSum; 1486 1494 /*For homogeneous input (like Det3,3,5) the int points may be negative. So add a suitable multiple of (1,_,1)*/ 1487 1495 if(hasHomInput==TRUE && iv64isStrictlyPositive(ivIntPointOfCone)==FALSE) … … 2274 2282 { 2275 2283 //Found a parallel vector. Add it 2276 initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly)); 2284 initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly));//pAdd = p_Add_q destroys args 2277 2285 } 2278 2286 omFree(v); … … 2500 2508 dd_LPSolverType solver=dd_DualSimplex; 2501 2509 dd_LPSolutionPtr lpSol=NULL; 2502 dd_rowset ddlinset,ddredrows; //needed for dd_FindRelativeInterior2503 dd_rowindex ddnewpos;2510 // dd_rowset ddlinset,ddredrows; //needed for dd_FindRelativeInterior 2511 // dd_rowindex ddnewpos; 2504 2512 dd_NumberType numb; 2505 2513 //M->representation=dd_Inequality; … … 2790 2798 { 2791 2799 A[jj]=(*ivw)[jj]; 2792 if( A[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight!\n");2800 if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight!\n"); 2793 2801 } 2794 2802 res->wvhdl[0]=(int *)A; … … 2832 2840 A1[jj]=(*ivw)[jj]; 2833 2841 A2[jj]=-(*fNormal)[jj]; 2834 if( A1[jj]>=INT_MAX || A2[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight2!\n");2842 if((*ivw)[jj]>=INT_MAX || (*fNormal)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::rCopyAndAddWeight2!\n"); 2835 2843 } 2836 2844 res->wvhdl[0]=(int *)A1; … … 3823 3831 replacementRing->order[2]=ringorder_C; 3824 3832 3825 int64vec *ivw = this->getIntPoint( );3833 int64vec *ivw = this->getIntPoint(TRUE); 3826 3834 // assert(this->ivIntPt); 3827 3835 int length=ivw->length(); … … 3830 3838 { 3831 3839 A[jj]=(*ivw)[jj]; 3832 if( A[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::replaceDouble_ringorder_a_ByASingleOne!\n");3840 if((*ivw)[jj]>=INT_MAX) WarnS("A[jj] exceeds INT_MAX in gcone::replaceDouble_ringorder_a_ByASingleOne!\n"); 3833 3841 } 3834 delete ivw;3842 // delete ivw; 3835 3843 replacementRing->wvhdl[0]=(int *)A; 3836 3844 replacementRing->block1[0]=length; … … 4047 4055 { 4048 4056 string weight; 4049 weight=line.substr(0,line.find_first_of(",)")); 4050 (*iv)[ii]=atol(weight.c_str());//Better to long. Weight bound in Singular:2147483647 4057 weight=line.substr(0,line.find_first_of(",)")); 4058 char *w=new char[weight.size()+1]; 4059 strcpy(w,weight.c_str()); 4060 (*iv)[ii]=atol(w/*weight.c_str()*/);//Better to long. Weight bound in Singular:2147483647 4061 delete[] w; 4051 4062 line.erase(0,line.find_first_of(",)")+1); 4052 4063 } … … 4085 4096 getline(gcInputFile, line); 4086 4097 strGcBasisLength = line; 4087 int size=atoi(strGcBasisLength.c_str()); 4098 char *s=new char[strGcBasisLength.size()+1]; 4099 strcpy(s,strGcBasisLength.c_str()); 4100 int size=atoi(s/*strGcBasisLength.c_str()*/); 4101 delete[] s; 4088 4102 gcBasisLength=size; 4089 4103 gc->gcBasis=idInit(size,1); … … 4103 4117 { 4104 4118 poly strPoly;//=pInit(); 4105 number nCoeff=nInit(1); 4106 number nCoeffNom=nInit(1); 4107 number nCoeffDenom=nInit(1); 4119 4108 4120 string strMonom, strCoeff, strCoeffNom, strCoeffDenom; 4109 4121 bool hasCoeffInQ = FALSE; //does the polynomial have rational coeff? … … 4123 4135 strMonom = line.substr(0,found); 4124 4136 line.erase(0,found); 4137 number nCoeff=nInit(1); 4138 number nCoeffNom=nInit(1); 4139 number nCoeffDenom=nInit(1); 4125 4140 found = strMonom.find_first_of("/"); 4126 4141 if(found!=string::npos) //i.e. "/" exists in strMonom … … 4130 4145 strCoeffDenom=strMonom.substr(found+1,strMonom.find_first_not_of("1234567890",found+1)); 4131 4146 strMonom.erase(0,found); 4132 strMonom.erase(0,strMonom.find_first_not_of("1234567890/")); 4133 nRead(strCoeffNom.c_str(), &nCoeffNom); 4134 nRead(strCoeffDenom.c_str(), &nCoeffDenom); 4147 strMonom.erase(0,strMonom.find_first_not_of("1234567890/")); 4148 char *Nom=new char[strCoeffNom.size()+1]; 4149 char *Denom=new char[strCoeffDenom.size()+1]; 4150 strcpy(Nom,strCoeffNom.c_str()); 4151 strcpy(Denom,strCoeffDenom.c_str()); 4152 nRead(Nom/*strCoeffNom.c_str()*/, &nCoeffNom); 4153 nRead(Denom/*strCoeffDenom.c_str()*/, &nCoeffDenom); 4154 delete[] Nom; 4155 delete[] Denom; 4135 4156 } 4136 4157 else 4137 4158 { 4138 4159 found = strMonom.find_first_not_of("1234567890"); 4139 strCoeff = strMonom.substr(0,found); 4160 strCoeff = strMonom.substr(0,found); 4140 4161 if(!strCoeff.empty()) 4141 4162 { 4142 nRead(strCoeff.c_str(),&nCoeff); 4163 char *coeff = new char[strCoeff.size()+1]; 4164 strcpy(coeff, strCoeff.c_str()); 4165 nRead(coeff/*strCoeff.c_str()*/,&nCoeff); 4166 delete[] coeff; 4143 4167 } 4144 else4145 {4146 // intCoeff = 1;4147 nCoeff = nInit(1);4148 }4149 4150 4168 } 4151 const char* monom = strMonom.c_str(); 4152 4153 p_Read(monom,strPoly,currRing); //strPoly:=monom 4169 char* monom = new char[strMonom.size()+1]; 4170 strcpy(monom, strMonom.c_str()); 4171 p_Read(monom,strPoly,currRing); //strPoly:=monom 4172 delete[] monom; 4154 4173 switch (hasCoeffInQ) 4155 4174 { … … 4164 4183 if(!nIsOne(nCoeff)) 4165 4184 { 4166 // if(hasNegCoeff)4167 // intCoeff *= -1;4168 // pSetCoeff(strPoly,(number) intCoeff);4169 4185 pSetCoeff(strPoly, nCoeff ); 4170 4186 } 4171 4187 break; 4172 4173 4188 } 4174 4189 //pSetCoeff(strPoly, (number) intCoeff);//Why is this set to zero instead of 1??? 4175 4190 if(pIsConstantComp(resPoly)) 4176 resPoly=pCopy(strPoly); 4191 { 4192 resPoly=pCopy(strPoly); 4193 pDelete(&strPoly); 4194 } 4177 4195 else 4196 { 4197 // poly tmp=pAdd(pCopy(resPoly),strPoly);//foo is destroyed 4198 // pDelete(&resPoly); 4199 // resPoly=tmp; 4200 // pDelete(&tmp); 4178 4201 resPoly=pAdd(resPoly,strPoly);//pAdd = p_Add_q, destroys args 4179 // nDelete(&nCoeff); 4202 } 4203 /*if(nCoeff!=NULL) 4204 nDelete(&nCoeff);*/ //NOTE This may cause a crash on certain examples... 4180 4205 nDelete(&nCoeffNom); 4181 4206 nDelete(&nCoeffDenom); 4182 // pDelete(&strPoly);4183 4207 }//while(!line.empty()) 4184 4208 gc->gcBasis->m[jj]=pCopy(resPoly); 4185 4209 pDelete(&resPoly); //reset 4186 // pDelete(&strPoly); //NOTE Crashes - already deleted by pAdd4187 4210 } 4188 4211 // break; … … 4202 4225 found = normalString.find(","); 4203 4226 component=normalString.substr(0,found); 4204 (*fN)[ii]=atol(component.c_str()); 4227 char *sComp = new char[component.size()+1]; 4228 strcpy(sComp,component.c_str()); 4229 (*fN)[ii]=atol(sComp/*component.c_str()*/); 4230 delete[] sComp; 4205 4231 normalString.erase(0,found+1); 4206 4232 }
Note: See TracChangeset
for help on using the changeset viewer.