static void test_locale (void) { int i; char *s = NULL; mpfr_t x; double y; int count; for(i = 0; i < numberof(tab_locale) && s == NULL; i++) s = setlocale (LC_ALL, tab_locale[i]); if (s == NULL || MPFR_THOUSANDS_SEPARATOR != ',') return; mpfr_init2 (x, 113); mpfr_set_ui (x, 10000, MPFR_RNDN); y = 100000; count = mpfr_printf ("(1) 10000=%'Rg 100000=%'g \n", x, y); check_length (10000, count, 33, d); count = mpfr_printf ("(2) 10000=%'Rf 100000=%'f \n", x, y); check_length (10001, count, 47, d); mpfr_clear (x); }
void coords_dump(const coords* c, const char* msg) { mpfr_printf("%s\nc->cx:%.Rf\tc->cy:%.Rf\tc->size:%.Rf\n", msg, c->cx, c->cy, c->width); mpfr_printf("c->xmin:%.Rf\tc->xmax:%.Rf\tc->ymax:%.Rf\n", c->xmin, c->xmax, c->ymax); printf("c->precision: %ld\n", (long)c->precision); }
static void bug20081214 (void) { /* problem with glibc 2.3.6, December 14, 2008: the system asprintf outputs "-1.0" instead of "-1.". */ mpfr_t x; double y; int xi; char *xs; int yi; char *ys; mpfr_init2 (x, MPFR_LDBL_MANT_DIG); y = -9.90597761233942053494e-01; mpfr_set_d (x, y, MPFR_RNDN); xi = mpfr_asprintf (&xs, "%- #0.*RG", 1, x); yi = mpfr_asprintf (&ys, "%- #0.*G", 1, y); if (xi != yi || strcmp (xs, ys) != 0) { mpfr_printf ("Error in bug20081214\n" "mpfr_asprintf(\"%- #0.*Re\", 1, %Re)\n", x); printf ("expected: %s\n", ys); printf (" got: %s\n", xs); printf ("xi=%d yi=%d\n", xi, yi); exit (1); } mpfr_free_str (xs); mpfr_free_str (ys); mpfr_clear (x); }
void func_print_cvec(func_t *f) { int i; //printf("complex["); printf("["); for(i=0; i<func_cvec_size(f); i++){ if(cis_real(func_cvec_at(f,i))){ mpfr_printf("%.5Rg",C_R(func_cvec_at(f,i))); }else if(cis_pure_imaginary(func_cvec_at(f,i))){ mpfr_printf("%.5Rg*I",C_I(func_cvec_at(f,i))); }else{ mpfr_printf("%.5Rg%+.5Rg*I",C_R(func_cvec_at(f,i)),C_I(func_cvec_at(f,i))); } if(i<(func_cvec_size(f))-1) printf(" "); } printf("]"); }
static void test_grandom (long nbtests, mpfr_prec_t prec, mpfr_rnd_t rnd, int verbose) { mpfr_t *t; mpfr_t av, va, tmp; int i, inexact; nbtests = (nbtests & 1) ? (nbtests + 1) : nbtests; t = (mpfr_t *) tests_allocate (nbtests * sizeof (mpfr_t)); for (i = 0; i < nbtests; ++i) mpfr_init2 (t[i], prec); for (i = 0; i < nbtests; i += 2) { inexact = mpfr_grandom (t[i], t[i + 1], RANDS, MPFR_RNDN); if ((inexact & 3) == 0 || (inexact & (3 << 2)) == 0) { /* one call in the loop pretended to return an exact number! */ printf ("Error: mpfr_grandom() returns a zero ternary value.\n"); exit (1); } } #ifdef HAVE_STDARG if (verbose) { mpfr_init2 (av, prec); mpfr_init2 (va, prec); mpfr_init2 (tmp, prec); mpfr_set_ui (av, 0, MPFR_RNDN); mpfr_set_ui (va, 0, MPFR_RNDN); for (i = 0; i < nbtests; ++i) { mpfr_add (av, av, t[i], MPFR_RNDN); mpfr_sqr (tmp, t[i], MPFR_RNDN); mpfr_add (va, va, tmp, MPFR_RNDN); } mpfr_div_ui (av, av, nbtests, MPFR_RNDN); mpfr_div_ui (va, va, nbtests, MPFR_RNDN); mpfr_sqr (tmp, av, MPFR_RNDN); mpfr_sub (va, va, av, MPFR_RNDN); mpfr_printf ("Average = %.5Rf\nVariance = %.5Rf\n", av, va); mpfr_clear (av); mpfr_clear (va); mpfr_clear (tmp); } #endif /* HAVE_STDARG */ for (i = 0; i < nbtests; ++i) mpfr_clear (t[i]); tests_free (t, nbtests * sizeof (mpfr_t)); return; }
void printx(char *s, mpz_t x, int prec) { mpfr_t y; mpfr_init2(y, 53); mpfr_set_z(y, x, GMP_RNDN); mpfr_div_2ui(y, y, prec, GMP_RNDN); mpfr_printf("%s: %Rf\n", s, y); mpfr_clear(y); }
TEST(RingCCC, axioms) { CCC *R = CCC::create(100); RingElementGenerator<CCC> gen(*R); for (int i = 0; i < ntrials; i++) { ring_elem a = gen.nextElement(); ring_elem b = gen.nextElement(); ring_elem c = gen.nextElement(); // Test commutativity // test: a*b = b*a // test: a+b == b+a ring_elem d = R->add(a, b); ring_elem e = R->add(b, a); EXPECT_TRUE(R->is_equal(d, e)); d = R->mult(a, b); e = R->mult(b, a); EXPECT_TRUE(almostEqual(R, 98, d, e)); // Test associativity // test: a+(b+c) == (a+b)+c // test: a*(b*c) == (a*b)*c d = R->add(a, R->add(b, c)); e = R->add(R->add(a, b), c); EXPECT_TRUE(almostEqual(R, 94, d, e)); d = R->mult(a, R->mult(b, c)); e = R->mult(R->mult(a, b), c); EXPECT_TRUE(almostEqual(R, 94, d, e)); // Test distributivity // test: a*(b+c) == a*b + a*c d = R->mult(a, R->add(b, c)); e = R->add(R->mult(a, b), R->mult(a, c)); #if 0 mpfr_printf("a=(%.20Rf,%.20Rf)\n",BIGCC_RE(a), BIGCC_IM(a)); mpfr_printf("b=(%.20Rf,%.20Rf)\n",BIGCC_RE(b), BIGCC_IM(b)); mpfr_printf("a*(b+c)=(%.20Rf,%.20Rf)\n",BIGCC_RE(d), BIGCC_IM(d)); mpfr_printf("a*b+a*c=(%.20Rf,%.20Rf)\n",BIGCC_RE(e), BIGCC_IM(e)); #endif EXPECT_TRUE(almostEqual(R, 92, d, e)); } }
static void check (const char *fmt, mpfr_t x) { if (mpfr_printf (fmt, x) == -1) { fprintf (stderr, "Error in mpfr_printf(\"%s\", ...)\n", fmt); exit (1); } putchar ('\n'); }
int main() { slong iter; flint_rand_t state; flint_printf("zeta_ui_euler_product...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000 * arb_test_multiplier(); iter++) { arb_t r; ulong n; mpfr_t s; slong prec, accuracy; do { n = n_randint(state, 1 << n_randint(state, 10)); } while (n < 6); prec = 2 + n_randint(state, n * FLINT_BIT_COUNT(n)); arb_init(r); mpfr_init2(s, prec + 100); arb_zeta_ui_euler_product(r, n, prec); mpfr_zeta_ui(s, n, MPFR_RNDN); if (!arb_contains_mpfr(r, s)) { flint_printf("FAIL: containment\n\n"); flint_printf("n = %wu\n\n", n); flint_printf("r = "); arb_printd(r, prec / 3.33); flint_printf("\n\n"); flint_printf("s = "); mpfr_printf("%.275Rf\n", s); flint_printf("\n\n"); flint_abort(); } accuracy = arb_rel_accuracy_bits(r); if (accuracy < prec - 4) { flint_printf("FAIL: accuracy = %wd, prec = %wd\n\n", accuracy, prec); flint_printf("n = %wu\n\n", n); flint_printf("r = "); arb_printd(r, prec / 3.33); flint_printf("\n\n"); flint_abort(); } arb_clear(r); mpfr_clear(s); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("zeta_ui_bernoulli...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 1000; iter++) { arb_t r; ulong n; mpfr_t s; slong prec, accuracy; prec = 2 + n_randint(state, 1 << n_randint(state, 14)); arb_init(r); mpfr_init2(s, prec + 100); do { n = n_randint(state, 1 << n_randint(state, 10)); } while (n % 2 || n == 0); arb_zeta_ui_bernoulli(r, n, prec); mpfr_zeta_ui(s, (unsigned long) FLINT_MIN(n, ULONG_MAX), MPFR_RNDN); if (!arb_contains_mpfr(r, s)) { flint_printf("FAIL: containment\n\n"); flint_printf("n = %wu\n\n", n); flint_printf("r = "); arb_printd(r, prec / 3.33); flint_printf("\n\n"); flint_printf("s = "); mpfr_printf("%.275Rf\n", s); flint_printf("\n\n"); abort(); } accuracy = arb_rel_accuracy_bits(r); if (accuracy < prec - 4) { flint_printf("FAIL: accuracy = %wd, prec = %wd\n\n", accuracy, prec); flint_printf("r = "); arb_printd(r, prec / 3.33); flint_printf("\n\n"); abort(); } arb_clear(r); mpfr_clear(s); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
void fmpr_printd(const fmpr_t x, long digits) { mpfr_t t; mpfr_init2(t, digits * 3.33 + 10); mpfr_set_emin(MPFR_EMIN_MIN); mpfr_set_emax(MPFR_EMAX_MAX); fmpr_get_mpfr(t, x, MPFR_RNDN); mpfr_printf("%.*Rg", FLINT_MAX(digits, 1), t); mpfr_clear(t); }
void func_print_rvec(func_t *f) { int i; //printf("real["); printf("["); for(i=0; i<func_rvec_size(f); i++){ mpfr_printf("%.5Rg",func_rvec_at(f,i)); if(i<(func_rvec_size(f))-1) printf(" "); } printf("]"); }
static void check (FILE *fout, char *fmt, mpfr_t x) { if (mpfr_fprintf (fout, fmt, x) == -1) { mpfr_printf ("Error in mpfr_fprintf(fout, \"%s\", %Re)\n", fmt, x); exit (1); } fputc ('\n', fout); }
int main() { long iter; flint_rand_t state; printf("zeta_ui_borwein_bsplit...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 1000; iter++) { arb_t r; ulong n; mpfr_t s; long prec, accuracy; prec = 2 + n_randint(state, 1 << n_randint(state, 14)); arb_init(r); mpfr_init2(s, prec + 100); do { n = n_randint(state, 1 << n_randint(state, 10)); } while (n == 1); arb_zeta_ui_borwein_bsplit(r, n, prec); mpfr_zeta_ui(s, n, MPFR_RNDN); if (!arb_contains_mpfr(r, s)) { printf("FAIL: containment\n\n"); printf("n = %lu\n\n", n); printf("r = "); arb_printd(r, prec / 3.33); printf("\n\n"); printf("s = "); mpfr_printf("%.275Rf\n", s); printf("\n\n"); abort(); } accuracy = arb_rel_accuracy_bits(r); if (accuracy < prec - 4) { printf("FAIL: accuracy = %ld, prec = %ld\n\n", accuracy, prec); printf("r = "); arb_printd(r, prec / 3.33); printf("\n\n"); abort(); } arb_clear(r); mpfr_clear(s); } flint_randclear(state); flint_cleanup(); printf("PASS\n"); return EXIT_SUCCESS; }
void eterm_show(int m, cmulti **x, func_t *fF, int bmax, int kappa) { int kmax,k,db=64; int *b=NULL,tau; func_t *fJ=NULL; cmulti **y=NULL; rmulti **e=NULL,**eps=NULL,**em=NULL,**r=NULL,*rmax=NULL,**p=NULL; kmax=(bmax-64)/db; if(kmax<0){ kmax=2; } tau=cvec_get_exp_max(m,x); printf("tau=%d\n",tau); fJ=func_grad(func_retain(fF),func_var1_list(m)); CVA(y,m); RVA(e,kmax); RVA(eps,kmax); RVA(em,kmax); RVA(r,kmax); RVA(p,kmax); RA(rmax); b=ivec_allocate(kmax); b[0]=53; for(k=1; k<kmax; k++){ b[k]=(k-1)*db+64; } for(k=0; k<kmax; k++){ printf("b=%4d ",b[k]); set_default_prec(b[k]); rset_d(eps[k],1); rmul_2exp(eps[k],eps[k],-b[k]+tau); mpfr_printf("2^(-b+tau)=%8.1Re ",eps[k]); cvec_round(m,y,b[k]); csolve_newton_map(m,y,x,fF,fJ); csolve_newton_e_norm(e[k],m,y,x,fF,fJ,bmax*4); if(rgt(eps[k],e[k])){ printf("> "); }else{ printf("< "); } mpfr_printf("e=%8.1Re ",e[k]); rset_d(em[k],1); rmul_2exp(em[k],em[k],-b[k]+tau+kappa); if(rgt(e[k],em[k])){ printf("> "); }else{ printf("< "); } mpfr_printf("em=%8.1Re ",em[k]); rlog2(p[k],e[k]); rsub_d1(p[k],tau,p[k]); rsub_d1(p[k],b[k],p[k]); mpfr_printf("b-tau+log2(e)=%+6.2Rf ",p[k]); rlog2(r[k],e[k]); rsub_d1(r[k],tau,r[k]); rdiv_d2(r[k],r[k],b[k]); rsub_d1(r[k],1,r[k]); mpfr_printf("κ=1-(tau-log2(e))/b=%+.10Rf ",r[k]); printf("\n"); } rvec_max(rmax,kmax,p); mpfr_printf("cancel bits=%+.2Rf\n",rmax); rvec_max(rmax,kmax,r); mpfr_printf("κ_max=%+.10Rf\n",rmax); // done fJ=func_del(fJ); b=ivec_free(b); CVF(y,m); RVF(e,kmax); RVF(eps,kmax); RVF(em,kmax); RVF(r,kmax); RVF(p,kmax); RF(rmax); }
TEST(RingCCC, power) { CCC *R = CCC::create(100); mpz_t gmp1; mpz_init(gmp1); RingElementGenerator<CCC> gen(*R); for (int i = 0; i < ntrials; i++) { ring_elem a = gen.nextElement(); // TODO: what should the answer here be? // EXPECT_TRUE(R->is_equal(R->power(a, 0), R->one())); // 0^0 == 1 too? EXPECT_TRUE(R->is_equal(R->power(a, 1), a)); int e1 = rawRandomInt(10) + 1; int e2 = rawRandomInt(10) + 1; // std::cout << "(" << e1 << "," << e2 << ")" << std::endl; ring_elem b = R->power(a, e1); ring_elem c = R->power(a, e2); ring_elem d = R->power(a, e1 + e2); #if 0 ring_elem e = R->mult(b,c); mpfr_printf("b=(%.30Rf,%.30Rf)\n",BIGCC_RE(b), BIGCC_IM(b)); mpfr_printf("c=(%.30Rf,%.30Rf)\n",BIGCC_RE(c), BIGCC_IM(c)); mpfr_printf("d=(%.30Rf,%.30Rf)\n",BIGCC_RE(d), BIGCC_IM(d)); mpfr_printf("e=(%.30Rf,%.30Rf)\n",BIGCC_RE(e), BIGCC_IM(e)); #endif EXPECT_TRUE(almostEqual(R, 80, R->mult(b, c), d)); // Make sure that powers via mpz work (at least for small exponents) mpz_set_si(gmp1, e1); ring_elem b1 = R->power(a, gmp1); EXPECT_TRUE(R->is_equal(b1, b)); } mpz_clear(gmp1); }
static void check_vfprintf (FILE *fout, char *fmt, ...) { va_list ap; va_start (ap, fmt); if (mpfr_vfprintf (fout, fmt, ap) == -1) { mpfr_printf ("Error in mpfr_vfprintf(fout, \"%s\", ...)\n", fmt); va_end (ap); exit (1); } va_end (ap); fputc ('\n', fout); }
int main (int argc, char **argv) { mpfr_t LIST; mp_prec_t prec; int pprec; /* will be prec - 1 for mpfr_printf */ if (argc != 4) { fprintf (stderr, "Usage: rndo-add <prec> <x> <y>\n"); exit (1); } prec = atoi (argv[1]); if (prec < 2) { fprintf (stderr, "rndo-add: bad precision\n"); exit (1); } pprec = prec - 1; mpfr_inits2 (prec, LIST, (mpfr_ptr) 0); if (mpfr_set_str (x, argv[2], 0, GMP_RNDN)) { fprintf (stderr, "rndo-add: bad x value\n"); exit (1); } mpfr_printf ("x = %.*Rb\n", pprec, x); if (mpfr_set_str (y, argv[3], 0, GMP_RNDN)) { fprintf (stderr, "rndo-add: bad y value\n"); exit (1); } mpfr_printf ("y = %.*Rb\n", pprec, y); mpfr_add (d, x, y, GMP_RNDD); mpfr_printf ("d = %.*Rb\n", pprec, d); mpfr_add (u, x, y, GMP_RNDU); mpfr_printf ("u = %.*Rb\n", pprec, u); mpfr_add (e, d, u, GMP_RNDN); mpfr_div_2ui (e, e, 1, GMP_RNDN); mpfr_printf ("e = %.*Rb\n", pprec, e); mpfr_sub (z, u, e, GMP_RNDN); mpfr_add (z, z, d, GMP_RNDN); mpfr_printf ("z = %.*Rb\n", pprec, z); mpfr_clears (LIST, (mpfr_ptr) 0); return 0; }
int main (int argc, char *argv[]) { int dmax, n, p; mpfr_t VARS; if (argc != 3 && argc != 4) { fprintf (stderr, "Usage: divworst <dmax> <n> [ <p> ]\n"); exit (EXIT_FAILURE); } dmax = atoi (argv[1]); n = atoi (argv[2]); p = argc == 3 ? n : atoi (argv[3]); if (p < n) { fprintf (stderr, "divworst: p must be greater or equal to n\n"); exit (EXIT_FAILURE); } mpfr_inits2 (n, PRECN, (mpfr_ptr) 0); mpfr_init2 (t, p); for (mpfr_set_ui_2exp (x, 1, -1, MPFR_RNDN); mpfr_get_exp (x) <= dmax; mpfr_nextabove (x)) for (mpfr_set_ui_2exp (y, 1, -1, MPFR_RNDN); mpfr_get_exp (y) == 0; mpfr_nextabove (y)) { unsigned long rz, rn; if (mpfr_sub (z, x, y, MPFR_RNDZ) != 0) continue; /* x - y is not representable in precision n */ rz = eval (x, y, z, t, MPFR_RNDZ); rn = eval (x, y, z, t, MPFR_RNDN); if (rz == rn) continue; mpfr_printf ("x = %.*Rb ; y = %.*Rb ; Z: %lu ; N: %lu\n", n - 1, x, n - 1, y, rz, rn); } mpfr_clears (VARS, (mpfr_ptr) 0); return 0; }
int main() { slong iter; flint_rand_t state; flint_printf("zeta_ui_asymp...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 10000; iter++) { arb_t r; ulong n; mpfr_t s; slong prec; prec = 2 + n_randint(state, 1 << n_randint(state, 10)); arb_init(r); mpfr_init2(s, prec + 100); n = 2 + n_randint(state, 1 << n_randint(state, 10)); arb_zeta_ui_asymp(r, n, prec); mpfr_zeta_ui(s, (unsigned long) FLINT_MIN(n, ULONG_MAX), MPFR_RNDN); if (!arb_contains_mpfr(r, s)) { flint_printf("FAIL: containment\n\n"); flint_printf("n = %wu\n\n", n); flint_printf("r = "); arb_printd(r, prec / 3.33); flint_printf("\n\n"); flint_printf("s = "); mpfr_printf("%.275Rf\n", s); flint_printf("\n\n"); abort(); } arb_clear(r); mpfr_clear(s); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main(void) { struct number n; char *input, buffer[256]; rl_bind_key('\t', rl_complete); while (1) { snprintf(buffer, sizeof(buffer), "> "); input = readline(buffer); if (!input || !strcmp(input, "exit")) break; add_history(input); calculate(input, &n); // snprintf(buffer, sizeof(buffer), "%%.%ldRf\n", mpfr_get_prec(n.num)); mpfr_printf("%RNf\n", n.num); mpfr_clear(n.num); mpfr_free_cache(); free(input); } return 0; }
void mpfr_taylor_sin_bounded(mpfr_t R, mpfr_t x, unsigned int N) { mpfr_printf("%.20RNF\n", x); assert(mpfr_cmp_ui(x, 0) >= 0 && mpfr_cmp(x, MPFR_HALF_PI) <= 0); mpfr_t t, x_2; mpfr_init_set(R, x, MPFR_RNDN); mpfr_init_set(t, x, MPFR_RNDN); mpfr_init(x_2); mpfr_mul(x_2, x, x, MPFR_RNDN); for(int n = 1; n < N; n++) { mpfr_div_ui(t, t, (2*n+1)*(2*(n++)), MPFR_RNDN); mpfr_mul(t, t, x_2, MPFR_RNDN); mpfr_sub(R, R, t, MPFR_RNDN); mpfr_div_ui(t, t, (2*n+1)*(2*n), MPFR_RNDN); mpfr_mul(t, t, x_2, MPFR_RNDN); mpfr_add(R, R, t, MPFR_RNDN); } }
static void check (long i, mpfr_rnd_t rnd) { mpfr_t f; mpz_t z; mpfr_exp_t e; int inex; /* using CHAR_BIT * sizeof(long) bits of precision ensures that mpfr_set_z_2exp is exact below */ mpfr_init2 (f, CHAR_BIT * sizeof(long)); mpz_init (z); mpz_set_ui (z, i); /* the following loop ensures that no overflow occurs */ do e = randexp (); while (e > mpfr_get_emax () - CHAR_BIT * sizeof(long)); inex = mpfr_set_z_2exp (f, z, e, rnd); if (inex != 0) { printf ("Error in mpfr_set_z_2exp for i=%ld, e=%ld," " wrong ternary value\n", i, (long) e); printf ("expected 0, got %d\n", inex); exit (1); } mpfr_div_2si (f, f, e, rnd); if (mpfr_get_si (f, MPFR_RNDZ) != i) { printf ("Error in mpfr_set_z_2exp for i=%ld e=%ld rnd_mode=%d\n", i, e, rnd); printf ("expected %ld\n", i); mpfr_printf ("got %Re\n", f); exit (1); } mpfr_clear (f); mpz_clear (z); }
mpfr_t* double_pole_case_c(long pole_order_max, mpfr_t base, mpfr_t pole_position, mpfr_t incomplete_gamma_factor, mpfr_prec_t prec){ mpfr_t* result=malloc(sizeof(mpfr_t)*(pole_order_max+1)); mpfr_t temp1; mpfr_init2(temp1,prec); mpfr_t double_pole_integral; mpfr_init2(double_pole_integral,prec); mpfr_t temp2; mpfr_init2(temp2,prec); mpfr_t minus_pole_position; mpfr_init2(minus_pole_position,prec); mpfr_neg(minus_pole_position,pole_position,MPFR_RNDN); // mpfr_t factorial; // mpfr_init2(factorial,prec); // mpfr_set_ui(factorial,1,MPFR_RNDN); mpfr_t minus_log_base; mpfr_init2(minus_log_base,prec); mpfr_log(minus_log_base,base,prec); mpfr_neg(minus_log_base,minus_log_base,MPFR_RNDN); mpfr_ui_div(minus_log_base,1,minus_log_base,MPFR_RNDN); mpfr_t log_base_power; mpfr_init2(log_base_power,prec); mpfr_set(log_base_power,minus_log_base,MPFR_RNDN); //mpfr_set_ui(temp1,0,MPFR_RNDN); //mpfr_mul(double_pole_integral,temp1,incomplete_gamma_factor,MPFR_RNDN); mpfr_log(temp1,base,MPFR_RNDN); mpfr_mul(double_pole_integral,incomplete_gamma_factor,temp1,MPFR_RNDN); mpfr_ui_div(temp1,1,minus_pole_position,MPFR_RNDN); mpfr_add(double_pole_integral,double_pole_integral,temp1,MPFR_RNDN); //mpfr_printf("before loop: double_pole_integral = %.32RNf\n",double_pole_integral); for(int i=0;i<=pole_order_max;i++){ mpfr_init2(result[i],prec); mpfr_set(result[i],double_pole_integral,MPFR_RNDN); if(i<pole_order_max){ mpfr_mul(double_pole_integral,double_pole_integral,pole_position,MPFR_RNDN); } } #ifdef debug_mode for(int i=0;i<=pole_order_max;i++){ mpfr_printf("result[%d] = %.16RNf\n",i,result[i],MPFR_RNDN); } #endif mpfr_t * factorial_times_power_lnb; mpfr_t * single_pole_coeffs; /* * x**1/(x+a)**2 case * */ if(pole_order_max >= 1){ single_pole_coeffs=malloc(sizeof(mpfr_t)*(pole_order_max)); /* x^(j+1)=( * single_pole_coeffs[0] x^(j-1) + * single_pole_coeffs[1] x^(j-2) + ... + * single_pole_coeffs[j-1] x^0 * )*(x-a)^2 + * * single_pole_coeffs[j](x-a) * ((x-a) + a) * * + a^(j+1) * * => single_pole_coeffs[j+1] * * single_pole_coeffs[j+1] = single_pole_coeffs[j]*a + a^j+1 * single_pole_coeffs[0] = * */ if(pole_order_max>=2){ factorial_times_power_lnb=malloc(sizeof(mpfr_t)*(pole_order_max-1)); mpfr_init2(factorial_times_power_lnb[0],prec); mpfr_set(factorial_times_power_lnb[0],minus_log_base,MPFR_RNDN); } mpfr_set(temp1,pole_position,MPFR_RNDN); /* below temp1 is used as pole_position^j*/ mpfr_init2(single_pole_coeffs[0],prec); mpfr_set_ui(single_pole_coeffs[0], 1 ,MPFR_RNDN); mpfr_add(result[1],result[1],incomplete_gamma_factor,MPFR_RNDN); for(int j=1;j<=pole_order_max-1;j++){ mpfr_init2(single_pole_coeffs[j],prec); mpfr_mul(single_pole_coeffs[j],single_pole_coeffs[j-1],pole_position,MPFR_RNDN); mpfr_add(single_pole_coeffs[j],single_pole_coeffs[j],temp1,MPFR_RNDN); mpfr_mul(temp2,single_pole_coeffs[j],incomplete_gamma_factor,MPFR_RNDN); mpfr_add(result[j+1],result[j+1],temp2,MPFR_RNDN); if(j<=pole_order_max-2){ mpfr_init2(factorial_times_power_lnb[j],prec); mpfr_mul(temp1,temp1,pole_position,MPFR_RNDN); mpfr_mul(factorial_times_power_lnb[j],factorial_times_power_lnb[j-1],minus_log_base,MPFR_RNDN); mpfr_mul_ui(factorial_times_power_lnb[j],factorial_times_power_lnb[j],j,MPFR_RNDN); } } } #ifdef debug_mode for(int j=0;j<=pole_order_max-1;j++){ mpfr_printf("single_pole_coeffs[%d] = %.16RNf\n",j,single_pole_coeffs[j]); } #endif #ifdef debug_mode for(int j=0;j<=pole_order_max-2;j++){ mpfr_printf("factorial_times_power_lnb[%d] = %.16RNf\n",j,factorial_times_power_lnb[j]); } #endif for(int j=0;j<=pole_order_max-2;j++){ for(int k=0;k<=j;k++){ mpfr_mul(temp2,factorial_times_power_lnb[k],single_pole_coeffs[j-k],MPFR_RNDN); mpfr_add(result[j+2],result[j+2],temp2,MPFR_RNDN); } } for(int i=0;i<=pole_order_max-1;i++){ mpfr_clear(single_pole_coeffs[i]); } for(int i=0;i<=pole_order_max-2;i++){ mpfr_clear(factorial_times_power_lnb[i]); } if(pole_order_max > 0){ free(single_pole_coeffs); } if(pole_order_max > 1){ free(factorial_times_power_lnb); } mpfr_clear(temp1); mpfr_clear(double_pole_integral); mpfr_clear(temp2); mpfr_clear(minus_pole_position); //mpfr_clear(factorial); mpfr_clear(minus_log_base); mpfr_clear(log_base_power); return result; }
/* check concordance between mpfr_asprintf result with a regular mpfr float and with a regular double float */ static int random_double (void) { mpfr_t x; /* random regular mpfr float */ double y; /* regular double float (equal to x) */ char flag[] = { '-', '+', ' ', '#', '0', /* no ambiguity: first zeros are flag zero*/ '\'' }; /* no 'a': mpfr and glibc do not have the same semantic */ char specifier[] = { 'e', 'f', 'g', 'E', 'f', /* SUSv2 doesn't accept %F, but %F and %f are the same for regular numbers */ 'G', }; int spec; /* random index in specifier[] */ int prec; /* random value for precision field */ /* in the format string for mpfr_t variable, the maximum length is reached by something like "%-+ #0'.*Rf", that is 12 characters. */ #define FMT_MPFR_SIZE 12 char fmt_mpfr[FMT_MPFR_SIZE]; char *ptr_mpfr; /* in the format string for double variable, the maximum length is reached by something like "%-+ #0'.*f", that is 11 characters. */ #define FMT_SIZE 11 char fmt[FMT_SIZE]; char *ptr; int xi; char *xs; int yi; char *ys; int i, j, jmax; mpfr_init2 (x, MPFR_LDBL_MANT_DIG); for (i = 0; i < 1000; ++i) { /* 1. random double */ do { y = DBL_RAND (); } #ifdef HAVE_DENORMS while (0); #else while (ABS(y) < DBL_MIN); #endif if (randlimb () % 2 == 0) y = -y; mpfr_set_d (x, y, MPFR_RNDN); if (y != mpfr_get_d (x, MPFR_RNDN)) /* conversion error: skip this one */ continue; /* 2. build random format strings fmt_mpfr and fmt */ ptr_mpfr = fmt_mpfr; ptr = fmt; *ptr_mpfr++ = *ptr++ = '%'; /* random specifier 'e', 'f', 'g', 'E', 'F', or 'G' */ spec = (int) (randlimb() % 6); /* random flags, but no ' flag with %e */ jmax = (spec == 0 || spec == 3) ? 5 : 6; for (j = 0; j < jmax; j++) { if (randlimb() % 3 == 0) *ptr_mpfr++ = *ptr++ = flag[j]; } *ptr_mpfr++ = *ptr++ = '.'; *ptr_mpfr++ = *ptr++ = '*'; *ptr_mpfr++ = 'R'; *ptr_mpfr++ = *ptr++ = specifier[spec]; *ptr_mpfr = *ptr = '\0'; MPFR_ASSERTN (ptr - fmt < FMT_SIZE); MPFR_ASSERTN (ptr_mpfr - fmt_mpfr < FMT_MPFR_SIZE); /* advantage small precision */ if (randlimb() % 2 == 0) prec = (int) (randlimb() % 10); else prec = (int) (randlimb() % prec_max_printf); /* 3. calls and checks */ /* the double float case is handled by the libc asprintf through gmp_asprintf */ xi = mpfr_asprintf (&xs, fmt_mpfr, prec, x); yi = mpfr_asprintf (&ys, fmt, prec, y); /* test if XS and YS differ, beware that ISO C99 doesn't specify the sign of a zero exponent (the C99 rationale says: "The sign of a zero exponent in %e format is unspecified. The committee knows of different implementations and choose not to require implementations to document their behaviour in this case (by making this be implementation defined behaviour). Most implementations use a "+" sign, e.g., 1.2e+00; but there is at least one implementation that uses the sign of the unlimited precision result, e.g., the 0.987 would be 9.87e-01, so could end up as 1e-00 after rounding to one digit of precision."), while mpfr always uses '+' */ if (xi != yi || ((strcmp (xs, ys) != 0) && (spec == 1 || spec == 4 || ((strstr (xs, "e+00") == NULL || strstr (ys, "e-00") == NULL) && (strstr (xs, "E+00") == NULL || strstr (ys, "E-00") == NULL))))) { mpfr_printf ("Error in mpfr_asprintf(\"%s\", %d, %Re)\n", fmt_mpfr, prec, x); printf ("expected: %s\n", ys); printf (" got: %s\n", xs); printf ("xi=%d yi=%d spec=%d\n", xi, yi, spec); exit (1); } mpfr_free_str (xs); mpfr_free_str (ys); } mpfr_clear (x); return 0; }
int main() { slong i; mpfr_t tabx, expx, y1, y2; mpz_t tt; flint_printf("exp_tab...."); fflush(stdout); { slong prec, bits, num; prec = ARB_EXP_TAB1_LIMBS * FLINT_BITS; bits = ARB_EXP_TAB1_BITS; num = ARB_EXP_TAB1_NUM; mpfr_init2(tabx, prec); mpfr_init2(expx, prec); mpfr_init2(y1, prec); mpfr_init2(y2, prec); for (i = 0; i < num; i++) { tt->_mp_d = (mp_ptr) arb_exp_tab1[i]; tt->_mp_size = prec / FLINT_BITS; tt->_mp_alloc = tt->_mp_size; while (tt->_mp_size > 0 && tt->_mp_d[tt->_mp_size-1] == 0) tt->_mp_size--; mpfr_set_z(tabx, tt, MPFR_RNDD); mpfr_div_2ui(tabx, tabx, prec, MPFR_RNDD); mpfr_set_ui(expx, i, MPFR_RNDD); mpfr_div_2ui(expx, expx, bits, MPFR_RNDD); mpfr_exp(expx, expx, MPFR_RNDD); mpfr_mul_2ui(y1, tabx, prec, MPFR_RNDD); mpfr_floor(y1, y1); mpfr_div_2ui(y1, y1, prec, MPFR_RNDD); mpfr_mul_2ui(y2, expx, prec - 1, MPFR_RNDD); mpfr_floor(y2, y2); mpfr_div_2ui(y2, y2, prec, MPFR_RNDD); if (!mpfr_equal_p(y1, y2)) { flint_printf("FAIL: i = %wd, bits = %wd, prec = %wd\n", i, bits, prec); mpfr_printf("y1 = %.1500Rg\n", y1); mpfr_printf("y2 = %.1500Rg\n", y2); abort(); } } mpfr_clear(tabx); mpfr_clear(expx); mpfr_clear(y1); mpfr_clear(y2); } { slong prec, bits, num; prec = ARB_EXP_TAB2_LIMBS * FLINT_BITS; bits = ARB_EXP_TAB21_BITS; num = ARB_EXP_TAB21_NUM; mpfr_init2(tabx, prec); mpfr_init2(expx, prec); mpfr_init2(y1, prec); mpfr_init2(y2, prec); for (i = 0; i < num; i++) { tt->_mp_d = (mp_ptr) arb_exp_tab21[i]; tt->_mp_size = prec / FLINT_BITS; tt->_mp_alloc = tt->_mp_size; while (tt->_mp_size > 0 && tt->_mp_d[tt->_mp_size-1] == 0) tt->_mp_size--; mpfr_set_z(tabx, tt, MPFR_RNDD); mpfr_div_2ui(tabx, tabx, prec, MPFR_RNDD); mpfr_set_ui(expx, i, MPFR_RNDD); mpfr_div_2ui(expx, expx, bits, MPFR_RNDD); mpfr_exp(expx, expx, MPFR_RNDD); mpfr_mul_2ui(y1, tabx, prec, MPFR_RNDD); mpfr_floor(y1, y1); mpfr_div_2ui(y1, y1, prec, MPFR_RNDD); mpfr_mul_2ui(y2, expx, prec - 1, MPFR_RNDD); mpfr_floor(y2, y2); mpfr_div_2ui(y2, y2, prec, MPFR_RNDD); if (!mpfr_equal_p(y1, y2)) { flint_printf("FAIL: i = %wd, bits = %wd, prec = %wd\n", i, bits, prec); mpfr_printf("y1 = %.1500Rg\n", y1); mpfr_printf("y2 = %.1500Rg\n", y2); abort(); } } mpfr_clear(tabx); mpfr_clear(expx); mpfr_clear(y1); mpfr_clear(y2); } { slong prec, bits, num; prec = ARB_EXP_TAB2_LIMBS * FLINT_BITS; bits = ARB_EXP_TAB21_BITS + ARB_EXP_TAB22_BITS; num = ARB_EXP_TAB22_NUM; mpfr_init2(tabx, prec); mpfr_init2(expx, prec); mpfr_init2(y1, prec); mpfr_init2(y2, prec); for (i = 0; i < num; i++) { tt->_mp_d = (mp_ptr) arb_exp_tab22[i]; tt->_mp_size = prec / FLINT_BITS; tt->_mp_alloc = tt->_mp_size; while (tt->_mp_size > 0 && tt->_mp_d[tt->_mp_size-1] == 0) tt->_mp_size--; mpfr_set_z(tabx, tt, MPFR_RNDD); mpfr_div_2ui(tabx, tabx, prec, MPFR_RNDD); mpfr_set_ui(expx, i, MPFR_RNDD); mpfr_div_2ui(expx, expx, bits, MPFR_RNDD); mpfr_exp(expx, expx, MPFR_RNDD); mpfr_mul_2ui(y1, tabx, prec, MPFR_RNDD); mpfr_floor(y1, y1); mpfr_div_2ui(y1, y1, prec, MPFR_RNDD); mpfr_mul_2ui(y2, expx, prec - 1, MPFR_RNDD); mpfr_floor(y2, y2); mpfr_div_2ui(y2, y2, prec, MPFR_RNDD); if (!mpfr_equal_p(y1, y2)) { flint_printf("FAIL: i = %wd, bits = %wd, prec = %wd\n", i, bits, prec); mpfr_printf("y1 = %.1500Rg\n", y1); mpfr_printf("y2 = %.1500Rg\n", y2); abort(); } } mpfr_clear(tabx); mpfr_clear(expx); mpfr_clear(y1); mpfr_clear(y2); } flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { slong iter; flint_rand_t state; flint_printf("zeta_ui_vec_borwein...."); fflush(stdout); flint_randinit(state); for (iter = 0; iter < 100; iter++) { arb_ptr r; ulong n; slong i, num, step; mpfr_t s; slong prec, accuracy; prec = 2 + n_randint(state, 1 << n_randint(state, 13)); num = 1 + n_randint(state, 20); step = 1 + n_randint(state, 5); r = _arb_vec_init(num); mpfr_init2(s, prec + 100); do { n = n_randint(state, 1 << n_randint(state, 10)); } while (n < 2); arb_zeta_ui_vec_borwein(r, n, num, step, prec); for (i = 0; i < num; i++) { mpfr_zeta_ui(s, (unsigned long) FLINT_MIN(n + i * step, ULONG_MAX), MPFR_RNDN); if (!arb_contains_mpfr(r + i, s)) { flint_printf("FAIL: containment\n\n"); flint_printf("n = %wu\n\n", n + i * step); flint_printf("r = "); arb_printd(r + i, prec / 3.33); flint_printf("\n\n"); flint_printf("s = "); mpfr_printf("%.275Rf\n", s); flint_printf("\n\n"); abort(); } accuracy = arb_rel_accuracy_bits(r + i); if (accuracy < prec - 4) { flint_printf("FAIL: accuracy = %wd, prec = %wd\n\n", accuracy, prec); flint_printf("n = %wu\n\n", n + i * step); flint_printf("r = "); arb_printd(r + i, prec / 3.33); flint_printf("\n\n"); abort(); } } _arb_vec_clear(r, num); mpfr_clear(s); } flint_randclear(state); flint_cleanup(); flint_printf("PASS\n"); return EXIT_SUCCESS; }
int main() { int op; bool res=0; long int per=100; int no, *ptr,*temp,n1,i; double n,k,j,pcomp,cnt=0; double x; // ******************************************Calculate original probability **************************************** mpfr_t p,t; mpfr_init2(p,100); // declare probability with a pecision of 100 so that smaller probabilities dont get truncated to zero mpfr_set_d (p, 1.0, MPFR_RNDD); //initialise p with 1.0 mpfr_init2(t,100); mpfr_set_d (t, 1.0, MPFR_RNDD); printf("Enter the number of people :\n"); //Number of people to form a group of scanf("%lf",&k); printf("Choose :\nLeap Year(1)\nNormal Year(2)\n"); // Choose if its a normal year or a leap year scanf("%d",&op); if(op==1) n=366; else if(op==2) n=365; for(i=1;i<=k;i++) //this loop calculates the probability that two people dont have birthdays on the same day { x=(n-i+1)/n; mpfr_mul_d(p, p,x, MPFR_RNDD); } mpfr_sub(p,t,p,MPFR_RNDD); // 1-probability that no two people have birthdays on the same day mpfr_mul_si(p,p,per,MPFR_RNDD); //Percentage printf ("Expected Probability in Percentage : "); mpfr_printf ("%.64Rf ", p); putchar ('\n'); mpfr_clear(p); mpfr_clear(t); // ****************************************Verification of this paradox********************************************** printf("Enter the number of trials you want to take :\n"); //number of trials to take to confirm the resultant probaility scanf("%d",&no); ptr=(int *)malloc(k*sizeof(int)); //Assign memory space for an array of k people for each test case temp=ptr; for(j=0;j<no;j++) { ptr=temp; res=0; for(i=0,n1=(int)n;i<k;i++,ptr++) *ptr=(rand()%n1)+1; //randomly select nth day from 365/366 days for assigning birthdays ptr=temp; qsort(ptr,k,sizeof(int),compare_int); //sort the array using quick sort ptr=temp; for(i=0;i<k;i++,ptr++) { if(*ptr==*(ptr+1)) //comparing if two people have birthdays on the same day { res=1; break; } } if(res==1) cnt++; //increase the count of tests which turned out to be positive from total number of trials } pcomp = (cnt/no) *100; //percentage of success cases printf("Actual Probability in Percentage : %lf \n",pcomp); return 0; }
static void check_random (FILE *fout, int nb_tests) { int i; mpfr_t x; mp_rnd_t rnd; char flag[] = { '-', '+', ' ', '#', '0', /* no ambiguity: first zeros are flag zero*/ '\'' }; char specifier[] = { 'a', 'b', 'e', 'f', 'g' }; mp_exp_t old_emin, old_emax; old_emin = mpfr_get_emin (); old_emax = mpfr_get_emax (); mpfr_init (x); for (i = 0; i < nb_tests; ++i) { int ret; int j, jmax; int spec, prec; #define FMT_SIZE 13 char fmt[FMT_SIZE]; /* at most something like "%-+ #0'.*R*f" */ char *ptr = fmt; tests_default_random (x, 256, MPFR_EMIN_MIN, MPFR_EMAX_MAX); rnd = RND_RAND (); spec = (int) (randlimb () % 5); jmax = (spec == 3 || spec == 4) ? 6 : 5; /* ' flag only with %f or %g */ /* advantage small precision */ prec = (int) (randlimb () % ((randlimb () % 2) ? 10 : prec_max_printf)); if (spec == 3 && (mpfr_get_exp (x) > prec_max_printf || mpfr_get_exp (x) < -prec_max_printf)) /* change style 'f' to style 'e' when number x is large */ --spec; *ptr++ = '%'; for (j = 0; j < jmax; j++) { if (randlimb () % 3 == 0) *ptr++ = flag[j]; } *ptr++ = '.'; *ptr++ = '*'; *ptr++ = 'R'; *ptr++ = '*'; *ptr++ = specifier[spec]; *ptr = '\0'; MPFR_ASSERTD (ptr - fmt < FMT_SIZE); mpfr_fprintf (fout, "mpfr_fprintf(fout, \"%s\", %d, %s, %Re)\n", fmt, prec, mpfr_print_rnd_mode (rnd), x); ret = mpfr_fprintf (fout, fmt, prec, rnd, x); if (ret == -1) { if (spec == 3 && (MPFR_GET_EXP (x) > INT_MAX || MPFR_GET_EXP (x) < -INT_MAX)) /* normal failure: x is too large to be output with full precision */ { mpfr_fprintf (fout, "too large !"); } else { mpfr_printf ("Error in mpfr_fprintf(fout, \"%s\", %d, %s, %Re)\n", fmt, prec, mpfr_print_rnd_mode (rnd), x); exit (1); } } mpfr_fprintf (fout, "\n"); } mpfr_set_emin (old_emin); mpfr_set_emax (old_emax); mpfr_clear (x); }
void riep_dhToda_TN(int m, int M, rmulti **A, int LDA, rmulti **Q, int LDQ, rmulti **E, rmulti **lambda, rmulti **c, int debug) { int prec=0,k=0,n=0,f_size=0,n_size=0,*Q0_size=NULL,*E0_size=NULL,LDQ1; rmulti *a=NULL,**f=NULL,***Q0=NULL,***E0=NULL,**sigma=NULL,**Q1=NULL,**E1=NULL; // init n_size=(M+1)*(m-1)+2*M; // precision prec=rmat_get_prec_max(m,m,A,LDA); // allocate if(Q==NULL) { LDQ1=m; Q1=rmat_allocate_prec(m,M,prec); } else { LDQ1=LDQ; Q1=Q; } if(E==NULL) { E1=rvec_allocate_prec(m,prec); } else { E1=E; } sigma=rvec_allocate_prec(m,prec); a=rallocate_prec(prec); Q0_size=ivec_allocate(m); Q0=malloc(m*sizeof(rmulti**)); for(k=0; k<m; k++) { Q0_size[k]=n_size-k*(M+1); Q0[k]=rvec_allocate_prec(Q0_size[k],prec); } E0_size=ivec_allocate(m); E0=malloc(m*sizeof(rmulti**)); for(k=0; k<m; k++) { E0_size[k]=n_size-(k+1)*(M+1)+1; E0[k]=rvec_allocate_prec(E0_size[k],prec); } f_size=Q0_size[0]+1; f=rvec_allocate_prec(f_size,prec); // generate sigma[n] rinv_d(a,M); rvec_pow_r(m,sigma,lambda,a); // generate f[n] for(n=0; n<f_size; n++) { rset_d(f[n],0); for(k=0; k<m; k++) { rpow_si(a,sigma[k],n); // a=(sigma[i])^n radd_mul(f[n],c[k],a); // f[i]=f[i]+c[i]*(sigma[i])^n } } // Q[n][0]=f[n+1]/f[n] for(n=0; n<Q0_size[0]; n++) { if(n+1<f_size) { rdiv(Q0[0][n],f[n+1],f[n]); } else { rset_nan(Q0[0][n]); } } // E[0][n]=Q[0][n+M]-Q[0][n]; k=0; for(n=0; n<E0_size[k]; n++) { if(n+M<Q0_size[k] && n<Q0_size[k]) { rsub(E0[k][n],Q0[k][n+M],Q0[k][n]); } else { rset_nan(E0[k][n]); } } // loop for QE-table for(k=1; k<m; k++) { // Q[k][n]=(E[k-1][n+1]*Q[k-1][n+M])/E[k-1][n]; for(n=0; n<Q0_size[k]; n++) { rdiv(a,E0[k-1][n+1],E0[k-1][n]); rmul(Q0[k][n],a,Q0[k-1][n+M]); } // E[k][n]=Q[k][n+M]-Q[k][n]+E[k-1][n+1] for(n=0; n<E0_size[k]; n++) { rsub(a,Q0[k][n+M],Q0[k][n]); radd(E0[k][n],a,E0[k-1][n+1]); } } // debug if(debug>0) { printf("Q=\n"); for(n=0; n<n_size; n++) { for(k=0; k<m; k++) { if(n<Q0_size[k]) { mpfr_printf("%.3Re ",Q0[k][n]); } } printf("\n"); } printf("E=\n"); for(n=0; n<n_size; n++) { for(k=0; k<m; k++) { if(n<E0_size[k]) { mpfr_printf("%.3Re ",E0[k][n]); } } printf("\n"); } } // generate vector E for(k=0; k<m; k++) { rcopy(E1[k],E0[k][0]); } // generate matrix Q for(n=0; n<M; n++) { for(k=0; k<m; k++) { rcopy(MAT(Q1,k,n,LDQ1),Q0[k][n]); } } // genrate matrix A if(A!=NULL) { riep_dhToda_QE_to_A(m,M,A,LDA,Q1,LDQ1,E1,debug); } // done if(Q==NULL) { Q1=rmat_free(LDQ1,M,Q1); } else { Q1=NULL; } if(E==NULL) { E1=rvec_free(m,E1); } else { E1=NULL; } a=rfree(a); f=rvec_free(f_size,f); sigma=rvec_free(m,sigma); for(k=0; k<m; k++) { Q0[k]=rvec_free(Q0_size[k],Q0[k]); } free(Q0); Q0=NULL; for(k=0; k<m; k++) { E0[k]=rvec_free(E0_size[k],E0[k]); } free(E0); E0=NULL; Q0_size=ivec_free(Q0_size); E0_size=ivec_free(E0_size); return; }