Changeset f91fddc in git
- Timestamp:
- Apr 9, 2010, 9:20:11 AM (13 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- cacfb67cf6bf7cd84cd8e725d9acf88690092d61
- Parents:
- 807ee2919f6e854d2cfa4def4e5f3c99b8883a2d
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/gfan.cc
r807ee2 rf91fddc 76 76 //NOTE Defining this will slow things down! 77 77 //Only good for very coarse profiling 78 // #define gfanp78 // #define gfanp 79 79 #ifdef gfanp 80 80 #include <sys/time.h> … … 157 157 while(f2Copy!=NULL) 158 158 { 159 if(f2Act==NULL || f2Act==(facet*)0xfefefefefefefefe) 159 if(f2Act==NULL 160 #ifndef NDEBUG 161 #if SIZEOF_LONG==8 162 || f2Act==(facet*)0xfefefefefefefefe 163 #elif SIZEOF_LONG==4 164 || f2Act==(facet*)0xfefefefe 165 #endif 166 #endif 167 ) 160 168 { 161 169 f2Act=new facet(2); … … 273 281 } 274 282 } 283 // if( fIntP->compare(gIntP)!=0) res=FALSE; 275 284 #ifdef gfanp 276 285 gettimeofday(&end, 0); … … 840 849 dd_rowset ddredrows; // # of redundant rows in ddineq 841 850 dd_rowset ddlinset; // the opposite 842 dd_rowindex ddnewpos ; // all to make dd_Canonicalize happy851 dd_rowindex ddnewpos=NULL; // all to make dd_Canonicalize happy 843 852 dd_NumberType ddnumb=dd_Integer; //Number type 844 853 dd_ErrorType dderr=dd_NoError; … … 894 903 for(int ii=0;ii<ddineq->rowsize;ii++) 895 904 { 896 ideal initialForm=idInit(IDELEMS(I), 1);905 ideal initialForm=idInit(IDELEMS(I),I->rank); 897 906 //read row ii into gamma 898 int64 tmp;907 // int64 tmp; 899 908 int64vec *gamma=new int64vec(this->numVars); 900 909 for(int jj=1;jj<=this->numVars;jj++) 901 910 { 911 int64 tmp; 902 912 tmp=(int64)mpq_get_d(ddineq->matrix[ii][jj]); 903 913 (*gamma)[jj-1]=(int64)tmp; … … 909 919 for(int jj=0;jj<IDELEMS(initialForm);jj++) 910 920 { 911 L->m[jj]=pCopy(pHead(initialForm->m[jj])); 921 poly p=pHead(initialForm->m[jj]); 922 L->m[jj]=pCopy(/*pHead(initialForm->m[jj]))*/p); 923 pDelete(&p); 912 924 } 913 925 … … 946 958 } 947 959 } 960 pDelete(&q); 948 961 if(isMaybeFacet==TRUE) 949 { 962 { 950 963 break;//while(p!=NULL) 951 964 } 952 965 p=pNext(p); 953 pDelete(&q);954 966 }//while 955 967 // pDelete(&p);//NOTE Better to use pDel and qDel. Commenting in this line will not work! 956 pDelete(&q);968 if(q!=NULL) pDelete(&q); 957 969 pDelete(&pDel); 958 970 pDelete(&qDel); … … 960 972 { 961 973 dd_set_si(ddineq->matrix[ii][0],1); 962 if(num_alloc==0) 963 num_alloc += 1; 964 else 965 num_alloc += 1; 974 // if(num_alloc==0) 975 // num_alloc += 1; 976 // else 977 // num_alloc += 1; 978 if(num_alloc==num_elts) num_alloc==0 ? num_alloc=1 : num_alloc*=2; 979 966 980 void *tmp = realloc(redRowsArray,(num_alloc*sizeof(int))); 967 981 if(!tmp) … … 987 1001 // delete gamma; 988 1002 int offset=0;//needed for correction of redRowsArray[ii] 1003 #ifdef gfan_DEBUG 1004 printf("Removed %i of %i in preprocessing step\n",num_elts,ddineq->rowsize); 1005 #endif 989 1006 for( int ii=0;ii<num_elts;ii++ ) 990 1007 { 991 1008 dd_MatrixRowRemove(&ddineq,redRowsArray[ii]+1-offset);//cddlib sucks at enumeration 992 1009 offset++; 993 } 994 free(redRowsArray); 1010 } 1011 free(redRowsArray);//NOTE May crash on some machines. 995 1012 /*And now for the strictly positive rows 996 1013 * Doesn't gain significant speedup … … 1063 1080 for (int jj = 1; jj <ddcols; jj++) 1064 1081 { 1065 double foo;1066 foo =mpq_get_d(ddineq->matrix[kk][jj]);1067 (*load)[jj-1] = (int64)foo; //store typecasted entry at pos jj-1 of load1068 ggT = int gcd(ggT,(int64&)foo);1082 int64 val; 1083 val = (int64)mpq_get_d(ddineq->matrix[kk][jj]); 1084 (*load)[jj-1] = val; //store typecasted entry at pos jj-1 of load 1085 ggT = int64gcd(ggT,/*(int64&)foo*/val); 1069 1086 }//for (int jj = 1; jj <ddcols; jj++) 1070 1087 if(ggT>1) … … 1190 1207 } 1191 1208 //Clean up but don't delete the return value! 1192 dd_FreeMatrix(ddineq); 1193 set_free(ddredrows); 1194 set_free(ddlinset); 1195 free(ddnewpos); 1209 dd_FreeMatrix(ddineq); 1210 set_free(ddredrows);//check 1211 set_free(ddlinset);//check 1212 free(ddnewpos);//<-- NOTE Here the crash occurs omAlloc issue? 1196 1213 #ifdef gfanp 1197 1214 gettimeofday(&end, 0); … … 1478 1495 // mpq_clear(product); 1479 1496 //Compute intgcd 1480 ggT=int gcd(ggT,(*ivIntPointOfCone)[ii]);1497 ggT=int64gcd(ggT,(*ivIntPointOfCone)[ii]); 1481 1498 } 1482 1499 … … 1520 1537 int64 ggT=(*ivIntPointOfCone)[0]; 1521 1538 for(int ii=0;ii<this->numVars;ii++) 1522 ggT=int gcd( ggT, (*ivIntPointOfCone)[ii]);1539 ggT=int64gcd( ggT, (*ivIntPointOfCone)[ii]); 1523 1540 if(ggT>1) 1524 1541 { … … 1602 1619 int64 ggT=(*ivIntPointOfFacet)[0]; 1603 1620 for(int ii=0;ii<this->numVars;ii++) 1604 ggT=int gcd(ggT,(*ivIntPointOfFacet)[ii]);1621 ggT=int64gcd(ggT,(*ivIntPointOfFacet)[ii]); 1605 1622 if(ggT>1) 1606 1623 { … … 1855 1872 pGetExpV(aktpoly,src_ExpV); 1856 1873 rChangeCurrRing(tmpRing); //this ring change is crucial! 1857 pGetExpV(pCopy(H->m[ii]),dst_ExpV); 1874 poly p=pCopy(H->m[ii]); 1875 pGetExpV(p/*pCopy(H->m[ii])*/,dst_ExpV); 1876 pDelete(&p); 1858 1877 rChangeCurrRing(srcRing); 1859 1878 bool expVAreEqual=TRUE; … … 2252 2271 * and in gcone::flip for obvious reasons. 2253 2272 */ 2254 inlinevoid gcone::computeInv(const ideal &gb, ideal &initialForm, const int64vec &fNormal)2273 /*inline*/ void gcone::computeInv(const ideal &gb, ideal &initialForm, const int64vec &fNormal) 2255 2274 { 2256 2275 #ifdef gfanp … … 2265 2284 pGetExpV(aktpoly,leadExpV); //find the leading exponent in leadExpV[1],...,leadExpV[n], use pNext(p) 2266 2285 initialFormElement=pHead(aktpoly); 2286 // int *v=(int *)omAlloc((this->numVars+1)*sizeof(int)); 2267 2287 while(pNext(aktpoly)!=NULL) /*loop trough terms and check for parallelity*/ 2268 2288 { 2269 2289 int64vec *check = new int64vec(this->numVars); 2270 2290 aktpoly=pNext(aktpoly); //next term 2271 // pSetm(aktpoly);2272 2291 int *v=(int *)omAlloc((this->numVars+1)*sizeof(int)); 2273 2292 pGetExpV(aktpoly,v); 2274 /* Convert (int)v into (int64vec)check */ 2293 /* Convert (int)v into (int64vec)check */ 2294 // bool notPar=FALSE; 2275 2295 for (int jj=0;jj<this->numVars;jj++) 2276 2296 { 2277 2297 (*check)[jj]=v[jj+1]-leadExpV[jj+1]; 2298 // register int64 foo=(fNormal)[jj]; 2299 // if( ( (*check)[jj] == /*fNormal[jj]*/foo ) 2300 // || ( (/*fNormal[jj]*/foo!=0) && ( ( (*check)[jj] % /*fNormal[jj]*/foo ) !=0 ) ) ) 2301 // { 2302 // notPar=TRUE; 2303 // break; 2304 // } 2278 2305 } 2279 if (isParallel(*check,fNormal)) //pass *check when 2280 // if(isParallel((const int64vec*)&check,(const int64vec*)&fNormal)) 2281 // if(fNormal.compare(check)==0) 2282 { 2283 //Found a parallel vector. Add it 2306 omFree(v); 2307 if (isParallel(*check,fNormal))//Found a parallel vector. Add it 2308 // if(notPar==FALSE) 2309 { 2284 2310 initialFormElement = pAdd((initialFormElement),(poly)pHead(aktpoly));//pAdd = p_Add_q destroys args 2285 2311 } 2286 omFree(v);2287 2312 delete check; 2288 2313 }//while 2314 // omFree(v); 2289 2315 #ifdef gfan_DEBUG 2290 2316 // cout << "Initial Form="; … … 2478 2504 gettimeofday(&start, 0); 2479 2505 #endif*/ 2480 int lhs,rhs;2481 2506 bool res; 2482 lhs=dotProduct(a,b)*dotProduct(a,b); 2483 rhs=dotProduct(a,a)*dotProduct(b,b); 2484 //cout << "LHS="<<lhs<<", RHS="<<rhs<<endl; 2507 int lhs=dotProduct(a,b)*dotProduct(a,b); 2508 int rhs=dotProduct(a,a)*dotProduct(b,b); 2485 2509 if (lhs==rhs) 2486 2510 { … … 3372 3396 mpq_mul(res,qkgV,M->matrix[line-1][ii+1]); 3373 3397 n[ii]=(int64)mpz_get_d(mpq_numref(res)); 3374 // ggT=int gcd(ggT,n[ii]);3398 // ggT=int64gcd(ggT,n[ii]); 3375 3399 } 3376 3400 int64 ggT=n[0]; 3377 3401 for(int ii=0;ii<this->numVars;ii++) 3378 ggT=int gcd(ggT,n[ii]);3402 ggT=int64gcd(ggT,n[ii]); 3379 3403 //Normalization 3380 3404 if(ggT>1) … … 3859 3883 /** \brief Compute the gcd of two ints 3860 3884 */ 3861 static int intgcd(const int64 &a, const int64 &b) 3885 static int64 int64gcd(const int64 &a, const int64 &b) 3886 { 3887 int64 r, p=a, q=b; 3888 if(p < 0) 3889 p = -p; 3890 if(q < 0) 3891 q = -q; 3892 while(q != 0) 3893 { 3894 r = p % q; 3895 p = q; 3896 q = r; 3897 } 3898 return p; 3899 } 3900 3901 static int intgcd(const int &a, const int &b) 3862 3902 { 3863 3903 int r, p=a, q=b; … … 3873 3913 } 3874 3914 return p; 3875 } 3915 } 3876 3916 3877 3917 /** \brief Construct a dd_MatrixPtr from a cone's list of facets … … 3971 4011 while(fAct!=NULL) 3972 4012 { 3973 const int64vec *iv ;3974 iv=fAct->getRef2FacetNormal();//->getFacetNormal();4013 const int64vec *iv=fAct->getRef2FacetNormal(); 4014 // iv=fAct->getRef2FacetNormal();//->getFacetNormal(); 3975 4015 f2Act=fAct->codim2Ptr; 3976 4016 for (int ii=0;ii<iv->length();ii++) … … 4009 4049 gcOutputFile.close(); 4010 4050 } 4051 delete [] ringString; 4011 4052 4012 4053 }//writeConeToFile(gcone const &gc) -
kernel/gfan.h
r807ee2 rf91fddc 251 251 }; 252 252 lists lprepareResult(gcone *gc, const int n); 253 static int intgcd(const int64 &a, const int64 &b); 253 static int64 int64gcd(const int64 &a, const int64 &b); 254 static int intgcd(const int &a, const int &b); 254 255 static int dotProduct(const int64vec &iva, const int64vec &ivb); 255 256 static bool isParallel(const int64vec &a, const int64vec &b);
Note: See TracChangeset
for help on using the changeset viewer.