diff options
| author | Julian Weigt <juw@posteo.de> | 2025-12-28 11:20:32 +0000 |
|---|---|---|
| committer | Julian Weigt <juw@posteo.de> | 2026-02-04 15:55:48 +0100 |
| commit | 944f90c47ffcde862dfe5f258de0b1ebf229c20e (patch) | |
| tree | 0d4ef7dd8a8b97c440dc6abec538403c5726d0fd /charf.c | |
| parent | e65748fa8908c46ae2e6af7ef63d28fb3427238d (diff) | |
Implement double arithmetic with error bounds.
Diffstat (limited to 'charf.c')
| -rw-r--r-- | charf.c | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -4,13 +4,21 @@ #include <pthread.h> #include <assert.h> -#ifndef EXACT -#define EXACT false +#define DOUBLEMODE 0 +#define DOUBLEERRORMODE 1 +#define RATIOMODE 2 + +#ifndef MODE +#define MODE DOUBLEMODE #endif #define NUM_THREADS 6 -#if EXACT +#if MODE == DOUBLEERRORMODE +#include "double-error.h" +#define VALUETYPE double_error +#define EXPTYPE double_error +#elif MODE == RATIOMODE #include "ratio.h" #define VALUETYPE rational #define EXPTYPE unsigned int @@ -173,7 +181,9 @@ void compute(EXPTYPE p, int t){ printf("f: "); for(int i=0;i<D;i++) printf("%1.0f ",to_double(f[i])); printf("\n"); - printf("%.4f\n",to_double(r)); + char s[128]; + to_string(s,r); + printf("%.4f (%s)\n",to_double(r),s); } } @@ -194,7 +204,7 @@ void* perform_work(void* arguments){ int main() { /*exponent p of the L^p norm to consider*/ - EXPTYPE p = 1; + EXPTYPE p = to_exptype(1); /*Iterate over all strings of 0s and 1s with length N. Those will represent f.*/ int t = 1; |
