eyeling 1.15.5 → 1.15.6
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.
- package/examples/fft8-numeric.n3 +138 -0
- package/examples/fft8-symbolic.n3 +109 -0
- package/examples/output/fft8-numeric.n3 +4 -0
- package/examples/output/fft8-symbolic.n3 +3 -0
- package/eyeling.js +0 -12
- package/lib/parser.js +0 -12
- package/package.json +1 -1
- package/examples/fast-fourier-transform.n3 +0 -92
- package/examples/output/fast-fourier-transform.n3 +0 -3
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# ===================================================
|
|
2
|
+
# Fast Fourier Transform (FFT)
|
|
3
|
+
# Input sequence: (0 1 2 3 4 5 6 7)
|
|
4
|
+
# Numeric version with explicit complex pairs (re im)
|
|
5
|
+
# 8th roots of unity are baked in as constants
|
|
6
|
+
# ===================================================
|
|
7
|
+
|
|
8
|
+
@prefix : <http://example.org/fft8#>.
|
|
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
|
+
# 8th roots of unity: W8^k = exp(-2*pi*i*k/8)
|
|
14
|
+
# represented as (re im)
|
|
15
|
+
# -------------------------------------------
|
|
16
|
+
|
|
17
|
+
0 :w8 (1.0 0.0).
|
|
18
|
+
1 :w8 (0.7071067811865476 -0.7071067811865476).
|
|
19
|
+
2 :w8 (0.0 -1.0).
|
|
20
|
+
3 :w8 (-0.7071067811865476 -0.7071067811865476).
|
|
21
|
+
4 :w8 (-1.0 0.0).
|
|
22
|
+
5 :w8 (-0.7071067811865476 0.7071067811865476).
|
|
23
|
+
6 :w8 (0.0 1.0).
|
|
24
|
+
7 :w8 (0.7071067811865476 0.7071067811865476).
|
|
25
|
+
|
|
26
|
+
# --------------------------------------------
|
|
27
|
+
# Complex arithmetic on explicit pairs (re im)
|
|
28
|
+
# --------------------------------------------
|
|
29
|
+
|
|
30
|
+
# (a+bi) + (c+di) = (a+c) + (b+d)i
|
|
31
|
+
{
|
|
32
|
+
((?ar ?ai) (?br ?bi)) :cAdd (?cr ?ci).
|
|
33
|
+
} <= {
|
|
34
|
+
(?ar ?br) math:sum ?cr.
|
|
35
|
+
(?ai ?bi) math:sum ?ci.
|
|
36
|
+
}.
|
|
37
|
+
|
|
38
|
+
# (a+bi) * (c+di) = (ac-bd) + (ad+bc)i
|
|
39
|
+
{
|
|
40
|
+
((?ar ?ai) (?br ?bi)) :cMul (?cr ?ci).
|
|
41
|
+
} <= {
|
|
42
|
+
(?ar ?br) math:product ?ac.
|
|
43
|
+
(?ai ?bi) math:product ?bd.
|
|
44
|
+
(?ac ?bd) math:difference ?cr.
|
|
45
|
+
|
|
46
|
+
(?ar ?bi) math:product ?ad.
|
|
47
|
+
(?ai ?br) math:product ?bc.
|
|
48
|
+
(?ad ?bc) math:sum ?ci.
|
|
49
|
+
}.
|
|
50
|
+
|
|
51
|
+
# --------------------------------------------------------
|
|
52
|
+
# Numeric radix-2 FFT evaluator
|
|
53
|
+
#
|
|
54
|
+
# ((samples...) p) :fftPair (re im)
|
|
55
|
+
#
|
|
56
|
+
# This computes X[p] for the given sample list, where p is
|
|
57
|
+
# in 0..7 and the primitive 8th root table above is used.
|
|
58
|
+
# --------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
# Base case: one real sample x becomes the complex number (x 0)
|
|
61
|
+
{
|
|
62
|
+
((?x) ?p) :fftPair (?x 0.0).
|
|
63
|
+
} <= {}.
|
|
64
|
+
|
|
65
|
+
# Length 2
|
|
66
|
+
{
|
|
67
|
+
((?x0 ?x1) ?p) :fftPair ?out.
|
|
68
|
+
} <= {
|
|
69
|
+
(?p 2) math:product ?twiceP.
|
|
70
|
+
(?twiceP 8) math:remainder ?childP.
|
|
71
|
+
|
|
72
|
+
((?x0) ?childP) :fftPair ?lhs.
|
|
73
|
+
((?x1) ?childP) :fftPair ?rhs.
|
|
74
|
+
|
|
75
|
+
?p :w8 ?w.
|
|
76
|
+
(?w ?rhs) :cMul ?tw.
|
|
77
|
+
(?lhs ?tw) :cAdd ?out.
|
|
78
|
+
}.
|
|
79
|
+
|
|
80
|
+
# Length 4
|
|
81
|
+
{
|
|
82
|
+
((?x0 ?x1 ?x2 ?x3) ?p) :fftPair ?out.
|
|
83
|
+
} <= {
|
|
84
|
+
(?p 2) math:product ?twiceP.
|
|
85
|
+
(?twiceP 8) math:remainder ?childP.
|
|
86
|
+
|
|
87
|
+
((?x0 ?x2) ?childP) :fftPair ?lhs.
|
|
88
|
+
((?x1 ?x3) ?childP) :fftPair ?rhs.
|
|
89
|
+
|
|
90
|
+
?p :w8 ?w.
|
|
91
|
+
(?w ?rhs) :cMul ?tw.
|
|
92
|
+
(?lhs ?tw) :cAdd ?out.
|
|
93
|
+
}.
|
|
94
|
+
|
|
95
|
+
# Length 8
|
|
96
|
+
{
|
|
97
|
+
((?x0 ?x1 ?x2 ?x3 ?x4 ?x5 ?x6 ?x7) ?p) :fftPair ?out.
|
|
98
|
+
} <= {
|
|
99
|
+
(?p 2) math:product ?twiceP.
|
|
100
|
+
(?twiceP 8) math:remainder ?childP.
|
|
101
|
+
|
|
102
|
+
((?x0 ?x2 ?x4 ?x6) ?childP) :fftPair ?lhs.
|
|
103
|
+
((?x1 ?x3 ?x5 ?x7) ?childP) :fftPair ?rhs.
|
|
104
|
+
|
|
105
|
+
?p :w8 ?w.
|
|
106
|
+
(?w ?rhs) :cMul ?tw.
|
|
107
|
+
(?lhs ?tw) :cAdd ?out.
|
|
108
|
+
}.
|
|
109
|
+
|
|
110
|
+
# ---------------------
|
|
111
|
+
# Top-level 8-point FFT
|
|
112
|
+
# ---------------------
|
|
113
|
+
|
|
114
|
+
{
|
|
115
|
+
(?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :fft8
|
|
116
|
+
(?y0 ?y1 ?y2 ?y3 ?y4 ?y5 ?y6 ?y7).
|
|
117
|
+
} <= {
|
|
118
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 0) :fftPair ?y0.
|
|
119
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 1) :fftPair ?y1.
|
|
120
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 2) :fftPair ?y2.
|
|
121
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 3) :fftPair ?y3.
|
|
122
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 4) :fftPair ?y4.
|
|
123
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 5) :fftPair ?y5.
|
|
124
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 6) :fftPair ?y6.
|
|
125
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) 7) :fftPair ?y7.
|
|
126
|
+
}.
|
|
127
|
+
|
|
128
|
+
# -----
|
|
129
|
+
# Query
|
|
130
|
+
# -----
|
|
131
|
+
|
|
132
|
+
{
|
|
133
|
+
(0 1 2 3 4 5 6 7) :fft8 ?out.
|
|
134
|
+
}
|
|
135
|
+
log:query
|
|
136
|
+
{
|
|
137
|
+
:result :fft ?out.
|
|
138
|
+
}.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# ===================================================
|
|
2
|
+
# Fast Fourier Transform (FFT)
|
|
3
|
+
# Input sequence: (0 1 2 3 4 5 6 7)
|
|
4
|
+
# Symbolic radix-2 FFT
|
|
5
|
+
# Complex roots of unity are represented symbolically
|
|
6
|
+
# ===================================================
|
|
7
|
+
|
|
8
|
+
@prefix : <http://example.org/fft8#>.
|
|
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
|
+
# Symbolic expression encoding
|
|
14
|
+
#
|
|
15
|
+
# sample i -> (:leaf i)
|
|
16
|
+
# omega^p -> (:twiddle :omega p)
|
|
17
|
+
# omega^p * expr -> (:mul (:twiddle :omega p) expr)
|
|
18
|
+
# a + b -> (:add a b)
|
|
19
|
+
# -------------------------------------------------
|
|
20
|
+
|
|
21
|
+
# ---------
|
|
22
|
+
# Base case
|
|
23
|
+
# ---------
|
|
24
|
+
|
|
25
|
+
# A list of length 1 is turned into a leaf node.
|
|
26
|
+
{
|
|
27
|
+
((?i) ?root ?p ?n) :fftExpr (:leaf ?i).
|
|
28
|
+
} <= {}.
|
|
29
|
+
|
|
30
|
+
# ------------------------------
|
|
31
|
+
# FFT rule for lists of length 2
|
|
32
|
+
# ------------------------------
|
|
33
|
+
|
|
34
|
+
# FFT([a,b], p) =
|
|
35
|
+
# FFT([a], 2p mod n) + omega^p * FFT([b], 2p mod n)
|
|
36
|
+
{
|
|
37
|
+
((?i0 ?i1) ?root ?p ?n) :fftExpr
|
|
38
|
+
(:add ?lhs (:mul (:twiddle ?root ?p) ?rhs)).
|
|
39
|
+
} <= {
|
|
40
|
+
(?p 2) math:product ?twiceP.
|
|
41
|
+
(?twiceP ?n) math:remainder ?childP.
|
|
42
|
+
|
|
43
|
+
((?i0) ?root ?childP ?n) :fftExpr ?lhs.
|
|
44
|
+
((?i1) ?root ?childP ?n) :fftExpr ?rhs.
|
|
45
|
+
}.
|
|
46
|
+
|
|
47
|
+
# ------------------------------
|
|
48
|
+
# FFT rule for lists of length 4
|
|
49
|
+
# ------------------------------
|
|
50
|
+
|
|
51
|
+
# Split the input into even and odd positions.
|
|
52
|
+
{
|
|
53
|
+
((?i0 ?i1 ?i2 ?i3) ?root ?p ?n) :fftExpr
|
|
54
|
+
(:add ?lhs (:mul (:twiddle ?root ?p) ?rhs)).
|
|
55
|
+
} <= {
|
|
56
|
+
(?p 2) math:product ?twiceP.
|
|
57
|
+
(?twiceP ?n) math:remainder ?childP.
|
|
58
|
+
|
|
59
|
+
((?i0 ?i2) ?root ?childP ?n) :fftExpr ?lhs.
|
|
60
|
+
((?i1 ?i3) ?root ?childP ?n) :fftExpr ?rhs.
|
|
61
|
+
}.
|
|
62
|
+
|
|
63
|
+
# ------------------------------
|
|
64
|
+
# FFT rule for lists of length 8
|
|
65
|
+
# ------------------------------
|
|
66
|
+
|
|
67
|
+
# Split the input into even and odd positions.
|
|
68
|
+
{
|
|
69
|
+
((?i0 ?i1 ?i2 ?i3 ?i4 ?i5 ?i6 ?i7) ?root ?p ?n) :fftExpr
|
|
70
|
+
(:add ?lhs (:mul (:twiddle ?root ?p) ?rhs)).
|
|
71
|
+
} <= {
|
|
72
|
+
(?p 2) math:product ?twiceP.
|
|
73
|
+
(?twiceP ?n) math:remainder ?childP.
|
|
74
|
+
|
|
75
|
+
((?i0 ?i2 ?i4 ?i6) ?root ?childP ?n) :fftExpr ?lhs.
|
|
76
|
+
((?i1 ?i3 ?i5 ?i7) ?root ?childP ?n) :fftExpr ?rhs.
|
|
77
|
+
}.
|
|
78
|
+
|
|
79
|
+
# ---------------------
|
|
80
|
+
# Top-level 8-point FFT
|
|
81
|
+
# ---------------------
|
|
82
|
+
|
|
83
|
+
# Evaluate the symbolic FFT at p = 0..7.
|
|
84
|
+
{
|
|
85
|
+
(?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :fft8
|
|
86
|
+
(?x0 ?x1 ?x2 ?x3 ?x4 ?x5 ?x6 ?x7).
|
|
87
|
+
} <= {
|
|
88
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 0 8) :fftExpr ?x0.
|
|
89
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 1 8) :fftExpr ?x1.
|
|
90
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 2 8) :fftExpr ?x2.
|
|
91
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 3 8) :fftExpr ?x3.
|
|
92
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 4 8) :fftExpr ?x4.
|
|
93
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 5 8) :fftExpr ?x5.
|
|
94
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 6 8) :fftExpr ?x6.
|
|
95
|
+
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :omega 7 8) :fftExpr ?x7.
|
|
96
|
+
}.
|
|
97
|
+
|
|
98
|
+
# -----
|
|
99
|
+
# Query
|
|
100
|
+
# -----
|
|
101
|
+
|
|
102
|
+
# Ask for the symbolic FFT of (0 1 2 3 4 5 6 7).
|
|
103
|
+
{
|
|
104
|
+
(0 1 2 3 4 5 6 7) :fft8 ?out.
|
|
105
|
+
}
|
|
106
|
+
log:query
|
|
107
|
+
{
|
|
108
|
+
:result :fft ?out.
|
|
109
|
+
}.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
@prefix : <http://example.org/fft8#> .
|
|
2
|
+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
|
3
|
+
|
|
4
|
+
:result :fft (("28"^^xsd:decimal "0"^^xsd:decimal) ("-4"^^xsd:decimal "9.65685424949238"^^xsd:decimal) ("-4"^^xsd:decimal "4"^^xsd:decimal) ("-4"^^xsd:decimal "1.6568542494923806"^^xsd:decimal) ("-4"^^xsd:decimal "0"^^xsd:decimal) ("-4"^^xsd:decimal "-1.6568542494923806"^^xsd:decimal) ("-4"^^xsd:decimal "-4"^^xsd:decimal) ("-4"^^xsd:decimal "-9.65685424949238"^^xsd:decimal)) .
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
@prefix : <http://example.org/fft8#> .
|
|
2
|
+
|
|
3
|
+
:result :fft ((:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 0) (:leaf 4))) (:mul (:twiddle :omega 0) (:add (:leaf 2) (:mul (:twiddle :omega 0) (:leaf 6))))) (:mul (:twiddle :omega 0) (:add (:add (:leaf 1) (:mul (:twiddle :omega 0) (:leaf 5))) (:mul (:twiddle :omega 0) (:add (:leaf 3) (:mul (:twiddle :omega 0) (:leaf 7))))))) (:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 4) (:leaf 4))) (:mul (:twiddle :omega 2) (:add (:leaf 2) (:mul (:twiddle :omega 4) (:leaf 6))))) (:mul (:twiddle :omega 1) (:add (:add (:leaf 1) (:mul (:twiddle :omega 4) (:leaf 5))) (:mul (:twiddle :omega 2) (:add (:leaf 3) (:mul (:twiddle :omega 4) (:leaf 7))))))) (:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 0) (:leaf 4))) (:mul (:twiddle :omega 4) (:add (:leaf 2) (:mul (:twiddle :omega 0) (:leaf 6))))) (:mul (:twiddle :omega 2) (:add (:add (:leaf 1) (:mul (:twiddle :omega 0) (:leaf 5))) (:mul (:twiddle :omega 4) (:add (:leaf 3) (:mul (:twiddle :omega 0) (:leaf 7))))))) (:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 4) (:leaf 4))) (:mul (:twiddle :omega 6) (:add (:leaf 2) (:mul (:twiddle :omega 4) (:leaf 6))))) (:mul (:twiddle :omega 3) (:add (:add (:leaf 1) (:mul (:twiddle :omega 4) (:leaf 5))) (:mul (:twiddle :omega 6) (:add (:leaf 3) (:mul (:twiddle :omega 4) (:leaf 7))))))) (:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 0) (:leaf 4))) (:mul (:twiddle :omega 0) (:add (:leaf 2) (:mul (:twiddle :omega 0) (:leaf 6))))) (:mul (:twiddle :omega 4) (:add (:add (:leaf 1) (:mul (:twiddle :omega 0) (:leaf 5))) (:mul (:twiddle :omega 0) (:add (:leaf 3) (:mul (:twiddle :omega 0) (:leaf 7))))))) (:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 4) (:leaf 4))) (:mul (:twiddle :omega 2) (:add (:leaf 2) (:mul (:twiddle :omega 4) (:leaf 6))))) (:mul (:twiddle :omega 5) (:add (:add (:leaf 1) (:mul (:twiddle :omega 4) (:leaf 5))) (:mul (:twiddle :omega 2) (:add (:leaf 3) (:mul (:twiddle :omega 4) (:leaf 7))))))) (:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 0) (:leaf 4))) (:mul (:twiddle :omega 4) (:add (:leaf 2) (:mul (:twiddle :omega 0) (:leaf 6))))) (:mul (:twiddle :omega 6) (:add (:add (:leaf 1) (:mul (:twiddle :omega 0) (:leaf 5))) (:mul (:twiddle :omega 4) (:add (:leaf 3) (:mul (:twiddle :omega 0) (:leaf 7))))))) (:add (:add (:add (:leaf 0) (:mul (:twiddle :omega 4) (:leaf 4))) (:mul (:twiddle :omega 6) (:add (:leaf 2) (:mul (:twiddle :omega 4) (:leaf 6))))) (:mul (:twiddle :omega 7) (:add (:add (:leaf 1) (:mul (:twiddle :omega 4) (:leaf 5))) (:mul (:twiddle :omega 6) (:add (:leaf 3) (:mul (:twiddle :omega 4) (:leaf 7)))))))) .
|
package/eyeling.js
CHANGED
|
@@ -8606,18 +8606,6 @@ function assertValidQNamePrefix(prefixName, fail, tok, context = 'prefixed name'
|
|
|
8606
8606
|
}
|
|
8607
8607
|
}
|
|
8608
8608
|
|
|
8609
|
-
function isKeywordLikeIdent(name) {
|
|
8610
|
-
return (
|
|
8611
|
-
name === 'a' ||
|
|
8612
|
-
name === 'has' ||
|
|
8613
|
-
name === 'is' ||
|
|
8614
|
-
name === 'of' ||
|
|
8615
|
-
name === 'true' ||
|
|
8616
|
-
name === 'false' ||
|
|
8617
|
-
name === 'id'
|
|
8618
|
-
);
|
|
8619
|
-
}
|
|
8620
|
-
|
|
8621
8609
|
function failInvalidKeywordLikeIdent(fail, tok, name) {
|
|
8622
8610
|
fail(`invalid_keyword(${name})`, tok);
|
|
8623
8611
|
}
|
package/lib/parser.js
CHANGED
|
@@ -37,18 +37,6 @@ function assertValidQNamePrefix(prefixName, fail, tok, context = 'prefixed name'
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function isKeywordLikeIdent(name) {
|
|
41
|
-
return (
|
|
42
|
-
name === 'a' ||
|
|
43
|
-
name === 'has' ||
|
|
44
|
-
name === 'is' ||
|
|
45
|
-
name === 'of' ||
|
|
46
|
-
name === 'true' ||
|
|
47
|
-
name === 'false' ||
|
|
48
|
-
name === 'id'
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
40
|
function failInvalidKeywordLikeIdent(fail, tok, name) {
|
|
53
41
|
fail(`invalid_keyword(${name})`, tok);
|
|
54
42
|
}
|
package/package.json
CHANGED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# ================================================================
|
|
2
|
-
# Symbolic FFT
|
|
3
|
-
#
|
|
4
|
-
# Relation signatures:
|
|
5
|
-
#
|
|
6
|
-
# ((samples) v p n) :eval expr.
|
|
7
|
-
# ((a0 a1 a2 a3 a4 a5 a6 a7) x0 x1 x2 x3 x4 x5 x6 x7) :fft true.
|
|
8
|
-
#
|
|
9
|
-
# Expression encoding:
|
|
10
|
-
#
|
|
11
|
-
# a(I) -> (:a I)
|
|
12
|
-
# w^P -> (:pow :w P)
|
|
13
|
-
# A1 + w^P * A2 -> (:plus A1 (:times (:pow :w P) A2))
|
|
14
|
-
# ================================================================
|
|
15
|
-
|
|
16
|
-
@prefix : <http://example.org/fft#>.
|
|
17
|
-
@prefix math: <http://www.w3.org/2000/10/swap/math#>.
|
|
18
|
-
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
|
|
19
|
-
|
|
20
|
-
# Base case: a singleton list evaluates to a(I).
|
|
21
|
-
{ ((?i) ?v ?p ?n) :eval (:a ?i). } <= {}.
|
|
22
|
-
|
|
23
|
-
# Length 2
|
|
24
|
-
{
|
|
25
|
-
((?i0 ?i1) ?v ?p ?n) :eval
|
|
26
|
-
(:plus ?a1 (:times (:pow ?v ?p) ?a2)).
|
|
27
|
-
}
|
|
28
|
-
<=
|
|
29
|
-
{
|
|
30
|
-
(?p 2) math:product ?pp.
|
|
31
|
-
(?pp ?n) math:remainder ?p1.
|
|
32
|
-
|
|
33
|
-
((?i0) ?v ?p1 ?n) :eval ?a1.
|
|
34
|
-
((?i1) ?v ?p1 ?n) :eval ?a2.
|
|
35
|
-
}.
|
|
36
|
-
|
|
37
|
-
# Length 4: alternate [0,2] and [1,3]
|
|
38
|
-
{
|
|
39
|
-
((?i0 ?i1 ?i2 ?i3) ?v ?p ?n) :eval
|
|
40
|
-
(:plus ?a1 (:times (:pow ?v ?p) ?a2)).
|
|
41
|
-
}
|
|
42
|
-
<=
|
|
43
|
-
{
|
|
44
|
-
(?p 2) math:product ?pp.
|
|
45
|
-
(?pp ?n) math:remainder ?p1.
|
|
46
|
-
|
|
47
|
-
((?i0 ?i2) ?v ?p1 ?n) :eval ?a1.
|
|
48
|
-
((?i1 ?i3) ?v ?p1 ?n) :eval ?a2.
|
|
49
|
-
}.
|
|
50
|
-
|
|
51
|
-
# Length 8: alternate [0,2,4,6] and [1,3,5,7]
|
|
52
|
-
{
|
|
53
|
-
((?i0 ?i1 ?i2 ?i3 ?i4 ?i5 ?i6 ?i7) ?v ?p ?n) :eval
|
|
54
|
-
(:plus ?a1 (:times (:pow ?v ?p) ?a2)).
|
|
55
|
-
}
|
|
56
|
-
<=
|
|
57
|
-
{
|
|
58
|
-
(?p 2) math:product ?pp.
|
|
59
|
-
(?pp ?n) math:remainder ?p1.
|
|
60
|
-
|
|
61
|
-
((?i0 ?i2 ?i4 ?i6) ?v ?p1 ?n) :eval ?a1.
|
|
62
|
-
((?i1 ?i3 ?i5 ?i7) ?v ?p1 ?n) :eval ?a2.
|
|
63
|
-
}.
|
|
64
|
-
|
|
65
|
-
# The original Prolog fft/2 calls eval at powers w^0 .. w^7 for N = 8.
|
|
66
|
-
{
|
|
67
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7)
|
|
68
|
-
?x0 ?x1 ?x2 ?x3 ?x4 ?x5 ?x6 ?x7) :fft true.
|
|
69
|
-
}
|
|
70
|
-
<=
|
|
71
|
-
{
|
|
72
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 0 8) :eval ?x0.
|
|
73
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 1 8) :eval ?x1.
|
|
74
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 2 8) :eval ?x2.
|
|
75
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 3 8) :eval ?x3.
|
|
76
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 4 8) :eval ?x4.
|
|
77
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 5 8) :eval ?x5.
|
|
78
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 6 8) :eval ?x6.
|
|
79
|
-
((?a0 ?a1 ?a2 ?a3 ?a4 ?a5 ?a6 ?a7) :w 7 8) :eval ?x7.
|
|
80
|
-
}.
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
((0 1 2 3 4 5 6 7)
|
|
84
|
-
?x0 ?x1 ?x2 ?x3 ?x4 ?x5 ?x6 ?x7) :fft true.
|
|
85
|
-
}
|
|
86
|
-
log:query
|
|
87
|
-
{
|
|
88
|
-
:result :fft (
|
|
89
|
-
?x0 ?x1 ?x2 ?x3
|
|
90
|
-
?x4 ?x5 ?x6 ?x7
|
|
91
|
-
).
|
|
92
|
-
}.
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
@prefix : <http://example.org/fft#> .
|
|
2
|
-
|
|
3
|
-
:result :fft ((:plus (:plus (:plus (:a 0) (:times (:pow :w 0) (:a 4))) (:times (:pow :w 0) (:plus (:a 2) (:times (:pow :w 0) (:a 6))))) (:times (:pow :w 0) (:plus (:plus (:a 1) (:times (:pow :w 0) (:a 5))) (:times (:pow :w 0) (:plus (:a 3) (:times (:pow :w 0) (:a 7))))))) (:plus (:plus (:plus (:a 0) (:times (:pow :w 4) (:a 4))) (:times (:pow :w 2) (:plus (:a 2) (:times (:pow :w 4) (:a 6))))) (:times (:pow :w 1) (:plus (:plus (:a 1) (:times (:pow :w 4) (:a 5))) (:times (:pow :w 2) (:plus (:a 3) (:times (:pow :w 4) (:a 7))))))) (:plus (:plus (:plus (:a 0) (:times (:pow :w 0) (:a 4))) (:times (:pow :w 4) (:plus (:a 2) (:times (:pow :w 0) (:a 6))))) (:times (:pow :w 2) (:plus (:plus (:a 1) (:times (:pow :w 0) (:a 5))) (:times (:pow :w 4) (:plus (:a 3) (:times (:pow :w 0) (:a 7))))))) (:plus (:plus (:plus (:a 0) (:times (:pow :w 4) (:a 4))) (:times (:pow :w 6) (:plus (:a 2) (:times (:pow :w 4) (:a 6))))) (:times (:pow :w 3) (:plus (:plus (:a 1) (:times (:pow :w 4) (:a 5))) (:times (:pow :w 6) (:plus (:a 3) (:times (:pow :w 4) (:a 7))))))) (:plus (:plus (:plus (:a 0) (:times (:pow :w 0) (:a 4))) (:times (:pow :w 0) (:plus (:a 2) (:times (:pow :w 0) (:a 6))))) (:times (:pow :w 4) (:plus (:plus (:a 1) (:times (:pow :w 0) (:a 5))) (:times (:pow :w 0) (:plus (:a 3) (:times (:pow :w 0) (:a 7))))))) (:plus (:plus (:plus (:a 0) (:times (:pow :w 4) (:a 4))) (:times (:pow :w 2) (:plus (:a 2) (:times (:pow :w 4) (:a 6))))) (:times (:pow :w 5) (:plus (:plus (:a 1) (:times (:pow :w 4) (:a 5))) (:times (:pow :w 2) (:plus (:a 3) (:times (:pow :w 4) (:a 7))))))) (:plus (:plus (:plus (:a 0) (:times (:pow :w 0) (:a 4))) (:times (:pow :w 4) (:plus (:a 2) (:times (:pow :w 0) (:a 6))))) (:times (:pow :w 6) (:plus (:plus (:a 1) (:times (:pow :w 0) (:a 5))) (:times (:pow :w 4) (:plus (:a 3) (:times (:pow :w 0) (:a 7))))))) (:plus (:plus (:plus (:a 0) (:times (:pow :w 4) (:a 4))) (:times (:pow :w 6) (:plus (:a 2) (:times (:pow :w 4) (:a 6))))) (:times (:pow :w 7) (:plus (:plus (:a 1) (:times (:pow :w 4) (:a 5))) (:times (:pow :w 6) (:plus (:a 3) (:times (:pow :w 4) (:a 7)))))))) .
|