ziko 0.54.0 → 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.cjs +998 -837
- package/dist/ziko.js +278 -137
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +271 -138
- package/package.json +1 -1
- package/src/data/converter/csv.js +1 -1
- package/src/math/complex/index.js +36 -9
- 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 +5 -5
- package/src/math/functions/index.js +1 -0
- package/src/math/functions/mapfun/index.js +14 -0
- package/src/math/functions/nested/index.js +41 -40
- package/src/math/functions/signal/index.js +104 -0
- package/src/math/functions/stats/index.js +49 -0
- package/src/math/functions/utils/index.js +90 -50
- package/src/math/matrix/index.js +605 -1
- package/src/math/statistics/functions/index.js +32 -32
- package/src/math/statistics/index.js +4 -4
- package/src/math/stats/index.js +1 -4
- package/src/math/stats/{position → percentile}/index.js +0 -3
- package/types/math/complex/index.d.ts +1 -0
- package/src/math/matrix/matrix.js +0 -596
|
@@ -1,54 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
if(x.isComplex?.()) return new x.constructor(
|
|
3
|
-
norm(x.a, min, max),
|
|
4
|
-
norm(x.b, min, max)
|
|
5
|
-
)
|
|
6
|
-
if(x.isMatrix?.()) return new x.constructor(
|
|
7
|
-
x.rows,
|
|
8
|
-
x.cols,
|
|
9
|
-
norm(x.arr.flat(1), min, max)
|
|
10
|
-
);
|
|
11
|
-
return min !== max ? (value - min) / (max - min) : 0;
|
|
12
|
-
}
|
|
1
|
+
import { mapfun, apply_fun } from "../mapfun/index.js";
|
|
13
2
|
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
lerp(x.a, min, max),
|
|
17
|
-
lerp(x.b, min, max)
|
|
18
|
-
)
|
|
19
|
-
if(x.isMatrix?.()) return new x.constructor(
|
|
20
|
-
x.rows,
|
|
21
|
-
x.cols,
|
|
22
|
-
lerp(x.arr.flat(1), min, max)
|
|
23
|
-
);
|
|
24
|
-
return (max - min) * value + min;
|
|
25
|
-
}
|
|
3
|
+
export const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
|
|
4
|
+
export const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
|
|
26
5
|
|
|
27
|
-
export const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
6
|
+
export const norm = (x, min, max) => apply_fun(
|
|
7
|
+
x,
|
|
8
|
+
v => min !== max ? (v - min) / (max - min) : 0
|
|
9
|
+
);
|
|
10
|
+
export const lerp = (x, min, max) => apply_fun(
|
|
11
|
+
x,
|
|
12
|
+
v => (max - min) * v + min
|
|
13
|
+
);
|
|
14
|
+
export const clamp = (x, min, max) => apply_fun(
|
|
15
|
+
x,
|
|
16
|
+
v => Math.min(Math.max(v, min), max)
|
|
17
|
+
);
|
|
18
|
+
export const map = (x, a, b, c, d) => apply_fun(
|
|
19
|
+
x,
|
|
20
|
+
v => lerp(norm(v, a, b), c, d)
|
|
21
|
+
);
|
|
39
22
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
+
// }
|
|
52
80
|
|
|
53
81
|
export const hypot = (...x) => {
|
|
54
82
|
const c0 = x.find(a => a.isComplex?.());
|
|
@@ -60,6 +88,18 @@ export const hypot = (...x) => {
|
|
|
60
88
|
};
|
|
61
89
|
|
|
62
90
|
|
|
63
|
-
export const atan2 = (
|
|
91
|
+
export const atan2 = (y, x, rad = true) => {
|
|
92
|
+
if (y instanceof Array && !(x instanceof Array))
|
|
93
|
+
return mapfun(n => atan2(n, x, rad), ...y);
|
|
94
|
+
|
|
95
|
+
if (x instanceof Array && !(y instanceof Array))
|
|
96
|
+
return mapfun(n => atan2(y, n, rad), ...x);
|
|
97
|
+
|
|
98
|
+
if (y instanceof Array && x instanceof Array)
|
|
99
|
+
return y.map((v, i) => atan2(v, x[i], rad));
|
|
100
|
+
|
|
101
|
+
const phi = Math.atan2(y, x);
|
|
102
|
+
return rad ? phi : phi * 180 / Math.PI;
|
|
103
|
+
}
|
|
104
|
+
|
|
64
105
|
|
|
65
|
-
}
|