コード例 #1
0
ファイル: rat.c プロジェクト: ptigwe/gte
/* GSoC12: Tobenna Peter, Igwe (Edited) */
Rat ratreduce (Rat a)
{
    if (zero(a.num))
    {
        /*a.den = 1;*/
        itomp(1, a.den);
    }
    else
    {
        mp div;
        mp c;
        if (negative(a.den))
        {
            /*a.den = -a.den;*/
            changesign(a.den);
            /*a.num = -a.num;*/
            changesign(a.num);
        }
        /*div = ratgcd(a.den, a.num);*/
        ratgcd(a.den, a.num, div);
        /*a.num = a.num/div;*/
        divint(a.num, div, c);
        copy(a.num, c);
        /*a.den = a.den/div;*/
        divint(a.den, div, c);
        copy(a.den, c);
    }
    return a;
}
コード例 #2
0
ファイル: prepdiag.c プロジェクト: cbpark/twoscale_softsusy
static void  standartsubst(int v,int l,char* subst)
{  int  i, vv, ll, ch, flg1 = 0, flg2 = 0; 
 
   if (vcs.vertlist[v-1][l-1].moment == nin + nout) 
   {  subst[0] = 0;
      /* strcpy(subst,""); */
      for (i = 1; i <= nin; i++)
         subst[++subst[0]] = i;          
         /* sbld(subst,"%s%c",subst,i); */
      for (i = nin + 1; i <= nin + nout - 1; i++)
         subst[++subst[0]] = -i;
         /* sbld(subst,"%s%c",subst,-i); */
      return;
   }

   ch = nin + nout; 
   findsubst(v,l,subst); 
   for (i = 1; i <= subst[0]; i++) 
   {  if (subst[i] ==  ch) flg1 = 1;
      if (subst[i] == -ch) flg2 = 1;
   }
   if (flg1 && flg2) 
   { 
      vv = vcs.vertlist[v-1][l-1].nextvert.vno; 
      ll = vcs.vertlist[v-1][l-1].nextvert.edno;
      findsubst(vv,ll,subst); 
      changesign(subst); 
   } 
}   /*  StandartSubst  */ 
コード例 #3
0
ファイル: poly_l2.c プロジェクト: BTHUNTERCN/cygwin
/*--- poly_l2p1() -----------------------------------------------------------+
 |   Base 2 logarithm by a polynomial approximation.                         |
 |   log2(x+1)                                                               |
 +---------------------------------------------------------------------------*/
int	poly_l2p1(u_char sign0, u_char sign1,
		  FPU_REG *st0_ptr, FPU_REG *st1_ptr, FPU_REG *dest)
{
  u_char       	tag;
  s32        	exponent;
  Xsig         	accumulator, yaccum;

  if ( exponent16(st0_ptr) < 0 )
    {
      log2_kernel(st0_ptr, sign0, &accumulator, &exponent);

      yaccum.lsw = 0;
      XSIG_LL(yaccum) = significand(st1_ptr);
      mul_Xsig_Xsig(&accumulator, &yaccum);

      exponent += round_Xsig(&accumulator);

      exponent += exponent16(st1_ptr) + 1;
      if ( exponent < EXP_WAY_UNDER ) exponent = EXP_WAY_UNDER;

      significand(dest) = XSIG_LL(accumulator);
      setexponent16(dest, exponent);

      tag = FPU_round(dest, 1, 0, FULL_PRECISION, sign0 ^ sign1);
      FPU_settagi(1, tag);

      if ( tag == TAG_Valid )
	set_precision_flag_up();   /* 80486 appears to always do this */
    }
  else
    {
      /* The magnitude of st0_ptr is far too large. */

      if ( sign0 != SIGN_POS )
	{
	  /* Trying to get the log of a negative number. */
#ifdef PECULIAR_486   /* Stupid 80486 doesn't worry about log(negative). */
	  changesign(st1_ptr);
#else
	  if ( arith_invalid(1) < 0 )
	    return 1;
#endif /* PECULIAR_486 */
	}

      /* 80486 appears to do this */
      if ( sign0 == SIGN_NEG )
	set_precision_flag_down();
      else
	set_precision_flag_up();
    }

  if ( exponent(dest) <= EXP_UNDER )
    EXCEPTION(EX_Underflow);

  return 0;

}
コード例 #4
0
ファイル: prepdiag.c プロジェクト: cbpark/twoscale_softsusy
static void  optimsubst(int v,int l,char* subst)
{momsum      frontsubst, backsubst; 
 int        i, vv, ll; 

   findsubst(v,l,frontsubst); 
   vv = vcs.vertlist[v-1][l-1].nextvert.vno; 
   ll = vcs.vertlist[v-1][l-1].nextvert.edno; 
   findsubst(vv,ll,backsubst); 
   if (/*strlen(frontsubst) <= strlen(backsubst)*/
       frontsubst[0] <= backsubst[0]) 
      for (i = 0; i <= frontsubst[0]; i++) subst[i] = frontsubst[i];
      /* strcpy(subst,frontsubst); */
   else 
   {  for (i = 0; i <= backsubst[0]; i++) subst[i] = backsubst[i];
      /* strcpy(subst,backsubst); */
      changesign(subst); 
   } 
}   /*  OptimCond  */
コード例 #5
0
ファイル: rat.c プロジェクト: ptigwe/gte
/* GSoC12: Tobenna Peter, Igwe (Edited)*/
Rat ratneg (Rat a)
{
    /*a.num = - a.num;*/
    changesign(a.num);
    return  a;
}