• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ erf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中erf函数的典型用法代码示例。如果您正苦于以下问题:C++ erf函数的具体用法?C++ erf怎么用?C++ erf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了erf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: simult_chi_huber

double
vpRobust::simultscale(vpColVector &x)
{
  unsigned int p = 6; //Number of parameters to be estimated.
  unsigned int n = x.getRows();
  double sigma2=0;
  /* long */ double Expectation=0;
  /* long */ double Sum_chi=0;
  /* long */ double chiTmp =0;

  for(unsigned int i=0; i<n; i++)
  {

    chiTmp = simult_chi_huber(x[i]);
    Expectation += chiTmp*(1-erf(chiTmp));
    Sum_chi += chiTmp;

#ifdef VP_DEBUG
#if VP_DEBUG_MODE == 3
    {
      std::cout << "erf = " << 1-erf(chiTmp) << std::endl;
      std::cout << "x[i] = " << x[i] <<std::endl;
      std::cout << "chi = " << chiTmp << std::endl;
      std::cout << "Sum chi = " << chiTmp*vpMath::sqr(sig_prev) << std::endl;
      std::cout << "Expectation = " << chiTmp*(1-erf(chiTmp)) << std::endl;
      //getchar();
    }
#endif
#endif
  }


  sigma2 = Sum_chi*vpMath::sqr(sig_prev)/((n-p)*Expectation);

#ifdef VP_DEBUG
#if VP_DEBUG_MODE == 3
  {
    std::cout << "Expectation = " << Expectation << std::endl;
    std::cout << "Sum chi = " << Sum_chi << std::endl;
    std::cout << "sig_prev" << sig_prev << std::endl;
    std::cout << "sig_out" << sqrt(fabs(sigma2)) << std::endl;
  }
#endif
#endif

  return sqrt(fabs(sigma2));

}
开发者ID:DaikiMaekawa,项目名称:visp,代码行数:48,代码来源:vpRobust.cpp


示例2: erf

Foam::scalar Foam::distributionModels::normal::sample() const
{

    scalar a = erf((minValue_ - expectation_)/variance_);
    scalar b = erf((maxValue_ - expectation_)/variance_);

    scalar y = rndGen_.sample01<scalar>();
    scalar x = erfInv(y*(b - a) + a)*variance_ + expectation_;

    // Note: numerical approximation of the inverse function yields slight
    //       inaccuracies

    x = min(max(x, minValue_), maxValue_);

    return x;
}
开发者ID:000861,项目名称:OpenFOAM-2.1.x,代码行数:16,代码来源:normal.C


示例3: erf

Foam::scalar Foam::pdfs::lognormal::sample() const
{

    scalar a = erf((minValue_ - expectation_)/variance_);
    scalar b = erf((maxValue_ - expectation_)/variance_);

    scalar y = rndGen_.scalar01();
    scalar x = erfInv(y*(b - a) + a)*variance_ + expectation_;

    // Note: numerical approximation of the inverse function yields slight
    //       inaccuracies

    x = min(max(exp(x), exp(minValue_)), exp(maxValue_));

    return log(x);
}
开发者ID:rbpiccinini,项目名称:codes,代码行数:16,代码来源:lognormal.C


示例4: trans_unif

static double trans_unif(double x , const arg_pack_type * arg) {
  double y;
  double min   = arg_pack_iget_double(arg , 0);
  double max   = arg_pack_iget_double(arg , 1);
  y = 0.5*(1 + erf(x/sqrt(2.0))); /* 0 - 1 */
  return y * (max - min) + min;
}
开发者ID:JacobStoren,项目名称:ert,代码行数:7,代码来源:trans_func.c


示例5: function

 double function(const double phi, double **data)
 {
   double alfa = (*data[2]);
   double tau = (*data[3]); 
   double X = erf((tau * phi - alfa) / sqrt((1 - tau) * (1 + tau)));
   return X * X * exp(- phi * phi / 2); // / (*data[4]);
 }
开发者ID:mikaem,项目名称:PMFpack,代码行数:7,代码来源:Integrator.cpp


示例6: erf

double
Partitioner::CodeCriteria::get_vote(const RegionStats *stats, std::vector<double> *votes) const
{
    if (votes!=NULL)
        votes->resize(dictionary.size(), NAN);

    double sum=0.0, total_wt=0.0;
    for (size_t cc_id=0; cc_id<criteria.size(); ++cc_id) {
        if (criteria[cc_id].weight <= 0.0)
            continue;

        size_t stat_id = stats->find_analysis(get_name(cc_id));
        if (-1==(ssize_t)stat_id)
            continue;

        double stat_val = stats->get_value(stat_id);
        if (!std::isnan(stat_val)) {
            double c = 0.0==criteria[cc_id].variance ?
                       (stat_val==criteria[cc_id].mean ? 1.0 : 0.0) :
                       1 + erf(-fabs(stat_val-criteria[cc_id].mean) / sqrt(2*criteria[cc_id].variance));
            if (votes)
                (*votes)[cc_id] = c;
            if (!std::isnan(c)) {
                sum += c * criteria[cc_id].weight;
                total_wt += criteria[cc_id].weight;
            }
        }
    }
    return total_wt>0.0 ? sum / total_wt : NAN;
}
开发者ID:Root-nix,项目名称:rose,代码行数:30,代码来源:PStatistics.C


示例7: sqrt

//! inverse error function is taken from NIST
double userFunctions::erfinv (double x)
{
    if (x < -1 || x > 1)
        return NAN;
    
    if (x == 0)
        return 0;
    
    int  sign_x;
    if (x > 0) {
        sign_x = 1;
    } else {
        sign_x = -1;
        x = -x;
    }
    
    double r;
    if (x <= 0.686) {
        double x2 = x * x;
        r = x * (((-0.140543331 * x2 + 0.914624893) * x2 + -1.645349621) * x2 + 0.886226899);
        r /= (((0.012229801 * x2 + -0.329097515) * x2 + 1.442710462) * x2 + -2.118377725) * x2 + 1;
    } else {
        double y = sqrt (-log((1 - x) / 2));
        r = (((1.641345311 * y + 3.429567803) * y + -1.62490649) * y + -1.970840454);
        r /= ((1.637067800 * y + 3.543889200) * y + 1);
    }
    
    r *= sign_x;
    x *= sign_x;
    
    r -= (erf(r) - x) / (2 / sqrt (M_PI) * exp(-r*r));
    
    return r;
}
开发者ID:auterpe,项目名称:Smilei_SEF,代码行数:35,代码来源:userFunctions.cpp


示例8: ndtr

double ndtr(double a)
{
double x, y, z;

if (isnan(a)) {
  mtherr("ndtr", DOMAIN);
  return (NAN);
}

x = a * SQRTH;
z = fabs(x);

if( z < SQRTH )
	y = 0.5 + 0.5 * erf(x);

else
	{
	y = 0.5 * erfc(z);

	if( x > 0 )
		y = 1.0 - y;
	}

return(y);
}
开发者ID:SaulAryehKohn,项目名称:aipy,代码行数:25,代码来源:ndtr.c


示例9: l_erf

static double
l_erf(char *nm)
{
    extern double  erf();

    return(erf(argument(1)));
}
开发者ID:MITSustainableDesignLab,项目名称:Daysim,代码行数:7,代码来源:biggerlib.c


示例10: Phi

/*c.d.f of Standard Normal*/
double Phi(double x)
{
  double tmp=x/sqrt(2.);
  tmp=1+erf(tmp); 

  return tmp/2;
}
开发者ID:mallyvai,项目名称:hashbash,代码行数:8,代码来源:df.c


示例11: cephes_normal

double
cephes_normal(double x)
{
	double arg, result, sqrt2=1.414213562373095048801688724209698078569672;

	if (x > 0) {
		arg = x/sqrt2;
		result = 0.5 * ( 1 + erf(arg) );
	}
	else {
		arg = -x/sqrt2;
		result = 0.5 * ( 1 - erf(arg) );
	}

	return( result);
}
开发者ID:drazil1234,项目名称:StreamCoding,代码行数:16,代码来源:cephes.c


示例12: WarningIn

void Foam::equationReader::evalDimsErfDimCheck
(
    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::evalDimsErfDimCheck")
            << "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, 0.0);
    xDims.reset(erf(ds).dimensions());
    operator[](index)[i].assignOpDimsFunction
    (
        &Foam::equationReader::evalDimsErf
    );
}
开发者ID:Unofficial-Extend-Project-Mirror,项目名称:openfoam-extend-Breeder1.6-libraries-equationReaderExtension,代码行数:33,代码来源:equationReaderEvalDimsP.C


示例13: evalf

ex evalf( const ex& x )
{
	if( is_a<numeric>(x) )
		return bealab::erf( ex_to<numeric>(x).to_double() );
	else
		return erf(x).hold();
}
开发者ID:damianmarelli,项目名称:bealab,代码行数:7,代码来源:symbolic.cpp


示例14: ATF_TC_BODY

ATF_TC_BODY(erf_inf_pos, tc)
{
	const double x = 1.0L / 0.0L;

	if (erf(x) != 1.0)
		atf_tc_fail_nonfatal("erf(+Inf) != 1.0");
}
开发者ID:2asoft,项目名称:freebsd,代码行数:7,代码来源:t_erf.c


示例15: BoysFunction

/* ************************************************************************** */
solreal BoysFunction(const int m,solreal x)
{
   static const solreal srpo2=0.88622692545275801365e0; //$\sqrt{\pi}/2$
   solreal srx=sqrt(x);
   solreal F0=srpo2*erf(srx)/srx;
   if (m==0) {return F0;}
   solreal emx=exp(-x);
   solreal oo2x=0.5e0/x;
   if (m==1) {return ((F0-emx)*oo2x);}
   solreal oo2x2=oo2x*oo2x;
   if (m==2) {return (3.0e0*F0*oo2x2-emx*(oo2x+3.0e0*oo2x2));}
   solreal oo2x3=oo2x*oo2x2;
   if (m==3) {return (15.0e0*F0*oo2x3-emx*(oo2x+5.0e0*oo2x2+15.0e0*oo2x3));}
   solreal oo2x4=oo2x2*oo2x2;
   //std::cout << "oo2x4: " << oo2x4 << std::endl;
   if (m==4) {return (105.0e0*F0*oo2x4-emx*(oo2x+7.0e0*oo2x2+35.0e0*oo2x3+105.0e0*oo2x4));}
   solreal oo2x5=oo2x3*oo2x2;
   //std::cout << "oo2x5: " << oo2x5 << std::endl;
   if (m==5) {
      return (945.0e0*F0*oo2x5-emx*(oo2x+9.0e0*oo2x2+63.0e0*oo2x3+315.0e0*oo2x4+945.0e0*oo2x5));
   }
   solreal oo2x6=oo2x3*oo2x3;
   //std::cout << "oo2x6: " << oo2x6 << std::endl;
   if (m==6) {
      return (10395.0e0*F0*oo2x6-emx*(oo2x+11.0e0*oo2x2+99.0e0*oo2x3+693.0e0*oo2x4
                                       +3465.0e0*oo2x5+10395.0e0*oo2x6));
   }
#if DEBUG
   std::cout << "This value of m (" << m << ") is not implemented yet..." << std::endl;
#endif
   return 0.0e0;
}
开发者ID:jmsolano,项目名称:denstoolkit,代码行数:33,代码来源:solmath.cpp


示例16: g1

 float g1(const Vector& v, const Vector& m) const {
   if(dot(v, m) * Bsdf::cos_theta(v) <= 0.f) {
     return 0.f;
   }
   float a = Bsdf::cos_theta(v) / (this->alpha_b * Bsdf::sin_theta(v));
   return 2.f / (1.f + erf(a) + exp(-square(a)) / (a * SQRT_PI));
 }
开发者ID:honzasp,项目名称:dort,代码行数:7,代码来源:microfacet_distrib.hpp


示例17: main

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;
}
开发者ID:DanielMiklody,项目名称:openmeeg,代码行数:35,代码来源:have_ieee_math.cpp


示例18: main

int main(void)
{
	#pragma STDC FENV_ACCESS ON
	double y;
	float d;
	int e, i, err = 0;
	struct d_d *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = erf(p->x);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexcept(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s erf(%a)=%a, want %s",
				p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperr(y, p->y, p->dy);
		if (!checkulp(d, p->r)) {
			printf("%s:%d: %s erf(%a) want %a got %a ulperr %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
			err++;
		}
	}
	return !!err;
}
开发者ID:andrey-gvrd,项目名称:rusl,代码行数:33,代码来源:erf.c


示例19: sqrt

double Novosibirsk::Normalisation(PhaseSpaceBoundary * boundary)
{
	(void) boundary;
	
	// Get the physics parameters
	width = allParameters.GetPhysicsParameter( widthName )->GetValue();
	peak  = allParameters.GetPhysicsParameter( peakName )->GetValue();
	tail  = allParameters.GetPhysicsParameter( tailName )->GetValue();

	double tailLog4 = tail * sqrt(log(4.));
	double widthLog4 = width * sqrt(log(4.));
	double _sinh = sinh(tailLog4);
	double _csch = 1./sinh(tailLog4);
	
	double val(0.);

	double xhigh = 0.12;
	double xlow = 0.;
	
	//cout << - width*tail*sqrt(TMath::Pi()*log(2.))*_csch*erf( ( tail*tail - log( (xhigh - peak)*_sinh/widthLog4 + 1. ) ) / (sqrt(2.)*tail) ) << endl;
	//cout << + width*tail*sqrt(TMath::Pi()*log(2.))*_csch*erf( ( tail*tail - log( (xlow  - peak)*_sinh/widthLog4 + 1. ) ) / (sqrt(2.)*tail) ) << endl;

	val = - width*tail*sqrt(TMath::Pi()*log(2.))*_csch*erf( ( tail*tail - log( (xhigh - peak)*_sinh/widthLog4 + 1. ) ) / (sqrt(2.)*tail) );
	      //+ width*tail*sqrt(TMath::Pi()*log(2.))*_csch*erf( ( tail*tail - log( (xlow  - peak)*_sinh/widthLog4 + 1. ) ) / (sqrt(2.)*tail) );

	return 2.*val;
}
开发者ID:abmorris,项目名称:RapidFit,代码行数:27,代码来源:Novosibirsk.cpp


示例20: erfc

/* Implementation of complementary Error function */
double
erfc(double x)
{
  static const double one_sqrtpi=  0.564189583547756287;
  double a = 1;
  double b = x;
  double c = x;
  double d = x*x+0.5;
  double q1;
  double q2 = b/d;
  double n = 1.0;
  double t;
  if (fabs(x) < 2.2) {
    return 1.0 - erf(x);
  }
  if (x < 0.0) { /*signbit(x)*/
    return 2.0 - erfc(-x);
  }
  do {
    t  = a*n+b*x;
    a  = b;
    b  = t;
    t  = c*n+d*x;
    c  = d;
    d  = t;
    n += 0.5;
    q1 = q2;
    q2 = b/d;
  } while (fabs(q1-q2)/q2 > MATH_TOLERANCE);
  return one_sqrtpi*exp(-x*x)*q2;
}
开发者ID:Bovi-Li,项目名称:mruby,代码行数:32,代码来源:math.c



注:本文中的erf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ erfc函数代码示例发布时间:2022-05-30
下一篇:
C++ ereport函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap