[BACK]Return to up.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2018 / engine

Diff for /OpenXM_contrib2/asir2018/engine/up.c between version 1.1 and 1.3

version 1.1, 2018/09/19 05:45:07 version 1.3, 2019/03/03 05:21:17
Line 45 
Line 45 
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  *   *
  * $OpenXM$   * $OpenXM: OpenXM_contrib2/asir2018/engine/up.c,v 1.2 2018/09/28 08:20:28 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include <math.h>  #include <math.h>
Line 163  void reversep(P p1,Q d,P *rp)
Line 163  void reversep(P p1,Q d,P *rp)
     *rp = 0;      *rp = 0;
   else {    else {
     ptoup(p1,&n1);      ptoup(p1,&n1);
     reverseup(n1,QTOS(d),&r);      reverseup(n1,ZTOS(d),&r);
     uptop(r,rp);      uptop(r,rp);
   }    }
 }  }
Line 176  void invmodp(P p1,Q d,P *rp)
Line 176  void invmodp(P p1,Q d,P *rp)
     error("invmodp : invalid input");      error("invmodp : invalid input");
   else {    else {
     ptoup(p1,&n1);      ptoup(p1,&n1);
     invmodup(n1,QTOS(d),&r);      invmodup(n1,ZTOS(d),&r);
     uptop(r,rp);      uptop(r,rp);
   }    }
 }  }
Line 296  void hybrid_squareup(int ff,UP n1,UP *nr)
Line 296  void hybrid_squareup(int ff,UP n1,UP *nr)
   
 void hybrid_tmulup(int ff,UP n1,UP n2,int d,UP *nr)  void hybrid_tmulup(int ff,UP n1,UP n2,int d,UP *nr)
 {  {
     UP t;
   
   if ( !n1 || !n2 )    if ( !n1 || !n2 )
     *nr = 0;      *nr = 0;
   else if ( MAX(n1->d,n2->d) < up_fft_mag )    else if ( MAX(n1->d,n2->d) < up_fft_mag )
Line 681  void pwrup(UP n,Z e,UP *nr)
Line 683  void pwrup(UP n,Z e,UP *nr)
   else if ( UNIQ(e) )    else if ( UNIQ(e) )
     *nr = n;      *nr = n;
   else {    else {
     STOQ(2,two);      STOZ(2,two);
     while ( 1 ) {      while ( 1 ) {
       divqrz(e,two,&q,&r); e = q;        divqrz(e,two,&q,&r); e = q;
       if ( r ) {        if ( r ) {
Line 856  void rembymulup(UP n1,UP n2,UP *nr)
Line 858  void rembymulup(UP n1,UP n2,UP *nr)
 void hybrid_rembymulup_special(int ff,UP n1,UP n2,UP inv2,UP *nr)  void hybrid_rembymulup_special(int ff,UP n1,UP n2,UP inv2,UP *nr)
 {  {
   int d1,d2,d;    int d1,d2,d;
   UP r1,t,s,q;    UP r1,t,s,q,t1;
   
   if ( !n2 )    if ( !n2 )
     error("hybrid_rembymulup : division by 0");      error("hybrid_rembymulup : division by 0");
Line 1112  void fmarraytoup(ModNum *f,int d,UP *nr)
Line 1114  void fmarraytoup(ModNum *f,int d,UP *nr)
   } else {    } else {
     *nr = r = UPALLOC(d); c = (Z *)r->c;      *nr = r = UPALLOC(d); c = (Z *)r->c;
     for ( i = 0; i <= d; i++ ) {      for ( i = 0; i <= d; i++ ) {
       UTOQ((unsigned int)f[i],c[i]);        UTOZ((unsigned int)f[i],c[i]);
     }      }
     for ( i = d; i >= 0 && !c[i]; i-- );      for ( i = d; i >= 0 && !c[i]; i-- );
     if ( i < 0 )      if ( i < 0 )
Line 1363  void fft_mulup_main(UP n1,UP n2,int dbd,UP *nr)
Line 1365  void fft_mulup_main(UP n1,UP n2,int dbd,UP *nr)
     }      }
     if ( cond )      if ( cond )
       error("fft_mulup : error in FFT_pol_product");        error("fft_mulup : error in FFT_pol_product");
     STOQ(mod,m1); mulz(m,m1,&m2); m = m2;      STOZ(mod,m1); mulz(m,m1,&m2); m = m2;
     if ( z_bits((Q)m) > bound ) {      if ( z_bits((Q)m) > bound ) {
       if ( !dbd )        if ( !dbd )
         dbd = d1+d2+1;          dbd = d1+d2+1;
       crup(frarray,MIN(d1+d2,dbd-1),modarray,frarray_index,m,&r);        crup(frarray,MIN(d1+d2,dbd-1),modarray,frarray_index,m,&r);
       STOQ(2,two);        STOZ(2,two);
       divqrz(m,two,&m2,&rem);        divqrz(m,two,&m2,&rem);
       adj_coefup(r,m,m2,nr);        adj_coefup(r,m,m2,nr);
       return;        return;
Line 1384  void crup(ModNum **f,int d,int *mod,int index,Z m,UP *
Line 1386  void crup(ModNum **f,int d,int *mod,int index,Z m,UP *
   mpz_t cof,c,rem;    mpz_t cof,c,rem;
   mpz_t *s;    mpz_t *s;
   UP u;    UP u;
     Z z;
   int inv,i,j,t;    int inv,i,j,t;
   
   mpz_init(c); mpz_init(cof); mpz_init(rem);    mpz_init(c); mpz_init(cof); mpz_init(rem);
Line 1408  void crup(ModNum **f,int d,int *mod,int index,Z m,UP *
Line 1411  void crup(ModNum **f,int d,int *mod,int index,Z m,UP *
   else {    else {
     u = UPALLOC(i);      u = UPALLOC(i);
     DEG(u) = i;      DEG(u) = i;
     for ( j = 0; j <= i; j++ )      for ( j = 0; j <= i; j++ ) {
       COEF(u)[j] = (Num)s[j];        MPZTOZ(s[j],z); COEF(u)[j] = (Num)z;
       }
     remcup(u,m,r);      remcup(u,m,r);
   }    }
 }  }
Line 1462  void fft_mulup_specialmod_main(UP n1,UP n2,int dbd,int
Line 1466  void fft_mulup_specialmod_main(UP n1,UP n2,int dbd,int
     }      }
     if ( cond )      if ( cond )
       error("fft_mulup_specialmod_main : error in FFT_pol_product");        error("fft_mulup_specialmod_main : error in FFT_pol_product");
     STOQ(modarray[i],m1); mulz(m,m1,&m2); m = m2;      STOZ(modarray[i],m1); mulz(m,m1,&m2); m = m2;
   }    }
   if ( !dbd )    if ( !dbd )
     dbd = d1+d2+1;      dbd = d1+d2+1;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>