ziko 0.54.1 → 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.js +66 -48
- 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/matrix/matrix.js +0 -596
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 : 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
|
|
@@ -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
|
}
|
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
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
|
|
@@ -125,6 +125,13 @@ class Complex{
|
|
|
125
125
|
static Zero() {
|
|
126
126
|
return new Complex(0, 0);
|
|
127
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
|
+
}
|
|
128
135
|
get conj() {
|
|
129
136
|
return new Complex(this.a, -this.b);
|
|
130
137
|
}
|
|
@@ -159,7 +166,7 @@ class Complex{
|
|
|
159
166
|
}
|
|
160
167
|
this.a = z * Math.cos(phi);
|
|
161
168
|
this.b = z * Math.sin(phi);
|
|
162
|
-
return this;
|
|
169
|
+
return this.toFixed(8);
|
|
163
170
|
}
|
|
164
171
|
div(...c){
|
|
165
172
|
let {z, phi} = this;
|
|
@@ -168,10 +175,9 @@ class Complex{
|
|
|
168
175
|
z /= c[i].z;
|
|
169
176
|
phi -= c[i].phi;
|
|
170
177
|
}
|
|
171
|
-
this.a = z*Math.cos(phi);
|
|
172
|
-
this.b = z*Math.sin(phi);
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
178
|
+
this.a = z * Math.cos(phi);
|
|
179
|
+
this.b = z * Math.sin(phi);
|
|
180
|
+
return this.toFixed(8); }
|
|
175
181
|
modulo(...c) {
|
|
176
182
|
for (let i = 0; i < c.length; i++) {
|
|
177
183
|
if (typeof c[i] === "number") c[i] = new Complex(c[i], 0);
|
|
@@ -255,6 +261,8 @@ const complex=(a,b)=>{
|
|
|
255
261
|
return new Complex(a,b)
|
|
256
262
|
};
|
|
257
263
|
|
|
264
|
+
const PRECESION = 8;
|
|
265
|
+
|
|
258
266
|
const abs = (...x) => mapfun(
|
|
259
267
|
x =>{
|
|
260
268
|
if(x.isComplex?.()) return x.z;
|
|
@@ -288,8 +296,8 @@ const sqrt$2 = (...x) => mapfun(
|
|
|
288
296
|
x=>{
|
|
289
297
|
if(x.isComplex?.())
|
|
290
298
|
return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
|
|
291
|
-
if(x < 0) return complex(0, Math.sqrt(-x))
|
|
292
|
-
return Math.sqrt(x);
|
|
299
|
+
if(x < 0) return complex(0, Math.sqrt(-x)).toFixed(PRECESION)
|
|
300
|
+
return + Math.sqrt(x).toFixed(PRECESION);
|
|
293
301
|
},
|
|
294
302
|
...x
|
|
295
303
|
);
|
|
@@ -297,8 +305,8 @@ const sqrt$2 = (...x) => mapfun(
|
|
|
297
305
|
const cbrt = (...x) => mapfun(
|
|
298
306
|
x=>{
|
|
299
307
|
if(x.isComplex?.())
|
|
300
|
-
return new x.constructor({z: x.z**(1/3), phi: x.phi/3})
|
|
301
|
-
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);
|
|
302
310
|
},
|
|
303
311
|
...x
|
|
304
312
|
);
|
|
@@ -309,8 +317,10 @@ const nthr = (...x) => {
|
|
|
309
317
|
return mapfun(
|
|
310
318
|
x => {
|
|
311
319
|
if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
|
|
312
|
-
if(x<0) return n%2===2
|
|
313
|
-
|
|
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)
|
|
314
324
|
},
|
|
315
325
|
...x
|
|
316
326
|
)
|
|
@@ -330,7 +340,7 @@ const croot = (...x) =>{
|
|
|
330
340
|
return new c.constructor(
|
|
331
341
|
A * Math.cos(B),
|
|
332
342
|
A * Math.sin(B)
|
|
333
|
-
)
|
|
343
|
+
).toFixed(PRECESION)
|
|
334
344
|
},
|
|
335
345
|
...x
|
|
336
346
|
)
|
|
@@ -341,8 +351,8 @@ const exp$1 = (...x) => mapfun(
|
|
|
341
351
|
if(x.isComplex?.()) return new x.constructor(
|
|
342
352
|
Math.exp(x.a) * Math.cos(x.b),
|
|
343
353
|
Math.exp(x.a) * Math.sin(x.b)
|
|
344
|
-
);
|
|
345
|
-
return Math.exp(x)
|
|
354
|
+
).toFixed(PRECESION);
|
|
355
|
+
return + Math.exp(x).toFixed(PRECESION)
|
|
346
356
|
}
|
|
347
357
|
,...x
|
|
348
358
|
);
|
|
@@ -352,8 +362,8 @@ const ln = (...x) => mapfun(
|
|
|
352
362
|
if(x.isComplex?.()) return new x.constructor(
|
|
353
363
|
Math.log(x.z),
|
|
354
364
|
x.phi
|
|
355
|
-
);
|
|
356
|
-
return Math.log(x)
|
|
365
|
+
).toFixed(PRECESION);
|
|
366
|
+
return + Math.log(x).toFixed(PRECESION)
|
|
357
367
|
}
|
|
358
368
|
,...x
|
|
359
369
|
);
|
|
@@ -428,8 +438,8 @@ const cos$3 = (...x) => mapfun(
|
|
|
428
438
|
if(x.isComplex?.()) return new x.constructor(
|
|
429
439
|
Math.cos(x.a) * Math.cosh(x.b),
|
|
430
440
|
-Math.sin(x.a) * Math.sinh(x.b)
|
|
431
|
-
);
|
|
432
|
-
return Math.cos(x)
|
|
441
|
+
).toFixed(PRECESION);
|
|
442
|
+
return + Math.cos(x).toFixed(PRECESION)
|
|
433
443
|
}
|
|
434
444
|
,...x
|
|
435
445
|
);
|
|
@@ -439,8 +449,8 @@ const sin$3 = (...x) => mapfun(
|
|
|
439
449
|
if(x?.isComplex) return new x.constructor(
|
|
440
450
|
Math.sin(x.a) * Math.cosh(x.b),
|
|
441
451
|
Math.cos(x.a) * Math.sinh(x.b)
|
|
442
|
-
);
|
|
443
|
-
return Math.sin(x)
|
|
452
|
+
).toFixed(PRECESION);
|
|
453
|
+
return + Math.sin(x).toFixed(PRECESION)
|
|
444
454
|
}
|
|
445
455
|
, ...x
|
|
446
456
|
);
|
|
@@ -452,9 +462,9 @@ const tan = (...x) => mapfun(
|
|
|
452
462
|
return new x.constructor(
|
|
453
463
|
Math.sin(2*x.a) / D,
|
|
454
464
|
Math.sinh(2*x.b) / D
|
|
455
|
-
);
|
|
465
|
+
).toFixed(PRECESION);
|
|
456
466
|
}
|
|
457
|
-
return Math.tan(x)
|
|
467
|
+
return + Math.tan(x).toFixed(PRECESION)
|
|
458
468
|
},
|
|
459
469
|
...x
|
|
460
470
|
);
|
|
@@ -462,7 +472,7 @@ const tan = (...x) => mapfun(
|
|
|
462
472
|
const sec = (...x) => mapfun(
|
|
463
473
|
x => {
|
|
464
474
|
if(x.isComplex?.()) ;
|
|
465
|
-
return 1 / Math.cos(x)
|
|
475
|
+
return + (1 / Math.cos(x)).toFixed(PRECESION)
|
|
466
476
|
}
|
|
467
477
|
,...x
|
|
468
478
|
);
|
|
@@ -478,9 +488,9 @@ const acos$1 = (...x) => mapfun(
|
|
|
478
488
|
return new x.constructor(
|
|
479
489
|
Math.acos((Rp - Rm) / 2),
|
|
480
490
|
-Math.acosh((Rp + Rm) / 2),
|
|
481
|
-
)
|
|
491
|
+
).toFixed(PRECESION)
|
|
482
492
|
}
|
|
483
|
-
return Math.acos(x)
|
|
493
|
+
return + Math.acos(x).toFixed(PRECESION)
|
|
484
494
|
},
|
|
485
495
|
...x
|
|
486
496
|
);
|
|
@@ -494,9 +504,9 @@ const asin = (...x) => mapfun(
|
|
|
494
504
|
return new x.constructor(
|
|
495
505
|
Math.asin((Rp - Rm) / 2),
|
|
496
506
|
Math.acosh((Rp + Rm) / 2)
|
|
497
|
-
);
|
|
507
|
+
).toFixed(PRECESION);
|
|
498
508
|
}
|
|
499
|
-
return Math.asin(x);
|
|
509
|
+
return + Math.asin(x).toFixed(PRECESION);
|
|
500
510
|
},
|
|
501
511
|
...x
|
|
502
512
|
);
|
|
@@ -508,9 +518,9 @@ const atan = (...x) => mapfun(
|
|
|
508
518
|
return new x.constructor(
|
|
509
519
|
Math.atan((a*2/(1-a**2-b**2)))/2,
|
|
510
520
|
Math.log((a**2 + (1+b)**2)/(a**2 + (1-b)**2))/4
|
|
511
|
-
)
|
|
521
|
+
).toFixed(PRECESION)
|
|
512
522
|
}
|
|
513
|
-
return Math.atan(x);
|
|
523
|
+
return + Math.atan(x).toFixed(PRECESION);
|
|
514
524
|
},
|
|
515
525
|
...x
|
|
516
526
|
);
|
|
@@ -522,9 +532,9 @@ const acot = (...x) => mapfun(
|
|
|
522
532
|
return new x.constructor(
|
|
523
533
|
Math.atan(2*a/(a**2+(b-1)*(b+1)))/2,
|
|
524
534
|
Math.log((a**2 + (b-1)**2)/(a**2 + (b+1)**2))/4
|
|
525
|
-
)
|
|
535
|
+
).toFixed(PRECESION)
|
|
526
536
|
}
|
|
527
|
-
return Math.PI/2 - Math.atan(x);
|
|
537
|
+
return + (Math.PI/2 - Math.atan(x)).toFixed(PRECESION);
|
|
528
538
|
},
|
|
529
539
|
...x
|
|
530
540
|
);
|
|
@@ -535,8 +545,8 @@ const cosh$2 = (...x) => mapfun(
|
|
|
535
545
|
if(x?.isComplex) return new x.constructor(
|
|
536
546
|
Math.cosh(x.a) * Math.cos(x.b),
|
|
537
547
|
Math.sinh(x.a) * Math.sin(x.b)
|
|
538
|
-
);
|
|
539
|
-
return Math.cosh(x)
|
|
548
|
+
).toFixed(PRECESION);
|
|
549
|
+
return + Math.cosh(x).toFixed(PRECESION)
|
|
540
550
|
},
|
|
541
551
|
...x
|
|
542
552
|
);
|
|
@@ -545,8 +555,8 @@ const sinh$1 = (...x) => mapfun(
|
|
|
545
555
|
if(x?.isComplex) return new x.constructor(
|
|
546
556
|
Math.sinh(x.a) * Math.cos(x.b),
|
|
547
557
|
Math.cosh(x.a) * Math.sin(x.b)
|
|
548
|
-
);
|
|
549
|
-
return Math.sinh(x)
|
|
558
|
+
).toFixed(PRECESION);
|
|
559
|
+
return + Math.sinh(x).toFixed(PRECESION)
|
|
550
560
|
},
|
|
551
561
|
...x
|
|
552
562
|
);
|
|
@@ -557,9 +567,9 @@ const tanh = (...x) => mapfun(
|
|
|
557
567
|
return new x.constructor(
|
|
558
568
|
Math.sinh(2*a) / D,
|
|
559
569
|
Math.sin(2*b) / D
|
|
560
|
-
)
|
|
570
|
+
).toFixed(PRECESION)
|
|
561
571
|
}
|
|
562
|
-
return Math.tanh(x)
|
|
572
|
+
return + Math.tanh(x).toFixed(PRECESION)
|
|
563
573
|
},
|
|
564
574
|
...x
|
|
565
575
|
);
|
|
@@ -572,9 +582,9 @@ const coth = (...x) => mapfun(
|
|
|
572
582
|
return new x.constructor(
|
|
573
583
|
Math.cosh(a) * Math.sinh(a) / D,
|
|
574
584
|
- Math.sin(b) * Math.cos(b) / D
|
|
575
|
-
)
|
|
585
|
+
).toFixed(PRECESION)
|
|
576
586
|
}
|
|
577
|
-
return 1/Math.tanh(x)
|
|
587
|
+
return + (1 / Math.tanh(x)).toFixed(PRECESION)
|
|
578
588
|
},
|
|
579
589
|
...x
|
|
580
590
|
);
|
|
@@ -584,7 +594,7 @@ const acosh = (...x) => mapfun(
|
|
|
584
594
|
if(x?.isComplex){
|
|
585
595
|
return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).sub(1))))
|
|
586
596
|
}
|
|
587
|
-
return Math.acosh(x)
|
|
597
|
+
return + Math.acosh(x).toFixed(PRECESION)
|
|
588
598
|
},
|
|
589
599
|
...x
|
|
590
600
|
);
|
|
@@ -594,7 +604,7 @@ const asinh = (...x) => mapfun(
|
|
|
594
604
|
if(x?.isComplex){
|
|
595
605
|
return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).add(1))))
|
|
596
606
|
}
|
|
597
|
-
return Math.asinh(x)
|
|
607
|
+
return + Math.asinh(x).toFixed(PRECESION)
|
|
598
608
|
},
|
|
599
609
|
...x
|
|
600
610
|
);
|
|
@@ -602,7 +612,7 @@ const asinh = (...x) => mapfun(
|
|
|
602
612
|
const atanh = (...x) => mapfun(
|
|
603
613
|
x =>{
|
|
604
614
|
if(x?.isComplex);
|
|
605
|
-
return Math.atanh(x)
|
|
615
|
+
return + Math.atanh(x).toFixed(PRECESION)
|
|
606
616
|
},
|
|
607
617
|
...x
|
|
608
618
|
);
|
|
@@ -610,7 +620,7 @@ const atanh = (...x) => mapfun(
|
|
|
610
620
|
const sig = (...x) => mapfun(
|
|
611
621
|
x =>{
|
|
612
622
|
if(x?.isComplex);
|
|
613
|
-
return 1/(1+Math.exp(-x))
|
|
623
|
+
return 1/(1 + Math.exp(-x)).toFixed(PRECESION)
|
|
614
624
|
},
|
|
615
625
|
...x
|
|
616
626
|
);
|
|
@@ -623,7 +633,7 @@ const _add = (x, y) =>{
|
|
|
623
633
|
}
|
|
624
634
|
}
|
|
625
635
|
if(x.isComplex?.()){
|
|
626
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
636
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().add(y);
|
|
627
637
|
}
|
|
628
638
|
};
|
|
629
639
|
|
|
@@ -633,7 +643,7 @@ const _sub = (x, y) =>{
|
|
|
633
643
|
if(y.isComplex?.()) return new y.constructor(x - y.a, y.b);
|
|
634
644
|
}
|
|
635
645
|
if(x.isComplex?.()){
|
|
636
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
646
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().sub(y);
|
|
637
647
|
}
|
|
638
648
|
};
|
|
639
649
|
|
|
@@ -653,7 +663,7 @@ const _div = (x, y) =>{
|
|
|
653
663
|
if(y.isComplex?.()) return new y.constructor(x, 0).div(y)
|
|
654
664
|
}
|
|
655
665
|
if(x.isComplex?.()){
|
|
656
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
666
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().mul(y);
|
|
657
667
|
}
|
|
658
668
|
};
|
|
659
669
|
|
|
@@ -663,7 +673,7 @@ const _modulo = (x, y) =>{
|
|
|
663
673
|
if(y.isComplex?.()) return new y.constructor(x, 0).modulo(y)
|
|
664
674
|
}
|
|
665
675
|
if(x.isComplex?.()){
|
|
666
|
-
if(typeof y === 'number' || y.isComplex?.()) return
|
|
676
|
+
if(typeof y === 'number' || y.isComplex?.()) return x.clone().modulo(y);
|
|
667
677
|
}
|
|
668
678
|
};
|
|
669
679
|
|
|
@@ -3380,6 +3390,14 @@ class Matrix{
|
|
|
3380
3390
|
clone() {
|
|
3381
3391
|
return new Matrix(this.rows, this.cols, this.arr.flat(1));
|
|
3382
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
|
+
}
|
|
3383
3401
|
[Symbol.iterator]() {
|
|
3384
3402
|
return this.arr[Symbol.iterator]();
|
|
3385
3403
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.2",
|
|
4
4
|
"description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"front-end",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Matrix } from "../../math/matrix/
|
|
1
|
+
import { Matrix } from "../../math/matrix/index.js"
|
|
2
2
|
const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
|
|
3
3
|
const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
|
|
4
4
|
const csv2object = (csv, delimiter = ",") => {
|