From edcded21cbeb272ff206a92c693ab21bf33ebae6 Mon Sep 17 00:00:00 2001 From: Julian Weigt Date: Tue, 23 Dec 2025 15:55:51 +0000 Subject: Define safe sums and products and finish exact version. --- charf.c | 100 ++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 47 deletions(-) (limited to 'charf.c') diff --git a/charf.c b/charf.c index ccbc265..97f9e34 100644 --- a/charf.c +++ b/charf.c @@ -2,11 +2,13 @@ #include #include +#ifndef EXACT #define EXACT false +#endif #if EXACT #include "ratio.h" -#define VALUETYPE ratio +#define VALUETYPE rational #define EXPTYPE unsigned int #else #include "double.h" @@ -22,18 +24,18 @@ void differentiate(VALUETYPE** df, int D, int K){ /*compute kth derivative of f from (k-1)th*/ /*only compute derivatives at arguments i < D-k, because for larger i we would need data from outside the domain of f*/ for(i=0; i Mf[i]) Mf[i] = Af[i][j]; + if(is_greater(Af[i][j], Mf[i])) Mf[i] = Af[i][j]; } } /*Print computed functions and averages*/ - //printf("Mf "); - //for(int i=0;i> i) & 1); + f[(D-N)/2+i+K/2] = convert_int((t >> i) & 1); //if(i%3==0) f[2*N+i+K/2] = 1; } /*Compute ||Mf^{(k)}||_p/||f^{(k)}||_p.*/ - r = compute_derivatives(f, Sf, Af, Mf, df, dMf, p, intdf, intdMf, D, K); + r = compute_derivatives(f, Sf, Af, Mf, df, dMf, p, intdfp, intdMfp, D, K); //printf("%.3d: %.3f \n",t,r); /*Print f and ||Mf^{(k)}||_p/||f^{(k)}||_p if the latter is close to 1/2.*/ - if(r>.4997){ + if(to_double(r)>.4997){ printf("f: "); - for(int i=0;i