ziko 0.54.0 → 0.54.2

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.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sun Dec 07 2025 00:00:39 GMT+0100 (UTC+01:00)
5
+ Date : Thu Dec 11 2025 13:24:43 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
@@ -30,6 +30,20 @@ const mapfun=(fun,...X)=>{
30
30
  }
31
31
  });
32
32
  return Y.length==1? Y[0]: Y;
33
+ };
34
+
35
+ const apply_fun = (x, fn) => {
36
+ if (x.isComplex?.()) return new x.constructor(
37
+ fn(x.a),
38
+ fn(x.b)
39
+ )
40
+ if (x.isMatrix?.()) return new x.constructor(
41
+ x.rows,
42
+ x.cols,
43
+ x.arr.flat(1).map(fn)
44
+ )
45
+ if (x instanceof Array) mapfun(fn, ...x);
46
+ return fn(x)
33
47
  };
34
48
 
35
49
  // import {sum,prod,deg2rad} from "../utils/index.js";
@@ -89,7 +103,16 @@ class Complex{
89
103
  : (str = `-${Math.abs(this.b)}*i`);
90
104
  return str;
91
105
  }
92
-
106
+ toFixed(n){
107
+ this.a = + this.a.toFixed(n);
108
+ this.b = + this.b.toFixed(n);
109
+ return this;
110
+ }
111
+ toPrecision(n){
112
+ this.a = + this.a.toPrecision(n);
113
+ this.b = + this.b.toPrecision(n);
114
+ return this;
115
+ }
93
116
  clone() {
94
117
  return new Complex(this.a, this.b);
95
118
  }
@@ -102,6 +125,13 @@ class Complex{
102
125
  static Zero() {
103
126
  return new Complex(0, 0);
104
127
  }
128
+ static Twidlle(N, K){
129
+ const phi = -2 * Math.PI * K / N;
130
+ return new Complex(
131
+ Math.cos(phi),
132
+ Math.sin(phi)
133
+ );
134
+ }
105
135
  get conj() {
106
136
  return new Complex(this.a, -this.b);
107
137
  }
@@ -132,23 +162,22 @@ class Complex{
132
162
  for (let i = 0; i < c.length; i++) {
133
163
  if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
134
164
  z *= c[i].z;
135
- phi += c[i].z;
165
+ phi += c[i].phi;
136
166
  }
137
- this.a = z*Math.cos(phi);
138
- this.b = z*Math.sin(phi);
139
- return this;
167
+ this.a = z * Math.cos(phi);
168
+ this.b = z * Math.sin(phi);
169
+ return this.toFixed(8);
140
170
  }
141
171
  div(...c){
142
172
  let {z, phi} = this;
143
173
  for (let i = 0; i < c.length; i++) {
144
174
  if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
145
175
  z /= c[i].z;
146
- phi -= c[i].z;
176
+ phi -= c[i].phi;
147
177
  }
148
- this.a = z*Math.cos(phi);
149
- this.b = z*Math.sin(phi);
150
- return this;
151
- }
178
+ this.a = z * Math.cos(phi);
179
+ this.b = z * Math.sin(phi);
180
+ return this.toFixed(8); }
152
181
  modulo(...c) {
153
182
  for (let i = 0; i < c.length; i++) {
154
183
  if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
@@ -157,6 +186,17 @@ class Complex{
157
186
  }
158
187
  return this;
159
188
  }
189
+ pow(...c){
190
+ let {z, phi} = this;
191
+ for (let i = 0; i < c.length; i++) {
192
+ if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
193
+ z *= Math.exp(c[i].a * Math.log(z) - c[i].b * phi);
194
+ phi += c[i].b * Math.log(z) + c[i].a * phi;
195
+ }
196
+ this.a = z * Math.cos(phi);
197
+ this.b = z * Math.sin(phi);
198
+ return this;
199
+ }
160
200
  static fromExpo(z, phi) {
161
201
  return new Complex(
162
202
  +(z * cos(phi)).toFixed(13),
@@ -221,8 +261,7 @@ const complex=(a,b)=>{
221
261
  return new Complex(a,b)
222
262
  };
223
263
 
224
- const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
225
- const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
264
+ const PRECESION = 8;
226
265
 
227
266
  const abs = (...x) => mapfun(
228
267
  x =>{
@@ -257,8 +296,8 @@ const sqrt$2 = (...x) => mapfun(
257
296
  x=>{
258
297
  if(x.isComplex?.())
259
298
  return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
260
- if(x < 0) return complex(0, Math.sqrt(-x))
261
- return Math.sqrt(x);
299
+ if(x < 0) return complex(0, Math.sqrt(-x)).toFixed(PRECESION)
300
+ return + Math.sqrt(x).toFixed(PRECESION);
262
301
  },
263
302
  ...x
264
303
  );
@@ -266,8 +305,8 @@ const sqrt$2 = (...x) => mapfun(
266
305
  const cbrt = (...x) => mapfun(
267
306
  x=>{
268
307
  if(x.isComplex?.())
269
- return new x.constructor({z: x.z**(1/3), phi: x.phi/3})
270
- return Math.cbrt(x);
308
+ return new x.constructor({z: x.z**(1/3), phi: x.phi/3}).toFixed(PRECESION)
309
+ return + Math.cbrt(x).toFixed(PRECESION);
271
310
  },
272
311
  ...x
273
312
  );
@@ -278,8 +317,10 @@ const nthr = (...x) => {
278
317
  return mapfun(
279
318
  x => {
280
319
  if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
281
- if(x<0) return n%2===2 ? complex(0, (-x)**(1/n)) : -1 * (-x)**(1/n)
282
- return x**(1/n)
320
+ if(x<0) return n %2 ===2
321
+ ? complex(0, (-x)**(1/n)).toFixed(PRECESION)
322
+ : + (-1 * (-x)**(1/n)).toFixed(PRECESION)
323
+ return + (x**(1/n)).toFixed(PRECESION)
283
324
  },
284
325
  ...x
285
326
  )
@@ -299,7 +340,7 @@ const croot = (...x) =>{
299
340
  return new c.constructor(
300
341
  A * Math.cos(B),
301
342
  A * Math.sin(B)
302
- )
343
+ ).toFixed(PRECESION)
303
344
  },
304
345
  ...x
305
346
  )
@@ -310,8 +351,8 @@ const exp$1 = (...x) => mapfun(
310
351
  if(x.isComplex?.()) return new x.constructor(
311
352
  Math.exp(x.a) * Math.cos(x.b),
312
353
  Math.exp(x.a) * Math.sin(x.b)
313
- );
314
- return Math.exp(x)
354
+ ).toFixed(PRECESION);
355
+ return + Math.exp(x).toFixed(PRECESION)
315
356
  }
316
357
  ,...x
317
358
  );
@@ -321,8 +362,8 @@ const ln = (...x) => mapfun(
321
362
  if(x.isComplex?.()) return new x.constructor(
322
363
  Math.log(x.z),
323
364
  x.phi
324
- );
325
- return Math.log(x)
365
+ ).toFixed(PRECESION);
366
+ return + Math.log(x).toFixed(PRECESION)
326
367
  }
327
368
  ,...x
328
369
  );
@@ -397,8 +438,8 @@ const cos$3 = (...x) => mapfun(
397
438
  if(x.isComplex?.()) return new x.constructor(
398
439
  Math.cos(x.a) * Math.cosh(x.b),
399
440
  -Math.sin(x.a) * Math.sinh(x.b)
400
- );
401
- return Math.cos(x)
441
+ ).toFixed(PRECESION);
442
+ return + Math.cos(x).toFixed(PRECESION)
402
443
  }
403
444
  ,...x
404
445
  );
@@ -408,8 +449,8 @@ const sin$3 = (...x) => mapfun(
408
449
  if(x?.isComplex) return new x.constructor(
409
450
  Math.sin(x.a) * Math.cosh(x.b),
410
451
  Math.cos(x.a) * Math.sinh(x.b)
411
- );
412
- return Math.sin(x)
452
+ ).toFixed(PRECESION);
453
+ return + Math.sin(x).toFixed(PRECESION)
413
454
  }
414
455
  , ...x
415
456
  );
@@ -421,9 +462,9 @@ const tan = (...x) => mapfun(
421
462
  return new x.constructor(
422
463
  Math.sin(2*x.a) / D,
423
464
  Math.sinh(2*x.b) / D
424
- );
465
+ ).toFixed(PRECESION);
425
466
  }
426
- return Math.tan(x)
467
+ return + Math.tan(x).toFixed(PRECESION)
427
468
  },
428
469
  ...x
429
470
  );
@@ -431,7 +472,7 @@ const tan = (...x) => mapfun(
431
472
  const sec = (...x) => mapfun(
432
473
  x => {
433
474
  if(x.isComplex?.()) ;
434
- return 1 / Math.cos(x)
475
+ return + (1 / Math.cos(x)).toFixed(PRECESION)
435
476
  }
436
477
  ,...x
437
478
  );
@@ -447,9 +488,9 @@ const acos$1 = (...x) => mapfun(
447
488
  return new x.constructor(
448
489
  Math.acos((Rp - Rm) / 2),
449
490
  -Math.acosh((Rp + Rm) / 2),
450
- )
491
+ ).toFixed(PRECESION)
451
492
  }
452
- return Math.acos(x)
493
+ return + Math.acos(x).toFixed(PRECESION)
453
494
  },
454
495
  ...x
455
496
  );
@@ -463,9 +504,9 @@ const asin = (...x) => mapfun(
463
504
  return new x.constructor(
464
505
  Math.asin((Rp - Rm) / 2),
465
506
  Math.acosh((Rp + Rm) / 2)
466
- );
507
+ ).toFixed(PRECESION);
467
508
  }
468
- return Math.asin(x);
509
+ return + Math.asin(x).toFixed(PRECESION);
469
510
  },
470
511
  ...x
471
512
  );
@@ -477,9 +518,9 @@ const atan = (...x) => mapfun(
477
518
  return new x.constructor(
478
519
  Math.atan((a*2/(1-a**2-b**2)))/2,
479
520
  Math.log((a**2 + (1+b)**2)/(a**2 + (1-b)**2))/4
480
- )
521
+ ).toFixed(PRECESION)
481
522
  }
482
- return Math.atan(x);
523
+ return + Math.atan(x).toFixed(PRECESION);
483
524
  },
484
525
  ...x
485
526
  );
@@ -491,9 +532,9 @@ const acot = (...x) => mapfun(
491
532
  return new x.constructor(
492
533
  Math.atan(2*a/(a**2+(b-1)*(b+1)))/2,
493
534
  Math.log((a**2 + (b-1)**2)/(a**2 + (b+1)**2))/4
494
- )
535
+ ).toFixed(PRECESION)
495
536
  }
496
- return Math.PI/2 - Math.atan(x);
537
+ return + (Math.PI/2 - Math.atan(x)).toFixed(PRECESION);
497
538
  },
498
539
  ...x
499
540
  );
@@ -504,8 +545,8 @@ const cosh$2 = (...x) => mapfun(
504
545
  if(x?.isComplex) return new x.constructor(
505
546
  Math.cosh(x.a) * Math.cos(x.b),
506
547
  Math.sinh(x.a) * Math.sin(x.b)
507
- );
508
- return Math.cosh(x)
548
+ ).toFixed(PRECESION);
549
+ return + Math.cosh(x).toFixed(PRECESION)
509
550
  },
510
551
  ...x
511
552
  );
@@ -514,8 +555,8 @@ const sinh$1 = (...x) => mapfun(
514
555
  if(x?.isComplex) return new x.constructor(
515
556
  Math.sinh(x.a) * Math.cos(x.b),
516
557
  Math.cosh(x.a) * Math.sin(x.b)
517
- );
518
- return Math.sinh(x)
558
+ ).toFixed(PRECESION);
559
+ return + Math.sinh(x).toFixed(PRECESION)
519
560
  },
520
561
  ...x
521
562
  );
@@ -526,9 +567,9 @@ const tanh = (...x) => mapfun(
526
567
  return new x.constructor(
527
568
  Math.sinh(2*a) / D,
528
569
  Math.sin(2*b) / D
529
- )
570
+ ).toFixed(PRECESION)
530
571
  }
531
- return Math.tanh(x)
572
+ return + Math.tanh(x).toFixed(PRECESION)
532
573
  },
533
574
  ...x
534
575
  );
@@ -541,9 +582,9 @@ const coth = (...x) => mapfun(
541
582
  return new x.constructor(
542
583
  Math.cosh(a) * Math.sinh(a) / D,
543
584
  - Math.sin(b) * Math.cos(b) / D
544
- )
585
+ ).toFixed(PRECESION)
545
586
  }
546
- return 1/Math.tanh(x)
587
+ return + (1 / Math.tanh(x)).toFixed(PRECESION)
547
588
  },
548
589
  ...x
549
590
  );
@@ -553,7 +594,7 @@ const acosh = (...x) => mapfun(
553
594
  if(x?.isComplex){
554
595
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).sub(1))))
555
596
  }
556
- return Math.acosh(x)
597
+ return + Math.acosh(x).toFixed(PRECESION)
557
598
  },
558
599
  ...x
559
600
  );
@@ -563,7 +604,7 @@ const asinh = (...x) => mapfun(
563
604
  if(x?.isComplex){
564
605
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).add(1))))
565
606
  }
566
- return Math.asinh(x)
607
+ return + Math.asinh(x).toFixed(PRECESION)
567
608
  },
568
609
  ...x
569
610
  );
@@ -571,7 +612,7 @@ const asinh = (...x) => mapfun(
571
612
  const atanh = (...x) => mapfun(
572
613
  x =>{
573
614
  if(x?.isComplex);
574
- return Math.atanh(x)
615
+ return + Math.atanh(x).toFixed(PRECESION)
575
616
  },
576
617
  ...x
577
618
  );
@@ -579,7 +620,7 @@ const atanh = (...x) => mapfun(
579
620
  const sig = (...x) => mapfun(
580
621
  x =>{
581
622
  if(x?.isComplex);
582
- return 1/(1+Math.exp(-x))
623
+ return 1/(1 + Math.exp(-x)).toFixed(PRECESION)
583
624
  },
584
625
  ...x
585
626
  );
@@ -592,7 +633,7 @@ const _add = (x, y) =>{
592
633
  }
593
634
  }
594
635
  if(x.isComplex?.()){
595
- if(typeof y === 'number' || y.isComplex?.()) return new x.clone().add(y);
636
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
596
637
  }
597
638
  };
598
639
 
@@ -602,7 +643,7 @@ const _sub = (x, y) =>{
602
643
  if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
603
644
  }
604
645
  if(x.isComplex?.()){
605
- if(typeof y === 'number' || y.isComplex?.()) return new x.clone().sub(y);
646
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
606
647
  }
607
648
  };
608
649
 
@@ -612,7 +653,7 @@ const _mul = (x, y) =>{
612
653
  if(y.isComplex?.()) return y.clone().mul(x);
613
654
  }
614
655
  if(x.isComplex?.()){
615
- if(typeof y === 'number' || y.isComplex?.()) return new x.clone().mul(y);
656
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
616
657
  }
617
658
  };
618
659
 
@@ -622,7 +663,7 @@ const _div = (x, y) =>{
622
663
  if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
623
664
  }
624
665
  if(x.isComplex?.()){
625
- if(typeof y === 'number' || y.isComplex?.()) return new x.clone().mul(y);
666
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
626
667
  }
627
668
  };
628
669
 
@@ -632,7 +673,7 @@ const _modulo = (x, y) =>{
632
673
  if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
633
674
  }
634
675
  if(x.isComplex?.()){
635
- if(typeof y === 'number' || y.isComplex?.()) return new x.clone().modulo(y);
676
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
636
677
  }
637
678
  };
638
679
 
@@ -667,57 +708,83 @@ const modulo=(a,...b)=>{
667
708
  return res;
668
709
  };
669
710
 
670
- const norm = (x, min, max) => {
671
- if(x.isComplex?.()) return new x.constructor(
672
- norm(x.a, min, max),
673
- norm(x.b, min, max)
674
- )
675
- if(x.isMatrix?.()) return new x.constructor(
676
- x.rows,
677
- x.cols,
678
- norm(x.arr.flat(1), min, max)
679
- );
680
- return min !== max ? (value - min) / (max - min) : 0;
681
- };
711
+ const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
712
+ const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
682
713
 
683
- const lerp = (x, min, max) => {
684
- if(x.isComplex?.()) return new x.constructor(
685
- lerp(x.a, min, max),
686
- lerp(x.b, min, max)
687
- )
688
- if(x.isMatrix?.()) return new x.constructor(
689
- x.rows,
690
- x.cols,
691
- lerp(x.arr.flat(1), min, max)
692
- );
693
- return (max - min) * value + min;
694
- };
714
+ const norm = (x, min, max) => apply_fun(
715
+ x,
716
+ v => min !== max ? (v - min) / (max - min) : 0
717
+ );
718
+ const lerp = (x, min, max) => apply_fun(
719
+ x,
720
+ v => (max - min) * v + min
721
+ );
722
+ const clamp = (x, min, max) => apply_fun(
723
+ x,
724
+ v => Math.min(Math.max(v, min), max)
725
+ );
726
+ const map$1 = (x, a, b, c, d) => apply_fun(
727
+ x,
728
+ v => lerp(norm(v, a, b), c, d)
729
+ );
695
730
 
696
- const map$1 = (x, min, max) => {
697
- if(x.isComplex?.()) return new x.constructor(
698
- map$1(x.a),
699
- map$1(x.b)
700
- )
701
- if(x.isMatrix?.()) return new x.constructor(
702
- x.rows,
703
- x.cols,
704
- map$1(x.arr.flat(1))
705
- );
706
- return lerp(norm(x, a, b), c, d);
707
- };
708
731
 
709
- const clamp = (x, min, max) => {
710
- if(x.isComplex?.()) return new x.constructor(
711
- clamp(x.a, min, max),
712
- clamp(x.b, min, max)
713
- )
714
- if(x.isMatrix?.()) return new x.constructor(
715
- x.rows,
716
- x.cols,
717
- clamp(x.arr.flat(1), min, max)
718
- );
719
- return Math.min(Math.max(c, min), max)
720
- };
732
+ // export const norm = (x, min, max) => {
733
+ // if(x.isComplex?.()) return new x.constructor(
734
+ // norm(x.a, min, max),
735
+ // norm(x.b, min, max)
736
+ // )
737
+ // if(x.isMatrix?.()) return new x.constructor(
738
+ // x.rows,
739
+ // x.cols,
740
+ // norm(x.arr.flat(1), min, max)
741
+ // );
742
+ // if(x instanceof Array) return mapfun(n => norm(n, min, max), ...x);
743
+ // return min !== max ? (x - min) / (max - min) : 0;
744
+ // }
745
+
746
+
747
+ // export const lerp = (x, min, max) => {
748
+ // if(x.isComplex?.()) return new x.constructor(
749
+ // lerp(x.a, min, max),
750
+ // lerp(x.b, min, max)
751
+ // )
752
+ // if(x.isMatrix?.()) return new x.constructor(
753
+ // x.rows,
754
+ // x.cols,
755
+ // lerp(x.arr.flat(1), min, max)
756
+ // );
757
+ // if(x instanceof Array) return mapfun(n => lerp(n, min, max), ...x);
758
+ // return (max - min) * x + min;
759
+ // }
760
+
761
+ // export const map = (x, a, b, c, d) => {
762
+ // if(x.isComplex?.()) return new x.constructor(
763
+ // map(x.a, a, b, c, d),
764
+ // map(x.b, a, b, c, d)
765
+ // )
766
+ // if(x.isMatrix?.()) return new x.constructor(
767
+ // x.rows,
768
+ // x.cols,
769
+ // map(x.arr.flat(1), a, b, c, d)
770
+ // );
771
+ // if(x instanceof Array) return mapfun(n => map(n, a, b, c, d), ...x);
772
+ // return lerp(norm(x, a, b), c, d);
773
+ // }
774
+
775
+ // export const clamp = (x, min, max) => {
776
+ // if(x.isComplex?.()) return new x.constructor(
777
+ // clamp(x.a, min, max),
778
+ // clamp(x.b, min, max)
779
+ // )
780
+ // if(x.isMatrix?.()) return new x.constructor(
781
+ // x.rows,
782
+ // x.cols,
783
+ // clamp(x.arr.flat(1), min, max)
784
+ // );
785
+ // if(x instanceof Array) return mapfun(n => clamp(n, min, max), ...x);
786
+ // return Math.min(Math.max(x, min), max)
787
+ // }
721
788
 
722
789
  const hypot = (...x) => {
723
790
  const c0 = x.find(a => a.isComplex?.());
@@ -729,10 +796,68 @@ const hypot = (...x) => {
729
796
  };
730
797
 
731
798
 
732
- const atan2 = (x, y, rad = true) =>{
799
+ const atan2 = (y, x, rad = true) => {
800
+ if (y instanceof Array && !(x instanceof Array))
801
+ return mapfun(n => atan2(n, x, rad), ...y);
802
+
803
+ if (x instanceof Array && !(y instanceof Array))
804
+ return mapfun(n => atan2(y, n, rad), ...x);
733
805
 
806
+ if (y instanceof Array && x instanceof Array)
807
+ return y.map((v, i) => atan2(v, x[i], rad));
808
+
809
+ const phi = Math.atan2(y, x);
810
+ return rad ? phi : phi * 180 / Math.PI;
734
811
  };
735
812
 
813
+ const min$1 = (...x) => Math.min(...x);
814
+ const max$1 = (...x) => Math.max(...x);
815
+
816
+ const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
817
+
818
+ const variance = (...x) => {
819
+ const n = x.length;
820
+ if (n === 0) return NaN;
821
+ const x_mean = mean(...x);
822
+ return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / n;
823
+ };
824
+
825
+ const std = (...x) => Math.sqrt(variance(...x));
826
+
827
+ const accum_sum = (...x) => {
828
+ let result = [];
829
+ let total = 0, i; n = x.length;
830
+ for(i = 0; i < n ; i++){
831
+ total = add(total, x[i]);
832
+ result.push(total);
833
+ }
834
+ return result;
835
+ };
836
+
837
+ const accum_prod = (...x) => {
838
+ let result = [];
839
+ let prod = 1, i; n = x.length;
840
+ for(i = 0; i < n ; i++){
841
+ prod = mul(prod, x[i]);
842
+ result.push(prod);
843
+ }
844
+ return result;
845
+ };
846
+
847
+ const percentile = (X, p) => {
848
+ if (X.length === 0)
849
+ return NaN;
850
+ let a = [...X].sort((x, y) => x - y);
851
+ let index = (p / 100) * (a.length - 1);
852
+ let i = Math.floor(index);
853
+ let f = index - i;
854
+ if (i === a.length - 1)
855
+ return a[i];
856
+ return a[i] * (1 - f) + a[i + 1] * f;
857
+ };
858
+
859
+ const median = X => percentile(X, 50);
860
+
736
861
  const preload=(url)=>{
737
862
  const xhr = new XMLHttpRequest();
738
863
  xhr.open("GET", url, false);
@@ -3265,6 +3390,14 @@ class Matrix{
3265
3390
  clone() {
3266
3391
  return new Matrix(this.rows, this.cols, this.arr.flat(1));
3267
3392
  }
3393
+ toComplex(){
3394
+ this.arr = mapfun(
3395
+ x => x?.isComplex?.() ? x : new Complex(x, 0),
3396
+ ...this.arr
3397
+ );
3398
+ this.#maintain();
3399
+ return this;
3400
+ }
3268
3401
  [Symbol.iterator]() {
3269
3402
  return this.arr[Symbol.iterator]();
3270
3403
  }
@@ -3520,7 +3653,7 @@ class Matrix{
3520
3653
  // return result;
3521
3654
  // }
3522
3655
  map(Imin, Imax, Fmin, Fmax) {
3523
- this.arr = map$1(this.arr);
3656
+ this.arr = map$1(this.arr, Imin, Imax, Fmin, Fmax);
3524
3657
  return this;
3525
3658
  }
3526
3659
  lerp(min, max) {
@@ -3919,36 +4052,36 @@ const prod=(...x)=>{
3919
4052
  }
3920
4053
  return Y.length===1?Y[0]:Y;
3921
4054
  };
3922
- const min$1=(...num)=>{
3923
- if(num.every(n=>typeof n==="number"))return Math.min(...num);
3924
- const Y=[];
3925
- for(let i=0;i<num.length;i++){
3926
- if(num[i] instanceof Array)Y.push(min$1(...num[i]));
3927
- else if(num[i] instanceof Object){
3928
- Y.push(
3929
- Object.fromEntries(
3930
- [Object.entries(num[i]).sort((a,b)=>a[1]-b[1])[0]]
3931
- )
3932
- );
3933
- }
3934
- }
3935
- return Y.length===1?Y[0]:Y;
3936
- };
3937
- const max$1=(...num)=>{
3938
- if(num.every(n=>typeof n==="number"))return Math.max(...num);
3939
- const Y=[];
3940
- for(let i=0;i<num.length;i++){
3941
- if(num[i] instanceof Array)Y.push(min$1(...num[i]));
3942
- else if(num[i] instanceof Object){
3943
- Y.push(
3944
- Object.fromEntries(
3945
- [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
3946
- )
3947
- );
3948
- }
3949
- }
3950
- return Y.length===1?Y[0]:Y;
3951
- };
4055
+ // const min=(...num)=>{
4056
+ // if(num.every(n=>typeof n==="number"))return Math.min(...num);
4057
+ // const Y=[];
4058
+ // for(let i=0;i<num.length;i++){
4059
+ // if(num[i] instanceof Array)Y.push(min(...num[i]));
4060
+ // else if(num[i] instanceof Object){
4061
+ // Y.push(
4062
+ // Object.fromEntries(
4063
+ // [Object.entries(num[i]).sort((a,b)=>a[1]-b[1])[0]]
4064
+ // )
4065
+ // )
4066
+ // }
4067
+ // }
4068
+ // return Y.length===1?Y[0]:Y;
4069
+ // }
4070
+ // const max=(...num)=>{
4071
+ // if(num.every(n=>typeof n==="number"))return Math.max(...num);
4072
+ // const Y=[];
4073
+ // for(let i=0;i<num.length;i++){
4074
+ // if(num[i] instanceof Array)Y.push(min(...num[i]));
4075
+ // else if(num[i] instanceof Object){
4076
+ // Y.push(
4077
+ // Object.fromEntries(
4078
+ // [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
4079
+ // )
4080
+ // )
4081
+ // }
4082
+ // }
4083
+ // return Y.length===1?Y[0]:Y;
4084
+ // }
3952
4085
  const accum=(...num)=>{
3953
4086
  if(num.every(n=>typeof n==="number")){
3954
4087
  let acc = num.reduce((x, y) => [...x, x[x.length - 1] + y], [0]);
@@ -4602,7 +4735,7 @@ class TimeAnimation {
4602
4735
  this.t += this.state.step;
4603
4736
  this.i++;
4604
4737
 
4605
- this.tx = map$1(this.t, 0, this.state.duration);
4738
+ this.tx = map$1(this.t, 0, this.state.duration, 0, 1);
4606
4739
  this.ty = this.state.ease(this.tx);
4607
4740
 
4608
4741
  this.callback(this);
@@ -5610,4 +5743,4 @@ if(globalThis?.document){
5610
5743
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5611
5744
  }
5612
5745
 
5613
- export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$1 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_swipe_event, bind_touch_event, bind_view_event, bind_wheel_event, cartesianProduct, cbrt, ceil, clamp, clock, combinaison, complex, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, event_controller, exp$1 as exp, floor, fract, geomspace, getEvent, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun, matrix, matrix2, matrix3, matrix4, max$1 as max, min$1 as min, modulo, mul, norm, nthr, nums, obj2str, ones, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, toggle_event_listener, trunc, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, zeros };
5746
+ export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$1 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, accum_prod, accum_sum, acos$1 as acos, acosh, acot, add, animation, apply_fun, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_swipe_event, bind_touch_event, bind_view_event, bind_wheel_event, cartesianProduct, cbrt, ceil, clamp, clock, combinaison, complex, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, event_controller, exp$1 as exp, floor, fract, geomspace, getEvent, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun, matrix, matrix2, matrix3, matrix4, max$1 as max, mean, median, min$1 as min, modulo, mul, norm, nthr, nums, obj2str, ones, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, percentile, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, std, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, toggle_event_listener, trunc, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitForUIElm, waitForUIElmSync, zeros };