eyeling 1.15.6 → 1.15.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,302 @@
1
+ # ===================================================
2
+ # Fast Fourier Transform (FFT)
3
+ # Numeric version with explicit complex pairs (re im)
4
+ # 32nd roots of unity are baked in as constants
5
+ # Ccompute the whole spectrum once per waveform
6
+ # ===================================================
7
+
8
+ @prefix : <http://example.org/fft32#>.
9
+ @prefix math: <http://www.w3.org/2000/10/swap/math#>.
10
+ @prefix log: <http://www.w3.org/2000/10/swap/log#>.
11
+
12
+ # ----------------------------------------------
13
+ # 32nd roots of unity: W32^k = exp(-2*pi*i*k/32)
14
+ # represented as (re im)
15
+ # ----------------------------------------------
16
+ 0 :w32 (1.0 0.0).
17
+ 1 :w32 (0.98078528040323043 -0.19509032201612825).
18
+ 2 :w32 (0.92387953251128674 -0.38268343236508978).
19
+ 3 :w32 (0.83146961230254524 -0.55557023301960218).
20
+ 4 :w32 (0.70710678118654757 -0.70710678118654746).
21
+ 5 :w32 (0.55557023301960229 -0.83146961230254524).
22
+ 6 :w32 (0.38268343236508984 -0.92387953251128674).
23
+ 7 :w32 (0.19509032201612833 -0.98078528040323043).
24
+ 8 :w32 (0.0 -1.0).
25
+ 9 :w32 (-0.19509032201612819 -0.98078528040323043).
26
+ 10 :w32 (-0.38268343236508973 -0.92387953251128674).
27
+ 11 :w32 (-0.55557023301960196 -0.83146961230254546).
28
+ 12 :w32 (-0.70710678118654746 -0.70710678118654757).
29
+ 13 :w32 (-0.83146961230254535 -0.55557023301960218).
30
+ 14 :w32 (-0.92387953251128674 -0.38268343236508989).
31
+ 15 :w32 (-0.98078528040323043 -0.19509032201612861).
32
+ 16 :w32 (-1.0 0.0).
33
+ 17 :w32 (-0.98078528040323043 0.19509032201612836).
34
+ 18 :w32 (-0.92387953251128685 0.38268343236508967).
35
+ 19 :w32 (-0.83146961230254546 0.55557023301960196).
36
+ 20 :w32 (-0.70710678118654768 0.70710678118654746).
37
+ 21 :w32 (-0.55557023301960218 0.83146961230254524).
38
+ 22 :w32 (-0.38268343236509034 0.92387953251128652).
39
+ 23 :w32 (-0.19509032201612866 0.98078528040323032).
40
+ 24 :w32 (0.0 1.0).
41
+ 25 :w32 (0.1950903220161283 0.98078528040323043).
42
+ 26 :w32 (0.38268343236509 0.92387953251128663).
43
+ 27 :w32 (0.55557023301960184 0.83146961230254546).
44
+ 28 :w32 (0.70710678118654735 0.70710678118654768).
45
+ 29 :w32 (0.83146961230254524 0.55557023301960218).
46
+ 30 :w32 (0.92387953251128652 0.38268343236509039).
47
+ 31 :w32 (0.98078528040323032 0.19509032201612872).
48
+
49
+ # --------------------------------------------
50
+ # Complex arithmetic on explicit pairs (re im)
51
+ # --------------------------------------------
52
+
53
+ # (a+bi) + (c+di) = (a+c) + (b+d)i
54
+ { ((?ar ?ai) (?br ?bi)) :cAdd (?cr ?ci). } <= { (?ar ?br) math:sum ?cr. (?ai ?bi) math:sum ?ci. }.
55
+
56
+ # (a+bi) - (c+di) = (a-c) + (b-d)i
57
+ { ((?ar ?ai) (?br ?bi)) :cSub (?cr ?ci). } <= { (?ar ?br) math:difference ?cr. (?ai ?bi) math:difference ?ci. }.
58
+
59
+ # (a+bi) * (c+di) = (ac-bd) + (ad+bc)i
60
+ { ((?ar ?ai) (?br ?bi)) :cMul (?cr ?ci). } <= { (?ar ?br) math:product ?ac. (?ai ?bi) math:product ?bd. (?ac ?bd) math:difference ?cr. (?ar ?bi) math:product ?ad. (?ai ?br) math:product ?bc. (?ad ?bc) math:sum ?ci. }.
61
+
62
+ # -------------------------
63
+ # Numeric FFT vector rules
64
+ # -------------------------
65
+
66
+ # Base case: one real sample x becomes the complex number (x 0)
67
+ { (?x) :fft1 (?x 0.0). } <= {}.
68
+
69
+ # ---------
70
+ # Length 2
71
+ # ---------
72
+
73
+ {
74
+ (?x0 ?x1) :fft2 (?y0 ?y1).
75
+ } <= {
76
+ (?x0) :fft1 ?e0.
77
+ (?x1) :fft1 ?o0.
78
+
79
+ (?e0 ?o0) :cAdd ?y0.
80
+ (?e0 ?o0) :cSub ?y1.
81
+ }.
82
+
83
+ # ---------
84
+ # Length 4
85
+ # ---------
86
+
87
+ {
88
+ (?x0 ?x1 ?x2 ?x3) :fft4 (?y0 ?y1 ?y2 ?y3).
89
+ } <= {
90
+ (?x0 ?x2) :fft2 (?e0 ?e1).
91
+ (?x1 ?x3) :fft2 (?o0 ?o1).
92
+
93
+ (?e0 ?o0) :cAdd ?y0.
94
+ (?e0 ?o0) :cSub ?y2.
95
+
96
+ 8 :w32 ?w1.
97
+ (?w1 ?o1) :cMul ?t1.
98
+ (?e1 ?t1) :cAdd ?y1.
99
+ (?e1 ?t1) :cSub ?y3.
100
+ }.
101
+
102
+ # ---------
103
+ # Length 8
104
+ # ---------
105
+
106
+ {
107
+ (?x0 ?x1 ?x2 ?x3 ?x4 ?x5 ?x6 ?x7) :fft8 (?y0 ?y1 ?y2 ?y3 ?y4 ?y5 ?y6 ?y7).
108
+ } <= {
109
+ (?x0 ?x2 ?x4 ?x6) :fft4 (?e0 ?e1 ?e2 ?e3).
110
+ (?x1 ?x3 ?x5 ?x7) :fft4 (?o0 ?o1 ?o2 ?o3).
111
+
112
+ (?e0 ?o0) :cAdd ?y0.
113
+ (?e0 ?o0) :cSub ?y4.
114
+
115
+ 4 :w32 ?w1.
116
+ (?w1 ?o1) :cMul ?t1.
117
+ (?e1 ?t1) :cAdd ?y1.
118
+ (?e1 ?t1) :cSub ?y5.
119
+
120
+ 8 :w32 ?w2.
121
+ (?w2 ?o2) :cMul ?t2.
122
+ (?e2 ?t2) :cAdd ?y2.
123
+ (?e2 ?t2) :cSub ?y6.
124
+
125
+ 12 :w32 ?w3.
126
+ (?w3 ?o3) :cMul ?t3.
127
+ (?e3 ?t3) :cAdd ?y3.
128
+ (?e3 ?t3) :cSub ?y7.
129
+ }.
130
+
131
+ # ---------
132
+ # Length 16
133
+ # ---------
134
+
135
+ {
136
+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32 ?w3.
204
+ (?w3 ?o3) :cMul ?t3.
205
+ (?e3 ?t3) :cAdd ?y3.
206
+ (?e3 ?t3) :cSub ?y19.
207
+
208
+ 4 :w32 ?w4.
209
+ (?w4 ?o4) :cMul ?t4.
210
+ (?e4 ?t4) :cAdd ?y4.
211
+ (?e4 ?t4) :cSub ?y20.
212
+
213
+ 5 :w32 ?w5.
214
+ (?w5 ?o5) :cMul ?t5.
215
+ (?e5 ?t5) :cAdd ?y5.
216
+ (?e5 ?t5) :cSub ?y21.
217
+
218
+ 6 :w32 ?w6.
219
+ (?w6 ?o6) :cMul ?t6.
220
+ (?e6 ?t6) :cAdd ?y6.
221
+ (?e6 ?t6) :cSub ?y22.
222
+
223
+ 7 :w32 ?w7.
224
+ (?w7 ?o7) :cMul ?t7.
225
+ (?e7 ?t7) :cAdd ?y7.
226
+ (?e7 ?t7) :cSub ?y23.
227
+
228
+ 8 :w32 ?w8.
229
+ (?w8 ?o8) :cMul ?t8.
230
+ (?e8 ?t8) :cAdd ?y8.
231
+ (?e8 ?t8) :cSub ?y24.
232
+
233
+ 9 :w32 ?w9.
234
+ (?w9 ?o9) :cMul ?t9.
235
+ (?e9 ?t9) :cAdd ?y9.
236
+ (?e9 ?t9) :cSub ?y25.
237
+
238
+ 10 :w32 ?w10.
239
+ (?w10 ?o10) :cMul ?t10.
240
+ (?e10 ?t10) :cAdd ?y10.
241
+ (?e10 ?t10) :cSub ?y26.
242
+
243
+ 11 :w32 ?w11.
244
+ (?w11 ?o11) :cMul ?t11.
245
+ (?e11 ?t11) :cAdd ?y11.
246
+ (?e11 ?t11) :cSub ?y27.
247
+
248
+ 12 :w32 ?w12.
249
+ (?w12 ?o12) :cMul ?t12.
250
+ (?e12 ?t12) :cAdd ?y12.
251
+ (?e12 ?t12) :cSub ?y28.
252
+
253
+ 13 :w32 ?w13.
254
+ (?w13 ?o13) :cMul ?t13.
255
+ (?e13 ?t13) :cAdd ?y13.
256
+ (?e13 ?t13) :cSub ?y29.
257
+
258
+ 14 :w32 ?w14.
259
+ (?w14 ?o14) :cMul ?t14.
260
+ (?e14 ?t14) :cAdd ?y14.
261
+ (?e14 ?t14) :cSub ?y30.
262
+
263
+ 15 :w32 ?w15.
264
+ (?w15 ?o15) :cMul ?t15.
265
+ (?e15 ?t15) :cAdd ?y15.
266
+ (?e15 ?t15) :cSub ?y31.
267
+ }.
268
+
269
+ # ---------
270
+ # waveforms
271
+ # ---------
272
+
273
+ # alternating
274
+ (1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1) a :WaveForm.
275
+
276
+ # constant ones
277
+ (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) a :WaveForm.
278
+
279
+ # cosine bin3
280
+ (1 0.83146961230254501 0.38268343236509 -0.195090322016128 -0.70710678118654702 -0.98078528040322999 -0.92387953251128696 -0.55557023301960196 0 0.55557023301960196 0.92387953251128696 0.98078528040322999 0.70710678118654802 0.195090322016129 -0.38268343236509 -0.83146961230254501 -1 -0.83146961230254601 -0.382683432365091 0.195090322016127 0.70710678118654702 0.98078528040322999 0.92387953251128696 0.55557023301960295 0.000000000000001 -0.55557023301960196 -0.92387953251128596 -0.98078528040323099 -0.70710678118654702 -0.19509032201613 0.38268343236509 0.83146961230254401) a :WaveForm.
281
+
282
+ # impulse
283
+ (1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) a :WaveForm.
284
+
285
+ # ramp 0-32
286
+ (0 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) a :WaveForm.
287
+
288
+ # sine bin5
289
+ (0 0.83146961230254501 0.92387953251128696 0.195090322016129 -0.70710678118654702 -0.98078528040322999 -0.38268343236509 0.55557023301960196 1 0.55557023301960196 -0.38268343236509 -0.98078528040323099 -0.70710678118654802 0.195090322016127 0.92387953251128596 0.83146961230254601 0.000000000000001 -0.83146961230254501 -0.92387953251128696 -0.195090322016128 0.70710678118654802 0.98078528040322999 0.382683432365089 -0.55557023301960295 -1 -0.55557023301960395 0.38268343236508801 0.98078528040322999 0.70710678118654902 -0.195090322016127 -0.92387953251128596 -0.83146961230254601) a :WaveForm.
290
+
291
+ # -----
292
+ # Query
293
+ # -----
294
+
295
+ {
296
+ ?in a :WaveForm.
297
+ ?in :fft32 ?out.
298
+ }
299
+ log:query
300
+ {
301
+ ?in :fft ?out.
302
+ }.
@@ -0,0 +1,9 @@
1
+ @prefix : <http://example.org/fft32#> .
2
+ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
3
+
4
+ (0 0.83146961230254501 0.92387953251128696 0.195090322016129 -0.70710678118654702 -0.98078528040322999 -0.38268343236509 0.55557023301960196 1 0.55557023301960196 -0.38268343236509 -0.98078528040323099 -0.70710678118654802 0.195090322016127 0.92387953251128596 0.83146961230254601 0.000000000000001 -0.83146961230254501 -0.92387953251128696 -0.195090322016128 0.70710678118654802 0.98078528040322999 0.382683432365089 -0.55557023301960295 -1 -0.55557023301960395 0.38268343236508801 0.98078528040322999 0.70710678118654902 -0.195090322016127 -0.92387953251128596 -0.83146961230254601) :fft (("-2.9968028886505635e-15"^^xsd:decimal "0"^^xsd:decimal) ("2.7410764551198392e-15"^^xsd:decimal "-2.0320206323861304e-15"^^xsd:decimal) ("6.653803231410531e-15"^^xsd:decimal "-2.935201360539696e-15"^^xsd:decimal) ("-3.263161509486249e-15"^^xsd:decimal "5.895742328325398e-15"^^xsd:decimal) ("-3.118026263548378e-15"^^xsd:decimal "1.7057423285703395e-15"^^xsd:decimal) ("-8.327471962526034e-15"^^xsd:decimal "-16"^^xsd:decimal) ("-1.8187743254395905e-15"^^xsd:decimal "-8.649275785265081e-16"^^xsd:decimal) ("-7.698815671630478e-16"^^xsd:decimal "-5.907250600715114e-15"^^xsd:decimal) ("5.996003610813205e-15"^^xsd:decimal "9.992007221626409e-16"^^xsd:decimal) ("-1.046010004595602e-15"^^xsd:decimal "7.32799883525688e-17"^^xsd:decimal) ("-4.2047531300660247e-16"^^xsd:decimal "5.481556342888897e-16"^^xsd:decimal) ("3.4408920985006257e-15"^^xsd:decimal "0"^^xsd:decimal) ("1.1212233748978148e-15"^^xsd:decimal "-2.9265911575494193e-16"^^xsd:decimal) ("1.6825725784634528e-15"^^xsd:decimal "-8.40438346133828e-16"^^xsd:decimal) ("-4.145535929643375e-16"^^xsd:decimal "-1.522118147724299e-15"^^xsd:decimal) ("1.3184849660375944e-15"^^xsd:decimal "-1.5590910214806506e-15"^^xsd:decimal) ("2.998401444325282e-15"^^xsd:decimal "0"^^xsd:decimal) ("9.36240855879889e-16"^^xsd:decimal "1.5259059172126727e-15"^^xsd:decimal) ("-4.145535929643375e-16"^^xsd:decimal "1.5221181477242987e-15"^^xsd:decimal) ("2.151339929186374e-15"^^xsd:decimal "1.2096850292756035e-15"^^xsd:decimal) ("1.1212233748978148e-15"^^xsd:decimal "2.926591157549422e-16"^^xsd:decimal) ("5.543122344752187e-16"^^xsd:decimal "0"^^xsd:decimal) ("-4.2047531300660207e-16"^^xsd:decimal "-5.481556342888898e-16"^^xsd:decimal) ("-5.348202489988052e-16"^^xsd:decimal "8.574383478270009e-16"^^xsd:decimal) ("5.996003610813205e-15"^^xsd:decimal "-9.992007221626409e-16"^^xsd:decimal) ("-1.3022367882033748e-15"^^xsd:decimal "5.761905245021641e-15"^^xsd:decimal) ("-1.8187743254395905e-15"^^xsd:decimal "8.649275785265076e-16"^^xsd:decimal) ("-1.3434497875801754e-14"^^xsd:decimal "16"^^xsd:decimal) ("-3.118026263548378e-15"^^xsd:decimal "-1.7057423285703398e-15"^^xsd:decimal) ("-3.2384833686133903e-15"^^xsd:decimal "-6.2649890114671735e-15"^^xsd:decimal) ("6.653803231410531e-15"^^xsd:decimal "2.935201360539697e-15"^^xsd:decimal) ("3.0916442077252603e-15"^^xsd:decimal "1.2798327561680123e-15"^^xsd:decimal)) .
5
+ (0 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) :fft ((496 "0"^^xsd:decimal) ("-16.000000000000004"^^xsd:decimal "162.45072620174173"^^xsd:decimal) ("-16"^^xsd:decimal "80.43743187401355"^^xsd:decimal) ("-16.000000000000007"^^xsd:decimal "52.74493134301312"^^xsd:decimal) ("-16"^^xsd:decimal "38.62741699796952"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "29.93389458863023"^^xsd:decimal) ("-16.000000000000004"^^xsd:decimal "23.945692202647823"^^xsd:decimal) ("-16.000000000000004"^^xsd:decimal "19.49605640940763"^^xsd:decimal) ("-16"^^xsd:decimal "16"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "13.13086065325857"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "10.690858206708782"^^xsd:decimal) ("-16.000000000000007"^^xsd:decimal "8.552178175212664"^^xsd:decimal) ("-16"^^xsd:decimal "6.627416997969519"^^xsd:decimal) ("-15.999999999999995"^^xsd:decimal "4.853546937717482"^^xsd:decimal) ("-16.000000000000004"^^xsd:decimal "3.1825978780745316"^^xsd:decimal) ("-16.00000000000003"^^xsd:decimal "1.5758624537146346"^^xsd:decimal) (-16 "0"^^xsd:decimal) ("-15.999999999999996"^^xsd:decimal "-1.5758624537146204"^^xsd:decimal) ("-16"^^xsd:decimal "-3.1825978780745245"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "-4.8535469377174785"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "-6.627416997969519"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "-8.552178175212667"^^xsd:decimal) ("-15.999999999999996"^^xsd:decimal "-10.690858206708786"^^xsd:decimal) ("-16.000000000000004"^^xsd:decimal "-13.130860653258566"^^xsd:decimal) ("-16"^^xsd:decimal "-16"^^xsd:decimal) ("-16.000000000000004"^^xsd:decimal "-19.49605640940762"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "-23.94569220264782"^^xsd:decimal) ("-15.999999999999986"^^xsd:decimal "-29.933894588630235"^^xsd:decimal) ("-15.999999999999998"^^xsd:decimal "-38.62741699796952"^^xsd:decimal) ("-16"^^xsd:decimal "-52.74493134301312"^^xsd:decimal) ("-15.999999999999993"^^xsd:decimal "-80.43743187401357"^^xsd:decimal) ("-15.999999999999957"^^xsd:decimal "-162.45072620174176"^^xsd:decimal)) .
6
+ (1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1) :fft ((0 "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) (32 "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal)) .
7
+ (1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) :fft ((1 "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) (1 "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal) ("1"^^xsd:decimal "0"^^xsd:decimal)) .
8
+ (1 0.83146961230254501 0.38268343236509 -0.195090322016128 -0.70710678118654702 -0.98078528040322999 -0.92387953251128696 -0.55557023301960196 0 0.55557023301960196 0.92387953251128696 0.98078528040322999 0.70710678118654802 0.195090322016129 -0.38268343236509 -0.83146961230254501 -1 -0.83146961230254601 -0.382683432365091 0.195090322016127 0.70710678118654702 0.98078528040322999 0.92387953251128696 0.55557023301960295 0.000000000000001 -0.55557023301960196 -0.92387953251128596 -0.98078528040323099 -0.70710678118654702 -0.19509032201613 0.38268343236509 0.83146961230254401) :fft (("-1.9976021664879226e-15"^^xsd:decimal "0"^^xsd:decimal) ("1.3737538074197586e-15"^^xsd:decimal "-1.946465856829794e-15"^^xsd:decimal) ("-5.564884063023956e-15"^^xsd:decimal "1.1067652769226016e-15"^^xsd:decimal) ("15.999999999999998"^^xsd:decimal "-7.66133814775094e-15"^^xsd:decimal) ("1.4138824906527567e-15"^^xsd:decimal "1.4130832128153977e-15"^^xsd:decimal) ("-2.705341196503391e-16"^^xsd:decimal "-1.5008655956026007e-15"^^xsd:decimal) ("1.890916229553308e-16"^^xsd:decimal "-1.2688104344492827e-16"^^xsd:decimal) ("-1.431798885729609e-16"^^xsd:decimal "6.382299624403909e-17"^^xsd:decimal) ("1.999200722162641e-15"^^xsd:decimal "0"^^xsd:decimal) ("-1.974143070189294e-15"^^xsd:decimal "1.2758998416373139e-16"^^xsd:decimal) ("6.370748026754646e-16"^^xsd:decimal "-9.546460247504417e-16"^^xsd:decimal) ("-2.8857717599356964e-15"^^xsd:decimal "-1.4169280937773732e-15"^^xsd:decimal) ("-1.4122839349780385e-15"^^xsd:decimal "1.4130832128153975e-15"^^xsd:decimal) ("8.881784197001252e-16"^^xsd:decimal "-1.55351295663786e-15"^^xsd:decimal) ("7.38717637393161e-16"^^xsd:decimal "-3.717802593033475e-15"^^xsd:decimal) ("3.3987495982314057e-15"^^xsd:decimal "-3.4349527686803807e-15"^^xsd:decimal) ("5.996003610813205e-15"^^xsd:decimal "0"^^xsd:decimal) ("3.919183002821392e-15"^^xsd:decimal "3.338931990141291e-15"^^xsd:decimal) ("7.387176373931606e-16"^^xsd:decimal "3.717802593033475e-15"^^xsd:decimal) ("1.7763568394002505e-15"^^xsd:decimal "2.9968028886505635e-15"^^xsd:decimal) ("-1.4122839349780383e-15"^^xsd:decimal "-1.4130832128153977e-15"^^xsd:decimal) ("-1.5058227197499114e-15"^^xsd:decimal "1.946553361127382e-15"^^xsd:decimal) ("6.370748026754641e-16"^^xsd:decimal "9.54646024750442e-16"^^xsd:decimal) ("-1.6322401255607569e-15"^^xsd:decimal "-7.241239318976423e-16"^^xsd:decimal) ("1.999200722162641e-15"^^xsd:decimal "0"^^xsd:decimal) ("2.339199387486444e-16"^^xsd:decimal "-6.286805864256665e-16"^^xsd:decimal) ("1.8909162295533075e-16"^^xsd:decimal "1.2688104344492837e-16"^^xsd:decimal) ("-6.669419188648045e-16"^^xsd:decimal "3.0510651347749833e-16"^^xsd:decimal) ("1.413882490652757e-15"^^xsd:decimal "-1.4130832128153975e-15"^^xsd:decimal) ("15.999999999999996"^^xsd:decimal "8.216449660063518e-15"^^xsd:decimal) ("-5.564884063023956e-15"^^xsd:decimal "-1.1067652769226028e-15"^^xsd:decimal) ("1.929384094702813e-15"^^xsd:decimal "1.8716105437342336e-15"^^xsd:decimal)) .
9
+ (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) :fft ((32 "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) (0 "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal) ("0"^^xsd:decimal "0"^^xsd:decimal)) .
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.15.6",
3
+ "version": "1.15.7",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
@@ -42,11 +42,10 @@
42
42
  "test:api": "node test/api.test.js",
43
43
  "test:n3gen": "node test/n3gen.test.js",
44
44
  "test:examples": "node test/examples.test.js",
45
- "test:check": "node test/check.test.js",
46
45
  "test:manifest": "node test/manifest.test.js",
47
46
  "test:playground": "node test/playground.test.js",
48
47
  "test:package": "node test/package.test.js",
49
- "test:all": "npm run test:api && npm run test:n3gen && npm run test:examples && npm run test:check && npm run test:manifest && npm run test:playground",
48
+ "test:all": "npm run test:api && npm run test:n3gen && npm run test:examples && npm run && npm run test:manifest && npm run test:playground",
50
49
  "pretest": "npm run build && npm run test:packlist",
51
50
  "test": "npm run test:all",
52
51
  "posttest": "npm run test:package",
@@ -1,198 +0,0 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
3
- #include <stdint.h>
4
- #include <string.h>
5
-
6
- #define BIG_BASE 1000000000u
7
-
8
- typedef struct {
9
- uint32_t *d;
10
- size_t len;
11
- size_t cap;
12
- } BigInt;
13
-
14
- static void die(const char *msg) {
15
- fputs(msg, stderr);
16
- fputc('\n', stderr);
17
- exit(EXIT_FAILURE);
18
- }
19
-
20
- static void bi_init(BigInt *a, unsigned int value) {
21
- a->cap = 4;
22
- a->len = 1;
23
- a->d = (uint32_t *)calloc(a->cap, sizeof(uint32_t));
24
- if (!a->d) die("out of memory");
25
- a->d[0] = value;
26
- }
27
-
28
- static void bi_reserve(BigInt *a, size_t need) {
29
- if (need <= a->cap) return;
30
- size_t cap = a->cap;
31
- while (cap < need) cap *= 2;
32
- uint32_t *p = (uint32_t *)realloc(a->d, cap * sizeof(uint32_t));
33
- if (!p) die("out of memory");
34
- memset(p + a->cap, 0, (cap - a->cap) * sizeof(uint32_t));
35
- a->d = p;
36
- a->cap = cap;
37
- }
38
-
39
- static void bi_trim(BigInt *a) {
40
- while (a->len > 1 && a->d[a->len - 1] == 0) a->len--;
41
- }
42
-
43
- static void bi_mul_small(BigInt *a, unsigned int m) {
44
- uint64_t carry = 0;
45
- for (size_t i = 0; i < a->len; i++) {
46
- uint64_t cur = (uint64_t)a->d[i] * m + carry;
47
- a->d[i] = (uint32_t)(cur % BIG_BASE);
48
- carry = cur / BIG_BASE;
49
- }
50
- while (carry) {
51
- bi_reserve(a, a->len + 1);
52
- a->d[a->len++] = (uint32_t)(carry % BIG_BASE);
53
- carry /= BIG_BASE;
54
- }
55
- }
56
-
57
- static void bi_add_small(BigInt *a, unsigned int add) {
58
- uint64_t carry = add;
59
- size_t i = 0;
60
- while (carry) {
61
- if (i == a->len) {
62
- bi_reserve(a, a->len + 1);
63
- a->d[a->len++] = 0;
64
- }
65
- uint64_t cur = (uint64_t)a->d[i] + carry;
66
- a->d[i] = (uint32_t)(cur % BIG_BASE);
67
- carry = cur / BIG_BASE;
68
- i++;
69
- }
70
- }
71
-
72
- static void bi_sub_small(BigInt *a, unsigned int sub) {
73
- uint64_t borrow = sub;
74
- size_t i = 0;
75
- while (borrow) {
76
- if (i >= a->len) die("underflow");
77
- uint64_t cur = a->d[i];
78
- uint64_t part = borrow % BIG_BASE;
79
- borrow /= BIG_BASE;
80
- if (cur < part) {
81
- a->d[i] = (uint32_t)(cur + BIG_BASE - part);
82
- borrow += 1;
83
- } else {
84
- a->d[i] = (uint32_t)(cur - part);
85
- }
86
- i++;
87
- }
88
- bi_trim(a);
89
- }
90
-
91
- static unsigned int bi_to_uint(const BigInt *a) {
92
- if (a->len == 0) return 0;
93
- if (a->len > 2) die("value too large for unsigned int");
94
- uint64_t v = a->d[0];
95
- if (a->len == 2) v += (uint64_t)a->d[1] * BIG_BASE;
96
- if (v > 0xffffffffu) die("value too large for unsigned int");
97
- return (unsigned int)v;
98
- }
99
-
100
- static char *bi_to_string(const BigInt *a) {
101
- size_t bytes = a->len * 10 + 1;
102
- char *s = (char *)malloc(bytes);
103
- if (!s) die("out of memory");
104
- int n = snprintf(s, bytes, "%u", a->d[a->len - 1]);
105
- if (n < 0) die("snprintf failed");
106
- size_t pos = (size_t)n;
107
- for (size_t i = a->len - 1; i-- > 0;) {
108
- n = snprintf(s + pos, bytes - pos, "%09u", a->d[i]);
109
- if (n < 0) die("snprintf failed");
110
- pos += (size_t)n;
111
- }
112
- return s;
113
- }
114
-
115
- static void bi_free(BigInt *a) {
116
- free(a->d);
117
- a->d = NULL;
118
- a->len = 0;
119
- a->cap = 0;
120
- }
121
-
122
- static BigInt bi_pow2(unsigned int exp) {
123
- BigInt r;
124
- bi_init(&r, 1);
125
- for (unsigned int i = 0; i < exp; i++) bi_mul_small(&r, 2);
126
- return r;
127
- }
128
-
129
- /* Independent evaluator for the fixed-z hyperoperation chain used by
130
- examples/ackermann.n3:
131
- A(x,y) = H(x, y+3, 2) - 3
132
- where H(0,y,2)=y+1, H(1,y,2)=y+2, H(2,y,2)=2y, H(3,y,2)=2^y,
133
- and H(x,0,2)=1 for x>3, H(x,y,2)=H(x-1, H(x,y-1,2), 2).
134
- */
135
- static BigInt hyper2(unsigned int x, unsigned int y) {
136
- if (x == 0) {
137
- BigInt r;
138
- bi_init(&r, y + 1);
139
- return r;
140
- }
141
- if (x == 1) {
142
- BigInt r;
143
- bi_init(&r, y + 2);
144
- return r;
145
- }
146
- if (x == 2) {
147
- BigInt r;
148
- bi_init(&r, 2u * y);
149
- return r;
150
- }
151
- if (x == 3) {
152
- return bi_pow2(y);
153
- }
154
- if (y == 0) {
155
- BigInt r;
156
- bi_init(&r, 1);
157
- return r;
158
- }
159
-
160
- BigInt inner = hyper2(x, y - 1);
161
- unsigned int inner_u = bi_to_uint(&inner);
162
- bi_free(&inner);
163
- return hyper2(x - 1, inner_u);
164
- }
165
-
166
- static BigInt ackermann2(unsigned int x, unsigned int y) {
167
- BigInt r = hyper2(x, y + 3);
168
- bi_sub_small(&r, 3);
169
- return r;
170
- }
171
-
172
- static void print_line(unsigned int x, unsigned int y) {
173
- BigInt v = ackermann2(x, y);
174
- char *s = bi_to_string(&v);
175
- printf(" (%u %u) :ackermann %s .\n", x, y, s);
176
- free(s);
177
- bi_free(&v);
178
- }
179
-
180
- int main(void) {
181
- puts("@prefix : <https://eyereasoner.github.io/ns#> .");
182
- puts("");
183
- puts(":test :is {");
184
- print_line(0, 0);
185
- print_line(0, 6);
186
- print_line(1, 2);
187
- print_line(1, 7);
188
- print_line(2, 2);
189
- print_line(2, 9);
190
- print_line(3, 4);
191
- print_line(3, 1000);
192
- print_line(4, 0);
193
- print_line(4, 1);
194
- print_line(4, 2);
195
- print_line(5, 0);
196
- puts("} .");
197
- return 0;
198
- }
@@ -1,97 +0,0 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
3
- #include <string.h>
4
-
5
- enum { DEPTH = 10 };
6
-
7
- static int emit(const char *s) {
8
- return fputs(s, stdout) != EOF;
9
- }
10
-
11
- static int emit_type(const char *kind, int index) {
12
- return printf(":ind a :%s%d .\n", kind, index) >= 0;
13
- }
14
-
15
- int main(void) {
16
- unsigned char hasN[DEPTH + 1];
17
- unsigned char hasI[DEPTH + 1];
18
- unsigned char hasJ[DEPTH + 1];
19
- unsigned char hasA2 = 0;
20
- unsigned char hasTest = 0;
21
- int changed = 1;
22
-
23
- memset(hasN, 0, sizeof(hasN));
24
- memset(hasI, 0, sizeof(hasI));
25
- memset(hasJ, 0, sizeof(hasJ));
26
-
27
- /* fact: :ind a :N0. */
28
- hasN[0] = 1;
29
-
30
- /*
31
- * Forward-chain the rules to a fixpoint.
32
- *
33
- * {?X a :N0} => {?X a :N1, :I1, :J1}.
34
- * {?X a :N1} => {?X a :N2, :I2, :J2}.
35
- * ...
36
- * {?X a :N9} => {?X a :N10, :I10, :J10}.
37
- * {?X a :N10} => {?X a :A2}.
38
- * {:ind a :A2} => {:test :is true}.
39
- */
40
- while (changed) {
41
- changed = 0;
42
-
43
- for (int i = 0; i < DEPTH; i++) {
44
- if (!hasN[i]) {
45
- continue;
46
- }
47
-
48
- if (!hasN[i + 1]) {
49
- hasN[i + 1] = 1;
50
- changed = 1;
51
- }
52
- if (!hasI[i + 1]) {
53
- hasI[i + 1] = 1;
54
- changed = 1;
55
- }
56
- if (!hasJ[i + 1]) {
57
- hasJ[i + 1] = 1;
58
- changed = 1;
59
- }
60
- }
61
-
62
- if (hasN[DEPTH] && !hasA2) {
63
- hasA2 = 1;
64
- changed = 1;
65
- }
66
-
67
- if (hasA2 && !hasTest) {
68
- hasTest = 1;
69
- changed = 1;
70
- }
71
- }
72
-
73
- if (!emit("@prefix : <http://eulersharp.sourceforge.net/2009/12dtb/test#> .\n\n")) {
74
- return EXIT_FAILURE;
75
- }
76
-
77
- for (int i = 1; i <= DEPTH; i++) {
78
- if (!hasN[i] || !hasI[i] || !hasJ[i]) {
79
- fprintf(stderr, "incomplete closure at depth %d\n", i);
80
- return EXIT_FAILURE;
81
- }
82
- if (!emit_type("N", i) || !emit_type("I", i) || !emit_type("J", i)) {
83
- return EXIT_FAILURE;
84
- }
85
- }
86
-
87
- if (!hasA2 || !hasTest) {
88
- fputs("expected conclusions were not derived\n", stderr);
89
- return EXIT_FAILURE;
90
- }
91
-
92
- if (!emit(":ind a :A2 .\n:test :is true .\n")) {
93
- return EXIT_FAILURE;
94
- }
95
-
96
- return EXIT_SUCCESS;
97
- }