ziko 0.54.5 → 0.56.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/ziko.cjs +298 -444
- package/dist/ziko.js +297 -626
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +297 -618
- package/package.json +1 -1
- package/src/math/--discret/index.js +12 -0
- package/src/math/complex/index.js +18 -12
- package/src/math/functions/conversions/index.js +61 -0
- package/src/math/functions/index.js +1 -1
- package/src/math/functions/signal/index.js +1 -1
- package/src/math/functions/stats/index.js +14 -2
- package/src/math/functions/utils/index.js +0 -58
- package/src/math/index.js +2 -2
- package/src/math/matrix/helpers/constructor.js +30 -0
- package/src/math/matrix/helpers/index.js +1 -0
- package/src/math/matrix/index.js +212 -176
- package/src/math/random/index.js +111 -155
- package/src/math/utils/conversions.js +17 -17
- package/src/math/utils/index.js +10 -10
- package/types/math/complex/index.d.ts +5 -5
- package/src/math/discret/Combinaison/index.js +0 -34
- package/src/math/discret/Conversion/index.js +0 -86
- package/src/math/discret/Permutation/index.js +0 -31
- package/src/math/discret/index.js +0 -12
- package/src/math/statistics/functions/index.js +0 -100
- package/src/math/statistics/index.js +0 -16
- /package/src/math/{discret → --discret}/Set/index.js +0 -0
- /package/src/math/{discret → --discret}/Set/power-set.js +0 -0
- /package/src/math/{discret → --discret}/Set/sub-set.js +0 -0
- /package/src/math/functions/{nested → ufunc}/index.js +0 -0
package/dist/ziko.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Sat Dec 13 2025 01:41:10 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -52,8 +52,280 @@
|
|
|
52
52
|
return fn(x)
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const base2base = (value, fromBase, toBase) => {
|
|
56
|
+
|
|
57
|
+
const dec = parseInt(value, fromBase);
|
|
58
|
+
if (Number.isNaN(dec)) throw new TypeError('Invalid value for the given base');
|
|
59
|
+
|
|
60
|
+
return dec.toString(toBase);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const _add = (x, y) =>{
|
|
64
|
+
if(typeof x === 'number'){
|
|
65
|
+
if(typeof y === 'number') return x + y;
|
|
66
|
+
if(y.isComplex?.()) {
|
|
67
|
+
return y.clone().add(x);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if(x.isComplex?.()){
|
|
71
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const _sub = (x, y) =>{
|
|
76
|
+
if(typeof x === 'number'){
|
|
77
|
+
if(typeof y === 'number') return x - y;
|
|
78
|
+
if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
|
|
79
|
+
}
|
|
80
|
+
if(x.isComplex?.()){
|
|
81
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const _mul = (x, y) =>{
|
|
86
|
+
if(typeof x === 'number'){
|
|
87
|
+
if(typeof y === 'number') return x * y;
|
|
88
|
+
if(y.isComplex?.()) return y.clone().mul(x);
|
|
89
|
+
}
|
|
90
|
+
if(x.isComplex?.()){
|
|
91
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const _div = (x, y) =>{
|
|
96
|
+
if(typeof x === 'number'){
|
|
97
|
+
if(typeof y === 'number') return x / y;
|
|
98
|
+
if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
|
|
99
|
+
}
|
|
100
|
+
if(x.isComplex?.()){
|
|
101
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const _modulo = (x, y) =>{
|
|
106
|
+
if(typeof x === 'number'){
|
|
107
|
+
if(typeof y === 'number') return x % y;
|
|
108
|
+
if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
|
|
109
|
+
}
|
|
110
|
+
if(x.isComplex?.()){
|
|
111
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const add=(a,...b)=>{
|
|
116
|
+
let res = a;
|
|
117
|
+
for(let i=0; i<b.length; i++)
|
|
118
|
+
res = _add(res, b[i]);
|
|
119
|
+
return res;
|
|
120
|
+
};
|
|
121
|
+
const sub=(a,...b)=>{
|
|
122
|
+
let res = a;
|
|
123
|
+
for(let i=0; i<b.length; i++)
|
|
124
|
+
res = _sub(res, b[i]);
|
|
125
|
+
return res;
|
|
126
|
+
};
|
|
127
|
+
const mul=(a,...b)=>{
|
|
128
|
+
let res = a;
|
|
129
|
+
for(let i=0; i<b.length; i++)
|
|
130
|
+
res = _mul(res, b[i]);
|
|
131
|
+
return res;
|
|
132
|
+
};
|
|
133
|
+
const div=(a,...b)=>{
|
|
134
|
+
let res = a;
|
|
135
|
+
for(let i=0; i<b.length; i++)
|
|
136
|
+
res = _div(res, b[i]);
|
|
137
|
+
return res;
|
|
138
|
+
};
|
|
139
|
+
const modulo=(a,...b)=>{
|
|
140
|
+
let res = a;
|
|
141
|
+
for(let i=0; i<b.length; i++)
|
|
142
|
+
res = _modulo(res, b[i]);
|
|
143
|
+
return res;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const min$1 = (...x) => Math.min(...x);
|
|
147
|
+
const max$1 = (...x) => Math.max(...x);
|
|
148
|
+
|
|
149
|
+
const binomial = (n, k) =>{
|
|
150
|
+
if(n !== Math.floor(n)) return TypeError('n must be an integer');
|
|
151
|
+
if(k !== Math.floor(k)) return TypeError('k must be an integer');
|
|
152
|
+
if (n < 0) return TypeError('n must be non-negative');
|
|
153
|
+
if (k < 0 || n < 0 || k > n) return 0;
|
|
154
|
+
if (k > n - k) k = n - k;
|
|
155
|
+
let c = 1, i;
|
|
156
|
+
for (i = 0; i < k; i++)
|
|
157
|
+
c = c * (n - i) / (i + 1);
|
|
158
|
+
return c;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
|
|
162
|
+
|
|
163
|
+
const variance = (...x) => {
|
|
164
|
+
const n = x.length;
|
|
165
|
+
if (n === 0) return NaN;
|
|
166
|
+
const x_mean = mean(...x);
|
|
167
|
+
return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / n;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const std = (...x) => Math.sqrt(variance(...x));
|
|
171
|
+
|
|
172
|
+
const accum_sum = (...x) => {
|
|
173
|
+
let result = [];
|
|
174
|
+
let total = 0, i, n = x.length;
|
|
175
|
+
for(i = 0; i < n ; i++){
|
|
176
|
+
total = add(total, x[i]);
|
|
177
|
+
result.push(total);
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const accum_prod = (...x) => {
|
|
183
|
+
let result = [];
|
|
184
|
+
let prod = 1, i, n = x.length;
|
|
185
|
+
for(i = 0; i < n ; i++){
|
|
186
|
+
prod = mul(prod, x[i]);
|
|
187
|
+
result.push(prod);
|
|
188
|
+
}
|
|
189
|
+
return result;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const percentile = (X, p) => {
|
|
193
|
+
if (X.length === 0)
|
|
194
|
+
return NaN;
|
|
195
|
+
let a = [...X].sort((x, y) => x - y);
|
|
196
|
+
let index = (p / 100) * (a.length - 1);
|
|
197
|
+
let i = Math.floor(index);
|
|
198
|
+
let f = index - i;
|
|
199
|
+
if (i === a.length - 1)
|
|
200
|
+
return a[i];
|
|
201
|
+
return a[i] * (1 - f) + a[i + 1] * f;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const median = X => percentile(X, 50);
|
|
205
|
+
|
|
206
|
+
class Random {
|
|
207
|
+
static int(a, b){
|
|
208
|
+
return Math.floor(this.float(a, b));
|
|
209
|
+
}
|
|
210
|
+
static float(a, b){
|
|
211
|
+
return b !== undefined
|
|
212
|
+
? Math.random() * (b - a) + a
|
|
213
|
+
: Math.random() * a;
|
|
214
|
+
}
|
|
215
|
+
static bin(){
|
|
216
|
+
return this.int(2);
|
|
217
|
+
}
|
|
218
|
+
static oct(){
|
|
219
|
+
return this.int(8);
|
|
220
|
+
}
|
|
221
|
+
static dec(){
|
|
222
|
+
return this.int(10);
|
|
223
|
+
}
|
|
224
|
+
static hex(){
|
|
225
|
+
return base2base(this.int(16), 10, 16);
|
|
226
|
+
}
|
|
227
|
+
static char(upperCase = false){
|
|
228
|
+
const i = upperCase
|
|
229
|
+
? this.int(65, 91)
|
|
230
|
+
: this.int(97, 123);
|
|
231
|
+
return String.fromCharCode(i);
|
|
232
|
+
}
|
|
233
|
+
static bool(){
|
|
234
|
+
return Boolean(this.int(2));
|
|
235
|
+
}
|
|
236
|
+
static get color(){
|
|
237
|
+
return {
|
|
238
|
+
hex : () =>
|
|
239
|
+
`#${this.int(0xffffff).toString(16).padStart(6, '0')}`,
|
|
240
|
+
|
|
241
|
+
hexa : () => {
|
|
242
|
+
const [r,g,b,a] = Array.from(
|
|
243
|
+
{length:4},
|
|
244
|
+
() => this.int(0xff).toString(16).padStart(2,'0')
|
|
245
|
+
);
|
|
246
|
+
return `#${r}${g}${b}${a}`;
|
|
247
|
+
},
|
|
248
|
+
rgb : () => {
|
|
249
|
+
const [r,g,b] = Array.from({length:3}, () => this.int(0xff));
|
|
250
|
+
return `rgb(${r}, ${g}, ${b})`;
|
|
251
|
+
},
|
|
252
|
+
rgba : () => {
|
|
253
|
+
const [r,g,b] = Array.from({length:3}, () => this.int(0xff));
|
|
254
|
+
const a = Math.random().toFixed(2);
|
|
255
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
256
|
+
},
|
|
257
|
+
hsl : () => {
|
|
258
|
+
const h = this.int(360);
|
|
259
|
+
const s = this.int(100);
|
|
260
|
+
const l = this.int(100);
|
|
261
|
+
return `hsl(${h}, ${s}%, ${l}%)`;
|
|
262
|
+
},
|
|
263
|
+
hsla : () => {
|
|
264
|
+
const h = this.int(360);
|
|
265
|
+
const s = this.int(100);
|
|
266
|
+
const l = this.int(100);
|
|
267
|
+
const a = Math.random().toFixed(2);
|
|
268
|
+
return `hsla(${h}, ${s}%, ${l}%, ${a})`;
|
|
269
|
+
},
|
|
270
|
+
gray : () => {
|
|
271
|
+
const g = this.int(0xff);
|
|
272
|
+
return `rgb(${g}, ${g}, ${g})`;
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
static get sample(){
|
|
277
|
+
const R = this;
|
|
278
|
+
return {
|
|
279
|
+
int : (n,a,b) => Array.from({length:n}, () => R.int(a,b)),
|
|
280
|
+
float : (n,a,b) => Array.from({length:n}, () => R.float(a,b)),
|
|
281
|
+
char : (n,upper=false) => Array.from({length:n}, () => R.char(upper)),
|
|
282
|
+
bool : n => Array.from({length:n}, () => R.bool()),
|
|
283
|
+
bin : n => Array.from({length:n}, () => R.bin()),
|
|
284
|
+
oct : n => Array.from({length:n}, () => R.oct()),
|
|
285
|
+
dec : n => Array.from({length:n}, () => R.dec()),
|
|
286
|
+
hex : n => Array.from({length:n}, () => R.hex()),
|
|
287
|
+
get color(){
|
|
288
|
+
return {
|
|
289
|
+
hex : n => Array.from({length:n}, () => R.color.hex()),
|
|
290
|
+
hexa : n => Array.from({length:n}, () => R.color.hexa()),
|
|
291
|
+
rgb : n => Array.from({length:n}, () => R.color.rgb()),
|
|
292
|
+
rgba : n => Array.from({length:n}, () => R.color.rgba()),
|
|
293
|
+
hsl : n => Array.from({length:n}, () => R.color.hsl()),
|
|
294
|
+
hsla : n => Array.from({length:n}, () => R.color.hsla()),
|
|
295
|
+
gray : n => Array.from({length:n}, () => R.color.gray())
|
|
296
|
+
};
|
|
297
|
+
},
|
|
298
|
+
choice : (n, choices, p) =>
|
|
299
|
+
Array.from({length:n}, () => R.choice(choices, p))
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
static shuffle(arr){
|
|
303
|
+
return [...arr].sort(() => 0.5 - Math.random());
|
|
304
|
+
}
|
|
305
|
+
static choice(choices = [1,2,3], p = new Array(choices.length).fill(1 / choices.length)){
|
|
306
|
+
const acc = accum_sum(...p).map(v => v * 100);
|
|
307
|
+
const pool = new Array(100);
|
|
308
|
+
pool.fill(choices[0], 0, acc[0]);
|
|
309
|
+
for(let i=1;i<choices.length;i++)
|
|
310
|
+
pool.fill(choices[i], acc[i-1], acc[i]);
|
|
311
|
+
return pool[this.int(pool.length)];
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
globalThis.Random = Random;
|
|
317
|
+
|
|
318
|
+
// // (upperCase) => upperCase ? : String.fromCharCode(rand_int(97,120))
|
|
319
|
+
// class Random {
|
|
320
|
+
// static string(length,upperCase){
|
|
321
|
+
// return length instanceof Array?
|
|
322
|
+
// new Array(this.int(...length)).fill(0).map(() => this.char(upperCase)).join(""):
|
|
323
|
+
// new Array(length).fill(0).map(() => this.char(upperCase)).join("");
|
|
324
|
+
// }
|
|
325
|
+
|
|
326
|
+
// }
|
|
327
|
+
// export{Random}
|
|
328
|
+
|
|
57
329
|
class Complex{
|
|
58
330
|
constructor(a = 0, b = 0) {
|
|
59
331
|
if(a instanceof Complex){
|
|
@@ -131,6 +403,12 @@
|
|
|
131
403
|
static Zero() {
|
|
132
404
|
return new Complex(0, 0);
|
|
133
405
|
}
|
|
406
|
+
static get Random(){
|
|
407
|
+
return {
|
|
408
|
+
int : (a, b)=> new Complex(...Random.sample.int(2, a, b) ),
|
|
409
|
+
float : (a, b)=> new Complex(...Random.sample.float(2, a, b) ),
|
|
410
|
+
}
|
|
411
|
+
}
|
|
134
412
|
static Twiddle(N, K){
|
|
135
413
|
const phi = -2 * Math.PI * K / N;
|
|
136
414
|
return new Complex(
|
|
@@ -631,89 +909,6 @@
|
|
|
631
909
|
...x
|
|
632
910
|
);
|
|
633
911
|
|
|
634
|
-
const _add = (x, y) =>{
|
|
635
|
-
if(typeof x === 'number'){
|
|
636
|
-
if(typeof y === 'number') return x + y;
|
|
637
|
-
if(y.isComplex?.()) {
|
|
638
|
-
return y.clone().add(x);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
if(x.isComplex?.()){
|
|
642
|
-
if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
|
|
646
|
-
const _sub = (x, y) =>{
|
|
647
|
-
if(typeof x === 'number'){
|
|
648
|
-
if(typeof y === 'number') return x - y;
|
|
649
|
-
if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
|
|
650
|
-
}
|
|
651
|
-
if(x.isComplex?.()){
|
|
652
|
-
if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
|
|
653
|
-
}
|
|
654
|
-
};
|
|
655
|
-
|
|
656
|
-
const _mul = (x, y) =>{
|
|
657
|
-
if(typeof x === 'number'){
|
|
658
|
-
if(typeof y === 'number') return x * y;
|
|
659
|
-
if(y.isComplex?.()) return y.clone().mul(x);
|
|
660
|
-
}
|
|
661
|
-
if(x.isComplex?.()){
|
|
662
|
-
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
const _div = (x, y) =>{
|
|
667
|
-
if(typeof x === 'number'){
|
|
668
|
-
if(typeof y === 'number') return x / y;
|
|
669
|
-
if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
|
|
670
|
-
}
|
|
671
|
-
if(x.isComplex?.()){
|
|
672
|
-
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
const _modulo = (x, y) =>{
|
|
677
|
-
if(typeof x === 'number'){
|
|
678
|
-
if(typeof y === 'number') return x % y;
|
|
679
|
-
if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
|
|
680
|
-
}
|
|
681
|
-
if(x.isComplex?.()){
|
|
682
|
-
if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
|
|
686
|
-
const add=(a,...b)=>{
|
|
687
|
-
let res = a;
|
|
688
|
-
for(let i=0; i<b.length; i++)
|
|
689
|
-
res = _add(res, b[i]);
|
|
690
|
-
return res;
|
|
691
|
-
};
|
|
692
|
-
const sub=(a,...b)=>{
|
|
693
|
-
let res = a;
|
|
694
|
-
for(let i=0; i<b.length; i++)
|
|
695
|
-
res = _sub(res, b[i]);
|
|
696
|
-
return res;
|
|
697
|
-
};
|
|
698
|
-
const mul=(a,...b)=>{
|
|
699
|
-
let res = a;
|
|
700
|
-
for(let i=0; i<b.length; i++)
|
|
701
|
-
res = _mul(res, b[i]);
|
|
702
|
-
return res;
|
|
703
|
-
};
|
|
704
|
-
const div=(a,...b)=>{
|
|
705
|
-
let res = a;
|
|
706
|
-
for(let i=0; i<b.length; i++)
|
|
707
|
-
res = _div(res, b[i]);
|
|
708
|
-
return res;
|
|
709
|
-
};
|
|
710
|
-
const modulo=(a,...b)=>{
|
|
711
|
-
let res = a;
|
|
712
|
-
for(let i=0; i<b.length; i++)
|
|
713
|
-
res = _modulo(res, b[i]);
|
|
714
|
-
return res;
|
|
715
|
-
};
|
|
716
|
-
|
|
717
912
|
const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
|
|
718
913
|
const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
|
|
719
914
|
|
|
@@ -734,64 +929,6 @@
|
|
|
734
929
|
v => lerp(norm(v, a, b), c, d)
|
|
735
930
|
);
|
|
736
931
|
|
|
737
|
-
|
|
738
|
-
// export const norm = (x, min, max) => {
|
|
739
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
740
|
-
// norm(x.a, min, max),
|
|
741
|
-
// norm(x.b, min, max)
|
|
742
|
-
// )
|
|
743
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
744
|
-
// x.rows,
|
|
745
|
-
// x.cols,
|
|
746
|
-
// norm(x.arr.flat(1), min, max)
|
|
747
|
-
// );
|
|
748
|
-
// if(x instanceof Array) return mapfun(n => norm(n, min, max), ...x);
|
|
749
|
-
// return min !== max ? (x - min) / (max - min) : 0;
|
|
750
|
-
// }
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
// export const lerp = (x, min, max) => {
|
|
754
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
755
|
-
// lerp(x.a, min, max),
|
|
756
|
-
// lerp(x.b, min, max)
|
|
757
|
-
// )
|
|
758
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
759
|
-
// x.rows,
|
|
760
|
-
// x.cols,
|
|
761
|
-
// lerp(x.arr.flat(1), min, max)
|
|
762
|
-
// );
|
|
763
|
-
// if(x instanceof Array) return mapfun(n => lerp(n, min, max), ...x);
|
|
764
|
-
// return (max - min) * x + min;
|
|
765
|
-
// }
|
|
766
|
-
|
|
767
|
-
// export const map = (x, a, b, c, d) => {
|
|
768
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
769
|
-
// map(x.a, a, b, c, d),
|
|
770
|
-
// map(x.b, a, b, c, d)
|
|
771
|
-
// )
|
|
772
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
773
|
-
// x.rows,
|
|
774
|
-
// x.cols,
|
|
775
|
-
// map(x.arr.flat(1), a, b, c, d)
|
|
776
|
-
// );
|
|
777
|
-
// if(x instanceof Array) return mapfun(n => map(n, a, b, c, d), ...x);
|
|
778
|
-
// return lerp(norm(x, a, b), c, d);
|
|
779
|
-
// }
|
|
780
|
-
|
|
781
|
-
// export const clamp = (x, min, max) => {
|
|
782
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
783
|
-
// clamp(x.a, min, max),
|
|
784
|
-
// clamp(x.b, min, max)
|
|
785
|
-
// )
|
|
786
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
787
|
-
// x.rows,
|
|
788
|
-
// x.cols,
|
|
789
|
-
// clamp(x.arr.flat(1), min, max)
|
|
790
|
-
// );
|
|
791
|
-
// if(x instanceof Array) return mapfun(n => clamp(n, min, max), ...x);
|
|
792
|
-
// return Math.min(Math.max(x, min), max)
|
|
793
|
-
// }
|
|
794
|
-
|
|
795
932
|
const hypot = (...x) => {
|
|
796
933
|
const c0 = x.find(a => a.isComplex?.());
|
|
797
934
|
if (c0) {
|
|
@@ -816,54 +953,6 @@
|
|
|
816
953
|
return rad ? phi : phi * 180 / Math.PI;
|
|
817
954
|
};
|
|
818
955
|
|
|
819
|
-
const min$1 = (...x) => Math.min(...x);
|
|
820
|
-
const max$1 = (...x) => Math.max(...x);
|
|
821
|
-
|
|
822
|
-
const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
|
|
823
|
-
|
|
824
|
-
const variance = (...x) => {
|
|
825
|
-
const n = x.length;
|
|
826
|
-
if (n === 0) return NaN;
|
|
827
|
-
const x_mean = mean(...x);
|
|
828
|
-
return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / n;
|
|
829
|
-
};
|
|
830
|
-
|
|
831
|
-
const std = (...x) => Math.sqrt(variance(...x));
|
|
832
|
-
|
|
833
|
-
const accum_sum = (...x) => {
|
|
834
|
-
let result = [];
|
|
835
|
-
let total = 0, i; n = x.length;
|
|
836
|
-
for(i = 0; i < n ; i++){
|
|
837
|
-
total = add(total, x[i]);
|
|
838
|
-
result.push(total);
|
|
839
|
-
}
|
|
840
|
-
return result;
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
const accum_prod = (...x) => {
|
|
844
|
-
let result = [];
|
|
845
|
-
let prod = 1, i; n = x.length;
|
|
846
|
-
for(i = 0; i < n ; i++){
|
|
847
|
-
prod = mul(prod, x[i]);
|
|
848
|
-
result.push(prod);
|
|
849
|
-
}
|
|
850
|
-
return result;
|
|
851
|
-
};
|
|
852
|
-
|
|
853
|
-
const percentile = (X, p) => {
|
|
854
|
-
if (X.length === 0)
|
|
855
|
-
return NaN;
|
|
856
|
-
let a = [...X].sort((x, y) => x - y);
|
|
857
|
-
let index = (p / 100) * (a.length - 1);
|
|
858
|
-
let i = Math.floor(index);
|
|
859
|
-
let f = index - i;
|
|
860
|
-
if (i === a.length - 1)
|
|
861
|
-
return a[i];
|
|
862
|
-
return a[i] * (1 - f) + a[i + 1] * f;
|
|
863
|
-
};
|
|
864
|
-
|
|
865
|
-
const median = X => percentile(X, 50);
|
|
866
|
-
|
|
867
956
|
const not = x => {
|
|
868
957
|
if(x.isComplex?.()) return new x.constructor(not(x.a), not(x.b))
|
|
869
958
|
if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, x.arr.flat(1).map(not))
|
|
@@ -3520,6 +3609,7 @@
|
|
|
3520
3609
|
get inv() {
|
|
3521
3610
|
return matrix_inverse(this)
|
|
3522
3611
|
}
|
|
3612
|
+
// normalize names
|
|
3523
3613
|
static eye(size) {
|
|
3524
3614
|
let result = new Matrix(size, size);
|
|
3525
3615
|
for (let i = 0; i < size; i++)
|
|
@@ -3544,6 +3634,20 @@
|
|
|
3544
3634
|
for (let j = 0; j < cols; j++) result.arr[i][j] = number;
|
|
3545
3635
|
return result;
|
|
3546
3636
|
}
|
|
3637
|
+
static get Random(){
|
|
3638
|
+
return {
|
|
3639
|
+
int : (r, c, a, b)=> new Matrix(
|
|
3640
|
+
r,
|
|
3641
|
+
c,
|
|
3642
|
+
Random.sample.int(r*c, a, b)
|
|
3643
|
+
),
|
|
3644
|
+
float : (r, c, a,)=> new Matrix(
|
|
3645
|
+
r,
|
|
3646
|
+
c,
|
|
3647
|
+
Random.sample.float(r*c, a, b)
|
|
3648
|
+
),
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3547
3651
|
hstack(...matrices) {
|
|
3548
3652
|
const M=[this, ...matrices].reduce((a,b)=>hstack(a, b));
|
|
3549
3653
|
Object.assign(this, M);
|
|
@@ -3998,21 +4102,6 @@
|
|
|
3998
4102
|
const matrix3=(...element)=>new Matrix(3, 3, element);
|
|
3999
4103
|
const matrix4=(...element)=>new Matrix(4, 4, element);
|
|
4000
4104
|
|
|
4001
|
-
const powerSet=originalSet=>{
|
|
4002
|
-
const subSets = [];
|
|
4003
|
-
const NUMBER_OF_COMBINATIONS = 2 ** originalSet.length;
|
|
4004
|
-
for (let i = 0; i < NUMBER_OF_COMBINATIONS; i += 1) {
|
|
4005
|
-
const subSet = [];
|
|
4006
|
-
for (let j = 0; j < originalSet.length; j += 1) {
|
|
4007
|
-
if (i & (1 << j)) {
|
|
4008
|
-
subSet.push(originalSet[j]);
|
|
4009
|
-
}
|
|
4010
|
-
}
|
|
4011
|
-
subSets.push(subSet);
|
|
4012
|
-
}
|
|
4013
|
-
return subSets;
|
|
4014
|
-
};
|
|
4015
|
-
|
|
4016
4105
|
const zeros=(n)=>new Array(n).fill(0);
|
|
4017
4106
|
const ones=(n)=>new Array(n).fill(1);
|
|
4018
4107
|
const nums=(num,n)=>new Array(n).fill(num);
|
|
@@ -4081,97 +4170,6 @@
|
|
|
4081
4170
|
}
|
|
4082
4171
|
};
|
|
4083
4172
|
|
|
4084
|
-
// Mixed calcul
|
|
4085
|
-
const sum=(...x)=>{
|
|
4086
|
-
if(x.every(n=>typeof n==="number")){
|
|
4087
|
-
let s = x[0];
|
|
4088
|
-
for (let i = 1; i < x.length; i++) s += x[i];
|
|
4089
|
-
return s;
|
|
4090
|
-
}
|
|
4091
|
-
const Y=[];
|
|
4092
|
-
for(let i=0;i<x.length;i++){
|
|
4093
|
-
if(x[i] instanceof Array)Y.push(sum(...x[i]));
|
|
4094
|
-
else if(x[i] instanceof Object){
|
|
4095
|
-
Y.push(sum(...Object.values(x[i])));
|
|
4096
|
-
}
|
|
4097
|
-
}
|
|
4098
|
-
return Y.length===1?Y[0]:Y;
|
|
4099
|
-
};
|
|
4100
|
-
const prod=(...x)=>{
|
|
4101
|
-
if(x.every(n=>typeof n==="number")){
|
|
4102
|
-
let p = x[0];
|
|
4103
|
-
for (let i = 1; i < x.length; i++) p *= x[i];
|
|
4104
|
-
return p;
|
|
4105
|
-
}
|
|
4106
|
-
const Y=[];
|
|
4107
|
-
for(let i=0;i<x.length;i++){
|
|
4108
|
-
if(x[i] instanceof Array)Y.push(prod(...x[i]));
|
|
4109
|
-
else if(x[i] instanceof Object){
|
|
4110
|
-
Y.push(prod(...Object.values(x[i])));
|
|
4111
|
-
}
|
|
4112
|
-
}
|
|
4113
|
-
return Y.length===1?Y[0]:Y;
|
|
4114
|
-
};
|
|
4115
|
-
// const min=(...num)=>{
|
|
4116
|
-
// if(num.every(n=>typeof n==="number"))return Math.min(...num);
|
|
4117
|
-
// const Y=[];
|
|
4118
|
-
// for(let i=0;i<num.length;i++){
|
|
4119
|
-
// if(num[i] instanceof Array)Y.push(min(...num[i]));
|
|
4120
|
-
// else if(num[i] instanceof Object){
|
|
4121
|
-
// Y.push(
|
|
4122
|
-
// Object.fromEntries(
|
|
4123
|
-
// [Object.entries(num[i]).sort((a,b)=>a[1]-b[1])[0]]
|
|
4124
|
-
// )
|
|
4125
|
-
// )
|
|
4126
|
-
// }
|
|
4127
|
-
// }
|
|
4128
|
-
// return Y.length===1?Y[0]:Y;
|
|
4129
|
-
// }
|
|
4130
|
-
// const max=(...num)=>{
|
|
4131
|
-
// if(num.every(n=>typeof n==="number"))return Math.max(...num);
|
|
4132
|
-
// const Y=[];
|
|
4133
|
-
// for(let i=0;i<num.length;i++){
|
|
4134
|
-
// if(num[i] instanceof Array)Y.push(min(...num[i]));
|
|
4135
|
-
// else if(num[i] instanceof Object){
|
|
4136
|
-
// Y.push(
|
|
4137
|
-
// Object.fromEntries(
|
|
4138
|
-
// [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
|
|
4139
|
-
// )
|
|
4140
|
-
// )
|
|
4141
|
-
// }
|
|
4142
|
-
// }
|
|
4143
|
-
// return Y.length===1?Y[0]:Y;
|
|
4144
|
-
// }
|
|
4145
|
-
const accum=(...num)=>{
|
|
4146
|
-
if(num.every(n=>typeof n==="number")){
|
|
4147
|
-
let acc = num.reduce((x, y) => [...x, x[x.length - 1] + y], [0]);
|
|
4148
|
-
acc.shift();
|
|
4149
|
-
return acc;
|
|
4150
|
-
}
|
|
4151
|
-
const Y=[];
|
|
4152
|
-
for(let i=0;i<num.length;i++){
|
|
4153
|
-
if(num[i] instanceof Array)Y.push(accum(...num[i]));
|
|
4154
|
-
else if(num[i] instanceof Object){
|
|
4155
|
-
Y.push(null
|
|
4156
|
-
// Object.fromEntries(
|
|
4157
|
-
// [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
|
|
4158
|
-
// )
|
|
4159
|
-
);
|
|
4160
|
-
}
|
|
4161
|
-
}
|
|
4162
|
-
return Y.length===1?Y[0]:Y;
|
|
4163
|
-
};
|
|
4164
|
-
|
|
4165
|
-
//moy
|
|
4166
|
-
//med
|
|
4167
|
-
//variance
|
|
4168
|
-
//std
|
|
4169
|
-
//mode
|
|
4170
|
-
//acccum
|
|
4171
|
-
//min2max
|
|
4172
|
-
//max2min
|
|
4173
|
-
//percentile
|
|
4174
|
-
|
|
4175
4173
|
/** @module Math */
|
|
4176
4174
|
/**
|
|
4177
4175
|
* Checks if a value is within the specified range.
|
|
@@ -4284,325 +4282,6 @@
|
|
|
4284
4282
|
isApproximatlyEqual
|
|
4285
4283
|
};
|
|
4286
4284
|
|
|
4287
|
-
// const subSet = (...arr) => {
|
|
4288
|
-
// let list = arange(0, 2 ** arr.length, 1);
|
|
4289
|
-
// let bin = list.map((n) => n.toString(2).padStart(arr.length, '0')).map((n) => n.split("").map((n) => +n));
|
|
4290
|
-
// let sub = bin.map((n) => n.map((m, i) => (m === 1 ? arr[i] : null))).map((n) => n.filter((x) => x !== null));
|
|
4291
|
-
// return sub;
|
|
4292
|
-
// };
|
|
4293
|
-
const subSet = null;
|
|
4294
|
-
|
|
4295
|
-
const Base={
|
|
4296
|
-
_mode:Number,
|
|
4297
|
-
_map:function(func,number,toBase){
|
|
4298
|
-
if (number instanceof Matrix)
|
|
4299
|
-
return new Matrix(
|
|
4300
|
-
number.rows,
|
|
4301
|
-
number.cols,
|
|
4302
|
-
number.arr.flat(1).map(n=>func(n,toBase))
|
|
4303
|
-
);
|
|
4304
|
-
else if (number instanceof Complex) return new Complex(func(number.a,toBase),func(number.b,toBase));
|
|
4305
|
-
else if (number instanceof Array) return number.map((n) =>func(n,toBase));
|
|
4306
|
-
},
|
|
4307
|
-
dec2base(dec,base){
|
|
4308
|
-
base<=10?this._mode=Number:this._mode=String;
|
|
4309
|
-
//this._mode=String
|
|
4310
|
-
if (typeof dec === "number") return this._mode((dec >>> 0).toString(base));
|
|
4311
|
-
return this._map(this.dec2base,dec,base)
|
|
4312
|
-
},
|
|
4313
|
-
dec2bin(dec){
|
|
4314
|
-
return this.dec2base(dec,2);
|
|
4315
|
-
},
|
|
4316
|
-
dec2oct(dec){
|
|
4317
|
-
return this.dec2base(dec,8);
|
|
4318
|
-
},
|
|
4319
|
-
dec2hex(dec){
|
|
4320
|
-
return this.dec2base(dec,16);
|
|
4321
|
-
},
|
|
4322
|
-
bin2base(bin, base) {
|
|
4323
|
-
return this.dec2base(this.bin2dec(bin),base)
|
|
4324
|
-
},
|
|
4325
|
-
bin2dec(bin){
|
|
4326
|
-
return this._mode("0b"+bin);
|
|
4327
|
-
},
|
|
4328
|
-
bin2oct(bin){
|
|
4329
|
-
return this.bin2base(bin,8);
|
|
4330
|
-
},
|
|
4331
|
-
bin2hex(bin){
|
|
4332
|
-
return this.bin2base(bin,16);
|
|
4333
|
-
},
|
|
4334
|
-
oct2dec(oct){
|
|
4335
|
-
return this._mode("0o"+oct);
|
|
4336
|
-
},
|
|
4337
|
-
oct2bin(oct){
|
|
4338
|
-
return this.dec2bin(this.oct2dec(oct))
|
|
4339
|
-
},
|
|
4340
|
-
oct2hex(oct){
|
|
4341
|
-
return this.dec2hex(this.oct2dec(oct))
|
|
4342
|
-
},
|
|
4343
|
-
oct2base(oct, base) {
|
|
4344
|
-
return this.dec2base(this.oct2dec(oct),base)
|
|
4345
|
-
},
|
|
4346
|
-
hex2dec(hex){
|
|
4347
|
-
return this._mode("0x"+hex);
|
|
4348
|
-
},
|
|
4349
|
-
hex2bin(hex){
|
|
4350
|
-
return this.dec2bin(this.hex2dec(hex))
|
|
4351
|
-
},
|
|
4352
|
-
hex2oct(hex){
|
|
4353
|
-
return this.dec2oct(this.hex2dec(hex))
|
|
4354
|
-
},
|
|
4355
|
-
hex2base(hex, base) {
|
|
4356
|
-
return this.dec2base(this.hex2dec(hex),base)
|
|
4357
|
-
},
|
|
4358
|
-
IEEE32toDec(Bin){
|
|
4359
|
-
let IEEE32=Bin.split(" ").join("").padEnd(32,"0");
|
|
4360
|
-
let s=IEEE32[0];
|
|
4361
|
-
let e=2**(+("0b"+IEEE32.slice(1,9))-127);
|
|
4362
|
-
let m=IEEE32.slice(9,32).split("").map(n=>+n);
|
|
4363
|
-
let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
|
|
4364
|
-
let dec=(-1)**s*(1+M)*e;
|
|
4365
|
-
return dec
|
|
4366
|
-
},
|
|
4367
|
-
IEEE64toDec(Bin){
|
|
4368
|
-
let IEEE64=Bin.split(" ").join("").padEnd(64,"0");
|
|
4369
|
-
let s=IEEE64[0];
|
|
4370
|
-
let e=2**(+("0b"+IEEE64.slice(1,12))-1023);
|
|
4371
|
-
let m=IEEE64.slice(13,64).split("").map(n=>+n);
|
|
4372
|
-
let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
|
|
4373
|
-
let dec=(-1)**s*(1+M)*e;
|
|
4374
|
-
return dec;
|
|
4375
|
-
}
|
|
4376
|
-
};
|
|
4377
|
-
|
|
4378
|
-
class Permutation {
|
|
4379
|
-
static withDiscount(arr, l = arr.length) {
|
|
4380
|
-
if (l === 1) return arr.map((n) => [n]);
|
|
4381
|
-
const permutations = [];
|
|
4382
|
-
let smallerPermutations;
|
|
4383
|
-
smallerPermutations = this.withDiscount(arr, l - 1);
|
|
4384
|
-
arr.forEach((currentOption) => {
|
|
4385
|
-
smallerPermutations.forEach((smallerPermutation) => {
|
|
4386
|
-
permutations.push([currentOption].concat(smallerPermutation));
|
|
4387
|
-
});
|
|
4388
|
-
});
|
|
4389
|
-
return permutations;
|
|
4390
|
-
}
|
|
4391
|
-
static withoutDiscount(arr) {
|
|
4392
|
-
const l = arr.length;
|
|
4393
|
-
if (l === 1) return arr.map((n) => [n]);
|
|
4394
|
-
const permutations = [];
|
|
4395
|
-
const smallerPermutations = this.withoutDiscount(arr.slice(1));
|
|
4396
|
-
const firstOption = arr[0];
|
|
4397
|
-
for (let i = 0; i < smallerPermutations.length; i++) {
|
|
4398
|
-
const smallerPermutation = smallerPermutations[i];
|
|
4399
|
-
for (let j = 0; j <= smallerPermutation.length; j++) {
|
|
4400
|
-
const permutationPrefix = smallerPermutation.slice(0, j);
|
|
4401
|
-
const permutationSuffix = smallerPermutation.slice(j);
|
|
4402
|
-
permutations.push(permutationPrefix.concat([firstOption], permutationSuffix));
|
|
4403
|
-
}
|
|
4404
|
-
}
|
|
4405
|
-
return permutations;
|
|
4406
|
-
}
|
|
4407
|
-
}
|
|
4408
|
-
|
|
4409
|
-
class Combinaison {
|
|
4410
|
-
static withDiscount(comboOptions, comboLength) {
|
|
4411
|
-
if (comboLength === 1) {
|
|
4412
|
-
return comboOptions.map((comboOption) => [comboOption]);
|
|
4413
|
-
}
|
|
4414
|
-
const combos = [];
|
|
4415
|
-
comboOptions.forEach((currentOption, optionIndex) => {
|
|
4416
|
-
const smallerCombos = this.withDiscount(comboOptions.slice(optionIndex), comboLength - 1);
|
|
4417
|
-
smallerCombos.forEach((smallerCombo) => {
|
|
4418
|
-
combos.push([currentOption].concat(smallerCombo));
|
|
4419
|
-
});
|
|
4420
|
-
});
|
|
4421
|
-
return combos;
|
|
4422
|
-
}
|
|
4423
|
-
static withoutDiscount(comboOptions, comboLength) {
|
|
4424
|
-
if (comboLength === 1) {
|
|
4425
|
-
return comboOptions.map((comboOption) => [comboOption]);
|
|
4426
|
-
}
|
|
4427
|
-
const combos = [];
|
|
4428
|
-
comboOptions.forEach((currentOption, optionIndex) => {
|
|
4429
|
-
const smallerCombos = this.withoutDiscount(comboOptions.slice(optionIndex + 1), comboLength - 1);
|
|
4430
|
-
smallerCombos.forEach((smallerCombo) => {
|
|
4431
|
-
combos.push([currentOption].concat(smallerCombo));
|
|
4432
|
-
});
|
|
4433
|
-
});
|
|
4434
|
-
|
|
4435
|
-
return combos;
|
|
4436
|
-
}
|
|
4437
|
-
}
|
|
4438
|
-
const combinaison=(comboOptions, comboLength, discount=false)=>Combinaison[discount?"withDiscount":"withoutDiscount"](comboOptions, comboLength);
|
|
4439
|
-
|
|
4440
|
-
class Random {
|
|
4441
|
-
static float(a = 1, b) {
|
|
4442
|
-
return b ? Math.random() * (b - a) + a : a * Math.random();
|
|
4443
|
-
}
|
|
4444
|
-
static int(a, b) {
|
|
4445
|
-
return Math.floor(this.float(a, b));
|
|
4446
|
-
}
|
|
4447
|
-
static char(upperCase){
|
|
4448
|
-
upperCase=upperCase??this.bool();
|
|
4449
|
-
const Char=String.fromCharCode(this.int(97,120));
|
|
4450
|
-
return upperCase?Char.toUpperCase():Char;
|
|
4451
|
-
}
|
|
4452
|
-
static bool(){
|
|
4453
|
-
return [false,true][Math.floor(Math.random()*2)];
|
|
4454
|
-
}
|
|
4455
|
-
static string(length,upperCase){
|
|
4456
|
-
return length instanceof Array?
|
|
4457
|
-
new Array(this.int(...length)).fill(0).map(() => this.char(upperCase)).join(""):
|
|
4458
|
-
new Array(length).fill(0).map(() => this.char(upperCase)).join("");
|
|
4459
|
-
}
|
|
4460
|
-
static bin() {
|
|
4461
|
-
return this.int(2);
|
|
4462
|
-
}
|
|
4463
|
-
static oct() {
|
|
4464
|
-
return this.int(8);
|
|
4465
|
-
}
|
|
4466
|
-
static dec() {
|
|
4467
|
-
return this.int(8);
|
|
4468
|
-
}
|
|
4469
|
-
static hex() {
|
|
4470
|
-
return this.int(16);
|
|
4471
|
-
}
|
|
4472
|
-
static choice(choices = [1, 2, 3], p = new Array(choices.length).fill(1 / choices.length)) {
|
|
4473
|
-
let newchoice = new Array(100);
|
|
4474
|
-
p=Utils.accum(...p).map(n=>n*100);
|
|
4475
|
-
newchoice.fill(choices[0], 0, p[0]);
|
|
4476
|
-
for (let i = 1; i < choices.length; i++) newchoice.fill(choices[i], p[i - 1], p[i]);
|
|
4477
|
-
return newchoice[this.int(newchoice.length - 1)];
|
|
4478
|
-
}
|
|
4479
|
-
static shuffleArr(arr){
|
|
4480
|
-
return arr.sort(()=>0.5-Math.random())
|
|
4481
|
-
}
|
|
4482
|
-
static floats(n, a, b) {
|
|
4483
|
-
return new Array(n).fill(0).map(() => this.float(a, b));
|
|
4484
|
-
}
|
|
4485
|
-
static ints(n, a, b) {
|
|
4486
|
-
return new Array(n).fill(0).map(() => this.int(a, b));
|
|
4487
|
-
}
|
|
4488
|
-
static bools(n){
|
|
4489
|
-
return new Array(n).fill(0).map(() => this.bool());
|
|
4490
|
-
}
|
|
4491
|
-
static bins(n) {
|
|
4492
|
-
return new Array(n).fill(0).map(() => this.int(2));
|
|
4493
|
-
}
|
|
4494
|
-
static octs(n) {
|
|
4495
|
-
return new Array(n).fill(0).map(() => this.int(8));
|
|
4496
|
-
}
|
|
4497
|
-
static decs(n) {
|
|
4498
|
-
return new Array(n).fill(0).map(() => this.int(10));
|
|
4499
|
-
}
|
|
4500
|
-
static hexs(n) {
|
|
4501
|
-
return new Array(n).fill(0).map(() => this.int(16));
|
|
4502
|
-
}
|
|
4503
|
-
static choices(n, choices, p) {
|
|
4504
|
-
return new Array(n).fill(0).map(() => this.choice(choices, p));
|
|
4505
|
-
}
|
|
4506
|
-
static perm(...arr) {
|
|
4507
|
-
// permutation
|
|
4508
|
-
return arr.permS[this.int(arr.length)];
|
|
4509
|
-
}
|
|
4510
|
-
static color() {
|
|
4511
|
-
return "#" + Base.dec2hex(this.float(16777216)).padStart(6,0);
|
|
4512
|
-
}
|
|
4513
|
-
static colors(n) {
|
|
4514
|
-
return new Array(n).fill(null).map(()=>this.color());
|
|
4515
|
-
}
|
|
4516
|
-
|
|
4517
|
-
// Should be Moved to Matrix and Complex to avoid Circular dependencies
|
|
4518
|
-
// static complex(a = [0,1], b = [0,1]) {
|
|
4519
|
-
// return a instanceof Array?
|
|
4520
|
-
// new Complex(
|
|
4521
|
-
// this.float(a[0], a[1]),
|
|
4522
|
-
// this.float(b[0], b[1])
|
|
4523
|
-
// ):
|
|
4524
|
-
// new Complex(
|
|
4525
|
-
// ...this.floats(2,a,b)
|
|
4526
|
-
// )
|
|
4527
|
-
|
|
4528
|
-
// }
|
|
4529
|
-
// static complexInt(a = [0,1], b = [0,1]) {
|
|
4530
|
-
// return new Complex(
|
|
4531
|
-
// this.int(a[0], a[1]),
|
|
4532
|
-
// this.int(b[0], b[1])
|
|
4533
|
-
// );
|
|
4534
|
-
// }
|
|
4535
|
-
// static complexBin() {
|
|
4536
|
-
// return new Complex(...this.bins(2));
|
|
4537
|
-
// }
|
|
4538
|
-
// static complexOct() {
|
|
4539
|
-
// return new Complex(...this.octs(2));
|
|
4540
|
-
// }
|
|
4541
|
-
// static complexDec() {
|
|
4542
|
-
// return new Complex(...this.decs(10));
|
|
4543
|
-
// }
|
|
4544
|
-
// static complexHex() {
|
|
4545
|
-
// return new Complex(...this.octs(2));
|
|
4546
|
-
// }
|
|
4547
|
-
// static complexes(n, a = 0, b = 1) {
|
|
4548
|
-
// return new Array(n).fill(0).map(() => this.complex(a, b));
|
|
4549
|
-
// }
|
|
4550
|
-
// static complexesInt(n, a = 0, b = 1) {
|
|
4551
|
-
// return new Array(n).fill(0).map(() => this.complexInt(a, b));
|
|
4552
|
-
// }
|
|
4553
|
-
// static complexesBin(n) {
|
|
4554
|
-
// return new Array(n).fill(0).map(() => this.complexBin());
|
|
4555
|
-
// }
|
|
4556
|
-
// static complexesOct(n) {
|
|
4557
|
-
// return new Array(n).fill(0).map(() => this.complexOct());
|
|
4558
|
-
// }
|
|
4559
|
-
// static complexesDec(n) {
|
|
4560
|
-
// return new Array(n).fill(0).map(() => this.complexDec());
|
|
4561
|
-
// }
|
|
4562
|
-
// static complexesHex(n) {
|
|
4563
|
-
// return new Array(n).fill(0).map(() => this.complexHex());
|
|
4564
|
-
// }
|
|
4565
|
-
// static matrix(r,c,min,max){
|
|
4566
|
-
// return matrix(r,c,this.floats(r*c,min,max))
|
|
4567
|
-
// }
|
|
4568
|
-
// static matrixInt(r,c,min,max){
|
|
4569
|
-
// return matrix(r,c,this.ints(r*c,min,max))
|
|
4570
|
-
// }
|
|
4571
|
-
// static matrixBin(r,c){
|
|
4572
|
-
// return matrix(r,c,this.bins(r*c))
|
|
4573
|
-
// }
|
|
4574
|
-
// static matrixOct(r,c){
|
|
4575
|
-
// return matrix(r,c,this.octs(r*c))
|
|
4576
|
-
// }
|
|
4577
|
-
// static matrixDec(r,c){
|
|
4578
|
-
// return matrix(r,c,this.decs(r*c))
|
|
4579
|
-
// }
|
|
4580
|
-
// static matrixHex(r,c){
|
|
4581
|
-
// return matrix(r,c,this.hex(r*c))
|
|
4582
|
-
// }
|
|
4583
|
-
// static matrixColor(r,c){
|
|
4584
|
-
// return matrix(r,c,this.colors(r*c))
|
|
4585
|
-
// }
|
|
4586
|
-
// static matrixComplex(r,c,a,b){
|
|
4587
|
-
// return matrix(r,c,this.complexes(r*c,a,b))
|
|
4588
|
-
// }
|
|
4589
|
-
// static matrixComplexInt(r,c,a,b){
|
|
4590
|
-
// return matrix(r,c,this.complexesInt(r*c,a,b))
|
|
4591
|
-
// }
|
|
4592
|
-
// static matrixComplexBin(r,c){
|
|
4593
|
-
// return matrix(r,c,this.complexesBin(r*c))
|
|
4594
|
-
// }
|
|
4595
|
-
// static matrixComplexOct(r,c){
|
|
4596
|
-
// return matrix(r,c,this.complexesBin(r*c))
|
|
4597
|
-
// }
|
|
4598
|
-
// static matrixComplexDec(r,c){
|
|
4599
|
-
// return matrix(r,c,this.complexesBin(r*c))
|
|
4600
|
-
// }
|
|
4601
|
-
// static matrixComplexHex(r,c){
|
|
4602
|
-
// return matrix(r,c,this.complexesBin(r*c))
|
|
4603
|
-
// }
|
|
4604
|
-
}
|
|
4605
|
-
|
|
4606
4285
|
const { PI, sqrt: sqrt$1, cos: cos$2, sin: sin$2, acos, pow } = Math;
|
|
4607
4286
|
|
|
4608
4287
|
const linear = t => t;
|
|
@@ -5760,9 +5439,7 @@
|
|
|
5760
5439
|
}
|
|
5761
5440
|
|
|
5762
5441
|
exports.App = App;
|
|
5763
|
-
exports.Base = Base;
|
|
5764
5442
|
exports.Clock = Clock;
|
|
5765
|
-
exports.Combinaison = Combinaison;
|
|
5766
5443
|
exports.Complex = Complex;
|
|
5767
5444
|
exports.E = E;
|
|
5768
5445
|
exports.EPSILON = EPSILON;
|
|
@@ -5771,7 +5448,6 @@
|
|
|
5771
5448
|
exports.HTMLWrapper = HTMLWrapper;
|
|
5772
5449
|
exports.Matrix = Matrix;
|
|
5773
5450
|
exports.PI = PI$1;
|
|
5774
|
-
exports.Permutation = Permutation;
|
|
5775
5451
|
exports.Random = Random;
|
|
5776
5452
|
exports.SPA = SPA;
|
|
5777
5453
|
exports.SVGWrapper = SVGWrapper;
|
|
@@ -5799,7 +5475,6 @@
|
|
|
5799
5475
|
exports.ZikoUISuspense = ZikoUISuspense;
|
|
5800
5476
|
exports.ZikoUIText = ZikoUIText;
|
|
5801
5477
|
exports.abs = abs;
|
|
5802
|
-
exports.accum = accum;
|
|
5803
5478
|
exports.accum_prod = accum_prod;
|
|
5804
5479
|
exports.accum_sum = accum_sum;
|
|
5805
5480
|
exports.acos = acos$1;
|
|
@@ -5829,12 +5504,12 @@
|
|
|
5829
5504
|
exports.bind_touch_event = bind_touch_event;
|
|
5830
5505
|
exports.bind_view_event = bind_view_event;
|
|
5831
5506
|
exports.bind_wheel_event = bind_wheel_event;
|
|
5507
|
+
exports.binomial = binomial;
|
|
5832
5508
|
exports.cartesianProduct = cartesianProduct;
|
|
5833
5509
|
exports.cbrt = cbrt;
|
|
5834
5510
|
exports.ceil = ceil;
|
|
5835
5511
|
exports.clamp = clamp;
|
|
5836
5512
|
exports.clock = clock;
|
|
5837
|
-
exports.combinaison = combinaison;
|
|
5838
5513
|
exports.complex = complex;
|
|
5839
5514
|
exports.cos = cos$3;
|
|
5840
5515
|
exports.cosh = cosh$2;
|
|
@@ -5929,10 +5604,8 @@
|
|
|
5929
5604
|
exports.percentile = percentile;
|
|
5930
5605
|
exports.pgcd = pgcd;
|
|
5931
5606
|
exports.pow = pow$1;
|
|
5932
|
-
exports.powerSet = powerSet;
|
|
5933
5607
|
exports.ppcm = ppcm;
|
|
5934
5608
|
exports.preload = preload;
|
|
5935
|
-
exports.prod = prod;
|
|
5936
5609
|
exports.rad2deg = rad2deg;
|
|
5937
5610
|
exports.round = round;
|
|
5938
5611
|
exports.sec = sec;
|
|
@@ -5946,8 +5619,6 @@
|
|
|
5946
5619
|
exports.step = step;
|
|
5947
5620
|
exports.step_fps = step_fps;
|
|
5948
5621
|
exports.sub = sub;
|
|
5949
|
-
exports.subSet = subSet;
|
|
5950
|
-
exports.sum = sum;
|
|
5951
5622
|
exports.svg2ascii = svg2ascii;
|
|
5952
5623
|
exports.svg2img = svg2img;
|
|
5953
5624
|
exports.svg2imgUrl = svg2imgUrl;
|