Changeset aaf310 in git
- Timestamp:
- Oct 16, 2009, 12:29:28 PM (14 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- d1f231e3b792657bbd71d87ddd26f304449bd4f4
- Parents:
- 6666eaa6f8a2ff004dc43a60643801895ec2db11
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/clapconv.cc
r6666ea raaf310 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapconv.cc,v 1.2 0 2009-10-08 10:43:33Singular Exp $5 // $Id: clapconv.cc,v 1.21 2009-10-16 10:29:28 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: convert data between Singular and factory … … 35 35 static void convRecGFGF ( const CanonicalForm & f, int * exp, poly & result ); 36 36 37 static number convFactoryNSingAN( const CanonicalForm &f );37 static number convFactoryNSingAN( const CanonicalForm &f, const ring r); 38 38 39 39 CanonicalForm convSingNFactoryN( number n, const ring r ) … … 236 236 237 237 static void 238 convRecAP_R ( const CanonicalForm & f, int * exp, poly & result, int par_start, int var_start ) ;239 240 poly convFactoryAPSingAP_R ( const CanonicalForm & f, int par_start, int var_start )241 { 242 int n = pVariables+1+rPar(currRing);238 convRecAP_R ( const CanonicalForm & f, int * exp, poly & result, int par_start, int var_start, const ring r) ; 239 240 poly convFactoryAPSingAP_R ( const CanonicalForm & f, int par_start, int var_start, const ring r ) 241 { 242 int n = rVar(r)+rPar(r)+1; 243 243 int * exp = (int *)omAlloc0(n*sizeof(int)); 244 244 poly result = NULL; 245 convRecAP_R( f, exp, result,par_start, var_start );245 convRecAP_R( f, exp, result,par_start, var_start, r ); 246 246 omFreeSize((ADDRESS)exp,n*sizeof(int)); 247 247 return result; 248 248 } 249 249 250 poly convFactoryAPSingAP ( const CanonicalForm & f )251 { 252 return convFactoryAPSingAP_R(f,0,rPar( currRing));253 } 254 255 static void convRecAP_R ( const CanonicalForm & f, int * exp, poly & result, int par_start, int var_start )250 poly convFactoryAPSingAP ( const CanonicalForm & f, const ring r ) 251 { 252 return convFactoryAPSingAP_R(f,0,rPar(r),r); 253 } 254 255 static void convRecAP_R ( const CanonicalForm & f, int * exp, poly & result, int par_start, int var_start, const ring r ) 256 256 { 257 257 if (f.isZero()) … … 263 263 { 264 264 exp[l] = i.exp(); 265 convRecAP_R( i.coeff(), exp, result, par_start, var_start 265 convRecAP_R( i.coeff(), exp, result, par_start, var_start, r); 266 266 } 267 267 exp[l] = 0; … … 269 269 else 270 270 { 271 napoly z=(napoly)convFactoryASingA( f );271 napoly z=(napoly)convFactoryASingA( f,r ); 272 272 if (z!=NULL) 273 273 { 274 poly term = p Init();274 poly term = p_Init(r); 275 275 pNext( term ) = NULL; 276 276 int i; 277 for ( i = 1; i <= pVariables; i++)278 p SetExp( term, i , exp[i+var_start]);277 for ( i = rVar(r); i>0 ; i-- ) 278 p_SetExp( term, i , exp[i+var_start],r); 279 279 //if (rRing_has_Comp(currRing->algring)) p_SetComp(term, 0, currRing->algring); // done by pInit 280 280 if (par_start==0) … … 282 282 for ( i = 1; i <= var_start; i++ ) 283 283 //z->e[i-1]+=exp[i]; 284 napAddExp(z,i,exp[i]);284 p_AddExp(z,i,exp[i],r->algring); 285 285 } 286 286 else … … 288 288 for ( i = par_start+1; i <= var_start+rPar(currRing); i++ ) 289 289 //z->e[i-1]+=exp[i]; 290 napAddExp(z,i,exp[i-par_start]);290 p_AddExp(z,i,exp[i-par_start],r->algring); 291 291 } 292 292 pGetCoeff(term)=(number)omAlloc0Bin(rnumber_bin); 293 293 ((lnumber)pGetCoeff(term))->z=z; 294 p Setm( term);295 result = p Add( result, term);294 p_Setm( term,r ); 295 result = p_Add_q( result, term, r ); 296 296 } 297 297 } … … 342 342 } 343 343 344 static number convFactoryNSingAN( const CanonicalForm &f )344 static number convFactoryNSingAN( const CanonicalForm &f, const ring r) 345 345 { 346 346 if ( f.isImm() ) 347 return n_Init( f.intval(), currRing->algring );347 return n_Init( f.intval(), r->algring ); 348 348 else 349 349 { … … 370 370 } 371 371 372 napoly convFactoryASingA ( const CanonicalForm & f )373 { 374 napoly a=NULL;375 napoly t;372 napoly convFactoryASingA ( const CanonicalForm & f, const ring r ) 373 { 374 poly a=NULL; 375 poly t; 376 376 for( CFIterator i=f; i.hasTerms(); i++) 377 377 { 378 378 t=napNew(); 379 379 // pNext( t ) = NULL; //already done by napNew 380 napGetCoeff(t)=convFactoryNSingAN( i.coeff());381 if (n_IsZero(napGetCoeff(t), currRing->algring))382 { 383 p_Delete(&t, nacRing);384 } 385 else 386 { 387 napSetExp(t,1,i.exp());388 a= napAdd(a,t);380 pGetCoeff(t)=convFactoryNSingAN( i.coeff(), r ); 381 if (n_IsZero(napGetCoeff(t),r->algring)) 382 { 383 p_Delete(&t,r->algring); 384 } 385 else 386 { 387 p_SetExp(t,1,i.exp(),r->algring); 388 a=p_Add_q(a,t,r->algring); 389 389 } 390 390 } 391 391 if (a!=NULL) 392 392 { 393 if (naMinimalPoly!=NULL) 394 { 395 if (p_GetExp(a,1,currRing->algring) >= p_GetExp(naMinimalPoly,1,currRing->algring)) 396 a = napRemainder( a, naMinimalPoly); 393 if (r->minpoly!=NULL) 394 { 395 lnumber l=(lnumber)r->minpoly; 396 if (p_GetExp(a,1,r->algring) >= p_GetExp(l->z,1,r->algring)) 397 a = napRemainder( a, l->z); 397 398 } 398 399 } -
kernel/clapconv.h
r6666ea raaf310 3 3 * Computer Algebra System SINGULAR * 4 4 ****************************************/ 5 // $Id: clapconv.h,v 1. 7 2009-09-16 12:26:26Singular Exp $5 // $Id: clapconv.h,v 1.8 2009-10-16 10:29:28 Singular Exp $ 6 6 /* 7 7 * ABSTRACT: convert data between Singular and factory … … 20 20 21 21 CanonicalForm convSingAPFactoryAP ( poly p , const Variable & a, const ring r ); 22 poly convFactoryAPSingAP ( const CanonicalForm & f );22 poly convFactoryAPSingAP ( const CanonicalForm & f, const ring r ); 23 23 poly convFactoryAPSingAP_R ( const CanonicalForm & f, int par_start, int var_start ); 24 24 … … 27 27 28 28 CanonicalForm convSingAFactoryA ( napoly p , const Variable & a, const ring r ); 29 napoly convFactoryASingA ( const CanonicalForm & f );29 napoly convFactoryASingA ( const CanonicalForm & f, const ring r ); 30 30 31 31 CanonicalForm convSingTrPFactoryP ( poly p, const ring r=currRing );
Note: See TracChangeset
for help on using the changeset viewer.