当前位置: 首页>>代码示例>>C++>>正文


C++ Gamma函数代码示例

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


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

示例1: temp

rowvec GridBdry::interp_normal(cube u) {      //TODO
    rowvec temp = zeros<rowvec>(Gamma.n_rows);
    for(unsigned int i = 0; i < Gamma.n_rows; i++) {
        temp(i) = u(Gamma(i, 0), Gamma(i, 1), 0)*n(i, 0) + u(Gamma(i, 0), Gamma(i, 1), 1)*n(i, 1);
    }
    return temp;
}
开发者ID:BobMarly,项目名称:Wing-Design-Tool,代码行数:7,代码来源:GridBdry.cpp

示例2: Gamma

void ThreePhaseDecoder::makePhase() {
	int n = width * height;
	float i1, i2, i3;
	for (int i = 0; i < n; i++) {
		i1 = (float) graySequence[0][i];
		i2 = (float) graySequence[1][i];
		i3 = (float) graySequence[2][i];

		#ifdef USE_GAMMA
		i1 = Gamma(i1 / 255.0, gamma) * 255.0;
		i2 = Gamma(i2 / 255.0, gamma) * 255.0;
		i3 = Gamma(i3 / 255.0, gamma) * 255.0;
		#endif

		range[i] = findRange(i1, i2, i3);
		mask[i] = range[i] <= rangeThreshold;
		ready[i] = !mask[i];

		reflectivity[i] = (byte) ((i1 + i2 + i3) / 3);

		if(ready[i])
			phase[i] = atan2f(sqrtf(3) * (i1 - i3), 2.f * i2 - i1 - i3) / (float) TWO_PI;
	}
	#ifdef LINEARIZE_PHASE
	if(linearize) {
		buildLut();
		applyLut();
	}
	#endif
}
开发者ID:UnforeseenOcean,项目名称:TheJanusMachine,代码行数:30,代码来源:ThreePhaseDecoder.cpp

示例3: Gamma

// ===========================================================
double Gamma(double u)
{
// Only for two particular cases:
// u = integer
// u = integer + 0.5
	int cas;
	double G;
	int i;
	int k;
	
	k=(int)(u+0.5);
	if(fabs(k-(int)u)<0.5) cas=1; else cas=2;
	
	switch(cas)
	{
		case 1: // u integer
		if(k==1) return 1;
			G=1;
			for(i=2;i<k;i++) G=G*i;
			return G;
		
		case 2: // u = k +1/2. We use the duplication formula
		k=k-1;  	
		G=sqrt(pi)*pow(2,1-2*k)*Gamma(2*k)/Gamma(k);
		return G;
		default:
		ERROR("tools 79. In Gamma, u %f is neither inter nor half-integer");
	}
}
开发者ID:poornimac1,项目名称:popot,代码行数:30,代码来源:tools.c

示例4: FDistPDF

 /// Probabiliy density function for F distribution
 /// The F distribution is the ratio of two chi-square distributions with degrees
 /// of freedom N1 and N2, respectively, where each chi-square has first been
 /// divided by its degrees of freedom.
 /// An F-test (Snedecor and Cochran, 1983) is used to test if the standard
 /// deviations of two populations are equal. This test can be a two-tailed test or
 /// a one-tailed test.
 /// The F hypothesis test is defined as:
 ///   H0:   s1 = s2     (sN is sigma or std deviation)
 ///   Ha:   s1 < s2     for a lower one tailed test
 ///         s1 > s2     for an upper one tailed test
 ///         s1 != s2    for a two tailed test 
 /// Test Statistic: F = s1^2/s2^2 where s1^2 and s2^2 are the sample variances.
 /// The more this ratio deviates from 1, the stronger the evidence for unequal
 /// population variances. Significance Level is alpha, a probability (0<=alpha<=1).
 /// The hypothesis that the two standard deviations are equal is rejected if
 ///    F > PP(alpha,N1-1,N2-1)     for an upper one-tailed test
 ///    F < PP(1-alpha,N1-1,N2-1)     for a lower one-tailed test
 ///    F < PP(1-alpha/2,N1-1,N2-1)   for a two-tailed test
 ///    F > PP(alpha/2,N1-1,N2-1)
 /// where PP(alpha,k-1,N-1) is the percent point function of the F distribution
 /// [PPfunc is inverse of the CDF : PP(alpha,N1,N2) == F where alpha=CDF(F,N1,N2)]
 /// with N1 and N2 degrees of freedom and a significance level of alpha. 
 /// 
 /// Ref http://www.itl.nist.gov/div898/handbook/ 1.3.6.6.5
 /// @param x probability or significance level of the test, >=0 and < 1
 /// @param n1   degrees of freedom of first sample, n1 > 0
 /// @param n2   degrees of freedom of second sample, n2 > 0
 /// @return         the statistic (a ratio variance1/variance2) at this prob
 double FDistPDF(double x, int n1, int n2) throw(Exception)
 {
    try {
       double dn1(n1),dn2(n2);
       double F = Gamma((dn1+dn2)/2.0) / (Gamma(dn1/2.0)*Gamma(dn2/2.0));
       F *= ::pow(dn1/dn2,dn1/2.0) * ::pow(x,dn1/2.0 - 1.0);
       F /= ::pow(1.0+x*dn1/dn2,(dn1+dn2)/2.0);
       return F;
    }
    catch(Exception& e) { GPSTK_RETHROW(e); }
 }
开发者ID:vestuto,项目名称:GPSTk,代码行数:40,代码来源:SpecialFuncs.hpp

示例5: sprintf

// Load B-V conversion parameters from config file
void StelSkyDrawer::initColorTableFromConfigFile(QSettings* conf)
{
	std::map<float,Vec3f> color_map;
	for (float bV=-0.5f;bV<=4.0f;bV+=0.01)
	{
		char entry[256];
		sprintf(entry,"bv_color_%+5.2f",bV);
		const QStringList s(conf->value(QString("stars/") + entry).toStringList());
		if (!s.isEmpty())
		{
			Vec3f c;
			if (s.size()==1)
				c = StelUtils::strToVec3f(s[0]);
			else
				c =StelUtils::strToVec3f(s);
			color_map[bV] = Gamma(eye->getDisplayGamma(),c);
		}
	}

	if (color_map.size() > 1)
	{
		for (int i=0;i<128;i++)
		{
			const float bV = StelSkyDrawer::indexToBV(i);
			std::map<float,Vec3f>::const_iterator greater(color_map.upper_bound(bV));
			if (greater == color_map.begin())
			{
				colorTable[i] = greater->second;
			}
			else
			{
				std::map<float,Vec3f>::const_iterator less(greater);--less;
				if (greater == color_map.end())
				{
					colorTable[i] = less->second;
				}
				else
				{
					colorTable[i] = Gamma(1.f/eye->getDisplayGamma(), ((bV-less->first)*greater->second + (greater->first-bV)*less->second) *(1.f/(greater->first-less->first)));
				}
			}
		}
	}

// 	QString res;
// 	for (int i=0;i<128;i++)
// 	{
// 		res += QString("Vec3f(%1,%2,%3),\n").arg(colorTable[i][0], 0, 'g', 6).arg(colorTable[i][1], 0, 'g', 6).arg(colorTable[i][2], 0, 'g', 6);
// 	}
// 	qDebug() << res;
}
开发者ID:huiqingz,项目名称:stellarium-to-oculus,代码行数:52,代码来源:StelSkyDrawer.cpp

示例6: besselpoly

double besselpoly(double a, double lambda, double nu) {

  int m, factor=0;
  double Sm, relerr, Sol;
  double sum=0.0;

  /* Special handling for a = 0.0 */
  if (a == 0.0) {
    if (nu == 0.0) return 1.0/(lambda + 1);
    else return 0.0;
  }
  /* Special handling for negative and integer nu */
  if ((nu < 0) && (floor(nu)==nu)) {
    nu = -nu;
    factor = ((int) nu) % 2;
  }    
  Sm = exp(nu*log(a))/(/*cephes_*/Gamma(nu+1)*(lambda+nu+1));
  m = 0;
  do {
    sum += Sm;
    Sol = Sm;
    Sm *= -a*a*(lambda+nu+1+2*m)/((nu+m+1)*(m+1)*(lambda+nu+1+2*m+2));
    m++;
    relerr = fabs((Sm-Sol)/Sm);
  } while (relerr > EPS && m < 1000);
  if (!factor)
    return sum;
  else
    return -sum;
}
开发者ID:darrylwally,项目名称:libmva,代码行数:30,代码来源:besselpoly.c

示例7: autonomous

task autonomous()
{
    StartTask(descore);

    StartTask(velocitycalculator);

    if(SensorValue[J1]) // blue
    {
        if(SensorValue[J2]) //normal
        {
            // RAM
            ArmWall();

            ForwardTillStop(127);

        }
        else // oppo
        {
            Gamma();
        }
    }
    else // red
    {
        if(SensorValue[J2]) // normal
        {
            Beta();
        }
        else // oppo
        {
            Delta();
        }
    }

    StopTask(velocitycalculator);
}
开发者ID:Skeer,项目名称:5000A,代码行数:35,代码来源:Autonomous.c

示例8: _nbi

void MR::calcMagnetizations() {
    for( size_t i = 0; i < G.nrNodes(); i++ ) {
        if( props.updates == Properties::UpdateType::FULL ) {
            // find indices in nb(i)
            sub_nb _nbi( G.nb(i).size() );
            _nbi.set();

            // calc numerator1 and denominator1
            Real sum_even, sum_odd;
            sum_subs(i, _nbi, &sum_even, &sum_odd);

            Mag[i] = (tanh(theta[i]) * sum_even + sum_odd) / (sum_even + tanh(theta[i]) * sum_odd);

        } else if( props.updates == Properties::UpdateType::LINEAR ) {
            sub_nb empty( G.nb(i).size() );
            Mag[i] = T(i,empty);

            for( size_t _l1 = 0; _l1 < G.nb(i).size(); _l1++ )
                for( size_t _l2 = _l1 + 1; _l2 < G.nb(i).size(); _l2++ )
                    Mag[i] += Gamma(i,_l1,_l2) * tJ[i][_l1] * tJ[i][_l2] * cors[i][_l1][_l2];
        }
        if( abs( Mag[i] ) > 1.0 )
            Mag[i] = (Mag[i] > 0.0) ? 1.0 : -1.0;
    }
}
开发者ID:AndrewNguyenF3,项目名称:libdai,代码行数:25,代码来源:mr.cpp

示例9: rf_gauss

double rf_gauss (double d2, const double *a)
{   /* --- (general.) Gaussian function */
    double ma;                    /* temporary buffer for m/a */

    if (d2 < 0) {                 /* if to the get normalization factor */
        if (a[0] <= 0) return 0;    /* check whether the integral exists */
        if (a[0] == 2)              /* use simplified formula for a = 2 */
            return pow(2*M_PI, 0.5*d2);
        ma = -d2 /a[0];
        d2 *= -0.5; /* m/a and m/2 (m = number of dims.) */
        return (a[0] *Gamma(d2)) / (pow(2, ma+1) *pow(M_PI, d2) *Gamma(ma));
    }                             /* return the normalization factor */
    if (a[0] != 2)                /* raise distance to the given power */
        d2 = pow(d2, 0.5*a[0]);     /* (note that d2 is already squared) */
    return exp(-0.5 *d2);         /* compute Gaussian function */
}  /* rf_gauss() */
开发者ID:sridhar19091986,项目名称:datamining,代码行数:16,代码来源:radfn.c

示例10: errMsg

//__________________________________________________________________________________
_PMathObj _Constant::IGamma (_PMathObj arg)
{
    if (arg->ObjectClass()!=NUMBER) {
        _String errMsg ("A non-numerical argument passed to IGamma(a,x)");
        WarnError (errMsg);
        return new _Constant (0.0);
    }
    _Parameter x = ((_Constant*)arg)->theValue, sum=0.0;
    if (x>1e25) {
        x=1e25;
    } else if (x<0) {
        _String errMsg ("The domain of x is {x>0} for IGamma (a,x)");
        WarnError (errMsg);
        return new _Constant (0.0);
    } else if (x==0.0) {
        return new _Constant (0.0);
    }


    if (x<=theValue+1) // use the series representation
        // IGamma (a,x)=exp(-x) x^a \sum_{n=0}^{\infty} \frac{\Gamma((a)}{\Gamma(a+1+n)} x^n
    {
        _Parameter term = 1.0/theValue, den = theValue+1;
        long count = 0;
        while ((fabs(term)>=fabs(sum)*machineEps)&&(count<500)) {
            sum+=term;
            term*=x/den;
            den += 1.0;
            count++;
        }
    } else // use the continue fraction representation
        // IGamma (a,x)=exp(-x) x^a 1/x+/1-a/1+/1/x+/2-a/1+/2/x+...
    {
        _Parameter lastTerm = 0, a0 = 1.0, a1 = x, b0 = 0.0, b1 = 1.0, factor = 1.0, an, ana, anf;
        for (long count = 1; count<500; count++) {
            an = count;
            ana = an - theValue;
            a0 = (a1+a0*ana)*factor;
            b0 = (b1+b0*ana)*factor;
            anf = an*factor;
            a1  = x*a0+anf*a1;
            b1  = x*b0+anf*b1;
            if (a1!=0.0) {
                factor=1.0/a1;
                sum = b1*factor;
                if (fabs(sum-lastTerm)/sum<machineEps) {
                    break;
                }
                lastTerm = sum;
            }

        }
    }
    _Constant *result = (_Constant*)Gamma();
    result->SetValue(sum*exp(-x+theValue*log(x))/result->theValue);
    if (x>theValue+1) {
        result->SetValue (1.0-result->theValue);
    }
    return result;
}
开发者ID:HyperionRiaz,项目名称:hyphy,代码行数:61,代码来源:constant.cpp

示例11: dimensionedScalar

tmp<fvMatrix<Type> >
laplacian
(
    GeometricField<Type, fvPatchField, volMesh>& vf
)
{
    surfaceScalarField Gamma
    (
        IOobject
        (
            "1",
            vf.time().constant(),
            vf.mesh(),
            IOobject::NO_READ
        ),
        vf.mesh(),
        dimensionedScalar("1", dimless, 1.0)
    );

    return fvm::laplacian
    (
        Gamma,
        vf,
        "laplacian(" + vf.name() + ')'
    );
}
开发者ID:CFMS,项目名称:foam-extend-foam-extend-3.2,代码行数:26,代码来源:fvmLaplacian.C

示例12: FinalKick

void FinalKick(particle_t *SPH, double dt){
	#pragma omp parallel for
	for(int i = 0 ; i < N_SPHP ; ++ i){
		SPH[i].v = SPH[i].v_h + 0.5 * dt * SPH[i].a    ;
		SPH[i].u = SPH[i].u_h + 0.5 * dt * SPH[i].u_dot;
		SPH[i].Y = SPH[i].Y_h + 0.5 * dt * SPH[i].m * (Gamma(SPH[i].rho, SPH[i].u, SPH[i].p_smth) - 1.0) * SPH[i].u_dot;
	}
}
开发者ID:NatsukiHosono,项目名称:pfSPH,代码行数:8,代码来源:integral.cpp

示例13: TimeEvolve

/*
void TimeEvolve(particle_t *SPH, double dt){
	#pragma omp parallel for
	for(int i = 0 ; i < N_SPHP ; ++ i){
		SPH[i].r   += SPH[i].v * dt + 0.5 * SPH[i].a * dt * dt;
		SPH[i].v   += SPH[i].a * dt;
		SPH[i].u   += SPH[i].u_dot * dt;
		SPH[i].rho += - SPH[i].rho * SPH[i].div_v * dt;
		SPH[i].h   += SPH[i].h * SPH[i].div_v * dt;
	}
}
*/
void InitialKick(particle_t *SPH, double dt){
	#pragma omp parallel for
	for(int i = 0 ; i < N_SPHP ; ++ i){
		SPH[i].v_h = SPH[i].v + 0.5 * dt * SPH[i].a    ;
		SPH[i].u_h = SPH[i].u + 0.5 * dt * SPH[i].u_dot;//Gammaにsmoothed pを送るのはすごく重要。
		SPH[i].Y_h = SPH[i].Y + 0.5 * dt * SPH[i].m * (Gamma(SPH[i].rho, SPH[i].u, SPH[i].p_smth) - 1.0) * SPH[i].u_dot;
	}
}
开发者ID:NatsukiHosono,项目名称:pfSPH,代码行数:20,代码来源:integral.cpp

示例14: Predict

void Predict(particle_t *SPH, double dt){
	#pragma omp parallel for
	for(int i = 0 ; i < N_SPHP ; ++ i){
		SPH[i].v += dt * SPH[i].a    ;
		SPH[i].u += dt * SPH[i].u_dot;
		SPH[i].Y += dt * SPH[i].m * (Gamma(SPH[i].rho, SPH[i].u, SPH[i].p_smth) - 1.0) * SPH[i].u_dot;
	}
}
开发者ID:NatsukiHosono,项目名称:pfSPH,代码行数:8,代码来源:integral.cpp

示例15: Dirichlet

/* Returns a sample from Dirichlet(n,a) where n is dimensionality */
int Dirichlet(RndState *S, long n, double *a, double *x)
{
	long i;
	double tot=0, z;
	for (i=0; i<n; i++) { z=Gamma(S,a[i]); tot+=z; x[i]=z; }
	for (i=0; i<n; i++) { x[i]/=tot; }
	return 1;
}
开发者ID:samer--,项目名称:plrand,代码行数:9,代码来源:rndutils.c


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