Changeset 287cc8 in git for ntl/src/ZZ_pEX.c


Ignore:
Timestamp:
Jan 5, 2010, 5:51:13 PM (14 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
3c38b3810fd61108b01f123f5a91e13ccff52b20
Parents:
1d43d184dd871d77c1ba8e095d768f22a0fbe92f
Message:
ntl 5.5.2

git-svn-id: file:///usr/local/Singular/svn/trunk@12402 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ntl/src/ZZ_pEX.c

    r1d43d18 r287cc8  
    9797   long j, m;
    9898
    99    if (i < 0) 
     99   if (i < 0)
    100100      Error("SetCoeff: negative index");
    101101
     
    174174   long j, m;
    175175
    176    if (i < 0) 
     176   if (i < 0)
    177177      Error("coefficient index out of range");
    178178
     
    203203   return deg(a) == 1 && IsOne(LeadCoeff(a)) && IsZero(ConstTerm(a));
    204204}
    205      
    206      
     205
     206
    207207
    208208const ZZ_pE& coeff(const ZZ_pEX& a, long i)
     
    245245void conv(ZZ_pEX& x, long a)
    246246{
    247    if (a == 0) 
     247   if (a == 0)
    248248      clear(x);
    249249   else if (a == 1)
     
    265265void conv(ZZ_pEX& x, const ZZ_p& a)
    266266{
    267    if (IsZero(a)) 
     267   if (IsZero(a))
    268268      clear(x);
    269269   else if (IsOne(a))
     
    305305
    306306   long i;
    307    const ZZ_pE *ap, *bp; 
     307   const ZZ_pE *ap, *bp;
    308308   ZZ_pE* xp;
    309309
     
    406406
    407407   long i;
    408    const ZZ_pE *ap, *bp; 
     408   const ZZ_pE *ap, *bp;
    409409   ZZ_pE* xp;
    410410
     
    537537void sub(ZZ_pEX& x, long a, const ZZ_pEX& b)
    538538{
    539    NTL_ZZ_pRegister(T); 
     539   NTL_ZZ_pRegister(T);
    540540   T = a;
    541541   negate(x, b);
     
    558558      mul(c, b, ConstTerm(a));
    559559      return;
    560    } 
     560   }
    561561
    562562   if (deg(b) == 0) {
     
    586586      long dcoeff = deg(coeff);
    587587      for (j = 0; j <= dcoeff; j++)
    588          A.rep[n2*i + j] = coeff.rep[j]; 
     588         A.rep[n2*i + j] = coeff.rep[j];
    589589   }
    590590
     
    597597      long dcoeff = deg(coeff);
    598598      for (j = 0; j <= dcoeff; j++)
    599          B.rep[n2*i + j] = coeff.rep[j]; 
     599         B.rep[n2*i + j] = coeff.rep[j];
    600600   }
    601601
     
    611611
    612612   ZZ_pX tmp;
    613    
     613
    614614   for (i = 0; i <= dc; i++) {
    615615      tmp.rep.SetLength(n2);
     
    621621      conv(c.rep[i], tmp);
    622622   }
    623  
     623
    624624   c.normalize();
    625625}
     
    700700      conv(c, res);
    701701      return;
    702    } 
     702   }
    703703
    704704   // general case...Kronecker subst
     
    722722      long dcoeff = deg(coeff);
    723723      for (j = 0; j <= dcoeff; j++)
    724          A.rep[n2*i + j] = coeff.rep[j]; 
     724         A.rep[n2*i + j] = coeff.rep[j];
    725725   }
    726726
     
    736736
    737737   ZZ_pX tmp;
    738    
     738
    739739   for (i = 0; i <= dc; i++) {
    740740      tmp.rep.SetLength(n2);
     
    746746      conv(c.rep[i], tmp);
    747747   }
    748  
    749  
     748
     749
    750750   c.normalize();
    751751}
     
    796796
    797797   x.normalize();
    798 } 
     798}
    799799
    800800
    801801void trunc(ZZ_pEX& x, const ZZ_pEX& a, long m)
    802802
    803 // x = a % X^m, output may alias input 
     803// x = a % X^m, output may alias input
    804804
    805805{
     
    931931   const ZZ_pE *ap, *bp;
    932932   ZZ_pE *xp;
    933    
     933
    934934   ZZ_pEX la, lb;
    935935
     
    10201020   SetSize(x, da+1, 2*ZZ_pE::degree());
    10211021
    1022    for (i = 0; i <= da; i++) 
     1022   for (i = 0; i <= da; i++)
    10231023      x[i] = rep(a.rep[i]);
    10241024
     
    11041104
    11051105
    1106 void PlainDivRem(ZZ_pEX& q, ZZ_pEX& r, const ZZ_pEX& a, const ZZ_pEX& b, 
     1106void PlainDivRem(ZZ_pEX& q, ZZ_pEX& r, const ZZ_pEX& a, const ZZ_pEX& b,
    11071107     vec_ZZ_pX& x)
    11081108{
     
    13111311   long da = deg(a);
    13121312   long i;
    1313  
     1313
    13141314   if (da < n) {
    13151315      clear(x);
     
    13371337
    13381338   if (n < 0) {
    1339       if (n < -NTL_MAX_LONG) 
     1339      if (n < -NTL_MAX_LONG)
    13401340         clear(x);
    13411341      else
     
    14451445   if (NTL_OVERFLOW(n, ZZ_pE::degree(), 0))
    14461446      Error("build(ZZ_pEXModulus,ZZ_pEX): overflow");
    1447    
     1447
    14481448
    14491449   F.tracevec.SetLength(0);
     
    14781478
    14791479
    1480 ZZ_pEXModulus::~ZZ_pEXModulus() 
    1481 { 
     1480ZZ_pEXModulus::~ZZ_pEXModulus()
     1481{
    14821482}
    14831483
     
    17391739   mul(P1, P2, b);
    17401740   sub(P1, a, P1);
    1741    
     1741
    17421742   r = P1;
    17431743}
     
    17601760   mul(P1, P2, b);
    17611761   sub(P1, a, P1);
    1762    
     1762
    17631763   r = P1;
    17641764   q = P2;
     
    17801780   mul(P2, P1, P2);
    17811781   RightShift(P2, P2, da-db);
    1782    
     1782
    17831783   q = P2;
    17841784}
     
    18871887
    18881888
    1889    inv(t, LeadCoeff(x)); 
    1890    mul(x, x, t); 
    1891 }
    1892 
    1893 
    1894 
    1895          
     1889   inv(t, LeadCoeff(x));
     1890   mul(x, x, t);
     1891}
     1892
     1893
     1894
     1895
    18961896
    18971897void XGCD(ZZ_pEX& d, ZZ_pEX& s, ZZ_pEX& t, const ZZ_pEX& a, const ZZ_pEX& b)
     
    19131913      long e = max(deg(a), deg(b)) + 1;
    19141914
    1915       ZZ_pEX temp(INIT_SIZE, e), u(INIT_SIZE, e), v(INIT_SIZE, e), 
    1916             u0(INIT_SIZE, e), v0(INIT_SIZE, e), 
    1917             u1(INIT_SIZE, e), v1(INIT_SIZE, e), 
     1915      ZZ_pEX temp(INIT_SIZE, e), u(INIT_SIZE, e), v(INIT_SIZE, e),
     1916            u0(INIT_SIZE, e), v0(INIT_SIZE, e),
     1917            u1(INIT_SIZE, e), v1(INIT_SIZE, e),
    19181918            u2(INIT_SIZE, e), v2(INIT_SIZE, e), q(INIT_SIZE, e);
    19191919
     
    20922092   f.rep = res;
    20932093}
    2094    
    2095 void InnerProduct(ZZ_pEX& x, const vec_ZZ_pE& v, long low, long high, 
     2094
     2095void InnerProduct(ZZ_pEX& x, const vec_ZZ_pE& v, long low, long high,
    20962096                   const vec_ZZ_pEX& H, long n, vec_ZZ_pX& t)
    20972097{
     
    21222122
    21232123
    2124 void CompMod(ZZ_pEX& x, const ZZ_pEX& g, const ZZ_pEXArgument& A, 
     2124void CompMod(ZZ_pEX& x, const ZZ_pEX& g, const ZZ_pEXArgument& A,
    21252125             const ZZ_pEXModulus& F)
    21262126{
     
    22302230}
    22312231
    2232 void Comp3Mod(ZZ_pEX& x1, ZZ_pEX& x2, ZZ_pEX& x3, 
     2232void Comp3Mod(ZZ_pEX& x1, ZZ_pEX& x2, ZZ_pEX& x3,
    22332233              const ZZ_pEX& g1, const ZZ_pEX& g2, const ZZ_pEX& g3,
    22342234              const ZZ_pEX& h, const ZZ_pEXModulus& F)
     
    22782278      B.shamt_fbi = 0;
    22792279   else
    2280       B.shamt_fbi = F.n-2 - d; 
     2280      B.shamt_fbi = F.n-2 - d;
    22812281
    22822282   CopyReverse(B.fbi, t, d);
    22832283
    2284    // The following code optimizes the case when 
     2284   // The following code optimizes the case when
    22852285   // f = X^n + low degree poly
    22862286
     
    23582358
    23592359static
    2360 void ProjectPowers(vec_ZZ_pE& x, const ZZ_pEX& a, long k, 
     2360void ProjectPowers(vec_ZZ_pE& x, const ZZ_pEX& a, long k,
    23612361                   const ZZ_pEXArgument& H, const ZZ_pEXModulus& F)
    23622362{
    2363    if (k < 0 || NTL_OVERFLOW(k, 1, 0) || deg(a) >= F.n) 
     2363   if (k < 0 || NTL_OVERFLOW(k, 1, 0) || deg(a) >= F.n)
    23642364      Error("ProjectPowers: bad args");
    23652365
     
    23872387
    23882388static
    2389 void ProjectPowers(vec_ZZ_pE& x, const ZZ_pEX& a, long k, const ZZ_pEX& h, 
     2389void ProjectPowers(vec_ZZ_pE& x, const ZZ_pEX& a, long k, const ZZ_pEX& h,
    23902390                   const ZZ_pEXModulus& F)
    23912391{
     
    24742474   }
    24752475
    2476    // cerr << "finished: " << L << " " << deg(Lambda) << "\n"; 
     2476   // cerr << "finished: " << L << " " << deg(Lambda) << "\n";
    24772477
    24782478   dl = deg(Lambda);
     
    24982498
    24992499
    2500 void DoMinPolyMod(ZZ_pEX& h, const ZZ_pEX& g, const ZZ_pEXModulus& F, long m, 
     2500void DoMinPolyMod(ZZ_pEX& h, const ZZ_pEX& g, const ZZ_pEXModulus& F, long m,
    25012501               const ZZ_pEX& R)
    25022502{
     
    25412541   ZZ_pEX R;
    25422542   ZZ_pEXTransMultiplier H1;
    2543    
     2543
    25442544
    25452545   for (;;) {
     
    26342634   ZZ_pEX lq, r;
    26352635   DivRem(lq, r, a, b);
    2636    if (!IsZero(r)) return 0; 
     2636   if (!IsZero(r)) return 0;
    26372637   q = lq;
    26382638   return 1;
     
    26442644   ZZ_pEX lq, r;
    26452645   DivRem(lq, r, a, b);
    2646    if (!IsZero(r)) return 0; 
     2646   if (!IsZero(r)) return 0;
    26472647   return 1;
    26482648}
     
    26712671   return k;
    26722672}
    2673      
     2673
    26742674
    26752675
     
    27372737
    27382738   v[0] = g;
    2739  
     2739
    27402740   if (k > 1) {
    27412741      ZZ_pEX t;
     
    27532753   val = 0;
    27542754   for (i = n-1; i >= 0; i--) {
    2755       val = (val << 1) | bit(e, i); 
     2755      val = (val << 1) | bit(e, i);
    27562756      if (val == 0)
    27572757         SqrMod(res, res, F);
     
    29072907   res.SetMaxLength(da*e + 1);
    29082908   res = 1;
    2909    
     2909
    29102910   long k = NumBits(e);
    29112911   long i;
     
    30053005      Error("trace: bad args");
    30063006
    3007    if (F.tracevec.length() == 0) 
     3007   if (F.tracevec.length() == 0)
    30083008      ComputeTraceVec(F);
    30093009
     
    30233023{
    30243024   ZZ_pE res;
    3025  
     3025
    30263026   if (IsZero(a) || IsZero(b))
    30273027      clear(res);
    3028    else if (deg(a) == 0 && deg(b) == 0) 
     3028   else if (deg(a) == 0 && deg(b) == 0)
    30293029      set(res);
    30303030   else {
     
    30623062            else
    30633063               clear(res);
    3064        
     3064
    30653065            break;
    30663066         }
     
    30733073void resultant(ZZ_pE& rres, const ZZ_pEX& a, const ZZ_pEX& b)
    30743074{
    3075    PlainResultant(rres, a, b); 
     3075   PlainResultant(rres, a, b);
    30763076}
    30773077
     
    30793079void NormMod(ZZ_pE& x, const ZZ_pEX& a, const ZZ_pEX& f)
    30803080{
    3081    if (deg(f) <= 0 || deg(a) >= deg(f)) 
     3081   if (deg(f) <= 0 || deg(a) >= deg(f))
    30823082      Error("norm: bad args");
    30833083
     
    31633163
    31643164
    3165 void CompTower(ZZ_pEX& x, const ZZ_pX& g, const ZZ_pEX& h, 
     3165void CompTower(ZZ_pEX& x, const ZZ_pX& g, const ZZ_pEX& h,
    31663166             const ZZ_pEXModulus& F)
    31673167   // x = g(h) mod f
     
    31973197}
    31983198
    3199 void ProjectedInnerProduct(ZZ_p& x, const vec_ZZ_pE& a, 
     3199void ProjectedInnerProduct(ZZ_p& x, const vec_ZZ_pE& a,
    32003200                           const vec_vec_ZZ_p& b)
    32013201{
     
    32323232   }
    32333233}
    3234    
     3234
    32353235
    32363236
     
    32423242   long n = F.n;
    32433243
    3244    if (a.length() > n || k < 0 || NTL_OVERFLOW(k, 1, 0)) 
     3244   if (a.length() > n || k < 0 || NTL_OVERFLOW(k, 1, 0))
    32453245      Error("ProjectPowers: bad args");
    32463246
     
    33013301
    33023302   ProjectPowersTower(x, R, 2*m, g, F, proj);
    3303    
     3303
    33043304   MinPolySeq(h, x, m);
    33053305}
    33063306
    33073307
    3308 void ProbMinPolyTower(ZZ_pX& h, const ZZ_pEX& g, const ZZ_pEXModulus& F, 
     3308void ProbMinPolyTower(ZZ_pX& h, const ZZ_pEX& g, const ZZ_pEXModulus& F,
    33093309                      long m)
    33103310{
     
    33263326
    33273327
    3328 void ProbMinPolyTower(ZZ_pX& h, const ZZ_pEX& g, const ZZ_pEXModulus& F, 
     3328void ProbMinPolyTower(ZZ_pX& h, const ZZ_pEX& g, const ZZ_pEXModulus& F,
    33293329                      long m, const vec_ZZ_p& proj)
    33303330{
     
    33693369   vec_ZZ_pE R;
    33703370   ZZ_pEXTransMultiplier H1;
    3371    
     3371
    33723372
    33733373   for (;;) {
Note: See TracChangeset for help on using the changeset viewer.