ziko 0.54.1 → 0.54.3
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 +147 -57
- package/dist/ziko.js +66 -48
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +66 -48
- package/package.json +1 -1
- package/src/data/converter/csv.js +1 -1
- package/src/math/complex/index.js +11 -4
- package/src/math/discret/Conversion/index.js +1 -1
- package/src/math/discret/Logic/index.js +1 -1
- package/src/math/functions/arithmetic/index.js +4 -4
- package/src/math/functions/nested/index.js +42 -38
- package/src/math/matrix/index.js +605 -1
- package/types/math/complex/index.d.ts +1 -0
- package/src/math/adapted/index.js +0 -7
- package/src/math/matrix/matrix.js +0 -596
- package/types/math/adapted/index.d.ts +0 -4
package/dist/ziko.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Fri Dec 12 2025 14:53:26 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
|
|
@@ -105,7 +105,16 @@ class Complex{
|
|
|
105
105
|
: (str = `-${Math.abs(this.b)}*i`);
|
|
106
106
|
return str;
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
toFixed(n){
|
|
109
|
+
this.a = + this.a.toFixed(n);
|
|
110
|
+
this.b = + this.b.toFixed(n);
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
toPrecision(n){
|
|
114
|
+
this.a = + this.a.toPrecision(n);
|
|
115
|
+
this.b = + this.b.toPrecision(n);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
109
118
|
clone() {
|
|
110
119
|
return new Complex(this.a, this.b);
|
|
111
120
|
}
|
|
@@ -118,6 +127,13 @@ class Complex{
|
|
|
118
127
|
static Zero() {
|
|
119
128
|
return new Complex(0, 0);
|
|
120
129
|
}
|
|
130
|
+
static Twidlle(N, K){
|
|
131
|
+
const phi = -2 * Math.PI * K / N;
|
|
132
|
+
return new Complex(
|
|
133
|
+
Math.cos(phi),
|
|
134
|
+
Math.sin(phi)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
121
137
|
get conj() {
|
|
122
138
|
return new Complex(this.a, -this.b);
|
|
123
139
|
}
|
|
@@ -148,23 +164,22 @@ class Complex{
|
|
|
148
164
|
for (let i = 0; i < c.length; i++) {
|
|
149
165
|
if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
|
|
150
166
|
z *= c[i].z;
|
|
151
|
-
phi += c[i].
|
|
167
|
+
phi += c[i].phi;
|
|
152
168
|
}
|
|
153
|
-
this.a = z*Math.cos(phi);
|
|
154
|
-
this.b = z*Math.sin(phi);
|
|
155
|
-
return this;
|
|
169
|
+
this.a = z * Math.cos(phi);
|
|
170
|
+
this.b = z * Math.sin(phi);
|
|
171
|
+
return this.toFixed(8);
|
|
156
172
|
}
|
|
157
173
|
div(...c){
|
|
158
174
|
let {z, phi} = this;
|
|
159
175
|
for (let i = 0; i < c.length; i++) {
|
|
160
176
|
if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
|
|
161
177
|
z /= c[i].z;
|
|
162
|
-
phi -= c[i].
|
|
178
|
+
phi -= c[i].phi;
|
|
163
179
|
}
|
|
164
|
-
this.a = z*Math.cos(phi);
|
|
165
|
-
this.b = z*Math.sin(phi);
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
180
|
+
this.a = z * Math.cos(phi);
|
|
181
|
+
this.b = z * Math.sin(phi);
|
|
182
|
+
return this.toFixed(8); }
|
|
168
183
|
modulo(...c) {
|
|
169
184
|
for (let i = 0; i < c.length; i++) {
|
|
170
185
|
if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
|
|
@@ -173,6 +188,17 @@ class Complex{
|
|
|
173
188
|
}
|
|
174
189
|
return this;
|
|
175
190
|
}
|
|
191
|
+
pow(...c){
|
|
192
|
+
let {z, phi} = this;
|
|
193
|
+
for (let i = 0; i < c.length; i++) {
|
|
194
|
+
if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
|
|
195
|
+
z *= Math.exp(c[i].a * Math.log(z) - c[i].b * phi);
|
|
196
|
+
phi += c[i].b * Math.log(z) + c[i].a * phi;
|
|
197
|
+
}
|
|
198
|
+
this.a = z * Math.cos(phi);
|
|
199
|
+
this.b = z * Math.sin(phi);
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
176
202
|
static fromExpo(z, phi) {
|
|
177
203
|
return new Complex(
|
|
178
204
|
+(z * cos(phi)).toFixed(13),
|
|
@@ -237,6 +263,8 @@ const complex=(a,b)=>{
|
|
|
237
263
|
return new Complex(a,b)
|
|
238
264
|
};
|
|
239
265
|
|
|
266
|
+
const PRECESION = 8;
|
|
267
|
+
|
|
240
268
|
const abs = (...x) => mapfun(
|
|
241
269
|
x =>{
|
|
242
270
|
if(x.isComplex?.()) return x.z;
|
|
@@ -270,8 +298,8 @@ const sqrt$2 = (...x) => mapfun(
|
|
|
270
298
|
x=>{
|
|
271
299
|
if(x.isComplex?.())
|
|
272
300
|
return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
|
|
273
|
-
if(x < 0) return complex(0, Math.sqrt(-x))
|
|
274
|
-
return Math.sqrt(x);
|
|
301
|
+
if(x < 0) return complex(0, Math.sqrt(-x)).toFixed(PRECESION)
|
|
302
|
+
return + Math.sqrt(x).toFixed(PRECESION);
|
|
275
303
|
},
|
|
276
304
|
...x
|
|
277
305
|
);
|
|
@@ -279,8 +307,8 @@ const sqrt$2 = (...x) => mapfun(
|
|
|
279
307
|
const cbrt = (...x) => mapfun(
|
|
280
308
|
x=>{
|
|
281
309
|
if(x.isComplex?.())
|
|
282
|
-
return new x.constructor({z: x.z**(1/3), phi: x.phi/3})
|
|
283
|
-
return Math.cbrt(x);
|
|
310
|
+
return new x.constructor({z: x.z**(1/3), phi: x.phi/3}).toFixed(PRECESION)
|
|
311
|
+
return + Math.cbrt(x).toFixed(PRECESION);
|
|
284
312
|
},
|
|
285
313
|
...x
|
|
286
314
|
);
|
|
@@ -291,8 +319,10 @@ const nthr = (...x) => {
|
|
|
291
319
|
return mapfun(
|
|
292
320
|
x => {
|
|
293
321
|
if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
|
|
294
|
-
if(x<0) return n%2===2
|
|
295
|
-
|
|
322
|
+
if(x<0) return n %2 ===2
|
|
323
|
+
? complex(0, (-x)**(1/n)).toFixed(PRECESION)
|
|
324
|
+
: + (-1 * (-x)**(1/n)).toFixed(PRECESION)
|
|
325
|
+
return + (x**(1/n)).toFixed(PRECESION)
|
|
296
326
|
},
|
|
297
327
|
...x
|
|
298
328
|
)
|
|
@@ -312,7 +342,7 @@ const croot = (...x) =>{
|
|
|
312
342
|
return new c.constructor(
|
|
313
343
|
A * Math.cos(B),
|
|
314
344
|
A * Math.sin(B)
|
|
315
|
-
)
|
|
345
|
+
).toFixed(PRECESION)
|
|
316
346
|
},
|
|
317
347
|
...x
|
|
318
348
|
)
|
|
@@ -323,8 +353,8 @@ const exp$1 = (...x) => mapfun(
|
|
|
323
353
|
if(x.isComplex?.()) return new x.constructor(
|
|
324
354
|
Math.exp(x.a) * Math.cos(x.b),
|
|
325
355
|
Math.exp(x.a) * Math.sin(x.b)
|
|
326
|
-
);
|
|
327
|
-
return Math.exp(x)
|
|
356
|
+
).toFixed(PRECESION);
|
|
357
|
+
return + Math.exp(x).toFixed(PRECESION)
|
|
328
358
|
}
|
|
329
359
|
,...x
|
|
330
360
|
);
|
|
@@ -334,8 +364,8 @@ const ln = (...x) => mapfun(
|
|
|
334
364
|
if(x.isComplex?.()) return new x.constructor(
|
|
335
365
|
Math.log(x.z),
|
|
336
366
|
x.phi
|
|
337
|
-
);
|
|
338
|
-
return Math.log(x)
|
|
367
|
+
).toFixed(PRECESION);
|
|
368
|
+
return + Math.log(x).toFixed(PRECESION)
|
|
339
369
|
}
|
|
340
370
|
,...x
|
|
341
371
|
);
|
|
@@ -410,8 +440,8 @@ const cos$3 = (...x) => mapfun(
|
|
|
410
440
|
if(x.isComplex?.()) return new x.constructor(
|
|
411
441
|
Math.cos(x.a) * Math.cosh(x.b),
|
|
412
442
|
-Math.sin(x.a) * Math.sinh(x.b)
|
|
413
|
-
);
|
|
414
|
-
return Math.cos(x)
|
|
443
|
+
).toFixed(PRECESION);
|
|
444
|
+
return + Math.cos(x).toFixed(PRECESION)
|
|
415
445
|
}
|
|
416
446
|
,...x
|
|
417
447
|
);
|
|
@@ -421,8 +451,8 @@ const sin$3 = (...x) => mapfun(
|
|
|
421
451
|
if(x?.isComplex) return new x.constructor(
|
|
422
452
|
Math.sin(x.a) * Math.cosh(x.b),
|
|
423
453
|
Math.cos(x.a) * Math.sinh(x.b)
|
|
424
|
-
);
|
|
425
|
-
return Math.sin(x)
|
|
454
|
+
).toFixed(PRECESION);
|
|
455
|
+
return + Math.sin(x).toFixed(PRECESION)
|
|
426
456
|
}
|
|
427
457
|
, ...x
|
|
428
458
|
);
|
|
@@ -434,9 +464,9 @@ const tan = (...x) => mapfun(
|
|
|
434
464
|
return new x.constructor(
|
|
435
465
|
Math.sin(2*x.a) / D,
|
|
436
466
|
Math.sinh(2*x.b) / D
|
|
437
|
-
);
|
|
467
|
+
).toFixed(PRECESION);
|
|
438
468
|
}
|
|
439
|
-
return Math.tan(x)
|
|
469
|
+
return + Math.tan(x).toFixed(PRECESION)
|
|
440
470
|
},
|
|
441
471
|
...x
|
|
442
472
|
);
|
|
@@ -444,7 +474,7 @@ const tan = (...x) => mapfun(
|
|
|
444
474
|
const sec = (...x) => mapfun(
|
|
445
475
|
x => {
|
|
446
476
|
if(x.isComplex?.()) ;
|
|
447
|
-
return 1 / Math.cos(x)
|
|
477
|
+
return + (1 / Math.cos(x)).toFixed(PRECESION)
|
|
448
478
|
}
|
|
449
479
|
,...x
|
|
450
480
|
);
|
|
@@ -460,9 +490,9 @@ const acos$1 = (...x) => mapfun(
|
|
|
460
490
|
return new x.constructor(
|
|
461
491
|
Math.acos((Rp - Rm) / 2),
|
|
462
492
|
-Math.acosh((Rp + Rm) / 2),
|
|
463
|
-
)
|
|
493
|
+
).toFixed(PRECESION)
|
|
464
494
|
}
|
|
465
|
-
return Math.acos(x)
|
|
495
|
+
return + Math.acos(x).toFixed(PRECESION)
|
|
466
496
|
},
|
|
467
497
|
...x
|
|
468
498
|
);
|
|
@@ -476,9 +506,9 @@ const asin = (...x) => mapfun(
|
|
|
476
506
|
return new x.constructor(
|
|
477
507
|
Math.asin((Rp - Rm) / 2),
|
|
478
508
|
Math.acosh((Rp + Rm) / 2)
|
|
479
|
-
);
|
|
509
|
+
).toFixed(PRECESION);
|
|
480
510
|
}
|
|
481
|
-
return Math.asin(x);
|
|
511
|
+
return + Math.asin(x).toFixed(PRECESION);
|
|
482
512
|
},
|
|
483
513
|
...x
|
|
484
514
|
);
|
|
@@ -490,9 +520,9 @@ const atan = (...x) => mapfun(
|
|
|
490
520
|
return new x.constructor(
|
|
491
521
|
Math.atan((a*2/(1-a**2-b**2)))/2,
|
|
492
522
|
Math.log((a**2 + (1+b)**2)/(a**2 + (1-b)**2))/4
|
|
493
|
-
)
|
|
523
|
+
).toFixed(PRECESION)
|
|
494
524
|
}
|
|
495
|
-
return Math.atan(x);
|
|
525
|
+
return + Math.atan(x).toFixed(PRECESION);
|
|
496
526
|
},
|
|
497
527
|
...x
|
|
498
528
|
);
|
|
@@ -504,9 +534,9 @@ const acot = (...x) => mapfun(
|
|
|
504
534
|
return new x.constructor(
|
|
505
535
|
Math.atan(2*a/(a**2+(b-1)*(b+1)))/2,
|
|
506
536
|
Math.log((a**2 + (b-1)**2)/(a**2 + (b+1)**2))/4
|
|
507
|
-
)
|
|
537
|
+
).toFixed(PRECESION)
|
|
508
538
|
}
|
|
509
|
-
return Math.PI/2 - Math.atan(x);
|
|
539
|
+
return + (Math.PI/2 - Math.atan(x)).toFixed(PRECESION);
|
|
510
540
|
},
|
|
511
541
|
...x
|
|
512
542
|
);
|
|
@@ -517,8 +547,8 @@ const cosh$2 = (...x) => mapfun(
|
|
|
517
547
|
if(x?.isComplex) return new x.constructor(
|
|
518
548
|
Math.cosh(x.a) * Math.cos(x.b),
|
|
519
549
|
Math.sinh(x.a) * Math.sin(x.b)
|
|
520
|
-
);
|
|
521
|
-
return Math.cosh(x)
|
|
550
|
+
).toFixed(PRECESION);
|
|
551
|
+
return + Math.cosh(x).toFixed(PRECESION)
|
|
522
552
|
},
|
|
523
553
|
...x
|
|
524
554
|
);
|
|
@@ -527,8 +557,8 @@ const sinh$1 = (...x) => mapfun(
|
|
|
527
557
|
if(x?.isComplex) return new x.constructor(
|
|
528
558
|
Math.sinh(x.a) * Math.cos(x.b),
|
|
529
559
|
Math.cosh(x.a) * Math.sin(x.b)
|
|
530
|
-
);
|
|
531
|
-
return Math.sinh(x)
|
|
560
|
+
).toFixed(PRECESION);
|
|
561
|
+
return + Math.sinh(x).toFixed(PRECESION)
|
|
532
562
|
},
|
|
533
563
|
...x
|
|
534
564
|
);
|
|
@@ -539,9 +569,9 @@ const tanh = (...x) => mapfun(
|
|
|
539
569
|
return new x.constructor(
|
|
540
570
|
Math.sinh(2*a) / D,
|
|
541
571
|
Math.sin(2*b) / D
|
|
542
|
-
)
|
|
572
|
+
).toFixed(PRECESION)
|
|
543
573
|
}
|
|
544
|
-
return Math.tanh(x)
|
|
574
|
+
return + Math.tanh(x).toFixed(PRECESION)
|
|
545
575
|
},
|
|
546
576
|
...x
|
|
547
577
|
);
|
|
@@ -554,9 +584,9 @@ const coth = (...x) => mapfun(
|
|
|
554
584
|
return new x.constructor(
|
|
555
585
|
Math.cosh(a) * Math.sinh(a) / D,
|
|
556
586
|
- Math.sin(b) * Math.cos(b) / D
|
|
557
|
-
)
|
|
587
|
+
).toFixed(PRECESION)
|
|
558
588
|
}
|
|
559
|
-
return 1/Math.tanh(x)
|
|
589
|
+
return + (1 / Math.tanh(x)).toFixed(PRECESION)
|
|
560
590
|
},
|
|
561
591
|
...x
|
|
562
592
|
);
|
|
@@ -566,7 +596,7 @@ const acosh = (...x) => mapfun(
|
|
|
566
596
|
if(x?.isComplex){
|
|
567
597
|
return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).sub(1))))
|
|
568
598
|
}
|
|
569
|
-
return Math.acosh(x)
|
|
599
|
+
return + Math.acosh(x).toFixed(PRECESION)
|
|
570
600
|
},
|
|
571
601
|
...x
|
|
572
602
|
);
|
|
@@ -576,7 +606,7 @@ const asinh = (...x) => mapfun(
|
|
|
576
606
|
if(x?.isComplex){
|
|
577
607
|
return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).add(1))))
|
|
578
608
|
}
|
|
579
|
-
return Math.asinh(x)
|
|
609
|
+
return + Math.asinh(x).toFixed(PRECESION)
|
|
580
610
|
},
|
|
581
611
|
...x
|
|
582
612
|
);
|
|
@@ -584,7 +614,7 @@ const asinh = (...x) => mapfun(
|
|
|
584
614
|
const atanh = (...x) => mapfun(
|
|
585
615
|
x =>{
|
|
586
616
|
if(x?.isComplex);
|
|
587
|
-
return Math.atanh(x)
|
|
617
|
+
return + Math.atanh(x).toFixed(PRECESION)
|
|
588
618
|
},
|
|
589
619
|
...x
|
|
590
620
|
);
|
|
@@ -592,7 +622,7 @@ const atanh = (...x) => mapfun(
|
|
|
592
622
|
const sig = (...x) => mapfun(
|
|
593
623
|
x =>{
|
|
594
624
|
if(x?.isComplex);
|
|
595
|
-
return 1/(1+Math.exp(-x))
|
|
625
|
+
return 1/(1 + Math.exp(-x)).toFixed(PRECESION)
|
|
596
626
|
},
|
|
597
627
|
...x
|
|
598
628
|
);
|
|
@@ -605,7 +635,7 @@ const _add = (x, y) =>{
|
|
|
605
635
|
}
|
|
606
636
|
}
|
|
607
637
|
if(x.isComplex?.()){
|
|
608
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
638
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
|
|
609
639
|
}
|
|
610
640
|
};
|
|
611
641
|
|
|
@@ -615,7 +645,7 @@ const _sub = (x, y) =>{
|
|
|
615
645
|
if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
|
|
616
646
|
}
|
|
617
647
|
if(x.isComplex?.()){
|
|
618
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
648
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
|
|
619
649
|
}
|
|
620
650
|
};
|
|
621
651
|
|
|
@@ -625,7 +655,7 @@ const _mul = (x, y) =>{
|
|
|
625
655
|
if(y.isComplex?.()) return y.clone().mul(x);
|
|
626
656
|
}
|
|
627
657
|
if(x.isComplex?.()){
|
|
628
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
658
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
629
659
|
}
|
|
630
660
|
};
|
|
631
661
|
|
|
@@ -635,7 +665,7 @@ const _div = (x, y) =>{
|
|
|
635
665
|
if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
|
|
636
666
|
}
|
|
637
667
|
if(x.isComplex?.()){
|
|
638
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
668
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
639
669
|
}
|
|
640
670
|
};
|
|
641
671
|
|
|
@@ -645,7 +675,7 @@ const _modulo = (x, y) =>{
|
|
|
645
675
|
if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
|
|
646
676
|
}
|
|
647
677
|
if(x.isComplex?.()){
|
|
648
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
678
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
|
|
649
679
|
}
|
|
650
680
|
};
|
|
651
681
|
|
|
@@ -680,9 +710,6 @@ const modulo=(a,...b)=>{
|
|
|
680
710
|
return res;
|
|
681
711
|
};
|
|
682
712
|
|
|
683
|
-
const min$1 = (...x) => Math.min(...x);
|
|
684
|
-
const max$1 = (...x) => Math.max(...x);
|
|
685
|
-
|
|
686
713
|
const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
|
|
687
714
|
const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
|
|
688
715
|
|
|
@@ -785,6 +812,54 @@ const atan2 = (y, x, rad = true) => {
|
|
|
785
812
|
return rad ? phi : phi * 180 / Math.PI;
|
|
786
813
|
};
|
|
787
814
|
|
|
815
|
+
const min$1 = (...x) => Math.min(...x);
|
|
816
|
+
const max$1 = (...x) => Math.max(...x);
|
|
817
|
+
|
|
818
|
+
const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
|
|
819
|
+
|
|
820
|
+
const variance = (...x) => {
|
|
821
|
+
const n = x.length;
|
|
822
|
+
if (n === 0) return NaN;
|
|
823
|
+
const x_mean = mean(...x);
|
|
824
|
+
return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / n;
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
const std = (...x) => Math.sqrt(variance(...x));
|
|
828
|
+
|
|
829
|
+
const accum_sum = (...x) => {
|
|
830
|
+
let result = [];
|
|
831
|
+
let total = 0, i; n = x.length;
|
|
832
|
+
for(i = 0; i < n ; i++){
|
|
833
|
+
total = add(total, x[i]);
|
|
834
|
+
result.push(total);
|
|
835
|
+
}
|
|
836
|
+
return result;
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
const accum_prod = (...x) => {
|
|
840
|
+
let result = [];
|
|
841
|
+
let prod = 1, i; n = x.length;
|
|
842
|
+
for(i = 0; i < n ; i++){
|
|
843
|
+
prod = mul(prod, x[i]);
|
|
844
|
+
result.push(prod);
|
|
845
|
+
}
|
|
846
|
+
return result;
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
const percentile = (X, p) => {
|
|
850
|
+
if (X.length === 0)
|
|
851
|
+
return NaN;
|
|
852
|
+
let a = [...X].sort((x, y) => x - y);
|
|
853
|
+
let index = (p / 100) * (a.length - 1);
|
|
854
|
+
let i = Math.floor(index);
|
|
855
|
+
let f = index - i;
|
|
856
|
+
if (i === a.length - 1)
|
|
857
|
+
return a[i];
|
|
858
|
+
return a[i] * (1 - f) + a[i + 1] * f;
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
const median = X => percentile(X, 50);
|
|
862
|
+
|
|
788
863
|
const preload=(url)=>{
|
|
789
864
|
const xhr = new XMLHttpRequest();
|
|
790
865
|
xhr.open("GET", url, false);
|
|
@@ -3317,6 +3392,14 @@ class Matrix{
|
|
|
3317
3392
|
clone() {
|
|
3318
3393
|
return new Matrix(this.rows, this.cols, this.arr.flat(1));
|
|
3319
3394
|
}
|
|
3395
|
+
toComplex(){
|
|
3396
|
+
this.arr = mapfun(
|
|
3397
|
+
x => x?.isComplex?.() ? x : new Complex(x, 0),
|
|
3398
|
+
...this.arr
|
|
3399
|
+
);
|
|
3400
|
+
this.#maintain();
|
|
3401
|
+
return this;
|
|
3402
|
+
}
|
|
3320
3403
|
[Symbol.iterator]() {
|
|
3321
3404
|
return this.arr[Symbol.iterator]();
|
|
3322
3405
|
}
|
|
@@ -5704,6 +5787,8 @@ exports.ZikoUISuspense = ZikoUISuspense;
|
|
|
5704
5787
|
exports.ZikoUIText = ZikoUIText;
|
|
5705
5788
|
exports.abs = abs;
|
|
5706
5789
|
exports.accum = accum;
|
|
5790
|
+
exports.accum_prod = accum_prod;
|
|
5791
|
+
exports.accum_sum = accum_sum;
|
|
5707
5792
|
exports.acos = acos$1;
|
|
5708
5793
|
exports.acosh = acosh;
|
|
5709
5794
|
exports.acot = acot;
|
|
@@ -5804,6 +5889,8 @@ exports.matrix2 = matrix2;
|
|
|
5804
5889
|
exports.matrix3 = matrix3;
|
|
5805
5890
|
exports.matrix4 = matrix4;
|
|
5806
5891
|
exports.max = max$1;
|
|
5892
|
+
exports.mean = mean;
|
|
5893
|
+
exports.median = median;
|
|
5807
5894
|
exports.min = min$1;
|
|
5808
5895
|
exports.modulo = modulo;
|
|
5809
5896
|
exports.mul = mul;
|
|
@@ -5822,6 +5909,7 @@ exports.out_quad = out_quad;
|
|
|
5822
5909
|
exports.out_quart = out_quart;
|
|
5823
5910
|
exports.out_quint = out_quint;
|
|
5824
5911
|
exports.out_sin = out_sin;
|
|
5912
|
+
exports.percentile = percentile;
|
|
5825
5913
|
exports.pgcd = pgcd;
|
|
5826
5914
|
exports.pow = pow$1;
|
|
5827
5915
|
exports.powerSet = powerSet;
|
|
@@ -5837,6 +5925,7 @@ exports.sin = sin$3;
|
|
|
5837
5925
|
exports.sinh = sinh$1;
|
|
5838
5926
|
exports.sleep = sleep;
|
|
5839
5927
|
exports.sqrt = sqrt$2;
|
|
5928
|
+
exports.std = std;
|
|
5840
5929
|
exports.step = step;
|
|
5841
5930
|
exports.step_fps = step_fps;
|
|
5842
5931
|
exports.sub = sub;
|
|
@@ -5868,6 +5957,7 @@ exports.useSessionStorage = useSessionStorage;
|
|
|
5868
5957
|
exports.useState = useState;
|
|
5869
5958
|
exports.useThread = useThread;
|
|
5870
5959
|
exports.useTitle = useTitle;
|
|
5960
|
+
exports.variance = variance;
|
|
5871
5961
|
exports.wait = wait;
|
|
5872
5962
|
exports.waitForUIElm = waitForUIElm;
|
|
5873
5963
|
exports.waitForUIElmSync = waitForUIElmSync;
|