Ejemplo n.º 1
0
static void* __timer_thread(void* param){
	on_time func = ((st_thread_param*)param)->func;
	int interval = ((st_thread_param*)param)->interval;
	int id = ((st_thread_param*)param)->id;
	FT_FREE(param);
	param = NULL;
	
	timeval std_time;
	gettimeofday(&std_time, NULL);
	//Debug("%d,%d\n", std_time.tv_sec, std_time.tv_usec);
	usleep(interval * 1000);
	while(1){
		timeval tv, now, interval_time;
		gettimeofday(&now, NULL);
		//Debug("%d,%d\n", now.tv_sec, now.tv_usec);
		tv.tv_sec = interval / 1000;
		tv.tv_usec = interval % 1000;

		interval_time = __reduce(__add(__add(tv, tv),std_time), now);
		interval_time = interval_time.tv_sec>0?interval_time:tv;
		//Debug("%d,%d\n", interval_time.tv_sec, interval_time.tv_usec);
		select( 0, 0, 0, 0, &interval_time);
		func(id);
		std_time = now;
		//usleep(interval*1000);
	}

}
Ejemplo n.º 2
0
/* y=0 is not permitted if x<=0. No error messages are given.     */
void __mpatan2(mp_no *y, mp_no *x, mp_no *z, int p) {

  static const double ZERO = 0.0, ONE = 1.0;

  mp_no mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
  mp_no mpt1,mpt2,mpt3;


  if (X[0] <= ZERO) {
    mpone.e = 1;                 mpone.d[0] = mpone.d[1] = ONE;
    __dvd(x,y,&mpt1,p);          __mul(&mpt1,&mpt1,&mpt2,p);
    if (mpt1.d[0] != ZERO)       mpt1.d[0] = ONE;
    __add(&mpt2,&mpone,&mpt3,p); __mpsqrt(&mpt3,&mpt2,p);
    __add(&mpt1,&mpt2,&mpt3,p);  mpt3.d[0]=Y[0];
    __mpatan(&mpt3,&mpt1,p);     __add(&mpt1,&mpt1,z,p);
  }
  else
  { __dvd(y,x,&mpt1,p);
    __mpatan(&mpt1,z,p);
  }

  return;
}
double __slowpow(double x, double y, double z) {
  double res,res1;
  mp_no mpx, mpy, mpz,mpw,mpp,mpr,mpr1;
  static const mp_no eps = {-3,{1.0,4.0}};
  int p;

  res = __halfulp(x,y);        /* halfulp() returns -10 or x^y             */
  if (res >= 0) return res;  /* if result was really computed by halfulp */
                  /*  else, if result was not really computed by halfulp */
  p = 10;         /*  p=precision   */
  __dbl_mp(x,&mpx,p);
  __dbl_mp(y,&mpy,p);
  __dbl_mp(z,&mpz,p);
  __mplog(&mpx, &mpz, p);     /* log(x) = z   */
  __mul(&mpy,&mpz,&mpw,p);    /*  y * z =w    */
  __mpexp(&mpw, &mpp, p);     /*  e^w =pp     */
  __add(&mpp,&eps,&mpr,p);    /*  pp+eps =r   */
  __mp_dbl(&mpr, &res, p);
  __sub(&mpp,&eps,&mpr1,p);   /*  pp -eps =r1 */
  __mp_dbl(&mpr1, &res1, p);  /*  converting into double precision */
  if (res == res1) return res;

  p = 32;     /* if we get here result wasn't calculated exactly, continue */
  __dbl_mp(x,&mpx,p);                          /* for more exact calculation */
  __dbl_mp(y,&mpy,p);
  __dbl_mp(z,&mpz,p);
  __mplog(&mpx, &mpz, p);   /* log(c)=z  */
  __mul(&mpy,&mpz,&mpw,p);  /* y*z =w    */
  __mpexp(&mpw, &mpp, p);   /* e^w=pp    */
  __mp_dbl(&mpp, &res, p);  /* converting into double precision */
  return res;
}
Ejemplo n.º 4
0
double
SECTION
__cos32(double x, double res, double res1) {
  int p;
  mp_no a,b,c;
  p=32;
  __dbl_mp(res,&a,p);
  __dbl_mp(0.5*(res1-res),&b,p);
  __add(&a,&b,&c,p);
  if (x>2.4)
  { __sub(&pi,&c,&a,p);
    __c32(&a,&b,&c,p);
    b.d[0]=-b.d[0];
  }
  else if (x>0.8)
       { __sub(&hp,&c,&a,p);
	 __c32(&a,&c,&b,p);
       }
  else __c32(&c,&b,&a,p);     /* b=cos(0.5*(res+res1))  */
  __dbl_mp(x,&c,p);    /* c = x                  */
  __sub(&b,&c,&a,p);
	     /* if a>0 return max(res,res1), otherwise return min(res,res1) */
  if (a.d[0]>0)  return (res>res1)?res:res1;
  else  return (res<res1)?res:res1;
}
Ejemplo n.º 5
0
/* Stage 3: Perform a multi-Precision computation */
static double
SECTION
atan2Mp (double x, double y, const int pr[])
{
  double z1, z2;
  int i, p;
  mp_no mpx, mpy, mpz, mpz1, mpz2, mperr, mpt1;
  for (i = 0; i < MM; i++)
    {
      p = pr[i];
      __dbl_mp (x, &mpx, p);
      __dbl_mp (y, &mpy, p);
      __mpatan2 (&mpy, &mpx, &mpz, p);
      __dbl_mp (ud[i].d, &mpt1, p);
      __mul (&mpz, &mpt1, &mperr, p);
      __add (&mpz, &mperr, &mpz1, p);
      __sub (&mpz, &mperr, &mpz2, p);
      __mp_dbl (&mpz1, &z1, p);
      __mp_dbl (&mpz2, &z2, p);
      if (z1 == z2)
	{
	  LIBC_PROBE (slowatan2, 4, &p, &x, &y, &z1);
	  return z1;
	}
    }
  LIBC_PROBE (slowatan2_inexact, 4, &p, &x, &y, &z1);
  return z1;			/*if impossible to do exact computing */
}
Ejemplo n.º 6
0
/*Converting from double precision to Multi-precision and calculating  e^x */
double
SECTION
__slowexp (double x)
{
#ifndef USE_LONG_DOUBLE_FOR_MP
  double w, z, res, eps = 3.0e-26;
  int p;
  mp_no mpx, mpy, mpz, mpw, mpeps, mpcor;

  /* Use the multiple precision __MPEXP function to compute the exponential
     First at 144 bits and if it is not accurate enough, at 768 bits.  */
  p = 6;
  __dbl_mp (x, &mpx, p);
  __mpexp (&mpx, &mpy, p);
  __dbl_mp (eps, &mpeps, p);
  __mul (&mpeps, &mpy, &mpcor, p);
  __add (&mpy, &mpcor, &mpw, p);
  __sub (&mpy, &mpcor, &mpz, p);
  __mp_dbl (&mpw, &w, p);
  __mp_dbl (&mpz, &z, p);
  if (w == z)
    return w;
  else
    {
      p = 32;
      __dbl_mp (x, &mpx, p);
      __mpexp (&mpx, &mpy, p);
      __mp_dbl (&mpy, &res, p);
      return res;
    }
#else
  return (double) __ieee754_expl((long double)x);
#endif
}
Ejemplo n.º 7
0
/* Receive double x and two double results of cos(x) and return result which is
   more accurate, computing cos(x) with multi precision routine c32.  */
double
SECTION
__cos32 (double x, double res, double res1)
{
  int p;
  mp_no a, b, c;
  p = 32;
  __dbl_mp (res, &a, p);
  __dbl_mp (0.5 * (res1 - res), &b, p);
  __add (&a, &b, &c, p);
  if (x > 2.4)
    {
      __sub (&pi, &c, &a, p);
      __c32 (&a, &b, &c, p);
      b.d[0] = -b.d[0];
    }
  else if (x > 0.8)
    {
      __sub (&hp, &c, &a, p);
      __c32 (&a, &c, &b, p);
    }
  else
    __c32 (&c, &b, &a, p);	/* b=cos(0.5*(res+res1))  */
  __dbl_mp (x, &c, p);		/* c = x                  */
  __sub (&b, &c, &a, p);
  /* if a > 0 return max (res, res1), otherwise return min (res, res1).  */
  if ((a.d[0] > 0 && res <= res1) || (a.d[0] <= 0 && res >= res1))
    res = res1;
  LIBC_PROBE (slowacos, 2, &res, &x);
  return res;
}
Ejemplo n.º 8
0
/*Converting from double precision to Multi-precision and calculating  e^x */
double
SECTION
__slowexp(double x) {
  double w,z,res,eps=3.0e-26;
#if 0
  double y;
#endif
  int p;
#if 0
  int orig,i;
#endif
  mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;

  p=6;
  __dbl_mp(x,&mpx,p); /* Convert a double precision number  x               */
		    /* into a multiple precision number mpx with prec. p. */
  __mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
  __dbl_mp(eps,&mpeps,p);
  __mul(&mpeps,&mpy,&mpcor,p);
  __add(&mpy,&mpcor,&mpw,p);
  __sub(&mpy,&mpcor,&mpz,p);
  __mp_dbl(&mpw, &w, p);
  __mp_dbl(&mpz, &z, p);
  if (w == z) return w;
  else  {                   /* if calculating is not exactly   */
    p = 32;
    __dbl_mp(x,&mpx,p);
    __mpexp(&mpx, &mpy, p);
    __mp_dbl(&mpy, &res, p);
    return res;
  }
}
Ejemplo n.º 9
0
 /* Final stages. Compute atan(x) by multiple precision arithmetic */
static double
atanMp (double x, const int pr[])
{
  mp_no mpx, mpy, mpy2, mperr, mpt1, mpy1;
  double y1, y2;
  int i, p;

  for (i = 0; i < M; i++)
    {
      p = pr[i];
      __dbl_mp (x, &mpx, p);
      __mpatan (&mpx, &mpy, p);
      __dbl_mp (u9[i].d, &mpt1, p);
      __mul (&mpy, &mpt1, &mperr, p);
      __add (&mpy, &mperr, &mpy1, p);
      __sub (&mpy, &mperr, &mpy2, p);
      __mp_dbl (&mpy1, &y1, p);
      __mp_dbl (&mpy2, &y2, p);
      if (y1 == y2)
	{
	  LIBC_PROBE (slowatan, 3, &p, &x, &y1);
	  return y1;
	}
    }
  LIBC_PROBE (slowatan_inexact, 3, &p, &x, &y1);
  return y1;			/*if impossible to do exact computing */
}
Ejemplo n.º 10
0
void __mplog(mp_no *x, mp_no *y, int p) {
#include "mplog.h"
  int i,m;
#if 0
  int j,k,m1,m2,n;
  double a,b;
#endif
  static const int mp[33] = {0,0,0,0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
                             4,4,4,4,4,4,4,4,4,4,4,4,4,4};
  mp_no mpone = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
                    0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};
  mp_no mpt1,mpt2;

  /* Choose m and initiate mpone */
  m = mp[p];  mpone.e = 1;  mpone.d[0]=mpone.d[1]=ONE;

  /* Perform m newton iterations to solve for y: exp(y)-x=0.     */
  /* The iterations formula is:  y(n+1)=y(n)+(x*exp(-y(n))-1).   */
  __cpy(y,&mpt1,p);
  for (i=0; i<m; i++) {
    mpt1.d[0]=-mpt1.d[0];
    __mpexp(&mpt1,&mpt2,p);
    __mul(x,&mpt2,&mpt1,p);
    __sub(&mpt1,&mpone,&mpt2,p);
    __add(y,&mpt2,&mpt1,p);
    __cpy(&mpt1,y,p);
  }
  return;
}
Ejemplo n.º 11
0
/*Converting from double precision to Multi-precision and calculating  e^x */
double __slowexp(double x) {
#ifdef NO_LONG_DOUBLE
  double w,z,res,eps=3.0e-26;
  int p;
  mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;

  p=6;
  __dbl_mp(x,&mpx,p); /* Convert a double precision number  x               */
                    /* into a multiple precision number mpx with prec. p. */
  __mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
  __dbl_mp(eps,&mpeps,p);
  __mul(&mpeps,&mpy,&mpcor,p);
  __add(&mpy,&mpcor,&mpw,p);
  __sub(&mpy,&mpcor,&mpz,p);
  __mp_dbl(&mpw, &w, p);
  __mp_dbl(&mpz, &z, p);
  if (w == z) return w;
  else  {                   /* if calculating is not exactly   */
    p = 32;
    __dbl_mp(x,&mpx,p);
    __mpexp(&mpx, &mpy, p);
    __mp_dbl(&mpy, &res, p);
    return res;
  }
#else
  return (double) __ieee754_expl((long double)x);
#endif
}
Ejemplo n.º 12
0
static void add(int idx, comparable_t item, array_t list)
{
        __list(list);
        __list_obj(item);
        __list_add(list);
        __list_idx(idx, list);
	__add(idx, item, list);
}
Ejemplo n.º 13
0
int output::add(char* target, map_pidtype &pids)
{
	char *save;
	int ret = -1;
	char *item = strtok_r(target, CHAR_CMD_COMMA, &save);
	if (item) while (item) {

		ret = __add(item, pids);
		if (ret < 0)
			return ret;

		item = strtok_r(NULL, CHAR_CMD_COMMA, &save);
	} else
		ret = __add(target, pids);

	return ret;
}
Ejemplo n.º 14
0
void ReverseDependsIndex< VersionT >::add(RelationTypeT relationType)
{
	auto insertResult = __data.insert({ relationType, {} });
	if (insertResult.second)
	{
		__add(relationType, &insertResult.first->second);
	}
}
Ejemplo n.º 15
0
void __c32(mp_no *x, mp_no *y, mp_no *z, int p) {
  static const mp_no mpt={1,{1.0,2.0}}, one={1,{1.0,1.0}};
  mp_no u,t,t1,t2,c,s;
  int i;
  __cpy(x,&u,p);
  u.e=u.e-1;
  cc32(&u,&c,p);
  ss32(&u,&s,p);
  for (i=0;i<24;i++) {
    __mul(&c,&s,&t,p);
    __sub(&s,&t,&t1,p);
    __add(&t1,&t1,&s,p);
    __sub(&mpt,&c,&t1,p);
    __mul(&t1,&c,&t2,p);
    __add(&t2,&t2,&c,p);
  }
  __sub(&one,&c,y,p);
  __cpy(&s,z,p);
}
Ejemplo n.º 16
0
	void file_list_from_metadb_handle_list::init_from_list(const list_base_const_t<metadb_handle_ptr> & p_list)
	{
		m_data.free_all();

		t_size n, m = p_list.get_count();
		for(n=0;n<m;n++) {
			__add( p_list.get_item(n)->get_path() );
		}
		file_list_remove_duplicates(m_data);
	}
Ejemplo n.º 17
0
Archivo: list.c Proyecto: sktwj/var
static inline struct node *add_tail(struct list *list, void *src, size_t size)
{
	struct node *pnode = (struct node *)malloc(sizeof(struct node) + size);
	assert(pnode);
	memcpy(pnode->par, src, size);

	__add(pnode, list->head.prev, &list->head);

	return pnode;
}
Ejemplo n.º 18
0
/* Compute cos() of double-length number (X + DX) as Multi Precision number and
   return result as double.  If REDUCE_RANGE is true, X is assumed to be the
   original input and DX is ignored.  */
double
SECTION
__mpcos (double x, double dx, bool reduce_range)
{
  double y;
  mp_no a, b, c, s;
  int n;
  int p = 32;

  if (reduce_range)
    {
      n = __mpranred (x, &a, p);	/* n is 0, 1, 2 or 3.  */
      __c32 (&a, &c, &s, p);
    }
  else
    {
      n = -1;
      __dbl_mp (x, &b, p);
      __dbl_mp (dx, &c, p);
      __add (&b, &c, &a, p);
      if (x > 0.8)
        {
          __sub (&hp, &a, &b, p);
          __c32 (&b, &s, &c, p);
        }
      else
        __c32 (&a, &c, &s, p);	/* a = cos(x+dx)     */
    }

  /* Convert result based on which quarter of unit circle y is in.  */
  switch (n)
    {
    case 1:
      __mp_dbl (&s, &y, p);
      y = -y;
      break;

    case 3:
      __mp_dbl (&s, &y, p);
      break;

    case 2:
      __mp_dbl (&c, &y, p);
      y = -y;
      break;

    /* Quadrant not set, so the result must be cos (X + DX), which is also
       stored in C.  */
    case 0:
    default:
      __mp_dbl (&c, &y, p);
    }
  LIBC_PROBE (slowcos, 3, &x, &dx, &y);
  return y;
}
Ejemplo n.º 19
0
void
SECTION
__c32(mp_no *x, mp_no *y, mp_no *z, int p) {
  mp_no u,t,t1,t2,c,s;
  int i;
  __cpy(x,&u,p);
  u.e=u.e-1;
  cc32(&u,&c,p);
  ss32(&u,&s,p);
  for (i=0;i<24;i++) {
    __mul(&c,&s,&t,p);
    __sub(&s,&t,&t1,p);
    __add(&t1,&t1,&s,p);
    __sub(&mptwo,&c,&t1,p);
    __mul(&t1,&c,&t2,p);
    __add(&t2,&t2,&c,p);
  }
  __sub(&mpone,&c,y,p);
  __cpy(&s,z,p);
}
Ejemplo n.º 20
0
double __mpsin(double x, double dx) {
  int p;
  double y;
  mp_no a,b,c;
  p=32;
  __dbl_mp(x,&a,p);
  __dbl_mp(dx,&b,p);
  __add(&a,&b,&c,p);
  if (x>0.8) { __sub(&hp,&c,&a,p); __c32(&a,&b,&c,p); }
  else __c32(&c,&a,&b,p);     /* b = sin(x+dx)     */
  __mp_dbl(&b,&y,p);
  return y;
}
Ejemplo n.º 21
0
int cache_add(struct cache *c, struct cache_object *obj, int id)
{
	int ret;

	ret = __add(c, obj, id);
	if (ret == -1) {
		c->stats.add_fail++;
		if (errno == ENOSPC)
			c->stats.add_fail_enospc++;
		return -1;
	}
	c->stats.add_ok++;
	return 0;
}
Ejemplo n.º 22
0
int cache_add(struct cache *c, struct cache_object *obj, int id)
{
	int ret;

	obj->owner = STATE_SYNC(channel)->current;
	ret = __add(c, obj, id);
	if (ret == -1) {
		c->stats.add_fail++;
		if (errno == ENOSPC)
			c->stats.add_fail_enospc++;
		return -1;
	}
	c->stats.add_ok++;
	return 0;
}
Ejemplo n.º 23
0
	void file_list_from_metadb_handle_list::init_from_list_display(const list_base_const_t<metadb_handle_ptr> & p_list)
	{
		m_data.free_all();
		
		pfc::string8_fastalloc temp;

		t_size n, m = p_list.get_count();
		for(n=0;n<m;n++)
		{
			filesystem::g_get_display_path(p_list.get_item(n)->get_path(),temp);
			__add(temp);
		}
		file_list_remove_duplicates(m_data);


	}
Ejemplo n.º 24
0
template <class U> typename __sumtype1<typename U::for_in_unit>::type __sum(U *iter) {
    typename __sumtype1<typename U::for_in_unit>::type result;
    result = __zero<typename __sumtype1<typename U::for_in_unit>::type>();
    typename U::for_in_unit e;
    typename U::for_in_loop __3;
    int __2;
    U *__1;
    bool first = true;
    FOR_IN(e,iter,1,2,3)
        if(first) {
            result = (typename __sumtype1<typename U::for_in_unit>::type)e;
            first = false;
        }
        else
            result = __add(result, (typename __sumtype1<typename U::for_in_unit>::type)e);
    END_FOR
    return result;
}
Ejemplo n.º 25
0
/*Converting from double precision to Multi-precision and calculating  e^x */
double
SECTION
__slowexp (double x)
{
#ifndef USE_LONG_DOUBLE_FOR_MP
  double w, z, res, eps = 3.0e-26;
  int p;
  mp_no mpx, mpy, mpz, mpw, mpeps, mpcor;

  /* Use the multiple precision __MPEXP function to compute the exponential
     First at 144 bits and if it is not accurate enough, at 768 bits.  */
  p = 6;
  __dbl_mp (x, &mpx, p);
  __mpexp (&mpx, &mpy, p);
  __dbl_mp (eps, &mpeps, p);
  __mul (&mpeps, &mpy, &mpcor, p);
  __add (&mpy, &mpcor, &mpw, p);
  __sub (&mpy, &mpcor, &mpz, p);
  __mp_dbl (&mpw, &w, p);
  __mp_dbl (&mpz, &z, p);
  if (w == z)
    {
      /* Track how often we get to the slow exp code plus
	 its input/output values.  */
      LIBC_PROBE (slowexp_p6, 2, &x, &w);
      return w;
    }
  else
    {
      p = 32;
      __dbl_mp (x, &mpx, p);
      __mpexp (&mpx, &mpy, p);
      __mp_dbl (&mpy, &res, p);

      /* Track how often we get to the uber-slow exp code plus
	 its input/output values.  */
      LIBC_PROBE (slowexp_p32, 2, &x, &res);
      return res;
    }
#else
  return (double) __ieee754_expl((long double)x);
#endif
}
Ejemplo n.º 26
0
/*Converting from double precision to Multi-precision and calculating  e^x */
double __slowexp(double x) {
  double w,z,res,eps=3.0e-26;
#if 0
  double y;
#endif
  int p;
#if 0
  int orig,i;
#endif
  mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;

  p=6;
  __dbl_mp(x,&mpx,p); /* Convert a double precision number  x               */
                    /* into a multiple precision number mpx with prec. p. */
  __mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
  __dbl_mp(eps,&mpeps,p);
  __mul(&mpeps,&mpy,&mpcor,p);
  __add(&mpy,&mpcor,&mpw,p);
  __sub(&mpy,&mpcor,&mpz,p);
  __mp_dbl(&mpw, &w, p);
  __mp_dbl(&mpz, &z, p);
  if (w == z) {
    /* Track how often we get to the slow exp code plus
       its input/output values.  */
    LIBC_PROBE (slowexp_p6, 2, &x, &w);
    return w;
  }
  else  {                   /* if calculating is not exactly   */
    p = 32;
    __dbl_mp(x,&mpx,p);
    __mpexp(&mpx, &mpy, p);
    __mp_dbl(&mpy, &res, p);
 
    /* Track how often we get to the uber-slow exp code plus
       its input/output values.  */
    LIBC_PROBE (slowexp_p32, 2, &x, &res);
    return res;
  }
}
Ejemplo n.º 27
0
Archivo: list.c Proyecto: sktwj/var
static inline void add_tail(struct list *list, struct node *node)
{
	__add(node, list->head->prev, list->head);
}
Ejemplo n.º 28
0
Archivo: mpatan.c Proyecto: dreal/tai
void
SECTION
__mpatan(mp_no *x, mp_no *y, int p) {

  int i,m,n;
  double dx;
  mp_no
    mpone    = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}},
    mptwo    = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}},
    mptwoim1 = {0,{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,
		0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}};

  mp_no mps,mpsm,mpt,mpt1,mpt2,mpt3;

		      /* Choose m and initiate mpone, mptwo & mptwoim1 */
    if      (EX>0) m=7;
    else if (EX<0) m=0;
    else {
      __mp_dbl(x,&dx,p);  dx=ABS(dx);
      for (m=6; m>0; m--)
	{if (dx>__atan_xm[m].d) break;}
    }
    mpone.e    = mptwo.e    = mptwoim1.e = 1;
    mpone.d[0] = mpone.d[1] = mptwo.d[0] = mptwoim1.d[0] = ONE;
    mptwo.d[1] = TWO;

				 /* Reduce x m times */
    __mul(x,x,&mpsm,p);
    if (m==0) __cpy(x,&mps,p);
    else {
      for (i=0; i<m; i++) {
	__add(&mpone,&mpsm,&mpt1,p);
	__mpsqrt(&mpt1,&mpt2,p);
	__add(&mpt2,&mpt2,&mpt1,p);
	__add(&mptwo,&mpsm,&mpt2,p);
	__add(&mpt1,&mpt2,&mpt3,p);
	__dvd(&mpsm,&mpt3,&mpt1,p);
	__cpy(&mpt1,&mpsm,p);
      }
      __mpsqrt(&mpsm,&mps,p);    mps.d[0] = X[0];
    }

		    /* Evaluate a truncated power series for Atan(s) */
    n=__atan_np[p];    mptwoim1.d[1] = __atan_twonm1[p].d;
    __dvd(&mpsm,&mptwoim1,&mpt,p);
    for (i=n-1; i>1; i--) {
      mptwoim1.d[1] -= TWO;
      __dvd(&mpsm,&mptwoim1,&mpt1,p);
      __mul(&mpsm,&mpt,&mpt2,p);
      __sub(&mpt1,&mpt2,&mpt,p);
    }
    __mul(&mps,&mpt,&mpt1,p);
    __sub(&mps,&mpt1,&mpt,p);

			  /* Compute Atan(x) */
    mptwoim1.d[1] = __atan_twom[m].d;
    __mul(&mptwoim1,&mpt,y,p);

  return;
}
Ejemplo n.º 29
0
Archivo: list.c Proyecto: sktwj/var
static inline void add(struct list *list, struct node *node)
{
	__add(node, list->head, list->head->next);
}
Ejemplo n.º 30
0
 void add(int a, int b, int v) {
     __add(a, v);
     __add(b, (MOD - v) % MOD);
 }