hclang 0.51.0 → 0.53.0
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.
|
@@ -2793,67 +2793,77 @@ export const HC_SOURCES = new Map([
|
|
|
2793
2793
|
"```",
|
|
2794
2794
|
"## Geometric observers, `.##%` … `.###%%%`",
|
|
2795
2795
|
"Six observers read a Denum through a geometry (occurrence/figure 007.41b,",
|
|
2796
|
-
"007.41c
|
|
2797
|
-
"
|
|
2798
|
-
"
|
|
2799
|
-
"
|
|
2800
|
-
"
|
|
2801
|
-
"
|
|
2802
|
-
"
|
|
2803
|
-
"",
|
|
2804
|
-
"
|
|
2805
|
-
"
|
|
2806
|
-
"
|
|
2807
|
-
"
|
|
2808
|
-
"
|
|
2809
|
-
"
|
|
2810
|
-
"
|
|
2811
|
-
"
|
|
2812
|
-
"
|
|
2813
|
-
"
|
|
2796
|
+
"007.41c, 007.43h, 007.43i, 007.44, 007.46). The count of percent signs is the",
|
|
2797
|
+
"ladder order: one `%` is SSL, two are KPSL, three are KDSL. The Count of the Denum is its rank `r`, and",
|
|
2798
|
+
"each geometry wants a definite number of slots for that rank: the simplex (SSL,",
|
|
2799
|
+
"`%`) `r+1`, the cross-polytope (KPSL, `%%`) `2r` and the Cayley–Dickson signed",
|
|
2800
|
+
"basis (KDSL, `%%%`) `2^r`. The stored loads are aligned to the wanted length:",
|
|
2801
|
+
"missing slots are 0 and excess slots wrap by index modulo the wanted length,",
|
|
2802
|
+
"adding into the slot they wrap to. The observer is the geometry's ordinary",
|
|
2803
|
+
"formula on that virtual array, so every Count has a defined reading under every",
|
|
2804
|
+
"observer, Count zero included. `.#%` is not applied and is unchanged. The `##`",
|
|
2805
|
+
"spelling answers a squared magnitude, exact and nonnegative: a Count when whole",
|
|
2806
|
+
"and a rational otherwise. The `###` spelling answers a fresh list of signed",
|
|
2807
|
+
"coordinates, never a Denum and never a single number. They are observations",
|
|
2808
|
+
"only: no load, native observer or operator changes, and no algebra product is",
|
|
2809
|
+
"installed",
|
|
2810
|
+
"",
|
|
2811
|
+
"The centered simplex, `%`, places the `r+1` slots on the vertices of a regular",
|
|
2812
|
+
"simplex centred at zero. `.##%` is `(C·Σbi² − S²)/(C−1)` with `S = Σbi` and",
|
|
2813
|
+
"`C = r+1`, and `.###%` is the centred coefficients `bi − S/C`, which sum to",
|
|
2814
|
+
"zero. Adding the same amount to every slot changes neither, and rank 0 is the",
|
|
2815
|
+
"degenerate simplex, of magnitude 0",
|
|
2816
|
+
"```",
|
|
2817
|
+
"; .Sd (Denum [2, [2, 5, 3, 7, 4]]);",
|
|
2818
|
+
"; [Sd.##%, Sd.###%, “” Sd]",
|
|
2819
|
+
"# [36, [2, 2, -4], “Denum(2,[2, 5, 3, 7, 4])”]",
|
|
2820
|
+
"; [(Denum [1, [3, 1]]).##%, (Denum [3, [2, 4, 2, 4]]).##%, (Denum [2, [1]]).###%, (Denum [2, [4, 4, 4]]).##%, (Denum [0, [5, 3]]).###%]",
|
|
2814
2821
|
"# [4, 16/3, [2/3, -1/3, -1/3], 0, [0]]",
|
|
2815
2822
|
"```",
|
|
2816
|
-
"The
|
|
2817
|
-
"
|
|
2818
|
-
"
|
|
2819
|
-
"
|
|
2820
|
-
"
|
|
2821
|
-
"
|
|
2822
|
-
"`Σ xk²`. Each `xk²` is rational, so `.##%%` is exact and equals `.##%`. A",
|
|
2823
|
-
"coordinate is exact when it is rational and a double where it has a radical.",
|
|
2824
|
-
"Equal magnitudes do not make the products agree: at C = 2, `B = [3, 1]` maps to",
|
|
2825
|
-
"`x = [0, 2]`, whose Cayley–Dickson square is −4, while the simplex magnitude is",
|
|
2826
|
-
"+4",
|
|
2827
|
-
"```",
|
|
2828
|
-
"; [(Denum [2, [3, 1]]).###%%, (Denum [2, [3, 1]]).##%%, (Denum [4, [2, 4, 2, 7]]).##%% = (Denum [4, [2, 4, 2, 7]]).##%, ((Denum [4, [2, 4, 2, 7]]).###%%) .3]",
|
|
2829
|
-
"# [[0, 2], 4, <>, -13/3]",
|
|
2830
|
-
"; [(Denum [3, [1]]).##%%, (Denum [6, [1]]).###%%, (Denum [1, [5]]).###%%]",
|
|
2831
|
-
"# [$!.denum-cd-count, $!.denum-cd-count, [0]]",
|
|
2832
|
-
"```",
|
|
2833
|
-
"The cross-polytope observers, `%%%`, place one load on each vertex of a",
|
|
2834
|
-
"cross-polytope, `C = 2n` vertices `+e0 … +e(n−1), −e0 … −e(n−1)`, so `bi` and",
|
|
2835
|
-
"`b(i+n)` are opposite. `.###%%%` is the antipodal residual `ri = bi − b(i+n)`",
|
|
2836
|
-
"and `.##%%%` is `Σ ri²`, zero exactly when every opposite pair matches. An odd",
|
|
2837
|
-
"Count has no such pairing and is `$!.denum-cross-count`; that refuses only this",
|
|
2838
|
-
"one-load-per-vertex binding, since a cross-polytope exists in every dimension n",
|
|
2839
|
-
"```",
|
|
2840
|
-
"; [(Denum [4, [2, 4, 2, 4]]).###%%%, (Denum [4, [2, 4, 2, 4]]).##%%%, (Denum [6, [5, 2, 3, 5, 1, 3]]).###%%%, (Denum [6, [5, 2, 3, 5, 1, 3]]).##%%%, (Denum [2, [3, 1]]).###%%%]",
|
|
2823
|
+
"The cross-polytope observers, `%%`, place `2r` slots on the vertices",
|
|
2824
|
+
"`+e0 … +e(r−1), −e0 … −e(r−1)`, so `bi` and `b(i+r)` are opposite. `.###%%` is",
|
|
2825
|
+
"the antipodal residual `ri = bi − b(i+r)` and `.##%%` is `Σ ri²`, zero exactly",
|
|
2826
|
+
"when every opposite pair matches. Rank 0 wants no slots and reads `[]` and 0",
|
|
2827
|
+
"```",
|
|
2828
|
+
"; [(Denum [2, [2, 4, 2, 4]]).###%%, (Denum [2, [2, 4, 2, 4]]).##%%, (Denum [3, [5, 2, 3, 5, 1, 3]]).###%%, (Denum [3, [5, 2, 3, 5, 1, 3]]).##%%, (Denum [1, [3, 1]]).###%%]",
|
|
2841
2829
|
"# [[0, 0], 0, [0, 1, 0], 1, [2]]",
|
|
2842
|
-
"; [(Denum [
|
|
2843
|
-
"# [
|
|
2830
|
+
"; [(Denum [0, [1]]).###%%, (Denum [1, [5]]).##%%, (Denum [2, [1, 2]]).###%%]",
|
|
2831
|
+
"# [[], 25, [1, 2]]",
|
|
2832
|
+
"```",
|
|
2833
|
+
"The Cayley–Dickson signed-basis observers, `%%%`, read `2^r` slots in the",
|
|
2834
|
+
"reference order `+e0 … +e(n−1), −e0 … −e(n−1)` with `n = 2^(r−1)`. `.###%%%` is",
|
|
2835
|
+
"`ri = vi − v(i+n)`, i = 0 … n−1, including the real coordinate; at rank 0 it is",
|
|
2836
|
+
"the single value. `.##%%%` is `Σ ri²`. Each antipodal pair cancels on its own, so",
|
|
2837
|
+
"the load `[2, 4, 2, 4]` at rank 2 reads `[0, 0]` and `0`, and `[3, 2, 1, 4]`",
|
|
2838
|
+
"reads `[2, -2]` and `8`. Equal magnitudes would not make products agree, and no",
|
|
2839
|
+
"Cayley–Dickson product is installed: `.##%%%` is a squared norm of the",
|
|
2840
|
+
"residual, not the multiplication. The `2^r` loads are signature loads, and the",
|
|
2841
|
+
"residual is `2^(r−1)` signed coefficients, one Cayley–Dickson rung below",
|
|
2842
|
+
"```",
|
|
2843
|
+
"; [(Denum [2, [2, 4, 2, 4]]).###%%%, (Denum [2, [2, 4, 2, 4]]).##%%%, (Denum [2, [3, 2, 1, 4]]).###%%%, (Denum [2, [3, 2, 1, 4]]).##%%%]",
|
|
2844
|
+
"# [[0, 0], 0, [2, -2], 8]",
|
|
2845
|
+
"; [(Denum [0, [5, 3, 9]]).###%%%, (Denum [1, [5, 3, 9]]).###%%%, (Denum [3, [9, 1, 2, 3, 4, 5, 6, 7]]).###%%%, (Denum [2, [3, 1]]).##%%%]",
|
|
2846
|
+
"# [[17], [11], [5, -4, -4, -4], 10]",
|
|
2847
|
+
"```",
|
|
2848
|
+
"The two differ wherever `2r` and `2^r` differ. At rank 3 the same six loads are",
|
|
2849
|
+
"three antipodal pairs to KPSL and eight padded slots to KDSL",
|
|
2850
|
+
"```",
|
|
2851
|
+
"; .W (Denum [3, [5, 2, 3, 5, 1, 3]]);",
|
|
2852
|
+
"; [W.###%%, W.##%%, W.###%%%, W.##%%%]",
|
|
2853
|
+
"# [[0, 1, 0], 1, [4, -1, 3, 5], 51]",
|
|
2844
2854
|
"```",
|
|
2845
|
-
"Only a Denum is observed,
|
|
2846
|
-
"
|
|
2855
|
+
"Only a Denum is observed, and no class can declare an observer of its own. A",
|
|
2856
|
+
"rank whose wanted slots pass the binding capacity of 65536 is refused",
|
|
2847
2857
|
"```",
|
|
2848
|
-
"; [[5, 3].##%, 3.###%%, (Denum [
|
|
2849
|
-
"# [$!.denum-binding-receiver, $!.denum-binding-receiver, $!.denum-binding-
|
|
2858
|
+
"; [[5, 3].##%, 3.###%%, (Denum [70000, [1]]).###%, (Denum [17, [1]]).##%%%, [.##% {7}].##%]",
|
|
2859
|
+
"# [$!.denum-binding-receiver, $!.denum-binding-receiver, $!.denum-binding-capacity, $!.denum-binding-capacity, $!.denum-binding-receiver]",
|
|
2850
2860
|
"```",
|
|
2851
2861
|
"Each observer is one token. A longer run, such as `.##%%%%`, is one unbound",
|
|
2852
2862
|
"name, never an observer before a `%`.",
|
|
2853
2863
|
"**Breaking:** `.##%%` and `.###%%` written without a space used to read as",
|
|
2854
2864
|
"`.##` or `.###` before `%%`; write `.## %%` for the modulo",
|
|
2855
2865
|
"```",
|
|
2856
|
-
"; [[5, 3, 1].## %% 2, [5, 3, 1].### %% 2, (Denum [
|
|
2866
|
+
"; [[5, 3, 1].## %% 2, [5, 3, 1].### %% 2, (Denum [1, [3, 1]]).##%.#]",
|
|
2857
2867
|
"# [1, 1, 4]",
|
|
2858
2868
|
"```",
|
|
2859
2869
|
"## Importing",
|
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Geometric observers of a
|
|
3
|
-
* 007.41c). They read a Denum and answer numbers and
|
|
4
|
-
* native.
|
|
2
|
+
* Geometric observers of a Denum, read by rank (occurrence/figure 007.41b,
|
|
3
|
+
* 007.41c, 007.43h, 007.43i, 007.44). They read a Denum and answer numbers and
|
|
4
|
+
* lists, and change nothing native.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* The Count of the Denum is the rank `r`. Each geometry wants a definite
|
|
7
|
+
* number of slots for that rank, and the Denum's stored loads are aligned to
|
|
8
|
+
* it into a virtual array: missing slots are 0, and excess slots wrap by index
|
|
9
|
+
* modulo the wanted length, their loads adding into the slot they wrap to, as
|
|
10
|
+
* `.#%` folds. The residual is then the geometry's ordinary formula on that
|
|
11
|
+
* virtual array, so every Count has a defined reading under every observer.
|
|
12
|
+
* The Count binding `.#%` itself is unchanged and is not applied here.
|
|
12
13
|
*
|
|
13
|
-
* | Geometry | Size-like | Residual-like |
|
|
14
|
+
* | Geometry | Size-like | Residual-like | Wanted slots |
|
|
14
15
|
* | --- | --- | --- | --- |
|
|
15
|
-
* | centered simplex `%` | `.##%` | `.###%` |
|
|
16
|
-
* |
|
|
17
|
-
* |
|
|
16
|
+
* | centered simplex (SSL) `%` | `.##%` | `.###%` | r + 1 |
|
|
17
|
+
* | cross-polytope (KPSL) `%%` | `.##%%` | `.###%%` | 2r |
|
|
18
|
+
* | Cayley–Dickson signed basis (KDSL) `%%%` | `.##%%%` | `.###%%%` | 2ʳ |
|
|
18
19
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
20
|
+
* The suffix order is a semantic contract (007.46): one `%` is SSL, two are
|
|
21
|
+
* KPSL, three are KDSL. v0.52.0 shipped the last two the other way round.
|
|
22
|
+
*
|
|
23
|
+
* KDSL (007.43h) reads signed basis pairs: at rank 0 the single value, at rank
|
|
24
|
+
* r ≥ 1 the 2^(r−1) differences `vᵢ − v(i+2^(r−1))`. Its Size-like is the sum
|
|
25
|
+
* of their squares. A wanted length past `DENUM_BINDING_CAPACITY` is refused as
|
|
26
|
+
* `$!.denum-binding-capacity`.
|
|
27
|
+
*
|
|
28
|
+
* KDSL's Size-like and Residual-like are observations of the coordinates, not
|
|
29
|
+
* its multiplication. The Cayley–Dickson product is the separate reference in
|
|
30
|
+
* `cayley-dickson.ts`; no observer spelling answers it.
|
|
31
|
+
*
|
|
32
|
+
* Return types: a squared magnitude is exact and nonnegative, a FrameCount
|
|
33
|
+
* when whole and a FrameRational otherwise. Coordinates are a fresh array of
|
|
34
|
+
* signed exact numbers, never a Denum. No native observer, operator or Denum
|
|
35
|
+
* load changes, and no algebra product is installed.
|
|
26
36
|
*
|
|
27
37
|
* @module
|
|
28
38
|
*/
|
|
@@ -30,35 +40,18 @@ import { Frame } from "./frame.js";
|
|
|
30
40
|
import { FrameArray } from "./frame-array.js";
|
|
31
41
|
import { FrameCount } from "./frame-count.js";
|
|
32
42
|
import { FrameInt } from "./frame-int.js";
|
|
33
|
-
import { FrameNumber } from "./frame-number.js";
|
|
34
43
|
import { FrameRational } from "./frame-rational.js";
|
|
35
|
-
import {
|
|
44
|
+
import { DENUM_BINDING_CAPACITY, denumState } from "./fourth-hash.js";
|
|
36
45
|
/** An exact nonnegative magnitude: a Count when whole, a rational otherwise. */
|
|
37
46
|
function magnitude(num, den) {
|
|
38
47
|
const value = FrameRational.create(num, den);
|
|
39
48
|
return value instanceof FrameInt ? new FrameCount(value.data) : value;
|
|
40
49
|
}
|
|
41
|
-
/** The exact square root of a nonnegative bigint, or undefined. */
|
|
42
|
-
function exactRoot(value) {
|
|
43
|
-
if (value < 2n)
|
|
44
|
-
return value;
|
|
45
|
-
let root = value;
|
|
46
|
-
let next = (root + 1n) / 2n;
|
|
47
|
-
while (next < root) {
|
|
48
|
-
root = next;
|
|
49
|
-
next = (root + value / root) / 2n;
|
|
50
|
-
}
|
|
51
|
-
return root * root === value ? root : undefined;
|
|
52
|
-
}
|
|
53
50
|
const sum = (values) => values.reduce((total, value) => total + value, 0n);
|
|
54
51
|
/**
|
|
55
|
-
* Centered simplex, `.##%`: `Q_S = (C·Σbᵢ² − S²)/(C−1)` with `S = Σbᵢ`, the
|
|
52
|
+
* Centered simplex (SSL), `.##%`: `Q_S = (C·Σbᵢ² − S²)/(C−1)` with `S = Σbᵢ`, the
|
|
56
53
|
* squared length of `Σbᵢvᵢ` over the C unit vertices of a centered regular
|
|
57
54
|
* simplex. Count 1 is degenerate and answers 0.
|
|
58
|
-
*
|
|
59
|
-
* It is also the Cayley–Dickson norm `.##%%`: the Helmert map φ_C is an
|
|
60
|
-
* isometry, so `N(φ_C(B)) = Σxₖ²` equals this form exactly. The identity is
|
|
61
|
-
* checked by test rather than computed twice.
|
|
62
55
|
*/
|
|
63
56
|
function simplexSize(loads) {
|
|
64
57
|
const c = BigInt(loads.length);
|
|
@@ -80,88 +73,65 @@ function simplexResidual(loads) {
|
|
|
80
73
|
return new FrameArray(loads.map((load) => FrameRational.create(c * load - total, c)));
|
|
81
74
|
}
|
|
82
75
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
function helmertNumerators(loads) {
|
|
87
|
-
const numerators = [];
|
|
88
|
-
let prefix = 0n;
|
|
89
|
-
for (let k = 1; k < loads.length; k++) {
|
|
90
|
-
prefix += loads[k - 1];
|
|
91
|
-
numerators.push(prefix - BigInt(k) * loads[k]);
|
|
92
|
-
}
|
|
93
|
-
return numerators;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Cayley–Dickson, `.###%%`: the coefficients `[0, x₁, …, x(C−1)]` of
|
|
97
|
-
* `x = φ_C(B)` on the basis `e₀ = 1, e₁, …`, with
|
|
98
|
-
* `xₖ = sₖ·√(C/((C−1)k(k+1)))`. Writing `d = (C−1)k(k+1)`, that is
|
|
99
|
-
* `sₖ·√(C·d)/d`, so a coordinate is the exact rational `sₖ·√m/d` when
|
|
100
|
-
* `m = C·d` is a perfect square, and a double otherwise, computed as the
|
|
101
|
-
* 007.41 experiment computes it. The real part is the exact 0. A double past
|
|
102
|
-
* the finite range is refused as `$!.numeric-range .###%%`, though `.##%%` of
|
|
103
|
-
* the same Denum stays exact: the two readings have different ranges by
|
|
104
|
-
* design (007.41e).
|
|
76
|
+
* Cross-polytope (KPSL), 2n slots (007.41b §5.A): the slots sit on the
|
|
77
|
+
* vertices `+e₀ … +e(n−1), −e₀ … −e(n−1)`, so `bᵢ` and `b(i+n)` are opposite,
|
|
78
|
+
* and the antipodal residual is `rᵢ = bᵢ − b(i+n)`, i = 0 … n−1.
|
|
105
79
|
*/
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
const scale = c > 1 ? Math.sqrt(c / (c - 1)) : 0;
|
|
110
|
-
for (const [index, s] of helmertNumerators(loads).entries()) {
|
|
111
|
-
const k = BigInt(index + 1);
|
|
112
|
-
const d = BigInt(c - 1) * k * (k + 1n);
|
|
113
|
-
const root = s === 0n ? 0n : exactRoot(BigInt(c) * d);
|
|
114
|
-
if (root !== undefined) {
|
|
115
|
-
coordinates.push(FrameRational.create(s * root, d));
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
const kk = index + 1;
|
|
119
|
-
const value = (scale * Number(s)) / Math.sqrt(kk * (kk + 1));
|
|
120
|
-
if (!Number.isFinite(value)) {
|
|
121
|
-
return Frame.error("$!.numeric-range .###%%");
|
|
122
|
-
}
|
|
123
|
-
coordinates.push(new FrameNumber(value));
|
|
124
|
-
}
|
|
125
|
-
return new FrameArray(coordinates);
|
|
80
|
+
function antipodalResidual(slots) {
|
|
81
|
+
const n = slots.length / 2;
|
|
82
|
+
return slots.slice(0, n).map((slot, i) => slot - slots[i + n]);
|
|
126
83
|
}
|
|
127
84
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
85
|
+
* Cayley–Dickson signed basis (KDSL, 007.43h), 2ʳ slots in the reference order
|
|
86
|
+
* `+e₀ … +e(n−1), −e₀ … −e(n−1)`: rank 0 is the single value, and rank r ≥ 1
|
|
87
|
+
* is `Rᵢ = vᵢ − v(i+n)` with n = 2^(r−1). The real coordinate is included.
|
|
131
88
|
*/
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
return loads.slice(0, n).map((load, i) => load - loads[i + n]);
|
|
89
|
+
function signedBasisResidual(slots) {
|
|
90
|
+
return slots.length === 1 ? [slots[0]] : antipodalResidual(slots);
|
|
135
91
|
}
|
|
136
|
-
|
|
137
|
-
const
|
|
92
|
+
const sumSquares = (values) => new FrameCount(sum(values.map((value) => value * value)));
|
|
93
|
+
const integers = (values) => new FrameArray(values.map((value) => new FrameInt(value)));
|
|
138
94
|
/**
|
|
139
95
|
* The geometries by the `%` suffix that follows `##` or `###`. Their keys are
|
|
140
96
|
* `Frame.GEOMETRY_SUFFIXES`, from which `Frame.GEOMETRIC_OBSERVERS` is spelled.
|
|
141
|
-
* Odd C has no antipodal pairing, so `$!.denum-cross-count` refuses only this
|
|
142
|
-
* binding, not odd-dimensional cross-polytopes.
|
|
143
97
|
*/
|
|
144
98
|
export const GEOMETRIES = {
|
|
145
99
|
"%": {
|
|
146
|
-
|
|
100
|
+
wanted: (r) => r + 1n,
|
|
147
101
|
size: simplexSize,
|
|
148
102
|
residual: simplexResidual,
|
|
149
103
|
},
|
|
150
104
|
"%%": {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
105
|
+
// KPSL, the cross-polytope: 2r slots.
|
|
106
|
+
wanted: (r) => 2n * r,
|
|
107
|
+
size: (slots) => sumSquares(antipodalResidual(slots)),
|
|
108
|
+
residual: (slots) => integers(antipodalResidual(slots)),
|
|
154
109
|
},
|
|
155
110
|
"%%%": {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
111
|
+
// KDSL, the Cayley–Dickson signed basis: 2ʳ slots, saturated so a huge
|
|
112
|
+
// rank is refused rather than computed.
|
|
113
|
+
wanted: (r) => r > 64n ? DENUM_BINDING_CAPACITY + 1n : 1n << r,
|
|
114
|
+
size: (slots) => sumSquares(signedBasisResidual(slots)),
|
|
115
|
+
residual: (slots) => integers(signedBasisResidual(slots)),
|
|
159
116
|
},
|
|
160
117
|
};
|
|
161
118
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
|
|
119
|
+
* Aligns stored loads to a wanted length: shorter is zero-filled, longer wraps
|
|
120
|
+
* by index modulo the wanted length, adding into the slot it wraps to.
|
|
121
|
+
*/
|
|
122
|
+
function align(loads, wanted) {
|
|
123
|
+
const slots = new Array(wanted).fill(0n);
|
|
124
|
+
if (wanted === 0)
|
|
125
|
+
return slots;
|
|
126
|
+
loads.forEach((load, index) => {
|
|
127
|
+
slots[index % wanted] += load;
|
|
128
|
+
});
|
|
129
|
+
return slots;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Answers one geometric observer of a source: recognizes the Denum, takes its
|
|
133
|
+
* Count as the rank, aligns its stored loads to the rank's wanted slots, and
|
|
134
|
+
* reads the virtual array.
|
|
165
135
|
*
|
|
166
136
|
* @param source The observed Frame.
|
|
167
137
|
* @param key One of `Frame.GEOMETRIC_OBSERVERS`.
|
|
@@ -170,12 +140,14 @@ export const GEOMETRIES = {
|
|
|
170
140
|
function observeGeometry(source, key) {
|
|
171
141
|
const residual = key.startsWith("###");
|
|
172
142
|
const geometry = GEOMETRIES[key.slice(residual ? 3 : 2)];
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
175
|
-
return
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
178
|
-
return
|
|
179
|
-
|
|
143
|
+
const state = denumState(source);
|
|
144
|
+
if (state instanceof Frame)
|
|
145
|
+
return state;
|
|
146
|
+
const wanted = geometry.wanted(state.count);
|
|
147
|
+
if (wanted > DENUM_BINDING_CAPACITY) {
|
|
148
|
+
return Frame.error("$!.denum-binding-capacity");
|
|
149
|
+
}
|
|
150
|
+
const slots = align(state.loads, Number(wanted));
|
|
151
|
+
return residual ? geometry.residual(slots) : geometry.size(slots);
|
|
180
152
|
}
|
|
181
153
|
Frame.observeGeometry = observeGeometry;
|
|
@@ -133,15 +133,14 @@ export function bindDenumCount(source) {
|
|
|
133
133
|
return construct(new FrameCount(BigInt(bound.length)), bound.map((load) => new FrameCount(load)));
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
* The
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* they consume the same genuine binding as `.#%` at no extra cost.
|
|
136
|
+
* The recognized Denum state of `source`, or the error `.#%` answers for a
|
|
137
|
+
* failed or non-Denum receiver. The rank observers (007.43i, 007.44) read this
|
|
138
|
+
* stored Count and the stored loads as they are, without binding.
|
|
140
139
|
*
|
|
141
140
|
* @param source The observed Frame.
|
|
142
|
-
* @returns The
|
|
141
|
+
* @returns The Count and stored loads, or the receiver's error.
|
|
143
142
|
*/
|
|
144
|
-
export function
|
|
143
|
+
export function denumState(source) {
|
|
145
144
|
const failure = source.observationError();
|
|
146
145
|
if (failure)
|
|
147
146
|
return failure;
|
|
@@ -150,6 +149,21 @@ export function boundLoads(source) {
|
|
|
150
149
|
const state = recognizeDenum(source);
|
|
151
150
|
if (!state)
|
|
152
151
|
return Frame.error("$!.denum-binding-receiver");
|
|
152
|
+
return { count: state.count, loads: state.loads };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The loads of `source.#%`, the C sums `bj = Σ ai` over `i mod C = j`, folded
|
|
156
|
+
* without building the bound Denum, or the binding's error in the order
|
|
157
|
+
* `bindDenumCount` documents. The geometric observers (007.41b) read these, so
|
|
158
|
+
* they consume the same genuine binding as `.#%` at no extra cost.
|
|
159
|
+
*
|
|
160
|
+
* @param source The observed Frame.
|
|
161
|
+
* @returns The C bound loads, or the binding's error.
|
|
162
|
+
*/
|
|
163
|
+
export function boundLoads(source) {
|
|
164
|
+
const state = denumState(source);
|
|
165
|
+
if (state instanceof Frame)
|
|
166
|
+
return state;
|
|
153
167
|
if (state.count === 0n)
|
|
154
168
|
return Frame.error("$!.denum-binding-zero-count");
|
|
155
169
|
if (state.count > DENUM_BINDING_CAPACITY) {
|
package/esm/lib/frames/frame.js
CHANGED
|
@@ -1157,9 +1157,9 @@ Object.defineProperty(Frame, "kBIND", {
|
|
|
1157
1157
|
});
|
|
1158
1158
|
/**
|
|
1159
1159
|
* The `%` suffixes of the geometric observers of a Count-bound Denum
|
|
1160
|
-
* (occurrence/figure 007.41b, 007.
|
|
1161
|
-
*
|
|
1162
|
-
* `GEOMETRIES` in `denum-observers.ts`.
|
|
1160
|
+
* (occurrence/figure 007.41b, 007.46): the centered simplex SSL `%`, the
|
|
1161
|
+
* cross-polytope KPSL `%%` and the Cayley–Dickson signed basis KDSL `%%%`.
|
|
1162
|
+
* The order is a contract. They key `GEOMETRIES` in `denum-observers.ts`.
|
|
1163
1163
|
*/
|
|
1164
1164
|
Object.defineProperty(Frame, "GEOMETRY_SUFFIXES", {
|
|
1165
1165
|
enumerable: true,
|
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.53.0";
|