@danielsimonjr/mathts-functions 0.33.0 → 0.34.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.
@@ -1,4 +1,12 @@
1
+ /**
2
+ * Digital filter design + application (Wave D / remaining). FIR window design
3
+ * (`firwin`), IIR Butterworth design (`butter`), the direct-form filter (`lfilter`),
4
+ * and zero-phase filtering (`filtfilt`). Matches `scipy.signal`. `butter` reuses the
5
+ * core `Complex` type for the analog-pole bilinear-transform pipeline.
6
+ */
7
+ import { Complex } from '@danielsimonjr/mathts-core';
1
8
  type Vec = readonly number[] | Float64Array;
9
+ export declare const sinc: (x: number) => number;
2
10
  /**
3
11
  * FIR lowpass filter coefficients by the windowed-sinc method (Hamming window,
4
12
  * normalized to unit DC gain) — `scipy.signal.firwin(numtaps, cutoff)` with the
@@ -22,12 +30,43 @@ export declare function lfilterZi(b: Vec, a: Vec): number[];
22
30
  * magnitude response is applied with no phase distortion.
23
31
  */
24
32
  export declare function filtfilt(b: Vec, a: Vec, x: Vec): number[];
33
+ export declare const cAdd: (p: Complex, q: Complex) => Complex;
34
+ export declare const cSub: (p: Complex, q: Complex) => Complex;
35
+ export declare const cMul: (p: Complex, q: Complex) => Complex;
36
+ export declare const cDiv: (p: Complex, q: Complex) => Complex;
37
+ /** Scale a Complex by a real number (`Complex.mul` only accepts `Scalar`, not `number`). */
38
+ export declare const cScale: (p: Complex, s: number) => Complex;
39
+ /** Real polynomial coefficients (highest degree first) of ∏(x − rₖ). */
40
+ export declare function polyFromRoots(roots: Complex[]): number[];
41
+ /** Analog lowpass prototype: zeros, poles, gain (cutoff normalized to 1 rad/s). */
42
+ export interface AnalogProto {
43
+ z: Complex[];
44
+ p: Complex[];
45
+ k: number;
46
+ }
47
+ export type FilterBtype = 'low' | 'high' | 'bandpass' | 'bandstop';
48
+ /** zpk → transfer-function coefficients (scipy `zpk2tf`). */
49
+ export declare function zpkToTf(z: Complex[], p: Complex[], k: number): {
50
+ b: number[];
51
+ a: number[];
52
+ };
53
+ /**
54
+ * Digital IIR filter design pipeline shared by butter/cheby1/cheby2/ellip:
55
+ * pre-warp `Wn` → frequency-transform the analog lowpass prototype (`proto`,
56
+ * cutoff normalized to 1 rad/s) to the requested `btype` → bilinear transform →
57
+ * zpk2tf. Matches `scipy.signal.iirfilter`'s internal pipeline (fs = 2 convention).
58
+ */
59
+ export declare function analogToDigital(proto: AnalogProto, Wn: number | readonly number[], btype: FilterBtype): {
60
+ b: number[];
61
+ a: number[];
62
+ };
25
63
  /**
26
64
  * Butterworth IIR filter design — returns `{ b, a }` transfer-function coefficients.
27
- * `N` is the order, `Wn` the cutoff normalized to Nyquist (0..1). Lowpass only
28
- * (`btype='low'`, the common case). Matches `scipy.signal.butter(N, Wn)`.
65
+ * `N` is the order, `Wn` the cutoff (scalar) or `[low, high]` band edges, normalized
66
+ * to Nyquist (0..1). `btype` defaults to `'low'` (matches the original 2-arg call
67
+ * unchanged). Matches `scipy.signal.butter(N, Wn, btype)`.
29
68
  */
30
- export declare function butter(N: number, Wn: number): {
69
+ export declare function butter(N: number, Wn: number | readonly number[], btype?: FilterBtype): {
31
70
  b: number[];
32
71
  a: number[];
33
72
  };
@@ -1 +1 @@
1
- {"version":3,"file":"signal-filter-extra.d.ts","sourceRoot":"","sources":["../src/signal-filter-extra.ts"],"names":[],"mappings":"AAYA,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAK5C;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAahE;AAkCD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,EAAE,CAExD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MA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AE,CAG9B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-functions",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",