Changeset e63576 in git for libpolys/polys/nc/old.gring.cc


Ignore:
Timestamp:
Aug 11, 2011, 4:42:02 PM (13 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
95eb6d00149ac8549074f366eba29162578e4ead
Parents:
3e305b6ce4edb47687c2d4f484f63a86ab340c0f
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-08-11 16:42:02+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 13:19:16+01:00
Message:
FIX: started moving GB-related non-commutative routines to kernel/
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/nc/old.gring.cc

    r3e305b re63576  
    24742474   return(res);
    24752475}
    2476 /*
    2477 ideal twostd(ideal I) // works in currRing only!
    2478 {
    2479   ideal J = kStd(I, currQuotient, testHomog, NULL, NULL, 0, 0, NULL); // in currRing!!!
    2480   idSkipZeroes(J); // ring independent!
    2481 
    2482   const int rN = currRing->N;
    2483 
    2484   loop
    2485   {
    2486     ideal     K    = NULL;
    2487     const int s    = idElem(J); // ring independent
    2488 
    2489     for(int i = 0; i < s; i++)
    2490     {
    2491       const poly p = J->m[i];
    2492 
    2493 #ifdef PDEBUG
    2494       p_Test(p, currRing);
    2495 #if 0
    2496       Print("p: "); // !
    2497       p_Write(p, currRing);
    2498 #endif
    2499 #endif
    2500 
    2501       for (int j = 1; j <= rN; j++) // for all j = 1..N
    2502       {
    2503         poly varj = p_One( currRing);
    2504         p_SetExp(varj, j, 1, currRing);
    2505         p_Setm(varj, currRing);
    2506 
    2507         poly q = pp_Mult_mm(p, varj, currRing); // q = J[i] * var(j),
    2508 
    2509 #ifdef PDEBUG
    2510         p_Test(varj, currRing);
    2511         p_Test(p, currRing);
    2512         p_Test(q, currRing);
    2513 #if 0
    2514         Print("Reducing p: "); // !
    2515         p_Write(p, currRing);
    2516         Print("With q: "); // !
    2517         p_Write(q, currRing);
    2518 #endif
    2519 #endif
    2520 
    2521         p_Delete(&varj, currRing);
    2522 
    2523         if (q != NULL)
    2524         {
    2525 #ifdef PDEBUG
    2526 #if 0
    2527           Print("Reducing q[j = %d]: ", j); // !
    2528           p_Write(q, currRing);
    2529 
    2530           Print("With p:");
    2531           p_Write(p, currRing);
    2532 
    2533 #endif
    2534 #endif
    2535 
    2536           // bug: lm(p) may not divide lm(p * var(i)) in a SCA!
    2537           if( p_LmDivisibleBy(p, q, currRing) )
    2538             q = nc_ReduceSpoly(p, q, currRing);
    2539 
    2540 
    2541 #ifdef PDEBUG
    2542           p_Test(q, currRing);
    2543 #if 0
    2544           Print("reductum q/p: ");
    2545           p_Write(q, currRing);
    2546 
    2547           // Print("With J!\n");
    2548 #endif
    2549 #endif
    2550 
    2551 //          if( q != NULL)
    2552           q = kNF(J, currQuotient, q, 0, KSTD_NF_NONORM); // in currRing!!!
    2553 
    2554 #ifdef PDEBUG
    2555           p_Test(q, currRing);
    2556 #if 0
    2557           Print("NF(J/currQuotient)=> q: "); // !
    2558           p_Write(q, currRing);
    2559 #endif
    2560 #endif
    2561           if (q!=NULL)
    2562           {
    2563             if (p_IsConstant(q, currRing)) // => return (1)!
    2564             {
    2565               p_Delete(&q, currRing);
    2566               id_Delete(&J, currRing);
    2567 
    2568               if (K != NULL)
    2569                 id_Delete(&K, currRing);
    2570 
    2571               ideal Q = idInit(1,1); // ring independent!
    2572               Q->m[0] = p_One(currRing);
    2573 
    2574               return(Q);
    2575             }
    2576 
    2577 //            flag = false;
    2578 
    2579             // K += q:
    2580 
    2581             ideal Q = idInit(1,1); // ring independent
    2582             Q->m[0]=q;
    2583 
    2584             if( K == NULL )
    2585               K = Q;
    2586             else
    2587             {
    2588               ideal id_tmp = idSimpleAdd(K, Q); // in currRing
    2589               id_Delete(&K, currRing);
    2590               id_Delete(&Q, currRing);
    2591               K = id_tmp; // K += Q
    2592             }
    2593           }
    2594 
    2595 
    2596         } // if q != NULL
    2597       } // for all variables
    2598 
    2599     }
    2600 
    2601     if (K == NULL) // nothing new: i.e. all elements are two-sided
    2602       return(J);
    2603     // now we update GrBasis J with K
    2604     //    iSize=IDELEMS(J);
    2605 #ifdef PDEBUG
    2606     idTest(J); // in currRing!
    2607 #if 0
    2608     Print("J:");
    2609     idPrint(J);
    2610     PrintLn();
    2611 #endif // debug
    2612 #endif
    2613 
    2614 
    2615 
    2616 #ifdef PDEBUG
    2617     idTest(K); // in currRing!
    2618 #if 0
    2619     Print("+K:");
    2620     idPrint(K);
    2621     PrintLn();
    2622 #endif // debug
    2623 #endif
    2624 
    2625 
    2626     int iSize = idElem(J); // ring independent
    2627 
    2628     // J += K:
    2629     ideal id_tmp = idSimpleAdd(J,K); // in currRing
    2630     id_Delete(&K, currRing); id_Delete(&J, currRing);
    2631 
    2632 #if 1
    2633     BITSET save_test=test;
    2634     test|=Sy_bit(OPT_SB_1); // ring independent
    2635     J = kStd(id_tmp, currQuotient, testHomog, NULL, NULL, 0, iSize); // J = J + K, J - std // in currRing!
    2636     test = save_test;
    2637 #else
    2638     J=kStd(id_tmp, currQuotient,testHomog,NULL,NULL,0,0,NULL);
    2639 #endif
    2640 
    2641     id_Delete(&id_tmp, currRing);
    2642     idSkipZeroes(J); // ring independent
    2643 
    2644 #ifdef PDEBUG
    2645     idTest(J); // in currRing!
    2646 #if 0
    2647     Print("J:");
    2648     idPrint(J);
    2649     PrintLn();
    2650 #endif // debug
    2651 #endif
    2652   } // loop
    2653 }
    2654 */
    2655 
    2656 
    26572476/// returns matrix with the info on noncomm multiplication
    26582477matrix nc_PrintMat(int a, int b, ring r, int metric)
     
    35103329}
    35113330
    3512 /*
    3513 static ideal idPrepareStd(ideal T, ideal s,  int k)
    3514 {
    3515   // T is a left SB, without zeros, s is a list with zeros
    3516 #ifdef PDEBUG
    3517   if (IDELEMS(s)!=IDELEMS(T))
    3518   {
    3519     Print("ideals of diff. size!!!");
    3520   }
    3521 #endif
    3522   ideal t = idCopy(T);
    3523   int j,rs=idRankFreeModule(s);
    3524   poly p,q;
    3525 
    3526   ideal res = idInit(2*idElem(t),1+idElem(t));
    3527   if (rs == 0)
    3528   {
    3529     for (j=0; j<IDELEMS(t); j++)
    3530     {
    3531       if (s->m[j]!=NULL) pSetCompP(s->m[j],1);
    3532       if (t->m[j]!=NULL) pSetCompP(t->m[j],1);
    3533     }
    3534     k = si_max(k,1);
    3535   }
    3536   for (j=0; j<IDELEMS(t); j++)
    3537   {
    3538     if (s->m[j]!=NULL)
    3539     {
    3540       p = s->m[j];
    3541       q = pOne();
    3542       pSetComp(q,k+1+j);
    3543       pSetmComp(q);
    3544 #if 0
    3545       while (pNext(p)) pIter(p);
    3546       pNext(p) = q;
    3547 #else
    3548       p = pAdd(p,q);
    3549       s->m[j] = p;
    3550 #ifdef PDEBUG
    3551     pTest(p);
    3552 #endif
    3553 #endif
    3554     }
    3555   }
    3556   res = idSimpleAdd(t,s);
    3557   idDelete(&t);
    3558   res->rank = 1+idElem(T);
    3559   return(res);
    3560 }
    3561 */
    3562 
    3563 /* 
    3564 ideal Approx_Step(ideal L)
    3565 {
    3566   int N=currRing->N;
    3567   int i,j; // k=syzcomp
    3568   int flag, flagcnt=0, syzcnt=0;
    3569   int syzcomp = 0;
    3570   int k=1; // for ideals not modules
    3571   ideal I = kStd(L, currQuotient,testHomog,NULL,NULL,0,0,NULL);
    3572   idSkipZeroes(I);
    3573   ideal s_I;
    3574   int idI = idElem(I);
    3575   ideal trickyQuotient;
    3576   if (currQuotient !=NULL)
    3577   {
    3578     trickyQuotient = idSimpleAdd(currQuotient,I);
    3579   }
    3580   else
    3581     trickyQuotient = I;
    3582   idSkipZeroes(trickyQuotient);
    3583   poly *var = (poly *)omAlloc0((N+1)*sizeof(poly));
    3584   //  poly *W = (poly *)omAlloc0((2*N+1)*sizeof(poly));
    3585   resolvente S = (resolvente)omAlloc0((N+1)*sizeof(ideal));
    3586   ideal SI, res;
    3587   matrix MI;
    3588   poly x=pOne();
    3589   var[0]=x;
    3590   ideal   h2, h3, s_h2, s_h3;
    3591   poly    p,q,qq;
    3592   // init vars
    3593   for (i=1; i<=N; i++ )
    3594   {
    3595     x = pOne();
    3596     pSetExp(x,i,1);
    3597     pSetm(x);
    3598     var[i]=pCopy(x);
    3599   }
    3600   // init NF's
    3601   for (i=1; i<=N; i++ )
    3602   {
    3603     h2 = idInit(idI,1);
    3604     flag = 0;
    3605     for (j=0; j< idI; j++ )
    3606     {
    3607       q = pp_Mult_mm(I->m[j],var[i],currRing);
    3608       q = kNF(I,currQuotient,q,0,0);
    3609       if (q!=0)
    3610       {
    3611     h2->m[j]=pCopy(q);
    3612     //  pShift(&(h2->m[flag]),1);
    3613     flag++;
    3614     pDelete(&q);
    3615       }
    3616       else
    3617     h2->m[j]=0;
    3618     }
    3619     // W[1..idElems(I)]
    3620     if (flag >0)
    3621     {
    3622       // compute syzygies with values in I
    3623       //      idSkipZeroes(h2);
    3624       //      h2 = idSimpleAdd(h2,I);
    3625       //      h2->rank=flag+idI+1;
    3626       idTest(h2);
    3627       //idShow(h2);
    3628       ring orig_ring=currRing;
    3629       ring syz_ring=rCurrRingAssure_SyzComp();
    3630       syzcomp = 1;
    3631       rSetSyzComp(syzcomp);
    3632       if (orig_ring != syz_ring)
    3633       {
    3634         s_h2=idrCopyR_NoSort(h2,orig_ring);
    3635         //  s_trickyQuotient=idrCopyR_NoSort(trickyQuotient,orig_ring);
    3636         //  rDebugPrint(syz_ring);
    3637         s_I=idrCopyR_NoSort(I,orig_ring);
    3638       }
    3639       else
    3640       {
    3641         s_h2 = h2;
    3642         s_I  = I;
    3643         //  s_trickyQuotient=trickyQuotient;
    3644       }
    3645       idTest(s_h2);
    3646       //      idTest(s_trickyQuotient);
    3647       Print(".proceeding with the variable %d\n",i);
    3648       s_h3 = idPrepareStd(s_I, s_h2, 1);
    3649       BITSET save_test=test;
    3650       test|=Sy_bit(OPT_SB_1);
    3651       idTest(s_h3);
    3652       idDelete(&s_h2);
    3653       s_h2=idCopy(s_h3);
    3654       idDelete(&s_h3);
    3655       Print("...computing Syz");
    3656       s_h3 = kStd(s_h2, currQuotient,(tHomog)FALSE,NULL,NULL,syzcomp,idI);
    3657       test=save_test;
    3658       //idShow(s_h3);
    3659       if (orig_ring != syz_ring)
    3660       {
    3661         idDelete(&s_h2);
    3662         for (j=0; j<IDELEMS(s_h3); j++)
    3663         {
    3664           if (s_h3->m[j] != NULL)
    3665           {
    3666             if (p_MinComp(s_h3->m[j],syz_ring) > syzcomp) // i.e. it is a syzygy
    3667               pShift(&s_h3->m[j], -syzcomp);
    3668             else
    3669               pDelete(&s_h3->m[j]);
    3670           }
    3671         }
    3672         idSkipZeroes(s_h3);
    3673         s_h3->rank -= syzcomp;
    3674         rChangeCurrRing(orig_ring);
    3675         //  s_h3 = idrMoveR_NoSort(s_h3, syz_ring);
    3676         s_h3 = idrMoveR_NoSort(s_h3, syz_ring);
    3677         rKill(syz_ring);
    3678       }
    3679       idTest(s_h3);
    3680       S[syzcnt]=kStd(s_h3,currQuotient,(tHomog)FALSE,NULL,NULL);
    3681       syzcnt++;
    3682       idDelete(&s_h3);
    3683     } // end if flag >0
    3684     else
    3685     {
    3686       flagcnt++;
    3687     }
    3688   }
    3689   if (flagcnt == N)
    3690   {
    3691     Print("the input is a two--sided ideal");
    3692     return(I);
    3693   }
    3694   if (syzcnt >0)
    3695   {
    3696     Print("..computing Intersect of %d modules\n",syzcnt);
    3697     if (syzcnt == 1)
    3698       SI = S[0];
    3699     else
    3700       SI = idMultSect(S, syzcnt);
    3701     //idShow(SI);
    3702     MI = idModule2Matrix(SI);
    3703     res= idInit(MATCOLS(MI),1);
    3704     for (i=1; i<= MATCOLS(MI); i++)
    3705     {
    3706       p = NULL;
    3707       for (j=0; j< idElem(I); j++)
    3708       {
    3709         q = pCopy(MATELEM(MI,j+1,i));
    3710         if (q!=NULL)
    3711         {
    3712           q = pMult(q,pCopy(I->m[j]));
    3713           p = pAdd(p,q);
    3714         }
    3715       }
    3716       res->m[i-1]=p;
    3717     }
    3718     Print("final std");
    3719     res = kStd(res, currQuotient,testHomog,NULL,NULL,0,0,NULL);
    3720     idSkipZeroes(res);
    3721     return(res);
    3722   }
    3723   else
    3724   {
    3725     Print("No syzygies");
    3726     return(I);
    3727   }
    3728 }
    3729 */
    37303331
    37313332// creates a commutative nc extension; "converts" comm.ring to a Plural ring
Note: See TracChangeset for help on using the changeset viewer.