@danielsimonjr/mathts-functions 0.43.3 → 0.45.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1011 -190
- package/dist/numeric/control-equations.d.ts +18 -6
- package/dist/numeric/control-equations.d.ts.map +1 -1
- package/dist/numeric/solveODE.d.ts +32 -0
- package/dist/numeric/solveODE.d.ts.map +1 -1
- package/dist/signal/fir-smoothing.d.ts +12 -8
- package/dist/signal/fir-smoothing.d.ts.map +1 -1
- package/dist/signal/iir-design.d.ts +15 -6
- package/dist/signal/iir-design.d.ts.map +1 -1
- package/dist/signal/remez-exchange.d.ts +28 -0
- package/dist/signal/remez-exchange.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -11,15 +11,27 @@
|
|
|
11
11
|
* - {@link care} — continuous algebraic Riccati equation
|
|
12
12
|
* `AᵀX + XA − X B R⁻¹ Bᵀ X + Q = 0`, solved via the **matrix sign
|
|
13
13
|
* function** applied to the Hamiltonian `H = [[A, −BR⁻¹Bᵀ], [−Q, −Aᵀ]]`.
|
|
14
|
-
* This
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* stabilizing initial gain that a Kleinman/Newton iteration would
|
|
18
|
-
* require (the natural starting point `X₀ = 0` is not stabilizing for
|
|
19
|
-
* e.g. the classic double-integrator `A = [[0,1],[0,0]]`, which is only
|
|
14
|
+
* This needs no stabilizing initial gain that a Kleinman/Newton iteration
|
|
15
|
+
* would require (the natural starting point `X₀ = 0` is not stabilizing
|
|
16
|
+
* for e.g. the classic double-integrator `A = [[0,1],[0,0]]`, which is only
|
|
20
17
|
* marginally stable). The sign-function Newton iteration converges
|
|
21
18
|
* unconditionally (given the standard stabilizability/detectability
|
|
22
19
|
* assumptions) directly from `H` itself.
|
|
20
|
+
*
|
|
21
|
+
* The classical alternative is the **Hamiltonian-eigenvector** construction
|
|
22
|
+
* (eigendecompose `H`, take the stable invariant subspace `U=[U₁;U₂]`,
|
|
23
|
+
* `X = U₂U₁⁻¹`). Since `matrix`'s `eig` gained complex eigenvectors
|
|
24
|
+
* (`vectorsIm`, 2026-07-16) that path IS now implementable — but it was
|
|
25
|
+
* prototyped and **measured against the sign function** (2026-07-18) and
|
|
26
|
+
* found strictly **less** accurate on every corpus case, with the gap
|
|
27
|
+
* widening on ill-conditioned Hamiltonians (near-uncontrollable /
|
|
28
|
+
* lightly-damped: Riccati residual ~1e-10..1e-13 for the eigenvector path
|
|
29
|
+
* vs ~1e-13..1e-14 for the sign function). Eigenvector-basis subspace
|
|
30
|
+
* extraction is the numerically inferior classical method (ill-conditioned
|
|
31
|
+
* eigenvectors near defectiveness), which is why LAPACK/scipy use ordered
|
|
32
|
+
* Schur, not eigenvectors. The self-contained sign-function method is
|
|
33
|
+
* therefore retained. (`funm`/`cosm`/`sinm` likewise use eigen*values*,
|
|
34
|
+
* not eigenvectors — see `matrix-functions.ts`.)
|
|
23
35
|
* - {@link dare} — discrete algebraic Riccati equation
|
|
24
36
|
* `AᵀXA − X − AᵀXB(R + BᵀXB)⁻¹BᵀXA + Q = 0`, solved via the
|
|
25
37
|
* **structure-preserving doubling algorithm** (SDA), the discrete-time
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-equations.d.ts","sourceRoot":"","sources":["../../src/numeric/control-equations.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"control-equations.d.ts","sourceRoot":"","sources":["../../src/numeric/control-equations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAuJH;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAgB9D;AASD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CA6C3F;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CA+B3F"}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
import type { MathNumericType, MathArray, Unit } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* An event function `g(t, y)` whose zero crossings `solveODE` locates. May carry scipy-style
|
|
4
|
+
* `terminal`/`direction` attributes directly on the function object.
|
|
5
|
+
*
|
|
6
|
+
* - `terminal`: `true` (stop at the first crossing), a positive integer (stop after that many
|
|
7
|
+
* crossings), or omitted/`false` (record every crossing, never stop).
|
|
8
|
+
* - `direction`: `+1` (trigger only on `−`→`+` crossings), `−1` (only `+`→`−`), or `0`/omitted
|
|
9
|
+
* (either direction).
|
|
10
|
+
*
|
|
11
|
+
* The state `y` is passed in the same shape the forcing function receives it (a `number[]` — a
|
|
12
|
+
* length-1 array for a scalar ODE).
|
|
13
|
+
*/
|
|
14
|
+
interface EventFunction {
|
|
15
|
+
(t: number, y: number[]): number;
|
|
16
|
+
terminal?: boolean | number;
|
|
17
|
+
direction?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Object form of an ODE event: the function plus its `terminal`/`direction` attributes. */
|
|
20
|
+
interface EventSpec {
|
|
21
|
+
event: (t: number, y: number[]) => number;
|
|
22
|
+
terminal?: boolean | number;
|
|
23
|
+
direction?: number;
|
|
24
|
+
}
|
|
25
|
+
/** One event, or an array of events, accepted by the `events` option. */
|
|
26
|
+
type ODEEvents = EventFunction | EventSpec | Array<EventFunction | EventSpec>;
|
|
2
27
|
/**
|
|
3
28
|
* Options for ODE solver
|
|
4
29
|
*/
|
|
@@ -17,6 +42,13 @@ interface ODEOptions {
|
|
|
17
42
|
* (n = state dimension). Ignored by the explicit RK23/RK45 methods.
|
|
18
43
|
*/
|
|
19
44
|
jac?: (t: number, y: number[]) => number[][];
|
|
45
|
+
/**
|
|
46
|
+
* Event detection (scipy `solve_ivp`-style). One event function `g(t, y)` or an array of them;
|
|
47
|
+
* `solveODE` locates each zero crossing between accepted steps and reports it in `tEvents`/
|
|
48
|
+
* `yEvents`. A `terminal` event stops the integration at its crossing; `direction` filters the
|
|
49
|
+
* crossing sign. Requires plain-number state (throws otherwise). See {@link EventFunction}.
|
|
50
|
+
*/
|
|
51
|
+
events?: ODEEvents;
|
|
20
52
|
}
|
|
21
53
|
/**
|
|
22
54
|
* Forcing function type for ODE
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solveODE.d.ts","sourceRoot":"","sources":["../../src/numeric/solveODE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solveODE.d.ts","sourceRoot":"","sources":["../../src/numeric/solveODE.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAU,IAAI,EAAa,MAAM,aAAa,CAAC;AAkCvF;;;;;;;;;;;GAWG;AACH,UAAU,aAAa;IACrB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4FAA4F;AAC5F,UAAU,SAAS;IACjB,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC;IAC1C,QAAQ,CAAC,EAAE,OA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ChB,KAAK,EAAE,OAAO,EAAE,EAChB,OAAO,GAAE,UAAe,GACvB;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAiHhC;AAED,eAAO,MAAM,cAAc,yDAyrB1B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type RemezType } from './remez-exchange.js';
|
|
1
2
|
type Vec = readonly number[] | Float64Array;
|
|
2
3
|
/** Polynomial/deconvolution division result: `signal = conv(divisor, quotient) + remainder`. */
|
|
3
4
|
export interface DeconvolveResult {
|
|
@@ -49,14 +50,17 @@ export declare function wiener(x: Vec, mysize?: number): number[];
|
|
|
49
50
|
*/
|
|
50
51
|
export declare function firls(numtaps: number, bands: readonly number[], desired: readonly number[]): number[];
|
|
51
52
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* with
|
|
57
|
-
*
|
|
58
|
-
*
|
|
53
|
+
* Optimal equiripple FIR design (`scipy.signal.remez`) via the exact
|
|
54
|
+
* Parks-McClellan / Remez exchange algorithm (delegates to `remezExchange`).
|
|
55
|
+
*
|
|
56
|
+
* **Convention note:** unlike `firls` above (which follows `scipy.signal.firls`
|
|
57
|
+
* with `1 = Nyquist` and one `desired` value per band *edge*), `remez` follows
|
|
58
|
+
* `scipy.signal.remez` exactly: band edges are normalized to `[0, 0.5]`
|
|
59
|
+
* (`fs = 1`, `0.5 = Nyquist`), and `desired`/`weight` carry one value per band
|
|
60
|
+
* (length `bands.length / 2`). `type` is `'bandpass'` (symmetric, the default),
|
|
61
|
+
* `'differentiator'`, or `'hilbert'` (antisymmetric). Coefficients match
|
|
62
|
+
* `scipy.signal.remez` to machine precision.
|
|
59
63
|
*/
|
|
60
|
-
export declare function remez(numtaps: number, bands: readonly number[], desired: readonly number[]): number[];
|
|
64
|
+
export declare function remez(numtaps: number, bands: readonly number[], desired: readonly number[], weight?: readonly number[], type?: RemezType): number[];
|
|
61
65
|
export {};
|
|
62
66
|
//# sourceMappingURL=fir-smoothing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fir-smoothing.d.ts","sourceRoot":"","sources":["../../src/signal/fir-smoothing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fir-smoothing.d.ts","sourceRoot":"","sources":["../../src/signal/fir-smoothing.ts"],"names":[],"mappings":"AASA,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEpE,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAG5C,gGAAgG;AAChG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAsCD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAa5F;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CA4BhF;AAID;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,gBAAgB,CAiBtE;AAID;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,SAAI,GAAG,MAAM,EAAE,CAsBnD;AA8GD;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,MAAM,EAAE,CAUV;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,EAC1B,IAAI,GAAE,SAAsB,GAC3B,MAAM,EAAE,CAEV"}
|
|
@@ -63,17 +63,26 @@ export declare function bilinear(bIn: Vec, aIn: Vec, fs: number): {
|
|
|
63
63
|
a: number[];
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
|
-
* Minimum Butterworth filter order
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* Nyquist (0..1); `gpass`/`gstop` are in dB.
|
|
70
|
-
* `
|
|
71
|
-
*
|
|
66
|
+
* Minimum Butterworth filter order and the corresponding natural frequency
|
|
67
|
+
* `Wn` (the "3 dB" frequency) meeting a passband/stopband spec, for a digital
|
|
68
|
+
* lowpass, highpass, bandpass, or bandstop filter. Frequencies are normalized
|
|
69
|
+
* to Nyquist (`0..1`); `gpass`/`gstop` are in dB. For lowpass/highpass, `wp`
|
|
70
|
+
* and `ws` are scalars and `Wn` is a scalar; for bandpass/bandstop, `wp` and
|
|
71
|
+
* `ws` are `[low, high]` pairs and `Wn` is the `[low, high]` natural-frequency
|
|
72
|
+
* array. Matches `scipy.signal.buttord(wp, ws, gpass, gstop)`.
|
|
73
|
+
*
|
|
74
|
+
* Filter type follows scipy: scalar `wp < ws` → lowpass, `wp > ws` → highpass;
|
|
75
|
+
* array with `wp[0] > ws[0]` (passband inside stopband) → bandpass, `wp[0] <
|
|
76
|
+
* ws[0]` (stopband inside passband) → bandstop.
|
|
72
77
|
*/
|
|
73
78
|
export declare function buttord(wp: number, ws: number, gpass: number, gstop: number): {
|
|
74
79
|
N: number;
|
|
75
80
|
Wn: number;
|
|
76
81
|
};
|
|
82
|
+
export declare function buttord(wp: readonly [number, number], ws: readonly [number, number], gpass: number, gstop: number): {
|
|
83
|
+
N: number;
|
|
84
|
+
Wn: [number, number];
|
|
85
|
+
};
|
|
77
86
|
type ZpkRoot = number | Complex;
|
|
78
87
|
/**
|
|
79
88
|
* Group zeros/poles/gain into cascaded second-order sections:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iir-design.d.ts","sourceRoot":"","sources":["../../src/signal/iir-design.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAOL,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AAKnC,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAoB5C;;;;GAIG;AACH,wBAAgB,MAAM,CACpB,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAC9B,KAAK,GAAE,WAAmB,GACzB;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAI9B;AAgCD;;;;;GAKG;AACH,wBAAgB,MAAM,CACpB,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAC9B,KAAK,GAAE,WAAmB,GACzB;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAI9B;AAkJD;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CACnB,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAC9B,KAAK,GAAE,WAAmB,GACzB;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAK9B;AA4BD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GA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AAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CA8BrF;AAyHD;;;;;;;;;;;;GAYG;AACH,wBAAgB,OAAO,CACrB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7B,wBAAgB,OAAO,CACrB,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAkFvC,KAAK,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAoDhC;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,SAAS,OAAO,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAmB3F;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,EAAE,CAS7E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact Parks-McClellan (Remez exchange) optimal equiripple FIR design.
|
|
3
|
+
*
|
|
4
|
+
* This is a faithful TypeScript port of the classic McClellan-Parks-Rabiner
|
|
5
|
+
* FORTRAN program (via Erik Kvaleberg's `remez.c`), the same code SciPy wraps
|
|
6
|
+
* in `scipy.signal.remez` (`_sigtoolsmodule.cc`: `pre_remez` + `remez`). It
|
|
7
|
+
* replaces the earlier Lawson-IRLS approximation. Conventions match SciPy
|
|
8
|
+
* exactly: band edges are normalized to `[0, 0.5]` (`fs = 1`, `0.5 = Nyquist`),
|
|
9
|
+
* `desired`/`weight` carry one value per band (length `bands.length / 2`), and
|
|
10
|
+
* `type` is `'bandpass'` (symmetric), `'differentiator'`, or `'hilbert'`
|
|
11
|
+
* (antisymmetric). Coefficients are pinned against `scipy.signal.remez` in
|
|
12
|
+
* `functions/tests/remez-pm.test.ts`.
|
|
13
|
+
*
|
|
14
|
+
* The port preserves the original's 1-based array indexing and control flow
|
|
15
|
+
* (the extremal-search `goto` block is expressed as a small state machine) so
|
|
16
|
+
* that it reproduces SciPy's discrete-grid extremal selection bit-for-bit.
|
|
17
|
+
*/
|
|
18
|
+
export type RemezType = 'bandpass' | 'differentiator' | 'hilbert';
|
|
19
|
+
/**
|
|
20
|
+
* Optimal equiripple FIR design (`scipy.signal.remez`) via the exact
|
|
21
|
+
* Parks-McClellan / Remez exchange algorithm. `bands` is a flat list of band
|
|
22
|
+
* edges normalized to `[0, 0.5]` (`fs = 1`, `0.5 = Nyquist`); `desired` and
|
|
23
|
+
* `weight` carry one value per band (`bands.length / 2` entries). `type`
|
|
24
|
+
* selects the linear-phase family (`'bandpass'` symmetric; `'differentiator'`
|
|
25
|
+
* and `'hilbert'` antisymmetric). Returns `numtaps` FIR coefficients.
|
|
26
|
+
*/
|
|
27
|
+
export declare function remezExchange(numtaps: number, bands: readonly number[], desired: readonly number[], weight?: readonly number[], type?: RemezType, maxiter?: number, gridDensity?: number): number[];
|
|
28
|
+
//# sourceMappingURL=remez-exchange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remez-exchange.d.ts","sourceRoot":"","sources":["../../src/signal/remez-exchange.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAgelE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,EAC1B,IAAI,GAAE,SAAsB,EAC5B,OAAO,SAAK,EACZ,WAAW,SAAK,GACf,MAAM,EAAE,CA4IV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-functions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@danielsimonjr/mathts-core": "^0.13.0",
|
|
38
38
|
"@danielsimonjr/mathts-expression": "^0.6.7",
|
|
39
39
|
"@danielsimonjr/mathts-gpu": "^0.2.0",
|
|
40
|
-
"@danielsimonjr/mathts-matrix": "^0.
|
|
40
|
+
"@danielsimonjr/mathts-matrix": "^0.7.0",
|
|
41
41
|
"@danielsimonjr/mathts-parallel": "^0.6.3",
|
|
42
42
|
"bignumber.js": "^9.1.2",
|
|
43
43
|
"complex.js": "^2.2.5",
|