ziko 0.54.1 → 0.54.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.cjs +147 -57
- package/dist/ziko.js +66 -48
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +66 -48
- package/package.json +1 -1
- package/src/data/converter/csv.js +1 -1
- package/src/math/complex/index.js +11 -4
- package/src/math/discret/Conversion/index.js +1 -1
- package/src/math/discret/Logic/index.js +1 -1
- package/src/math/functions/arithmetic/index.js +4 -4
- package/src/math/functions/nested/index.js +42 -38
- package/src/math/matrix/index.js +605 -1
- package/types/math/complex/index.d.ts +1 -0
- package/src/math/adapted/index.js +0 -7
- package/src/math/matrix/matrix.js +0 -596
- package/types/math/adapted/index.d.ts +0 -4
package/dist/ziko.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Fri Dec 12 2025 14:53:26 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -131,6 +131,13 @@
|
|
|
131
131
|
static Zero() {
|
|
132
132
|
return new Complex(0, 0);
|
|
133
133
|
}
|
|
134
|
+
static Twidlle(N, K){
|
|
135
|
+
const phi = -2 * Math.PI * K / N;
|
|
136
|
+
return new Complex(
|
|
137
|
+
Math.cos(phi),
|
|
138
|
+
Math.sin(phi)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
134
141
|
get conj() {
|
|
135
142
|
return new Complex(this.a, -this.b);
|
|
136
143
|
}
|
|
@@ -165,7 +172,7 @@
|
|
|
165
172
|
}
|
|
166
173
|
this.a = z * Math.cos(phi);
|
|
167
174
|
this.b = z * Math.sin(phi);
|
|
168
|
-
return this;
|
|
175
|
+
return this.toFixed(8);
|
|
169
176
|
}
|
|
170
177
|
div(...c){
|
|
171
178
|
let {z, phi} = this;
|
|
@@ -174,10 +181,9 @@
|
|
|
174
181
|
z /= c[i].z;
|
|
175
182
|
phi -= c[i].phi;
|
|
176
183
|
}
|
|
177
|
-
this.a = z*Math.cos(phi);
|
|
178
|
-
this.b = z*Math.sin(phi);
|
|
179
|
-
return this;
|
|
180
|
-
}
|
|
184
|
+
this.a = z * Math.cos(phi);
|
|
185
|
+
this.b = z * Math.sin(phi);
|
|
186
|
+
return this.toFixed(8); }
|
|
181
187
|
modulo(...c) {
|
|
182
188
|
for (let i = 0; i < c.length; i++) {
|
|
183
189
|
if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
|
|
@@ -261,6 +267,8 @@
|
|
|
261
267
|
return new Complex(a,b)
|
|
262
268
|
};
|
|
263
269
|
|
|
270
|
+
const PRECESION = 8;
|
|
271
|
+
|
|
264
272
|
const abs = (...x) => mapfun(
|
|
265
273
|
x =>{
|
|
266
274
|
if(x.isComplex?.()) return x.z;
|
|
@@ -294,8 +302,8 @@
|
|
|
294
302
|
x=>{
|
|
295
303
|
if(x.isComplex?.())
|
|
296
304
|
return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
|
|
297
|
-
if(x < 0) return complex(0, Math.sqrt(-x))
|
|
298
|
-
return Math.sqrt(x);
|
|
305
|
+
if(x < 0) return complex(0, Math.sqrt(-x)).toFixed(PRECESION)
|
|
306
|
+
return + Math.sqrt(x).toFixed(PRECESION);
|
|
299
307
|
},
|
|
300
308
|
...x
|
|
301
309
|
);
|
|
@@ -303,8 +311,8 @@
|
|
|
303
311
|
const cbrt = (...x) => mapfun(
|
|
304
312
|
x=>{
|
|
305
313
|
if(x.isComplex?.())
|
|
306
|
-
return new x.constructor({z: x.z**(1/3), phi: x.phi/3})
|
|
307
|
-
return Math.cbrt(x);
|
|
314
|
+
return new x.constructor({z: x.z**(1/3), phi: x.phi/3}).toFixed(PRECESION)
|
|
315
|
+
return + Math.cbrt(x).toFixed(PRECESION);
|
|
308
316
|
},
|
|
309
317
|
...x
|
|
310
318
|
);
|
|
@@ -315,8 +323,10 @@
|
|
|
315
323
|
return mapfun(
|
|
316
324
|
x => {
|
|
317
325
|
if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
|
|
318
|
-
if(x<0) return n%2===2
|
|
319
|
-
|
|
326
|
+
if(x<0) return n %2 ===2
|
|
327
|
+
? complex(0, (-x)**(1/n)).toFixed(PRECESION)
|
|
328
|
+
: + (-1 * (-x)**(1/n)).toFixed(PRECESION)
|
|
329
|
+
return + (x**(1/n)).toFixed(PRECESION)
|
|
320
330
|
},
|
|
321
331
|
...x
|
|
322
332
|
)
|
|
@@ -336,7 +346,7 @@
|
|
|
336
346
|
return new c.constructor(
|
|
337
347
|
A * Math.cos(B),
|
|
338
348
|
A * Math.sin(B)
|
|
339
|
-
)
|
|
349
|
+
).toFixed(PRECESION)
|
|
340
350
|
},
|
|
341
351
|
...x
|
|
342
352
|
)
|
|
@@ -347,8 +357,8 @@
|
|
|
347
357
|
if(x.isComplex?.()) return new x.constructor(
|
|
348
358
|
Math.exp(x.a) * Math.cos(x.b),
|
|
349
359
|
Math.exp(x.a) * Math.sin(x.b)
|
|
350
|
-
);
|
|
351
|
-
return Math.exp(x)
|
|
360
|
+
).toFixed(PRECESION);
|
|
361
|
+
return + Math.exp(x).toFixed(PRECESION)
|
|
352
362
|
}
|
|
353
363
|
,...x
|
|
354
364
|
);
|
|
@@ -358,8 +368,8 @@
|
|
|
358
368
|
if(x.isComplex?.()) return new x.constructor(
|
|
359
369
|
Math.log(x.z),
|
|
360
370
|
x.phi
|
|
361
|
-
);
|
|
362
|
-
return Math.log(x)
|
|
371
|
+
).toFixed(PRECESION);
|
|
372
|
+
return + Math.log(x).toFixed(PRECESION)
|
|
363
373
|
}
|
|
364
374
|
,...x
|
|
365
375
|
);
|
|
@@ -434,8 +444,8 @@
|
|
|
434
444
|
if(x.isComplex?.()) return new x.constructor(
|
|
435
445
|
Math.cos(x.a) * Math.cosh(x.b),
|
|
436
446
|
-Math.sin(x.a) * Math.sinh(x.b)
|
|
437
|
-
);
|
|
438
|
-
return Math.cos(x)
|
|
447
|
+
).toFixed(PRECESION);
|
|
448
|
+
return + Math.cos(x).toFixed(PRECESION)
|
|
439
449
|
}
|
|
440
450
|
,...x
|
|
441
451
|
);
|
|
@@ -445,8 +455,8 @@
|
|
|
445
455
|
if(x?.isComplex) return new x.constructor(
|
|
446
456
|
Math.sin(x.a) * Math.cosh(x.b),
|
|
447
457
|
Math.cos(x.a) * Math.sinh(x.b)
|
|
448
|
-
);
|
|
449
|
-
return Math.sin(x)
|
|
458
|
+
).toFixed(PRECESION);
|
|
459
|
+
return + Math.sin(x).toFixed(PRECESION)
|
|
450
460
|
}
|
|
451
461
|
, ...x
|
|
452
462
|
);
|
|
@@ -458,9 +468,9 @@
|
|
|
458
468
|
return new x.constructor(
|
|
459
469
|
Math.sin(2*x.a) / D,
|
|
460
470
|
Math.sinh(2*x.b) / D
|
|
461
|
-
);
|
|
471
|
+
).toFixed(PRECESION);
|
|
462
472
|
}
|
|
463
|
-
return Math.tan(x)
|
|
473
|
+
return + Math.tan(x).toFixed(PRECESION)
|
|
464
474
|
},
|
|
465
475
|
...x
|
|
466
476
|
);
|
|
@@ -468,7 +478,7 @@
|
|
|
468
478
|
const sec = (...x) => mapfun(
|
|
469
479
|
x => {
|
|
470
480
|
if(x.isComplex?.()) ;
|
|
471
|
-
return 1 / Math.cos(x)
|
|
481
|
+
return + (1 / Math.cos(x)).toFixed(PRECESION)
|
|
472
482
|
}
|
|
473
483
|
,...x
|
|
474
484
|
);
|
|
@@ -484,9 +494,9 @@
|
|
|
484
494
|
return new x.constructor(
|
|
485
495
|
Math.acos((Rp - Rm) / 2),
|
|
486
496
|
-Math.acosh((Rp + Rm) / 2),
|
|
487
|
-
)
|
|
497
|
+
).toFixed(PRECESION)
|
|
488
498
|
}
|
|
489
|
-
return Math.acos(x)
|
|
499
|
+
return + Math.acos(x).toFixed(PRECESION)
|
|
490
500
|
},
|
|
491
501
|
...x
|
|
492
502
|
);
|
|
@@ -500,9 +510,9 @@
|
|
|
500
510
|
return new x.constructor(
|
|
501
511
|
Math.asin((Rp - Rm) / 2),
|
|
502
512
|
Math.acosh((Rp + Rm) / 2)
|
|
503
|
-
);
|
|
513
|
+
).toFixed(PRECESION);
|
|
504
514
|
}
|
|
505
|
-
return Math.asin(x);
|
|
515
|
+
return + Math.asin(x).toFixed(PRECESION);
|
|
506
516
|
},
|
|
507
517
|
...x
|
|
508
518
|
);
|
|
@@ -514,9 +524,9 @@
|
|
|
514
524
|
return new x.constructor(
|
|
515
525
|
Math.atan((a*2/(1-a**2-b**2)))/2,
|
|
516
526
|
Math.log((a**2 + (1+b)**2)/(a**2 + (1-b)**2))/4
|
|
517
|
-
)
|
|
527
|
+
).toFixed(PRECESION)
|
|
518
528
|
}
|
|
519
|
-
return Math.atan(x);
|
|
529
|
+
return + Math.atan(x).toFixed(PRECESION);
|
|
520
530
|
},
|
|
521
531
|
...x
|
|
522
532
|
);
|
|
@@ -528,9 +538,9 @@
|
|
|
528
538
|
return new x.constructor(
|
|
529
539
|
Math.atan(2*a/(a**2+(b-1)*(b+1)))/2,
|
|
530
540
|
Math.log((a**2 + (b-1)**2)/(a**2 + (b+1)**2))/4
|
|
531
|
-
)
|
|
541
|
+
).toFixed(PRECESION)
|
|
532
542
|
}
|
|
533
|
-
return Math.PI/2 - Math.atan(x);
|
|
543
|
+
return + (Math.PI/2 - Math.atan(x)).toFixed(PRECESION);
|
|
534
544
|
},
|
|
535
545
|
...x
|
|
536
546
|
);
|
|
@@ -541,8 +551,8 @@
|
|
|
541
551
|
if(x?.isComplex) return new x.constructor(
|
|
542
552
|
Math.cosh(x.a) * Math.cos(x.b),
|
|
543
553
|
Math.sinh(x.a) * Math.sin(x.b)
|
|
544
|
-
);
|
|
545
|
-
return Math.cosh(x)
|
|
554
|
+
).toFixed(PRECESION);
|
|
555
|
+
return + Math.cosh(x).toFixed(PRECESION)
|
|
546
556
|
},
|
|
547
557
|
...x
|
|
548
558
|
);
|
|
@@ -551,8 +561,8 @@
|
|
|
551
561
|
if(x?.isComplex) return new x.constructor(
|
|
552
562
|
Math.sinh(x.a) * Math.cos(x.b),
|
|
553
563
|
Math.cosh(x.a) * Math.sin(x.b)
|
|
554
|
-
);
|
|
555
|
-
return Math.sinh(x)
|
|
564
|
+
).toFixed(PRECESION);
|
|
565
|
+
return + Math.sinh(x).toFixed(PRECESION)
|
|
556
566
|
},
|
|
557
567
|
...x
|
|
558
568
|
);
|
|
@@ -563,9 +573,9 @@
|
|
|
563
573
|
return new x.constructor(
|
|
564
574
|
Math.sinh(2*a) / D,
|
|
565
575
|
Math.sin(2*b) / D
|
|
566
|
-
)
|
|
576
|
+
).toFixed(PRECESION)
|
|
567
577
|
}
|
|
568
|
-
return Math.tanh(x)
|
|
578
|
+
return + Math.tanh(x).toFixed(PRECESION)
|
|
569
579
|
},
|
|
570
580
|
...x
|
|
571
581
|
);
|
|
@@ -578,9 +588,9 @@
|
|
|
578
588
|
return new x.constructor(
|
|
579
589
|
Math.cosh(a) * Math.sinh(a) / D,
|
|
580
590
|
- Math.sin(b) * Math.cos(b) / D
|
|
581
|
-
)
|
|
591
|
+
).toFixed(PRECESION)
|
|
582
592
|
}
|
|
583
|
-
return 1/Math.tanh(x)
|
|
593
|
+
return + (1 / Math.tanh(x)).toFixed(PRECESION)
|
|
584
594
|
},
|
|
585
595
|
...x
|
|
586
596
|
);
|
|
@@ -590,7 +600,7 @@
|
|
|
590
600
|
if(x?.isComplex){
|
|
591
601
|
return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).sub(1))))
|
|
592
602
|
}
|
|
593
|
-
return Math.acosh(x)
|
|
603
|
+
return + Math.acosh(x).toFixed(PRECESION)
|
|
594
604
|
},
|
|
595
605
|
...x
|
|
596
606
|
);
|
|
@@ -600,7 +610,7 @@
|
|
|
600
610
|
if(x?.isComplex){
|
|
601
611
|
return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).add(1))))
|
|
602
612
|
}
|
|
603
|
-
return Math.asinh(x)
|
|
613
|
+
return + Math.asinh(x).toFixed(PRECESION)
|
|
604
614
|
},
|
|
605
615
|
...x
|
|
606
616
|
);
|
|
@@ -608,7 +618,7 @@
|
|
|
608
618
|
const atanh = (...x) => mapfun(
|
|
609
619
|
x =>{
|
|
610
620
|
if(x?.isComplex);
|
|
611
|
-
return Math.atanh(x)
|
|
621
|
+
return + Math.atanh(x).toFixed(PRECESION)
|
|
612
622
|
},
|
|
613
623
|
...x
|
|
614
624
|
);
|
|
@@ -616,7 +626,7 @@
|
|
|
616
626
|
const sig = (...x) => mapfun(
|
|
617
627
|
x =>{
|
|
618
628
|
if(x?.isComplex);
|
|
619
|
-
return 1/(1+Math.exp(-x))
|
|
629
|
+
return 1/(1 + Math.exp(-x)).toFixed(PRECESION)
|
|
620
630
|
},
|
|
621
631
|
...x
|
|
622
632
|
);
|
|
@@ -629,7 +639,7 @@
|
|
|
629
639
|
}
|
|
630
640
|
}
|
|
631
641
|
if(x.isComplex?.()){
|
|
632
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
642
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
|
|
633
643
|
}
|
|
634
644
|
};
|
|
635
645
|
|
|
@@ -639,7 +649,7 @@
|
|
|
639
649
|
if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
|
|
640
650
|
}
|
|
641
651
|
if(x.isComplex?.()){
|
|
642
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
652
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
|
|
643
653
|
}
|
|
644
654
|
};
|
|
645
655
|
|
|
@@ -659,7 +669,7 @@
|
|
|
659
669
|
if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
|
|
660
670
|
}
|
|
661
671
|
if(x.isComplex?.()){
|
|
662
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
672
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
663
673
|
}
|
|
664
674
|
};
|
|
665
675
|
|
|
@@ -669,7 +679,7 @@
|
|
|
669
679
|
if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
|
|
670
680
|
}
|
|
671
681
|
if(x.isComplex?.()){
|
|
672
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
682
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
|
|
673
683
|
}
|
|
674
684
|
};
|
|
675
685
|
|
|
@@ -3386,6 +3396,14 @@
|
|
|
3386
3396
|
clone() {
|
|
3387
3397
|
return new Matrix(this.rows, this.cols, this.arr.flat(1));
|
|
3388
3398
|
}
|
|
3399
|
+
toComplex(){
|
|
3400
|
+
this.arr = mapfun(
|
|
3401
|
+
x => x?.isComplex?.() ? x : new Complex(x, 0),
|
|
3402
|
+
...this.arr
|
|
3403
|
+
);
|
|
3404
|
+
this.#maintain();
|
|
3405
|
+
return this;
|
|
3406
|
+
}
|
|
3389
3407
|
[Symbol.iterator]() {
|
|
3390
3408
|
return this.arr[Symbol.iterator]();
|
|
3391
3409
|
}
|