@thi.ng/math 5.3.16 → 5.3.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-16T12:52:25Z
3
+ - **Last updated**: 2022-12-20T16:33:11Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/interval.d.ts CHANGED
@@ -92,11 +92,11 @@ export declare const minNonZero3: FnN3;
92
92
  */
93
93
  export declare const smin: FnN3;
94
94
  /**
95
- * Smooth maximum. Note: Result values will be slightly larger than max
96
- * value near max(a,b) + eps due to exponential decay. Higher `k` values
97
- * reduce the error, but also reduce the smoothing. Recommended k=16.
95
+ * Smooth maximum. Note: Result values will be slightly larger than max value
96
+ * near max(a,b) + eps due to exponential decay. Higher `k` values reduce the
97
+ * error, but also reduce the smoothing. Recommended k=16.
98
98
  *
99
- * {@link https://en.wikipedia.org/wiki/Smooth_maximum}
99
+ * https://en.wikipedia.org/wiki/Smooth_maximum
100
100
  *
101
101
  * @param a -
102
102
  * @param b -
package/interval.js CHANGED
@@ -135,11 +135,11 @@ export const minNonZero3 = (a, b, c) => minNonZero2(minNonZero2(a, b), c);
135
135
  */
136
136
  export const smin = (a, b, k) => smax(a, b, -k);
137
137
  /**
138
- * Smooth maximum. Note: Result values will be slightly larger than max
139
- * value near max(a,b) + eps due to exponential decay. Higher `k` values
140
- * reduce the error, but also reduce the smoothing. Recommended k=16.
138
+ * Smooth maximum. Note: Result values will be slightly larger than max value
139
+ * near max(a,b) + eps due to exponential decay. Higher `k` values reduce the
140
+ * error, but also reduce the smoothing. Recommended k=16.
141
141
  *
142
- * {@link https://en.wikipedia.org/wiki/Smooth_maximum}
142
+ * https://en.wikipedia.org/wiki/Smooth_maximum
143
143
  *
144
144
  * @param a -
145
145
  * @param b -
package/mix.d.ts CHANGED
@@ -47,19 +47,19 @@ export declare const mixQuadratic: FnN4;
47
47
  */
48
48
  export declare const mixCubic: FnN5;
49
49
  /**
50
- * Returns hermite interpolation of `a, b, c, d` at normalized position
51
- * `t`, where `a` and `d` are used as predecessor/successor of `b` / `c`
52
- * and only inform the tangent of the interpolation curve. The
53
- * interpolated result is that of `b` and `c`.
50
+ * Returns hermite interpolation of `a, b, c, d` at normalized position `t`,
51
+ * where `a` and `d` are used as predecessor/successor of `b` / `c` and only
52
+ * inform the tangent of the interpolation curve. The interpolated result is
53
+ * that of `b` and `c`.
54
54
  *
55
55
  * Assumes all inputs are uniformly spaced. If that's not the case, use
56
56
  * {@link mixCubicHermite} with one of the tangent generators supporting
57
57
  * non-uniform spacing of points.
58
58
  *
59
- * See: {@link https://www.desmos.com/calculator/j4gf8g9vkr}
59
+ * See: https://www.desmos.com/calculator/j4gf8g9vkr
60
60
  *
61
61
  * Source:
62
- * {@link https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html}
62
+ * https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html
63
63
  *
64
64
  * - {@link mixCubicHermite}
65
65
  * - {@link tangentCardinal}
@@ -76,7 +76,7 @@ export declare const mixHermite: FnN5;
76
76
  * Computes cubic-hermite interpolation between `a` / `b` at normalized
77
77
  * time `t` and using respective tangents `ta` / `tb`.
78
78
  *
79
- * {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline}
79
+ * https://en.wikipedia.org/wiki/Cubic_Hermite_spline
80
80
  *
81
81
  * - {@link mixHermite}
82
82
  * - {@link tangentCardinal}
@@ -130,14 +130,14 @@ export declare const mixCubicHermiteFromPoints: FnN5;
130
130
  */
131
131
  export declare const mixBicubic: (s00: number, s01: number, s02: number, s03: number, s10: number, s11: number, s12: number, s13: number, s20: number, s21: number, s22: number, s23: number, s30: number, s31: number, s32: number, s33: number, u: number, v: number) => number;
132
132
  /**
133
- * Helper function for {@link mixCubicHermite}. Computes cardinal tangents
134
- * based on point neighbors of a point B (not given), i.e. `a`
135
- * (predecessor) and `c` (successor) and their times (defaults to
136
- * uniformly spaced). The optional `tension` parameter can be used to
137
- * scale the tangent where 0.0 produces a Cardinal spline tangent and
138
- * 1.0 a Catmull-Rom (opposite to the Wikipedia ref).
133
+ * Helper function for {@link mixCubicHermite}. Computes cardinal tangents based
134
+ * on point neighbors of a point B (not given), i.e. `a` (predecessor) and `c`
135
+ * (successor) and their times (defaults to uniformly spaced). The optional
136
+ * `tension` parameter can be used to scale the tangent where 0.0 produces a
137
+ * Cardinal spline tangent and 1.0 a Catmull-Rom (opposite to the Wikipedia
138
+ * ref).
139
139
  *
140
- * {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline}
140
+ * https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
141
141
  *
142
142
  * @param prev -
143
143
  * @param next -
@@ -148,15 +148,15 @@ export declare const mixBicubic: (s00: number, s01: number, s02: number, s03: nu
148
148
  export declare const tangentCardinal: (prev: number, next: number, scale?: number, ta?: number, tc?: number) => number;
149
149
  /**
150
150
  * Helper function for {@link mixCubicHermite}. Computes tangent for `curr`,
151
- * based on 3-point finite difference, where `prev` & `next` are
152
- * `curr`'s neighbors and the `tX` the three points' respective time
153
- * values. The latter are equally spaced by default (each 1.0 apart).
151
+ * based on 3-point finite difference, where `prev` & `next` are `curr`'s
152
+ * neighbors and the `tX` the three points' respective time values. The latter
153
+ * are equally spaced by default (each 1.0 apart).
154
154
  *
155
155
  * Using this function with equal spacing of 1.0 and together with
156
- * {@link mixCubicHermite} will produce same results as the somewhat
157
- * optimized variant {@link mixHermite}.
156
+ * {@link mixCubicHermite} will produce same results as the somewhat optimized
157
+ * variant {@link mixHermite}.
158
158
  *
159
- * {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference}
159
+ * https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference
160
160
  *
161
161
  * @param prev -
162
162
  * @param curr -
package/mix.js CHANGED
@@ -59,19 +59,19 @@ export const mixCubic = (a, b, c, d, t) => {
59
59
  return a * s2 * s + b * 3 * s2 * t + c * 3 * t2 * s + d * t2 * t;
60
60
  };
61
61
  /**
62
- * Returns hermite interpolation of `a, b, c, d` at normalized position
63
- * `t`, where `a` and `d` are used as predecessor/successor of `b` / `c`
64
- * and only inform the tangent of the interpolation curve. The
65
- * interpolated result is that of `b` and `c`.
62
+ * Returns hermite interpolation of `a, b, c, d` at normalized position `t`,
63
+ * where `a` and `d` are used as predecessor/successor of `b` / `c` and only
64
+ * inform the tangent of the interpolation curve. The interpolated result is
65
+ * that of `b` and `c`.
66
66
  *
67
67
  * Assumes all inputs are uniformly spaced. If that's not the case, use
68
68
  * {@link mixCubicHermite} with one of the tangent generators supporting
69
69
  * non-uniform spacing of points.
70
70
  *
71
- * See: {@link https://www.desmos.com/calculator/j4gf8g9vkr}
71
+ * See: https://www.desmos.com/calculator/j4gf8g9vkr
72
72
  *
73
73
  * Source:
74
- * {@link https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html}
74
+ * https://www.musicdsp.org/en/latest/Other/93-hermite-interpollation.html
75
75
  *
76
76
  * - {@link mixCubicHermite}
77
77
  * - {@link tangentCardinal}
@@ -92,7 +92,7 @@ export const mixHermite = (a, b, c, d, t) => {
92
92
  * Computes cubic-hermite interpolation between `a` / `b` at normalized
93
93
  * time `t` and using respective tangents `ta` / `tb`.
94
94
  *
95
- * {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline}
95
+ * https://en.wikipedia.org/wiki/Cubic_Hermite_spline
96
96
  *
97
97
  * - {@link mixHermite}
98
98
  * - {@link tangentCardinal}
@@ -163,14 +163,14 @@ export const mixCubicHermiteFromPoints = (a, b, c, d, t) => {
163
163
  */
164
164
  export const mixBicubic = (s00, s01, s02, s03, s10, s11, s12, s13, s20, s21, s22, s23, s30, s31, s32, s33, u, v) => mixCubicHermiteFromPoints(mixCubicHermiteFromPoints(s00, s01, s02, s03, u), mixCubicHermiteFromPoints(s10, s11, s12, s13, u), mixCubicHermiteFromPoints(s20, s21, s22, s23, u), mixCubicHermiteFromPoints(s30, s31, s32, s33, u), v);
165
165
  /**
166
- * Helper function for {@link mixCubicHermite}. Computes cardinal tangents
167
- * based on point neighbors of a point B (not given), i.e. `a`
168
- * (predecessor) and `c` (successor) and their times (defaults to
169
- * uniformly spaced). The optional `tension` parameter can be used to
170
- * scale the tangent where 0.0 produces a Cardinal spline tangent and
171
- * 1.0 a Catmull-Rom (opposite to the Wikipedia ref).
166
+ * Helper function for {@link mixCubicHermite}. Computes cardinal tangents based
167
+ * on point neighbors of a point B (not given), i.e. `a` (predecessor) and `c`
168
+ * (successor) and their times (defaults to uniformly spaced). The optional
169
+ * `tension` parameter can be used to scale the tangent where 0.0 produces a
170
+ * Cardinal spline tangent and 1.0 a Catmull-Rom (opposite to the Wikipedia
171
+ * ref).
172
172
  *
173
- * {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline}
173
+ * https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline
174
174
  *
175
175
  * @param prev -
176
176
  * @param next -
@@ -181,15 +181,15 @@ export const mixBicubic = (s00, s01, s02, s03, s10, s11, s12, s13, s20, s21, s22
181
181
  export const tangentCardinal = (prev, next, scale = 0.5, ta = 0, tc = 2) => scale * ((next - prev) / (tc - ta));
182
182
  /**
183
183
  * Helper function for {@link mixCubicHermite}. Computes tangent for `curr`,
184
- * based on 3-point finite difference, where `prev` & `next` are
185
- * `curr`'s neighbors and the `tX` the three points' respective time
186
- * values. The latter are equally spaced by default (each 1.0 apart).
184
+ * based on 3-point finite difference, where `prev` & `next` are `curr`'s
185
+ * neighbors and the `tX` the three points' respective time values. The latter
186
+ * are equally spaced by default (each 1.0 apart).
187
187
  *
188
188
  * Using this function with equal spacing of 1.0 and together with
189
- * {@link mixCubicHermite} will produce same results as the somewhat
190
- * optimized variant {@link mixHermite}.
189
+ * {@link mixCubicHermite} will produce same results as the somewhat optimized
190
+ * variant {@link mixHermite}.
191
191
  *
192
- * {@link https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference}
192
+ * https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference
193
193
  *
194
194
  * @param prev -
195
195
  * @param curr -
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/math",
3
- "version": "5.3.16",
3
+ "version": "5.3.17",
4
4
  "description": "Assorted common math functions & utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,7 +37,7 @@
37
37
  "test": "testament test"
38
38
  },
39
39
  "dependencies": {
40
- "@thi.ng/api": "^8.6.0"
40
+ "@thi.ng/api": "^8.6.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@microsoft/api-extractor": "^7.33.7",
@@ -135,5 +135,5 @@
135
135
  "thi.ng": {
136
136
  "year": 2013
137
137
  },
138
- "gitHead": "f445a9cc8022bcdebbf6ff91fd66ced016d72f01\n"
138
+ "gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
139
139
  }
package/solve.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import type { FnN2 } from "@thi.ng/api";
2
2
  /**
3
- * Produces a new function which computes derivative of the given
4
- * single-arg function. The extra optional arg `eps` is used to
5
- * define the step width for computing derived values:
3
+ * Produces a new function which computes derivative of the given single-arg
4
+ * function. The extra optional arg `eps` is used to define the step width for
5
+ * computing derived values:
6
6
  *
7
7
  * `f'(x) = (f(x + eps) - f(x)) / eps`
8
8
  *
9
- * The original function is assumed to be fully differentiable
10
- * in the interval the returned function is going to be used.
11
- * No validity checks of any form are done.
9
+ * The original function is assumed to be fully differentiable in the interval
10
+ * the returned function is going to be used. No validity checks of any form are
11
+ * done.
12
12
  *
13
- * {@link https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability}
13
+ * https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability
14
14
  *
15
15
  * @param fn -
16
16
  * @param eps -
@@ -26,13 +26,12 @@ export declare const derivative: (f: (x: number) => number, eps?: number) => (x:
26
26
  */
27
27
  export declare const solveLinear: FnN2;
28
28
  /**
29
- * Computes solutions for quadratic equation: `ax^2 + bx + c = 0`.
30
- * Returns array of real solutions.
31
- * Note: `a` MUST NOT be zero. If the quadratic term is missing,
32
- * use {@link solveLinear} instead.
29
+ * Computes solutions for quadratic equation: `ax^2 + bx + c = 0`. Returns array
30
+ * of real solutions. Note: `a` MUST NOT be zero. If the quadratic term is
31
+ * missing, use {@link solveLinear} instead.
33
32
  *
34
- * - {@link https://en.wikipedia.org/wiki/Quadratic_function}
35
- * - {@link https://en.wikipedia.org/wiki/Quadratic_equation}
33
+ * - https://en.wikipedia.org/wiki/Quadratic_function
34
+ * - https://en.wikipedia.org/wiki/Quadratic_equation
36
35
  *
37
36
  * @param a - quadratic coefficient
38
37
  * @param b - linear coefficient
@@ -42,11 +41,11 @@ export declare const solveLinear: FnN2;
42
41
  export declare const solveQuadratic: (a: number, b: number, c: number, eps?: number) => number[];
43
42
  /**
44
43
  * Computes solutions for quadratic equation: `ax^3 + bx^2 + c*x + d = 0`.
45
- * Returns array of solutions, both real & imaginary.
46
- * Note: `a` MUST NOT be zero. If the cubic term is missing (i.e. zero),
47
- * use {@link solveQuadratic} or {@link solveLinear} instead.
44
+ * Returns array of solutions, both real & imaginary. Note: `a` MUST NOT be
45
+ * zero. If the cubic term is missing (i.e. zero), use {@link solveQuadratic} or
46
+ * {@link solveLinear} instead.
48
47
  *
49
- * {@link https://en.wikipedia.org/wiki/Cubic_function}
48
+ * https://en.wikipedia.org/wiki/Cubic_function
50
49
  *
51
50
  * @param a - cubic coefficient
52
51
  * @param b - quadratic coefficient
package/solve.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import { EPS } from "./api.js";
2
2
  import { safeDiv } from "./safe-div.js";
3
3
  /**
4
- * Produces a new function which computes derivative of the given
5
- * single-arg function. The extra optional arg `eps` is used to
6
- * define the step width for computing derived values:
4
+ * Produces a new function which computes derivative of the given single-arg
5
+ * function. The extra optional arg `eps` is used to define the step width for
6
+ * computing derived values:
7
7
  *
8
8
  * `f'(x) = (f(x + eps) - f(x)) / eps`
9
9
  *
10
- * The original function is assumed to be fully differentiable
11
- * in the interval the returned function is going to be used.
12
- * No validity checks of any form are done.
10
+ * The original function is assumed to be fully differentiable in the interval
11
+ * the returned function is going to be used. No validity checks of any form are
12
+ * done.
13
13
  *
14
- * {@link https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability}
14
+ * https://en.wikipedia.org/wiki/Derivative#Continuity_and_differentiability
15
15
  *
16
16
  * @param fn -
17
17
  * @param eps -
@@ -27,13 +27,12 @@ export const derivative = (f, eps = EPS) => (x) => (f(x + eps) - f(x)) / eps;
27
27
  */
28
28
  export const solveLinear = (a, b) => safeDiv(-b, a);
29
29
  /**
30
- * Computes solutions for quadratic equation: `ax^2 + bx + c = 0`.
31
- * Returns array of real solutions.
32
- * Note: `a` MUST NOT be zero. If the quadratic term is missing,
33
- * use {@link solveLinear} instead.
30
+ * Computes solutions for quadratic equation: `ax^2 + bx + c = 0`. Returns array
31
+ * of real solutions. Note: `a` MUST NOT be zero. If the quadratic term is
32
+ * missing, use {@link solveLinear} instead.
34
33
  *
35
- * - {@link https://en.wikipedia.org/wiki/Quadratic_function}
36
- * - {@link https://en.wikipedia.org/wiki/Quadratic_equation}
34
+ * - https://en.wikipedia.org/wiki/Quadratic_function
35
+ * - https://en.wikipedia.org/wiki/Quadratic_equation
37
36
  *
38
37
  * @param a - quadratic coefficient
39
38
  * @param b - linear coefficient
@@ -51,11 +50,11 @@ export const solveQuadratic = (a, b, c, eps = 1e-9) => {
51
50
  };
52
51
  /**
53
52
  * Computes solutions for quadratic equation: `ax^3 + bx^2 + c*x + d = 0`.
54
- * Returns array of solutions, both real & imaginary.
55
- * Note: `a` MUST NOT be zero. If the cubic term is missing (i.e. zero),
56
- * use {@link solveQuadratic} or {@link solveLinear} instead.
53
+ * Returns array of solutions, both real & imaginary. Note: `a` MUST NOT be
54
+ * zero. If the cubic term is missing (i.e. zero), use {@link solveQuadratic} or
55
+ * {@link solveLinear} instead.
57
56
  *
58
- * {@link https://en.wikipedia.org/wiki/Cubic_function}
57
+ * https://en.wikipedia.org/wiki/Cubic_function
59
58
  *
60
59
  * @param a - cubic coefficient
61
60
  * @param b - quadratic coefficient