@thi.ng/math 5.0.8 → 5.2.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/CHANGELOG.md +174 -135
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +135 -126
- package/prime.d.ts +21 -0
- package/prime.js +54 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,236 +1,275 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## [5.0.8](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@5.0.7...@thi.ng/math@5.0.8) (2021-11-10)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @thi.ng/math
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## [5.0.7](https://github.com/thi-ng/umbrella/compare/@thi.ng/math@5.0.6...@thi.ng/math@5.0.7) (2021-11-03)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @thi.ng/math
|
|
17
|
-
|
|
3
|
+
- **Last updated**: 2021-12-13T10:26:00Z
|
|
4
|
+
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
18
5
|
|
|
6
|
+
All notable changes to this project will be documented in this file.
|
|
7
|
+
See [Conventional Commits](https://conventionalcommits.org/) for commit guidelines.
|
|
19
8
|
|
|
9
|
+
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
|
+
and/or version bumps of transitive dependencies.
|
|
20
11
|
|
|
12
|
+
## [5.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.2.0) (2021-12-13)
|
|
21
13
|
|
|
22
|
-
|
|
14
|
+
#### 🚀 Features
|
|
23
15
|
|
|
16
|
+
- add prime number fns ([f301256](https://github.com/thi-ng/umbrella/commit/f301256))
|
|
17
|
+
- add nearestPrime()
|
|
18
|
+
- add primesUntil()
|
|
19
|
+
- add tests
|
|
20
|
+
- update pkg
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
## [5.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.1.0) (2021-11-17)
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
#### 🚀 Features
|
|
28
25
|
|
|
26
|
+
- Using workspaces for local tools ([bf7a404](https://github.com/thi-ng/umbrella/commit/bf7a404))
|
|
27
|
+
Improving the overall build ergonomics
|
|
28
|
+
- introduced a tools workspaces
|
|
29
|
+
- imported it in all needed packages/examples
|
|
30
|
+
- inclusive project root
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
#### ♻️ Refactoring
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
- testrunner to binary ([4ebbbb2](https://github.com/thi-ng/umbrella/commit/4ebbbb2))
|
|
35
|
+
this commit reverts (partly) changes made in:
|
|
36
|
+
ef346d7a8753590dc9094108a3d861a8dbd5dd2c
|
|
37
|
+
overall purpose is better testament ergonomics:
|
|
38
|
+
instead of having to pass NODE_OPTIONS with every invocation
|
|
39
|
+
having a binary to handle this for us.
|
|
33
40
|
|
|
34
|
-
-
|
|
35
|
-
- CJS obsolete due to ESM support in recent versions of node:
|
|
36
|
-
- i.e. launch NodeJS via:
|
|
37
|
-
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
38
|
-
- in the node REPL use `await import(...)` instead of `require()`
|
|
39
|
-
- UMD obsolete due to widespread browser support for ESM
|
|
41
|
+
### [5.0.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.0.1) (2021-10-13)
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
- normalize/restructure/reorg all package.json files
|
|
43
|
-
- cleanup all build scripts, remove obsolete
|
|
44
|
-
- switch from mocha to @thi.ng/testament for all tests
|
|
43
|
+
#### ♻️ Refactoring
|
|
45
44
|
|
|
45
|
+
- update imports in all tests/pkgs ([effd591](https://github.com/thi-ng/umbrella/commit/effd591))
|
|
46
|
+
- update imports in all pkgs ([5fa2b6f](https://github.com/thi-ng/umbrella/commit/5fa2b6f))
|
|
47
|
+
- add .js suffix for all relative imports
|
|
46
48
|
|
|
49
|
+
# [5.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@5.0.0) (2021-10-12)
|
|
47
50
|
|
|
51
|
+
#### 🛑 Breaking changes
|
|
48
52
|
|
|
53
|
+
- major update of ALL pkgs (export maps, ESM only) ([0d1d6ea](https://github.com/thi-ng/umbrella/commit/0d1d6ea))
|
|
54
|
+
- BREAKING CHANGE: discontinue CommonJS & UMD versions
|
|
55
|
+
- only ESM modules will be published from now on
|
|
56
|
+
- CJS obsolete due to ESM support in recent versions of node:
|
|
57
|
+
- i.e. launch NodeJS via:
|
|
58
|
+
- `node --experimental-specifier-resolution=node --experimental-repl-await`
|
|
59
|
+
- in the node REPL use `await import(...)` instead of `require()`
|
|
60
|
+
- UMD obsolete due to widespread browser support for ESM
|
|
61
|
+
Also:
|
|
62
|
+
- normalize/restructure/reorg all package.json files
|
|
63
|
+
- cleanup all build scripts, remove obsolete
|
|
64
|
+
- switch from mocha to [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament) for all tests
|
|
49
65
|
|
|
66
|
+
#### ♻️ Refactoring
|
|
50
67
|
|
|
51
|
-
|
|
68
|
+
- update imports ([138571a](https://github.com/thi-ng/umbrella/commit/138571a))
|
|
69
|
+
- update all tests in _all_ pkgs ([8b582bc](https://github.com/thi-ng/umbrella/commit/8b582bc))
|
|
70
|
+
- update all to use [@thi.ng/testament](https://github.com/thi-ng/umbrella/tree/main/packages/testament)
|
|
52
71
|
|
|
53
|
-
###
|
|
72
|
+
### [4.0.6](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@4.0.6) (2021-09-03)
|
|
54
73
|
|
|
55
|
-
|
|
74
|
+
#### 🩹 Bug fixes
|
|
56
75
|
|
|
57
|
-
|
|
76
|
+
- removing deprecated eqDeltaFixed() ([1de245b](https://github.com/thi-ng/umbrella/commit/1de245b))
|
|
58
77
|
|
|
59
|
-
|
|
78
|
+
# [4.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@4.0.0) (2021-04-24)
|
|
60
79
|
|
|
61
|
-
|
|
62
|
-
- **math:** add/update modulo functions ([be7b02b](https://github.com/thi-ng/umbrella/commit/be7b02beaf4ab1ab1030597a5f4eb94d43e1469b))
|
|
80
|
+
#### 🛑 Breaking changes
|
|
63
81
|
|
|
64
|
-
|
|
82
|
+
- add/update modulo functions ([be7b02b](https://github.com/thi-ng/umbrella/commit/be7b02b))
|
|
83
|
+
- BREAKING CHANGE: Introduction of standard libc math functions causes
|
|
84
|
+
behavior change of existing `fmod()` function...
|
|
85
|
+
- rename `fmod()` => `mod()` to align w/ GLSL counterpart
|
|
86
|
+
- add new `fmod()` w/ standard libc behavior (same as JS % op)
|
|
87
|
+
- add `remainder()` w/ standard libc behavior
|
|
88
|
+
- update doc strings
|
|
65
89
|
|
|
66
|
-
|
|
67
|
-
- rename `fmod()` => `mod()` to align w/ GLSL counterpart
|
|
68
|
-
- add new `fmod()` w/ standard libc behavior (same as JS % op)
|
|
69
|
-
- add `remainder()` w/ standard libc behavior
|
|
70
|
-
- update doc strings
|
|
90
|
+
#### 🚀 Features
|
|
71
91
|
|
|
72
|
-
|
|
92
|
+
- add libc math fns ([28b41a8](https://github.com/thi-ng/umbrella/commit/28b41a8))
|
|
93
|
+
- add copysign()
|
|
94
|
+
- add exp2()
|
|
95
|
+
- add fdim()
|
|
96
|
+
- add fma()
|
|
97
|
+
- add frexp()
|
|
98
|
+
- add ldexp()
|
|
73
99
|
|
|
74
|
-
|
|
100
|
+
## [3.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@3.4.0) (2021-04-03)
|
|
75
101
|
|
|
76
|
-
|
|
102
|
+
#### 🚀 Features
|
|
77
103
|
|
|
78
|
-
|
|
104
|
+
- add lanczos(), fix/update/add sinc ([e661b7a](https://github.com/thi-ng/umbrella/commit/e661b7a))
|
|
105
|
+
- replace broken sinc() fn w/ non-normalized real sinc
|
|
106
|
+
- add sincNormalized()
|
|
107
|
+
- add lanczos()
|
|
79
108
|
|
|
80
|
-
|
|
109
|
+
#### 🩹 Bug fixes
|
|
81
110
|
|
|
82
|
-
|
|
111
|
+
- fix sigmoid01() signature ([378cb17](https://github.com/thi-ng/umbrella/commit/378cb17))
|
|
83
112
|
|
|
84
|
-
|
|
113
|
+
## [3.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@3.3.0) (2021-03-17)
|
|
85
114
|
|
|
86
|
-
|
|
115
|
+
#### 🚀 Features
|
|
87
116
|
|
|
88
|
-
|
|
117
|
+
- add mixBicubic(), mixCubicHermiteFromPoints() ([30dda42](https://github.com/thi-ng/umbrella/commit/30dda42))
|
|
89
118
|
|
|
90
|
-
|
|
119
|
+
#### ⏱ Performance improvements
|
|
91
120
|
|
|
92
|
-
|
|
121
|
+
- replace mixBilinear() w/ inline impl ([bb16dc5](https://github.com/thi-ng/umbrella/commit/bb16dc5))
|
|
122
|
+
- new impl ~1.7x faster
|
|
93
123
|
|
|
94
|
-
|
|
124
|
+
## [3.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@3.2.0) (2021-02-20)
|
|
95
125
|
|
|
96
|
-
|
|
126
|
+
#### 🚀 Features
|
|
97
127
|
|
|
98
|
-
|
|
128
|
+
- add clamp0() ([d18c869](https://github.com/thi-ng/umbrella/commit/d18c869))
|
|
99
129
|
|
|
100
|
-
|
|
130
|
+
## [3.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@3.1.0) (2021-01-10)
|
|
101
131
|
|
|
102
|
-
|
|
132
|
+
#### 🚀 Features
|
|
103
133
|
|
|
104
|
-
|
|
134
|
+
- add floorTo/ceilTo() ([595fe83](https://github.com/thi-ng/umbrella/commit/595fe83))
|
|
105
135
|
|
|
106
|
-
|
|
136
|
+
# [3.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@3.0.0) (2020-12-22)
|
|
107
137
|
|
|
108
|
-
|
|
138
|
+
#### 🛑 Breaking changes
|
|
109
139
|
|
|
110
|
-
|
|
140
|
+
- fix [#256](https://github.com/thi-ng/umbrella/issues/256) replace enum w/ type alias ([8f00375](https://github.com/thi-ng/umbrella/commit/8f00375))
|
|
141
|
+
- update comparison order in classifyCrossing()
|
|
142
|
+
- BREAKING CHANGE: replace Crossing enum w/ type alias
|
|
143
|
+
- update/fix sigmoid() behavior ([07a278f](https://github.com/thi-ng/umbrella/commit/07a278f))
|
|
144
|
+
- BREAKING CHANGE: add new bias arg for sigmoid() to satisfy more use cases.
|
|
145
|
+
Use sigmoid01() for old behavior.
|
|
146
|
+
- add/update docstrings
|
|
147
|
+
- add desmos links
|
|
111
148
|
|
|
112
|
-
|
|
149
|
+
#### 🚀 Features
|
|
113
150
|
|
|
114
|
-
|
|
151
|
+
- add more parametric T-norms ([38bd40e](https://github.com/thi-ng/umbrella/commit/38bd40e))
|
|
152
|
+
- add gaussian() ([138befe](https://github.com/thi-ng/umbrella/commit/138befe))
|
|
153
|
+
- add various T-norm functions ([ab4a810](https://github.com/thi-ng/umbrella/commit/ab4a810))
|
|
115
154
|
|
|
116
|
-
|
|
117
|
-
- **math:** add more parametric T-norms ([38bd40e](https://github.com/thi-ng/umbrella/commit/38bd40e1595e318c6472a526e03c8c8a06ebf396))
|
|
118
|
-
- **math:** add various T-norm functions ([ab4a810](https://github.com/thi-ng/umbrella/commit/ab4a810981c08c54365d5ea3212cd465d2589cf0))
|
|
155
|
+
### [2.2.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@2.2.2) (2020-12-07)
|
|
119
156
|
|
|
120
|
-
|
|
157
|
+
#### ♻️ Refactoring
|
|
121
158
|
|
|
122
|
-
-
|
|
123
|
-
- **math:** add new bias arg for sigmoid() to satisfy more use cases. Use sigmoid01() for old behavior.
|
|
124
|
-
- add/update docstrings
|
|
125
|
-
- add desmos links
|
|
159
|
+
- update type-only imports in various tests/pkgs ([3fd9c24](https://github.com/thi-ng/umbrella/commit/3fd9c24))
|
|
126
160
|
|
|
127
|
-
|
|
161
|
+
## [2.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@2.2.0) (2020-11-24)
|
|
128
162
|
|
|
129
|
-
|
|
163
|
+
#### 🚀 Features
|
|
130
164
|
|
|
131
|
-
-
|
|
165
|
+
- add generalized schlick curve ([4b6eb84](https://github.com/thi-ng/umbrella/commit/4b6eb84))
|
|
132
166
|
|
|
133
|
-
|
|
167
|
+
## [2.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@2.1.0) (2020-09-13)
|
|
134
168
|
|
|
135
|
-
|
|
169
|
+
#### 🚀 Features
|
|
136
170
|
|
|
137
|
-
-
|
|
171
|
+
- add lens(), invCircular() interpolators ([56dce17](https://github.com/thi-ng/umbrella/commit/56dce17))
|
|
138
172
|
|
|
139
|
-
|
|
173
|
+
#### ♻️ Refactoring
|
|
140
174
|
|
|
141
|
-
|
|
175
|
+
- update deps, imports, use new Fn types ([a40840d](https://github.com/thi-ng/umbrella/commit/a40840d))
|
|
176
|
+
- use new function aliases, update deps ([dd0337f](https://github.com/thi-ng/umbrella/commit/dd0337f))
|
|
142
177
|
|
|
143
|
-
|
|
178
|
+
### [1.7.5](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.7.5) (2020-04-05)
|
|
144
179
|
|
|
145
|
-
|
|
180
|
+
#### ♻️ Refactoring
|
|
146
181
|
|
|
147
|
-
-
|
|
148
|
-
- this is essentially a revert to 5018009
|
|
149
|
-
- also keep, but deprecate `eqDeltaFixed()` (synonym for `eqDelta` now)
|
|
182
|
+
- switch to non-const enums ([783e5e3](https://github.com/thi-ng/umbrella/commit/783e5e3))
|
|
150
183
|
|
|
151
|
-
|
|
184
|
+
## [1.7.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.7.0) (2020-02-25)
|
|
152
185
|
|
|
153
|
-
|
|
186
|
+
#### 🚀 Features
|
|
154
187
|
|
|
155
|
-
-
|
|
156
|
-
-
|
|
188
|
+
- add minNonZero2/3() ([49c88d9](https://github.com/thi-ng/umbrella/commit/49c88d9))
|
|
189
|
+
- add safeDiv() (from @nkint PR [#206](https://github.com/thi-ng/umbrella/issues/206)) ([0567b93](https://github.com/thi-ng/umbrella/commit/0567b93))
|
|
157
190
|
|
|
158
|
-
|
|
191
|
+
## [1.6.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.6.0) (2020-01-24)
|
|
159
192
|
|
|
160
|
-
|
|
193
|
+
#### 🚀 Features
|
|
161
194
|
|
|
162
|
-
-
|
|
163
|
-
-
|
|
195
|
+
- add clamp05, update wrapOnce, wrap01, wrap11 ([19af252](https://github.com/thi-ng/umbrella/commit/19af252))
|
|
196
|
+
- add clamp05()
|
|
197
|
+
- wrap fns now consistently use *closed* intervals
|
|
198
|
+
- add expFactor(), update wrap/wrapOnce() ([bb07348](https://github.com/thi-ng/umbrella/commit/bb07348))
|
|
199
|
+
- rename wrap => wrapOnce()
|
|
200
|
+
- add new wrap() which wraps any value, regardless of
|
|
201
|
+
dist to interval border
|
|
202
|
+
- update docs
|
|
164
203
|
|
|
165
|
-
|
|
204
|
+
## [1.5.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.5.0) (2019-11-09)
|
|
166
205
|
|
|
167
|
-
|
|
206
|
+
#### 🚀 Features
|
|
168
207
|
|
|
169
|
-
-
|
|
208
|
+
- add mixCubicHermite & tangent fns ([d6b4b37](https://github.com/thi-ng/umbrella/commit/d6b4b37))
|
|
170
209
|
|
|
171
|
-
|
|
210
|
+
## [1.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.4.0) (2019-07-07)
|
|
172
211
|
|
|
173
|
-
|
|
212
|
+
#### 🚀 Features
|
|
174
213
|
|
|
175
|
-
-
|
|
214
|
+
- add signed/unsigned int math ops ([518d79a](https://github.com/thi-ng/umbrella/commit/518d79a))
|
|
176
215
|
|
|
177
|
-
|
|
216
|
+
## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.3.0) (2019-05-22)
|
|
178
217
|
|
|
179
|
-
|
|
218
|
+
#### 🚀 Features
|
|
180
219
|
|
|
181
|
-
-
|
|
182
|
-
-
|
|
220
|
+
- add sigmoid / sigmoid11 fns ([3f085a3](https://github.com/thi-ng/umbrella/commit/3f085a3))
|
|
221
|
+
- add extrema & crossing fns and Crossing enum ([e102f39](https://github.com/thi-ng/umbrella/commit/e102f39))
|
|
183
222
|
|
|
184
|
-
|
|
223
|
+
## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.2.0) (2019-03-18)
|
|
185
224
|
|
|
186
|
-
|
|
225
|
+
#### 🚀 Features
|
|
187
226
|
|
|
188
|
-
-
|
|
189
|
-
-
|
|
190
|
-
-
|
|
227
|
+
- add cos/sin approximations, loc(), add docstrings ([78ed751](https://github.com/thi-ng/umbrella/commit/78ed751))
|
|
228
|
+
- add consts ([28e9898](https://github.com/thi-ng/umbrella/commit/28e9898))
|
|
229
|
+
- more trigonometry ([b5e1c02](https://github.com/thi-ng/umbrella/commit/b5e1c02))
|
|
191
230
|
|
|
192
|
-
|
|
231
|
+
## [1.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.1.0) (2019-02-05)
|
|
193
232
|
|
|
194
|
-
|
|
233
|
+
#### 🚀 Features
|
|
195
234
|
|
|
196
|
-
-
|
|
197
|
-
- **math:** add PHI const ([57d4488](https://github.com/thi-ng/umbrella/commit/57d4488))
|
|
198
|
-
- **math:** add simplifyRatio() ([31e369b](https://github.com/thi-ng/umbrella/commit/31e369b))
|
|
235
|
+
- add PHI const ([57d4488](https://github.com/thi-ng/umbrella/commit/57d4488))
|
|
199
236
|
|
|
200
|
-
#
|
|
237
|
+
# [1.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@1.0.0) (2019-01-21)
|
|
201
238
|
|
|
202
|
-
|
|
239
|
+
#### 🛑 Breaking changes
|
|
203
240
|
|
|
204
241
|
- update package build scripts & outputs, imports in ~50 packages ([b54b703](https://github.com/thi-ng/umbrella/commit/b54b703))
|
|
242
|
+
- BREAKING CHANGE: enabled multi-outputs (ES6 modules, CJS, UMD)
|
|
243
|
+
- build scripts now first build ES6 modules in package root, then call
|
|
244
|
+
`scripts/bundle-module` to build minified CJS & UMD bundles in `/lib`
|
|
245
|
+
- all imports MUST be updated to only refer to package level
|
|
246
|
+
(not individual files anymore). tree shaking in user land will get rid of
|
|
247
|
+
all unused imported symbols.
|
|
205
248
|
|
|
206
|
-
|
|
249
|
+
#### 🚀 Features
|
|
207
250
|
|
|
208
|
-
-
|
|
209
|
-
-
|
|
210
|
-
- **math:** add cossin(), add opt scale arg for sincos() ([0043fb5](https://github.com/thi-ng/umbrella/commit/0043fb5))
|
|
211
|
-
- **math:** update eqDelta w/ adaptive eps, rename old => eqDeltaFixed ([5018009](https://github.com/thi-ng/umbrella/commit/5018009))
|
|
251
|
+
- add absInnerAngle() ([a78bd87](https://github.com/thi-ng/umbrella/commit/a78bd87))
|
|
252
|
+
- update eqDelta w/ adaptive eps, rename old => eqDeltaFixed ([5018009](https://github.com/thi-ng/umbrella/commit/5018009))
|
|
212
253
|
|
|
213
|
-
|
|
254
|
+
#### ♻️ Refactoring
|
|
214
255
|
|
|
215
|
-
-
|
|
216
|
-
- build scripts now first build ES6 modules in package root, then call `scripts/bundle-module` to build minified CJS & UMD bundles in `/lib`
|
|
217
|
-
- all imports MUST be updated to only refer to package level (not individual files anymore). tree shaking in user land will get rid of all unused imported symbols.
|
|
256
|
+
- use arrow fns ([560207a](https://github.com/thi-ng/umbrella/commit/560207a))
|
|
218
257
|
|
|
219
|
-
|
|
258
|
+
### [0.2.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@0.2.1) (2018-11-20)
|
|
220
259
|
|
|
221
|
-
|
|
260
|
+
#### 🩹 Bug fixes
|
|
222
261
|
|
|
223
|
-
-
|
|
262
|
+
- fix [#60](https://github.com/thi-ng/umbrella/issues/60), add range check for norm() ([143c47c](https://github.com/thi-ng/umbrella/commit/143c47c))
|
|
224
263
|
|
|
225
|
-
|
|
264
|
+
## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@0.2.0) (2018-10-21)
|
|
226
265
|
|
|
227
|
-
|
|
266
|
+
#### 🚀 Features
|
|
228
267
|
|
|
229
|
-
-
|
|
230
|
-
-
|
|
268
|
+
- migrate mixCubic()/mixQuadratic() from geom package ([4a47daa](https://github.com/thi-ng/umbrella/commit/4a47daa))
|
|
269
|
+
- add sincos() & roundEps() ([f891c41](https://github.com/thi-ng/umbrella/commit/f891c41))
|
|
231
270
|
|
|
232
|
-
|
|
271
|
+
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/math@0.1.0) (2018-10-17)
|
|
233
272
|
|
|
234
|
-
|
|
273
|
+
#### 🚀 Features
|
|
235
274
|
|
|
236
|
-
-
|
|
275
|
+
- extract maths fns from [@thi.ng/vectors](https://github.com/thi-ng/umbrella/tree/main/packages/vectors) as new package ([4af1fba](https://github.com/thi-ng/umbrella/commit/4af1fba))
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,127 +1,136 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
2
|
+
"name": "@thi.ng/math",
|
|
3
|
+
"version": "5.2.0",
|
|
4
|
+
"description": "Assorted common math functions & utilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/math#readme",
|
|
14
|
+
"funding": [
|
|
15
|
+
{
|
|
16
|
+
"type": "github",
|
|
17
|
+
"url": "https://github.com/sponsors/postspectacular"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"type": "patreon",
|
|
21
|
+
"url": "https://patreon.com/thing_umbrella"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"author": "Karsten Schmidt <k+npm@thi.ng>",
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "yarn clean && tsc --declaration",
|
|
28
|
+
"clean": "rimraf '*.js' '*.d.ts' '*.map' doc",
|
|
29
|
+
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
|
|
30
|
+
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
|
|
31
|
+
"doc:readme": "yarn doc:stats && tools:readme",
|
|
32
|
+
"doc:stats": "tools:module-stats",
|
|
33
|
+
"pub": "yarn npm publish --access public",
|
|
34
|
+
"test": "testament test"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@thi.ng/api": "^8.3.3"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@microsoft/api-extractor": "^7.19.2",
|
|
41
|
+
"@thi.ng/testament": "^0.2.3",
|
|
42
|
+
"rimraf": "^3.0.2",
|
|
43
|
+
"tools": "^0.0.1",
|
|
44
|
+
"typedoc": "^0.22.10",
|
|
45
|
+
"typescript": "^4.5.3"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"animation",
|
|
49
|
+
"bezier",
|
|
50
|
+
"cubic",
|
|
51
|
+
"hermite",
|
|
52
|
+
"interpolation",
|
|
53
|
+
"interval",
|
|
54
|
+
"math",
|
|
55
|
+
"prime",
|
|
56
|
+
"quadratic",
|
|
57
|
+
"smooth",
|
|
58
|
+
"solver",
|
|
59
|
+
"t-norm",
|
|
60
|
+
"trigonometry",
|
|
61
|
+
"typescript"
|
|
62
|
+
],
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=12.7"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"*.js",
|
|
71
|
+
"*.d.ts"
|
|
72
|
+
],
|
|
73
|
+
"exports": {
|
|
74
|
+
".": {
|
|
75
|
+
"import": "./index.js"
|
|
76
|
+
},
|
|
77
|
+
"./abs": {
|
|
78
|
+
"import": "./abs.js"
|
|
79
|
+
},
|
|
80
|
+
"./angle": {
|
|
81
|
+
"import": "./angle.js"
|
|
82
|
+
},
|
|
83
|
+
"./api": {
|
|
84
|
+
"import": "./api.js"
|
|
85
|
+
},
|
|
86
|
+
"./crossing": {
|
|
87
|
+
"import": "./crossing.js"
|
|
88
|
+
},
|
|
89
|
+
"./eqdelta": {
|
|
90
|
+
"import": "./eqdelta.js"
|
|
91
|
+
},
|
|
92
|
+
"./extrema": {
|
|
93
|
+
"import": "./extrema.js"
|
|
94
|
+
},
|
|
95
|
+
"./fit": {
|
|
96
|
+
"import": "./fit.js"
|
|
97
|
+
},
|
|
98
|
+
"./int": {
|
|
99
|
+
"import": "./int.js"
|
|
100
|
+
},
|
|
101
|
+
"./interval": {
|
|
102
|
+
"import": "./interval.js"
|
|
103
|
+
},
|
|
104
|
+
"./libc": {
|
|
105
|
+
"import": "./libc.js"
|
|
106
|
+
},
|
|
107
|
+
"./min-error": {
|
|
108
|
+
"import": "./min-error.js"
|
|
109
|
+
},
|
|
110
|
+
"./mix": {
|
|
111
|
+
"import": "./mix.js"
|
|
112
|
+
},
|
|
113
|
+
"./prec": {
|
|
114
|
+
"import": "./prec.js"
|
|
115
|
+
},
|
|
116
|
+
"./prime": {
|
|
117
|
+
"import": "./prime.js"
|
|
118
|
+
},
|
|
119
|
+
"./ratio": {
|
|
120
|
+
"import": "./ratio.js"
|
|
121
|
+
},
|
|
122
|
+
"./safe-div": {
|
|
123
|
+
"import": "./safe-div.js"
|
|
124
|
+
},
|
|
125
|
+
"./solve": {
|
|
126
|
+
"import": "./solve.js"
|
|
127
|
+
},
|
|
128
|
+
"./step": {
|
|
129
|
+
"import": "./step.js"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"thi.ng": {
|
|
133
|
+
"year": 2013
|
|
134
|
+
},
|
|
135
|
+
"gitHead": "2db9dd34c0c2c60cbfde3dad0bca352b20292f5c\n"
|
|
136
|
+
}
|
package/prime.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns iterator of all prime numbers ≤ given `x` using Sieve of
|
|
3
|
+
* Eratosthenes.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Reference: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
|
|
7
|
+
*
|
|
8
|
+
* @param x
|
|
9
|
+
*/
|
|
10
|
+
export declare function primesUntil(x: number): Generator<number, void, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns largest prime number ≤ given `x` using Sieve of Eratosthenes. Returns
|
|
13
|
+
* -1 if x < 1.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Reference: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
|
|
17
|
+
*
|
|
18
|
+
* @param x
|
|
19
|
+
*/
|
|
20
|
+
export declare const nearestPrime: (x: number) => number;
|
|
21
|
+
//# sourceMappingURL=prime.d.ts.map
|
package/prime.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns iterator of all prime numbers ≤ given `x` using Sieve of
|
|
3
|
+
* Eratosthenes.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Reference: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
|
|
7
|
+
*
|
|
8
|
+
* @param x
|
|
9
|
+
*/
|
|
10
|
+
export function* primesUntil(x) {
|
|
11
|
+
if (x < 1)
|
|
12
|
+
return;
|
|
13
|
+
yield 1;
|
|
14
|
+
const sieve = [];
|
|
15
|
+
const max = Math.sqrt(x) | 0;
|
|
16
|
+
for (let i = 2; i <= x; i++) {
|
|
17
|
+
if (!sieve[i]) {
|
|
18
|
+
yield i;
|
|
19
|
+
__updateSieve(sieve, i, x, max);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns largest prime number ≤ given `x` using Sieve of Eratosthenes. Returns
|
|
25
|
+
* -1 if x < 1.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* Reference: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
|
|
29
|
+
*
|
|
30
|
+
* @param x
|
|
31
|
+
*/
|
|
32
|
+
export const nearestPrime = (x) => {
|
|
33
|
+
if (x < 1)
|
|
34
|
+
return -1;
|
|
35
|
+
let prime = 1;
|
|
36
|
+
const sieve = [];
|
|
37
|
+
const max = Math.sqrt(x) | 0;
|
|
38
|
+
for (let i = 2; i <= x; i++) {
|
|
39
|
+
if (!sieve[i]) {
|
|
40
|
+
prime = i;
|
|
41
|
+
__updateSieve(sieve, i, x, max);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return prime;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
const __updateSieve = (sieve, i, x, max) => {
|
|
50
|
+
if (i <= max) {
|
|
51
|
+
for (let j = i * i; j <= x; j += i)
|
|
52
|
+
sieve[j] = true;
|
|
53
|
+
}
|
|
54
|
+
};
|