~ubuntu-branches/debian/sid/bc/sid

« back to all changes in this revision

Viewing changes to lib/testmul.c

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2009-04-16 10:23:39 UTC
  • Revision ID: james.westby@ubuntu.com-20090416102339-l7970sr667eekbvw
Tags: 1.06.94-3.1
* Non-maintainer upload with John's permission.
* Apply patch to restore the .dcrc config file (closes: #472250)
* Merge patch from Ubuntu to notice read and write errors on
  input and output (closes: #488735)
* Include the bc manual (HTML) in the bc binary package

* Bump Standards Version to 3.8.1
* Bump debhelper compatibility to 7
* debian/rules: replace "dh_clean -k" with "dh_prep"
* debian/control: Add homepage field
* Fix hyphens in the bc and dc manpages
* Add a watch file
* debian/dc.doc-base: Remove leading whitespace
* debian/dc.doc-base: Move to section Science/Mathematics

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* compute the crossover for recursive and simple multiplication */
2
2
 
3
3
#include <stdio.h>
 
4
#include <stdlib.h>
 
5
#include <string.h>
4
6
#include <time.h>
5
7
#include "number.h"
6
8
#ifndef VARARGS
57
59
  va_end (args);
58
60
  
59
61
  fprintf (stderr, "Runtime error: %s\n", error_mesg);
 
62
  checkferror_output(stderr);
60
63
}
61
64
 
62
65
/* A runtime warning tells of some action taken by the processor that
90
93
  va_end (args);
91
94
 
92
95
  fprintf (stderr, "Runtime warning: %s\n", error_mesg);
 
96
  checkferror_output(stderr);
93
97
}
94
98
 
95
99
void
96
100
out_char (int ch)
97
101
{
98
102
  putchar (ch);
 
103
  checkferror_output(stdout);
99
104
}
100
105
 
101
106
/* Time stuff !!! */
147
152
  bc_init_num (&big);
148
153
  bc_int2num (&ten, 10);
149
154
 
150
 
  if (debug)
 
155
  if (debug) {
151
156
    fprintf (stderr, "Timings are for %d multiplies\n"
152
157
                     "Minimum time is %d seconds\n", test_n,
153
158
             test_time/CLOCKS_PER_SEC);
 
159
    checkferror_output(stderr);
 
160
  }
154
161
 
155
162
  /* Two of the same size */
156
163
  min = 10;
157
164
  max = 500;
158
165
 
159
 
  if (debug)
 
166
  if (debug) {
160
167
    fprintf (stderr, "Testing numbers of the same length.\n");
 
168
    checkferror_output(stderr);
 
169
  }
161
170
 
162
171
  while (min < max) {
163
172
    mid = (min+max)/2;
164
 
    if (debug) fprintf (stderr,"Checking %d...\n", mid);
 
173
    if (debug) {
 
174
      fprintf (stderr,"Checking %d...\n", mid);
 
175
      checkferror_output(stderr);
 
176
    }
165
177
 
166
178
    bc_int2num (&expo, mid);
167
179
    bc_raise (ten, expo, &num, 0);
183
195
    if (debug) {
184
196
      fprintf (stderr, "n1 = %d :: n2 = %d\n", n1, n2);
185
197
      fprintf (stderr, "p1 = %f :: p2 = %f\n", permul1, permul2);
 
198
      checkferror_output(stderr);
186
199
    }
187
200
  }  
188
201
 
189
 
  if (debug)
 
202
  if (debug) {
190
203
    fprintf (stderr, "Base digits crossover at %d digits\n", min);
 
204
    checkferror_output(stderr);
 
205
  }
191
206
  printf ("#define MUL_BASE_DIGITS %d\n", 2*min);
 
207
  checkferror_output(stdout);
192
208
 
193
209
 
194
210
#if 0
204
220
  min = min / 2;
205
221
  max = 500;
206
222
 
207
 
  if (debug)
 
223
  if (debug) {
208
224
    fprintf (stderr, "Testing numbers of the different length.\n");
 
225
    checkferror_output(stderr);
 
226
  }
209
227
 
210
228
  while (min < max) {
211
229
    mid = (min+max)/2;
212
 
    if (debug) fprintf (stderr, "Checking %d...\n", mid);
 
230
    if (debug) {
 
231
      fprintf (stderr, "Checking %d...\n", mid);
 
232
      checkferror_output(stderr);
 
233
    }
213
234
 
214
235
    bc_int2num (&expo, mid-smallsize);
215
236
    bc_raise (ten, expo, &num, 0);
231
252
    if (debug) {
232
253
      fprintf (stderr, "n1 = %d :: n2 = %d\n", n1, n2);
233
254
      fprintf (stderr, "p1 = %f :: p2 = %f\n", permul1, permul2);
 
255
      checkferror_output(stderr);
234
256
    }
235
257
  }  
236
258
  
237
 
  if (debug)
 
259
  if (debug) {
238
260
    fprintf (stderr, "Non equal digits crossover at %d total digits\n", min);
 
261
    checkferror_output(stderr);
 
262
  }
239
263
  printf ("#define MUL_SMALL_DIGITS = %d\n", min);
 
264
  checkferror_output(stdout);
240
265
 
241
266
#endif
242
267