本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例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 );
}
}
}
示例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;
}
}
示例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;
}
示例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;
}