@thi.ng/math 5.11.18 → 5.11.20
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 +1 -1
- package/README.md +1 -1
- package/abs.d.ts +1 -1
- package/angle.d.ts +8 -8
- package/extrema.d.ts +12 -12
- package/fit.d.ts +3 -3
- package/interval.d.ts +20 -20
- package/libc.d.ts +1 -0
- package/min-error.d.ts +10 -11
- package/mix.d.ts +23 -25
- package/package.json +5 -6
- package/solve.d.ts +7 -5
- package/step.d.ts +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 201 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/abs.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { FnN2 } from "@thi.ng/api";
|
|
|
8
8
|
export declare const absDiff: FnN2;
|
|
9
9
|
/**
|
|
10
10
|
* Similar to `Math.sign()`, but uses `eps` to determine the zero value (i.e. if
|
|
11
|
-
* `x` is in [-eps,eps] interval).
|
|
11
|
+
* `x` is in `[-eps,eps]` interval).
|
|
12
12
|
*
|
|
13
13
|
* @param x
|
|
14
14
|
* @param eps
|
package/angle.d.ts
CHANGED
|
@@ -14,22 +14,22 @@ export declare const sincos: (theta: number, n?: number) => [number, number];
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const cossin: (theta: number, n?: number) => [number, number];
|
|
16
16
|
/**
|
|
17
|
-
* Projects `theta` into [0
|
|
17
|
+
* Projects `theta` into `[0,2π]` interval.
|
|
18
18
|
*
|
|
19
19
|
* @param theta -
|
|
20
20
|
*/
|
|
21
21
|
export declare const absTheta: FnN;
|
|
22
22
|
export declare const absInnerAngle: FnN;
|
|
23
23
|
/**
|
|
24
|
-
* Returns smallest absolute angle difference between `a` and `b`.
|
|
25
|
-
*
|
|
24
|
+
* Returns smallest absolute angle difference between `a` and `b`. Result will
|
|
25
|
+
* be in `[0,π]` interval.
|
|
26
26
|
*
|
|
27
27
|
* @param a -
|
|
28
28
|
* @param b -
|
|
29
29
|
*/
|
|
30
30
|
export declare const angleDist: FnN2;
|
|
31
31
|
/**
|
|
32
|
-
* Like `Math.atan2`, but always returns angle in [0
|
|
32
|
+
* Like `Math.atan2`, but always returns angle in `[0,TAU)` interval.
|
|
33
33
|
*
|
|
34
34
|
* @param y -
|
|
35
35
|
* @param x -
|
|
@@ -72,8 +72,8 @@ export declare const sec: FnN;
|
|
|
72
72
|
*/
|
|
73
73
|
export declare const cot: FnN;
|
|
74
74
|
/**
|
|
75
|
-
* Law of Cosines. Takes length of two sides of a triangle and the inner
|
|
76
|
-
*
|
|
75
|
+
* Law of Cosines. Takes length of two sides of a triangle and the inner angle
|
|
76
|
+
* (in radians) between them. Returns length of third side.
|
|
77
77
|
*
|
|
78
78
|
* @param a -
|
|
79
79
|
* @param b -
|
|
@@ -81,7 +81,7 @@ export declare const cot: FnN;
|
|
|
81
81
|
*/
|
|
82
82
|
export declare const loc: FnN3;
|
|
83
83
|
/**
|
|
84
|
-
* Approximates cos(xπ) for x in [-1,1]
|
|
84
|
+
* Approximates cos(xπ) for x in `[-1,1]`
|
|
85
85
|
*
|
|
86
86
|
* @param x -
|
|
87
87
|
*/
|
|
@@ -90,7 +90,7 @@ export declare const normCos: FnN;
|
|
|
90
90
|
* Fast cosine approximation using {@link normCos} (polynomial). Max. error
|
|
91
91
|
* ~0.00059693
|
|
92
92
|
*
|
|
93
|
-
* In [0
|
|
93
|
+
* In `[0,2π]` interval, approx. 18-20% faster than `Math.cos` on V8.
|
|
94
94
|
*
|
|
95
95
|
* @param theta - in radians
|
|
96
96
|
*/
|
package/extrema.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ export declare const isMinima: FnU3<number, boolean>;
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const isMaxima: FnU3<number, boolean>;
|
|
18
18
|
/**
|
|
19
|
-
* Returns index of the first local & internal minima found in given
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Returns index of the first local & internal minima found in given `values`
|
|
20
|
+
* array, or -1 if no such minima exists. The search range can be optionally
|
|
21
|
+
* defined via semi-open `[from,to)` index interval.
|
|
22
22
|
*
|
|
23
23
|
* @param values -
|
|
24
24
|
* @param from -
|
|
@@ -26,9 +26,9 @@ export declare const isMaxima: FnU3<number, boolean>;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const minimaIndex: (values: number[], from?: number, to?: number) => number;
|
|
28
28
|
/**
|
|
29
|
-
* Returns index of the first local & internal maxima found in given
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Returns index of the first local & internal maxima found in given `values`
|
|
30
|
+
* array, or -1 if no such maxima exists. The search range can be optionally
|
|
31
|
+
* defined via semi-open `[from,to)` index interval.
|
|
32
32
|
*
|
|
33
33
|
* @param values -
|
|
34
34
|
* @param from -
|
|
@@ -36,9 +36,9 @@ export declare const minimaIndex: (values: number[], from?: number, to?: number)
|
|
|
36
36
|
*/
|
|
37
37
|
export declare const maximaIndex: (values: number[], from?: number, to?: number) => number;
|
|
38
38
|
/**
|
|
39
|
-
* Returns an iterator yielding all minima indices in given `values`
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* Returns an iterator yielding all minima indices in given `values` array. The
|
|
40
|
+
* search range can be optionally defined via semi-open `[from,to)` index
|
|
41
|
+
* interval.
|
|
42
42
|
*
|
|
43
43
|
* @param values -
|
|
44
44
|
* @param from -
|
|
@@ -46,9 +46,9 @@ export declare const maximaIndex: (values: number[], from?: number, to?: number)
|
|
|
46
46
|
*/
|
|
47
47
|
export declare const minimaIndices: (values: number[], from?: number, to?: number) => Generator<number, void, unknown>;
|
|
48
48
|
/**
|
|
49
|
-
* Returns an iterator yielding all maxima indices in given `values`
|
|
50
|
-
*
|
|
51
|
-
*
|
|
49
|
+
* Returns an iterator yielding all maxima indices in given `values` array. The
|
|
50
|
+
* search range can be optionally defined via semi-open `[from,to)` index
|
|
51
|
+
* interval.
|
|
52
52
|
*
|
|
53
53
|
* @param values -
|
|
54
54
|
* @param from -
|
package/fit.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const fit: FnN5;
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const fitClamped: FnN5;
|
|
34
34
|
/**
|
|
35
|
-
* Similar to {@link fitClamped}, assuming [0,1] as source interval.
|
|
35
|
+
* Similar to {@link fitClamped}, assuming `[0,1]` as source interval.
|
|
36
36
|
*
|
|
37
37
|
* @param x
|
|
38
38
|
* @param a
|
|
@@ -40,7 +40,7 @@ export declare const fitClamped: FnN5;
|
|
|
40
40
|
*/
|
|
41
41
|
export declare const fit01: FnN3;
|
|
42
42
|
/**
|
|
43
|
-
* Similar to {@link fitClamped}, assuming the reverse ordered [1,0] as source
|
|
43
|
+
* Similar to {@link fitClamped}, assuming the reverse ordered `[1,0]` as source
|
|
44
44
|
* interval.
|
|
45
45
|
*
|
|
46
46
|
* @param x
|
|
@@ -49,7 +49,7 @@ export declare const fit01: FnN3;
|
|
|
49
49
|
*/
|
|
50
50
|
export declare const fit10: FnN3;
|
|
51
51
|
/**
|
|
52
|
-
* Similar to {@link fitClamped}, assuming [-1,1] as source interval.
|
|
52
|
+
* Similar to {@link fitClamped}, assuming `[-1,1]` as source interval.
|
|
53
53
|
*
|
|
54
54
|
* @param x
|
|
55
55
|
* @param a
|
package/interval.d.ts
CHANGED
|
@@ -8,39 +8,38 @@ import type { FnN, FnN2, FnN3, FnN4, FnU2, FnU3 } from "@thi.ng/api";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const clamp: FnN3;
|
|
10
10
|
/**
|
|
11
|
-
* Clamps value `x` to closed [0
|
|
11
|
+
* Clamps value `x` to closed `[0,∞]` interval.
|
|
12
12
|
*
|
|
13
13
|
* @param x -
|
|
14
14
|
*/
|
|
15
15
|
export declare const clamp0: FnN;
|
|
16
16
|
/**
|
|
17
|
-
* Clamps value `x` to closed [0
|
|
17
|
+
* Clamps value `x` to closed `[0,1]` interval.
|
|
18
18
|
*
|
|
19
19
|
* @param x -
|
|
20
20
|
*/
|
|
21
21
|
export declare const clamp01: FnN;
|
|
22
22
|
/**
|
|
23
|
-
* Clamps value `x` to closed [-1
|
|
23
|
+
* Clamps value `x` to closed `[-1,1]` interval.
|
|
24
24
|
*
|
|
25
25
|
* @param x -
|
|
26
26
|
*/
|
|
27
27
|
export declare const clamp11: FnN;
|
|
28
28
|
/**
|
|
29
|
-
* Clamps value `x` to closed [0
|
|
29
|
+
* Clamps value `x` to closed `[0,0.5]` interval.
|
|
30
30
|
*
|
|
31
31
|
* @param x -
|
|
32
32
|
*/
|
|
33
33
|
export declare const clamp05: FnN;
|
|
34
34
|
/**
|
|
35
|
-
* Returns 2-tuple of [min(x,y), max(x,y)]
|
|
35
|
+
* Returns 2-tuple of `[min(x,y), max(x,y)]`.
|
|
36
36
|
*
|
|
37
37
|
* @param x
|
|
38
38
|
* @param y
|
|
39
39
|
*/
|
|
40
40
|
export declare const minMax: FnU2<number, [number, number]>;
|
|
41
41
|
/**
|
|
42
|
-
* Folds `x` back inside closed [min
|
|
43
|
-
* {@link wrapOnce}.
|
|
42
|
+
* Folds `x` back inside closed `[min,max]` interval. Also see {@link wrapOnce}.
|
|
44
43
|
*
|
|
45
44
|
* @param x -
|
|
46
45
|
* @param min -
|
|
@@ -48,9 +47,9 @@ export declare const minMax: FnU2<number, [number, number]>;
|
|
|
48
47
|
*/
|
|
49
48
|
export declare const wrap: FnN3;
|
|
50
49
|
/**
|
|
51
|
-
* Like {@link wrap}, but optimized for cases where `x` is guaranteed to
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* Like {@link wrap}, but optimized for cases where `x` is guaranteed to be in
|
|
51
|
+
* `[min-d,max+d]` interval, where `d = max - min`. Result will be in closed
|
|
52
|
+
* `[min,max]` interval.
|
|
54
53
|
*
|
|
55
54
|
* @param x -
|
|
56
55
|
* @param min -
|
|
@@ -58,13 +57,13 @@ export declare const wrap: FnN3;
|
|
|
58
57
|
*/
|
|
59
58
|
export declare const wrapOnce: FnN3;
|
|
60
59
|
/**
|
|
61
|
-
* Similar to {@link wrapOnce} for [0
|
|
60
|
+
* Similar to {@link wrapOnce} for `[0,1]` interval.
|
|
62
61
|
*
|
|
63
62
|
* @param x -
|
|
64
63
|
*/
|
|
65
64
|
export declare const wrap01: FnN;
|
|
66
65
|
/**
|
|
67
|
-
* Similar to {@link wrapOnce} for [-1
|
|
66
|
+
* Similar to {@link wrapOnce} for `[-1,1]` interval.
|
|
68
67
|
*
|
|
69
68
|
* @param x -
|
|
70
69
|
*/
|
|
@@ -91,7 +90,7 @@ export declare const minNonZero2: FnN2;
|
|
|
91
90
|
*/
|
|
92
91
|
export declare const minNonZero3: FnN3;
|
|
93
92
|
/**
|
|
94
|
-
* See
|
|
93
|
+
* Smooth minimum. See {@link smax} for details.
|
|
95
94
|
*
|
|
96
95
|
* @param a -
|
|
97
96
|
* @param b -
|
|
@@ -100,7 +99,7 @@ export declare const minNonZero3: FnN3;
|
|
|
100
99
|
export declare const smin: FnN3;
|
|
101
100
|
/**
|
|
102
101
|
* Smooth maximum. Note: Result values will be slightly larger than max value
|
|
103
|
-
* near max(a,b) + eps due to exponential decay. Higher `k` values reduce the
|
|
102
|
+
* near `max(a, b) + eps` due to exponential decay. Higher `k` values reduce the
|
|
104
103
|
* error, but also reduce the smoothing. Recommended k=16.
|
|
105
104
|
*
|
|
106
105
|
* https://en.wikipedia.org/wiki/Smooth_maximum
|
|
@@ -122,12 +121,13 @@ export declare const sclamp: FnN4;
|
|
|
122
121
|
export declare const absMin: FnN2;
|
|
123
122
|
export declare const absMax: FnN2;
|
|
124
123
|
/**
|
|
125
|
-
* If `abs(x) > abs(e)`, recursively mirrors `x` back into `[-e
|
|
126
|
-
*
|
|
124
|
+
* If `abs(x) > abs(e)`, recursively mirrors `x` back into `[-e,e]` interval at
|
|
125
|
+
* respective positive/negative boundary.
|
|
127
126
|
*
|
|
128
127
|
* @remarks
|
|
129
128
|
* References:
|
|
130
|
-
*
|
|
129
|
+
*
|
|
130
|
+
* - [Interactive graph](https://www.desmos.com/calculator/lkyf2ag3ta)
|
|
131
131
|
* - https://www.musicdsp.org/en/latest/Effects/203-fold-back-distortion.html
|
|
132
132
|
*
|
|
133
133
|
* @param e - threshold (> 0)
|
|
@@ -136,14 +136,14 @@ export declare const absMax: FnN2;
|
|
|
136
136
|
export declare const foldback: FnN2;
|
|
137
137
|
/**
|
|
138
138
|
* Similar to {@link foldback}, but with fixed target range: Folds `x` into the
|
|
139
|
-
* closed [0
|
|
139
|
+
* closed `[0,1]` interval, using infinite internal reflection on either side of
|
|
140
140
|
* the interval.
|
|
141
141
|
*
|
|
142
142
|
* @param x
|
|
143
143
|
*/
|
|
144
144
|
export declare const foldback01: FnN;
|
|
145
145
|
/**
|
|
146
|
-
* Returns true iff `x` is in closed interval `[min
|
|
146
|
+
* Returns true iff `x` is in closed interval `[min,max]`
|
|
147
147
|
*
|
|
148
148
|
* @param x -
|
|
149
149
|
* @param min -
|
|
@@ -151,7 +151,7 @@ export declare const foldback01: FnN;
|
|
|
151
151
|
*/
|
|
152
152
|
export declare const inRange: FnU3<number, boolean>;
|
|
153
153
|
/**
|
|
154
|
-
* Returns true iff `x` is in open interval `(min
|
|
154
|
+
* Returns true iff `x` is in open interval `(min,max)`
|
|
155
155
|
*
|
|
156
156
|
* @param x -
|
|
157
157
|
* @param min -
|
package/libc.d.ts
CHANGED
package/min-error.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Recursively evaluates function `fn` for `res` uniformly spaced values
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
2
|
+
* Recursively evaluates function `fn` for `res` uniformly spaced values `t` in
|
|
3
|
+
* the closed parametric interval `[start,end]` and computes corresponding
|
|
4
|
+
* sample values `p`. For each `p` then calls `error` function to compute the
|
|
5
|
+
* error to query target value `q` and eventually returns the `t` producing the
|
|
6
|
+
* overall minimum error. At each level of recursion the search interval is
|
|
7
|
+
* increasingly narrowed / centered around the best `t` of the current
|
|
8
|
+
* iteration.
|
|
9
9
|
*
|
|
10
|
-
* The search is terminated early if the best error value is less than
|
|
11
|
-
* `eps`.
|
|
10
|
+
* The search is terminated early if the best error value is less than `eps`.
|
|
12
11
|
*
|
|
13
|
-
* The interval end points `start` and `end` MUST be normalized values
|
|
14
|
-
*
|
|
12
|
+
* The interval end points `start` and `end` MUST be normalized values in the
|
|
13
|
+
* closed `[0,1]` interval.
|
|
15
14
|
*
|
|
16
15
|
* @param fn - function to evaluate
|
|
17
16
|
* @param error - error function
|
package/mix.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { FnN, FnN2, FnN3, FnN4, FnN5, FnN6 } from "@thi.ng/api";
|
|
|
4
4
|
*
|
|
5
5
|
* @param a - start value
|
|
6
6
|
* @param b - end value
|
|
7
|
-
* @param t - interpolation factor [0
|
|
7
|
+
* @param t - interpolation factor `[0,1]`
|
|
8
8
|
*/
|
|
9
9
|
export declare const mix: FnN3;
|
|
10
10
|
/**
|
|
@@ -56,7 +56,7 @@ export declare const mixCubic: FnN5;
|
|
|
56
56
|
* {@link mixCubicHermite} with one of the tangent generators supporting
|
|
57
57
|
* non-uniform spacing of points.
|
|
58
58
|
*
|
|
59
|
-
*
|
|
59
|
+
* [Interactive graph](https://www.desmos.com/calculator/j4gf8g9vkr)
|
|
60
60
|
*
|
|
61
61
|
* Source:
|
|
62
62
|
* https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html
|
|
@@ -168,7 +168,7 @@ export declare const tangentCardinal: (prev: number, next: number, scale?: numbe
|
|
|
168
168
|
export declare const tangentDiff3: (prev: number, curr: number, next: number, ta?: number, tb?: number, tc?: number) => number;
|
|
169
169
|
/**
|
|
170
170
|
* HOF interpolator. Takes a timing function `f` and interval `[from,to]`.
|
|
171
|
-
* Returns function which takes normalized time (in [0,1] range) as single arg
|
|
171
|
+
* Returns function which takes normalized time (in `[0,1]` range) as single arg
|
|
172
172
|
* and returns interpolated value.
|
|
173
173
|
*
|
|
174
174
|
* @example
|
|
@@ -201,18 +201,18 @@ export declare const tween: (f: (t: number) => number, from: number, to: number)
|
|
|
201
201
|
* Circular interpolation (ease out): `sqrt(1 - (1 - t)^2)`
|
|
202
202
|
*
|
|
203
203
|
* @remarks
|
|
204
|
-
*
|
|
204
|
+
* [Interactive graph](https://www.desmos.com/calculator/tisoiazdrw)
|
|
205
205
|
*
|
|
206
|
-
* @param t - interpolation factor [0
|
|
206
|
+
* @param t - interpolation factor `[0,1]`
|
|
207
207
|
*/
|
|
208
208
|
export declare const circular: FnN;
|
|
209
209
|
/**
|
|
210
210
|
* Inverse/flipped version of {@link circular} (ease in).
|
|
211
211
|
*
|
|
212
212
|
* @remarks
|
|
213
|
-
*
|
|
213
|
+
* [Interactive graph](https://www.desmos.com/calculator/tisoiazdrw)
|
|
214
214
|
*
|
|
215
|
-
* @param t - interpolation factor [0
|
|
215
|
+
* @param t - interpolation factor `[0,1]`
|
|
216
216
|
*/
|
|
217
217
|
export declare const invCircular: FnN;
|
|
218
218
|
/**
|
|
@@ -220,8 +220,8 @@ export declare const invCircular: FnN;
|
|
|
220
220
|
* strength.
|
|
221
221
|
*
|
|
222
222
|
* @remarks
|
|
223
|
-
* Lens position must be given in (0
|
|
224
|
-
* [-1,1] range. If negative, the lens will be bundling values near `pos`, if
|
|
223
|
+
* Lens position must be given in `(0,1)` interval. Lens strength must be in
|
|
224
|
+
* `[-1,1]` range. If negative, the lens will be bundling values near `pos`, if
|
|
225
225
|
* positive the lens has dilating characteristics and will spread values near
|
|
226
226
|
* `pos` towards the edges.
|
|
227
227
|
*
|
|
@@ -255,7 +255,7 @@ export declare const invCircular: FnN;
|
|
|
255
255
|
*
|
|
256
256
|
* @param pos - lens pos
|
|
257
257
|
* @param strength - lens strength
|
|
258
|
-
* @param t - interpolation factor [0
|
|
258
|
+
* @param t - interpolation factor `[0,1]`
|
|
259
259
|
*/
|
|
260
260
|
export declare const lens: FnN3;
|
|
261
261
|
export declare const cosine: FnN;
|
|
@@ -264,8 +264,7 @@ export declare const decimated: FnN2;
|
|
|
264
264
|
* Spring oscillator with damping.
|
|
265
265
|
*
|
|
266
266
|
* @remarks
|
|
267
|
-
* Interactive graph
|
|
268
|
-
* https://www.desmos.com/calculator/tywbpw8pck
|
|
267
|
+
* [Interactive graph](https://www.desmos.com/calculator/tywbpw8pck)
|
|
269
268
|
*
|
|
270
269
|
* @param k
|
|
271
270
|
* @param amp
|
|
@@ -308,7 +307,7 @@ export declare const sinc: FnN;
|
|
|
308
307
|
* @remarks
|
|
309
308
|
* https://en.wikipedia.org/wiki/Sinc_function
|
|
310
309
|
*
|
|
311
|
-
*
|
|
310
|
+
* See {@link sinc}
|
|
312
311
|
*
|
|
313
312
|
* @param k -
|
|
314
313
|
* @param t -
|
|
@@ -319,7 +318,7 @@ export declare const sincNormalized: FnN2;
|
|
|
319
318
|
* returns 0.
|
|
320
319
|
*
|
|
321
320
|
* @remarks
|
|
322
|
-
* Interactive graph
|
|
321
|
+
* [Interactive graph](https://www.desmos.com/calculator/pmypqgefle)
|
|
323
322
|
*
|
|
324
323
|
* @param a -
|
|
325
324
|
* @param t -
|
|
@@ -338,14 +337,14 @@ export declare const lanczos: FnN2;
|
|
|
338
337
|
*/
|
|
339
338
|
export declare const sigmoid: FnN3;
|
|
340
339
|
/**
|
|
341
|
-
* Sigmoid function for inputs in [0
|
|
340
|
+
* Sigmoid function for inputs in `[0,1]` interval. Center bias = 0.5.
|
|
342
341
|
*
|
|
343
342
|
* @param k - steepness
|
|
344
343
|
* @param t - input value
|
|
345
344
|
*/
|
|
346
345
|
export declare const sigmoid01: FnN2;
|
|
347
346
|
/**
|
|
348
|
-
* Sigmoid function for inputs in [-1
|
|
347
|
+
* Sigmoid function for inputs in `[-1,1]` interval. Center bias = 0
|
|
349
348
|
*
|
|
350
349
|
* @param k -
|
|
351
350
|
* @param t -
|
|
@@ -356,18 +355,17 @@ export declare const sigmoid11: FnN2;
|
|
|
356
355
|
* https://arxiv.org/abs/2010.09714
|
|
357
356
|
*
|
|
358
357
|
* @remarks
|
|
359
|
-
* Interactive graph
|
|
360
|
-
* https://www.desmos.com/calculator/u6bkm5rb7t
|
|
358
|
+
* [Interactive graph](https://www.desmos.com/calculator/u6bkm5rb7t)
|
|
361
359
|
*
|
|
362
|
-
* @param a - curve strength. recommended (0
|
|
363
|
-
* @param b - pivot position [0
|
|
364
|
-
* @param t - input val [0
|
|
360
|
+
* @param a - curve strength. recommended `(0,64]`
|
|
361
|
+
* @param b - pivot position `[0,1]`
|
|
362
|
+
* @param t - input val `[0,1]`
|
|
365
363
|
*/
|
|
366
364
|
export declare const schlick: FnN3;
|
|
367
365
|
/**
|
|
368
|
-
* Computes exponential factor to interpolate from `a` to `b` over
|
|
369
|
-
*
|
|
370
|
-
*
|
|
366
|
+
* Computes exponential factor to interpolate from `a` to `b` over `num` steps.
|
|
367
|
+
* I.e. multiplying `a` with the returned factor will yield `b` after `num`
|
|
368
|
+
* steps. All args must be > 0.
|
|
371
369
|
*
|
|
372
370
|
* @param a -
|
|
373
371
|
* @param b -
|
|
@@ -378,7 +376,7 @@ export declare const expFactor: FnN3;
|
|
|
378
376
|
* Computes gaussian bell curve for given center `bias` and `sigma` (spread).
|
|
379
377
|
*
|
|
380
378
|
* @remarks
|
|
381
|
-
* Interactive graph
|
|
379
|
+
* [Interactive graph](https://www.desmos.com/calculator/aq6hdzxprv)
|
|
382
380
|
*
|
|
383
381
|
* @param bias -
|
|
384
382
|
* @param sigma -
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/math",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.20",
|
|
4
4
|
"description": "Assorted common math functions & utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,18 +36,17 @@
|
|
|
36
36
|
"build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
|
|
37
37
|
"clean": "bun ../../tools/src/clean-package.ts",
|
|
38
38
|
"doc": "typedoc --options ../../typedoc.json --out doc src/index.ts",
|
|
39
|
-
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
40
39
|
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
|
|
41
40
|
"pub": "yarn npm publish --access public",
|
|
42
41
|
"test": "bun test",
|
|
43
42
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@thi.ng/api": "^8.11.
|
|
45
|
+
"@thi.ng/api": "^8.11.20"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"esbuild": "^0.
|
|
50
|
-
"typedoc": "^0.27.
|
|
48
|
+
"esbuild": "^0.25.0",
|
|
49
|
+
"typedoc": "^0.27.7",
|
|
51
50
|
"typescript": "^5.7.3"
|
|
52
51
|
},
|
|
53
52
|
"keywords": [
|
|
@@ -145,5 +144,5 @@
|
|
|
145
144
|
"thi.ng": {
|
|
146
145
|
"year": 2013
|
|
147
146
|
},
|
|
148
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "9a0b33253fef092aaf301decf6ecd54317874d4c\n"
|
|
149
148
|
}
|
package/solve.d.ts
CHANGED
|
@@ -59,13 +59,15 @@ export declare const solveQuadratic: (a: number, b: number, c: number, eps?: num
|
|
|
59
59
|
*/
|
|
60
60
|
export declare const solveCubic: (a: number, b: number, c: number, d: number, eps?: number) => number[];
|
|
61
61
|
/**
|
|
62
|
-
* Solves a system of linear equations for N unknowns:
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* Solves a system of linear equations for N unknowns:
|
|
63
|
+
*
|
|
64
|
+
* `a[i]*x[i−1] + b[i]*x[i] + c[i]*x[i+1] = d[i]`,
|
|
65
|
+
*
|
|
66
|
+
* where `a[0]=0` and `c[N-1]=0`. Writes solutions `x[i]` back into array of
|
|
67
|
+
* input coefficients `d` and returns it. The other arrays are not modified.
|
|
65
68
|
*
|
|
66
69
|
* @remarks
|
|
67
|
-
* Reference:
|
|
68
|
-
* https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm
|
|
70
|
+
* Reference: https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm
|
|
69
71
|
*
|
|
70
72
|
* @param a - subdiagonal [1,N-1], a[0] is lower left corner
|
|
71
73
|
* @param b - main diagonal [0,N-1]
|
package/step.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export declare const step: FnN2;
|
|
|
21
21
|
export declare const smoothStep: FnN3;
|
|
22
22
|
/**
|
|
23
23
|
* Specialized version of {@link smoothStep}, assuming edges are 0/1
|
|
24
|
-
* respectively and `x` is in [0
|
|
24
|
+
* respectively and `x` is in `[0,1]`. No clamping performed.
|
|
25
25
|
*
|
|
26
26
|
* @param x
|
|
27
27
|
*/
|
|
@@ -39,7 +39,7 @@ export declare const smoothStep01: FnN;
|
|
|
39
39
|
export declare const smootherStep: FnN3;
|
|
40
40
|
/**
|
|
41
41
|
* Specialized version of {@link smootherStep}, assuming edges are 0/1
|
|
42
|
-
* respectively and `x` is in [0
|
|
42
|
+
* respectively and `x` is in `[0,1]`. No clamping performed.
|
|
43
43
|
*
|
|
44
44
|
* @param x
|
|
45
45
|
*/
|
|
@@ -55,7 +55,7 @@ export declare const smootherStep01: FnN;
|
|
|
55
55
|
* - Pulse: k=0.005, n=-10
|
|
56
56
|
* - Ease-in: k=0.5, n=0.25
|
|
57
57
|
*
|
|
58
|
-
* Interactive graph
|
|
58
|
+
* [Interactive graph](https://www.desmos.com/calculator/gcnuyppycz)
|
|
59
59
|
*
|
|
60
60
|
* @param k -
|
|
61
61
|
* @param n -
|