-
Notifications
You must be signed in to change notification settings - Fork 3
/
fundamental.h
703 lines (629 loc) · 14.7 KB
/
fundamental.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
/*
This file is part of fundamental a brute force searcher
for relationships between constants & formulae for sequences.
Copyright (C) 2004 D.J. Barrow [email protected] [email protected]
It is licensed under GPL v2.1
*/
#include "fundamental_config.h"
#if defined(SEQUENCE_HUNTER) || defined(REAL_HUNTER)
#define HUNTER
#endif
#if defined(HAVE_FACTORIAL_OP) || \
defined(HAVE_ABS_OP) || \
defined(HAVE_FLOOR_OP)|| \
defined(HAVE_CEIL_OP) || \
defined(HAVE_RINT_OP) || \
defined(HAVE_SIN_OP) || \
defined(HAVE_COS_OP) || \
defined(HAVE_TAN_OP) || \
defined(HAVE_ONES_COMPLIMENT_OP) || \
defined(HAVE_NOT_OP)
#define HAVE_UNARY_OPERATORS
#endif
#if defined(HAVE_ADDITION_OP) || \
defined(HAVE_SUBTRACTION_OP) || \
defined(HAVE_MULTIPLY_OP) || \
defined(HAVE_DIVIDE_OP) || \
defined(HAVE_POWER_OP) || \
defined(HAVE_MODULO_OP) || \
defined(HAVE_AND_OP) || \
defined(HAVE_OR_OP) || \
defined(HAVE_XOR_OP) || \
defined(HAVE_LOG_SHIFT_OP) || \
defined(HAVE_LOG_RSHIFT_OP) || \
defined(HAVE_LOG_LSHIFT_OP) || \
defined(HAVE_ARITH_SHIFT_OP) || \
defined(HAVE_ROTATE_OP) || \
defined(HAVE_MASK_OP) || \
defined(HAVE_GETBIT_OP) || \
defined(HAVE_LN_OP) || \
defined(HAVE_GCD_OP) || \
defined(HAVE_EQ_COND) || \
defined(HAVE_GT_COND) || \
defined(HAVE_GE_COND) || \
defined(HAVE_LT_COND) || \
defined(HAVE_LE_COND) || \
defined(HAVE_AND_COND) || \
defined(HAVE_OR_COND) || \
defined(HAVE_MIN_OP) || \
defined(HAVE_MAX_OP)
#define HAVE_BINARY_OPERATORS
#endif
#if defined(HAVE_FLOOR_OP)|| \
defined(HAVE_CEIL_OP) || \
defined(HAVE_RINT_OP) || \
defined(HAVE_SIN_OP) || \
defined(HAVE_COS_OP) || \
defined(HAVE_TAN_OP) || \
defined(HAVE_LN_OP)
#define HAVE_FLOATING_POINT_OPERATORS
#endif
#if defined(HAVE_AND_OP) || \
defined(HAVE_OR_OP) || \
defined(HAVE_XOR_OP) || \
defined(HAVE_LOG_SHIFT_OP) || \
defined(HAVE_LOG_RSHIFT_OP) || \
defined(HAVE_LOG_LSHIFT_OP) || \
defined(HAVE_ARITH_SHIFT_OP) || \
defined(HAVE_ROTATE_OP) || \
defined(HAVE_LROTATE_OP) || \
defined(HAVE_RROTATE_OP) || \
defined(HAVE_MASK_OP) || \
defined(HAVE_GETBIT_OP)
#define HAVE_BOOLEAN_OPERATORS
#endif
#if defined(HAVE_EQ_COND) || \
defined(HAVE_GT_COND) || \
defined(HAVE_GE_COND) || \
defined(HAVE_LT_COND) || \
defined(HAVE_LE_COND) || \
defined(HAVE_AND_COND) || \
defined(HAVE_OR_COND)
#define HAVE_CONDITIONALS
#endif
#if defined(HAVE_MIN_OP) || \
defined(HAVE_MAX_OP)
#define HAVE_MIN_MAX_OPERATORS
#endif
#if defined(HAVE_LOG_RSHIFT_OP) || \
defined(HAVE_LOG_LSHIFT_OP) || \
defined(HAVE_SUBTRACTION_OP) || \
defined(HAVE_LROTATE_OP) || \
defined(HAVE_RROTATE_OP)
#define HAVE_EXCESS_INTEGER_UNSIGNED_OPERATORS
#endif
#if defined(HAVE_LMS_ERROR) || \
defined(HAVE_ABS_ERROR) || \
defined(HAVE_LMS_RATIOED_ERROR) || \
defined(HAVE_ABS_RATIOED_ERROR) || \
defined(HAVE_LMS_GT_ERROR) || \
defined(HAVE_GT_ERROR) || \
defined(HAVE_LMS_GT_RATIOED_ERROR) || \
defined(HAVE_GT_RATIOED_ERROR) || \
defined(HAVE_LMS_LT_ERROR) || \
defined(HAVE_LT_ERROR) || \
defined(HAVE_LMS_LT_RATIOED_ERROR) || \
defined(HAVE_LT_RATIOED_ERROR)
#define HAVE_ERROR_MEASUREMENTS
#endif
#if defined(HAVE_LMS_ERROR) || \
defined(HAVE_LMS_RATIOED_ERROR) || \
defined(HAVE_LMS_GT_ERROR) || \
defined(HAVE_LMS_GT_RATIOED_ERROR) || \
defined(HAVE_LMS_LT_ERROR) || \
defined(HAVE_LMS_LT_RATIOED_ERROR)
#define HAVE_LMS_ERROR_MEASUREMENTS
#endif
#if defined(HAVE_LMS_RATIOED_ERROR) || \
defined(HAVE_LMS_GT_RATIOED_ERROR) || \
defined(HAVE_LMS_LT_RATIOED_ERROR)
#define HAVE_LMS_RATIOED_ERROR_MEASUREMENTS
#endif
#if defined(HAVE_ABS_RATIOED_ERROR) || \
defined(HAVE_GT_RATIOED_ERROR) || \
defined(HAVE_LT_RATIOED_ERROR)
#define HAVE_POWER1_RATIOED_ERROR_MEASUREMENTS
#endif
#if defined(HAVE_POWER1_RATIOED_ERROR_MEASUREMENTS) || \
defined(HAVE_LMS_RATIOED_ERROR_MEASUREMENTS)
#define HAVE_RATIOED_ERROR_MEASUREMENTS
#endif
#if defined(HAVE_LMS_GT_ERROR) || \
defined(HAVE_GT_ERROR) || \
defined(HAVE_LMS_GT_RATIOED_ERROR) || \
defined(HAVE_GT_RATIOED_ERROR)
#define HAVE_GT_ERROR_MEASUREMENTS
#endif
#if defined(HAVE_LMS_LT_ERROR) || \
defined(HAVE_LT_ERROR) || \
defined(HAVE_LMS_LT_RATIOED_ERROR) || \
defined(HAVE_LT_RATIOED_ERROR)
#define HAVE_LT_ERROR_MEASUREMENTS
#endif
#include "fundamental_sanity.h"
#include "defs.h"
#ifndef NUM_INTEGER_BITS
#include <math.h>
#endif
//#define NDEBUG
#include <assert.h>
#ifdef NUM_INTEGER_BITS
#if NUM_INTEGER_BITS>32
#ifdef SIGNED_OPERATION
typedef long long number_t;
typedef long long uint_t;
#define NUMBER_FORMAT "%lld"
#else
typedef unsigned long long number_t;
typedef unsigned long long uint_t;
#define NUMBER_FORMAT "%llu"
#endif
/* atoll will break for unsigned numbers > signed long long */
#define ASCII_TO_NUM atoll
typedef unsigned long long unsigned_number_t;
typedef unsigned long long uint_t;
#if NUM_INTEGER_BITS!=64
#define RESULT_MASK (((1ULL<<NUM_INTEGER_BITS)-1))
#ifdef SIGNED_OPERATION
#define IS_NEGATIVE(val) (val&(1ULL<<(NUM_INTEGER_BITS-1)))
#define MAKE_POSITIVE(val) (((val^RESULT_MASK)+1ULL)&RESULT_MASK)
#endif
#endif
#else /* NUM_INTEGER_BITS>32 */
#ifdef SIGNED_OPERATION
typedef long number_t;
typedef unsigned long uint_t;
#define NUMBER_FORMAT "%ld"
#define ASCII_TO_NUM atol
#else
typedef unsigned long number_t;
typedef unsigned long uint_t;
#define NUMBER_FORMAT "%lu"
#define ASCII_TO_NUM (number_t)atoll
#endif
typedef unsigned long unsigned_number_t;
#if NUM_INTEGER_BITS!=32
#define RESULT_MASK (((1UL<<NUM_INTEGER_BITS)-1))
#ifdef SIGNED_OPERATION
#define IS_NEGATIVE(val) (val&(1UL<<(NUM_INTEGER_BITS-1)))
#define MAKE_POSITIVE(val) (((val^RESULT_MASK)+1UL)&RESULT_MASK)
#endif
#endif
#if defined (RESULT_MASK) && defined(SIGNED_OPERATION)
#define SIGN_EXTEND(val) (IS_NEGATIVE(val) ? ((val)|(~RESULT_MASK)):(val))
#else
#define SIGN_EXTEND(val) (val)
#ifdef SIGNED_OPERATION
#define IS_NEGATIVE(val) (val<0)
#define MAKE_POSITIVE(val) (-val)
#else
#define IS_NEGATIVE(val) (0)
#define MAKE_POSITIVE(val) (val)
#endif
#endif
#endif
#else /* NUM_INTEGER_BITS */
#define SIGN_EXTEND(val) (val)
#define IS_NEGATIVE(val) (val<0)
#define MAKE_POSITIVE(val) (-val)
typedef long long int_t;
typedef unsigned long long uint_t;
#define MAX_INT_T ((int_t)(~0ULL>>1))
#define MIN_INT_T (int_t)((uint_t)(~0ULL>>1)+1)
#endif
#ifndef NUM_INTEGER_BITS
typedef double number_t;
#define NUMBER_FORMAT "%e"
#define ASCII_TO_NUM atof
#endif
#ifdef MULTIPLE_RESULTS
typedef struct
{
#ifdef NUM_ANSWERS
number_t answer[NUM_ANSWERS];
#else
int num_answers;
number_t answer[0];
#endif
}
#if defined(SPARSE_ARRAY_INDICES) || !defined(NUM_ANSWERS)
result_array_t,*result_t;
#else
result_t;
#endif /* SPARSE_ARRAY_INDICES */
#else
typedef number_t result_t;
#endif /* MULTIPLE_RESULTS */
#ifdef MULTIPLE_RESULTS
#ifdef NUM_ANSWERS
#ifdef SPARSE_ARRAY_INDICES
extern result_t alloc_result(void);
#endif
#else /* NUM_ANSWERS */
extern result_t alloc_result(int num_answers);
#endif /* NUM_ANSWERS */
#endif
#ifdef REAL_HUNTER
#define MULTI_DIMENSIONAL (!defined(NUM_HUNTER_DIMENSIONS) || NUM_HUNTER_DIMENSIONS>1)
#ifndef NUM_HUMTER_DIMENSIONS
extern int NUM_HUMTER_DIMENSIONS;
#else
#ifdef SEQUENCE_HUNTER
#define MULTI_DIMENSIONAL (!defined(NUM_SEQUENCE_DIMENSIONS) || NUM_SEQUENCE_DIMENSIONS>1)
#endif
#endif
#endif
#ifdef SEQUENCE_HUNTER
typedef unsigned long dimension_t;
#ifdef HAVE_FUNCTIONS
extern dimension_t curr_seed;
#endif
#define MAX_DIMENSION ((dimension_t)-1)
#define DIMENSION_FORMAT "%lu"
extern int sequence_func(result_t *retnums,dimension_t *array_indices);
extern result_t *get_array_member(dimension_t *array_indices,dimension_t *idxptr);
#endif
#ifdef REAL_HUNTER
#define DIMENSION_FORMAT "%lu"
#endif
typedef int depth_t;
#define DEPTH_CHANGE_FORMAT "%d"
#ifdef HAVE_PRINT_SUM_INFIX
struct infix_tree;
struct infix_tree
{
int has_parent;
depth_t depth;
depth_t child[];
};
extern struct infix_tree **tree_members;
#endif
typedef enum
{
null_op=-1,
first_op=0,
#ifdef HAVE_UNARY_OPERATORS
first_unary_op=first_op,
dummy_op0=first_unary_op-1,
#ifdef HAVE_FACTORIAL_OP
factorial_op,
#endif
#ifdef HAVE_ABS_OP
abs_op,
#endif
#ifdef HAVE_FLOOR_OP
floor_op,
#endif
#ifdef HAVE_CEIL_OP
ceil_op,
#endif
#ifdef HAVE_RINT_OP
rint_op,
#endif
#ifdef HAVE_SIN_OP
sin_op,
#endif
#ifdef HAVE_COS_OP
cos_op,
#endif
#ifdef HAVE_TAN_OP
tan_op,
#endif
#ifdef HAVE_ONES_COMPLIMENT_OP
ones_compliment_op,
#endif
#ifdef HAVE_NOT_OP
not_op,
#endif
unary_op_idx,
last_unary_op=unary_op_idx-1,
#endif /* UNARY_OPERATORS */
#ifdef HAVE_BINARY_OPERATORS
first_binary_op
#ifndef HAVE_UNARY_OPERATORS
=first_op
#endif
,
dummy_op1=first_binary_op-1,
#endif
#ifdef HAVE_ADDITION_OP
addition_op,
#endif
#ifdef HAVE_SUBTRACTION_OP
subtraction_op,
#endif
#ifdef HAVE_MULTIPLY_OP
multiply_op,
#endif
#ifdef HAVE_DIVIDE_OP
divide_op,
#endif
#ifdef HAVE_POWER_OP
power_op,
#endif
#ifdef HAVE_MODULO_OP
modulo_op,
#endif
#ifdef HAVE_AND_OP
and_op,
#endif
#ifdef HAVE_OR_OP
or_op,
#endif
#ifdef HAVE_XOR_OP
xor_op,
#endif
#ifdef HAVE_LOG_SHIFT_OP
log_shift_op,
#endif
#ifdef HAVE_LOG_RSHIFT_OP
log_rshift_op,
#endif
#ifdef HAVE_LOG_LSHIFT_OP
log_lshift_op,
#endif
#ifdef HAVE_ARITH_SHIFT_OP
arith_shift_op,
#endif
#ifdef HAVE_ROTATE_OP
rotate_op,
#endif
#ifdef HAVE_LROTATE_OP
lrotate_op,
#endif
#ifdef HAVE_RROTATE_OP
rrotate_op,
#endif
#ifdef HAVE_MASK_OP
mask_op,
#endif
#ifdef HAVE_GETBIT_OP
getbit_op,
#endif
#ifdef HAVE_LN_OP
ln_op,
#endif
#ifdef HAVE_GCD_OP
gcd_op,
#endif
#ifdef HAVE_EQ_COND
eq_cond,
#endif
#ifdef HAVE_GT_COND
gt_cond,
#endif
#ifdef HAVE_GE_COND
ge_cond,
#endif
#ifdef HAVE_LT_COND
lt_cond,
#endif
#ifdef HAVE_LE_COND
le_cond,
#endif
#ifdef HAVE_AND_COND
and_cond,
#endif
#ifdef HAVE_OR_COND
or_cond,
#endif
#ifdef HAVE_MIN_OP
min_op,
#endif
#ifdef HAVE_MAX_OP
max_op,
#endif
binary_op_idx,
last_binary_op=binary_op_idx-1,
num_operators,
} operation;
extern depth_t op_depth[num_operators];
#ifdef HAVE_UNARY_OPERATORS
#define min_operator_depth (1)
#ifndef HAVE_BINARY_OPERATORS
#define max_operator_depth (1)
#endif
#else
#ifdef HAVE_BINARY_OPERATORS
#define min_operator_depth (2)
#endif
#endif
#ifdef HAVE_BINARY_OPERATORS
#define max_operator_depth (2)
#endif
#ifdef HAVE_CONSTANTS_FILE
struct fundamental_constant
{
struct fundamental_constant *next;
char type;
int used;
number_t value;
char name[0];
};
typedef struct fundamental_constant fundamental_constant;
extern fundamental_constant *head,**fundamental_list;
extern int num_constants;
#endif
typedef enum
{
invalid_tag=-1,
first_tag,
dummy_tag=first_tag-1,
#ifdef HUNTER
dimension_tag,
#endif
#ifdef HAVE_CONSTANTS_FILE
constant_tag,
#endif
integer_tag,
last_number_tag=integer_tag,
arithmetic_operation_tag,
#ifdef HAVE_FUNCTIONS
function_tag,
#endif
dummy_tag0,
max_tag=dummy_tag0-1
} stack_tag;
#ifdef HAVE_SIMPLIFICATION_TEST
typedef unsigned simplify_result_tag_t;
void init_simplifyable(void);
#endif /* HAVE_SIMPLIFICATION_TEST */
#define is_operator(tag) ((tag)>last_number_tag)
#define is_number(tag) ((tag)<=last_number_tag)
typedef long stackval_t;
#define STACKVAL_FORMAT "%ld"
#define abort_sum(err,format...) \
{ \
debug_printf(format); \
return(err); \
}
#ifdef MULTIPLE_RESULTS
dimension_t *retvals;
#ifdef NUM_ANSWERS
#define MAX_NUM_RESULTS (NUM_ANSWERS)
#else
dimension_t MAX_NUM_RESULTS;
#endif
#endif
extern int num_answers,max_num_answers;
#ifdef HAVE_ERROR_MEASUREMENTS
/* Better to leave as long double 12 byte float on intel to minimise risk of overflow */
typedef long double error_t;
#define ERROR_FORMAT "%Le"
enum
{
#ifdef HAVE_LMS_ERROR
lms_error,
#endif
#ifdef HAVE_ABS_ERROR
abs_error,
#endif
#ifdef HAVE_LMS_RATIOED_ERROR
lms_ratioed_error,
#endif
#ifdef HAVE_ABS_RATIOED_ERROR
abs_ratioed_error,
#endif
#ifdef HAVE_LMS_GT_ERROR
lms_gt_error,
#endif
#ifdef HAVE_GT_ERROR
gt_error,
#endif
#ifdef HAVE_LMS_GT_RATIOED_ERROR
lms_gt_ratioed_error,
#endif
#ifdef HAVE_GT_RATIOED_ERROR
gt_ratioed_error,
#endif
#ifdef HAVE_LMS_LT_ERROR
lms_lt_error,
#endif
#ifdef HAVE_LT_ERROR
lt_error,
#endif
#ifdef HAVE_LMS_LT_RATIOED_ERROR
lms_lt_ratioed_error,
#endif
#ifdef HAVE_LT_RATIOED_ERROR
lt_ratioed_error,
#endif
NUM_ERROR_MEASUREMENTS
};
#endif
typedef struct
{
stack_tag tag;
#ifdef SIGNED_OPERATION
int minus;
#endif
stackval_t val;
} stack_entry;
depth_t get_op_depth(stack_entry *curr);
typedef struct
{
int stack_depth;
#ifdef HAVE_FUNCTIONS
dimension_t seed;
#endif
number_t *result_stack;
stack_entry stack[];
} sum_t;
#if defined(MULTIPLE_RESULTS) || defined(HAVE_FUNCTIONS)
extern void print_sum_preamble(sum_t *sum);
#define PRINT_SUM_PREAMBLE(sum) print_sum_preamble(sum);
#else
#define PRINT_SUM_PREAMBLE(sum)
#endif
#define PRINT_SUM_POSTAMBLE(sum) print_sum_postamble(sum);
#ifdef HAVE_PRINT_SUM_INFIX
extern void print_sum_infix(sum_t *sum);
#endif
#ifdef HAVE_PRINT_SUM_RPN
extern void print_sum_rpn(sum_t *sum);
#endif
extern void print_sum(sum_t *sum);
#if defined(HAVE_PRINT_SUM_INFIX) && defined(HAVE_PRINT_SUM_RPN)
#define PRINT_SUM(sum1) {print_sum_preamble(sum1) print_sum_rpn(sum1);print_sum_infix(sum1);print_sum_postamble(sum1)}
#endif
#if defined(HAVE_PRINT_SUM_RPN) && !defined(HAVE_PRINT_SUM_INFIX)
#define PRINT_SUM(sum1)\
PRINT_SUM_PREAMBLE(sum1)\
print_sum_rpn(sum1);\
PRINT_SUM_POSTAMBLE(sum1)
#endif
#if defined(HAVE_PRINT_SUM_INFIX) && !defined(HAVE_PRINT_SUM_RPN)
#define PRINT_SUM(sum1)\
PRINT_SUM_PREAMBLE(sum1)\
print_sum_infix(sum1);\
PRINT_SUM_POSTAMBLE(sum1)
#endif /* defined(HAVE_PRINT_SUM_INFIX) && defined(HAVE_PRINT_SUM_RPN) */
#ifdef HAVE_ERROR_MEASUREMENTS
extern void print_error_measurements(void);
#endif
#ifdef HAVE_ERROR_MEASUREMENTS
#define __KERNEL__
#include <linux/list.h>
#undef __KERNEL
typedef struct
{
struct list_head list;
error_t error_val;
int processed;
sum_t sum;
} error_list_element;
extern struct list_head error_list[NUM_ERROR_MEASUREMENTS];
#endif
typedef struct
{
#ifdef HUNTER
int num_sequence_correct_depth;
#endif
#if !defined(NUM_INTEGER_BITS) && !defined(ERROR_OP)
number_t sum_correct_error_tolerance;
#endif
int sum_correct;
int aborted;
} calculate_sum_result;
typedef void (*calculate_sum_func_t)(calculate_sum_result *retval);
extern calculate_sum_result calculate_sum(sum_t *sum,calculate_sum_func_t sum_func);
#ifndef NUM_INTEGER_BITS
extern int number_to_int_t(number_t *numval,int_t *intval);
#endif
#ifdef SEQUENCE_HUNTER
//extern dimension_t *array_indices;
#endif
extern number_t *result_stack;
extern int max_stack_depth;
#ifdef REAL_HUNTER
extern number_t *coord_and_result_array;
extern int num_real_coord_idx;
#ifndef NUM_HUNTER_DIMENSIONS
extern number_t NUM_HUNTER_DIMENSIONS;
#endif
#endif
#ifdef SEQUENCE_HUNTER
#ifndef NUM_SEQUENCE_DIMENSIONS
extern dimension_t NUM_SEQUENCE_DIMENSIONS;
#endif
#endif