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 +298 -444
- package/dist/ziko.js +297 -626
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +297 -618
- package/package.json +1 -1
- package/src/math/--discret/index.js +12 -0
- package/src/math/complex/index.js +18 -12
- package/src/math/functions/conversions/index.js +61 -0
- package/src/math/functions/index.js +1 -1
- package/src/math/functions/signal/index.js +1 -1
- package/src/math/functions/stats/index.js +14 -2
- package/src/math/functions/utils/index.js +0 -58
- package/src/math/index.js +2 -2
- package/src/math/matrix/helpers/constructor.js +30 -0
- package/src/math/matrix/helpers/index.js +1 -0
- package/src/math/matrix/index.js +212 -176
- package/src/math/random/index.js +111 -155
- package/src/math/utils/conversions.js +17 -17
- package/src/math/utils/index.js +10 -10
- package/types/math/complex/index.d.ts +5 -5
- package/src/math/discret/Combinaison/index.js +0 -34
- package/src/math/discret/Conversion/index.js +0 -86
- package/src/math/discret/Permutation/index.js +0 -31
- package/src/math/discret/index.js +0 -12
- package/src/math/statistics/functions/index.js +0 -100
- package/src/math/statistics/index.js +0 -16
- /package/src/math/{discret → --discret}/Set/index.js +0 -0
- /package/src/math/{discret → --discret}/Set/power-set.js +0 -0
- /package/src/math/{discret → --discret}/Set/sub-set.js +0 -0
- /package/src/math/functions/{nested → ufunc}/index.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
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",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// import { powerSet , subSet } from "./Set/index.js";
|
|
2
|
+
// import { Base } from "./Conversion/index.js";
|
|
3
|
+
// import {
|
|
4
|
+
// Permutation,
|
|
5
|
+
// } from "./Permutation/index.js"
|
|
6
|
+
// import {
|
|
7
|
+
// Combinaison,
|
|
8
|
+
// combinaison,
|
|
9
|
+
// } from "./Combinaison/index.js"
|
|
10
|
+
|
|
11
|
+
// export{
|
|
12
|
+
// Base,Permutation,Combinaison,combinaison,powerSet,subSet}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Should avoid CD
|
|
1
|
+
import { Random } from "../random/index.js";
|
|
3
2
|
class Complex{
|
|
4
3
|
constructor(a = 0, b = 0) {
|
|
5
4
|
if(a instanceof Complex){
|
|
@@ -74,10 +73,23 @@ class Complex{
|
|
|
74
73
|
get phi(){
|
|
75
74
|
return Math.atan2(this.b , this.a);
|
|
76
75
|
}
|
|
77
|
-
static
|
|
76
|
+
static zero() {
|
|
78
77
|
return new Complex(0, 0);
|
|
79
78
|
}
|
|
80
|
-
static
|
|
79
|
+
static fromPolar(z, phi) {
|
|
80
|
+
return new Complex(
|
|
81
|
+
+(z * cos(phi)).toFixed(13),
|
|
82
|
+
+(z * sin(phi)).toFixed(13)
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static get random(){
|
|
87
|
+
return {
|
|
88
|
+
int : (a, b)=> new Complex(...Random.sample.int(2, a, b) ),
|
|
89
|
+
float : (a, b)=> new Complex(...Random.sample.float(2, a, b) ),
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
static twiddle(N, K){
|
|
81
93
|
const phi = -2 * Math.PI * K / N;
|
|
82
94
|
return new Complex(
|
|
83
95
|
Math.cos(phi),
|
|
@@ -150,12 +162,6 @@ class Complex{
|
|
|
150
162
|
this.b = z * Math.sin(phi)
|
|
151
163
|
return this;
|
|
152
164
|
}
|
|
153
|
-
static fromExpo(z, phi) {
|
|
154
|
-
return new Complex(
|
|
155
|
-
+(z * cos(phi)).toFixed(13),
|
|
156
|
-
+(z * sin(phi)).toFixed(13)
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
165
|
get expo() {
|
|
160
166
|
return [this.z, this.phi];
|
|
161
167
|
}
|
|
@@ -176,10 +182,10 @@ class Complex{
|
|
|
176
182
|
return complex({z: this.z ** (1/n), phi: this.phi / n});
|
|
177
183
|
}
|
|
178
184
|
get sqrt(){
|
|
179
|
-
return this.
|
|
185
|
+
return this.nthr(2);
|
|
180
186
|
}
|
|
181
187
|
get cbrt(){
|
|
182
|
-
return this.
|
|
188
|
+
return this.nthr(3);
|
|
183
189
|
}
|
|
184
190
|
get log(){
|
|
185
191
|
return complex(this.z, this.phi);
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const base2base = (value, fromBase, toBase) => {
|
|
2
|
+
if (fromBase < 2 || fromBase > 36 || toBase < 2 || toBase > 36)
|
|
3
|
+
throw new TypeError('Base must be between 2 and 36');
|
|
4
|
+
|
|
5
|
+
const dec = parseInt(value, fromBase);
|
|
6
|
+
if (Number.isNaN(dec)) throw new TypeError('Invalid value for the given base');
|
|
7
|
+
|
|
8
|
+
return dec.toString(toBase);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const bin2oct = (...x) => mapfun(
|
|
12
|
+
n => base2base(n, 2, 8),
|
|
13
|
+
...x
|
|
14
|
+
)
|
|
15
|
+
export const bin2dec = (...x) => mapfun(
|
|
16
|
+
n => base2base(n, 2, 10),
|
|
17
|
+
...x
|
|
18
|
+
)
|
|
19
|
+
export const bin2hex = (...x) => mapfun(
|
|
20
|
+
n => base2base(n, 2, 16),
|
|
21
|
+
...x
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export const oct2bin = (...x) => mapfun(
|
|
25
|
+
n => base2base(n, 8, 2),
|
|
26
|
+
...x
|
|
27
|
+
)
|
|
28
|
+
export const oct2dec = (...x) => mapfun(
|
|
29
|
+
n => base2base(n, 8, 10),
|
|
30
|
+
...x
|
|
31
|
+
)
|
|
32
|
+
export const oct2hex = (...x) => mapfun(
|
|
33
|
+
n => base2base(n, 8, 16),
|
|
34
|
+
...x
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
export const dec2bin = (...x) => mapfun(
|
|
38
|
+
n => base2base(n, 10, 2),
|
|
39
|
+
...x
|
|
40
|
+
)
|
|
41
|
+
export const dec2oct = (...x) => mapfun(
|
|
42
|
+
n => base2base(n, 10, 8),
|
|
43
|
+
...x
|
|
44
|
+
)
|
|
45
|
+
export const dec2hex = (...x) => mapfun(
|
|
46
|
+
n => base2base(n, 10, 16),
|
|
47
|
+
...x
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
export const hex2bin = (...x) => mapfun(
|
|
51
|
+
n => base2base(n, 16, 2),
|
|
52
|
+
...x
|
|
53
|
+
)
|
|
54
|
+
export const hex2oct = (...x) => mapfun(
|
|
55
|
+
n => base2base(n, 16, 8),
|
|
56
|
+
...x
|
|
57
|
+
)
|
|
58
|
+
export const hex2dec = (...x) => mapfun(
|
|
59
|
+
n => base2base(n, 16, 10),
|
|
60
|
+
...x
|
|
61
|
+
)
|
|
@@ -3,6 +3,18 @@ import {add, mul} from '../arithmetic/index.js';
|
|
|
3
3
|
export const min = (...x) => Math.min(...x);
|
|
4
4
|
export const max = (...x) => Math.max(...x);
|
|
5
5
|
|
|
6
|
+
export const binomial = (n, k) =>{
|
|
7
|
+
if(n !== Math.floor(n)) return TypeError('n must be an integer');
|
|
8
|
+
if(k !== Math.floor(k)) return TypeError('k must be an integer');
|
|
9
|
+
if (n < 0) return TypeError('n must be non-negative');
|
|
10
|
+
if (k < 0 || n < 0 || k > n) return 0;
|
|
11
|
+
if (k > n - k) k = n - k;
|
|
12
|
+
let c = 1, i;
|
|
13
|
+
for (i = 0; i < k; i++)
|
|
14
|
+
c = c * (n - i) / (i + 1);
|
|
15
|
+
return c;
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
export const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
|
|
7
19
|
|
|
8
20
|
export const variance = (...x) => {
|
|
@@ -16,7 +28,7 @@ export const std = (...x) => Math.sqrt(variance(...x));
|
|
|
16
28
|
|
|
17
29
|
export const accum_sum = (...x) => {
|
|
18
30
|
let result = [];
|
|
19
|
-
let total = 0, i
|
|
31
|
+
let total = 0, i, n = x.length;
|
|
20
32
|
for(i = 0; i < n ; i++){
|
|
21
33
|
total = add(total, x[i])
|
|
22
34
|
result.push(total);
|
|
@@ -26,7 +38,7 @@ export const accum_sum = (...x) => {
|
|
|
26
38
|
|
|
27
39
|
export const accum_prod = (...x) => {
|
|
28
40
|
let result = [];
|
|
29
|
-
let prod = 1, i
|
|
41
|
+
let prod = 1, i, n = x.length;
|
|
30
42
|
for(i = 0; i < n ; i++){
|
|
31
43
|
prod = mul(prod, x[i])
|
|
32
44
|
result.push(prod);
|
|
@@ -20,64 +20,6 @@ export const map = (x, a, b, c, d) => apply_fun(
|
|
|
20
20
|
v => lerp(norm(v, a, b), c, d)
|
|
21
21
|
);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
// export const norm = (x, min, max) => {
|
|
25
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
26
|
-
// norm(x.a, min, max),
|
|
27
|
-
// norm(x.b, min, max)
|
|
28
|
-
// )
|
|
29
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
30
|
-
// x.rows,
|
|
31
|
-
// x.cols,
|
|
32
|
-
// norm(x.arr.flat(1), min, max)
|
|
33
|
-
// );
|
|
34
|
-
// if(x instanceof Array) return mapfun(n => norm(n, min, max), ...x);
|
|
35
|
-
// return min !== max ? (x - min) / (max - min) : 0;
|
|
36
|
-
// }
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// export const lerp = (x, min, max) => {
|
|
40
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
41
|
-
// lerp(x.a, min, max),
|
|
42
|
-
// lerp(x.b, min, max)
|
|
43
|
-
// )
|
|
44
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
45
|
-
// x.rows,
|
|
46
|
-
// x.cols,
|
|
47
|
-
// lerp(x.arr.flat(1), min, max)
|
|
48
|
-
// );
|
|
49
|
-
// if(x instanceof Array) return mapfun(n => lerp(n, min, max), ...x);
|
|
50
|
-
// return (max - min) * x + min;
|
|
51
|
-
// }
|
|
52
|
-
|
|
53
|
-
// export const map = (x, a, b, c, d) => {
|
|
54
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
55
|
-
// map(x.a, a, b, c, d),
|
|
56
|
-
// map(x.b, a, b, c, d)
|
|
57
|
-
// )
|
|
58
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
59
|
-
// x.rows,
|
|
60
|
-
// x.cols,
|
|
61
|
-
// map(x.arr.flat(1), a, b, c, d)
|
|
62
|
-
// );
|
|
63
|
-
// if(x instanceof Array) return mapfun(n => map(n, a, b, c, d), ...x);
|
|
64
|
-
// return lerp(norm(x, a, b), c, d);
|
|
65
|
-
// }
|
|
66
|
-
|
|
67
|
-
// export const clamp = (x, min, max) => {
|
|
68
|
-
// if(x.isComplex?.()) return new x.constructor(
|
|
69
|
-
// clamp(x.a, min, max),
|
|
70
|
-
// clamp(x.b, min, max)
|
|
71
|
-
// )
|
|
72
|
-
// if(x.isMatrix?.()) return new x.constructor(
|
|
73
|
-
// x.rows,
|
|
74
|
-
// x.cols,
|
|
75
|
-
// clamp(x.arr.flat(1), min, max)
|
|
76
|
-
// );
|
|
77
|
-
// if(x instanceof Array) return mapfun(n => clamp(n, min, max), ...x);
|
|
78
|
-
// return Math.min(Math.max(x, min), max)
|
|
79
|
-
// }
|
|
80
|
-
|
|
81
23
|
export const hypot = (...x) => {
|
|
82
24
|
const c0 = x.find(a => a.isComplex?.());
|
|
83
25
|
if (c0) {
|
package/src/math/index.js
CHANGED
|
@@ -18,9 +18,9 @@ export * from "./const.js"
|
|
|
18
18
|
export * from "./functions/index.js"
|
|
19
19
|
export * from "./complex"
|
|
20
20
|
export * from "./matrix"
|
|
21
|
-
export * from "./discret"
|
|
21
|
+
// export * from "./discret"
|
|
22
22
|
export * from "./random"
|
|
23
23
|
export * from "./utils"
|
|
24
|
-
export * from "./statistics"
|
|
24
|
+
// export * from "./statistics"
|
|
25
25
|
// export default Math;
|
|
26
26
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const matrix_constructor = (rows, cols, element) => {
|
|
2
|
+
if (rows.isMatrix?.()) {
|
|
3
|
+
arr = rows.arr;
|
|
4
|
+
rows = rows.rows;
|
|
5
|
+
cols = rows.cols;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
let arr = [], i, j;
|
|
9
|
+
if (rows instanceof Array) {
|
|
10
|
+
arr = rows;
|
|
11
|
+
rows = arr.length;
|
|
12
|
+
cols = arr[0].length;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
for (i = 0; i < rows; i++) {
|
|
16
|
+
arr.push([]);
|
|
17
|
+
arr[i].push(new Array(cols));
|
|
18
|
+
for (j = 0; j < cols; j++) {
|
|
19
|
+
arr[i][j] = element[i * cols + j];
|
|
20
|
+
if (element[i * cols + j] == undefined) arr[i][j] = 0;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [
|
|
25
|
+
rows,
|
|
26
|
+
cols,
|
|
27
|
+
arr
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
};
|