arb/examples/pi.c

45 lines
798 B
C
Raw Normal View History

2013-09-19 17:28:23 +01:00
/* This file is public domain. Author: Fredrik Johansson. */
#include "arb.h"
2016-03-03 15:42:23 +01:00
#include "flint/profiler.h"
2013-09-19 17:28:23 +01:00
int main(int argc, char *argv[])
{
arb_t x;
2015-11-05 18:02:07 +00:00
slong prec, digits, condense;
2013-09-19 17:28:23 +01:00
if (argc < 2)
{
flint_printf("usage: build/examples/pi digits [condense = 20]\n");
2013-09-19 17:28:23 +01:00
return 1;
}
digits = atol(argv[1]);
if (argc > 2)
2015-01-27 18:09:38 +01:00
condense = atol(argv[2]);
2013-09-19 17:28:23 +01:00
else
2015-01-27 18:09:38 +01:00
condense = 20;
2013-09-19 17:28:23 +01:00
arb_init(x);
2013-09-19 17:28:23 +01:00
prec = digits * 3.3219280948873623 + 5;
flint_printf("computing pi with a precision of %wd bits... ", prec);
2013-09-19 17:28:23 +01:00
TIMEIT_ONCE_START
arb_const_pi(x, prec);
2013-09-19 17:28:23 +01:00
TIMEIT_ONCE_STOP
SHOW_MEMORY_USAGE
2015-01-27 18:09:38 +01:00
arb_printn(x, digits, ARB_STR_CONDENSE * condense);
2013-09-19 17:28:23 +01:00
flint_printf("\n");
2013-09-19 17:28:23 +01:00
arb_clear(x);
2013-09-19 17:28:23 +01:00
flint_cleanup();
return 0;
}