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 CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Dec 12 2025 14:53:26 GMT+0100 (UTC+01:00)
5
+ Date : Sat Dec 13 2025 00:46:54 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
@@ -127,7 +127,7 @@ class Complex{
127
127
  static Zero() {
128
128
  return new Complex(0, 0);
129
129
  }
130
- static Twidlle(N, K){
130
+ static Twiddle(N, K){
131
131
  const phi = -2 * Math.PI * K / N;
132
132
  return new Complex(
133
133
  Math.cos(phi),
@@ -730,64 +730,6 @@ const map$1 = (x, a, b, c, d) => apply_fun(
730
730
  v => lerp(norm(v, a, b), c, d)
731
731
  );
732
732
 
733
-
734
- // export const norm = (x, min, max) => {
735
- // if(x.isComplex?.()) return new x.constructor(
736
- // norm(x.a, min, max),
737
- // norm(x.b, min, max)
738
- // )
739
- // if(x.isMatrix?.()) return new x.constructor(
740
- // x.rows,
741
- // x.cols,
742
- // norm(x.arr.flat(1), min, max)
743
- // );
744
- // if(x instanceof Array) return mapfun(n => norm(n, min, max), ...x);
745
- // return min !== max ? (x - min) / (max - min) : 0;
746
- // }
747
-
748
-
749
- // export const lerp = (x, min, max) => {
750
- // if(x.isComplex?.()) return new x.constructor(
751
- // lerp(x.a, min, max),
752
- // lerp(x.b, min, max)
753
- // )
754
- // if(x.isMatrix?.()) return new x.constructor(
755
- // x.rows,
756
- // x.cols,
757
- // lerp(x.arr.flat(1), min, max)
758
- // );
759
- // if(x instanceof Array) return mapfun(n => lerp(n, min, max), ...x);
760
- // return (max - min) * x + min;
761
- // }
762
-
763
- // export const map = (x, a, b, c, d) => {
764
- // if(x.isComplex?.()) return new x.constructor(
765
- // map(x.a, a, b, c, d),
766
- // map(x.b, a, b, c, d)
767
- // )
768
- // if(x.isMatrix?.()) return new x.constructor(
769
- // x.rows,
770
- // x.cols,
771
- // map(x.arr.flat(1), a, b, c, d)
772
- // );
773
- // if(x instanceof Array) return mapfun(n => map(n, a, b, c, d), ...x);
774
- // return lerp(norm(x, a, b), c, d);
775
- // }
776
-
777
- // export const clamp = (x, min, max) => {
778
- // if(x.isComplex?.()) return new x.constructor(
779
- // clamp(x.a, min, max),
780
- // clamp(x.b, min, max)
781
- // )
782
- // if(x.isMatrix?.()) return new x.constructor(
783
- // x.rows,
784
- // x.cols,
785
- // clamp(x.arr.flat(1), min, max)
786
- // );
787
- // if(x instanceof Array) return mapfun(n => clamp(n, min, max), ...x);
788
- // return Math.min(Math.max(x, min), max)
789
- // }
790
-
791
733
  const hypot = (...x) => {
792
734
  const c0 = x.find(a => a.isComplex?.());
793
735
  if (c0) {
@@ -815,6 +757,18 @@ const atan2 = (y, x, rad = true) => {
815
757
  const min$1 = (...x) => Math.min(...x);
816
758
  const max$1 = (...x) => Math.max(...x);
817
759
 
760
+ const binomial = (n, k) =>{
761
+ if(n !== Math.floor(n)) return TypeError('n must be an integer');
762
+ if(k !== Math.floor(k)) return TypeError('k must be an integer');
763
+ if (n < 0) return TypeError('n must be non-negative');
764
+ if (k < 0 || n < 0 || k > n) return 0;
765
+ if (k > n - k) k = n - k;
766
+ let c = 1, i;
767
+ for (i = 0; i < k; i++)
768
+ c = c * (n - i) / (i + 1);
769
+ return c;
770
+ };
771
+
818
772
  const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
819
773
 
820
774
  const variance = (...x) => {
@@ -860,6 +814,60 @@ const percentile = (X, p) => {
860
814
 
861
815
  const median = X => percentile(X, 50);
862
816
 
817
+ const not = x => {
818
+ if(x.isComplex?.()) return new x.constructor(not(x.a), not(x.b))
819
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, x.arr.flat(1).map(not))
820
+ return + !x;
821
+ };
822
+ const handle_complex_and_matrix = (x, operation) => {
823
+ if (x.every(n => n.isComplex?.())) {
824
+ const Re = x.map(n => n.a);
825
+ const Im = x.map(n => n.b);
826
+ return new x[0].constructor(
827
+ operation(...Re),
828
+ operation(...Im)
829
+ );
830
+ }
831
+
832
+ if (x.every(n => n.isMatrix?.())) {
833
+ if (!x.every(mat => mat.rows === x[0].rows && mat.cols === x[0].cols)) {
834
+ return TypeError('All matrices must have the same shape');
835
+ }
836
+
837
+ const { rows, cols } = x[0];
838
+ const Y = Array.from({ length: rows }, (_, i) =>
839
+ Array.from({ length: cols }, (_, j) =>
840
+ operation(...x.map(mat => mat.arr[i][j]))
841
+ )
842
+ );
843
+ return new x[0].constructor(Y);
844
+ }
845
+
846
+ return null; // Return null if no Complex or Matrix found
847
+ };
848
+
849
+ const and = (...x) => {
850
+ const result = handle_complex_and_matrix(x, and);
851
+ if (result !== null) return result;
852
+ return x.reduce((n, m) => (n &= m), 1);
853
+ };
854
+
855
+ const or = (...x) => {
856
+ const result = handle_complex_and_matrix(x, or);
857
+ if (result !== null) return result;
858
+ return x.reduce((n, m) => (n |= m), 0);
859
+ };
860
+
861
+ const xor = (...x) => {
862
+ const result = handle_complex_and_matrix(x, xor);
863
+ if (result !== null) return result;
864
+ return x.reduce((n, m) => (n ^= m), 0);
865
+ };
866
+
867
+ const nand = (...x) => not(and(...x));
868
+ const nor = (...x) => not(or(...x));
869
+ const xnor = (...x) => not(xor(...x));
870
+
863
871
  const preload=(url)=>{
864
872
  const xhr = new XMLHttpRequest();
865
873
  xhr.open("GET", url, false);
@@ -3940,20 +3948,230 @@ const matrix2=(...element)=>new Matrix(2, 2, element);
3940
3948
  const matrix3=(...element)=>new Matrix(3, 3, element);
3941
3949
  const matrix4=(...element)=>new Matrix(4, 4, element);
3942
3950
 
3943
- const powerSet=originalSet=>{
3944
- const subSets = [];
3945
- const NUMBER_OF_COMBINATIONS = 2 ** originalSet.length;
3946
- for (let i = 0; i < NUMBER_OF_COMBINATIONS; i += 1) {
3947
- const subSet = [];
3948
- for (let j = 0; j < originalSet.length; j += 1) {
3949
- if (i & (1 << j)) {
3950
- subSet.push(originalSet[j]);
3951
- }
3952
- }
3953
- subSets.push(subSet);
3951
+ class Random{
3952
+ static int(a, b){
3953
+ return Math.floor(this.float(a, b));
3954
3954
  }
3955
- return subSets;
3956
- };
3955
+ static float(a, b){
3956
+ return b ? Math.random() * (b - a) + a : a * Math.random();
3957
+ }
3958
+ static bin
3959
+ static oct
3960
+ static hex
3961
+ static char
3962
+ static bool
3963
+ static string
3964
+
3965
+ static sample
3966
+ static shuffle
3967
+
3968
+ }
3969
+ // import { Utils } from "../utils/index.js";
3970
+ // // import{ Base } from "../--discret/index.js"
3971
+
3972
+ // export const rand_float = (a, b) => b ? Math.random() * (b - a) + a : a * Math.random();
3973
+ // export const rand_int = (a, b) => Math.floor(rand_float(a, b));
3974
+ // export const rand_char = (upperCase) =>{
3975
+ // const i = upperCase ? rand_int(65,90) : rand_int(97,120);
3976
+ // return String.fromCharCode(i);
3977
+ // }
3978
+ // export const rand_bool = () => Boolean(rand_int(1));
3979
+ // export const rand_bin = () => rand_int(1);
3980
+ // export const rand_oct = () => rand_int(7);
3981
+
3982
+ // export const rand_hex_color = () => `#${rand_int(0xffffff).toString(16).padStart(6, '0')}`
3983
+
3984
+ // export const rand_hexa_color = () => {
3985
+ // const r = rand_int(0xff).toString(16).padStart(2, '0');
3986
+ // const g = rand_int(0xff).toString(16).padStart(2, '0');
3987
+ // const b = rand_int(0xff).toString(16).padStart(2, '0');
3988
+ // const a = rand_int(0xff).toString(16).padStart(2, '0');
3989
+ // return `#${r}${g}${b}${a}`;
3990
+ // };
3991
+
3992
+ // export const rand_rgb = () => {
3993
+ // const r = rand_int(255);
3994
+ // const g = rand_int(255);
3995
+ // const b = rand_int(255);
3996
+ // return `rgb(${r}, ${g}, ${b})`;
3997
+ // };
3998
+
3999
+ // export const rand_rgba = () => {
4000
+ // const r = rand_int(255);
4001
+ // const g = rand_int(255);
4002
+ // const b = rand_int(255);
4003
+ // const a = +(Math.random()).toFixed(2);
4004
+ // return `rgba(${r}, ${g}, ${b}, ${a})`;
4005
+ // };
4006
+
4007
+
4008
+ // // (upperCase) => upperCase ? : String.fromCharCode(rand_int(97,120))
4009
+ // class Random {
4010
+ // static float(a = 1, b) {
4011
+ // return b ? Math.random() * (b - a) + a : a * Math.random();
4012
+ // }
4013
+ // static int(a, b) {
4014
+ // return Math.floor(this.float(a, b));
4015
+ // }
4016
+ // static char(upperCase){
4017
+ // upperCase=upperCase??this.bool();
4018
+ // const Char=String.fromCharCode(this.int(97,120));
4019
+ // return upperCase?Char.toUpperCase():Char;
4020
+ // }
4021
+ // static bool(){
4022
+ // return [false,true][Math.floor(Math.random()*2)];
4023
+ // }
4024
+ // static string(length,upperCase){
4025
+ // return length instanceof Array?
4026
+ // new Array(this.int(...length)).fill(0).map(() => this.char(upperCase)).join(""):
4027
+ // new Array(length).fill(0).map(() => this.char(upperCase)).join("");
4028
+ // }
4029
+ // static bin() {
4030
+ // return this.int(2);
4031
+ // }
4032
+ // static oct() {
4033
+ // return this.int(8);
4034
+ // }
4035
+ // static dec() {
4036
+ // return this.int(10);
4037
+ // }
4038
+ // static hex() {
4039
+ // return this.int(16);
4040
+ // }
4041
+ // static choice(choices = [1, 2, 3], p = new Array(choices.length).fill(1 / choices.length)) {
4042
+ // let newchoice = new Array(100);
4043
+ // p=Utils.accum(...p).map(n=>n*100)
4044
+ // newchoice.fill(choices[0], 0, p[0]);
4045
+ // for (let i = 1; i < choices.length; i++) newchoice.fill(choices[i], p[i - 1], p[i]);
4046
+ // return newchoice[this.int(newchoice.length - 1)];
4047
+ // }
4048
+ // static shuffleArr(arr){
4049
+ // return arr.sort(()=>0.5-Math.random())
4050
+ // }
4051
+ // static floats(n, a, b) {
4052
+ // return new Array(n).fill(0).map(() => this.float(a, b));
4053
+ // }
4054
+ // static ints(n, a, b) {
4055
+ // return new Array(n).fill(0).map(() => this.int(a, b));
4056
+ // }
4057
+ // static bools(n){
4058
+ // return new Array(n).fill(0).map(() => this.bool());
4059
+ // }
4060
+ // static bins(n) {
4061
+ // return new Array(n).fill(0).map(() => this.int(2));
4062
+ // }
4063
+ // static octs(n) {
4064
+ // return new Array(n).fill(0).map(() => this.int(8));
4065
+ // }
4066
+ // static decs(n) {
4067
+ // return new Array(n).fill(0).map(() => this.int(10));
4068
+ // }
4069
+ // static hexs(n) {
4070
+ // return new Array(n).fill(0).map(() => this.int(16));
4071
+ // }
4072
+ // static choices(n, choices, p) {
4073
+ // return new Array(n).fill(0).map(() => this.choice(choices, p));
4074
+ // }
4075
+ // static perm(...arr) {
4076
+ // // permutation
4077
+ // return arr.permS[this.int(arr.length)];
4078
+ // }
4079
+ // static color() {
4080
+ // return "#" + Base.dec2hex(this.float(16777216)).padStart(6,0);
4081
+ // }
4082
+ // static colors(n) {
4083
+ // return new Array(n).fill(null).map(()=>this.color());
4084
+ // }
4085
+
4086
+ // // Should be Moved to Matrix and Complex to avoid Circular dependencies
4087
+ // // static complex(a = [0,1], b = [0,1]) {
4088
+ // // return a instanceof Array?
4089
+ // // new Complex(
4090
+ // // this.float(a[0], a[1]),
4091
+ // // this.float(b[0], b[1])
4092
+ // // ):
4093
+ // // new Complex(
4094
+ // // ...this.floats(2,a,b)
4095
+ // // )
4096
+
4097
+ // // }
4098
+ // // static complexInt(a = [0,1], b = [0,1]) {
4099
+ // // return new Complex(
4100
+ // // this.int(a[0], a[1]),
4101
+ // // this.int(b[0], b[1])
4102
+ // // );
4103
+ // // }
4104
+ // // static complexBin() {
4105
+ // // return new Complex(...this.bins(2));
4106
+ // // }
4107
+ // // static complexOct() {
4108
+ // // return new Complex(...this.octs(2));
4109
+ // // }
4110
+ // // static complexDec() {
4111
+ // // return new Complex(...this.decs(10));
4112
+ // // }
4113
+ // // static complexHex() {
4114
+ // // return new Complex(...this.octs(2));
4115
+ // // }
4116
+ // // static complexes(n, a = 0, b = 1) {
4117
+ // // return new Array(n).fill(0).map(() => this.complex(a, b));
4118
+ // // }
4119
+ // // static complexesInt(n, a = 0, b = 1) {
4120
+ // // return new Array(n).fill(0).map(() => this.complexInt(a, b));
4121
+ // // }
4122
+ // // static complexesBin(n) {
4123
+ // // return new Array(n).fill(0).map(() => this.complexBin());
4124
+ // // }
4125
+ // // static complexesOct(n) {
4126
+ // // return new Array(n).fill(0).map(() => this.complexOct());
4127
+ // // }
4128
+ // // static complexesDec(n) {
4129
+ // // return new Array(n).fill(0).map(() => this.complexDec());
4130
+ // // }
4131
+ // // static complexesHex(n) {
4132
+ // // return new Array(n).fill(0).map(() => this.complexHex());
4133
+ // // }
4134
+ // // static matrix(r,c,min,max){
4135
+ // // return matrix(r,c,this.floats(r*c,min,max))
4136
+ // // }
4137
+ // // static matrixInt(r,c,min,max){
4138
+ // // return matrix(r,c,this.ints(r*c,min,max))
4139
+ // // }
4140
+ // // static matrixBin(r,c){
4141
+ // // return matrix(r,c,this.bins(r*c))
4142
+ // // }
4143
+ // // static matrixOct(r,c){
4144
+ // // return matrix(r,c,this.octs(r*c))
4145
+ // // }
4146
+ // // static matrixDec(r,c){
4147
+ // // return matrix(r,c,this.decs(r*c))
4148
+ // // }
4149
+ // // static matrixHex(r,c){
4150
+ // // return matrix(r,c,this.hex(r*c))
4151
+ // // }
4152
+ // // static matrixColor(r,c){
4153
+ // // return matrix(r,c,this.colors(r*c))
4154
+ // // }
4155
+ // // static matrixComplex(r,c,a,b){
4156
+ // // return matrix(r,c,this.complexes(r*c,a,b))
4157
+ // // }
4158
+ // // static matrixComplexInt(r,c,a,b){
4159
+ // // return matrix(r,c,this.complexesInt(r*c,a,b))
4160
+ // // }
4161
+ // // static matrixComplexBin(r,c){
4162
+ // // return matrix(r,c,this.complexesBin(r*c))
4163
+ // // }
4164
+ // // static matrixComplexOct(r,c){
4165
+ // // return matrix(r,c,this.complexesBin(r*c))
4166
+ // // }
4167
+ // // static matrixComplexDec(r,c){
4168
+ // // return matrix(r,c,this.complexesBin(r*c))
4169
+ // // }
4170
+ // // static matrixComplexHex(r,c){
4171
+ // // return matrix(r,c,this.complexesBin(r*c))
4172
+ // // }
4173
+ // }
4174
+ // export{Random}
3957
4175
 
3958
4176
  const zeros=(n)=>new Array(n).fill(0);
3959
4177
  const ones=(n)=>new Array(n).fill(1);
@@ -4226,369 +4444,6 @@ const Utils={
4226
4444
  isApproximatlyEqual
4227
4445
  };
4228
4446
 
4229
- // const subSet = (...arr) => {
4230
- // let list = arange(0, 2 ** arr.length, 1);
4231
- // let bin = list.map((n) => n.toString(2).padStart(arr.length, '0')).map((n) => n.split("").map((n) => +n));
4232
- // let sub = bin.map((n) => n.map((m, i) => (m === 1 ? arr[i] : null))).map((n) => n.filter((x) => x !== null));
4233
- // return sub;
4234
- // };
4235
- const subSet = null;
4236
-
4237
- const Base={
4238
- _mode:Number,
4239
- _map:function(func,number,toBase){
4240
- if (number instanceof Matrix)
4241
- return new Matrix(
4242
- number.rows,
4243
- number.cols,
4244
- number.arr.flat(1).map(n=>func(n,toBase))
4245
- );
4246
- else if (number instanceof Complex) return new Complex(func(number.a,toBase),func(number.b,toBase));
4247
- else if (number instanceof Array) return number.map((n) =>func(n,toBase));
4248
- },
4249
- dec2base(dec,base){
4250
- base<=10?this._mode=Number:this._mode=String;
4251
- //this._mode=String
4252
- if (typeof dec === "number") return this._mode((dec >>> 0).toString(base));
4253
- return this._map(this.dec2base,dec,base)
4254
- },
4255
- dec2bin(dec){
4256
- return this.dec2base(dec,2);
4257
- },
4258
- dec2oct(dec){
4259
- return this.dec2base(dec,8);
4260
- },
4261
- dec2hex(dec){
4262
- return this.dec2base(dec,16);
4263
- },
4264
- bin2base(bin, base) {
4265
- return this.dec2base(this.bin2dec(bin),base)
4266
- },
4267
- bin2dec(bin){
4268
- return this._mode("0b"+bin);
4269
- },
4270
- bin2oct(bin){
4271
- return this.bin2base(bin,8);
4272
- },
4273
- bin2hex(bin){
4274
- return this.bin2base(bin,16);
4275
- },
4276
- oct2dec(oct){
4277
- return this._mode("0o"+oct);
4278
- },
4279
- oct2bin(oct){
4280
- return this.dec2bin(this.oct2dec(oct))
4281
- },
4282
- oct2hex(oct){
4283
- return this.dec2hex(this.oct2dec(oct))
4284
- },
4285
- oct2base(oct, base) {
4286
- return this.dec2base(this.oct2dec(oct),base)
4287
- },
4288
- hex2dec(hex){
4289
- return this._mode("0x"+hex);
4290
- },
4291
- hex2bin(hex){
4292
- return this.dec2bin(this.hex2dec(hex))
4293
- },
4294
- hex2oct(hex){
4295
- return this.dec2oct(this.hex2dec(hex))
4296
- },
4297
- hex2base(hex, base) {
4298
- return this.dec2base(this.hex2dec(hex),base)
4299
- },
4300
- IEEE32toDec(Bin){
4301
- let IEEE32=Bin.split(" ").join("").padEnd(32,"0");
4302
- let s=IEEE32[0];
4303
- let e=2**(+("0b"+IEEE32.slice(1,9))-127);
4304
- let m=IEEE32.slice(9,32).split("").map(n=>+n);
4305
- let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
4306
- let dec=(-1)**s*(1+M)*e;
4307
- return dec
4308
- },
4309
- IEEE64toDec(Bin){
4310
- let IEEE64=Bin.split(" ").join("").padEnd(64,"0");
4311
- let s=IEEE64[0];
4312
- let e=2**(+("0b"+IEEE64.slice(1,12))-1023);
4313
- let m=IEEE64.slice(13,64).split("").map(n=>+n);
4314
- let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
4315
- let dec=(-1)**s*(1+M)*e;
4316
- return dec;
4317
- }
4318
- };
4319
-
4320
- const Logic$1={
4321
- _mode:Number,
4322
- _map:function(func,a,b){
4323
- if (a instanceof Matrix)
4324
- return new Matrix(
4325
- a.rows,
4326
- a.cols,
4327
- a.arr.flat(1).map((n) => func(n, b))
4328
- );
4329
- else if (a instanceof Complex) return new Complex(func(a.a, b), func(a.b, b));
4330
- else if (a instanceof Array) return a.map((n) => func(n, b));
4331
- },
4332
- not:function(input){
4333
- if(["number","boolean"].includes(typeof input)) return Logic$1._mode(!input);
4334
- else return this._map(this.not,input)
4335
- },
4336
- and:function(a, ...b){
4337
- if(["number","boolean"].includes(typeof a))return Logic$1._mode(b.reduce((n, m) => (n &= m), a));
4338
- else return this._map(this.and,a,b)
4339
- },
4340
- or:function(a, ...b) {
4341
- if(["number","boolean"].includes(typeof a)) return Logic$1._mode(b.reduce((n, m) => (n |= m), a));
4342
- else return this._map(this.or,a,b);
4343
- },
4344
- nand:function(a, ...b) {
4345
- return this.not(this.and(a, b));
4346
- },
4347
- nor:function(a, ...b) {
4348
- return this.not(this.or(a, b));
4349
- },
4350
- xor:function(a,...b){
4351
- let arr=[a,...b];
4352
- if(["number","boolean"].includes(typeof a))return this._mode(arr.reduce((length,cur)=>{
4353
- if(+cur===1)length+=1;
4354
- return length;
4355
- },0)===1);
4356
- else return this._map(this.xor,a,b);
4357
- },
4358
- xnor:function(a,...b){
4359
- return Logic$1.not(Logic$1.xor(a,b))
4360
- }
4361
-
4362
- };
4363
-
4364
- class Permutation {
4365
- static withDiscount(arr, l = arr.length) {
4366
- if (l === 1) return arr.map((n) => [n]);
4367
- const permutations = [];
4368
- let smallerPermutations;
4369
- smallerPermutations = this.withDiscount(arr, l - 1);
4370
- arr.forEach((currentOption) => {
4371
- smallerPermutations.forEach((smallerPermutation) => {
4372
- permutations.push([currentOption].concat(smallerPermutation));
4373
- });
4374
- });
4375
- return permutations;
4376
- }
4377
- static withoutDiscount(arr) {
4378
- const l = arr.length;
4379
- if (l === 1) return arr.map((n) => [n]);
4380
- const permutations = [];
4381
- const smallerPermutations = this.withoutDiscount(arr.slice(1));
4382
- const firstOption = arr[0];
4383
- for (let i = 0; i < smallerPermutations.length; i++) {
4384
- const smallerPermutation = smallerPermutations[i];
4385
- for (let j = 0; j <= smallerPermutation.length; j++) {
4386
- const permutationPrefix = smallerPermutation.slice(0, j);
4387
- const permutationSuffix = smallerPermutation.slice(j);
4388
- permutations.push(permutationPrefix.concat([firstOption], permutationSuffix));
4389
- }
4390
- }
4391
- return permutations;
4392
- }
4393
- }
4394
-
4395
- class Combinaison {
4396
- static withDiscount(comboOptions, comboLength) {
4397
- if (comboLength === 1) {
4398
- return comboOptions.map((comboOption) => [comboOption]);
4399
- }
4400
- const combos = [];
4401
- comboOptions.forEach((currentOption, optionIndex) => {
4402
- const smallerCombos = this.withDiscount(comboOptions.slice(optionIndex), comboLength - 1);
4403
- smallerCombos.forEach((smallerCombo) => {
4404
- combos.push([currentOption].concat(smallerCombo));
4405
- });
4406
- });
4407
- return combos;
4408
- }
4409
- static withoutDiscount(comboOptions, comboLength) {
4410
- if (comboLength === 1) {
4411
- return comboOptions.map((comboOption) => [comboOption]);
4412
- }
4413
- const combos = [];
4414
- comboOptions.forEach((currentOption, optionIndex) => {
4415
- const smallerCombos = this.withoutDiscount(comboOptions.slice(optionIndex + 1), comboLength - 1);
4416
- smallerCombos.forEach((smallerCombo) => {
4417
- combos.push([currentOption].concat(smallerCombo));
4418
- });
4419
- });
4420
-
4421
- return combos;
4422
- }
4423
- }
4424
- const combinaison=(comboOptions, comboLength, discount=false)=>Combinaison[discount?"withDiscount":"withoutDiscount"](comboOptions, comboLength);
4425
-
4426
- class Random {
4427
- static float(a = 1, b) {
4428
- return b ? Math.random() * (b - a) + a : a * Math.random();
4429
- }
4430
- static int(a, b) {
4431
- return Math.floor(this.float(a, b));
4432
- }
4433
- static char(upperCase){
4434
- upperCase=upperCase??this.bool();
4435
- const Char=String.fromCharCode(this.int(97,120));
4436
- return upperCase?Char.toUpperCase():Char;
4437
- }
4438
- static bool(){
4439
- return [false,true][Math.floor(Math.random()*2)];
4440
- }
4441
- static string(length,upperCase){
4442
- return length instanceof Array?
4443
- new Array(this.int(...length)).fill(0).map(() => this.char(upperCase)).join(""):
4444
- new Array(length).fill(0).map(() => this.char(upperCase)).join("");
4445
- }
4446
- static bin() {
4447
- return this.int(2);
4448
- }
4449
- static oct() {
4450
- return this.int(8);
4451
- }
4452
- static dec() {
4453
- return this.int(8);
4454
- }
4455
- static hex() {
4456
- return this.int(16);
4457
- }
4458
- static choice(choices = [1, 2, 3], p = new Array(choices.length).fill(1 / choices.length)) {
4459
- let newchoice = new Array(100);
4460
- p=Utils.accum(...p).map(n=>n*100);
4461
- newchoice.fill(choices[0], 0, p[0]);
4462
- for (let i = 1; i < choices.length; i++) newchoice.fill(choices[i], p[i - 1], p[i]);
4463
- return newchoice[this.int(newchoice.length - 1)];
4464
- }
4465
- static shuffleArr(arr){
4466
- return arr.sort(()=>0.5-Math.random())
4467
- }
4468
- static floats(n, a, b) {
4469
- return new Array(n).fill(0).map(() => this.float(a, b));
4470
- }
4471
- static ints(n, a, b) {
4472
- return new Array(n).fill(0).map(() => this.int(a, b));
4473
- }
4474
- static bools(n){
4475
- return new Array(n).fill(0).map(() => this.bool());
4476
- }
4477
- static bins(n) {
4478
- return new Array(n).fill(0).map(() => this.int(2));
4479
- }
4480
- static octs(n) {
4481
- return new Array(n).fill(0).map(() => this.int(8));
4482
- }
4483
- static decs(n) {
4484
- return new Array(n).fill(0).map(() => this.int(10));
4485
- }
4486
- static hexs(n) {
4487
- return new Array(n).fill(0).map(() => this.int(16));
4488
- }
4489
- static choices(n, choices, p) {
4490
- return new Array(n).fill(0).map(() => this.choice(choices, p));
4491
- }
4492
- static perm(...arr) {
4493
- // permutation
4494
- return arr.permS[this.int(arr.length)];
4495
- }
4496
- static color() {
4497
- return "#" + Base.dec2hex(this.float(16777216)).padStart(6,0);
4498
- }
4499
- static colors(n) {
4500
- return new Array(n).fill(null).map(()=>this.color());
4501
- }
4502
-
4503
- // Should be Moved to Matrix and Complex to avoid Circular dependencies
4504
- // static complex(a = [0,1], b = [0,1]) {
4505
- // return a instanceof Array?
4506
- // new Complex(
4507
- // this.float(a[0], a[1]),
4508
- // this.float(b[0], b[1])
4509
- // ):
4510
- // new Complex(
4511
- // ...this.floats(2,a,b)
4512
- // )
4513
-
4514
- // }
4515
- // static complexInt(a = [0,1], b = [0,1]) {
4516
- // return new Complex(
4517
- // this.int(a[0], a[1]),
4518
- // this.int(b[0], b[1])
4519
- // );
4520
- // }
4521
- // static complexBin() {
4522
- // return new Complex(...this.bins(2));
4523
- // }
4524
- // static complexOct() {
4525
- // return new Complex(...this.octs(2));
4526
- // }
4527
- // static complexDec() {
4528
- // return new Complex(...this.decs(10));
4529
- // }
4530
- // static complexHex() {
4531
- // return new Complex(...this.octs(2));
4532
- // }
4533
- // static complexes(n, a = 0, b = 1) {
4534
- // return new Array(n).fill(0).map(() => this.complex(a, b));
4535
- // }
4536
- // static complexesInt(n, a = 0, b = 1) {
4537
- // return new Array(n).fill(0).map(() => this.complexInt(a, b));
4538
- // }
4539
- // static complexesBin(n) {
4540
- // return new Array(n).fill(0).map(() => this.complexBin());
4541
- // }
4542
- // static complexesOct(n) {
4543
- // return new Array(n).fill(0).map(() => this.complexOct());
4544
- // }
4545
- // static complexesDec(n) {
4546
- // return new Array(n).fill(0).map(() => this.complexDec());
4547
- // }
4548
- // static complexesHex(n) {
4549
- // return new Array(n).fill(0).map(() => this.complexHex());
4550
- // }
4551
- // static matrix(r,c,min,max){
4552
- // return matrix(r,c,this.floats(r*c,min,max))
4553
- // }
4554
- // static matrixInt(r,c,min,max){
4555
- // return matrix(r,c,this.ints(r*c,min,max))
4556
- // }
4557
- // static matrixBin(r,c){
4558
- // return matrix(r,c,this.bins(r*c))
4559
- // }
4560
- // static matrixOct(r,c){
4561
- // return matrix(r,c,this.octs(r*c))
4562
- // }
4563
- // static matrixDec(r,c){
4564
- // return matrix(r,c,this.decs(r*c))
4565
- // }
4566
- // static matrixHex(r,c){
4567
- // return matrix(r,c,this.hex(r*c))
4568
- // }
4569
- // static matrixColor(r,c){
4570
- // return matrix(r,c,this.colors(r*c))
4571
- // }
4572
- // static matrixComplex(r,c,a,b){
4573
- // return matrix(r,c,this.complexes(r*c,a,b))
4574
- // }
4575
- // static matrixComplexInt(r,c,a,b){
4576
- // return matrix(r,c,this.complexesInt(r*c,a,b))
4577
- // }
4578
- // static matrixComplexBin(r,c){
4579
- // return matrix(r,c,this.complexesBin(r*c))
4580
- // }
4581
- // static matrixComplexOct(r,c){
4582
- // return matrix(r,c,this.complexesBin(r*c))
4583
- // }
4584
- // static matrixComplexDec(r,c){
4585
- // return matrix(r,c,this.complexesBin(r*c))
4586
- // }
4587
- // static matrixComplexHex(r,c){
4588
- // return matrix(r,c,this.complexesBin(r*c))
4589
- // }
4590
- }
4591
-
4592
4447
  const { PI, sqrt: sqrt$1, cos: cos$2, sin: sin$2, acos, pow } = Math;
4593
4448
 
4594
4449
  const linear = t => t;
@@ -5746,19 +5601,15 @@ if(globalThis?.document){
5746
5601
  }
5747
5602
 
5748
5603
  exports.App = App;
5749
- exports.Base = Base;
5750
5604
  exports.Clock = Clock;
5751
- exports.Combinaison = Combinaison;
5752
5605
  exports.Complex = Complex;
5753
5606
  exports.E = E;
5754
5607
  exports.EPSILON = EPSILON;
5755
5608
  exports.FileBasedRouting = FileBasedRouting;
5756
5609
  exports.Flex = Flex;
5757
5610
  exports.HTMLWrapper = HTMLWrapper;
5758
- exports.Logic = Logic$1;
5759
5611
  exports.Matrix = Matrix;
5760
5612
  exports.PI = PI$1;
5761
- exports.Permutation = Permutation;
5762
5613
  exports.Random = Random;
5763
5614
  exports.SPA = SPA;
5764
5615
  exports.SVGWrapper = SVGWrapper;
@@ -5786,13 +5637,13 @@ exports.ZikoUIFlex = ZikoUIFlex;
5786
5637
  exports.ZikoUISuspense = ZikoUISuspense;
5787
5638
  exports.ZikoUIText = ZikoUIText;
5788
5639
  exports.abs = abs;
5789
- exports.accum = accum;
5790
5640
  exports.accum_prod = accum_prod;
5791
5641
  exports.accum_sum = accum_sum;
5792
5642
  exports.acos = acos$1;
5793
5643
  exports.acosh = acosh;
5794
5644
  exports.acot = acot;
5795
5645
  exports.add = add;
5646
+ exports.and = and;
5796
5647
  exports.animation = animation;
5797
5648
  exports.apply_fun = apply_fun;
5798
5649
  exports.arange = arange;
@@ -5815,12 +5666,12 @@ exports.bind_swipe_event = bind_swipe_event;
5815
5666
  exports.bind_touch_event = bind_touch_event;
5816
5667
  exports.bind_view_event = bind_view_event;
5817
5668
  exports.bind_wheel_event = bind_wheel_event;
5669
+ exports.binomial = binomial;
5818
5670
  exports.cartesianProduct = cartesianProduct;
5819
5671
  exports.cbrt = cbrt;
5820
5672
  exports.ceil = ceil;
5821
5673
  exports.clamp = clamp;
5822
5674
  exports.clock = clock;
5823
- exports.combinaison = combinaison;
5824
5675
  exports.complex = complex;
5825
5676
  exports.cos = cos$3;
5826
5677
  exports.cosh = cosh$2;
@@ -5894,11 +5745,14 @@ exports.median = median;
5894
5745
  exports.min = min$1;
5895
5746
  exports.modulo = modulo;
5896
5747
  exports.mul = mul;
5748
+ exports.nand = nand;
5749
+ exports.nor = nor;
5897
5750
  exports.norm = norm;
5898
5751
  exports.nthr = nthr;
5899
5752
  exports.nums = nums;
5900
5753
  exports.obj2str = obj2str;
5901
5754
  exports.ones = ones;
5755
+ exports.or = or;
5902
5756
  exports.out_back = out_back;
5903
5757
  exports.out_bounce = out_bounce;
5904
5758
  exports.out_circ = out_circ;
@@ -5912,7 +5766,6 @@ exports.out_sin = out_sin;
5912
5766
  exports.percentile = percentile;
5913
5767
  exports.pgcd = pgcd;
5914
5768
  exports.pow = pow$1;
5915
- exports.powerSet = powerSet;
5916
5769
  exports.ppcm = ppcm;
5917
5770
  exports.preload = preload;
5918
5771
  exports.prod = prod;
@@ -5929,7 +5782,6 @@ exports.std = std;
5929
5782
  exports.step = step;
5930
5783
  exports.step_fps = step_fps;
5931
5784
  exports.sub = sub;
5932
- exports.subSet = subSet;
5933
5785
  exports.sum = sum;
5934
5786
  exports.svg2ascii = svg2ascii;
5935
5787
  exports.svg2img = svg2img;
@@ -5961,4 +5813,6 @@ exports.variance = variance;
5961
5813
  exports.wait = wait;
5962
5814
  exports.waitForUIElm = waitForUIElm;
5963
5815
  exports.waitForUIElmSync = waitForUIElmSync;
5816
+ exports.xnor = xnor;
5817
+ exports.xor = xor;
5964
5818
  exports.zeros = zeros;