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

C++ powl函数代码示例

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

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



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


示例16: ain

long double TSolver::gcalc(const char f,const long double a,const long double b,const long double step) //calculates function
{
 #define ain(x) (a-step<=x && a+step>=x)
 #define bin(x) (b-step<=x && b+step>=x)
 #define angin(x) (torad(a)-step<x && torad(a)+step>x)
 switch (f)
   {case '+' : return a+b;
    case '-' : return a-b;
    case '*' : return a*b;
    case '/' : if (bin(0)) {Err=E_DEV_ZERO;return 0;};return a/b;
    case '!' : if (floorl(a)!=a) {Err=E_ARG;return 0;}return factor(a);
    case '_' : return -a;

    case cpi   : return M_PI;
    case cx    : return X;

    case fexp  : return exp(a);
    case fln   : if (a<0) {Err=E_ARG;return 0;}return logl(a);
    case flog  : if (a<0) {Err=E_ARG;return 0;}return log10l(a);
    case flogn : if (a<0) {Err=E_ARG;return 0;}return log(a)/log(b);

    case '^':
    case f_op_pow:
    case fpow  : if (a<0 && b<1 && b>0 && (!fmodl(b,2))) {Err=E_ARG;return 0;}return powl(a,b);
    case fsqr  : return a*a;
    case f_op_root:
    case froot : if (a<0 && (!fmodl(b,2))){Err=E_ARG;return 0;}
		   return (a>0 || (!fmodl(b,2)))?powl(a,1/b):-powl(-a,1/b);
    case fsqrt : if (a<0) {Err=E_ARG;return 0;}return sqrtl(a);
    case f_abs  : return fabsl(a);

    case fsin  : return sinl(a);
    case fcos  : return cosl(a);
    case ftan  : if (angin(M_PI_2) || angin(M_PI_2+M_PI)) {Err=E_ARG;return 0;} return tanl(a);
    case fctan : if (angin(0) || angin(M_PI)) {Err=E_ARG;return 0;} return 1/tanl(a);

    case fsin+ARC : if (fabsl(a)>1) {Err=E_ARG;return 0;} return asinl(a);
    case fcos+ARC : if (fabsl(a)>1) {Err=E_ARG;return 0;} return acosl(a);
    case ftan+ARC : return atanl(a);
    case fctan+ARC: return atanl(1/a);

    case fsin+HYP : return sinhl(a);
    case fcos+HYP : return coshl(a);
    case ftan+HYP : return tanhl(a);
    case fctan+HYP : return 1/tanhl(a);
#ifndef _OLD_
    case fsin+HYP+ARC : return asinhl(a);
    case fcos+HYP+ARC : return acoshl(a);
    case ftan+HYP+ARC : if (fabsl(a)>=1) {Err=E_ARG;return 0;} return atanhl(a);
    case fctan+HYP+ARC : if (angin(0)) {Err=E_ARG;return 0;} return atanhl(1/a);
#endif
    default: return 0;
   }
}
开发者ID:chemikadze,项目名称:oldschool,代码行数:54,代码来源:NPS.CPP


示例17: powl

void LineAnimation::initValues()
{

    //IMEDIATELY AFTER KNOWING THE CONTROL POINTS WE CALCULATE THE OVERALL DESTANCE OF THE ANIMATION
    total_delta_x = controlPoints->second->at(X) - controlPoints->first->at(X);
    total_delta_y = controlPoints->second->at(Y) - controlPoints->first->at(Y);
    total_delta_z = controlPoints->second->at(Z) - controlPoints->first->at(Z);
    double dist_x = (double) powl(total_delta_x, 2.0);
    double dist_y = (double) powl(total_delta_y, 2.0);
    double dist_z = (double) powl(total_delta_z, 2.0);

    total_animation_distance = (double) sqrtl(dist_x + dist_y + dist_z);
}
开发者ID:cristianoalexandre,项目名称:LAIG-Project-3,代码行数:13,代码来源:LineAnimation.cpp


示例18: B

long double B(long double x)
{
long double ret;
if (fabsl(x)>1e-40)
{
	ret=x/(expl(x)-1.0);
//From mathworld and wikipidia
}else
{
	ret=1-x/2.0+powl(x,2.0)/12.0-powl(x,4.0)/720.0+powl(x,6.0)/30240.0;

}
return ret;
}
开发者ID:roderickmackenzie,项目名称:gpvdm,代码行数:14,代码来源:advmath.c


示例19: dB

//Taken from mathworld and wikipidia
long double dB(long double x)
{
long double ret;
if (fabsl(x)>1e-40)
{
	ret=(expl(x)-1.0-x*expl(x))/(expl(x)-1)/(expl(x)-1);
}
else
{
	ret= -1.0/2.0+x/6.0-powl(x,3.0)/180.0+powl(x,5.0)/5040;
}

return ret;
}
开发者ID:roderickmackenzie,项目名称:gpvdm,代码行数:15,代码来源:advmath.c


示例20: main

int main() {
	char i, isPosExist, isAddOverflow, isMulOverflow;
	long k = 0, a, b, m, y, z;
	scanf("%ld %ld\n%ld\n", &a, &b, &m);
	for (i = 63; i >= 0; i--) {
		isPosExist = ((long) powl(2, i) & b) == (long) powl(2, i);
		isMulOverflow = k << 1 < k;
		z = isMulOverflow ? (k % m) * (2 % m) : k * 2;
		y = a * isPosExist;
		isAddOverflow = (z * y) < y && (z * y) < z;
		k = isAddOverflow ? (z % m) + (y % m) : z + y;
	}
	printf("%li", k % m);
	return 0;
}
开发者ID:R0maNNN,项目名称:study,代码行数:15,代码来源:mulmod.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pp函数代码示例发布时间:2022-05-30
下一篇:
C++ powi函数代码示例发布时间: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