ziko 0.54.5 → 0.55.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.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Dec 12 2025 17:18:59 GMT+0100 (UTC+01:00)
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
@@ -46,8 +46,280 @@ const apply_fun = (x, fn) => {
46
46
  return fn(x)
47
47
  };
48
48
 
49
- // import {sum,prod,deg2rad} from "../utils/index.js";
50
- // Should avoid CD
49
+ const base2base = (value, fromBase, toBase) => {
50
+
51
+ const dec = parseInt(value, fromBase);
52
+ if (Number.isNaN(dec)) throw new TypeError('Invalid value for the given base');
53
+
54
+ return dec.toString(toBase);
55
+ };
56
+
57
+ const _add = (x, y) =>{
58
+ if(typeof x === 'number'){
59
+ if(typeof y === 'number') return x + y;
60
+ if(y.isComplex?.()) {
61
+ return y.clone().add(x);
62
+ }
63
+ }
64
+ if(x.isComplex?.()){
65
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
66
+ }
67
+ };
68
+
69
+ const _sub = (x, y) =>{
70
+ if(typeof x === 'number'){
71
+ if(typeof y === 'number') return x - y;
72
+ if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
73
+ }
74
+ if(x.isComplex?.()){
75
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
76
+ }
77
+ };
78
+
79
+ const _mul = (x, y) =>{
80
+ if(typeof x === 'number'){
81
+ if(typeof y === 'number') return x * y;
82
+ if(y.isComplex?.()) return y.clone().mul(x);
83
+ }
84
+ if(x.isComplex?.()){
85
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
86
+ }
87
+ };
88
+
89
+ const _div = (x, y) =>{
90
+ if(typeof x === 'number'){
91
+ if(typeof y === 'number') return x / y;
92
+ if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
93
+ }
94
+ if(x.isComplex?.()){
95
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
96
+ }
97
+ };
98
+
99
+ const _modulo = (x, y) =>{
100
+ if(typeof x === 'number'){
101
+ if(typeof y === 'number') return x % y;
102
+ if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
103
+ }
104
+ if(x.isComplex?.()){
105
+ if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
106
+ }
107
+ };
108
+
109
+ const add=(a,...b)=>{
110
+ let res = a;
111
+ for(let i=0; i<b.length; i++)
112
+ res = _add(res, b[i]);
113
+ return res;
114
+ };
115
+ const sub=(a,...b)=>{
116
+ let res = a;
117
+ for(let i=0; i<b.length; i++)
118
+ res = _sub(res, b[i]);
119
+ return res;
120
+ };
121
+ const mul=(a,...b)=>{
122
+ let res = a;
123
+ for(let i=0; i<b.length; i++)
124
+ res = _mul(res, b[i]);
125
+ return res;
126
+ };
127
+ const div=(a,...b)=>{
128
+ let res = a;
129
+ for(let i=0; i<b.length; i++)
130
+ res = _div(res, b[i]);
131
+ return res;
132
+ };
133
+ const modulo=(a,...b)=>{
134
+ let res = a;
135
+ for(let i=0; i<b.length; i++)
136
+ res = _modulo(res, b[i]);
137
+ return res;
138
+ };
139
+
140
+ const min$1 = (...x) => Math.min(...x);
141
+ const max$1 = (...x) => Math.max(...x);
142
+
143
+ const binomial = (n, k) =>{
144
+ if(n !== Math.floor(n)) return TypeError('n must be an integer');
145
+ if(k !== Math.floor(k)) return TypeError('k must be an integer');
146
+ if (n < 0) return TypeError('n must be non-negative');
147
+ if (k < 0 || n < 0 || k > n) return 0;
148
+ if (k > n - k) k = n - k;
149
+ let c = 1, i;
150
+ for (i = 0; i < k; i++)
151
+ c = c * (n - i) / (i + 1);
152
+ return c;
153
+ };
154
+
155
+ const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
156
+
157
+ const variance = (...x) => {
158
+ const n = x.length;
159
+ if (n === 0) return NaN;
160
+ const x_mean = mean(...x);
161
+ return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / n;
162
+ };
163
+
164
+ const std = (...x) => Math.sqrt(variance(...x));
165
+
166
+ const accum_sum = (...x) => {
167
+ let result = [];
168
+ let total = 0, i, n = x.length;
169
+ for(i = 0; i < n ; i++){
170
+ total = add(total, x[i]);
171
+ result.push(total);
172
+ }
173
+ return result;
174
+ };
175
+
176
+ const accum_prod = (...x) => {
177
+ let result = [];
178
+ let prod = 1, i, n = x.length;
179
+ for(i = 0; i < n ; i++){
180
+ prod = mul(prod, x[i]);
181
+ result.push(prod);
182
+ }
183
+ return result;
184
+ };
185
+
186
+ const percentile = (X, p) => {
187
+ if (X.length === 0)
188
+ return NaN;
189
+ let a = [...X].sort((x, y) => x - y);
190
+ let index = (p / 100) * (a.length - 1);
191
+ let i = Math.floor(index);
192
+ let f = index - i;
193
+ if (i === a.length - 1)
194
+ return a[i];
195
+ return a[i] * (1 - f) + a[i + 1] * f;
196
+ };
197
+
198
+ const median = X => percentile(X, 50);
199
+
200
+ class Random {
201
+ static int(a, b){
202
+ return Math.floor(this.float(a, b));
203
+ }
204
+ static float(a, b){
205
+ return b !== undefined
206
+ ? Math.random() * (b - a) + a
207
+ : Math.random() * a;
208
+ }
209
+ static bin(){
210
+ return this.int(2);
211
+ }
212
+ static oct(){
213
+ return this.int(8);
214
+ }
215
+ static dec(){
216
+ return this.int(10);
217
+ }
218
+ static hex(){
219
+ return base2base(this.int(16), 10, 16);
220
+ }
221
+ static char(upperCase = false){
222
+ const i = upperCase
223
+ ? this.int(65, 91)
224
+ : this.int(97, 123);
225
+ return String.fromCharCode(i);
226
+ }
227
+ static bool(){
228
+ return Boolean(this.int(2));
229
+ }
230
+ static get color(){
231
+ return {
232
+ hex : () =>
233
+ `#${this.int(0xffffff).toString(16).padStart(6, '0')}`,
234
+
235
+ hexa : () => {
236
+ const [r,g,b,a] = Array.from(
237
+ {length:4},
238
+ () => this.int(0xff).toString(16).padStart(2,'0')
239
+ );
240
+ return `#${r}${g}${b}${a}`;
241
+ },
242
+ rgb : () => {
243
+ const [r,g,b] = Array.from({length:3}, () => this.int(0xff));
244
+ return `rgb(${r}, ${g}, ${b})`;
245
+ },
246
+ rgba : () => {
247
+ const [r,g,b] = Array.from({length:3}, () => this.int(0xff));
248
+ const a = Math.random().toFixed(2);
249
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
250
+ },
251
+ hsl : () => {
252
+ const h = this.int(360);
253
+ const s = this.int(100);
254
+ const l = this.int(100);
255
+ return `hsl(${h}, ${s}%, ${l}%)`;
256
+ },
257
+ hsla : () => {
258
+ const h = this.int(360);
259
+ const s = this.int(100);
260
+ const l = this.int(100);
261
+ const a = Math.random().toFixed(2);
262
+ return `hsla(${h}, ${s}%, ${l}%, ${a})`;
263
+ },
264
+ gray : () => {
265
+ const g = this.int(0xff);
266
+ return `rgb(${g}, ${g}, ${g})`;
267
+ }
268
+ };
269
+ }
270
+ static get sample(){
271
+ const R = this;
272
+ return {
273
+ int : (n,a,b) => Array.from({length:n}, () => R.int(a,b)),
274
+ float : (n,a,b) => Array.from({length:n}, () => R.float(a,b)),
275
+ char : (n,upper=false) => Array.from({length:n}, () => R.char(upper)),
276
+ bool : n => Array.from({length:n}, () => R.bool()),
277
+ bin : n => Array.from({length:n}, () => R.bin()),
278
+ oct : n => Array.from({length:n}, () => R.oct()),
279
+ dec : n => Array.from({length:n}, () => R.dec()),
280
+ hex : n => Array.from({length:n}, () => R.hex()),
281
+ get color(){
282
+ return {
283
+ hex : n => Array.from({length:n}, () => R.color.hex()),
284
+ hexa : n => Array.from({length:n}, () => R.color.hexa()),
285
+ rgb : n => Array.from({length:n}, () => R.color.rgb()),
286
+ rgba : n => Array.from({length:n}, () => R.color.rgba()),
287
+ hsl : n => Array.from({length:n}, () => R.color.hsl()),
288
+ hsla : n => Array.from({length:n}, () => R.color.hsla()),
289
+ gray : n => Array.from({length:n}, () => R.color.gray())
290
+ };
291
+ },
292
+ choice : (n, choices, p) =>
293
+ Array.from({length:n}, () => R.choice(choices, p))
294
+ };
295
+ }
296
+ static shuffle(arr){
297
+ return [...arr].sort(() => 0.5 - Math.random());
298
+ }
299
+ static choice(choices = [1,2,3], p = new Array(choices.length).fill(1 / choices.length)){
300
+ const acc = accum_sum(...p).map(v => v * 100);
301
+ const pool = new Array(100);
302
+ pool.fill(choices[0], 0, acc[0]);
303
+ for(let i=1;i<choices.length;i++)
304
+ pool.fill(choices[i], acc[i-1], acc[i]);
305
+ return pool[this.int(pool.length)];
306
+ }
307
+ }
308
+
309
+
310
+ globalThis.Random = Random;
311
+
312
+ // // (upperCase) => upperCase ? : String.fromCharCode(rand_int(97,120))
313
+ // class Random {
314
+ // static string(length,upperCase){
315
+ // return length instanceof Array?
316
+ // new Array(this.int(...length)).fill(0).map(() => this.char(upperCase)).join(""):
317
+ // new Array(length).fill(0).map(() => this.char(upperCase)).join("");
318
+ // }
319
+
320
+ // }
321
+ // export{Random}
322
+
51
323
  class Complex{
52
324
  constructor(a = 0, b = 0) {
53
325
  if(a instanceof Complex){
@@ -125,6 +397,12 @@ class Complex{
125
397
  static Zero() {
126
398
  return new Complex(0, 0);
127
399
  }
400
+ static get Random(){
401
+ return {
402
+ int : (a, b)=> new Complex(...Random.sample.int(2, a, b) ),
403
+ float : (a, b)=> new Complex(...Random.sample.float(2, a, b) ),
404
+ }
405
+ }
128
406
  static Twiddle(N, K){
129
407
  const phi = -2 * Math.PI * K / N;
130
408
  return new Complex(
@@ -625,89 +903,6 @@ const sig = (...x) => mapfun(
625
903
  ...x
626
904
  );
627
905
 
628
- const _add = (x, y) =>{
629
- if(typeof x === 'number'){
630
- if(typeof y === 'number') return x + y;
631
- if(y.isComplex?.()) {
632
- return y.clone().add(x);
633
- }
634
- }
635
- if(x.isComplex?.()){
636
- if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
637
- }
638
- };
639
-
640
- const _sub = (x, y) =>{
641
- if(typeof x === 'number'){
642
- if(typeof y === 'number') return x - y;
643
- if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
644
- }
645
- if(x.isComplex?.()){
646
- if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
647
- }
648
- };
649
-
650
- const _mul = (x, y) =>{
651
- if(typeof x === 'number'){
652
- if(typeof y === 'number') return x * y;
653
- if(y.isComplex?.()) return y.clone().mul(x);
654
- }
655
- if(x.isComplex?.()){
656
- if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
657
- }
658
- };
659
-
660
- const _div = (x, y) =>{
661
- if(typeof x === 'number'){
662
- if(typeof y === 'number') return x / y;
663
- if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
664
- }
665
- if(x.isComplex?.()){
666
- if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
667
- }
668
- };
669
-
670
- const _modulo = (x, y) =>{
671
- if(typeof x === 'number'){
672
- if(typeof y === 'number') return x % y;
673
- if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
674
- }
675
- if(x.isComplex?.()){
676
- if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
677
- }
678
- };
679
-
680
- const add=(a,...b)=>{
681
- let res = a;
682
- for(let i=0; i<b.length; i++)
683
- res = _add(res, b[i]);
684
- return res;
685
- };
686
- const sub=(a,...b)=>{
687
- let res = a;
688
- for(let i=0; i<b.length; i++)
689
- res = _sub(res, b[i]);
690
- return res;
691
- };
692
- const mul=(a,...b)=>{
693
- let res = a;
694
- for(let i=0; i<b.length; i++)
695
- res = _mul(res, b[i]);
696
- return res;
697
- };
698
- const div=(a,...b)=>{
699
- let res = a;
700
- for(let i=0; i<b.length; i++)
701
- res = _div(res, b[i]);
702
- return res;
703
- };
704
- const modulo=(a,...b)=>{
705
- let res = a;
706
- for(let i=0; i<b.length; i++)
707
- res = _modulo(res, b[i]);
708
- return res;
709
- };
710
-
711
906
  const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
712
907
  const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
713
908
 
@@ -728,64 +923,6 @@ const map$1 = (x, a, b, c, d) => apply_fun(
728
923
  v => lerp(norm(v, a, b), c, d)
729
924
  );
730
925
 
731
-
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
- // }
788
-
789
926
  const hypot = (...x) => {
790
927
  const c0 = x.find(a => a.isComplex?.());
791
928
  if (c0) {
@@ -810,54 +947,6 @@ const atan2 = (y, x, rad = true) => {
810
947
  return rad ? phi : phi * 180 / Math.PI;
811
948
  };
812
949
 
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
-
861
950
  const not = x => {
862
951
  if(x.isComplex?.()) return new x.constructor(not(x.a), not(x.b))
863
952
  if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, x.arr.flat(1).map(not))
@@ -3514,6 +3603,7 @@ class Matrix{
3514
3603
  get inv() {
3515
3604
  return matrix_inverse(this)
3516
3605
  }
3606
+ // normalize names
3517
3607
  static eye(size) {
3518
3608
  let result = new Matrix(size, size);
3519
3609
  for (let i = 0; i < size; i++)
@@ -3538,6 +3628,20 @@ class Matrix{
3538
3628
  for (let j = 0; j < cols; j++) result.arr[i][j] = number;
3539
3629
  return result;
3540
3630
  }
3631
+ static get Random(){
3632
+ return {
3633
+ int : (r, c, a, b)=> new Matrix(
3634
+ r,
3635
+ c,
3636
+ Random.sample.int(r*c, a, b)
3637
+ ),
3638
+ float : (r, c, a,)=> new Matrix(
3639
+ r,
3640
+ c,
3641
+ Random.sample.float(r*c, a, b)
3642
+ ),
3643
+ }
3644
+ }
3541
3645
  hstack(...matrices) {
3542
3646
  const M=[this, ...matrices].reduce((a,b)=>hstack(a, b));
3543
3647
  Object.assign(this, M);
@@ -3992,21 +4096,6 @@ const matrix2=(...element)=>new Matrix(2, 2, element);
3992
4096
  const matrix3=(...element)=>new Matrix(3, 3, element);
3993
4097
  const matrix4=(...element)=>new Matrix(4, 4, element);
3994
4098
 
3995
- const powerSet=originalSet=>{
3996
- const subSets = [];
3997
- const NUMBER_OF_COMBINATIONS = 2 ** originalSet.length;
3998
- for (let i = 0; i < NUMBER_OF_COMBINATIONS; i += 1) {
3999
- const subSet = [];
4000
- for (let j = 0; j < originalSet.length; j += 1) {
4001
- if (i & (1 << j)) {
4002
- subSet.push(originalSet[j]);
4003
- }
4004
- }
4005
- subSets.push(subSet);
4006
- }
4007
- return subSets;
4008
- };
4009
-
4010
4099
  const zeros=(n)=>new Array(n).fill(0);
4011
4100
  const ones=(n)=>new Array(n).fill(1);
4012
4101
  const nums=(num,n)=>new Array(n).fill(num);
@@ -4075,97 +4164,6 @@ const geomspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
4075
4164
  }
4076
4165
  };
4077
4166
 
4078
- // Mixed calcul
4079
- const sum=(...x)=>{
4080
- if(x.every(n=>typeof n==="number")){
4081
- let s = x[0];
4082
- for (let i = 1; i < x.length; i++) s += x[i];
4083
- return s;
4084
- }
4085
- const Y=[];
4086
- for(let i=0;i<x.length;i++){
4087
- if(x[i] instanceof Array)Y.push(sum(...x[i]));
4088
- else if(x[i] instanceof Object){
4089
- Y.push(sum(...Object.values(x[i])));
4090
- }
4091
- }
4092
- return Y.length===1?Y[0]:Y;
4093
- };
4094
- const prod=(...x)=>{
4095
- if(x.every(n=>typeof n==="number")){
4096
- let p = x[0];
4097
- for (let i = 1; i < x.length; i++) p *= x[i];
4098
- return p;
4099
- }
4100
- const Y=[];
4101
- for(let i=0;i<x.length;i++){
4102
- if(x[i] instanceof Array)Y.push(prod(...x[i]));
4103
- else if(x[i] instanceof Object){
4104
- Y.push(prod(...Object.values(x[i])));
4105
- }
4106
- }
4107
- return Y.length===1?Y[0]:Y;
4108
- };
4109
- // const min=(...num)=>{
4110
- // if(num.every(n=>typeof n==="number"))return Math.min(...num);
4111
- // const Y=[];
4112
- // for(let i=0;i<num.length;i++){
4113
- // if(num[i] instanceof Array)Y.push(min(...num[i]));
4114
- // else if(num[i] instanceof Object){
4115
- // Y.push(
4116
- // Object.fromEntries(
4117
- // [Object.entries(num[i]).sort((a,b)=>a[1]-b[1])[0]]
4118
- // )
4119
- // )
4120
- // }
4121
- // }
4122
- // return Y.length===1?Y[0]:Y;
4123
- // }
4124
- // const max=(...num)=>{
4125
- // if(num.every(n=>typeof n==="number"))return Math.max(...num);
4126
- // const Y=[];
4127
- // for(let i=0;i<num.length;i++){
4128
- // if(num[i] instanceof Array)Y.push(min(...num[i]));
4129
- // else if(num[i] instanceof Object){
4130
- // Y.push(
4131
- // Object.fromEntries(
4132
- // [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
4133
- // )
4134
- // )
4135
- // }
4136
- // }
4137
- // return Y.length===1?Y[0]:Y;
4138
- // }
4139
- const accum=(...num)=>{
4140
- if(num.every(n=>typeof n==="number")){
4141
- let acc = num.reduce((x, y) => [...x, x[x.length - 1] + y], [0]);
4142
- acc.shift();
4143
- return acc;
4144
- }
4145
- const Y=[];
4146
- for(let i=0;i<num.length;i++){
4147
- if(num[i] instanceof Array)Y.push(accum(...num[i]));
4148
- else if(num[i] instanceof Object){
4149
- Y.push(null
4150
- // Object.fromEntries(
4151
- // [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
4152
- // )
4153
- );
4154
- }
4155
- }
4156
- return Y.length===1?Y[0]:Y;
4157
- };
4158
-
4159
- //moy
4160
- //med
4161
- //variance
4162
- //std
4163
- //mode
4164
- //acccum
4165
- //min2max
4166
- //max2min
4167
- //percentile
4168
-
4169
4167
  /** @module Math */
4170
4168
  /**
4171
4169
  * Checks if a value is within the specified range.
@@ -4278,325 +4276,6 @@ const Utils={
4278
4276
  isApproximatlyEqual
4279
4277
  };
4280
4278
 
4281
- // const subSet = (...arr) => {
4282
- // let list = arange(0, 2 ** arr.length, 1);
4283
- // let bin = list.map((n) => n.toString(2).padStart(arr.length, '0')).map((n) => n.split("").map((n) => +n));
4284
- // let sub = bin.map((n) => n.map((m, i) => (m === 1 ? arr[i] : null))).map((n) => n.filter((x) => x !== null));
4285
- // return sub;
4286
- // };
4287
- const subSet = null;
4288
-
4289
- const Base={
4290
- _mode:Number,
4291
- _map:function(func,number,toBase){
4292
- if (number instanceof Matrix)
4293
- return new Matrix(
4294
- number.rows,
4295
- number.cols,
4296
- number.arr.flat(1).map(n=>func(n,toBase))
4297
- );
4298
- else if (number instanceof Complex) return new Complex(func(number.a,toBase),func(number.b,toBase));
4299
- else if (number instanceof Array) return number.map((n) =>func(n,toBase));
4300
- },
4301
- dec2base(dec,base){
4302
- base<=10?this._mode=Number:this._mode=String;
4303
- //this._mode=String
4304
- if (typeof dec === "number") return this._mode((dec >>> 0).toString(base));
4305
- return this._map(this.dec2base,dec,base)
4306
- },
4307
- dec2bin(dec){
4308
- return this.dec2base(dec,2);
4309
- },
4310
- dec2oct(dec){
4311
- return this.dec2base(dec,8);
4312
- },
4313
- dec2hex(dec){
4314
- return this.dec2base(dec,16);
4315
- },
4316
- bin2base(bin, base) {
4317
- return this.dec2base(this.bin2dec(bin),base)
4318
- },
4319
- bin2dec(bin){
4320
- return this._mode("0b"+bin);
4321
- },
4322
- bin2oct(bin){
4323
- return this.bin2base(bin,8);
4324
- },
4325
- bin2hex(bin){
4326
- return this.bin2base(bin,16);
4327
- },
4328
- oct2dec(oct){
4329
- return this._mode("0o"+oct);
4330
- },
4331
- oct2bin(oct){
4332
- return this.dec2bin(this.oct2dec(oct))
4333
- },
4334
- oct2hex(oct){
4335
- return this.dec2hex(this.oct2dec(oct))
4336
- },
4337
- oct2base(oct, base) {
4338
- return this.dec2base(this.oct2dec(oct),base)
4339
- },
4340
- hex2dec(hex){
4341
- return this._mode("0x"+hex);
4342
- },
4343
- hex2bin(hex){
4344
- return this.dec2bin(this.hex2dec(hex))
4345
- },
4346
- hex2oct(hex){
4347
- return this.dec2oct(this.hex2dec(hex))
4348
- },
4349
- hex2base(hex, base) {
4350
- return this.dec2base(this.hex2dec(hex),base)
4351
- },
4352
- IEEE32toDec(Bin){
4353
- let IEEE32=Bin.split(" ").join("").padEnd(32,"0");
4354
- let s=IEEE32[0];
4355
- let e=2**(+("0b"+IEEE32.slice(1,9))-127);
4356
- let m=IEEE32.slice(9,32).split("").map(n=>+n);
4357
- let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
4358
- let dec=(-1)**s*(1+M)*e;
4359
- return dec
4360
- },
4361
- IEEE64toDec(Bin){
4362
- let IEEE64=Bin.split(" ").join("").padEnd(64,"0");
4363
- let s=IEEE64[0];
4364
- let e=2**(+("0b"+IEEE64.slice(1,12))-1023);
4365
- let m=IEEE64.slice(13,64).split("").map(n=>+n);
4366
- let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
4367
- let dec=(-1)**s*(1+M)*e;
4368
- return dec;
4369
- }
4370
- };
4371
-
4372
- class Permutation {
4373
- static withDiscount(arr, l = arr.length) {
4374
- if (l === 1) return arr.map((n) => [n]);
4375
- const permutations = [];
4376
- let smallerPermutations;
4377
- smallerPermutations = this.withDiscount(arr, l - 1);
4378
- arr.forEach((currentOption) => {
4379
- smallerPermutations.forEach((smallerPermutation) => {
4380
- permutations.push([currentOption].concat(smallerPermutation));
4381
- });
4382
- });
4383
- return permutations;
4384
- }
4385
- static withoutDiscount(arr) {
4386
- const l = arr.length;
4387
- if (l === 1) return arr.map((n) => [n]);
4388
- const permutations = [];
4389
- const smallerPermutations = this.withoutDiscount(arr.slice(1));
4390
- const firstOption = arr[0];
4391
- for (let i = 0; i < smallerPermutations.length; i++) {
4392
- const smallerPermutation = smallerPermutations[i];
4393
- for (let j = 0; j <= smallerPermutation.length; j++) {
4394
- const permutationPrefix = smallerPermutation.slice(0, j);
4395
- const permutationSuffix = smallerPermutation.slice(j);
4396
- permutations.push(permutationPrefix.concat([firstOption], permutationSuffix));
4397
- }
4398
- }
4399
- return permutations;
4400
- }
4401
- }
4402
-
4403
- class Combinaison {
4404
- static withDiscount(comboOptions, comboLength) {
4405
- if (comboLength === 1) {
4406
- return comboOptions.map((comboOption) => [comboOption]);
4407
- }
4408
- const combos = [];
4409
- comboOptions.forEach((currentOption, optionIndex) => {
4410
- const smallerCombos = this.withDiscount(comboOptions.slice(optionIndex), comboLength - 1);
4411
- smallerCombos.forEach((smallerCombo) => {
4412
- combos.push([currentOption].concat(smallerCombo));
4413
- });
4414
- });
4415
- return combos;
4416
- }
4417
- static withoutDiscount(comboOptions, comboLength) {
4418
- if (comboLength === 1) {
4419
- return comboOptions.map((comboOption) => [comboOption]);
4420
- }
4421
- const combos = [];
4422
- comboOptions.forEach((currentOption, optionIndex) => {
4423
- const smallerCombos = this.withoutDiscount(comboOptions.slice(optionIndex + 1), comboLength - 1);
4424
- smallerCombos.forEach((smallerCombo) => {
4425
- combos.push([currentOption].concat(smallerCombo));
4426
- });
4427
- });
4428
-
4429
- return combos;
4430
- }
4431
- }
4432
- const combinaison=(comboOptions, comboLength, discount=false)=>Combinaison[discount?"withDiscount":"withoutDiscount"](comboOptions, comboLength);
4433
-
4434
- class Random {
4435
- static float(a = 1, b) {
4436
- return b ? Math.random() * (b - a) + a : a * Math.random();
4437
- }
4438
- static int(a, b) {
4439
- return Math.floor(this.float(a, b));
4440
- }
4441
- static char(upperCase){
4442
- upperCase=upperCase??this.bool();
4443
- const Char=String.fromCharCode(this.int(97,120));
4444
- return upperCase?Char.toUpperCase():Char;
4445
- }
4446
- static bool(){
4447
- return [false,true][Math.floor(Math.random()*2)];
4448
- }
4449
- static string(length,upperCase){
4450
- return length instanceof Array?
4451
- new Array(this.int(...length)).fill(0).map(() => this.char(upperCase)).join(""):
4452
- new Array(length).fill(0).map(() => this.char(upperCase)).join("");
4453
- }
4454
- static bin() {
4455
- return this.int(2);
4456
- }
4457
- static oct() {
4458
- return this.int(8);
4459
- }
4460
- static dec() {
4461
- return this.int(8);
4462
- }
4463
- static hex() {
4464
- return this.int(16);
4465
- }
4466
- static choice(choices = [1, 2, 3], p = new Array(choices.length).fill(1 / choices.length)) {
4467
- let newchoice = new Array(100);
4468
- p=Utils.accum(...p).map(n=>n*100);
4469
- newchoice.fill(choices[0], 0, p[0]);
4470
- for (let i = 1; i < choices.length; i++) newchoice.fill(choices[i], p[i - 1], p[i]);
4471
- return newchoice[this.int(newchoice.length - 1)];
4472
- }
4473
- static shuffleArr(arr){
4474
- return arr.sort(()=>0.5-Math.random())
4475
- }
4476
- static floats(n, a, b) {
4477
- return new Array(n).fill(0).map(() => this.float(a, b));
4478
- }
4479
- static ints(n, a, b) {
4480
- return new Array(n).fill(0).map(() => this.int(a, b));
4481
- }
4482
- static bools(n){
4483
- return new Array(n).fill(0).map(() => this.bool());
4484
- }
4485
- static bins(n) {
4486
- return new Array(n).fill(0).map(() => this.int(2));
4487
- }
4488
- static octs(n) {
4489
- return new Array(n).fill(0).map(() => this.int(8));
4490
- }
4491
- static decs(n) {
4492
- return new Array(n).fill(0).map(() => this.int(10));
4493
- }
4494
- static hexs(n) {
4495
- return new Array(n).fill(0).map(() => this.int(16));
4496
- }
4497
- static choices(n, choices, p) {
4498
- return new Array(n).fill(0).map(() => this.choice(choices, p));
4499
- }
4500
- static perm(...arr) {
4501
- // permutation
4502
- return arr.permS[this.int(arr.length)];
4503
- }
4504
- static color() {
4505
- return "#" + Base.dec2hex(this.float(16777216)).padStart(6,0);
4506
- }
4507
- static colors(n) {
4508
- return new Array(n).fill(null).map(()=>this.color());
4509
- }
4510
-
4511
- // Should be Moved to Matrix and Complex to avoid Circular dependencies
4512
- // static complex(a = [0,1], b = [0,1]) {
4513
- // return a instanceof Array?
4514
- // new Complex(
4515
- // this.float(a[0], a[1]),
4516
- // this.float(b[0], b[1])
4517
- // ):
4518
- // new Complex(
4519
- // ...this.floats(2,a,b)
4520
- // )
4521
-
4522
- // }
4523
- // static complexInt(a = [0,1], b = [0,1]) {
4524
- // return new Complex(
4525
- // this.int(a[0], a[1]),
4526
- // this.int(b[0], b[1])
4527
- // );
4528
- // }
4529
- // static complexBin() {
4530
- // return new Complex(...this.bins(2));
4531
- // }
4532
- // static complexOct() {
4533
- // return new Complex(...this.octs(2));
4534
- // }
4535
- // static complexDec() {
4536
- // return new Complex(...this.decs(10));
4537
- // }
4538
- // static complexHex() {
4539
- // return new Complex(...this.octs(2));
4540
- // }
4541
- // static complexes(n, a = 0, b = 1) {
4542
- // return new Array(n).fill(0).map(() => this.complex(a, b));
4543
- // }
4544
- // static complexesInt(n, a = 0, b = 1) {
4545
- // return new Array(n).fill(0).map(() => this.complexInt(a, b));
4546
- // }
4547
- // static complexesBin(n) {
4548
- // return new Array(n).fill(0).map(() => this.complexBin());
4549
- // }
4550
- // static complexesOct(n) {
4551
- // return new Array(n).fill(0).map(() => this.complexOct());
4552
- // }
4553
- // static complexesDec(n) {
4554
- // return new Array(n).fill(0).map(() => this.complexDec());
4555
- // }
4556
- // static complexesHex(n) {
4557
- // return new Array(n).fill(0).map(() => this.complexHex());
4558
- // }
4559
- // static matrix(r,c,min,max){
4560
- // return matrix(r,c,this.floats(r*c,min,max))
4561
- // }
4562
- // static matrixInt(r,c,min,max){
4563
- // return matrix(r,c,this.ints(r*c,min,max))
4564
- // }
4565
- // static matrixBin(r,c){
4566
- // return matrix(r,c,this.bins(r*c))
4567
- // }
4568
- // static matrixOct(r,c){
4569
- // return matrix(r,c,this.octs(r*c))
4570
- // }
4571
- // static matrixDec(r,c){
4572
- // return matrix(r,c,this.decs(r*c))
4573
- // }
4574
- // static matrixHex(r,c){
4575
- // return matrix(r,c,this.hex(r*c))
4576
- // }
4577
- // static matrixColor(r,c){
4578
- // return matrix(r,c,this.colors(r*c))
4579
- // }
4580
- // static matrixComplex(r,c,a,b){
4581
- // return matrix(r,c,this.complexes(r*c,a,b))
4582
- // }
4583
- // static matrixComplexInt(r,c,a,b){
4584
- // return matrix(r,c,this.complexesInt(r*c,a,b))
4585
- // }
4586
- // static matrixComplexBin(r,c){
4587
- // return matrix(r,c,this.complexesBin(r*c))
4588
- // }
4589
- // static matrixComplexOct(r,c){
4590
- // return matrix(r,c,this.complexesBin(r*c))
4591
- // }
4592
- // static matrixComplexDec(r,c){
4593
- // return matrix(r,c,this.complexesBin(r*c))
4594
- // }
4595
- // static matrixComplexHex(r,c){
4596
- // return matrix(r,c,this.complexesBin(r*c))
4597
- // }
4598
- }
4599
-
4600
4279
  const { PI, sqrt: sqrt$1, cos: cos$2, sin: sin$2, acos, pow } = Math;
4601
4280
 
4602
4281
  const linear = t => t;
@@ -5753,4 +5432,4 @@ if(globalThis?.document){
5753
5432
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5754
5433
  }
5755
5434
 
5756
- export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, 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, and, 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, nand, nor, norm, nthr, nums, obj2str, ones, or, 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, xnor, xor, zeros };
5435
+ export { App, Clock, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Matrix, PI$1 as PI, 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_prod, accum_sum, acos$1 as acos, acosh, acot, add, and, 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, binomial, cartesianProduct, cbrt, ceil, clamp, clock, 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, nand, nor, norm, nthr, nums, obj2str, ones, or, 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, ppcm, preload, rad2deg, round, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, std, step, step_fps, sub, 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, xnor, xor, zeros };