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


C++ powl函数代码示例

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


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

示例1: powl

long double probability_functions::power_law_inverse(long double probability)
{
	long double d0, rho, lambda;

#if D0_1
	d0 = 1;
#endif

#if RHO_0_5
	rho = 0.5;
#endif
#if RHO_0_7
	rho = 0.7;
#endif
#if RHO_0_9
	rho = 0.9;
#endif

#if LAMBDA_0_75
	lambda = 0.75;
#endif
#if LAMBDA_1
	lambda = 1;
#endif
#if LAMBDA_1_25
	lambda = 1.25;
#endif

	//return (powl(rho / probability, 1.0 / lambda) - d0) / 10;
	return powl(rho / probability, 1 / lambda) - d0;

	return powl(rho / (probability + 0.1), 1 / lambda) - d0;
}
开发者ID:ld844870209,项目名称:PINOCCHIO,代码行数:33,代码来源:probability_functions.cpp

示例2: main

int main(void)
{
  int i;
  long double j, x, y, z;

  y = 1.0;
  x = -5.5;
  
  j = 1.0;

  printf( "      i           z/100000.0                  1/y \n\n" );

  for(i=1; i<=25; i++)
    {
      j *= i;
      z = floor( powl(-1.0, i) + ((powl(-x, i) *(100000.0/j))) + ((2.0/powl(((-x)*(-x)), 2.0*i)) *((2.0/100000.0)/(2.0/j))));
      y += ( z/100000.0 );

      printf( "      %d      %'.16Lf      %'.16Lf \n", i, z/100000.0, 1/y );

    }

  printf( "      real value of exp(-5.5) = %'.16Lf\n", (long double) exp(-5.5) );
  return 0;
}
开发者ID:leventguel,项目名称:c-lang-exercises,代码行数:25,代码来源:ex49.c

示例3: stirf

static long double stirf(long double x)
{
	long double y, w, v;

	w = 1.0L/x;
	/* For large x, use rational coefficients from the analytical expansion.  */
	if (x > 1024.0L)
		w = (((((6.97281375836585777429E-5L * w
		      + 7.84039221720066627474E-4L) * w
		      - 2.29472093621399176955E-4L) * w
		      - 2.68132716049382716049E-3L) * w
		      + 3.47222222222222222222E-3L) * w
		      + 8.33333333333333333333E-2L) * w
		      + 1.0L;
	else
		w = 1.0L + w * polevll( w, STIR, 8 );
	y = expl(x);
	if (x > MAXSTIR)
	{ /* Avoid overflow in pow() */
		v = powl(x, 0.5L * x - 0.25L);
		y = v * (v / y);
	}
	else
	{
		y = powl(x, x - 0.5L) / y;
	}
	y = SQTPI * y * w;
	return (y);
}
开发者ID:YunusIncredibl,项目名称:mingw-w64-crt,代码行数:29,代码来源:tgammal.c

示例4: updateBTX

void updateBTX(pulsar *psr,double val,double err,int pos,int k)
{
    if (pos==param_fb)
    {
        psr->param[param_fb].val[k] += (val/powl(1.0e7,k+1));
        psr->param[param_fb].err[k]  = err/powl(1.0e7,k+1);
    }
    else if (pos==param_a1 || pos==param_ecc || pos==param_t0 || pos==param_gamma || pos==param_edot)
    {
        psr->param[pos].val[0] += val;
        psr->param[pos].err[0]  = err;
    }
    else if (pos==param_om)
    {
        psr->param[pos].val[0] += val*180.0/M_PI;
        psr->param[pos].err[0]  = err*180.0/M_PI;
    }
    else if (pos==param_pbdot)
    {
        psr->param[pos].val[0] += val;
        psr->param[pos].err[0]  = err;
    }
    else if (pos==param_omdot)
    {
        psr->param[pos].val[0] += val*(SECDAY*365.25)*180.0/M_PI;
        psr->param[pos].err[0]  = err*(SECDAY*365.25)*180.0/M_PI;
    }
    else if (pos==param_a1dot)
    {
        psr->param[pos].val[0] += val;
        psr->param[pos].err[0]  = err;
    }
}
开发者ID:gdesvignes,项目名称:tempo2,代码行数:33,代码来源:BTXmodel.C

示例5: cmrpirpj

long double cmrpirpj(vec rpi, vec rpj)
{
  long double cmij;
  
  cmij = (powl((rpi[0]-rpj[0]),2)+powl((rpi[1]-rpj[1]),2)+powl((rpi[2]-rpj[2]),2))/2.;
  return(cmij);
}
开发者ID:abensonca,项目名称:mangle,代码行数:7,代码来源:healpixpolys.c

示例6: productFib

ull* productFib(ull prod) {

        ull *out = malloc(3 * sizeof(ull*));
        ull isfib = 1;
        long double golden = 1.6180339887498948482;
        long double srfive = 2.2360679774997896964;
        long double p = (long double)prod;
        long double n, m, r, t;

        n = roundl(sqrtl(p / golden));
        m = p / n;
        r = fmodl(p, n);

        if (r > 0) {
                isfib = 0;
                t = floorl(logl(n * srfive) / logl(golden)) + 1;
                n = roundl(powl(golden, t) / srfive);
                m = roundl(powl(golden, t + 1) / srfive);
        }

        out[0] = (ull)n;
        out[1] = (ull)m;
        out[2] = isfib;
        return out;
}
开发者ID:dendres,项目名称:c-play,代码行数:25,代码来源:fibprod.c

示例7: do_test

static int
do_test (void)
{
    int result = 0;

#ifndef NO_LONG_DOUBLE
# if LDBL_MANT_DIG == 64
    {
        long double x = 1e-20;
        union ieee854_long_double u;
        u.ieee.mantissa0 = 1;
        u.ieee.mantissa1 = 1;
        u.ieee.exponent = 0;
        u.ieee.negative = 0;
        (void) powl (0.2, u.d);
        x = powl (x, 1.5);
        if (fabsl (x - 1e-30) > 1e-10)
        {
            printf ("powl (1e-20, 1.5): wrong result: %Lg\n", x);
            result = 1;
        }
    }
# endif
#endif

    return result;
}
开发者ID:jnaulet,项目名称:glibc,代码行数:27,代码来源:test-powl.c

示例8: pixel_start

int pixel_start(int res, char scheme){

  //int res1;
  //long double res_d;
  
  if(res<0){
    fprintf(stderr, "error in pixel_start: %d not a valid resolution.\n", res);
    return(-1);
  }
  
  if(scheme=='s'){
    return ((int)((powl(4,res)-1)/3));
  }
  else if(scheme=='d'){
    //res_d = (long double)(logl((long double)res)/logl(2.0))+1;
    //res1 = (int)(res_d + 0.1);
    //printf("pixel_start: res = %d\n", res);
    if(res==0) return(0);
    else if(res==1) return(1);
    else return (468*(((int)powl(4,res-1)-4)/12)+118);
  }
  else{
    fprintf(stderr, "error in pixel_start: pixel scheme %c not recognized.\n", scheme);
    return(-1);  
  }
  
}  
开发者ID:ready4euclid,项目名称:pipeline,代码行数:27,代码来源:which_pixel.c

示例9: run_triangle

void run_triangle(unsigned long max_bits, double ratio)
{
   int max_iter = (int) ceil(log((double) max_bits) / log(ratio));

   unsigned long last_length = 0;
   unsigned long i;
   for (i = 0; i <= max_iter; i++)
   {
      unsigned long length = (unsigned long) floor(powl(ratio, i));
      if (length != last_length)
      {
         last_length = length;

         unsigned long last_bits = 0;
         unsigned long j;
         for (j = 0; j <= max_iter; j++)
         {
            unsigned long bits = (unsigned long) floor(powl(ratio, j));
            if (bits != last_bits)
            {
               last_bits = bits;

               if (bits * length < max_bits)
                  prof2d_sample(length, bits, NULL);
            }
         }
      }
   }
}
开发者ID:curtisbright,项目名称:flint1.6,代码行数:29,代码来源:NTL-profile.c

示例10: main

int main()
{
	char base[5] = {'m','a','n','k','u'};
	int output[100];
	int c[100],test;
	long long n,t=0,temp=0;
	int i=0;
	scanf("%d",&test);
	while(test--)
	{
		temp=0;i=0;
		scanf("%lld",&n);
		while((temp + powl(5,i)) <= n)
		{
			temp = temp+powl(5,i);
			output[i] = 0;
			i++;
		}
		n = n-temp;
		t=0;
		while(n != 0)
		{
			output[t] = n%5;
			n = n/5;
			t++;
		}
		for(t=i-1;t>=0;t--)
			printf("%c",base[output[t]]);
		printf("\n");
	}
	return 0;
}
开发者ID:stranger9811,项目名称:spoj,代码行数:32,代码来源:MAY99_2.c

示例11: P

static long double P(long double mu, long double sigma, long double x)
{
	long double tmp = 1 / (sigma * sqrtl(2.0 * M_PIl));
	long double up = -powl(x-mu, 2) / (2 * powl(sigma, 2));
	tmp *= expl(up);
	return tmp;
}
开发者ID:elopez,项目名称:IAA,代码行数:7,代码来源:librand-c.c

示例12: get_MS5637_temp_and_pressure

void get_MS5637_temp_and_pressure(double* temperature_ptr, double* pressure_ptr, uint8_t osr_d1, uint8_t osr_d2)
{
	uint32_t raw_temperature = 0;
	uint32_t raw_pressure = 0;
	double dt, offset, sens, t2, offset2, sens2;
	double temperature_buf;

	raw_pressure = I2C_MS5637_Read(osr_d1);
	raw_temperature = I2C_MS5637_Read(osr_d2);

    dt = raw_temperature - prom_data[5]*pow(2,8);    // calculate temperature difference from reference
    offset = prom_data[2]*pow(2, 17) + dt*prom_data[4]/pow(2,6);
    sens = prom_data[1]*pow(2,16) + (dt*prom_data[3])/pow(2,7);

    temperature_buf = (2000 + (dt*prom_data[6])/pow(2, 23))/100;           // First-order Temperature in degrees Centigrade

    // Second order corrections
    if(temperature_buf >= 20)
    {
    	t2 = 5*dt*dt/powl(2, 38); // correction for high temperatures
    	offset2 = 0;
    	sens2 = 0;
    }
    if(temperature_buf < 20)                   // correction for low temperature
    {
    	t2      = 3*dt*dt/powl(2, 33);
    	offset2 = 61*(temperature_buf - 2000)*(temperature_buf - 2000)/16;
    	sens2   = 29*(temperature_buf - 2000)*(temperature_buf - 2000)/16;
    }
    if(temperature_buf < -15)                      // correction for very low temperature
    {
    	offset2 = offset2 + 17*(temperature_buf + 1500)*(temperature_buf + 1500);
    	sens2 = sens2 + 9*(temperature_buf + 1500)*(temperature_buf + 1500);
    }

    if((temperature_buf < -50) || (temperature_buf > 100))
    {
//    	uint8_t reset_ctr = 0;
//    	for(reset_ctr = 0; reset_ctr < 7; reset_ctr++)
//    	{
//        	prom_data[reset_ctr] = 0;
//    	}
//    	setup_imu();
    }
    else
    {
        // End of second order corrections
        offset = offset - offset2;
        sens = sens - sens2;

    	if(xSemaphoreTake(xSemaphore_pressure_temperature_mutex_handle, 0))
    	{
    	    *temperature_ptr = temperature_buf - t2;
    	    *pressure_ptr = (((raw_pressure*sens)/pow(2, 21) - offset)/pow(2, 15))/100;  // Pressure in mbar or kPa		xSemaphoreGive( xSemaphore_pressure_temperature_mutex_handle );
    		xSemaphoreGive( xSemaphore_pressure_temperature_mutex_handle );
    	}
    }

}
开发者ID:wyrdmantis,项目名称:DroneID,代码行数:59,代码来源:imu_task.c

示例13: t2FitFunc_dmsinusoids

double t2FitFunc_dmsinusoids(pulsar *psr, int ipsr ,double x ,int ipos ,param_label label,int k){
    if (label==param_dm_sin1yr){
        return 1.0/(DM_CONST*powl(psr[ipsr].obsn[ipos].freqSSB/1.0e6,2))*sin(2*M_PI/(365.25)*(psr[ipsr].obsn[ipos].sat - psr[ipsr].param[param_dmepoch].val[0]));
    } else if (label==param_dm_cos1yr) {
        return 1.0/(DM_CONST*powl(psr[ipsr].obsn[ipos].freqSSB/1.0e6,2))*cos(2*M_PI/(365.25)*(psr[ipsr].obsn[ipos].sat - psr[ipsr].param[param_dmepoch].val[0]));
    } else {
        logerr("Called dmsinusoids without dmsin1yr or dmcos1yr");
        return 0;
    }
}
开发者ID:kernsuite-debian,项目名称:tempo2,代码行数:10,代码来源:t2fit_dmother.C

示例14: _parcJSONValue_GetNumber

static long double
_parcJSONValue_GetNumber(const PARCJSONValue *value)
{
    long double fraction = value->value.number.fraction / powl(10.0, value->value.number.fractionLog10);
    long double number = (long double) value->value.number.sign * ((long double) value->value.number.whole + fraction);

    long double result = number * powl(10.0, (long double) value->value.number.exponent);

    return result;
}
开发者ID:PARC,项目名称:Libparc,代码行数:10,代码来源:parc_JSONValue.c

示例15: getAnswer

int getAnswer(int n, int p)
{
  long double  k = 2;
  int val = powl(k,(long double)(p-1)/2)%p;
  printf("%d",val);
  
  printf("%d",k);
  long double x = powl((k + sqrt(k^2-n)),(p+1)/2);
  return (int)x;
}
开发者ID:pauchan,项目名称:SPOJ,代码行数:10,代码来源:crypto.c


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