File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -324,7 +324,7 @@ int tpool_join(struct __threadpool *pool)
324
324
#define PRECISION 100 /* upper bound in BPP sum */
325
325
326
326
/* Use Bailey–Borwein–Plouffe formula to approximate PI */
327
- static void * bpp (void * arg )
327
+ static void * bbp (void * arg )
328
328
{
329
329
int k = * (int * ) arg ;
330
330
double sum = (4.0 / (8 * k + 1 )) - (2.0 / (8 * k + 4 )) -
@@ -337,24 +337,24 @@ static void *bpp(void *arg)
337
337
338
338
int main ()
339
339
{
340
- int bpp_args [PRECISION + 1 ];
341
- double bpp_sum = 0 ;
340
+ int bbp_args [PRECISION + 1 ];
341
+ double bbp_sum = 0 ;
342
342
tpool_t pool = tpool_create (4 );
343
343
tpool_future_t futures [PRECISION + 1 ];
344
344
345
345
for (int i = 0 ; i <= PRECISION ; i ++ ) {
346
- bpp_args [i ] = i ;
347
- futures [i ] = tpool_apply (pool , bpp , (void * ) & bpp_args [i ]);
346
+ bbp_args [i ] = i ;
347
+ futures [i ] = tpool_apply (pool , bbp , (void * ) & bbp_args [i ]);
348
348
}
349
349
350
350
for (int i = 0 ; i <= PRECISION ; i ++ ) {
351
351
double * result = tpool_future_get (futures [i ], 0 /* blocking wait */ );
352
- bpp_sum += * result ;
352
+ bbp_sum += * result ;
353
353
tpool_future_destroy (futures [i ]);
354
354
free (result );
355
355
}
356
356
357
357
tpool_join (pool );
358
- printf ("PI calculated with %d terms: %.15f\n" , PRECISION + 1 , bpp_sum );
358
+ printf ("PI calculated with %d terms: %.15f\n" , PRECISION + 1 , bbp_sum );
359
359
return 0 ;
360
360
}
You can’t perform that action at this time.
0 commit comments