Changeset 6620d75 in git
- Timestamp:
- Aug 13, 2009, 5:17:03 PM (14 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 6b9d0537f5dd5461f48626224cc9ca9c391990d8
- Parents:
- ab33f6e148aa2f8f6099e5a25a55a07f1e7fdd2b
- Location:
- kernel
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/clapconv.cc
rab33f6e r6620d75 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapconv.cc,v 1.1 4 2009-08-13 12:48:39Singular Exp $5 // $Id: clapconv.cc,v 1.15 2009-08-13 15:17:02 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: convert data between Singular and factory … … 31 31 static void conv_RecPP ( const CanonicalForm & f, int * exp, sBucket_pt result, ring r ); 32 32 33 static void convRecPTr ( const CanonicalForm & f, int * exp, napoly & result ); 34 35 static void convRecTrP ( const CanonicalForm & f, int * exp, poly & result, int offs ); 33 static void convRecTrP ( const CanonicalForm & f, int * exp, poly & result, int offs, const ring r ); 36 34 37 35 static void convRecGFGF ( const CanonicalForm & f, int * exp, poly & result ); … … 97 95 } 98 96 99 CanonicalForm convSingPFactoryP( poly p, const ring r )100 {101 CanonicalForm result = 0;102 int e, n = r->N;103 assume( rPar(r)==0);104 105 if ( getCharacteristic() != 0 )106 {107 /* does only work for finite fields Z/p*/108 while ( p != NULL )109 {110 CanonicalForm term = npInt( pGetCoeff( p ) );111 for ( int i = n; i >0; i-- )112 {113 if ( (e = p_GetExp( p, i, r )) != 0 )114 term *= power( Variable( i ), e );115 }116 result += term;117 pIter( p );118 }119 }120 else121 {122 while ( p != NULL )123 {124 CanonicalForm term;125 if ( SR_HDL(pGetCoeff( p )) & SR_INT )126 {127 term = SR_TO_INT( pGetCoeff( p ) );128 }129 else130 {131 if ( pGetCoeff( p )->s == 3 )132 {133 MP_INT dummy;134 mpz_init_set( &dummy, &(pGetCoeff( p )->z) );135 term = make_cf( dummy );136 }137 else138 {139 // assume s==1 or s==0140 MP_INT num, den;141 On(SW_RATIONAL);142 mpz_init_set( &num, &(pGetCoeff( p )->z) );143 mpz_init_set( &den, &(pGetCoeff( p )->n) );144 term = make_cf( num, den, ( pGetCoeff( p )->s != 1 ));145 }146 }147 for ( int i = n; i >0; i-- )148 {149 if ( (e = p_GetExp( p, i, r )) != 0 )150 term *= power( Variable( i ), e );151 }152 result += term;153 pIter( p );154 }155 }156 return result;157 }158 159 97 poly convFactoryPSingP ( const CanonicalForm & f, const ring r ) 160 98 { 161 99 // cerr << " f = " << f << endl; 162 int n = r ->N+1;100 int n = rVar(r)+1; 163 101 /* ASSERT( level( f ) <= pVariables, "illegal number of variables" ); */ 164 102 int * exp = (int*)omAlloc0(n*sizeof(int)); … … 224 162 225 163 226 CanonicalForm convSing TrFactoryP( napoly p)164 CanonicalForm convSingPFactoryP( poly p, const int off, const ring r ) 227 165 { 228 166 CanonicalForm result = 0; 229 int e, n = r Par(currRing);167 int e, n = rVar(r); 230 168 231 169 while ( p!=NULL) … … 233 171 CanonicalForm term; 234 172 /* does only work for finite fields */ 235 if ( getCharacteristic() != 0)173 if ( rField_is_Zp(r) ) 236 174 { 237 175 term = npInt( pGetCoeff( p ) ); 238 176 } 239 else 177 else if (rField_is_Q(r)) 240 178 { 241 179 if ( SR_HDL(pGetCoeff( p )) & SR_INT ) … … 260 198 } 261 199 } 200 else 201 { 202 WerrorS("conversion error"); 203 return result; 204 } 262 205 for ( int i = n; i >0; i-- ) 263 206 { 264 if ( (e = p_GetExp( p, i, currRing->algring)) != 0 )265 term *= power( Variable( i ), e );207 if ( (e = p_GetExp( p, i, r)) != 0 ) 208 term *= power( Variable( i+off ), e ); 266 209 } 267 210 result += term; … … 269 212 } 270 213 return result; 271 }272 273 napoly convFactoryPSingTr ( const CanonicalForm & f )274 {275 // cerr << " f = " << f << endl;276 int n = rPar(currRing)+1;277 /* ASSERT( level( f ) <= rPar(currRing), "illegal number of variables" ); */278 int * exp = (int *)omAlloc0(n*sizeof(int));279 napoly result = NULL;280 convRecPTr( f, exp, result );281 omFreeSize((ADDRESS)exp,n*sizeof(int));282 return result;283 }284 285 static void convRecPTr ( const CanonicalForm & f, int * exp, napoly & result )286 {287 if (f.isZero())288 return;289 if ( ! f.inCoeffDomain() )290 {291 int l = f.level();292 for ( CFIterator i = f; i.hasTerms(); i++ )293 {294 exp[l] = i.exp();295 convRecPTr( i.coeff(), exp, result );296 }297 exp[l] = 0;298 }299 else300 {301 napoly term = napNew();302 // napNext( term ) = NULL; //already done by napNew303 for ( int i = rPar(currRing); i>=1; i-- )304 p_SetExp( term, i , exp[i],currRing->algring);305 p_Setm(term, currRing->algring);306 if ( f.isImm() )307 pGetCoeff( term ) = n_Init( f.intval(), currRing->algring );308 else309 {310 number z=(number)omAllocBin(rnumber_bin);311 #if defined(LDEBUG)312 z->debug=123456;313 #endif314 z->z = gmp_numerator( f );315 if ( f.den().isOne() )316 {317 z->s = 3;318 }319 else320 {321 z->n = gmp_denominator( f );322 if (mpz_cmp_si(&z->n,(long)1)==0)323 {324 mpz_clear(&z->n);325 z->s=3;326 }327 else328 {329 z->s = 0;330 n_Normalize(z,currRing->algring);331 }332 }333 pGetCoeff( term ) = z;334 }335 if (n_IsZero(pGetCoeff(term),currRing->algring))336 {337 napDelete(&term);338 }339 else340 {341 result = napAdd( result, term );342 }343 }344 214 } 345 215 … … 530 400 } 531 401 532 CanonicalForm convSingTrPFactoryP ( poly p )402 CanonicalForm convSingTrPFactoryP ( poly p, const ring r ) 533 403 { 534 404 CanonicalForm result = 0; 535 int e, n = pVariables;536 int offs = rPar( currRing);405 int e, n = rVar(r); 406 int offs = rPar(r); 537 407 538 408 while ( p!=NULL ) 539 409 { 540 n Normalize(pGetCoeff(p));541 CanonicalForm term=convSing TrFactoryP(((lnumber)pGetCoeff(p))->z);410 n_Normalize(pGetCoeff(p),r); 411 CanonicalForm term=convSingPFactoryP(((lnumber)pGetCoeff(p))->z,0,r->algring); 542 412 543 413 if ((((lnumber)pGetCoeff(p))->n!=NULL) … … 549 419 for ( int i = n; i > 0; i-- ) 550 420 { 551 if ( (e = p GetExp( p, i)) != 0 )421 if ( (e = p_GetExp( p, i,r )) != 0 ) 552 422 term = term * power( Variable( i + offs ), e ); 553 423 } … … 558 428 } 559 429 560 poly convFactoryPSingTrP ( const CanonicalForm & f )561 { 562 int n = pVariables+1;430 poly convFactoryPSingTrP ( const CanonicalForm & f, const ring r ) 431 { 432 int n = rVar(r)+1; 563 433 int * exp = (int*)omAlloc0(n*sizeof(int)); 564 434 poly result = NULL; 565 convRecTrP( f, exp, result , rPar( currRing));435 convRecTrP( f, exp, result , rPar(r), r ); 566 436 omFreeSize((ADDRESS)exp,n*sizeof(int)); 567 437 return result; … … 569 439 570 440 static void 571 convRecTrP ( const CanonicalForm & f, int * exp, poly & result , int offs )441 convRecTrP ( const CanonicalForm & f, int * exp, poly & result , int offs, const ring r) 572 442 { 573 443 if (f.isZero()) … … 579 449 { 580 450 exp[l-offs] = i.exp(); 581 convRecTrP( i.coeff(), exp, result, offs );451 convRecTrP( i.coeff(), exp, result, offs, r ); 582 452 } 583 453 exp[l-offs] = 0; … … 585 455 else 586 456 { 587 poly term = p Init();457 poly term = p_Init(r); 588 458 pNext( term ) = NULL; 589 for ( int i = 1; i <= pVariables; i++)590 p SetExp( term, i ,exp[i]);459 for ( int i = rVar(r); i>0; i-- ) 460 p_SetExp( term, i ,exp[i], r); 591 461 //if (rRing_has_Comp(currRing)) p_SetComp(term, 0, currRing); // done by pInit 592 462 pGetCoeff(term)=(number)omAlloc0Bin(rnumber_bin); 593 ((lnumber)pGetCoeff(term))->z=convFactoryPSing Tr( f);594 p Setm( term);595 result = p Add( result, term);463 ((lnumber)pGetCoeff(term))->z=convFactoryPSingP( f, r->algring ); 464 p_Setm( term,r ); 465 result = p_Add_q( result, term,r ); 596 466 } 597 467 } -
kernel/clapconv.h
rab33f6e r6620d75 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapconv.h,v 1. 4 2009-08-13 12:48:39Singular Exp $5 // $Id: clapconv.h,v 1.5 2009-08-13 15:17:02 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: convert data between Singular and factory … … 16 16 #include <factory.h> 17 17 18 napoly convFactoryPSingTr ( const CanonicalForm & f );19 CanonicalForm convSingTrFactoryP( napoly p );20 21 18 poly convFactoryPSingP ( const CanonicalForm & f, const ring r=currRing ); 22 CanonicalForm convSingPFactoryP( poly p, const ring r=currRing );19 CanonicalForm convSingPFactoryP( poly p, const int off=0, const ring r=currRing ); 23 20 24 21 CanonicalForm convSingAPFactoryAP ( poly p , const Variable & a ); … … 32 29 napoly convFactoryASingA ( const CanonicalForm & f ); 33 30 34 CanonicalForm convSingTrPFactoryP ( poly p );35 poly convFactoryPSingTrP ( const CanonicalForm & f );31 CanonicalForm convSingTrPFactoryP ( poly p, const ring r=currRing ); 32 poly convFactoryPSingTrP ( const CanonicalForm & f, const ring r=currRing ); 36 33 37 34 CanonicalForm convSingNFactoryN( number n ); -
kernel/clapsing.cc
rab33f6e r6620d75 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapsing.cc,v 1.4 1 2009-08-13 12:48:39Singular Exp $5 // $Id: clapsing.cc,v 1.42 2009-08-13 15:17:02 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: interface between Singular and factory … … 27 27 void out_cf(char *s1,const CanonicalForm &f,char *s2); 28 28 29 poly singclap_gcd ( poly f, poly g )30 {31 poly res=NULL;32 33 if (f!=NULL) pCleardenom(f);34 if (g!=NULL) pCleardenom(g);35 else return f; // g==0 => gcd=f (but do a pCleardenom)36 if (f==NULL) return g; // f==0 => gcd=g (but do a pCleardenom)37 38 if (pIsConstantPoly(f) || pIsConstantPoly(g))39 {40 pDelete(&f);41 pDelete(&g);42 return pOne();43 }44 45 // for now there is only the possibility to handle polynomials over46 // Q and Fp ...47 Off(SW_RATIONAL);48 if (( nGetChar() == 0 || nGetChar() > 1 )49 && (currRing->parameter==NULL))50 {51 CanonicalForm newGCD(const CanonicalForm & A, const CanonicalForm & B);52 setCharacteristic( nGetChar() );53 CanonicalForm F( convSingPFactoryP( f ) ), G( convSingPFactoryP( g ) );54 //if (nGetChar() > 1 )55 //{56 // res=convFactoryPSingP( newGCD( F,G ));57 // if (!nGreaterZero(pGetCoeff(res))) res=pNeg(res);58 //}59 //else60 res=convFactoryPSingP( gcd( F, G ) );61 }62 // and over Q(a) / Fp(a)63 else if (( nGetChar()==1 ) /* Q(a) */64 || (nGetChar() <-1)) /* Fp(a) */65 {66 if (nGetChar()==1) setCharacteristic( 0 );67 else setCharacteristic( -nGetChar() );68 if (currRing->minpoly!=NULL)69 {70 #if 071 if (( nGetChar()==1 ) /* Q(a) */ && (!isOn(SW_USE_QGCD)))72 {73 // WerrorS( feNotImplemented );74 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z);75 //Varlist ord;76 //ord.append(mipo.mvar());77 CFList as(mipo);78 Variable a=rootOf(mipo);79 //CanonicalForm F( convSingAPFactoryAP( f,a ) ), G( convSingAPFactoryAP( g,a ) );80 CanonicalForm F( convSingTrPFactoryP(f) ), G( convSingTrPFactoryP(g) );81 //res= convFactoryAPSingAP( algcd( F, G, as, ord) );82 //res= convFactoryAPSingAP( alg_gcd( F, G, as) );83 res= convFactoryAPSingAP( alg_gcd( F, G, as) );84 }85 else86 #endif87 {88 bool b=isOn(SW_USE_QGCD);89 if ( nGetChar()==1 ) On(SW_USE_QGCD);90 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z);91 Variable a=rootOf(mipo);92 CanonicalForm F( convSingAPFactoryAP( f,a ) ), G( convSingAPFactoryAP( g,a ) );93 res= convFactoryAPSingAP( gcd( F, G ) );94 if (!b) Off(SW_USE_QGCD);95 }96 }97 else98 {99 CanonicalForm F( convSingTrPFactoryP( f ) ), G( convSingTrPFactoryP( g ) );100 res= convFactoryPSingTrP( gcd( F, G ) );101 }102 }103 #if 0104 else if (( nGetChar()>1 )&&(currRing->parameter!=NULL)) /* GF(q) */105 {106 int p=rChar(currRing);107 int n=2;108 int t=p*p;109 while (t!=nChar) { t*=p;n++; }110 setCharacteristic(p,n,'a');111 CanonicalForm F( convSingGFFactoryGF( f ) ), G( convSingGFFactoryGF( g ) );112 res= convFactoryGFSingGF( gcd( F, G ) );113 }114 #endif115 else116 WerrorS( feNotImplemented );117 118 Off(SW_RATIONAL);119 pDelete(&f);120 pDelete(&g);121 pTest(res);122 return res;123 }124 125 29 poly singclap_gcd_r ( poly f, poly g, const ring r ) 126 30 { … … 141 45 CanonicalForm newGCD(const CanonicalForm & A, const CanonicalForm & B); 142 46 setCharacteristic( n_GetChar(r) ); 143 CanonicalForm F( convSingPFactoryP( f, r ) ), G( convSingPFactoryP( g, r ) );47 CanonicalForm F( convSingPFactoryP( f,0,r ) ), G( convSingPFactoryP( g,0, r ) ); 144 48 //if (nGetChar() > 1 ) 145 49 //{ … … 150 54 res=convFactoryPSingP( gcd( F, G ) , r); 151 55 } 56 // and over Q(a) / Fp(a) 57 else if (( n_GetChar(r)==1 ) /* Q(a) */ 58 || (n_GetChar(r) <-1)) /* Fp(a) */ 59 { 60 if (n_GetChar(r)==1) setCharacteristic( 0 ); 61 else setCharacteristic( -n_GetChar(r) ); 62 if (r->minpoly!=NULL) 63 { 64 #if 0 65 if (( n_GetChar(r)==1 ) /* Q(a) */ && (!isOn(SW_USE_QGCD))) 66 { 67 // WerrorS( feNotImplemented ); 68 CanonicalForm mipo=convSingPFactoryP(((lnumber)r->minpoly)->z,0,r->algring); 69 //Varlist ord; 70 //ord.append(mipo.mvar()); 71 CFList as(mipo); 72 Variable a=rootOf(mipo); 73 //CanonicalForm F( convSingAPFactoryAP( f,a,r ) ), G( convSingAPFactoryAP( g,a,r ) ); 74 CanonicalForm F( convSingTrPFactoryP(f,r) ), G( convSingTrPFactoryP(g,r) ); 75 //res= convFactoryAPSingAP( algcd( F, G, as, ord) ); 76 //res= convFactoryAPSingAP( alg_gcd( F, G, as) ); 77 res= convFactoryAPSingAP( alg_gcd( F, G, as),r ); 78 } 79 else 80 #endif 81 { 82 bool b=isOn(SW_USE_QGCD); 83 if ( nGetChar()==1 ) On(SW_USE_QGCD); 84 CanonicalForm mipo=convSingPFactoryP(((lnumber)r->minpoly)->z, 85 0,r->algring); 86 Variable a=rootOf(mipo); 87 CanonicalForm F( convSingAPFactoryAP( f,a ) ), 88 G( convSingAPFactoryAP( g,a ) ); 89 res= convFactoryAPSingAP( gcd( F, G ) ); 90 if (!b) Off(SW_USE_QGCD); 91 } 92 } 93 else 94 { 95 CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) ); 96 res= convFactoryPSingTrP( gcd( F, G ),r ); 97 } 98 } 99 #if 0 100 else if (( n_GetChar(r)>1 )&&(r->parameter!=NULL)) /* GF(q) */ 101 { 102 int p=rChar(r); 103 int n=2; 104 int t=p*p; 105 while (t!=n_Char(r)) { t*=p;n++; } 106 setCharacteristic(p,n,'a'); 107 CanonicalForm F( convSingGFFactoryGF( f,r ) ), G( convSingGFFactoryGF( g,r ) ); 108 res= convFactoryGFSingGF( gcd( F, G ),r ); 109 } 110 #endif 152 111 else 153 112 WerrorS( feNotImplemented ); 154 113 155 114 Off(SW_RATIONAL); 115 return res; 116 } 117 118 poly singclap_gcd ( poly f, poly g ) 119 { 120 poly res=NULL; 121 122 if (f!=NULL) pCleardenom(f); 123 if (g!=NULL) pCleardenom(g); 124 else return f; // g==0 => gcd=f (but do a pCleardenom) 125 if (f==NULL) return g; // f==0 => gcd=g (but do a pCleardenom) 126 127 res=singclap_gcd_r(f,g,currRing); 128 pDelete(&f); 129 pDelete(&g); 156 130 return res; 157 131 } … … 204 178 { 205 179 //Variable X(i); 206 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 180 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 181 0,currRing->algring); 207 182 Variable a=rootOf(mipo); 208 183 CanonicalForm F( convSingAPFactoryAP( f,a ) ), G( convSingAPFactoryAP( g,a ) ); … … 345 320 if (currRing->minpoly!=NULL) 346 321 { 347 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 322 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 323 0,currRing->algring); 348 324 Variable a=rootOf(mipo); 349 325 CanonicalForm F( convSingAPFactoryAP( f,a ) ), G( convSingAPFactoryAP( g,a ) ); … … 373 349 pa=convFactoryPSingTrP(Fa); 374 350 pb=convFactoryPSingTrP(Gb); 351 } 352 Off(SW_RATIONAL); 353 } 354 else 355 { 356 WerrorS( feNotImplemented ); 357 return TRUE; 358 } 359 return FALSE; 360 } 361 362 BOOLEAN singclap_extgcd_r ( poly f, poly g, poly &res, poly &pa, poly &pb, const ring r ) 363 { 364 // for now there is only the possibility to handle univariate 365 // polynomials over 366 // Q and Fp ... 367 res=NULL;pa=NULL;pb=NULL; 368 On(SW_SYMMETRIC_FF); 369 if (( n_GetChar(r) == 0 || n_GetChar(r) > 1 ) 370 && (r->parameter==NULL)) 371 { 372 setCharacteristic( n_GetChar(r) ); 373 CanonicalForm F( convSingPFactoryP( f,0,r ) ), G( convSingPFactoryP( g,0,r) ); 374 CanonicalForm FpG=F+G; 375 if (!(FpG.isUnivariate()|| FpG.inCoeffDomain())) 376 //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar()) 377 { 378 Off(SW_RATIONAL); 379 WerrorS("not univariate"); 380 return TRUE; 381 } 382 CanonicalForm Fa,Gb; 383 On(SW_RATIONAL); 384 res=convFactoryPSingP( extgcd( F, G, Fa, Gb ),r ); 385 pa=convFactoryPSingP(Fa,r); 386 pb=convFactoryPSingP(Gb,r); 387 Off(SW_RATIONAL); 388 } 389 // and over Q(a) / Fp(a) 390 else if (( n_GetChar(r)==1 ) /* Q(a) */ 391 || (n_GetChar(r) <-1)) /* Fp(a) */ 392 { 393 if (n_GetChar(r)==1) setCharacteristic( 0 ); 394 else setCharacteristic( -n_GetChar(r) ); 395 CanonicalForm Fa,Gb; 396 if (r->minpoly!=NULL) 397 { 398 CanonicalForm mipo=convSingPFactoryP(((lnumber)r->minpoly)->z, 399 0,r->algring); 400 Variable a=rootOf(mipo); 401 CanonicalForm F( convSingAPFactoryAP( f,a ) ), 402 G( convSingAPFactoryAP( g,a ) ); 403 CanonicalForm FpG=F+G; 404 if (!(FpG.isUnivariate()|| FpG.inCoeffDomain())) 405 //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar()) 406 { 407 WerrorS("not univariate"); 408 return TRUE; 409 } 410 res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ) ); 411 pa=convFactoryAPSingAP(Fa); 412 pb=convFactoryAPSingAP(Gb); 413 } 414 else 415 { 416 CanonicalForm F( convSingTrPFactoryP( f, r ) ), G( convSingTrPFactoryP( g, r ) ); 417 CanonicalForm FpG=F+G; 418 if (!(FpG.isUnivariate()|| FpG.inCoeffDomain())) 419 //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar()) 420 { 421 Off(SW_RATIONAL); 422 WerrorS("not univariate"); 423 return TRUE; 424 } 425 res= convFactoryPSingTrP( extgcd( F, G, Fa, Gb ), r ); 426 pa=convFactoryPSingTrP(Fa, r); 427 pb=convFactoryPSingTrP(Gb, r); 375 428 } 376 429 Off(SW_RATIONAL); … … 405 458 if (currRing->minpoly!=NULL) 406 459 { 407 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 460 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 461 0,currRing->algring); 408 462 Variable a=rootOf(mipo); 409 463 CanonicalForm F( convSingAPFactoryAP( f,a ) ), G( convSingAPFactoryAP( g,a ) ); … … 492 546 pIter(p); 493 547 } 494 g = convSing TrFactoryP( ((lnumber)g1)->z);495 g = gcd( g, convSing TrFactoryP( ((lnumber)g2)->z));548 g = convSingPFactoryP( ((lnumber)g1)->z, 0,currRing->algring ); 549 g = gcd( g, convSingPFactoryP( ((lnumber)g2)->z , 0,currRing->algring)); 496 550 497 551 // second run: gcd's … … 500 554 while ( (p != NULL) && (g != 1) && ( g != 0)) 501 555 { 502 h = convSing TrFactoryP( ((lnumber)pGetCoeff(p))->z);556 h = convSingPFactoryP( ((lnumber)pGetCoeff(p))->z, 0,currRing->algring ); 503 557 pIter( p ); 504 558 … … 519 573 lnumber c=(lnumber)pGetCoeff(p); 520 574 napDelete(&c->z); 521 c->z=convFactoryPSing Tr( i.getItem() /g );575 c->z=convFactoryPSingP( i.getItem() / g, currRing->algring ); 522 576 //nTest((number)c); 523 577 //#ifdef LDEBUG … … 566 620 if (currRing->minpoly!=NULL) 567 621 { 568 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 622 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 623 0,currRing->algring); 569 624 a=rootOf(mipo); 570 625 F=convSingAPFactoryAP( f,a ); … … 789 844 if (currRing->minpoly!=NULL) 790 845 { 791 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 846 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 847 0,currRing->algring); 792 848 Variable a=rootOf(mipo); 793 849 CanonicalForm F( convSingAPFactoryAP( f,a ) ); … … 1133 1189 if (currRing->minpoly!=NULL) 1134 1190 { 1135 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 1191 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 1192 0,currRing->algring); 1136 1193 Variable a=rootOf(mipo); 1137 1194 CanonicalForm F( convSingAPFactoryAP( f,a ) ); … … 1386 1443 //if (currRing->minpoly!=NULL) 1387 1444 //{ 1388 // CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 1445 // CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 1446 // 0,currRing->algring); 1389 1447 // Variable a=rootOf(mipo); 1390 1448 // CanonicalForm F( convSingAPFactoryAP( f,a ) ); … … 1440 1498 if (currRing->minpoly!=NULL) 1441 1499 { 1442 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 1500 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 1501 0,currRing->algring); 1443 1502 Variable a=rootOf(mipo); 1444 1503 int i,j; … … 1497 1556 if (currRing->minpoly!=NULL) 1498 1557 { 1499 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 1558 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 1559 0,currRing->algring); 1500 1560 Variable a=rootOf(mipo); 1501 1561 CanonicalForm F( convSingAFactoryA( f,a ) ), G( convSingAFactoryA( g,a ) ); … … 1510 1570 else 1511 1571 { 1512 CanonicalForm F( convSingTrFactoryP( f ) ), G( convSingTrFactoryP( g ) ); 1572 CanonicalForm F( convSingPFactoryP( f,0,currRing->algring ) ), 1573 G( convSingPFactoryP( g,0,currRing->algring ) ); 1513 1574 CanonicalForm GCD; 1514 1575 // calculate gcd … … 1516 1577 1517 1578 // calculate lcm 1518 res= convFactoryPSing Tr( (F/GCD)*G);1579 res= convFactoryPSingP( (F/GCD)*G, currRing->algring ); 1519 1580 } 1520 1581 … … 1533 1594 if (currRing->minpoly!=NULL) 1534 1595 { 1535 CanonicalForm mipo=convSingTrFactoryP(((lnumber)currRing->minpoly)->z); 1596 CanonicalForm mipo=convSingPFactoryP(((lnumber)currRing->minpoly)->z, 1597 0,currRing->algring); 1536 1598 Variable a=rootOf(mipo); 1537 1599 CanonicalForm F( convSingAFactoryA( f,a ) ), G( convSingAFactoryA( g,a ) ); … … 1548 1610 else 1549 1611 { 1550 CanonicalForm F( convSingTrFactoryP( f ) ), G( convSingTrFactoryP( g ) ); 1612 CanonicalForm F( convSingPFactoryP( f,0,currRing->algring ) ), 1613 G( convSingPFactoryP( g,0,currRing->algring ) ); 1551 1614 CanonicalForm GCD; 1552 1615 … … 1555 1618 if ((GCD!=1) && (GCD!=0)) 1556 1619 { 1557 ff= convFactoryPSing Tr( F/ GCD);1558 gg= convFactoryPSing Tr( G/ GCD);1620 ff= convFactoryPSingP( F/ GCD, currRing->algring ); 1621 gg= convFactoryPSingP( G/ GCD, currRing->algring ); 1559 1622 } 1560 1623 } -
kernel/clapsing.h
rab33f6e r6620d75 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapsing.h,v 1. 3 2009-08-05 17:29:12Singular Exp $5 // $Id: clapsing.h,v 1.4 2009-08-13 15:17:03 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: interface between Singular and factory … … 26 26 27 27 BOOLEAN singclap_extgcd ( poly f, poly g, poly &res, poly &pa, poly &pb ); 28 BOOLEAN singclap_extgcd_r ( poly f, poly g, poly &res, poly &pa, poly &pb, const ring r ); 28 29 29 30 poly singclap_pdivide ( poly f, poly g ); -
kernel/longalg.cc
rab33f6e r6620d75 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: longalg.cc,v 1.4 4 2009-08-07 13:55:21Singular Exp $ */4 /* $Id: longalg.cc,v 1.45 2009-08-13 15:17:03 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: algebraic numbers … … 34 34 napoly naMinimalPoly; 35 35 #define naParNames (currRing->parameter) 36 #define napNormalize(p) p_Normalize(p,nacRing)37 36 static int naIsChar0; 38 37 static int naPrimeM; … … 204 203 qq = (napoly)p_Init(nacRing); 205 204 napNext(qq) = NULL; 206 napNormalize(g);207 napNormalize(f);205 p_Normalize(g,nacRing); 206 p_Normalize(f,nacRing); 208 207 a = f; 209 208 do … … 216 215 h = napCopy(g); 217 216 napMultT(h, qq); 218 napNormalize(h);217 p_Normalize(h,nacRing); 219 218 n_Delete(&napGetCoeff(qq),nacRing); 220 219 a = napAdd(a, h); … … 234 233 qq = (napoly)p_Init(nacRing); 235 234 napNext(qq) = b = NULL; 236 napNormalize(g);237 napNormalize(f);235 p_Normalize(g,nacRing); 236 p_Normalize(f,nacRing); 238 237 a = f; 239 238 do … … 247 246 h = napCopy(g); 248 247 napMultT(h, qq); 249 napNormalize(h);248 p_Normalize(h,nacRing); 250 249 n_Delete(&napGetCoeff(qq),nacRing); 251 250 a = napAdd(a, h); … … 297 296 qa=p_Mult_nn(qa,t,nacRing); p_Normalize(qa,nacRing); 298 297 n_Delete(&t,nacRing); 299 napNormalize(qa);298 p_Normalize(qa,nacRing); 300 299 napDelete(&x); 301 300 napDelete(&r); … … 316 315 t = nacInvers(napGetCoeff(r)); 317 316 q=p_Mult_nn(q,t,nacRing); p_Normalize(q,nacRing); 318 napNormalize(q);317 p_Normalize(q,nacRing); 319 318 n_Delete(&t,nacRing); 320 319 napDelete(&x); … … 345 344 //nacNormalize(t); 346 345 q=p_Mult_nn(q,t,nacRing); p_Normalize(q,nacRing); 347 napNormalize(q);346 p_Normalize(q,nacRing); 348 347 n_Delete(&t,nacRing); 349 348 napDelete(&x); … … 1531 1530 napoly rz=napGcd(x->z, y->z); 1532 1531 CanonicalForm F, G, R; 1533 R=convSing TrFactoryP(rz);1534 napNormalize(x->z);1535 F=convSing TrFactoryP(x->z)/R;1536 napNormalize(y->z);1537 G=convSing TrFactoryP(y->z)/R;1532 R=convSingPFactoryP(rz,0,nacRing); 1533 p_Normalize(x->z,nacRing); 1534 F=convSingPFactoryP(x->z,0,nacRing)/R; 1535 p_Normalize(y->z,nacRing); 1536 G=convSingPFactoryP(y->z,0,nacRing)/R; 1538 1537 F = gcd( F, G ); 1539 1538 if (F.isOne()) … … 1542 1541 { 1543 1542 napDelete(&rz); 1544 result->z=convFactoryPSing Tr( F*R);1545 napNormalize(result->z);1543 result->z=convFactoryPSingP( F*R, nacRing ); 1544 p_Normalize(result->z,nacRing); 1546 1545 } 1547 1546 }
Note: See TracChangeset
for help on using the changeset viewer.