/ concept-collection / barycentric-rational
Sign in
concept-collection / barycentric-rational
barycentric-rational / src / engine / types.ts
101 lines · 2.3 KBBlameHistoryRaw
1// The contract between the app and the MATLAB layer: what goes into
2// params.json and what comes back in out.json. See src/matlab/driver.m.
4export type FuncName = 'runge' | 'sine' | 'abs' | 'custom'
5export type NodeKind = 'uniform' | 'chebyshev' | 'random' | 'paired' | 'graded'
7/** NaN and +-Inf both cross the JSON boundary as null. */
8export type Num = number | null
10export interface Want {
11 poly: boolean
12 spline: boolean
13 blend: boolean
14 poles: boolean
15 classical: boolean
18interface CommonParams {
19 f: FuncName
20 fexpr: string
21 a: number
22 b: number
23 nodes: NodeKind
24 seed: number
25 ngrid: number
26 want: Want
29export interface ExploreParams extends CommonParams {
30 mode: 'explore'
31 n: number
32 d: number
33 ngridwide: number
34 rootsMaxN: number
37export interface ConvergeParams extends CommonParams {
38 mode: 'converge'
39 ns: number[]
40 ds: number[]
43export type Params = ExploreParams | ConvergeParams
45export interface PolesOut {
46 /** the wide grid, running past both ends of [a, b] */
47 t: number[]
48 /** signed n-th root of the denominator, so that the sign and the zeros survive */
49 u: Num[]
50 /** real zeros of the denominator, located from sign changes: the poles of r */
51 realPoles: number[]
52 rootsRe: number[]
53 rootsIm: number[]
54 rootsShown: boolean
55 classical?: Num[]
56 classicalPoles?: number[]
59export interface ExploreOut {
60 n: number
61 d: number
62 x: number[]
63 y: number[]
64 t: number[]
65 ft: number[]
66 r: Num[]
67 err: Num[]
68 maxerr: Num
69 w: number[]
70 /** |w_k| divided by the smallest of them: the integers of Section 4 on a uniform mesh */
71 wscaled: number[]
72 wsign: number[]
73 wIsInteger: boolean
74 wAlternates: boolean
75 rpoly?: Num[]
76 rspline?: Num[]
77 hasBlend?: boolean
78 blendError?: string
79 /** P[i] is the local polynomial p_i on the grid, L[i] its normalised blending function */
80 P?: Num[][]
81 L?: Num[][]
82 /** the window [wlo[i], whi[i]] = [x_i, x_{i+d}] that p_i interpolates on */
83 wlo?: number[]
84 whi?: number[]
85 poles?: PolesOut
88export interface ConvergeOut {
89 ns: number[]
90 ds: number[]
91 /** E[i][j] is the max error for d = ds[i] at n = ns[j] */
92 E: Num[][]
93 orders: Num[][]
94 splineErr?: Num[]
95 splineOrders?: Num[]
96 polyErr?: Num[]
99export type RunResult<T> =
100 | { ok: true; data: T; output: string; ms: number }
101 | { ok: false; error: string; output: string; ms: number }
moveopenescclose