Changeset ee0500 in git
- Timestamp:
- Feb 4, 2003, 5:24:59 PM (21 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- d713d78830adcab82fa3ce5686817d1dbdbe140a
- Parents:
- f9c0d1a7fd1e9511255bd5313bd4ac9de109e42d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/NTLconvert.cc
rf9c0d1 ree0500 1 /* $Id: NTLconvert.cc,v 1. 4 2002-10-10 17:43:38Singular Exp $ */1 /* $Id: NTLconvert.cc,v 1.5 2003-02-04 16:24:59 Singular Exp $ */ 2 2 #include <config.h> 3 3 … … 411 411 //////////////////////////////////////////////////////////////////////////////// 412 412 413 static char *cf_stringtemp=NULL; 414 static char *cf_stringtemp2=NULL; 415 static int cf_stringtemp_l=0; 413 416 CanonicalForm convertZZ2CF(ZZ coefficient) 414 417 { 415 418 long coeff_long; 416 419 //CanonicalForm tmp=0; 417 char stringtemp[5000]=""; 418 char stringtemp2[5000]=""; 420 if (cf_stringtemp_l==0) 421 { 422 cf_stringtemp=(char *)omAlloc(1023); 423 cf_stringtemp2=(char *)omAlloc(1023); 424 cf_stringtemp[0]='\0'; 425 cf_stringtemp2[0]='\0'; 426 cf_stringtemp_l=1023; 427 } 419 428 char dummy[2]; 420 429 int minusremainder=0; … … 444 453 } 445 454 455 int l=0; 446 456 while (coefficient>9) 447 457 { … … 452 462 //tmp*=10; tmp+=to_long(remaind); 453 463 454 strcat(stringtemp,dummy); 464 l++; 465 if (l>=cf_stringtemp_l-2) 466 { 467 omFree(cf_stringtemp2); 468 char *p=(char *)omAlloc(cf_stringtemp_l*2); 469 memcpy(p,cf_stringtemp,cf_stringtemp_l); 470 cf_stringtemp_l*=2; 471 omFree(cf_stringtemp); 472 cf_stringtemp=p; 473 cf_stringtemp2=(char *)omAlloc(cf_stringtemp_l); 474 } 475 cf_stringtemp[l-1]=dummy[0]; 476 cf_stringtemp[l]='\0'; 477 //strcat(stringtemp,dummy); 455 478 456 479 coefficient=quotient; … … 458 481 //built up the string in dummy[0] 459 482 dummy[0]=(char)(to_long(coefficient)+'0'); 460 strcat( stringtemp,dummy);483 strcat(cf_stringtemp,dummy); 461 484 //tmp*=10; tmp+=to_long(coefficient); 462 485 … … 464 487 { 465 488 //Check whether coefficient has been negative at the start of the procedure 466 stringtemp2[0]='-';489 cf_stringtemp2[0]='-'; 467 490 //tmp*=(-1); 468 491 } 469 492 470 493 //reverse the list to obtain the correct string 471 int len=strlen( stringtemp);494 int len=strlen(cf_stringtemp); 472 495 for (int i=len-1;i>=0;i--) 473 496 { 474 stringtemp2[len-i-1+minusremainder]=stringtemp[i];475 } 476 stringtemp2[len+minusremainder]='\0';497 cf_stringtemp2[len-i-1+minusremainder]=cf_stringtemp[i]; 498 } 499 cf_stringtemp2[len+minusremainder]='\0'; 477 500 } 478 501 479 502 //convert the string to canonicalform using the char*-Constructor 480 return CanonicalForm( stringtemp2);503 return CanonicalForm(cf_stringtemp2); 481 504 //return tmp; 482 505 }
Note: See TracChangeset
for help on using the changeset viewer.