@ac-kit/math-analysis 0.1.11 → 0.2.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.
- package/CHANGELOG.md +66 -0
- package/README.md +82 -8
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/roots/_brent-kernel.d.ts +38 -0
- package/dist/roots/_brent-kernel.d.ts.map +1 -0
- package/dist/roots/_brent-kernel.js +112 -0
- package/dist/roots/_brent-kernel.js.map +1 -0
- package/dist/roots/_grown.d.ts +7 -0
- package/dist/roots/_grown.d.ts.map +1 -0
- package/dist/roots/_grown.js +20 -0
- package/dist/roots/_grown.js.map +1 -0
- package/dist/roots/_level-search.d.ts +137 -0
- package/dist/roots/_level-search.d.ts.map +1 -0
- package/dist/roots/_level-search.js +532 -0
- package/dist/roots/_level-search.js.map +1 -0
- package/dist/roots/brent.d.ts +59 -0
- package/dist/roots/brent.d.ts.map +1 -0
- package/dist/roots/brent.js +115 -0
- package/dist/roots/brent.js.map +1 -0
- package/dist/roots/find-level-bands.d.ts +148 -0
- package/dist/roots/find-level-bands.d.ts.map +1 -0
- package/dist/roots/find-level-bands.js +351 -0
- package/dist/roots/find-level-bands.js.map +1 -0
- package/dist/roots/find-level-crossings.d.ts +141 -0
- package/dist/roots/find-level-crossings.d.ts.map +1 -0
- package/dist/roots/find-level-crossings.js +168 -0
- package/dist/roots/find-level-crossings.js.map +1 -0
- package/dist/roots/level-search-options.d.ts +56 -0
- package/dist/roots/level-search-options.d.ts.map +1 -0
- package/dist/roots/level-search-options.js +2 -0
- package/dist/roots/level-search-options.js.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { describeValue } from "@ac-kit/core";
|
|
2
|
+
import { brentKernel_ } from "./_brent-kernel.js";
|
|
3
|
+
class FunctionBrentState_ {
|
|
4
|
+
f;
|
|
5
|
+
signal;
|
|
6
|
+
lower = 0;
|
|
7
|
+
upper = 0;
|
|
8
|
+
lowerValue = 0;
|
|
9
|
+
upperValue = 0;
|
|
10
|
+
tolerance = 0;
|
|
11
|
+
x = 0;
|
|
12
|
+
value = 0;
|
|
13
|
+
root = 0;
|
|
14
|
+
constructor(f, signal) {
|
|
15
|
+
this.f = f;
|
|
16
|
+
this.signal = signal;
|
|
17
|
+
}
|
|
18
|
+
evaluate() {
|
|
19
|
+
this.signal?.throwIfAborted();
|
|
20
|
+
const { x } = this;
|
|
21
|
+
const value = this.f(x);
|
|
22
|
+
if (Number.isNaN(value)) {
|
|
23
|
+
throw new RangeError(`brent: f(${x}) is NaN`);
|
|
24
|
+
}
|
|
25
|
+
this.value = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Finds where a function crosses zero inside a bracket, with Brent's 1973
|
|
30
|
+
* algorithm: bisection's guarantee at the speed of interpolation.
|
|
31
|
+
*
|
|
32
|
+
* Each step tries inverse quadratic interpolation through the last three points
|
|
33
|
+
* (or the secant through two), and falls back to bisection whenever the
|
|
34
|
+
* interpolated point would leave the bracket or shrink it too slowly. The root
|
|
35
|
+
* therefore stays bracketed throughout, the convergence is superlinear (order
|
|
36
|
+
* about 1.84) on a smooth simple root, and it is never much slower than
|
|
37
|
+
* bisection on anything else. It is the algorithm behind MATLAB's `fzero` and
|
|
38
|
+
* `scipy.optimize.brentq`, and the root finder to reach for here.
|
|
39
|
+
*
|
|
40
|
+
* **Tolerance.** Brent's: iteration stops once the bracket `[b, c]` satisfies
|
|
41
|
+
* `|c − b| / 2 ≤ 2ε|b| + tolerance`, ε being `Number.EPSILON`, and returns the
|
|
42
|
+
* end `b` with the smaller `|f|`. The root is then within `4ε|b| + 2 ·
|
|
43
|
+
* tolerance` of the result; Brent states the bound as `6ε|x| + 2t`. The
|
|
44
|
+
* relative part is fixed, so `tolerance: 0`, the default, asks for the bracket
|
|
45
|
+
* binary64 can resolve: a couple of ulps of the root, or the smallest subnormal
|
|
46
|
+
* at a root at zero.
|
|
47
|
+
*
|
|
48
|
+
* **Termination.** Guaranteed without a cap: Brent proves that it never takes
|
|
49
|
+
* more than about N² evaluations, N being the number bisection needs for the
|
|
50
|
+
* same bracket and tolerance; on a smooth simple root it takes far fewer than
|
|
51
|
+
* N. `maxIterations` only adds a cap of the caller's own.
|
|
52
|
+
*
|
|
53
|
+
* Accepts the bracket in either order. `f` may return ±`Infinity` (only its
|
|
54
|
+
* sign is used near a pole); `NaN` has no sign and throws.
|
|
55
|
+
*
|
|
56
|
+
* O(1) memory; one evaluation per iteration, two for the bracket.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* brent((x) => x * x - 2, 0, 2); // 1.414213562373095, an ulp from √2
|
|
61
|
+
* brent(Math.cos, 0, 3); // 1.5707963267948966
|
|
62
|
+
* brent((x) => x * x - 2, 2, 3); // throws RangeError — no sign change
|
|
63
|
+
* ```;
|
|
64
|
+
*
|
|
65
|
+
* @param f The function whose zero is sought, continuous on the bracket for the
|
|
66
|
+
* result to be a root rather than a jump.
|
|
67
|
+
* @param lower One end of the bracket, finite.
|
|
68
|
+
* @param upper The other end, finite.
|
|
69
|
+
* @param options `tolerance`: the absolute part `t` of the stopping test, `≥
|
|
70
|
+
* 0`, default `0`. `maxIterations`: evaluations after the two at the ends, a
|
|
71
|
+
* non-negative integer or `Infinity`, the default. `signal`: checked before
|
|
72
|
+
* every evaluation.
|
|
73
|
+
* @returns A point within `4ε|x| + 2 · tolerance` of a zero of `f`, or an end
|
|
74
|
+
* of the bracket where `f` is exactly zero.
|
|
75
|
+
* @throws {RangeError} When an end is not finite, `tolerance` is negative or
|
|
76
|
+
* not finite, `maxIterations` is not a non-negative integer or `Infinity`,
|
|
77
|
+
* `f` returns `NaN`, or `f(lower)` and `f(upper)` are both non-zero with the
|
|
78
|
+
* same sign — nothing guarantees a root between them.
|
|
79
|
+
* @throws {ConvergenceError} When `maxIterations` runs out first.
|
|
80
|
+
* @throws The signal's reason, once it is aborted.
|
|
81
|
+
* @see [Root finding](https://anthochamp.pages.grenadine.io/node-essentials/topics/math/calculus/root-finding/)
|
|
82
|
+
*/
|
|
83
|
+
export function brent(f, lower, upper, options) {
|
|
84
|
+
const tolerance = options?.tolerance ?? 0;
|
|
85
|
+
const maxIterations = options?.maxIterations ?? Number.POSITIVE_INFINITY;
|
|
86
|
+
if (!Number.isFinite(lower) || !Number.isFinite(upper)) {
|
|
87
|
+
throw new RangeError(`brent: the bracket must be finite, got [${describeValue(lower)}, ${describeValue(upper)}]`);
|
|
88
|
+
}
|
|
89
|
+
if (!Number.isFinite(tolerance) || tolerance < 0) {
|
|
90
|
+
throw new RangeError(`brent: tolerance must be finite and non-negative, got ${describeValue(tolerance)}`);
|
|
91
|
+
}
|
|
92
|
+
if (maxIterations !== Number.POSITIVE_INFINITY &&
|
|
93
|
+
!(Number.isSafeInteger(maxIterations) && maxIterations >= 0)) {
|
|
94
|
+
throw new RangeError(`brent: maxIterations must be a non-negative integer or Infinity, got ${describeValue(maxIterations)}`);
|
|
95
|
+
}
|
|
96
|
+
const state = new FunctionBrentState_(f, options?.signal);
|
|
97
|
+
state.x = lower;
|
|
98
|
+
state.evaluate();
|
|
99
|
+
const lowerValue = state.value;
|
|
100
|
+
state.x = upper;
|
|
101
|
+
state.evaluate();
|
|
102
|
+
const upperValue = state.value;
|
|
103
|
+
if ((lowerValue > 0 && upperValue > 0) ||
|
|
104
|
+
(lowerValue < 0 && upperValue < 0)) {
|
|
105
|
+
throw new RangeError(`brent: f(${lower}) and f(${upper}) have the same sign, so they bracket no root`);
|
|
106
|
+
}
|
|
107
|
+
state.lower = lower;
|
|
108
|
+
state.upper = upper;
|
|
109
|
+
state.lowerValue = lowerValue;
|
|
110
|
+
state.upperValue = upperValue;
|
|
111
|
+
state.tolerance = tolerance;
|
|
112
|
+
brentKernel_(state, maxIterations, "brent");
|
|
113
|
+
return state.root;
|
|
114
|
+
}
|
|
115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K,GAAG,KAAK,CAAC;IACpB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;IAC5B,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { type Callable } from "@ac-kit/core";
|
|
2
|
+
import { LevelSearch_ } from "./_level-search.js";
|
|
3
|
+
import type { LevelSearchOptions } from "./level-search-options.js";
|
|
4
|
+
/**
|
|
5
|
+
* Where a function lies within each of several bands `[low, high)`, as columns
|
|
6
|
+
* indexed by band: what {@link findLevelBands} writes, and may write again into
|
|
7
|
+
* the same object without allocating once its columns are large enough.
|
|
8
|
+
*
|
|
9
|
+
* Band `k`'s intervals are entries `offsets[k]` to `offsets[k + 1] − 1` of
|
|
10
|
+
* {@link starts}, {@link ends} and the enclosure columns; its unresolved
|
|
11
|
+
* intervals are entries `unresolvedOffsets[k]` to `unresolvedOffsets[k + 1] −
|
|
12
|
+
* 1` of {@link unresolvedStarts} and {@link unresolvedEnds}. The columns are
|
|
13
|
+
* reallocated when they grow, so read them again after each search.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const bands = findLevelBands(Math.sin, 0.5, 10, [[0.5, 1]], { maxRate: 1 });
|
|
18
|
+
* for (let index = bands.offsets[0]!; index < bands.offsets[1]!; index++) {
|
|
19
|
+
* console.log(bands.starts[index], bands.ends[index]);
|
|
20
|
+
* }
|
|
21
|
+
* // [π/6, 5π/6), then [13π/6, 17π/6); sin touches the high edge 1 at π/2
|
|
22
|
+
* // and 5π/2, which no rate bound decides, so bands.unresolvedOffsets[1]
|
|
23
|
+
* // is 2.
|
|
24
|
+
* ```;
|
|
25
|
+
*/
|
|
26
|
+
export declare class LevelBands {
|
|
27
|
+
/** @internal The search state and its buffers. */
|
|
28
|
+
readonly search: LevelSearch_;
|
|
29
|
+
private bandCount_;
|
|
30
|
+
private offsets_;
|
|
31
|
+
private starts_;
|
|
32
|
+
private ends_;
|
|
33
|
+
private earliestStarts_;
|
|
34
|
+
private latestStarts_;
|
|
35
|
+
private earliestEnds_;
|
|
36
|
+
private latestEnds_;
|
|
37
|
+
private unresolvedOffsets_;
|
|
38
|
+
private unresolvedStarts_;
|
|
39
|
+
private unresolvedEnds_;
|
|
40
|
+
private edges_;
|
|
41
|
+
private edgeLevels_;
|
|
42
|
+
private pendingStarts_;
|
|
43
|
+
private pendingEnds_;
|
|
44
|
+
private pendingCount_;
|
|
45
|
+
/** How many bands were searched. */
|
|
46
|
+
get bandCount(): number;
|
|
47
|
+
/** `bandCount + 1` entries: band `k`'s intervals start at `offsets[k]`. */
|
|
48
|
+
get offsets(): Uint32Array;
|
|
49
|
+
/**
|
|
50
|
+
* Starts of the half-open intervals `[start, end)` where `low ≤ f < high`,
|
|
51
|
+
* ascending within a band, disjoint and non-empty, inside `[lower, upper)`:
|
|
52
|
+
* `lower`, or the time of the crossing that enters the band.
|
|
53
|
+
*/
|
|
54
|
+
get starts(): Float64Array;
|
|
55
|
+
/** Ends of the intervals: the time of the crossing that leaves, or `upper`. */
|
|
56
|
+
get ends(): Float64Array;
|
|
57
|
+
/**
|
|
58
|
+
* Per interval, the enclosure of its start, as `findLevelCrossings` reports
|
|
59
|
+
* it for the crossing that enters the band: `f` is certified out of the band
|
|
60
|
+
* just before `earliestStarts` and in it just after `latestStarts`. Both are
|
|
61
|
+
* `lower` for an interval that starts there.
|
|
62
|
+
*/
|
|
63
|
+
get earliestStarts(): Float64Array;
|
|
64
|
+
/** Per interval, the end of its start's enclosure. */
|
|
65
|
+
get latestStarts(): Float64Array;
|
|
66
|
+
/** Per interval, the start of its end's enclosure; `upper` at `upper`. */
|
|
67
|
+
get earliestEnds(): Float64Array;
|
|
68
|
+
/** Per interval, the end of its end's enclosure. */
|
|
69
|
+
get latestEnds(): Float64Array;
|
|
70
|
+
/** `bandCount + 1` entries: band `k`'s unresolved intervals start here. */
|
|
71
|
+
get unresolvedOffsets(): Uint32Array;
|
|
72
|
+
/**
|
|
73
|
+
* Starts of the closed intervals where membership could not be decided,
|
|
74
|
+
* ascending and disjoint: the unresolved intervals of the band's two edges,
|
|
75
|
+
* and the enclosures of any visit too brief for a half-open interval, merged.
|
|
76
|
+
* Membership is certified everywhere else, outside the intervals' end
|
|
77
|
+
* enclosures.
|
|
78
|
+
*/
|
|
79
|
+
get unresolvedStarts(): Float64Array;
|
|
80
|
+
/** Ends of the closed unresolved intervals. */
|
|
81
|
+
get unresolvedEnds(): Float64Array;
|
|
82
|
+
/** How many times the last search called `f`, over all bands together. */
|
|
83
|
+
get evaluations(): number;
|
|
84
|
+
/** @internal Searches the interval already set on {@link search}. */
|
|
85
|
+
fill(f: Callable<[x: number], number>, bands: readonly (readonly [low: number, high: number])[], options: LevelSearchOptions): void;
|
|
86
|
+
private isAboveAtStart_;
|
|
87
|
+
private writeIntervals_;
|
|
88
|
+
/**
|
|
89
|
+
* Appends the interval from crossing `entry` to crossing `exit`, `-1`
|
|
90
|
+
* standing for the interval's ends.
|
|
91
|
+
*/
|
|
92
|
+
private appendInterval_;
|
|
93
|
+
/** Makes room for one more pending interval and returns its index. */
|
|
94
|
+
private reservePending_;
|
|
95
|
+
/**
|
|
96
|
+
* Writes the band's unresolved intervals: its edges' and its too-brief
|
|
97
|
+
* visits', each source sorted, sorted together by insertion and merged where
|
|
98
|
+
* they overlap.
|
|
99
|
+
*/
|
|
100
|
+
private writeUnresolved_;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* For each band `[low, high)`, the stretches of `[lower, upper)` where `low ≤ f
|
|
104
|
+
* < high`, **certified** like {@link findLevelCrossings}: given a true bound on
|
|
105
|
+
* `|f′|`, membership is exact outside the reported unresolved intervals and the
|
|
106
|
+
* enclosures of the intervals' ends.
|
|
107
|
+
*
|
|
108
|
+
* Every distinct finite band edge is a level, and all of them are searched in
|
|
109
|
+
* one subdivision, so `f` is evaluated once per point whatever the number of
|
|
110
|
+
* bands; edges shared by neighbouring bands, such as a golden hour's lower edge
|
|
111
|
+
* and a blue hour's upper one, are searched once. An edge may be `±∞` for an
|
|
112
|
+
* open band, and a band with `low === high` is empty. The intervals of a band
|
|
113
|
+
* follow from the crossings of its two edges; since the crossings of one
|
|
114
|
+
* subdivision step are ordered as `f` passes the levels, the edges can never be
|
|
115
|
+
* reported out of order (above `high` while below `low`).
|
|
116
|
+
*
|
|
117
|
+
* The guarantee, the behaviour under a violated `maxRate`, the termination
|
|
118
|
+
* bound and the allocation behaviour are {@link findLevelCrossings}'s, with
|
|
119
|
+
* `(upper − lower) / resolution` bounding the subdivision for all levels
|
|
120
|
+
* together.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* // Golden hour [−4°, 6°) and blue hour [−6°, −4°) of a solar altitude in
|
|
125
|
+
* // degrees over epoch milliseconds.
|
|
126
|
+
* const light = findLevelBands(altitude, start, end, [[-4, 6], [-6, -4]], {
|
|
127
|
+
* maxRate: 400 / 86_400_000,
|
|
128
|
+
* resolution: 60_000,
|
|
129
|
+
* integer: true,
|
|
130
|
+
* });
|
|
131
|
+
* ```;
|
|
132
|
+
*
|
|
133
|
+
* @param f The function, finite wherever it is called.
|
|
134
|
+
* @param lower Start of the interval, finite.
|
|
135
|
+
* @param upper End of the interval, finite and `≥ lower`; intervals end at it
|
|
136
|
+
* at the latest.
|
|
137
|
+
* @param bands The bands, as `[low, high]` pairs with `low ≤ high`.
|
|
138
|
+
* @param options The rate bound and how finely to search; see
|
|
139
|
+
* {@link LevelSearchOptions}.
|
|
140
|
+
* @param out A result to overwrite instead of allocating one; it must not be in
|
|
141
|
+
* use by an enclosing search (from inside `f`).
|
|
142
|
+
* @returns `out`, or a new {@link LevelBands}. Unspecified after a throw.
|
|
143
|
+
* @throws {RangeError} For a band edge that is `NaN` or `low > high`, and for
|
|
144
|
+
* everything {@link findLevelCrossings} rejects.
|
|
145
|
+
* @throws Whatever `budget.spend` throws, and the signal's reason once aborted.
|
|
146
|
+
*/
|
|
147
|
+
export declare function findLevelBands(f: Callable<[x: number], number>, lower: number, upper: number, bands: readonly (readonly [low: number, high: number])[], options: LevelSearchOptions, out?: LevelBands): LevelBands;
|
|
148
|
+
//# sourceMappingURL=find-level-bands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-level-bands.d.ts","sourceRoot":"","sources":["../../src/roots/find-level-bands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,cAAc,CAAC;AAG5D,OAAO,EAGN,YAAY,EACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,UAAU;IACtB,kDAAkD;IAClD,QAAQ,CAAC,MAAM,eAAsB;IAErC,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,kBAAkB,CAAsB;IAChD,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,eAAe,CAAuB;IAE9C,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAqB;IAExC,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,aAAa,CAAK;I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E,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,EACxD,OAAO,EAAE,kBAAkB,EAC3B,GAAG,GAAE,UAA6B,GAChC,UAAU,CAMZ"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { describeValue } from "@ac-kit/core";
|
|
2
|
+
import { grownFloat64_ } from "./_grown.js";
|
|
3
|
+
import { LEVEL_ABOVE_ALL_, LEVEL_BELOW_ALL_, LevelSearch_, } from "./_level-search.js";
|
|
4
|
+
/**
|
|
5
|
+
* Where a function lies within each of several bands `[low, high)`, as columns
|
|
6
|
+
* indexed by band: what {@link findLevelBands} writes, and may write again into
|
|
7
|
+
* the same object without allocating once its columns are large enough.
|
|
8
|
+
*
|
|
9
|
+
* Band `k`'s intervals are entries `offsets[k]` to `offsets[k + 1] − 1` of
|
|
10
|
+
* {@link starts}, {@link ends} and the enclosure columns; its unresolved
|
|
11
|
+
* intervals are entries `unresolvedOffsets[k]` to `unresolvedOffsets[k + 1] −
|
|
12
|
+
* 1` of {@link unresolvedStarts} and {@link unresolvedEnds}. The columns are
|
|
13
|
+
* reallocated when they grow, so read them again after each search.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const bands = findLevelBands(Math.sin, 0.5, 10, [[0.5, 1]], { maxRate: 1 });
|
|
18
|
+
* for (let index = bands.offsets[0]!; index < bands.offsets[1]!; index++) {
|
|
19
|
+
* console.log(bands.starts[index], bands.ends[index]);
|
|
20
|
+
* }
|
|
21
|
+
* // [π/6, 5π/6), then [13π/6, 17π/6); sin touches the high edge 1 at π/2
|
|
22
|
+
* // and 5π/2, which no rate bound decides, so bands.unresolvedOffsets[1]
|
|
23
|
+
* // is 2.
|
|
24
|
+
* ```;
|
|
25
|
+
*/
|
|
26
|
+
export class LevelBands {
|
|
27
|
+
/** @internal The search state and its buffers. */
|
|
28
|
+
search = new LevelSearch_();
|
|
29
|
+
bandCount_ = 0;
|
|
30
|
+
offsets_ = new Uint32Array(2);
|
|
31
|
+
starts_ = new Float64Array(8);
|
|
32
|
+
ends_ = new Float64Array(8);
|
|
33
|
+
earliestStarts_ = new Float64Array(8);
|
|
34
|
+
latestStarts_ = new Float64Array(8);
|
|
35
|
+
earliestEnds_ = new Float64Array(8);
|
|
36
|
+
latestEnds_ = new Float64Array(8);
|
|
37
|
+
unresolvedOffsets_ = new Uint32Array(2);
|
|
38
|
+
unresolvedStarts_ = new Float64Array(8);
|
|
39
|
+
unresolvedEnds_ = new Float64Array(8);
|
|
40
|
+
// The band edges, low then high per band, and the level index of each.
|
|
41
|
+
edges_ = new Float64Array(2);
|
|
42
|
+
edgeLevels_ = new Int32Array(2);
|
|
43
|
+
// The current band's candidate unresolved intervals, before sorting.
|
|
44
|
+
pendingStarts_ = new Float64Array(8);
|
|
45
|
+
pendingEnds_ = new Float64Array(8);
|
|
46
|
+
pendingCount_ = 0;
|
|
47
|
+
/** How many bands were searched. */
|
|
48
|
+
get bandCount() {
|
|
49
|
+
return this.bandCount_;
|
|
50
|
+
}
|
|
51
|
+
/** `bandCount + 1` entries: band `k`'s intervals start at `offsets[k]`. */
|
|
52
|
+
get offsets() {
|
|
53
|
+
return this.offsets_;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Starts of the half-open intervals `[start, end)` where `low ≤ f < high`,
|
|
57
|
+
* ascending within a band, disjoint and non-empty, inside `[lower, upper)`:
|
|
58
|
+
* `lower`, or the time of the crossing that enters the band.
|
|
59
|
+
*/
|
|
60
|
+
get starts() {
|
|
61
|
+
return this.starts_;
|
|
62
|
+
}
|
|
63
|
+
/** Ends of the intervals: the time of the crossing that leaves, or `upper`. */
|
|
64
|
+
get ends() {
|
|
65
|
+
return this.ends_;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Per interval, the enclosure of its start, as `findLevelCrossings` reports
|
|
69
|
+
* it for the crossing that enters the band: `f` is certified out of the band
|
|
70
|
+
* just before `earliestStarts` and in it just after `latestStarts`. Both are
|
|
71
|
+
* `lower` for an interval that starts there.
|
|
72
|
+
*/
|
|
73
|
+
get earliestStarts() {
|
|
74
|
+
return this.earliestStarts_;
|
|
75
|
+
}
|
|
76
|
+
/** Per interval, the end of its start's enclosure. */
|
|
77
|
+
get latestStarts() {
|
|
78
|
+
return this.latestStarts_;
|
|
79
|
+
}
|
|
80
|
+
/** Per interval, the start of its end's enclosure; `upper` at `upper`. */
|
|
81
|
+
get earliestEnds() {
|
|
82
|
+
return this.earliestEnds_;
|
|
83
|
+
}
|
|
84
|
+
/** Per interval, the end of its end's enclosure. */
|
|
85
|
+
get latestEnds() {
|
|
86
|
+
return this.latestEnds_;
|
|
87
|
+
}
|
|
88
|
+
/** `bandCount + 1` entries: band `k`'s unresolved intervals start here. */
|
|
89
|
+
get unresolvedOffsets() {
|
|
90
|
+
return this.unresolvedOffsets_;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Starts of the closed intervals where membership could not be decided,
|
|
94
|
+
* ascending and disjoint: the unresolved intervals of the band's two edges,
|
|
95
|
+
* and the enclosures of any visit too brief for a half-open interval, merged.
|
|
96
|
+
* Membership is certified everywhere else, outside the intervals' end
|
|
97
|
+
* enclosures.
|
|
98
|
+
*/
|
|
99
|
+
get unresolvedStarts() {
|
|
100
|
+
return this.unresolvedStarts_;
|
|
101
|
+
}
|
|
102
|
+
/** Ends of the closed unresolved intervals. */
|
|
103
|
+
get unresolvedEnds() {
|
|
104
|
+
return this.unresolvedEnds_;
|
|
105
|
+
}
|
|
106
|
+
/** How many times the last search called `f`, over all bands together. */
|
|
107
|
+
get evaluations() {
|
|
108
|
+
return this.search.evaluations;
|
|
109
|
+
}
|
|
110
|
+
/** @internal Searches the interval already set on {@link search}. */
|
|
111
|
+
fill(f, bands, options) {
|
|
112
|
+
const bandCount = bands.length;
|
|
113
|
+
const edgeCount = 2 * bandCount;
|
|
114
|
+
if (this.edges_.length < edgeCount) {
|
|
115
|
+
this.edges_ = new Float64Array(edgeCount);
|
|
116
|
+
this.edgeLevels_ = new Int32Array(edgeCount);
|
|
117
|
+
}
|
|
118
|
+
const edges = this.edges_;
|
|
119
|
+
for (let band = 0; band < bandCount; band++) {
|
|
120
|
+
const pair = bands[band];
|
|
121
|
+
const low = pair[0];
|
|
122
|
+
const high = pair[1];
|
|
123
|
+
if (Number.isNaN(low) || Number.isNaN(high) || low > high) {
|
|
124
|
+
throw new RangeError(`findLevelBands: band ${band} must have low ≤ high, got [${describeValue(low)}, ${describeValue(high)}]`);
|
|
125
|
+
}
|
|
126
|
+
edges[2 * band] = low;
|
|
127
|
+
edges[2 * band + 1] = high;
|
|
128
|
+
}
|
|
129
|
+
const { search } = this;
|
|
130
|
+
search.setLevels(edges, edgeCount, this.edgeLevels_);
|
|
131
|
+
if (this.offsets_.length < bandCount + 1) {
|
|
132
|
+
this.offsets_ = new Uint32Array(bandCount + 1);
|
|
133
|
+
this.unresolvedOffsets_ = new Uint32Array(bandCount + 1);
|
|
134
|
+
}
|
|
135
|
+
this.bandCount_ = 0;
|
|
136
|
+
search.run("findLevelBands", f, options);
|
|
137
|
+
let intervalCount = 0;
|
|
138
|
+
let unresolvedCount = 0;
|
|
139
|
+
for (let band = 0; band < bandCount; band++) {
|
|
140
|
+
this.offsets_[band] = intervalCount;
|
|
141
|
+
this.unresolvedOffsets_[band] = unresolvedCount;
|
|
142
|
+
const lowLevel = this.edgeLevels_[2 * band];
|
|
143
|
+
const highLevel = this.edgeLevels_[2 * band + 1];
|
|
144
|
+
// A band with low === high holds no value: nothing in it, or in doubt.
|
|
145
|
+
if (lowLevel === highLevel) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
this.pendingCount_ = 0;
|
|
149
|
+
intervalCount = this.writeIntervals_(intervalCount, lowLevel, highLevel);
|
|
150
|
+
unresolvedCount = this.writeUnresolved_(unresolvedCount, lowLevel, highLevel);
|
|
151
|
+
}
|
|
152
|
+
this.offsets_[bandCount] = intervalCount;
|
|
153
|
+
this.unresolvedOffsets_[bandCount] = unresolvedCount;
|
|
154
|
+
this.bandCount_ = bandCount;
|
|
155
|
+
}
|
|
156
|
+
isAboveAtStart_(level) {
|
|
157
|
+
if (level === LEVEL_BELOW_ALL_) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
if (level === LEVEL_ABOVE_ALL_) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
return this.search.startSides[level] === 1;
|
|
164
|
+
}
|
|
165
|
+
writeIntervals_(count, lowLevel, highLevel) {
|
|
166
|
+
const { search } = this;
|
|
167
|
+
let aboveLow = this.isAboveAtStart_(lowLevel);
|
|
168
|
+
let aboveHigh = this.isAboveAtStart_(highLevel);
|
|
169
|
+
let inside = aboveLow && !aboveHigh;
|
|
170
|
+
// The crossing that entered the band, or -1 for lower.
|
|
171
|
+
let entry = -1;
|
|
172
|
+
let written = count;
|
|
173
|
+
for (let index = 0; index < search.crossingCount; index++) {
|
|
174
|
+
const level = search.crossingLevels[index];
|
|
175
|
+
if (level === lowLevel) {
|
|
176
|
+
aboveLow = search.crossingDirections[index] === 1;
|
|
177
|
+
}
|
|
178
|
+
else if (level === highLevel) {
|
|
179
|
+
aboveHigh = search.crossingDirections[index] === 1;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const nowInside = aboveLow && !aboveHigh;
|
|
185
|
+
if (nowInside && !inside) {
|
|
186
|
+
entry = index;
|
|
187
|
+
}
|
|
188
|
+
else if (!nowInside && inside) {
|
|
189
|
+
written = this.appendInterval_(written, entry, index);
|
|
190
|
+
}
|
|
191
|
+
inside = nowInside;
|
|
192
|
+
}
|
|
193
|
+
if (inside) {
|
|
194
|
+
written = this.appendInterval_(written, entry, -1);
|
|
195
|
+
}
|
|
196
|
+
return written;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Appends the interval from crossing `entry` to crossing `exit`, `-1`
|
|
200
|
+
* standing for the interval's ends.
|
|
201
|
+
*/
|
|
202
|
+
appendInterval_(count, entry, exit) {
|
|
203
|
+
const { search } = this;
|
|
204
|
+
const lower = search.intervalLower;
|
|
205
|
+
const upper = search.intervalUpper;
|
|
206
|
+
const start = entry < 0 ? lower : search.crossingTimes[entry];
|
|
207
|
+
const end = exit < 0 ? upper : search.crossingTimes[exit];
|
|
208
|
+
const earliestStart = entry < 0 ? lower : search.crossingEarliest[entry];
|
|
209
|
+
const latestEnd = exit < 0 ? upper : search.crossingLatest[exit];
|
|
210
|
+
if (!(start < end)) {
|
|
211
|
+
// A visit too brief for a half-open interval, such as a level reached
|
|
212
|
+
// exactly at one point: in doubt over its enclosures.
|
|
213
|
+
if (entry >= 0 || exit >= 0) {
|
|
214
|
+
const pending = this.reservePending_();
|
|
215
|
+
this.pendingStarts_[pending] = earliestStart;
|
|
216
|
+
this.pendingEnds_[pending] = latestEnd;
|
|
217
|
+
}
|
|
218
|
+
return count;
|
|
219
|
+
}
|
|
220
|
+
if (count === this.starts_.length) {
|
|
221
|
+
this.starts_ = grownFloat64_(this.starts_, count + 1);
|
|
222
|
+
this.ends_ = grownFloat64_(this.ends_, count + 1);
|
|
223
|
+
this.earliestStarts_ = grownFloat64_(this.earliestStarts_, count + 1);
|
|
224
|
+
this.latestStarts_ = grownFloat64_(this.latestStarts_, count + 1);
|
|
225
|
+
this.earliestEnds_ = grownFloat64_(this.earliestEnds_, count + 1);
|
|
226
|
+
this.latestEnds_ = grownFloat64_(this.latestEnds_, count + 1);
|
|
227
|
+
}
|
|
228
|
+
this.starts_[count] = start;
|
|
229
|
+
this.ends_[count] = end;
|
|
230
|
+
this.earliestStarts_[count] = earliestStart;
|
|
231
|
+
this.latestStarts_[count] =
|
|
232
|
+
entry < 0 ? lower : search.crossingLatest[entry];
|
|
233
|
+
this.earliestEnds_[count] =
|
|
234
|
+
exit < 0 ? upper : search.crossingEarliest[exit];
|
|
235
|
+
this.latestEnds_[count] = latestEnd;
|
|
236
|
+
return count + 1;
|
|
237
|
+
}
|
|
238
|
+
/** Makes room for one more pending interval and returns its index. */
|
|
239
|
+
reservePending_() {
|
|
240
|
+
const count = this.pendingCount_;
|
|
241
|
+
if (count === this.pendingStarts_.length) {
|
|
242
|
+
this.pendingStarts_ = grownFloat64_(this.pendingStarts_, count + 1);
|
|
243
|
+
this.pendingEnds_ = grownFloat64_(this.pendingEnds_, count + 1);
|
|
244
|
+
}
|
|
245
|
+
this.pendingCount_ = count + 1;
|
|
246
|
+
return count;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Writes the band's unresolved intervals: its edges' and its too-brief
|
|
250
|
+
* visits', each source sorted, sorted together by insertion and merged where
|
|
251
|
+
* they overlap.
|
|
252
|
+
*/
|
|
253
|
+
writeUnresolved_(count, lowLevel, highLevel) {
|
|
254
|
+
const { search } = this;
|
|
255
|
+
for (let index = 0; index < search.unresolvedCount; index++) {
|
|
256
|
+
const level = search.unresolvedLevels[index];
|
|
257
|
+
if (level === lowLevel || level === highLevel) {
|
|
258
|
+
const pending = this.reservePending_();
|
|
259
|
+
this.pendingStarts_[pending] = search.unresolvedStarts[index];
|
|
260
|
+
this.pendingEnds_[pending] = search.unresolvedEnds[index];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const starts = this.pendingStarts_;
|
|
264
|
+
const ends = this.pendingEnds_;
|
|
265
|
+
const pending = this.pendingCount_;
|
|
266
|
+
for (let index = 1; index < pending; index++) {
|
|
267
|
+
const start = starts[index];
|
|
268
|
+
const end = ends[index];
|
|
269
|
+
let target = index;
|
|
270
|
+
while (target > 0 && starts[target - 1] > start) {
|
|
271
|
+
starts[target] = starts[target - 1];
|
|
272
|
+
ends[target] = ends[target - 1];
|
|
273
|
+
target--;
|
|
274
|
+
}
|
|
275
|
+
starts[target] = start;
|
|
276
|
+
ends[target] = end;
|
|
277
|
+
}
|
|
278
|
+
let written = count;
|
|
279
|
+
let index = 0;
|
|
280
|
+
while (index < pending) {
|
|
281
|
+
const start = starts[index];
|
|
282
|
+
let end = ends[index];
|
|
283
|
+
index++;
|
|
284
|
+
while (index < pending && starts[index] <= end) {
|
|
285
|
+
end = Math.max(end, ends[index]);
|
|
286
|
+
index++;
|
|
287
|
+
}
|
|
288
|
+
if (written === this.unresolvedStarts_.length) {
|
|
289
|
+
this.unresolvedStarts_ = grownFloat64_(this.unresolvedStarts_, written + 1);
|
|
290
|
+
this.unresolvedEnds_ = grownFloat64_(this.unresolvedEnds_, written + 1);
|
|
291
|
+
}
|
|
292
|
+
this.unresolvedStarts_[written] = start;
|
|
293
|
+
this.unresolvedEnds_[written] = end;
|
|
294
|
+
written++;
|
|
295
|
+
}
|
|
296
|
+
return written;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* For each band `[low, high)`, the stretches of `[lower, upper)` where `low ≤ f
|
|
301
|
+
* < high`, **certified** like {@link findLevelCrossings}: given a true bound on
|
|
302
|
+
* `|f′|`, membership is exact outside the reported unresolved intervals and the
|
|
303
|
+
* enclosures of the intervals' ends.
|
|
304
|
+
*
|
|
305
|
+
* Every distinct finite band edge is a level, and all of them are searched in
|
|
306
|
+
* one subdivision, so `f` is evaluated once per point whatever the number of
|
|
307
|
+
* bands; edges shared by neighbouring bands, such as a golden hour's lower edge
|
|
308
|
+
* and a blue hour's upper one, are searched once. An edge may be `±∞` for an
|
|
309
|
+
* open band, and a band with `low === high` is empty. The intervals of a band
|
|
310
|
+
* follow from the crossings of its two edges; since the crossings of one
|
|
311
|
+
* subdivision step are ordered as `f` passes the levels, the edges can never be
|
|
312
|
+
* reported out of order (above `high` while below `low`).
|
|
313
|
+
*
|
|
314
|
+
* The guarantee, the behaviour under a violated `maxRate`, the termination
|
|
315
|
+
* bound and the allocation behaviour are {@link findLevelCrossings}'s, with
|
|
316
|
+
* `(upper − lower) / resolution` bounding the subdivision for all levels
|
|
317
|
+
* together.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* // Golden hour [−4°, 6°) and blue hour [−6°, −4°) of a solar altitude in
|
|
322
|
+
* // degrees over epoch milliseconds.
|
|
323
|
+
* const light = findLevelBands(altitude, start, end, [[-4, 6], [-6, -4]], {
|
|
324
|
+
* maxRate: 400 / 86_400_000,
|
|
325
|
+
* resolution: 60_000,
|
|
326
|
+
* integer: true,
|
|
327
|
+
* });
|
|
328
|
+
* ```;
|
|
329
|
+
*
|
|
330
|
+
* @param f The function, finite wherever it is called.
|
|
331
|
+
* @param lower Start of the interval, finite.
|
|
332
|
+
* @param upper End of the interval, finite and `≥ lower`; intervals end at it
|
|
333
|
+
* at the latest.
|
|
334
|
+
* @param bands The bands, as `[low, high]` pairs with `low ≤ high`.
|
|
335
|
+
* @param options The rate bound and how finely to search; see
|
|
336
|
+
* {@link LevelSearchOptions}.
|
|
337
|
+
* @param out A result to overwrite instead of allocating one; it must not be in
|
|
338
|
+
* use by an enclosing search (from inside `f`).
|
|
339
|
+
* @returns `out`, or a new {@link LevelBands}. Unspecified after a throw.
|
|
340
|
+
* @throws {RangeError} For a band edge that is `NaN` or `low > high`, and for
|
|
341
|
+
* everything {@link findLevelCrossings} rejects.
|
|
342
|
+
* @throws Whatever `budget.spend` throws, and the signal's reason once aborted.
|
|
343
|
+
*/
|
|
344
|
+
export function findLevelBands(f, lower, upper, bands, options, out = new LevelBands()) {
|
|
345
|
+
const { search } = out;
|
|
346
|
+
search.intervalLower = lower;
|
|
347
|
+
search.intervalUpper = upper;
|
|
348
|
+
out.fill(f, bands, options);
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=find-level-bands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-level-bands.js","sourceRoot":"","sources":["../../src/roots/find-level-bands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,aAAa,EAAE,MAAM,cA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