Beispiel #1
0
double coshl( double x )				{
    return (double)cosh((double) x);
}
inline double _d0_sinh(double arg)         { return (cosh(arg)); }
Beispiel #3
0
 inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
 {
     double L, LC, sinC;
     L= atan(sinh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2)/cos((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2));
     sinC= sin((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2)/cosh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2);
     LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
     lp_lon= L/this->m_proj_parm.n1;
     lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1),this->m_par.e);
     /*fprintf(stderr,"inv:\nL      =%16.13f\nsinC   =%16.13f\nLC     =%16.13f\nXY(%16.4f,%16.4f)=LP(%16.13f,%16.13f)\n",L,sinC,LC,((xy_x/this->m_par.ra)+this->m_par.x0)/this->m_par.to_meter,((xy_y/this->m_par.ra)+this->m_par.y0)/this->m_par.to_meter,lp_lon+this->m_par.lam0,lp_lat);*/
 }
Beispiel #4
0
/*!
  \return Une reference sur une Constante contenant notre nouveau Rationnel.
  \sa Reel
  \sa <a href = "http://www.cplusplus.com/reference/clibrary/cmath/coh/">cosh</a>
*/
Constante& Rationnel::cosinush()const
{
    Reel* res = new Reel(cosh((float)num/den));
    return *res;
}
double g_psr_disk (double *k, size_t dim, void *params)
{   
    double rdd,zdd,r0,p0,beta,ita,h1,h2,H;
    double rd,zd;
    double xs,ys,xl,yl;
    double p_disk,p_pulsar;
    double A,a,B,E;
    double r1;
    double b,l;
    double Deff;
    double F;
    //double v,vl,vb,vrot,vrot_disk,sigma_y,sigma_z,mean_vl,mean_vb,sigma_vl,sigma_vb,vlfunc,vbfunc;
    double M;
    double alpha;
    double v,vl,vb,vol,vob,vdl,vdb,vsl,vsb,vdx,vdy,vdz,vsx,vsy,vsz,sigma_vdx,sigma_vdy,sigma_vdz,sigma_vsx,sigma_vsy,sigma_vsz,vdxfunc,vdyfunc,vdzfunc,vsxfunc,vsyfunc,vszfunc,vrot,vrot_disk;
    double d,R;
    double re,delta_func;

    r0=8.0; // kpc

    //l=k[8];
    //b=k[9];
    //b=-2.75*3.1415926/180.0;
    //l=1.16*3.1415926/180.0;
    b=0.000001;
    l=0.000001;
    //b=5.0*3.1415926/180.0;
    //l=5.0*3.1415926/180.0;

    if ( k[0] <= k[1] )
    {
        F=0.0;
    }
    else
    {
    d=k[1]*sin(b);
    R=sqrt(r0*r0+d*d-2.0*r0*d*cos(l));
    if ((d*d+R*R-r0*r0)/(2.0*d*R)>1.0)         alpha=acos(1);
    else if ((d*d+R*R-r0*r0)/(2.0*d*R)<-1.0)    alpha=acos(-1);
    else alpha=acos((d*d+R*R-r0*r0)/(2.0*d*R));
    if(sin(l)<0) alpha=-1*alpha;
    //alpha=acos( (d*d+R*R-r0*r0)/(2.0*d*R)>0.0 ? (d*d+R*R-r0*r0)/(2.0*d*R)-1e-8 : (d*d+R*R-r0*r0)/(2.0*d*R)+1e-8);
    //alpha=asin(r0*sin(l)/R);
    //alpha=2.0*3.1415926-asin(r0*sin(l)/R);

    M=1.4;

    // source distribution: disk
    rdd=sqrt(k[0]*k[0]*cos(b)*cos(b)-2.0*k[0]*r0*cos(b)*cos(l)+r0*r0);
    zdd=k[0]*sin(b);
    xs=-k[0]*cos(b)*cos(l)+r0;
    ys=k[0]*cos(b)*sin(l);

    //p0=0.0493*pow(10,9); // M*kpc^(-3)
    p0=1.388789*0.0493*pow(10.0,9.0); // kpc^(-3)
    //p0=1.3888*0.0493*pow(10.0,9.0); // kpc^(-3)
    //p0=0.0493*pow(10.0,9.0)/3.1; // kpc^(-3)
    beta=0.565;
    h1=0.270; // kpc
    h2=0.440; // kpc
    H=2.75; // kpc

    if (((rdd/9.025)+0.114)<=0.670)
    {
        ita=0.670;
    }
    else
    {
        ita=(rdd/9.025)+0.114;
    }

    //p_disk=(p0/ita)*exp(-(rdd-r0)/H)*((1.0-beta)*pow(cosh(zdd/(ita*h1)),-2.0)+beta*exp(-fabs(zdd)/(ita*h2)));  // :disk
    if (k[0]<5.0)
    {
        p_disk=(p0/ita)*exp(-(rdd-r0)/H)*((1.0-beta)*pow(cosh(zdd/(ita*h1)),-2.0)+beta*exp(-fabs(zdd)/(ita*h2)));  // :disk
    }
    else
    {
        p_disk=(1.0/pow(k[0],4.0))*(p0/ita)*exp(-(rdd-r0)/H)*((1.0-beta)*pow(cosh(zdd/(ita*h1)),-2.0)+beta*exp(-fabs(zdd)/(ita*h2)));  // :disk
    }

    // lens distribution: psr

    //A=41.0*1.6*pow(10.0,6.0); // kpc^(-2)
    //A=41.0*8.61*pow(10.0,6.0); // kpc^(-2)  by Lorimer 2006
    //A=2000.0*4.5*pow(10.0,5.0); // kpc^(-2)    by Kaspi 2006
    A=2000.0*10000/1.18; // kpc^(-2)    by Kaspi 2006
    //A=1.37*2000.0; // kpc^(-2)    by Kaspi 2006
    //A=2000.0*10000/5.15; // kpc^(-2)    by Kaspi 2006
    r1=0.55;  // kpc
    a=1.64;
    //B=9.01;
    B=4.01;
    E=0.05; // kpc

    rd=sqrt(k[1]*k[1]*cos(b)*cos(b)-2.0*k[1]*r0*cos(b)*cos(l)+r0*r0);
    zd=k[1]*sin(b);
    xl=-k[1]*cos(b)*cos(l)+r0;
    yl=k[1]*cos(b)*sin(l);

    p_pulsar=A*pow((rd+r1)/(r0+r1),a)*exp(-B*((rd-r0)/(r0+r1)))*exp(-fabs(zd)/E);  // pulsar density

    Deff=sqrt(k[1]*fabs(k[0]-k[1])/k[0]);

    // disk rotational velocity function
    vrot=220.0;

    // disk rotational velocity function
    //if ((xl*xl+yl*yl)<4.0)
    //{
    //    vrot_disk=220.0*xl; // 100km/s,x/kpc
    //}
    //else
    //{
          vrot_disk=220.0;
    //}

    // observor velocity
    vol=-220.0*cos(l);
    vob=220.0*sin(l)*sin(b);

    // deflector: disk velocity
    // vdx,vdy,vdz,sigma_dx=20.0,sigma_dy=30.0,sigma_dz=20
    vdx=k[2];
    vdy=k[3];
    vdz=k[4];
    vdl=vrot_disk*cos(alpha)+vdx*sin(l)-vdy*cos(l);
    vdb=-vrot_disk*sin(alpha)*sin(b)+vdx*cos(l)*sin(b)+vdy*sin(l)*sin(b)+vdz*cos(b);
    sigma_vdx=290.0;
    sigma_vdy=290.0;
    sigma_vdz=290.0;

    // source: disk velocity
    // vsx,vsy,vsz,sigma_sx=110.0,sigma_sy=82.5,sigma_sz=66.3
    vsx=k[5];
    vsy=k[6];
    vsz=k[7];
    vsl=vrot*cos(alpha)+vsx*sin(l)-vsy*cos(l);
    vsb=-vrot*sin(alpha)*sin(b)+vsx*cos(l)*sin(b)+vsy*sin(l)*sin(b)+vsz*cos(b);
    sigma_vsx=20.0;
    sigma_vsy=30.0;
    sigma_vsz=20.0;

    vl=vdl-vol+(vol-vsl)*(k[1]/k[0]);
    vb=vdb-vob+(vob-vsb)*(k[1]/k[0]);
    v=sqrt(vl*vl+vb*vb);

    //sigma_y=290.0;
    //sigma_z=290.0;
    //sigma_y=-5.625*pow(xl*xl+yl*yl,0.5)+75.0;
    //sigma_z=-3.75*pow(xl*xl+yl*yl,0.5)+50.0;
    // lens-source relative transverse velocity
    //vlb=(k[5]*cos(l)-k[4]*sin(l))/cos(b);
    //vlb=k[5]*cos(l)-k[4]*sin(l);
    //vbb=k[6]*cos(b)-tan(b)*(k[4]*cos(b)*cos(l)+k[5]*cos(b)*sin(l));
    //vlb=-k[4];
    ///////////////////////////////////////////////////////////////////
    //vld=k[3];
    //vbd=k[6];
    //vlb=k[4];
    //vbb=k[5];
    //vl=(vld+vrot_disk-220.0)+(220.0-vrot-vlb)*(k[1]/k[0]);
    //vl=k[3]+(220.0-vrot-vlb)*(k[1]/k[0]);
    //vb=vbd-vbb*(k[1]/k[0]);
    //v=pow(vl*vl+vb*vb,0.5);
    ////////////////////////////////////////////////////////////////////
    //vl=k[2];
    //vb=k[3];
    //mean_vl=(vrot_disk-220.0)+(220.0-vrot)*(k[1]/k[0]);
    //mean_vl=(220.0-vrot)*(k[1]/k[0]);
    //mean_vb=0.0;
    //sigma_vl=pow(sigma_y*sigma_y+82.5*82.5*k[1]*k[1]/(k[0]*k[0]),0.5);
    //sigma_vb=pow(sigma_z*sigma_z+66.3*66.3*k[1]*k[1]/(k[0]*k[0]),0.5);
    //v=pow(vl*vl+vb*vb,0.5);

    //if ((184.2*365.0*365.0*Deff*Deff*M/(t*t)-vl*vl)<=0)
    //{
    //    ifunc_vbd=0.0;
    //}
    //else
    //{
    //    ifunc_vbd=1.0;
    //}

    // vbd as a function of vlb,vx,vy,vz,M
    //vbd=pow(fabs(184.2*365.0*365.0*Deff*Deff*M/(t*t)-vl*vl),0.5)+vbb*(k[1]/k[0]);
    /////////////////////////////////////////////////////////////////////////////////////
    // vb as a function of vl
    //vb=pow(fabs(184.2*365.0*365.0*Deff*Deff*M/(t*t)-vl*vl),0.5);

    // f(vld),f(vbd),f(vx),f(vy),f(vx)
    //vldfunc=(1.0/(pow(2.0*3.1415926,0.5)*30.0))*exp(-0.5*vld*vld/900.0);
    //vyfunc=(1.0/(pow(2.0*3.1415926,0.5)*82.5))*exp(-0.5*vlb*vlb/(82.5*82.5));
    //vzfunc=(1.0/(pow(2.0*3.1415926,0.5)*66.3))*exp(-0.5*vbb*vbb/(66.3*66.3));
    //vbdfunc=(1.0/(pow(2.0*3.1415926,0.5)*20.0))*exp(-0.5*vbd*vbd/400.0);
    //vbdfunc=(1.0/(pow(2.0*3.1415926,0.5)*20.0))*exp(-0.5*vbd*vbd/400.0);
    ////////////////////////////////////////////////////////////////////////////////////////
    //vlfunc=(1.0/(pow(2.0*3.1415926,0.5)*sigma_vl))*exp(-0.5*(vl-mean_vl)*(vl-mean_vl)/(sigma_vl*sigma_vl));
    //vbfunc=(1.0/(pow(2.0*3.1415926,0.5)*sigma_vb))*exp(-0.5*(vb-mean_vb)*(vb-mean_vb)/(sigma_vb*sigma_vb));


    vdxfunc=(1.0/(sqrt(2.0*3.1415926)*sigma_vdx))*exp(-0.5*(vdx*vdx)/(sigma_vdx*sigma_vdx));
    vdyfunc=(1.0/(sqrt(2.0*3.1415926)*sigma_vdy))*exp(-0.5*(vdy*vdy)/(sigma_vdy*sigma_vdy));
    vdzfunc=(1.0/(sqrt(2.0*3.1415926)*sigma_vdz))*exp(-0.5*(vdz*vdz)/(sigma_vdz*sigma_vdz));
    vsxfunc=(1.0/(sqrt(2.0*3.1415926)*sigma_vsx))*exp(-0.5*(vsx*vsx)/(sigma_vsx*sigma_vsx));
    vsyfunc=(1.0/(sqrt(2.0*3.1415926)*sigma_vsy))*exp(-0.5*(vsy*vsy)/(sigma_vsy*sigma_vsy));
    vszfunc=(1.0/(sqrt(2.0*3.1415926)*sigma_vsz))*exp(-0.5*(vsz*vsz)/(sigma_vsz*sigma_vsz));

    re=4.28*pow(10.0,8.0)*Deff*sqrt(M);   // km
    //ve=365.0*13.57*Deff*pow(M,0.5);

    //vfunc=pow(59.6*Deff*Deff*k[2]/(t*t)-k[3]*k[3],0.5)*exp(0.5*0.002377*k[3]*k[3]);
    // delta_func
    delta_func=(1.0/(sqrt(2.0*3.1415926)*0.01))*exp(-0.5*(log10((re/v)/(24.0*60.0*60.0))-t)*(log10((re/v)/(24.0*60.0*60.0))-t)/(0.01*0.01));

        F=2.77*pow(10.0,-8.0)*k[0]*k[0]*cos(b)*p_disk*p_pulsar*(Deff)*(sqrt(M))*(v*vdxfunc*vdyfunc*vdzfunc*vsxfunc*vsyfunc*vszfunc)*1.02*pow(10.0,-9.0)*delta_func;
        //F=2.77*pow(10.0,-8.0)*k[0]*k[0]*cos(b)*pnum*exp(-rds)*p_pulsar*(Deff)*(pow(M,0.5))*(v*vlfunc*vbfunc)*1.02*pow(10.0,-9.0);
        //F=2.77*pow(10.0,-8.0)*k[0]*k[0]*cos(b)*pnum*exp(-rds)*p_disk*(Deff)*(pow(M,0.5)*mfunc)*(v*vldfunc*vbdfunc*vyfunc*vzfunc)*1.02*pow(10.0,-9.0)*delta_func/4.3656;
        //F=2.3*2.77*pow(10.0,-8.0)*k[0]*k[0]*cos(b)*pnum*exp(-rds)*p_disk*(Deff)*(pow(M,-0.5)*mfunc)*(v*vldfunc*vbdfunc*vyfunc*vzfunc)*1.02*pow(10.0,-9.0)/(0.1*4.3656);
        //F=2.3*2.77*pow(10.0,-8.0)*k[0]*k[0]*cos(b)*pnum*exp(-rds)*p_disk*(Deff)*(pow(M,0.5)*mfunc)*(v*vldfunc*vbdfunc*vyfunc*vzfunc)*1.02*pow(10.0,-9.0)/(0.1*4.3656);
        //F=2.3*pow(fabs(ve*ve-vl*vl),-0.5)*ve*ve*3.8375*pow(10,-16)*k[0]*k[0]*cos(b)*pnum*exp(-0.5*rds*rds)*p_disk*(Deff*Deff*365.0/t)*(M*mfunc)*(vbfunc*vlfunc);
        //F=2.3*pow(fabs(ve*ve-vl*vl),-0.5)*ve*ve*3.8375*pow(10,-14)*k[0]*k[0]*cos(b)*pnum*exp(-0.5*rds*rds)*p_disk*(Deff*Deff*365.0/t)*(mfunc)*M*(vbfunc*vlfunc)*ifunc*ifunc_vb;
        //F=pow(fabs(ve*ve-vl*vl),-0.5)*ve*ve*3.8375*pow(10,-16)*k[0]*k[0]*cos(b)*pnum*exp(-0.5*rds*rds)*p_disk*(Deff*Deff*365.0/t)*(M*mfunc)*(vbdfunc*vldfunc*vyfunc*vzfunc);
    }

    return F;
}
Beispiel #6
0
void ExprCopy::visit(const ExprCosh& e)  { if (unary_copy(e,cosh )) clone.insert(e,&cosh (EXPR)); }
void optimise_call(ExprNode *node)
{
	DBL result = 0.0;
	bool have_result = true;;

	if(node->op != OP_CALL)
		return;
	if(node->child == NULL)
		return;
	if(node->child->op != OP_CONSTANT)
		return;

	switch(node->call.token)
	{
		case SIN_TOKEN:
			result = sin(node->child->number);
			break;
		case COS_TOKEN:
			result = cos(node->child->number);
			break;
		case TAN_TOKEN:
			result = tan(node->child->number);
			break;
		case ASIN_TOKEN:
			result = asin(node->child->number);
			break;
		case ACOS_TOKEN:
			result = acos(node->child->number);
			break;
		case ATAN_TOKEN:
			result = atan(node->child->number);
			break;
		case SINH_TOKEN:
			result = sinh(node->child->number);
			break;
		case COSH_TOKEN:
			result = cosh(node->child->number);
			break;
		case TANH_TOKEN:
			result = tanh(node->child->number);
			break;
		case ASINH_TOKEN:
			result = asinh(node->child->number);
			break;
		case ACOSH_TOKEN:
			result = acosh(node->child->number);
			break;
		case ATANH_TOKEN:
			result = atanh(node->child->number);
			break;
		case ABS_TOKEN:
			result = fabs(node->child->number);
			break;
		case RADIANS_TOKEN:
			result = node->child->number * M_PI / 180.0;
			break;
		case DEGREES_TOKEN:
			result = node->child->number * 180.0 / M_PI;
			break;
		case FLOOR_TOKEN:
			result = floor(node->child->number);
			break;
		case INT_TOKEN:
			result = (int)(node->child->number);
			break;
		case CEIL_TOKEN:
			result = ceil(node->child->number);
			break;
		case SQRT_TOKEN:
			result = sqrt(node->child->number);
			break;
		case EXP_TOKEN:
			result = exp(node->child->number);
			break;
		case LN_TOKEN:
			if(node->child->number > 0.0)
				result = log(node->child->number);
			else
				Error("Domain error in 'ln'.");
			break;
		case LOG_TOKEN:
			if(node->child->number > 0.0)
				result = log10(node->child->number);
			else
				Error("Domain error in 'log'.");
			break;
		case MIN_TOKEN:
			have_result = false;
			break;
		case MAX_TOKEN:
			have_result = false;
			break;
		case ATAN2_TOKEN:
			have_result = false;
			break;
		case POW_TOKEN:
			have_result = false;
			break;
		case MOD_TOKEN:
			have_result = false;
			break;
		case SELECT_TOKEN:
			have_result = false;
			break;
		case FUNCT_ID_TOKEN:
			have_result = false;
			break;
		case VECTFUNCT_ID_TOKEN:
			have_result = false;
			break;
		default:
			have_result = false;
			break;
	}

	if(have_result == true)
	{
		POV_FREE(node->call.name);
		node->number = result;
		node->op = OP_CONSTANT;
		POV_FREE(node->child);
		node->child = NULL;
	}
}
Beispiel #8
0
bool Function::nonLinear(double &x, double &y) {
  double phi = atan2(y, x);
  double r = sqrt(x * x + y * y);
  switch (_nonLinear) {
  case 0:
    break;
  case 1:
    x = sin(x);
    y = sin(y);
    break;
  case 2:
    x = x / pow(r, 2);
    y = y / pow(r, 2);
    break;
  case 3:
    x = r * cos(phi + r);
    y = r * sin(phi + r);
    break;
  case 4:
    x = r * cos(phi * 2);
    y = r * sin(phi * 2);
    break;
  case 5:
    x = phi / M_PI;
    y = r - 1;
    break;
  case 6:
    x = r * sin(phi + r);
    y = r * cos(phi - r);
    break;
  case 7:
    x = r * sin(phi * r);
    y = 0 - cos(phi * r);
    break;
  case 8:
    x = phi * sin(M_PI * r) / M_PI;
    y = phi * cos(M_PI * r) / M_PI;
    break;
  case 9:
    x = (cos(phi) + sin(r)) / r;
    y = (sin(phi) - cos(r)) / r;
    break;
  case 10: {
    x = sin(phi) / r;
    y = cos(phi) * r;
    break;
  }
  case 11: {
    x = sin(phi) * cos(r);
    y = cos(phi) * sin(r);
    break;
  }
  case 12: {
    x = r * pow(sin(phi + r), 3);
    y = r * pow(cos(phi - r), 3);
    break;
  }
  case 13: {
    double omega = randomTo(2) ? M_PI : 0;
    x = sqrt(r) * cos((phi / 2) + omega);
    y = sqrt(r) * sin((phi / 2) + omega);
    break;
  }
  case 14: {
    x = (2 * r / (r + 1)) * x;
    y = (2 * r / (r + 1)) * y;
    break;
  }
  case 15: {
    double nx = cos(M_PI * x) * cosh(y);
    double ny = (0 - sin(M_PI * x)) * sinh(y);
    x = nx;
    y = ny;
    break;
  }
  default:
    return false;
  }
  return true;
}
double ICACHE_FLASH_ATTR __ieee754_cosh(double x) {
    return cosh(x);
}
Beispiel #10
0
double
__mth_i_dcosh(double d)
{
  return cosh(d);
}
 //-----------------------------------------------------------------------
 void FunCmplxCosH::Eval(ptr_val_type &ret, const ptr_val_type *a_pArg, int)
 {
   cmplx_type v(a_pArg[0]->GetFloat(), a_pArg[0]->GetImag());
   *ret = cosh(v);
 }
void
domath  (void)
{
#ifndef NO_DOUBLE
  double f1;
  double f2;

  int i1;

  f1 = acos (0.0);
  fprintf( stdout, "acos           : %f\n", f1);

  f1 = acosh (0.0);
  fprintf( stdout, "acosh          : %f\n", f1);

  f1 = asin (1.0);
  fprintf( stdout, "asin           : %f\n", f1);

  f1 = asinh (1.0);
  fprintf( stdout, "asinh          : %f\n", f1);

  f1 = atan (M_PI_4);
  fprintf( stdout, "atan           : %f\n", f1);

  f1 = atan2 (2.3, 2.3);
  fprintf( stdout, "atan2          : %f\n", f1);

  f1 = atanh (1.0);
  fprintf( stdout, "atanh          : %f\n", f1);

  f1 = cbrt (27.0);
  fprintf( stdout, "cbrt           : %f\n", f1);

  f1 = ceil (3.5);
  fprintf( stdout, "ceil           : %f\n", f1);

  f1 = copysign (3.5, -2.5);
  fprintf( stdout, "copysign       : %f\n", f1);

  f1 = cos (M_PI_2);
  fprintf( stdout, "cos            : %f\n", f1);

  f1 = cosh (M_PI_2);
  fprintf( stdout, "cosh           : %f\n", f1);

  f1 = erf (42.0);
  fprintf( stdout, "erf            : %f\n", f1);

  f1 = erfc (42.0);
  fprintf( stdout, "erfc           : %f\n", f1);

  f1 = exp (0.42);
  fprintf( stdout, "exp            : %f\n", f1);

  f1 = exp2 (0.42);
  fprintf( stdout, "exp2           : %f\n", f1);

  f1 = expm1 (0.00042);
  fprintf( stdout, "expm1          : %f\n", f1);

  f1 = fabs (-1.123);
  fprintf( stdout, "fabs           : %f\n", f1);

  f1 = fdim (1.123, 2.123);
  fprintf( stdout, "fdim           : %f\n", f1);

  f1 = floor (0.5);
  fprintf( stdout, "floor          : %f\n", f1);
  f1 = floor (-0.5);
  fprintf( stdout, "floor          : %f\n", f1);

  f1 = fma (2.1, 2.2, 3.01);
  fprintf( stdout, "fma            : %f\n", f1);

  f1 = fmax (-0.42, 0.42);
  fprintf( stdout, "fmax           : %f\n", f1);

  f1 = fmin (-0.42, 0.42);
  fprintf( stdout, "fmin           : %f\n", f1);

  f1 = fmod (42.0, 3.0);
  fprintf( stdout, "fmod           : %f\n", f1);

  /* no type-specific variant */
  i1 = fpclassify(1.0);
  fprintf( stdout, "fpclassify     : %d\n", i1);

  f1 = frexp (42.0, &i1);
  fprintf( stdout, "frexp          : %f\n", f1);

  f1 = hypot (42.0, 42.0);
  fprintf( stdout, "hypot          : %f\n", f1);

  i1 = ilogb (42.0);
  fprintf( stdout, "ilogb          : %d\n", i1);

  /* no type-specific variant */
  i1 = isfinite(3.0);
  fprintf( stdout, "isfinite       : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreater(3.0, 3.1);
  fprintf( stdout, "isgreater      : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreaterequal(3.0, 3.1);
  fprintf( stdout, "isgreaterequal : %d\n", i1);

  /* no type-specific variant */
  i1 = isinf(3.0);
  fprintf( stdout, "isinf          : %d\n", i1);

  /* no type-specific variant */
  i1 = isless(3.0, 3.1);
  fprintf( stdout, "isless         : %d\n", i1);

  /* no type-specific variant */
  i1 = islessequal(3.0, 3.1);
  fprintf( stdout, "islessequal    : %d\n", i1);

  /* no type-specific variant */
  i1 = islessgreater(3.0, 3.1);
  fprintf( stdout, "islessgreater  : %d\n", i1);

  /* no type-specific variant */
  i1 = isnan(0.0);
  fprintf( stdout, "isnan          : %d\n", i1);

  /* no type-specific variant */
  i1 = isnormal(3.0);
  fprintf( stdout, "isnormal       : %d\n", i1);

  /* no type-specific variant */
  f1 = isunordered(1.0, 2.0);
  fprintf( stdout, "isunordered    : %d\n", i1);

  f1 = j0 (1.2);
  fprintf( stdout, "j0             : %f\n", f1);

  f1 = j1 (1.2);
  fprintf( stdout, "j1             : %f\n", f1);

  f1 = jn (2,1.2);
  fprintf( stdout, "jn             : %f\n", f1);

  f1 = ldexp (1.2,3);
  fprintf( stdout, "ldexp          : %f\n", f1);

  f1 = lgamma (42.0);
  fprintf( stdout, "lgamma         : %f\n", f1);

  f1 = llrint (-0.5);
  fprintf( stdout, "llrint         : %f\n", f1);
  f1 = llrint (0.5);
  fprintf( stdout, "llrint         : %f\n", f1);

  f1 = llround (-0.5);
  fprintf( stdout, "lround         : %f\n", f1);
  f1 = llround (0.5);
  fprintf( stdout, "lround         : %f\n", f1);

  f1 = log (42.0);
  fprintf( stdout, "log            : %f\n", f1);

  f1 = log10 (42.0);
  fprintf( stdout, "log10          : %f\n", f1);

  f1 = log1p (42.0);
  fprintf( stdout, "log1p          : %f\n", f1);

  f1 = log2 (42.0);
  fprintf( stdout, "log2           : %f\n", f1);

  f1 = logb (42.0);
  fprintf( stdout, "logb           : %f\n", f1);

  f1 = lrint (-0.5);
  fprintf( stdout, "lrint          : %f\n", f1);
  f1 = lrint (0.5);
  fprintf( stdout, "lrint          : %f\n", f1);

  f1 = lround (-0.5);
  fprintf( stdout, "lround         : %f\n", f1);
  f1 = lround (0.5);
  fprintf( stdout, "lround         : %f\n", f1);

  f1 = modf (42.0,&f2);
  fprintf( stdout, "lmodf          : %f\n", f1);

  f1 = nan ("");
  fprintf( stdout, "nan            : %f\n", f1);

  f1 = nearbyint (1.5);
  fprintf( stdout, "nearbyint      : %f\n", f1);

  f1 = nextafter (1.5,2.0);
  fprintf( stdout, "nextafter      : %f\n", f1);

  f1 = pow (3.01, 2.0);
  fprintf( stdout, "pow            : %f\n", f1);

  f1 = remainder (3.01,2.0);
  fprintf( stdout, "remainder      : %f\n", f1);

  f1 = remquo (29.0,3.0,&i1);
  fprintf( stdout, "remquo         : %f\n", f1);

  f1 = rint (0.5);
  fprintf( stdout, "rint           : %f\n", f1);
  f1 = rint (-0.5);
  fprintf( stdout, "rint           : %f\n", f1);

  f1 = round (0.5);
  fprintf( stdout, "round          : %f\n", f1);
  f1 = round (-0.5);
  fprintf( stdout, "round          : %f\n", f1);

  f1 = scalbln (1.2,3);
  fprintf( stdout, "scalbln        : %f\n", f1);

  f1 = scalbn (1.2,3);
  fprintf( stdout, "scalbn         : %f\n", f1);

  /* no type-specific variant */
  i1 = signbit(1.0);
  fprintf( stdout, "signbit        : %i\n", i1);

  f1 = sin (M_PI_4);
  fprintf( stdout, "sin            : %f\n", f1);

  f1 = sinh (M_PI_4);
  fprintf( stdout, "sinh           : %f\n", f1);

  f1 = sqrt (9.0);
  fprintf( stdout, "sqrt           : %f\n", f1);

  f1 = tan (M_PI_4);
  fprintf( stdout, "tan            : %f\n", f1);

  f1 = tanh (M_PI_4);
  fprintf( stdout, "tanh           : %f\n", f1);

  f1 = tgamma (2.1);
  fprintf( stdout, "tgamma         : %f\n", f1);

  f1 = trunc (3.5);
  fprintf( stdout, "trunc          : %f\n", f1);

  f1 = y0 (1.2);
  fprintf( stdout, "y0             : %f\n", f1);

  f1 = y1 (1.2);
  fprintf( stdout, "y1             : %f\n", f1);

  f1 = yn (3,1.2);
  fprintf( stdout, "yn             : %f\n", f1);
#endif
}
Beispiel #13
0
void LibCosh(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
{
    ReturnValue->Val->FP = cosh(Param[0]->Val->FP);
}
Beispiel #14
0
double r_cosh(real *x)
#endif
{
return( cosh(*x) );
}
Beispiel #15
0
Datei: stubs.c Projekt: aosm/gcc3
float
coshf(float x)
{
  return (float) cosh(x);
}
Beispiel #16
0
 void c_dd_cosh(const double *a, double *b) {
     dd_real bb;
     bb = cosh(dd_real(a));
     TO_DOUBLE_PTR(bb, b);
 }
Beispiel #17
0
Datei: stubs.c Projekt: aosm/gcc3
long double
coshl(long double x)
{
  return cosh((double) x);
}
Beispiel #18
0
void bessel_ik( double xnu, double x, double *ri, double *rk, double *rip, double *rkp ) {

    const double EPS = 1.0e-16;
    const double FPMIN = 1.0e-30;
    const int MAXIT = 10000;
    const double XMIN = 2.0;

    int i, l, nl;
    double a, a1, b, c, d, del, del1, delh, dels, e, f, fact, fact2, ff,
           gam1, gam2, gammi, gampl, h, p, pimu, q, q1, q2, qnew, ril, ril1, rimu,
           rip1, ripl, ritemp, rk1, rkmu, rkmup, rktemp, s, sum, sum1, x2, xi, xi2, xmu, xmu2;

    if ( x <= 0.0 || xnu < 0.0 ) nrerror( "Bad arguments in bessel_ik." );

    nl = (int)(xnu + 0.5);

    xmu = xnu - nl;
    xmu2 = xmu*xmu;
    xi = 1.0/x;
    xi2 = 2.0*xi;
    h = xnu*xi;
    if ( h < FPMIN ) h = FPMIN;
    b = xi2*xnu;
    d = 0.0;
    c = h;
    for ( i = 1; i <= MAXIT; ++i ) {
        b += xi2;
        d = 1.0/(b + d);
        c = b + 1.0/c;
        del = c*d;
        h = del*h;
        if ( fabs(del-1.0) < EPS ) break;
    }
    if ( i > MAXIT ) nrerror( "Argument x too large in bessel_ik; try asymptotic expansion." );
    ril = FPMIN;
    ripl = h*ril;
    ril1 = ril;
    rip1 = ripl;
    fact = xnu*xi;
    for ( l = nl; l >= 1; --l ) {
        ritemp = fact*ril + ripl;
        fact -= xi;
        ripl = fact*ritemp + ril;
        ril = ritemp;
    }
    f= ripl/ril;
    if ( x < XMIN ) {
        x2 = 0.5*x;
        pimu = PI*xmu;
        fact = (fabs(pimu) < EPS ? 1.0 : pimu/sin(pimu));
        d = -log(x2);
        e = xmu*d;
        fact2 = (fabs(e) < EPS ? 1.0 : sinh(e)/e);
        bessel_cheb( xmu, &gam1, &gam2, &gampl, &gammi );
        ff = fact*(gam1*cosh(e) + gam2*fact2*d);
        sum = ff;
        e = exp(e);
        p = 0.5*e/gampl;
        q = 0.5/(e*gammi);
        c = 1.0;
        d = x2*x2;
        sum1 = p;
        for ( i = 1; i <= MAXIT; ++i ) {
            ff = (i*ff + p + q)/(i*i - xmu2);
            c *= d/i;
            p /= i - xmu;
            q /= i + xmu;
            del = c*ff;
            sum += del;
            del1 = c*(p - i*ff);
            sum1 += del1;
            if ( fabs(del) < EPS*fabs(sum) ) break;
        }
        if ( i > MAXIT ) nrerror("Bessel k series failed to converge in bessel_jy." );
        rkmu = sum;
        rk1 = sum1*xi2;
    } else {
        b = 2.0*(1.0 + x);
        d = 1.0/b;
        h = delh = d;
        q1 = 0.0;
        q2 = 1.0;
        a1 = 0.25 - xmu2;
        q = c = a1;
        a = -a1;
        s = 1.0 + q*delh;
        for ( i = 2; i <= MAXIT; ++i ) {
            a -= 2*(i - 1);
            c = -a*c/i;
            qnew = (q1 - b*q2)/a;
            q1 = q2;
            q2 = qnew;
            q += c*qnew;
            b += 2.0;
            d = 1.0/(b + a*d);
            delh = (b*d - 1.0)*delh;
            h += delh;
            dels = q*delh;
            s += dels;
            if ( fabs(dels/s) < EPS ) break;
        }
        if ( i > MAXIT ) nrerror( "Steed's method failed in bessel_ik." );
        h = a1*h;
        rkmu = sqrt(PI/(2.0*x))*exp(-x)/s;
        rk1 = rkmu*(xmu + x + 0.5 - h)*xi;
    }
    rkmup = xmu*xi*rkmu - rk1;
    rimu = xi/(f*rkmu - rkmup);
    *ri = rimu*ril1/ril;
    *rip = rimu*rip1/ril;
    for ( i = 1; i <= nl; ++i ) {
        rktemp = (xmu + i)*xi2*rk1 + rkmu;
        rkmu = rk1;
        rk1 = rktemp;
    }
    *rk = rkmu;
    *rkp = xnu*xi*rkmu - rk1;
}
double diskthick (double z)                 //  vertical mass distribution
{                                           //
    return 1.0/pow(cosh(z / z0), 2.0);      //
}                                           //
Beispiel #20
0
void bessel_jy( double xnu, double x, double *rj, double *ry, double *rjp, double *ryp ) {

    const double  EPS    =  1.0e-16;
    const double  FPMIN  =  1.0e-30;
    const int     MAXIT  =  10000;
    const double  XMIN   =  2.0;

    int i, isign, l, nl;
    double a, b, br, bi, c, cr, ci, d, del, del1, den, di, dlr, dli, dr, e, f, fact, fact2,
           fact3, ff, gam, gam1, gam2, gammi, gampl, h, p, pimu, pimu2, q, r, rjl,
           rjl1, rjmu, rjp1, rjpl, rjtemp, ry1, rymu, rymup, rytemp, sum, sum1,
           temp, w, x2, xi, xi2, xmu, xmu2;

    if ( x <= 0.0 || xnu < 0.0 ) nrerror( "Bad arguments in bessel_jy." );

    nl = ( x < XMIN ? (int)(xnu + 0.5) : imax( 0, (int)(xnu - x + 1.5) ) );

    xmu = xnu - nl;
    xmu2 = xmu*xmu;
    xi = 1.0/x;
    xi2 = 2.0*xi;
    w = xi2/PI;
    isign = 1;
    h = xnu*xi;
    if ( h < FPMIN ) h = FPMIN;
    b = xi2*xnu;
    d = 0.0;
    c = h;
    for ( i = 1; i <= MAXIT; ++i ) {
        b += xi2;
        d = b - d;
        if ( fabs(d) < FPMIN ) d = FPMIN;
        c = b - 1.0/c;
        if ( fabs(c) < FPMIN ) c = FPMIN;
        d = 1.0/d;
        del = c*d;
        h = del*h;
        if ( d < 0.0 ) isign = -isign;
        if ( fabs(del - 1.0) < EPS ) break;
    }
    if ( i > MAXIT ) nrerror( "Argument x too large in bessel_jy; try asymptotic expansion." );
    rjl = isign*FPMIN;
    rjpl = h*rjl;
    rjl1 = rjl;
    rjp1 = rjpl;
    fact = xnu*xi;
    for ( l = nl; l >= 1; --l ) {
        rjtemp = fact*rjl + rjpl;
        fact -= xi;
        rjpl = fact*rjtemp - rjl;
        rjl = rjtemp;
    }
    if ( rjl == 0.0 ) rjl = EPS;
    f= rjpl/rjl;
    if ( x < XMIN ) {
        x2 = 0.5*x;
        pimu = PI*xmu;
        fact = ( fabs(pimu) < EPS ? 1.0 : pimu/sin(pimu) );
        d = -log(x2);
        e = xmu*d;
        fact2 = ( fabs(e) < EPS ? 1.0 : sinh(e)/e );
        bessel_cheb( xmu, &gam1, &gam2, &gampl, &gammi );
        ff = (2.0/PI)*fact*(gam1*cosh(e) + gam2*fact2*d);
        e = exp(e);
        p = e/(PI*gampl);
        q = 1.0/(e*PI*gammi);
        pimu2 = 0.5*pimu;
        fact3 = (fabs(pimu2) < EPS ? 1.0 : sin(pimu2)/pimu2 );
        r = PI*pimu2*fact3*fact3;
        c = 1.0;
        d = -x2*x2;
        sum = ff + r*q;
        sum1 = p;
        for ( i = 1; i <= MAXIT; ++i ) {
            ff = (i*ff + p + q)/(i*i - xmu2);
            c *= d/i;
            p /= i - xmu;
            q /= i + xmu;
            del = c*(ff + r*q);
            sum += del;
            del1 = c*p - i*del;
            sum1 += del1;
            if ( fabs(del) < EPS*(1.0 + fabs(sum)) ) break;
        }
        if ( i > MAXIT ) nrerror("Bessel y series failed to converge in bessel_jy." );
        rymu = -sum;
        ry1 = -sum1*xi2;
        rymup = xmu*xi*rymu - ry1;
        rjmu = w/(rymup - f*rymu);
    } else {
        a = 0.25 - xmu2;
        q = 1.0;
        p = -0.5*xi;
        br = 2.0*x;
        bi = 2.0;
        fact = a*xi/(p*p + q*q);
        cr = br + q*fact;
        ci = bi + p*fact;
        den = br*br + bi*bi;
        dr = br/den;
        di = -bi/den;
        dlr = cr*dr - ci*di;
        dli = cr*di + ci*dr;
        temp = p*dlr - q*dli;
        q = p*dli + q*dlr;
        p = temp;
        for ( i = 2; i <= MAXIT; ++i ) {
            a += 2*(i - 1);
            bi += 2.0;
            dr = a*dr + br;
            di = a*di + bi;
            if ( fabs(dr) + fabs(di) < FPMIN ) dr = FPMIN;
            fact = a/(cr*cr + ci*ci);
            cr = br + cr*fact;
            ci = bi - ci*fact;
            if ( fabs(cr) + fabs(ci) < FPMIN ) cr = FPMIN;
            den = dr*dr + di*di;
            dr /= den;
            di /= -den;
            dlr = cr*dr - ci*di;
            dli = cr*di + ci*dr;
            temp = p*dlr - q*dli;
            q = p*dli + q*dlr;
            p = temp;
            if ( fabs(dlr - 1.0) + fabs(dli) < EPS ) break;
        }
        if ( i > MAXIT ) nrerror( "Lentz's method failed in bessel_jy." );
        gam = (p - f)/q;
        rjmu = sqrt(w/((p - f)*gam + q));
        rjmu = dsign( rjmu, rjl );
        rymu = rjmu*gam;
        rymup = rymu*(p + q/gam);
        ry1 = xmu*xi*rymu - rymup;
    }
    fact = rjmu/rjl;
    *rj = rjl1*fact;
    *rjp = rjp1*fact;
    for ( i = 1; i <= nl; ++i ) {
        rytemp = (xmu + i)*xi2*ry1 - rymu;
        rymu = ry1;
        ry1 = rytemp;
    }
    *ry = rymu;
    *ryp = xnu*xi*rymu - ry1;
}
Beispiel #21
0
static void evalPrimary(Parser *p){
    double d, d2=NAN;
    char *next= p->s;
    int i;

    /* number */
    d= strtod(p->s, &next);
    if(next != p->s){
        push(p, d);
        p->s= next;
        return;
    }

    /* named constants */
    for(i=0; p->const_name[i]; i++){
        if(strmatch(p->s, p->const_name[i])){
            push(p, p->const_value[i]);
            p->s+= strlen(p->const_name[i]);
            return;
        }
    }

    p->s= strchr(p->s, '(');
    if(p->s==NULL){
        fprintf(stderr, "Parser: missing ( in \"%s\"\n", next);
        return;
    }
    p->s++; // "("
    evalExpression(p);
    d= pop(p);
    if(p->s[0]== ','){
        p->s++; // ","
        evalExpression(p);
        d2= pop(p);
    }
    if(p->s[0] != ')'){
        fprintf(stderr, "Parser: missing ) in \"%s\"\n", next);
        return;
    }
    p->s++; // ")"

         if( strmatch(next, "sinh"  ) ) d= sinh(d);
    else if( strmatch(next, "cosh"  ) ) d= cosh(d);
    else if( strmatch(next, "tanh"  ) ) d= tanh(d);
    else if( strmatch(next, "sin"   ) ) d= sin(d);
    else if( strmatch(next, "cos"   ) ) d= cos(d);
    else if( strmatch(next, "tan"   ) ) d= tan(d);
    else if( strmatch(next, "exp"   ) ) d= exp(d);
    else if( strmatch(next, "log10"   ) ) d= log10(d);
    else if( strmatch(next, "log2"   ) ) d= log10(d)/log10(2);
    else if( strmatch(next, "log"   ) ) d= log(d);
    else if( strmatch(next, "sqrt"   ) ) d= sqrt(d);
    else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d));
    else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI);
    else if( strmatch(next, "abs"   ) ) d= fabs(d);
    else if( strmatch(next, "max"   ) ) d= d > d2 ? d : d2;
    else if( strmatch(next, "min"   ) ) d= d < d2 ? d : d2;
    else if( strmatch(next, "gte"    ) ) d= d >= d2 ? 1.0 : 0.0;
    else if( strmatch(next, "gt"    ) ) d= d > d2 ? 1.0 : 0.0;
    else if( strmatch(next, "lte"    ) ) d= d >= d2 ? 0.0 : 1.0;
    else if( strmatch(next, "lt"    ) ) d= d > d2 ? 0.0 : 1.0;
    else if( strmatch(next, "eq"    ) ) d= d == d2 ? 1.0 : 0.0;
//    else if( strmatch(next, "l1"    ) ) d= 1 + d2*(d - 1);
//    else if( strmatch(next, "sq01"  ) ) d= (d >= 0.0 && d <=1.0) ? 1.0 : 0.0;
    else{
        int error=1;
        for(i=0; p->func1_name && p->func1_name[i]; i++){
            if(strmatch(next, p->func1_name[i])){
                d= p->func1[i](p->opaque, d);
                error=0;
                break;
            }
        }

        for(i=0; p->func2_name && p->func2_name[i]; i++){
            if(strmatch(next, p->func2_name[i])){
                d= p->func2[i](p->opaque, d, d2);
                error=0;
                break;
            }
        }

        if(error){
            fprintf(stderr, "Parser: unknown function in \"%s\"\n", next);
            return;
        }
    }

    push(p, d);
}
int
gsl_sf_bessel_Y_temme(const double nu, const double x,
                      gsl_sf_result * Ynu,
                      gsl_sf_result * Ynup1)
{
  const int max_iter = 15000;
  
  const double half_x = 0.5 * x;
  const double ln_half_x = log(half_x);
  const double half_x_nu = exp(nu*ln_half_x);
  const double pi_nu   = M_PI * nu;
  const double alpha   = pi_nu / 2.0;
  const double sigma   = -nu * ln_half_x;
  const double sinrat  = (fabs(pi_nu) < GSL_DBL_EPSILON ? 1.0 : pi_nu/sin(pi_nu));
  const double sinhrat = (fabs(sigma) < GSL_DBL_EPSILON ? 1.0 : sinh(sigma)/sigma);
  const double sinhalf = (fabs(alpha) < GSL_DBL_EPSILON ? 1.0 : sin(alpha)/alpha);
  const double sin_sqr = nu*M_PI*M_PI*0.5 * sinhalf*sinhalf;
  
  double sum0, sum1;
  double fk, pk, qk, hk, ck;
  int k = 0;
  int stat_iter;

  double g_1pnu, g_1mnu, g1, g2;
  int stat_g = gsl_sf_temme_gamma(nu, &g_1pnu, &g_1mnu, &g1, &g2);

  fk = 2.0/M_PI * sinrat * (cosh(sigma)*g1 - sinhrat*ln_half_x*g2);
  pk = 1.0/M_PI /half_x_nu * g_1pnu;
  qk = 1.0/M_PI *half_x_nu * g_1mnu;
  hk = pk;
  ck = 1.0;

  sum0 = fk + sin_sqr * qk;
  sum1 = pk;

  while(k < max_iter) {
    double del0;
    double del1;
    double gk;
    k++;
    fk  = (k*fk + pk + qk)/(k*k-nu*nu);
    ck *= -half_x*half_x/k;
    pk /= (k - nu);
    qk /= (k + nu);
    gk  = fk + sin_sqr * qk;
    hk  = -k*gk + pk; 
    del0 = ck * gk;
    del1 = ck * hk;
    sum0 += del0;
    sum1 += del1;
    if(fabs(del0) < 0.5*(1.0 + fabs(sum0))*GSL_DBL_EPSILON) break;
  }

  Ynu->val   = -sum0;
  Ynu->err   = (2.0 + 0.5*k) * GSL_DBL_EPSILON * fabs(Ynu->val);
  Ynup1->val = -sum1 * 2.0/x;
  Ynup1->err = (2.0 + 0.5*k) * GSL_DBL_EPSILON * fabs(Ynup1->val);

  stat_iter = ( k >= max_iter ? GSL_EMAXITER : GSL_SUCCESS );
  return GSL_ERROR_SELECT_2(stat_iter, stat_g);
}
Beispiel #23
0
/* Functions added for Standard Basis Library are all indirected through here. */
Handle Real_dispatchc(TaskData *mdTaskData, Handle args, Handle code)
{
    unsigned c = get_C_unsigned(mdTaskData, DEREFWORDHANDLE(code));
    switch (c)
    {
    case 0: /* tan */ return real_result(mdTaskData, tan(real_arg(args)));
    case 1: /* asin */
        {
            double x = real_arg(args);
            if (x < -1.0 || x > 1.0)
                return real_result(mdTaskData, notANumber);
            else return real_result(mdTaskData, asin(x));
        }
    case 2: /* acos */
        {
            double x = real_arg(args);
            if (x < -1.0 || x > 1.0)
                return real_result(mdTaskData, notANumber);
            else return real_result(mdTaskData, acos(x));
        }
    case 3: /* atan2 */ return real_result(mdTaskData, atan2(real_arg1(args), real_arg2(args)));
    case 4: /* pow */ return powerOf(mdTaskData, args);
    case 5: /* log10 */
        {
            double x = real_arg(args);
            /* Make sure the result conforms to the definition. */
            if (x < 0.0)
                return real_result(mdTaskData, notANumber); /* Nan. */
            else if (x == 0.0) /* x may be +0.0 or -0.0 */
                return real_result(mdTaskData, negInf); /* -infinity. */
            else return real_result(mdTaskData, log10(x));
        }
    case 6: /* sinh */ return real_result(mdTaskData, sinh(real_arg(args)));
    case 7: /* cosh */ return real_result(mdTaskData, cosh(real_arg(args)));
    case 8: /* tanh */ return real_result(mdTaskData, tanh(real_arg(args)));
    case 9: /* setroundingmode */
        setrounding(mdTaskData, args);
        return mdTaskData->saveVec.push(TAGGED(0)); /* Unit */
    case 10: /* getroundingmode */
        return mdTaskData->saveVec.push(TAGGED(getrounding(mdTaskData)));
    /* Floating point representation queries. */
#ifdef _DBL_RADIX
    case 11: /* Value of radix */ return mdTaskData->saveVec.push(TAGGED(_DBL_RADIX));
#else
    case 11: /* Value of radix */ return mdTaskData->saveVec.push(TAGGED(FLT_RADIX));
#endif
    case 12: /* Value of precision */ return mdTaskData->saveVec.push(TAGGED(DBL_MANT_DIG));
    case 13: /* Maximum number */ return real_result(mdTaskData, DBL_MAX);
    /* float.h describes DBL_MIN as the minimum positive number.
       In fact this is the minimum NORMALISED number.  The smallest
       number which can be represented is DBL_MIN*2**(-DBL_MANT_DIG) */
    case 14: /* Minimum normalised number. */
        return real_result(mdTaskData, DBL_MIN);
    case 15: /* Is finite */ /* No longer used - implemented in ML. */
        return mdTaskData->saveVec.push(finite(real_arg(args)) ? TAGGED(1) : TAGGED(0));
    case 16: /* Is Nan */ /* No longer used - implemented in ML. */
        return mdTaskData->saveVec.push(isnan(real_arg(args)) ? TAGGED(1) : TAGGED(0));
    case 17: /* Get sign bit.  There may be better ways to find this. */
        return mdTaskData->saveVec.push(copysign(1.0, real_arg(args)) < 0.0 ? TAGGED(1) : TAGGED(0));
    case 18: /* Copy sign. */
        return real_result(mdTaskData, copysign(real_arg1(args), real_arg2(args)));
    case 19: /* Return largest integral value (as a real) <= x. */
        return real_result(mdTaskData, floor(real_arg(args)));
    case 20: /* Return smallest integral value (as a real) >= x  */
        return real_result(mdTaskData, ceil(real_arg(args)));
    case 21:
        { /* Truncate towards zero */
            double dx = real_arg(args);
            if (dx >= 0.0) return real_result(mdTaskData, floor(dx));
            else return real_result(mdTaskData, ceil(dx));
        }
    case 22: /* Round to nearest integral value. */
        {
            double dx = real_arg(args);
            double drem = fmod(dx, 2.0);
            if (drem == 0.5 || drem == -1.5)
                /* If the value was exactly positive even + 0.5 or
                   negative odd -0.5 round it down, otherwise round it up. */
                return real_result(mdTaskData, ceil(dx-0.5));
            else return real_result(mdTaskData, floor(dx+0.5));
        }
    case 23: /* Compute ldexp */
        {
            int exp = get_C_int(mdTaskData, DEREFHANDLE(args)->Get(1));
            return real_result(mdTaskData, ldexp(real_arg1(args), exp));
        }
    case 24: /* Get mantissa. */
        {
            int exp;
            return real_result(mdTaskData, frexp(real_arg(args), &exp));
        }
    case 25: /* Get exponent. */
        {
            int exp;
            (void)frexp(real_arg(args), &exp);
            return mdTaskData->saveVec.push(TAGGED(exp));
        }
    case 26: /* Return the mantissa from a Nan as a real number. */
        // I think this is no longer used.
        {
            union db r_arg_x, r_arg_y;
            /* We want to simply replace the exponent by the exponent
               value for 0.5<=x<1.
               I think there may be a more portable way of doing this. */
            r_arg_x.dble = posInf; /* Positive infinity. */
            r_arg_y.dble = 0.5;
            /* Use the infinity value as a mask, removing any bits set
               and replace by the exponent from 0.5. */
            byte *barg = DEREFBYTEHANDLE(args);
            for(unsigned i = 0; i < DBLE; i++)
            {
                r_arg_x.bytes[i] = (barg[i] & ~r_arg_x.bytes[i]) | r_arg_y.bytes[i];
            }
            return real_result(mdTaskData, r_arg_x.dble);
        }
    case 27: /* Construct a Nan from a given mantissa. */
        // I think this is no longer used.
        {
            union db r_arg;
            r_arg.dble = posInf; /* Positive infinity. */
            /* OR in the exponent. */
            byte *barg = DEREFBYTEHANDLE(args);
            for(unsigned i = 0; i < DBLE; i++)
            {
                r_arg.bytes[i] = r_arg.bytes[i] | barg[i];
            }
            return real_result(mdTaskData, r_arg.dble);
        }
    case 28: /* Return the number of bytes for a real.  */
        return mdTaskData->saveVec.push(TAGGED(sizeof(double)));

    default:
        {
            char msg[100];
            sprintf(msg, "Unknown real arithmetic function: %d", c);
            raise_exception_string(mdTaskData, EXC_Fail, msg);
            return 0;
        }
    }
}
Beispiel #24
0
double
tanh(double x)
{
    return sinh(x) / cosh(x);
}
inline double _cosh(double arg)            { return  cosh(arg); }
Beispiel #26
0
static int math_cosh (lua_State *L) {
  lua_pushnumber(L, cosh(luaL_checknumber(L, 1)));
  return 1;
}
inline double _d0_tanh(double arg)         { return (1.0/cosh(arg)/cosh(arg)); }
Beispiel #28
0
double
my_cosh(double __x)
{
    WRAPPERS_DEBUG_PRINTF("cosh()\n", __x);
    return cosh(__x);
}
Beispiel #29
0
PRIVATE double
cosh_wrapper (double x)
{
  warning_trace_info (NULL_STRING);
  return cosh (x);
}
__device__ void double_precision_math_functions() {
    int iX;
    double fX, fY;

    acos(1.0);
    acosh(1.0);
    asin(0.0);
    asinh(0.0);
    atan(0.0);
    atan2(0.0, 1.0);
    atanh(0.0);
    cbrt(0.0);
    ceil(0.0);
    copysign(1.0, -2.0);
    cos(0.0);
    cosh(0.0);
    cospi(0.0);
    cyl_bessel_i0(0.0);
    cyl_bessel_i1(0.0);
    erf(0.0);
    erfc(0.0);
    erfcinv(2.0);
    erfcx(0.0);
    erfinv(1.0);
    exp(0.0);
    exp10(0.0);
    exp2(0.0);
    expm1(0.0);
    fabs(1.0);
    fdim(1.0, 0.0);
    floor(0.0);
    fma(1.0, 2.0, 3.0);
    fmax(0.0, 0.0);
    fmin(0.0, 0.0);
    fmod(0.0, 1.0);
    frexp(0.0, &iX);
    hypot(1.0, 0.0);
    ilogb(1.0);
    isfinite(0.0);
    isinf(0.0);
    isnan(0.0);
    j0(0.0);
    j1(0.0);
    jn(-1.0, 1.0);
    ldexp(0.0, 0);
    lgamma(1.0);
    llrint(0.0);
    llround(0.0);
    log(1.0);
    log10(1.0);
    log1p(-1.0);
    log2(1.0);
    logb(1.0);
    lrint(0.0);
    lround(0.0);
    modf(0.0, &fX);
    nan("1");
    nearbyint(0.0);
    nextafter(0.0, 0.0);
    fX = 1.0;
    norm(1, &fX);
    norm3d(1.0, 0.0, 0.0);
    norm4d(1.0, 0.0, 0.0, 0.0);
    normcdf(0.0);
    normcdfinv(1.0);
    pow(1.0, 0.0);
    rcbrt(1.0);
    remainder(2.0, 1.0);
    remquo(1.0, 2.0, &iX);
    rhypot(0.0, 1.0);
    rint(1.0);
    fX = 1.0;
    rnorm(1, &fX);
    rnorm3d(0.0, 0.0, 1.0);
    rnorm4d(0.0, 0.0, 0.0, 1.0);
    round(0.0);
    rsqrt(1.0);
    scalbln(0.0, 1);
    scalbn(0.0, 1);
    signbit(1.0);
    sin(0.0);
    sincos(0.0, &fX, &fY);
    sincospi(0.0, &fX, &fY);
    sinh(0.0);
    sinpi(0.0);
    sqrt(0.0);
    tan(0.0);
    tanh(0.0);
    tgamma(2.0);
    trunc(0.0);
    y0(1.0);
    y1(1.0);
    yn(1, 1.0);
}