Changeset 0b0bc3 in git for kernel/ideals.cc
- Timestamp:
- Feb 8, 2013, 6:03:33 PM (10 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- c462b60ab56fe1781c7f591d40ccd2799acd6c92
- Parents:
- 67242b64d178faf65f7a6059740248dcfbf15c53
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/ideals.cc
r67242b r0b0bc3 2400 2400 #endif 2401 2401 2402 #ifdef HAVE_FACTORY 2402 2403 /*2 2403 2404 * xx,q: arrays of length 0..rl-1 … … 2407 2408 * destroys xx 2408 2409 */ 2409 #ifdef HAVE_FACTORY2410 2410 ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring R) 2411 2411 { … … 2415 2415 result->ncols=xx[0]->ncols; // for lifting matrices 2416 2416 int i,j; 2417 poly r,h,hh,res_p;2418 2417 number *x=(number *)omAlloc(rl*sizeof(number)); 2418 poly *p=(poly *)omAlloc(rl*sizeof(poly)); 2419 2419 for(i=cnt-1;i>=0;i--) 2420 2420 { 2421 res_p=NULL; 2422 loop 2423 { 2424 r=NULL; 2425 for(j=rl-1;j>=0;j--) 2426 { 2427 h=xx[j]->m[i]; 2428 if ((h!=NULL) 2429 &&((r==NULL)||(p_LmCmp(r,h,R)==-1))) 2430 r=h; 2431 } 2432 if (r==NULL) break; 2433 h=p_Head(r,R); 2434 for(j=rl-1;j>=0;j--) 2435 { 2436 hh=xx[j]->m[i]; 2437 if ((hh!=NULL) && (p_LmCmp(r,hh,R)==0)) 2438 { 2439 x[j]=pGetCoeff(hh); 2440 hh=p_LmFreeAndNext(hh,R); 2441 xx[j]->m[i]=hh; 2442 } 2443 else 2444 x[j]=n_Init(0, R->cf); 2445 } 2446 number n=n_ChineseRemainder(x,q,rl,R->cf); 2447 for(j=rl-1;j>=0;j--) 2448 { 2449 x[j]=NULL; // nlInit(0...) takes no memory 2450 } 2451 if (n_IsZero(n,R->cf)) p_Delete(&h,R); 2452 else 2453 { 2454 p_SetCoeff(h,n,R); 2455 //Print("new mon:");pWrite(h); 2456 res_p=p_Add_q(res_p,h,R); 2457 } 2458 } 2459 result->m[i]=res_p; 2460 } 2461 omFree(x); 2421 for(j=rl-1;j>=0;j--) 2422 { 2423 p[j]=xx[j]->m[i]; 2424 } 2425 result->m[i]=p_ChineseRemainder(p,x,q,rl,R); 2426 for(j=rl-1;j>=0;j--) 2427 { 2428 xx[j]->m[i]=p[j]; 2429 } 2430 } 2431 omFreeSize(p,rl*sizeof(poly)); 2432 omFreeSize(x,rl*sizeof(number)); 2462 2433 for(i=rl-1;i>=0;i--) id_Delete(&(xx[i]),R); 2463 omFree (xx);2434 omFreeSize(xx,rl*sizeof(ideal)); 2464 2435 return result; 2465 2436 } … … 2561 2532 for(i=cnt-1;i>=0;i--) 2562 2533 { 2563 poly h=p_Copy(x->m[i],r); 2564 result->m[i]=h; 2565 while(h!=NULL) 2566 { 2567 number c=pGetCoeff(h); 2568 pSetCoeff0(h,n_Farey(c,N,r->cf)); 2569 n_Delete(&c,r->cf); 2570 pIter(h); 2571 } 2572 while((result->m[i]!=NULL)&&(n_IsZero(pGetCoeff(result->m[i]),r->cf))) 2573 { 2574 p_LmDelete(&(result->m[i]),r); 2575 } 2576 h=result->m[i]; 2577 while((h!=NULL) && (pNext(h)!=NULL)) 2578 { 2579 if(n_IsZero(pGetCoeff(pNext(h)),r->cf)) 2580 { 2581 p_LmDelete(&pNext(h),r); 2582 } 2583 else pIter(h); 2584 } 2534 result->m[i]=p_Farey(x->m[i],N,r); 2585 2535 } 2586 2536 return result;
Note: See TracChangeset
for help on using the changeset viewer.