Пример #1
0
void test_acosh()
{
    static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
    static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
    static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
    assert(acosh(1) == 0);
}
Пример #2
0
static ex acosh_eval(const ex & x)
{
	if (x.info(info_flags::numeric)) {

		// acosh(0) -> Pi*I/2
		if (x.is_zero())
			return Pi*I*numeric(1,2);

		// acosh(1) -> 0
		if (x.is_equal(_ex1))
			return _ex0;

		// acosh(-1) -> Pi*I
		if (x.is_equal(_ex_1))
			return Pi*I;

		// acosh(float) -> float
		if (!x.info(info_flags::crational))
			return acosh(ex_to<numeric>(x));

		// acosh(-x) -> Pi*I-acosh(x)
		if (x.info(info_flags::negative))
			return Pi*I-acosh(-x);
	}
	
	return acosh(x).hold();
}
Пример #3
0
static ex acosh_evalf(const ex & x)
{
	if (is_exactly_a<numeric>(x))
		return acosh(ex_to<numeric>(x));
	
	return acosh(x).hold();
}
Пример #4
0
void test_hyps()
{
	double x;
	double y;
	
	RPN::Context cxt;
	cxt.insert("x", new RPN::VariableNode(&x));
	cxt.insert("y", new RPN::VariableNode(&y));
	
	RPN::Expression xsin("sinh x", cxt);
	RPN::Expression xcos("cosh x", cxt);
	RPN::Expression xtan("tanh x", cxt);
	
	RPN::Expression xsec("sech x", cxt);
	RPN::Expression xcsc("csch x", cxt);
	RPN::Expression xcot("coth x", cxt);
	
	RPN::Expression xasin("asinh x", cxt);
	RPN::Expression xacos("acosh x", cxt);
	RPN::Expression xatan("atanh x", cxt);
	
	RPN::Expression xasec("asech x", cxt);
	RPN::Expression xacsc("acsch x", cxt);
	RPN::Expression xacot("acoth x", cxt);
	
//	RPN::Expression xatan2("atanh2(x, y)", cxt);
//	RPN::Expression xacot2("acoth2(x, y)", cxt);
	
	for(x = -RPN::Constants::PI; x < RPN::Constants::PI; x += 0.097)
	{
		insist_equal(xsin.evaluate(), sinh(x));
		insist_equal(xcos.evaluate(), cosh(x));
		insist_equal(xtan.evaluate(), tanh(x));
		
		insist_equal(xsec.evaluate(), 1.0/cosh(x));
		insist_equal(xcsc.evaluate(), 1.0/sinh(x));
		insist_equal(xcot.evaluate(), 1.0/tanh(x));
	}
	
	for(x = -1; x < 1; x += 0.043)
	{
		insist_equal(xasin.evaluate(), asinh(x));
		insist_equal(xacos.evaluate(), acosh(x));
		insist_equal(xatan.evaluate(), atanh(x));
		
		insist_equal(xasec.evaluate(), acosh(1.0/x));
		insist_equal(xacsc.evaluate(), asinh(1.0/x));
		insist_equal(xacot.evaluate(), atanh(1.0/x));
	}
	
/*	for(x = -1; x < 1; x+= 0.069)
	{
		for(y = -1; y < 1; y += 0.73)
		{
			insist_equal(xatan2.evaluate(), atan2(x, y));
			insist_equal(xacot2.evaluate(), atan2(y, x));
		}
	}*/
}
Пример #5
0
/* see https://en.wikipedia.org/wiki/Chebyshev_polynomials */
double nsl_sf_poly_chebyshev_T(int n, double x) {
	if(fabs(x) <= 1)
		return cos(n*acos(x));
	else if (x > 1)
		return cosh(n*acosh(x));
	else 
		return pow(-1.,n)*cosh(n*acosh(-x));
}
Пример #6
0
Файл: cosmo.c Проект: jpcoles/ZM
/*
 ** This function integrates the time dependence of the "kick"-Hamiltonian.
 */
double csmComoveKickFac(CSM csm,double dTime,double dDelta) {
    double dOmega0 = csm->dOmega0;
    double dHubble0 = csm->dHubble0;
    double a0,A,B,a1,a2,eta1,eta2;

    if (!csm->bComove) return(dDelta);
    else if (csm->dLambda == 0.0 && csm->dOmegaRad == 0.0) {
	a1 = csmTime2Exp(csm,dTime);
	a2 = csmTime2Exp(csm,dTime+dDelta);
	if (dOmega0 == 1.0) {
	    return((2.0/dHubble0)*(sqrt(a2) - sqrt(a1)));
	    }
	else if (dOmega0 > 1.0) {
	    assert(dHubble0 >= 0.0);
	    if (dHubble0 == 0.0) {
		A = 1.0;
		B = 1.0/sqrt(dOmega0);
		}
	    else {
		a0 = 1.0/dHubble0/sqrt(dOmega0-1.0);
		A = 0.5*dOmega0/(dOmega0-1.0);
		B = A*a0;
		}
	    eta1 = acos(1.0-a1/A);
	    eta2 = acos(1.0-a2/A);
	    return(B/A*(eta2 - eta1));
	    }
	else if (dOmega0 > 0.0) {
	    assert(dHubble0 > 0.0);
	    a0 = 1.0/dHubble0/sqrt(1.0-dOmega0);
	    A = 0.5*dOmega0/(1.0-dOmega0);
	    B = A*a0;
	    eta1 = acosh(a1/A+1.0);
	    eta2 = acosh(a2/A+1.0);
	    return(B/A*(eta2 - eta1));
	    }
	else if (dOmega0 == 0.0) {
	    /*
	     ** YOU figure this one out!
	     */
	    assert(0);
	    return(0.0);
	    }
	else {
	    /*
	     ** Bad value?
	     */
	    assert(0);
	    return(0.0);
	    }
	}
    else {
	return dRombergO(csm,
			 (double (*)(void *, double)) csmComoveKickInt,
			 1.0/csmTime2Exp(csm, dTime),
			 1.0/csmTime2Exp(csm, dTime + dDelta), EPSCOSMO);
	}
    }
Пример #7
0
TEST(AgradRev,acosh) {
  AVAR a = 1.3;
  AVAR f = acosh(a);
  EXPECT_FLOAT_EQ(acosh(1.3), f.val());

  AVEC x = createAVEC(a);
  VEC grad_f;
  f.grad(x,grad_f);
  EXPECT_FLOAT_EQ(1.0/sqrt(1.3 * 1.3  - 1.0), grad_f[0]);
}
Пример #8
0
static ex acosh_conjugate(const ex & x)
{
	// conjugate(acosh(x))==acosh(conjugate(x)) unless on the branch cut
	// which runs along the real axis from +1 to -inf.
	if (is_exactly_a<numeric>(x) &&
	    (!x.imag_part().is_zero() || x > *_num1_p)) {
		return acosh(x.conjugate());
	}
	return conjugate_function(acosh(x)).hold();
}
Пример #9
0
void
DolphChebyWindow::GenerateWindow(int length, double Alpha_Parm)
{
  double denom, numer, x;
  double sum_re, sum_im;
  int n, k;
  int num_freq_samps, beg_freq_idx, end_freq_idx;
  double* freq_resp;
  int Interp_Rate = 10;

  freq_resp = new double[length * Interp_Rate];

  beg_freq_idx = ((1 - length) * Interp_Rate) / 2;
  end_freq_idx = ((length - 1) * Interp_Rate) / 2;
  num_freq_samps = Interp_Rate * (length - 1) + 1;

  denom = cosh(length * acosh(Alpha_Parm));

  for (n = beg_freq_idx; n <= end_freq_idx; n++) {
    x = Alpha_Parm * cos((M_PI * n) / double(Interp_Rate * length));
    if (x < 1.0) {
      numer = cos(length * acos(x));
    } else {
      numer = cosh(length * acosh(x));
    }
    if (n < 0) {
      freq_resp[n + num_freq_samps] = numer / denom;
    } else {
      freq_resp[n] = numer / denom;
    }
  }

  //  now do inverse DFT

  for (n = 0; n <= (length - 1) / 2; n++) {
    sum_re = 0.0;
    sum_im = 0.0;

    for (k = 0; k < num_freq_samps; k++) {
      sum_re +=
        (freq_resp[k] * cos((M_PI * 2 * k * n) / (double)num_freq_samps));
      sum_im +=
        (freq_resp[k] * sin((M_PI * 2 * k * n) / (double)num_freq_samps));
    }
    Half_Lag_Win[n] = sum_re / (double)num_freq_samps;
  }

  NormalizeWindow();
  delete[] freq_resp;
  return;
}
Пример #10
0
void SR::boost(SR::vec &fourVector, arma::vec3 direction, double beta)
{
#ifdef SRDEBUG
    cout << "Applying boost with hyperbolic angle " << beta << " along direction: " << direction;
#endif

    direction = normalise(direction);
    arma::mat44 omega;
    omega.zeros();
    double gamma = 1.0/sqrt(1 - beta*beta);
    double chi = acosh(gamma);

    for(int mu=1; mu<=3; mu++) {
        // direction is a 3-vector, so subtract 1 to go from 4-vector indices to 3-vector index
        omega(0,mu) = direction(mu-1)*chi;
        omega(mu,0) = direction(mu-1)*chi;
    }

    mat44 boostOperator = LorentzGenerator::generateElement(omega);
#ifdef SRDEBUG
    cout << "Boost matrix: " << endl << boostOperator;
#endif

    fourVector.applyOperator(boostOperator);
}
Пример #11
0
void SR::boostAndRotate(SR::vec &fourVector, arma::vec3 boostDirection, double beta, arma::vec3 rotationAxis, double angle)
{
    boostDirection = normalise(boostDirection);
    rotationAxis = normalise(rotationAxis);
    arma::mat44 omega;
    omega.zeros();

    double gamma = 1.0/sqrt(1 - beta*beta);
    double chi = acosh(gamma);

    for(int mu=1; mu<=3; mu++) {
        // direction is a 3-vector, so subtract 1 to go from 4-vector indices to 3-vector index
        omega(0,mu) = boostDirection(mu-1)*chi;
        omega(mu,0) = boostDirection(mu-1)*chi;

        for(int nu=1; nu<=3; nu++) {
            if(mu==nu) continue;
            // Sum of all indices is 1+2+3 = 6.
            // So the third index is then 6 - mu - nu = 6 - (mu+nu)
            int axisOfRotation = 6 - (mu+nu);
            omega(mu,nu) = angle*rotationAxis(axisOfRotation);
            omega(nu,mu) = -angle*rotationAxis(axisOfRotation);
        }
    }

    mat44 rotationOperator = LorentzGenerator::generateElement(omega);
    fourVector.applyOperator(rotationOperator);

}
Пример #12
0
double cOrbit::EccentricAnomalyAtTrueAnomaly(double tA) const
{
    double e = Eccentricity();
    if (IsHyperbolic()) {
        double cosTrueAnomaly = std::cos(tA);
        double H = acosh((e + cosTrueAnomaly) / (1.0 + e * cosTrueAnomaly));
        if (tA < 0) 
        {
            return -H;
        } 
        else 
        {
            return H;
        }
    } else {
        double E = 2 * std::atan(std::tan(tA / 2) / std::sqrt((1 + e) / (1 - e)));
        if (E < 0) 
        {
            return E + TWO_PI;
        } 
        else 
        {
            return E;
        }
    }
}
Пример #13
0
double hyperbolic_arc_cosine(double x, enum angle_type out_type)
{
      switch (out_type)
      {
      case RAD:
            return acosh(x);
            break;

      case DEG:
            return radians_to_degrees(acosh(x));
            break;

      case GRAD:
            return radians_to_grade(acosh(x));
      }
}
void Foam::equationReader::evalDimsAcoshDimCheck
(
    const equationReader * eqnReader,
    const label index,
    const label i,
    const label storageOffset,
    label& storeIndex,
    dimensionSet& xDims,
    dimensionSet sourceDims
) const
{
    if
    (
        !xDims.dimensionless() && dimensionSet::debug
    )
    {
        WarningIn("equationReader::evalDimsAcoshDimCheck")
            << "Dimension error thrown for operation ["
            << equationOperation::opName
            (
                operator[](index)[i].operation()
            )
            << "] in equation " << operator[](index).name()
            << ", given by:" << token::NL << token::TAB
            << operator[](index).rawText();
    }
    dimensionedScalar ds("temp", xDims, 1.0);
    xDims.reset(acosh(ds).dimensions());
    operator[](index)[i].assignOpDimsFunction
    (
        &Foam::equationReader::evalDimsAcosh
    );
}
Пример #15
0
int main() {
    double x = 1.0;
    double y = 1.0;
    int i = 1;
    acosh(x);
    asinh(x);
    atanh(x);
    cbrt(x);
    expm1(x);
    erf(x);
    erfc(x);
    isnan(x);
    j0(x);
    j1(x);
    jn(i,x);
    ilogb(x);
    logb(x);
    log1p(x);
    rint(x);
    y0(x);
    y1(x);
    yn(i,x);
#   ifdef _THREAD_SAFE
    gamma_r(x,&i);
    lgamma_r(x,&i);
#   else
    gamma(x);
    lgamma(x);
#   endif
    hypot(x,y);
    nextafter(x,y);
    remainder(x,y);
    scalb(x,y);
    return 0;
}
Пример #16
0
    CppEllipse CppEllipse::fromMatrix(const tmv::Matrix<double>& m, Angle& rotation, bool& parityFlip) 
    {
        dbg<<"ellipse from matrix "<<m<<'\n';
        assert(m.nrows()==2 && m.ncols()==2);
        double det = m(0,0)*m(1,1) - m(0,1)*m(1,0);
        parityFlip = false;
        double scale;
        if (det < 0) {
            parityFlip = true;
            scale = -det;
        } else if (det==0.) {
            // Degenerate transformation.  Return some junk
            return CppEllipse(CppShear(0.0, 0.0), -std::numeric_limits<double>::max());
        } else {
            scale = det;
        }
        // Determine and remove the dilation
        double mu = 0.5*std::log(scale);

        // Now make m m^T matrix, which is symmetric
        // a & b are diagonal elements here
        double a = m(0,1)*m(0,1) + m(0,0)*m(0,0);
        double b = m(1,1)*m(1,1) + m(1,0)*m(1,0);
        double c = m(1,1)*m(0,1) + m(1,0)*m(0,0);

        double eta = acosh(std::max(1.,0.5*(a+b)/scale));
        Angle beta = 0.5*std::atan2(2.*c, a-b) * radians;
        CppShear s;
        s.setEtaBeta(eta,beta);
        s.getMatrix(a,b,c);

        // Now look for the rotation
        rotation = std::atan2(-c*m(0,0)+a*m(1,0), b*m(0,0)-c*m(1,0)) * radians;
        return CppEllipse(s,mu, Position<double>(0.,0.));
    }
inline double hg_hyperbolic_distance_hyperbolic_rgg_standard(const hg_graph_t * graph,
							     const hg_coordinate_t & node1, 
							     const hg_coordinate_t & node2,
							     r_precomputedsinhcosh * r_psc = NULL) {
  // check if it is the same node
  if(node1.r == node2.r && node1.theta == node2.theta) {
    return 0;
  }
  // if the nodes have the same angular coordinates
  // then we return the euclidean distance
  if(node1.theta == node2.theta) {
    return abs(node1.r-node2.r);
  }
  // equation 13
  double zeta = (*graph)[boost::graph_bundle].zeta_eta;
  double delta_theta = HG_PI - abs(HG_PI - abs(node1.theta - node2.theta));
  double part1, part2;
  if(r_psc != NULL) {
    part1 = (*r_psc)[node1.r].second * (*r_psc)[node2.r].second;
    part2 = (*r_psc)[node1.r].first  * (*r_psc)[node2.r].first  * cos(delta_theta);
  }
  else {    
    part1 = cosh(zeta * node1.r) * cosh(zeta * node2.r);
    part2 = sinh(zeta * node1.r) * sinh(zeta * node2.r) * cos(delta_theta);
  }
  return  acosh(part1 - part2) / zeta;
}
Пример #18
0
static TACommandVerdict acosh_cmd(TAThread thread,TAInputStream stream)
{
    double x, res;

    // Prepare

    x = readDouble(&stream);
    errno = 0;
    
    START_TARGET_OPERATION(thread);
    
    // Execute

    res = acosh(x);
    
    END_TARGET_OPERATION(thread);
    
    // Response
    
    writeDouble(thread, res);
    writeInt(thread, errno);

    sendResponse(thread);
    return taDefaultVerdict;

}
Пример #19
0
/* Test NaN-resulting library calls. */
int test_errs(void) {
  int errs = 0;
  /*
   * Attempt to prevent constant folding and optimization of library
   * function bodies (when statically linked).
   */
  volatile double x;
  volatile double y;

  printf("Checking well-defined library errors\n");
  x = -3.0; y = 4.4;
  errs += CHECK_NAN(pow(x, y));
  errs += CHECK_NAN(log(x));
  x = -0.001;
  errs += CHECK_NAN(sqrt(x));
  x = 1.0001;
  errs += CHECK_NAN(asin(x));
  x = INFINITY;
  errs += CHECK_NAN(sin(x));
  errs += CHECK_NAN(cos(x));
  x = 0.999;
  errs += CHECK_NAN(acosh(x));
  x = 3.3; y = 0.0;
  errs += CHECK_NAN(remainder(x, y));
  y = INFINITY;
  errs += CHECK_NAN(remainder(y, x));
  return errs;
}
Пример #20
0
gsl_complex gsl_complex_arccsc_real(double a)
{				/* z = arccsc(a) */
    gsl_complex z;

    if (a <= -1.0 || a >= 1.0) {
	GSL_SET_COMPLEX(&z, asin(1 / a), 0.0);
    } else {
	if (a >= 0.0) {
	    GSL_SET_COMPLEX(&z, M_PI_2, -acosh(1 / a));
	} else {
	    GSL_SET_COMPLEX(&z, -M_PI_2, acosh(-1 / a));
	}
    }

    return z;
}
Пример #21
0
void
test (void)
{
  TEST (acos (d), LARGE_EDOM);
  TEST (asin (d), LARGE_EDOM);
  TEST (acosh (d), LARGE_NEG_EDOM);
  TEST (atanh (d), LARGE_EDOM);
  TEST (cosh (d), LARGE_ERANGE);
  TEST (sinh (d), LARGE_ERANGE);
  TEST (log (d), LARGE_NEG_EDOM);
#if defined (__sun__) && defined (__unix__)
  /* Disabled due to a bug in Solaris libm.  */
  if (0)
#endif
    TEST (log2 (d), LARGE_NEG_EDOM);
  TEST (log10 (d), LARGE_NEG_EDOM);
  /* Disabled due to glibc PR 6792, fixed in Apr 2015.  */
  if (0)
    TEST (log1p (d), LARGE_NEG_EDOM);
  TEST (exp (d), POWER_ERANGE);
#if (defined (__sun__) || defined(__hppa__)) && defined (__unix__)
  /* Disabled due to a bug in Solaris libm.  HP PA-RISC libm doesn't support
     ERANGE for exp2.  */
  if (0)
#endif
    {
      TEST (exp2 (d), POWER_ERANGE);
      TEST (expm1 (d), POWER_ERANGE);
    }
  TEST (sqrt (d), LARGE_NEG_EDOM);
  TEST (pow (100.0, d), POWER_ERANGE);
  TEST (pow (i, d), POWER_ERANGE);
}
Пример #22
0
gsl_complex gsl_complex_arccosh_real(double a)
{				/* z = arccosh(a) */
    gsl_complex z;

    if (a >= 1) {
	GSL_SET_COMPLEX(&z, acosh(a), 0);
    } else {
	if (a >= -1.0) {
	    GSL_SET_COMPLEX(&z, 0, acos(a));
	} else {
	    GSL_SET_COMPLEX(&z, acosh(-a), M_PI);
	}
    }

    return z;
}
Пример #23
0
gsl_complex gsl_complex_arccos_real(double a)
{				/* z = arccos(a) */
    gsl_complex z;

    if (fabs(a) <= 1.0) {
	GSL_SET_COMPLEX(&z, acos(a), 0);
    } else {
	if (a < 0.0) {
	    GSL_SET_COMPLEX(&z, M_PI, -acosh(-a));
	} else {
	    GSL_SET_COMPLEX(&z, 0, acosh(a));
	}
    }

    return z;
}
Пример #24
0
double
DHPt3Distance(point4 p0, point4 p1, int metric)
{
	double d0, d1;
	point4 diff;
    switch (metric)	{
	case DG_EUCLIDEAN:
	    VSUB3(p0,p1, diff);
	    return(MAGNITUDE3(diff));
	    break;
	case DG_HYPERBOLIC:
	    d0 =INPRO31(p0, p0);
	    d1 =INPRO31(p1, p1);
	    if (d0 >= 0.0 || d1 >= 0.0)	{
		fprintf(stderr,"Invalid points in dist_proj3\n");
		return(0.0);
		}
	    return(acosh( ABS( INPRO31(p0, p1) / sqrt(d0 * d1))));
	    break;
	case DG_SPHERICAL:
	    d0 =INPRO31(p0, p0);
	    d1 =INPRO31(p1, p1);
	    return(acos( ABS( INPRO4(p0, p1) / sqrt(d0 * d1))));
	    break;

	}
    return (double)0;
}
Пример #25
0
void solve_cubic(double a, double b, double c, double d, int &N, double &x0, double &x1, double &x2)
{
    // 0 = ax^3 + b*x^2 + c*x + d
    
    // First check if the "cubic" is actually a second order or first order curve
    if (std::abs(a) < 10*DBL_EPSILON){
        if (std::abs(b) < 10*DBL_EPSILON){
            // Linear solution if a = 0 and b = 0
            x0 = -d/c;
            N = 1;
            return;
        }
        else{
            // Quadratic solution(s) if a = 0 and b != 0
            x0 = (-c+sqrt(c*c-4*b*d))/(2*b);
            x1 = (-c-sqrt(c*c-4*b*d))/(2*b);
            N = 2;
            return;
        }
    }
    
    // Ok, it is really a cubic

    // Discriminant
    double DELTA = 18*a*b*c*d-4*b*b*b*d+b*b*c*c-4*a*c*c*c-27*a*a*d*d;
    // Coefficients for the depressed cubic t^3+p*t+q = 0
    double p = (3*a*c-b*b)/(3*a*a);
    double q = (2*b*b*b-9*a*b*c+27*a*a*d)/(27*a*a*a);

    if (DELTA<0)
    {
        // One real root
        double t0;
        if (4*p*p*p+27*q*q>0 && p<0)
        {
            t0 = -2.0*std::abs(q)/q*sqrt(-p/3.0)*cosh(1.0/3.0*acosh(-3.0*std::abs(q)/(2.0*p)*sqrt(-3.0/p)));
        }
        else
        {
            t0 = -2.0*sqrt(p/3.0)*sinh(1.0/3.0*asinh(3.0*q/(2.0*p)*sqrt(3.0/p)));
        }
        N = 1;
        x0 = t0-b/(3*a);
        x1 = t0-b/(3*a);
        x2 = t0-b/(3*a);
    }
    else //(DELTA>0)
    {
        // Three real roots
        double t0 = 2.0*sqrt(-p/3.0)*cos(1.0/3.0*acos(3.0*q/(2.0*p)*sqrt(-3.0/p))-0*2.0*M_PI/3.0);
        double t1 = 2.0*sqrt(-p/3.0)*cos(1.0/3.0*acos(3.0*q/(2.0*p)*sqrt(-3.0/p))-1*2.0*M_PI/3.0);
        double t2 = 2.0*sqrt(-p/3.0)*cos(1.0/3.0*acos(3.0*q/(2.0*p)*sqrt(-3.0/p))-2*2.0*M_PI/3.0);

        N = 3;
        x0 = t0-b/(3*a);
        x1 = t1-b/(3*a);
        x2 = t2-b/(3*a);
    }
}
Пример #26
0
/* {{{ php_acosh
*/
static double php_acosh(double x)
{
#ifdef HAVE_ACOSH
    return(acosh(x));
#else
    return(log(x + sqrt(x * x - 1)));
#endif
}
Пример #27
0
double kepler_anomaly_true_to_eccentric(double e, double f) {
    if(zero(e - 1.0))
        return tan(f / 2.0);
    if(e > 1.0)
        return sign(f) * acosh((e + cos(f)) / (1.0 + e * cos(f)));

    return atan2(sqrt(1.0-e*e) * sin(f), cos(f) + e);
}
Пример #28
0
// Vector acosh
inline
GVector acosh(const GVector &v)
{
    GVector result(v.m_num);
    for (int i = 0; i < v.m_num; ++i)
        result.m_data[i] = acosh(v.m_data[i]);
    return result;
}
Пример #29
0
//TODO: Implement variable recovery
//Invert nth Chebyshev-Polynomial of first kind
double invert_Tn(const double value_in){
  const int n = pars -> get_int("DEG");
  //const int n = 8;
  double inv = 0;
  //double tmp = fabs(fmod(value_in,M_PI)-1);
  inv = cosh(1./n*acosh(value_in));
  return inv;
}
Пример #30
0
Файл: cosmo.c Проект: jpcoles/ZM
double csmExp2Time(CSM csm,double dExp) {
    double dOmega0 = csm->dOmega0;
    double dHubble0 = csm->dHubble0;
    double a0,A,B,eta;

    if (!csm->bComove) {
	/*
	 ** Invalid call!
	 */
	assert(0);
	}
    if (csm->dLambda == 0.0 && csm->dOmegaRad == 0.0) {
	if (dOmega0 == 1.0) {
	    assert(dHubble0 > 0.0);
	    if (dExp == 0.0) return(0.0);
	    return(2.0/(3.0*dHubble0)*pow(dExp,1.5));
	    }
	else if (dOmega0 > 1.0) {
	    assert(dHubble0 >= 0.0);
	    if (dHubble0 == 0.0) {
		B = 1.0/sqrt(dOmega0);
		eta = acos(1.0-dExp);
		return(B*(eta-sin(eta)));
		}
	    if (dExp == 0.0) return(0.0);
	    a0 = 1.0/dHubble0/sqrt(dOmega0-1.0);
	    A = 0.5*dOmega0/(dOmega0-1.0);
	    B = A*a0;
	    eta = acos(1.0-dExp/A);
	    return(B*(eta-sin(eta)));
	    }
	else if (dOmega0 > 0.0) {
	    assert(dHubble0 > 0.0);
	    if (dExp == 0.0) return(0.0);
	    a0 = 1.0/dHubble0/sqrt(1.0-dOmega0);
	    A = 0.5*dOmega0/(1.0-dOmega0);
	    B = A*a0;
	    eta = acosh(dExp/A+1.0);
	    return(B*(sinh(eta)-eta));
	    }
	else if (dOmega0 == 0.0) {
	    assert(dHubble0 > 0.0);
	    if (dExp == 0.0) return(0.0);
	    return(dExp/dHubble0);
	    }
	else {
	    /*
	     ** Bad value.
	     */
	    assert(0);
	    return(0.0);
	    }
	}
    else {
	return dRombergO(csm, (double (*)(void *, double)) csmCosmoTint,
			 0.0, pow(dExp, 1.5), EPSCOSMO);
	}
    }