-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfundtest.c
211 lines (203 loc) · 3.76 KB
/
fundtest.c
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
/*
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.h"
#include <math.h>
#ifdef SEQUENCE_HUNTER
#if 0
int sequence_func(number_t *retnum,dimension_t *array_indices)
{
dimension_t curr_idx;
dimension_t *temp_indices=alloca(sizeof(dimension_t)*NUM_SEQUENCE_DIMENSIONS);
if(array_indices[0]==0||array_indices[1]<2)
*retnum=3;
else
{
temp_indices[0]=array_indices[0]-1;
temp_indices[1]=arrayindices[1]-2;
*retnum=*(get_array_member(temp_indices))+3;
}
return 0;
}
#endif
#if 0
int sequence_func(number_t *retnum,dimension_t *array_indices)
{
int numprimes=0;
int idx1,idx2;
for(idx1=1;;idx1++)
{
for(idx2=2;idx2<idx1;idx2++)
{
if((idx1%idx2)==0)
goto Skip;
}
if(numprimes==array_indices[0])
{
*retnum=idx1;
break;
}
numprimes++;
Skip:
}
return 0;
}
#endif
#if 0
int sequence_func(number_t *retnum,dimension_t *array_indices)
{
#if 0
int idx2;
for(idx2=2;idx2<array_indices[0];idx2++)
{
if((array_indices[0]%idx2)==0)
{
*retnum=idx2;
return 0;
}
}
*retnum=1;
return 0;
#endif
int i;
long long fact=1;
*retnum=1;
for(i=2;i<array_indices[0];i++)
if(array_indices[0]%i==0)
{
*retnum=i;
break;
}
return 0;
}
#endif
#if 0
double f_of_x(double x)
{
return sin(x*x);
}
#define widthinc (1.0/1024.0)
#define PI 3.14159265
#define NUM_RETVALS 10
int init=FALSE;
double retvals[NUM_RETVALS+1]={0.0,};
void fundfill()
{
int i;
double j,y0,y1,intadd;
double next_crossing=1,x0;
for(i=0;i<NUM_RETVALS;i++)
{
for(j=0;j<1;j+=widthinc)
{
y0=f_of_x(i+j);
y1=f_of_x(i+j+widthinc);
if(y0>=0)
{
if(y1>=0)
{
intadd=((y0+y1)/2)*widthinc;
}
else
{
x0=sqrt(next_crossing++*PI);
intadd=(y0*(x0-(i+j))/2)-(y1*((i+j+widthinc)-x0)/2);
}
}
else
{
if(y1<0)
{
intadd=((y0+y1)/2)*widthinc;
}
else
{
x0=sqrt(next_crossing++*PI);
intadd=(y1*((i+j+widthinc)-x0)/2)-(y0*(x0-(i+j))/2);
}
}
retvals[i+1]+=intadd;
}
if(i>=1)
retvals[i+1]+=retvals[i];
}
init=TRUE;
}
#endif
#if 0
int sequence_func(number_t *retnum,dimension_t *array_indices)
{
#if 0
*retnum=/*sin(array_indices[0]*array_indices[0])+*/(2*cos(array_indices[0]));
return 0;
#endif
if(!init)
{
fundfill();
}
if(array_indices[0]<=NUM_RETVALS)
{
*retnum=retvals[array_indices[0]];
return 0;
}
return 1;
}
#endif
#if 0
int sequence_func(number_t *retnum,dimension_t *array_indices)
{
*retnum=array_indices[0]+array_indices[1];
return 0;
}
#endif
#if 0
int sequence_func(result_t *retnum,dimension_t *array_indices)
{
*retnum=array_indices[0]+array_indices[1];
return 0;
}
#endif
#if 0
int sequence_func(result_t *retnums,dimension_t *array_indices)
{
#ifndef NUM_ANSWERS
*retnums=alloc_result(2);
(*retnums)->answer[0]=array_indices[0]*2;
(*retnums)->answer[1]=array_indices[0]*3;
#else
retnums->answer[0]=array_indices[0]*2;
retnums->answer[1]=array_indices[0]*3;
#endif
return 0;
}
#endif
#if 0
int sequence_func(result_t *retnum,dimension_t *array_indices)
{
*retnum=sin(array_indices[0]);
return 0;
}
#endif
#if 0
int sequence_func(result_t *retnum,dimension_t *array_indices)
{
*retnum=exp(array_indices[0]);
return 0;
}
#endif
#if 0
int sequence_func(result_t *retnum,dimension_t *array_indices)
{
*retnum=array_indices[0]*3+2;
return 0;
}
#endif
int sequence_func(result_t *retnum,dimension_t *array_indices)
{
*retnum=exp(array_indices[0]);
return 0;
}
#endif /* SEQUENCE_HUNTER */