ziko 0.51.0 → 0.52.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.
Files changed (37) hide show
  1. package/dist/ziko.cjs +1638 -1456
  2. package/dist/ziko.js +1446 -1385
  3. package/dist/ziko.min.js +2 -2
  4. package/dist/ziko.mjs +1446 -1385
  5. package/package.json +1 -1
  6. package/src/data/converter/csv.js +1 -1
  7. package/src/{__helpers__ → helpers}/register/index.js +1 -1
  8. package/src/hooks/use-ipc.js +1 -3
  9. package/src/math/adapted/index.js +7 -0
  10. package/src/math/complex/index.js +7 -5
  11. package/src/math/discret/Conversion/index.js +1 -1
  12. package/src/math/discret/Logic/index.js +1 -1
  13. package/src/math/functions/helper.js +68 -17
  14. package/src/math/functions/index.js +11 -11
  15. package/src/math/functions/primitives/index.js +176 -0
  16. package/src/math/mapfun/index.js +19 -0
  17. package/src/math/matrix/helpers/det.js +36 -0
  18. package/src/math/matrix/helpers/index.js +3 -0
  19. package/src/math/matrix/helpers/inverse.js +52 -0
  20. package/src/math/matrix/helpers/stack.js +24 -0
  21. package/src/math/matrix/index.js +1 -1
  22. package/src/math/matrix/matrix.js +601 -0
  23. package/src/math/random/index.js +88 -92
  24. package/src/math/signal/functions.js +23 -25
  25. package/src/math/utils/arithmetic.js +15 -17
  26. package/src/math/utils/index.js +1 -1
  27. package/src/math/utils/mapfun.js +31 -35
  28. package/src/ui/constructors/UIElement.js +9 -9
  29. package/src/ui/constructors/UIElementCore.js +2 -2
  30. package/types/math/adapted/index.d.ts +4 -0
  31. package/types/math/complex/index.d.ts +1 -1
  32. package/types/math/mapfun/index.d.ts +87 -0
  33. package/src/math/matrix/Matrix.js +0 -675
  34. /package/src/{__helpers__ → helpers}/checkers/index.js +0 -0
  35. /package/src/{__helpers__ → helpers}/index.js +0 -0
  36. /package/src/{__helpers__ → helpers}/register/register-to-class.js +0 -0
  37. /package/src/{__helpers__ → helpers}/register/register-to-instance.js +0 -0
@@ -1,8 +1,6 @@
1
1
 
2
- import{Complex}from"../complex/index.js"
3
2
  import { Utils } from "../utils/index.js";
4
- import{Base}from"../discret/index.js"
5
- import { matrix } from "../matrix/index.js";
3
+ import{ Base } from "../discret/index.js"
6
4
  class Random {
7
5
  static float(a = 1, b) {
8
6
  return b ? Math.random() * (b - a) + a : a * Math.random();
@@ -45,10 +43,6 @@ class Random {
45
43
  static shuffleArr(arr){
46
44
  return arr.sort(()=>0.5-Math.random())
47
45
  }
48
- static shuffleMatrix(M){
49
- const {rows,cols,arr}=M;
50
- return matrix(rows,cols,arr.flat().sort(()=>0.5-Math.random()))
51
- }
52
46
  static floats(n, a, b) {
53
47
  return new Array(n).fill(0).map(() => this.float(a, b));
54
48
  }
@@ -83,91 +77,93 @@ class Random {
83
77
  static colors(n) {
84
78
  return new Array(n).fill(null).map(()=>this.color());
85
79
  }
86
- static complex(a = [0,1], b = [0,1]) {
87
- return a instanceof Array?
88
- new Complex(
89
- this.float(a[0], a[1]),
90
- this.float(b[0], b[1])
91
- ):
92
- new Complex(
93
- ...this.floats(2,a,b)
94
- )
80
+
81
+ // Should be Moved to Matrix and Complex to avoid Circular dependencies
82
+ // static complex(a = [0,1], b = [0,1]) {
83
+ // return a instanceof Array?
84
+ // new Complex(
85
+ // this.float(a[0], a[1]),
86
+ // this.float(b[0], b[1])
87
+ // ):
88
+ // new Complex(
89
+ // ...this.floats(2,a,b)
90
+ // )
95
91
 
96
- }
97
- static complexInt(a = [0,1], b = [0,1]) {
98
- return new Complex(
99
- this.int(a[0], a[1]),
100
- this.int(b[0], b[1])
101
- );
102
- }
103
- static complexBin() {
104
- return new Complex(...this.bins(2));
105
- }
106
- static complexOct() {
107
- return new Complex(...this.octs(2));
108
- }
109
- static complexDec() {
110
- return new Complex(...this.decs(10));
111
- }
112
- static complexHex() {
113
- return new Complex(...this.octs(2));
114
- }
115
- static complexes(n, a = 0, b = 1) {
116
- return new Array(n).fill(0).map(() => this.complex(a, b));
117
- }
118
- static complexesInt(n, a = 0, b = 1) {
119
- return new Array(n).fill(0).map(() => this.complexInt(a, b));
120
- }
121
- static complexesBin(n) {
122
- return new Array(n).fill(0).map(() => this.complexBin());
123
- }
124
- static complexesOct(n) {
125
- return new Array(n).fill(0).map(() => this.complexOct());
126
- }
127
- static complexesDec(n) {
128
- return new Array(n).fill(0).map(() => this.complexDec());
129
- }
130
- static complexesHex(n) {
131
- return new Array(n).fill(0).map(() => this.complexHex());
132
- }
133
- static matrix(r,c,min,max){
134
- return matrix(r,c,this.floats(r*c,min,max))
135
- }
136
- static matrixInt(r,c,min,max){
137
- return matrix(r,c,this.ints(r*c,min,max))
138
- }
139
- static matrixBin(r,c){
140
- return matrix(r,c,this.bins(r*c))
141
- }
142
- static matrixOct(r,c){
143
- return matrix(r,c,this.octs(r*c))
144
- }
145
- static matrixDec(r,c){
146
- return matrix(r,c,this.decs(r*c))
147
- }
148
- static matrixHex(r,c){
149
- return matrix(r,c,this.hex(r*c))
150
- }
151
- static matrixColor(r,c){
152
- return matrix(r,c,this.colors(r*c))
153
- }
154
- static matrixComplex(r,c,a,b){
155
- return matrix(r,c,this.complexes(r*c,a,b))
156
- }
157
- static matrixComplexInt(r,c,a,b){
158
- return matrix(r,c,this.complexesInt(r*c,a,b))
159
- }
160
- static matrixComplexBin(r,c){
161
- return matrix(r,c,this.complexesBin(r*c))
162
- }
163
- static matrixComplexOct(r,c){
164
- return matrix(r,c,this.complexesBin(r*c))
165
- }
166
- static matrixComplexDec(r,c){
167
- return matrix(r,c,this.complexesBin(r*c))
168
- }
169
- static matrixComplexHex(r,c){
170
- return matrix(r,c,this.complexesBin(r*c))
171
- }
92
+ // }
93
+ // static complexInt(a = [0,1], b = [0,1]) {
94
+ // return new Complex(
95
+ // this.int(a[0], a[1]),
96
+ // this.int(b[0], b[1])
97
+ // );
98
+ // }
99
+ // static complexBin() {
100
+ // return new Complex(...this.bins(2));
101
+ // }
102
+ // static complexOct() {
103
+ // return new Complex(...this.octs(2));
104
+ // }
105
+ // static complexDec() {
106
+ // return new Complex(...this.decs(10));
107
+ // }
108
+ // static complexHex() {
109
+ // return new Complex(...this.octs(2));
110
+ // }
111
+ // static complexes(n, a = 0, b = 1) {
112
+ // return new Array(n).fill(0).map(() => this.complex(a, b));
113
+ // }
114
+ // static complexesInt(n, a = 0, b = 1) {
115
+ // return new Array(n).fill(0).map(() => this.complexInt(a, b));
116
+ // }
117
+ // static complexesBin(n) {
118
+ // return new Array(n).fill(0).map(() => this.complexBin());
119
+ // }
120
+ // static complexesOct(n) {
121
+ // return new Array(n).fill(0).map(() => this.complexOct());
122
+ // }
123
+ // static complexesDec(n) {
124
+ // return new Array(n).fill(0).map(() => this.complexDec());
125
+ // }
126
+ // static complexesHex(n) {
127
+ // return new Array(n).fill(0).map(() => this.complexHex());
128
+ // }
129
+ // static matrix(r,c,min,max){
130
+ // return matrix(r,c,this.floats(r*c,min,max))
131
+ // }
132
+ // static matrixInt(r,c,min,max){
133
+ // return matrix(r,c,this.ints(r*c,min,max))
134
+ // }
135
+ // static matrixBin(r,c){
136
+ // return matrix(r,c,this.bins(r*c))
137
+ // }
138
+ // static matrixOct(r,c){
139
+ // return matrix(r,c,this.octs(r*c))
140
+ // }
141
+ // static matrixDec(r,c){
142
+ // return matrix(r,c,this.decs(r*c))
143
+ // }
144
+ // static matrixHex(r,c){
145
+ // return matrix(r,c,this.hex(r*c))
146
+ // }
147
+ // static matrixColor(r,c){
148
+ // return matrix(r,c,this.colors(r*c))
149
+ // }
150
+ // static matrixComplex(r,c,a,b){
151
+ // return matrix(r,c,this.complexes(r*c,a,b))
152
+ // }
153
+ // static matrixComplexInt(r,c,a,b){
154
+ // return matrix(r,c,this.complexesInt(r*c,a,b))
155
+ // }
156
+ // static matrixComplexBin(r,c){
157
+ // return matrix(r,c,this.complexesBin(r*c))
158
+ // }
159
+ // static matrixComplexOct(r,c){
160
+ // return matrix(r,c,this.complexesBin(r*c))
161
+ // }
162
+ // static matrixComplexDec(r,c){
163
+ // return matrix(r,c,this.complexesBin(r*c))
164
+ // }
165
+ // static matrixComplexHex(r,c){
166
+ // return matrix(r,c,this.complexesBin(r*c))
167
+ // }
172
168
  }
173
169
  export{Random}
@@ -1,15 +1,13 @@
1
- import { Complex , complex } from "../complex/index.js";
2
1
  import { abs , pow , sqrtn , max , min} from "../functions/index.js";
3
2
  import { mul } from "../utils/index.js";
4
3
  import { E } from "../const.js";
5
- import { Matrix } from "../matrix/Matrix.js";
6
4
  const zeros=(n)=>new Array(n).fill(0);
7
5
  const ones=(n)=>new Array(n).fill(1);
8
6
  const nums=(num,n)=>new Array(n).fill(num);
9
7
  const norm=(value, min, max)=>{
10
8
  if (typeof value === "number") return min !== max ? (value - min) / (max - min) : 0;
11
- else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, norm(value.arr.flat(1), min, max));
12
- else if (value instanceof Complex) return new Complex(norm(value.a, min, max), norm(value.b, min, max));
9
+ else if (value.isMatrix?.()) return new value.constructor(value.rows, value.cols, norm(value.arr.flat(1), min, max));
10
+ else if (value.isComplex?.()) return new value.constructor(norm(value.a, min, max), norm(value.b, min, max));
13
11
  else if (value instanceof Array) {
14
12
  if (value.every((n) => typeof (n === "number"))) {
15
13
  return value.map((n) => norm(n, min, max));
@@ -23,8 +21,8 @@ const norm=(value, min, max)=>{
23
21
  }
24
22
  const lerp=(value, min, max)=>{
25
23
  if (typeof value === "number") return (max - min) * value + min;
26
- else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, lerp(value.arr.flat(1), min, max));
27
- else if (value instanceof Complex) return new Complex(lerp(value.a, min, max), lerp(value.b, min, max));
24
+ else if (value.isMatrix?.()) return new value.constructor(value.rows, value.cols, lerp(value.arr.flat(1), min, max));
25
+ else if (value.isComplex?.()) return new value.constructor(lerp(value.a, min, max), lerp(value.b, min, max));
28
26
  else if (value instanceof Array) {
29
27
  if (value.every((n) => typeof (n === "number"))) {
30
28
  return value.map((n) => lerp(n, min, max));
@@ -36,17 +34,17 @@ const lerp=(value, min, max)=>{
36
34
  }
37
35
  }
38
36
  }
39
- const map=(value, a, b, c, d)=>{
40
- if (typeof value === "number") return lerp(norm(value, a, b), c, d);
41
- else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, map(value.arr.flat(1), a, b, c, d));
42
- else if (value instanceof Complex) return new Complex(map(value.a, b, c, d), map(value.b, a, b, c, d));
43
- else if (value instanceof Array) {
44
- if (value.every((n) => typeof (n === "number"))) {
45
- return value.map((n) => map(n, a, b, c, d));
37
+ const map=(x, a, b, c, d)=>{
38
+ if (typeof x === "number") return lerp(norm(x, a, b), c, d);
39
+ else if (x.isMatrix?.()) return new x.constructor(x.rows, x.cols, map(x.arr.flat(1), a, b, c, d));
40
+ else if (x.isComplex?.()) return new x.constructor(map(x.a, b, c, d), map(x.b, a, b, c, d));
41
+ else if (x instanceof Array) {
42
+ if (x.every((n) => typeof (n === "number"))) {
43
+ return x.map((n) => map(n, a, b, c, d));
46
44
  } else {
47
- let y = new Array(value.length);
48
- for (let i = 0; i < value.length; i++) {
49
- y[i] = map(value[i], a, b, c, d);
45
+ let y = new Array(x.length);
46
+ for (let i = 0; i < x.length; i++) {
47
+ y[i] = map(x[i], a, b, c, d);
50
48
  }
51
49
  }
52
50
  }
@@ -54,8 +52,8 @@ const map=(value, a, b, c, d)=>{
54
52
  const clamp=(x, a , b)=>{
55
53
  const [min_value,max_value]=[min(a,b),max(a,b)]
56
54
  if (typeof x === "number") return min(max(x, min_value), max_value);
57
- else if (x instanceof Matrix) return new Matrix(x.rows, x.cols, clamp(x.arr.flat(1), min_value, max_value));
58
- else if (x instanceof Complex) return new Complex(clamp(x.a, min_value, max_value), clamp(x.b, min_value, max_value));
55
+ else if (x.isMatrix?.()) return new x.constructor(x.rows, x.cols, clamp(x.arr.flat(1), min_value, max_value));
56
+ else if (x.isComplex?.()) return new x.constructor(clamp(x.a, min_value, max_value), clamp(x.b, min_value, max_value));
59
57
  else if (x instanceof Array) {
60
58
  if (x.every((n) => typeof (n === "number"))) {
61
59
  return x.map((n) => clamp(n, min_value, max_value));
@@ -90,14 +88,14 @@ const linspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
90
88
  return Y
91
89
  }
92
90
 
93
- if([a,b].some(n=>n instanceof Complex)){
94
- const z1=complex(a)
95
- const z2=complex(b)
91
+ if([a,b].some(n=>n.isComplex?.())){
92
+ const z1 = new n.constructor(a)
93
+ const z2 = new n.constructor(b)
96
94
  n=n||Math.abs(z1.a-z2.a)+1;
97
95
  const X=linspace(z1.a,z2.a,n,endpoint);
98
96
  const Y=linspace(z1.b,z2.b,n,endpoint);
99
97
  let Z=new Array(n).fill(null);
100
- Z=Z.map((n,i)=>complex(X[i],Y[i]));
98
+ Z=Z.map((n,i)=> new n.constructor(X[i],Y[i]));
101
99
  return Z;
102
100
  }
103
101
  }
@@ -117,9 +115,9 @@ const geomspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
117
115
  return a<b?Y:Y.reverse()
118
116
  }
119
117
 
120
- if([a,b].some(n=>n instanceof Complex)){
121
- const z1=complex(a)
122
- const z2=complex(b)
118
+ if([a,b].some(n=>n.isComplex?.())){
119
+ const z1 = new n.constructor(a)
120
+ const z2 = new n.constructor(b)
123
121
  n=n||Math.abs(z1.a-z2.a)+1;
124
122
  let base;
125
123
  endpoint ? base = sqrtn(z2.div(z1),n-1) : base = sqrtn(z2.div(z1),n) ;
@@ -1,13 +1,11 @@
1
- import { Complex,complex} from "../complex/index.js";
2
- import { Matrix } from "../matrix/index.js";
3
1
  const _add=(a,b)=>{
4
2
  if(typeof(a)==="number"){
5
3
  if (typeof b == "number") return a + b;
6
- else if (b instanceof Complex)return complex(a + b.a, b.b);
7
- else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).add(b);
4
+ else if (b.isComplex?.())return new b.constructor(a + b.a, b.b);
5
+ else if (b.isMatrix?.()) return b.constructor.nums(b.rows, b.cols, a).add(b);
8
6
  else if (b instanceof Array)return b.map(n=>add(n,a));
9
7
  }
10
- else if(a instanceof Complex||a instanceof Matrix){
8
+ else if(a.isComplex?.()||a.isMatrix?.()){
11
9
  if(b instanceof Array)return b.map(n=>a.clone.add(n));
12
10
  return a.clone.add(b);
13
11
  }
@@ -23,11 +21,11 @@ const _add=(a,b)=>{
23
21
  const _sub=(a,b)=>{
24
22
  if(typeof(a)==="number"){
25
23
  if (typeof b == "number") return a - b;
26
- else if (b instanceof Complex)return complex(a - b.a, -b.b);
27
- else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).sub(b);
24
+ else if (b.isComplex?.())return new b.constructor(a - b.a, -b.b);
25
+ else if (b.isMatrix?.()) return b.constructor.nums(b.rows, b.cols, a).sub(b);
28
26
  else if (b instanceof Array)return b.map(n=>sub(n,a));
29
27
  }
30
- else if(a instanceof Complex||a instanceof Matrix){
28
+ else if(a.isComplex?.()||a.isMatrix?.()){
31
29
  if(b instanceof Array)return b.map(n=>a.clone.sub(n));
32
30
  return a.clone.sub(b);
33
31
  }
@@ -45,11 +43,11 @@ const _sub=(a,b)=>{
45
43
  const _mul=(a,b)=>{
46
44
  if(typeof(a)==="number"){
47
45
  if (typeof b == "number") return a * b;
48
- else if (b instanceof Complex)return complex(a * b.a,a * b.b);
49
- else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).mul(b);
46
+ else if (b.isComplex?.())return new b.constructor(a * b.a,a * b.b);
47
+ else if (b.isMatrix?.()) return b.constructor.nums(b.rows, b.cols, a).mul(b);
50
48
  else if (b instanceof Array)return b.map(n=>mul(a,n));
51
49
  }
52
- else if(a instanceof Complex||a instanceof Matrix){
50
+ else if(a.isComplex?.()||a.isMatrix?.()){
53
51
  if(b instanceof Array)return b.map(n=>a.clone.mul(n));
54
52
  return a.clone.mul(b);
55
53
  }
@@ -67,11 +65,11 @@ const _mul=(a,b)=>{
67
65
  const _div=(a,b)=>{
68
66
  if(typeof(a)==="number"){
69
67
  if (typeof b == "number") return a / b;
70
- else if (b instanceof Complex)return complex(a / b.a,a / b.b);
71
- else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).div(b);
68
+ else if (b.isComplex?.())return new b.constructor(a / b.a,a / b.b);
69
+ else if (b.isMatrix?.()) return b.constructor.nums(b.rows, b.cols, a).div(b);
72
70
  else if (b instanceof Array)return b.map(n=>div(a,n));
73
71
  }
74
- else if(a instanceof Complex||a instanceof Matrix){
72
+ else if(a.isComplex?.()||a.isMatrix?.()){
75
73
  if(b instanceof Array)return b.map(n=>a.clone.div(n));
76
74
  return a.clone.div(b);
77
75
  }
@@ -89,11 +87,11 @@ const _div=(a,b)=>{
89
87
  const _modulo=(a,b)=>{
90
88
  if(typeof(a)==="number"){
91
89
  if (typeof b == "number") return a % b;
92
- else if (b instanceof Complex)return complex(a % b.a,a % b.b);
93
- else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).modulo(b);
90
+ else if (b.isComplex?.())return new b.constructor(a % b.a,a % b.b);
91
+ else if (b.isMatrix?.()) return b.constructor.nums(b.rows, b.cols, a).modulo(b);
94
92
  else if (b instanceof Array)return b.map(n=>div(a,n));
95
93
  }
96
- else if(a instanceof Complex||a instanceof Matrix){
94
+ else if(a.isComplex?.()||a.isMatrix?.()){
97
95
  if(b instanceof Array)return b.map(n=>a.clone.div(n));
98
96
  return a.clone.div(b);
99
97
  }
@@ -1,4 +1,4 @@
1
- import { mapfun } from "./mapfun.js";
1
+ import { mapfun } from "../mapfun/index.js";
2
2
  import {
3
3
  add,
4
4
  sub,
@@ -1,47 +1,43 @@
1
- import { Matrix } from "../matrix/index.js";
2
- import { Complex , complex } from "../complex/index.js";
3
- import {ln,e,cos,sin,sqrt,cosh,sinh} from "../functions/index.js";
4
- import { Fixed } from "../functions/helper.js";
5
- // To generalise
6
-
7
1
  const mapfun=(fun,...X)=>{
8
2
  const Y=X.map(x=>{
9
- if(x===null) return fun(null);
10
- if(["number","string","boolean","bigint","undefined"].includes(typeof x)) return fun(x);
3
+ if(
4
+ x===null||
5
+ ["number","string","boolean","bigint","undefined"].includes(typeof x)||
6
+ x?.__mapfun__
7
+ ) return fun(x)
11
8
  if(x instanceof Array) return x.map(n=>mapfun(fun,n));
12
9
  if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
13
10
  if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
14
11
  if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
15
- if(x instanceof Matrix){
16
- return new Matrix(x.rows,x.cols, mapfun(x.arr.flat(1)))
17
- }
18
- if(x instanceof Complex){
19
- const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
20
- switch(fun){
21
- case Math.log: return complex(ln(z),phi); // Done
22
- case Math.exp: return complex(e(a)*cos(b),e(a)*sin(b)); // Done
23
- case Math.abs: return z; // Done
24
- case Math.sqrt: return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
25
- case Fixed.cos: return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
26
- case Fixed.sin: return complex(sin(a)*cosh(b),cos(a)*sinh(b));
27
- case Fixed.tan:{
28
- const DEN = cos(2*a)+cosh(2*b);
29
- return complex(sin(2*a)/DEN,sinh(2*b)/DEN);
30
- }
31
- case Fixed.cosh:return complex(cosh(a)*cos(b),sinh(a)*sin(b));
32
- case Fixed.sinh:return complex(sinh(a)*cos(b),cosh(a)*sin(b));
33
- case Fixed.tanh:{
34
- const DEN=cosh(2*a)+cos(2*b);
35
- return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
36
- }
37
- default : return fun(x)
38
- }
39
- }
12
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
13
+ // if(x.isComplex?.()){
14
+ // const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
15
+ // switch(fun){
16
+ // // Moved to Fixed to avoid Circular Dep
17
+ // // case Math.log: return new x.constructor(ln(z),phi); // Done
18
+ // // case Math.exp: return new x.constructor(e(a)*cos(b),e(a)*sin(b)); // Done
19
+ // // case Math.abs: return z; // Done
20
+ // // case Math.sqrt: return new x.constructor(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
21
+ // // case Fixed.cos: return new x.constructor(cos(a)*cosh(b),-(sin(a)*sinh(b)));
22
+ // // case Fixed.sin: return new x.constructor(sin(a)*cosh(b),cos(a)*sinh(b));
23
+ // // case Fixed.tan:{
24
+ // // const DEN = cos(2*a)+cosh(2*b);
25
+ // // return new x.constructor(sin(2*a)/DEN,sinh(2*b)/DEN);
26
+ // // }
27
+ // // case Fixed.cosh:return new x.constructor(cosh(a)*cos(b),sinh(a)*sin(b));
28
+ // // case Fixed.sinh:return new x.constructor(sinh(a)*cos(b),cosh(a)*sin(b));
29
+ // // case Fixed.tanh:{
30
+ // // const DEN=cosh(2*a)+cos(2*b);
31
+ // // return new x.constructor(sinh(2*a)/DEN,sin(2*b)/DEN)
32
+ // // }
33
+ // default : return fun(x)
34
+ // }
35
+ // }
40
36
  else if(x instanceof Object){
41
37
  return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
42
- return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
38
+ // return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
43
39
  }
44
40
  });
45
- return Y.length==1?Y[0]:Y;
41
+ return Y.length==1? Y[0]: Y;
46
42
  }
47
43
  export {mapfun}
@@ -1,5 +1,5 @@
1
1
  import { UIElementCore } from "./UIElementCore.js";
2
- import { register_to_class } from "../../__helpers__/register/register-to-class.js";
2
+ import { register_to_class } from "../../helpers/register/register-to-class.js";
3
3
  import {
4
4
  LifecycleMethods,
5
5
  AttrsMethods,
@@ -8,14 +8,14 @@ import {
8
8
  EventsMethodes,
9
9
  StyleMethods
10
10
  } from "../__methods__/index.js";
11
- import {
12
- // useCustomEvent,
13
- // useSwipeEvent,
14
- // watchIntersection,
15
- // watchSize,
16
- // watchAttr,
17
- // watchChildren
18
- } from "../../--reactivity-deprecated/events/custom-event.js"
11
+ // import {
12
+ // // useCustomEvent,
13
+ // // useSwipeEvent,
14
+ // // watchIntersection,
15
+ // // watchSize,
16
+ // // watchAttr,
17
+ // // watchChildren
18
+ // } from "../../--reactivity-deprecated/events/custom-event.js"
19
19
  class UIElement extends UIElementCore{
20
20
  constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
21
21
  super()
@@ -1,7 +1,7 @@
1
1
  import {UINode} from "./UINode.js";
2
- // import {__init__global__} from '../../__ziko__/index.js';
2
+ import {__init__global__} from '../../__ziko__/index.js';
3
3
  import { UIStore } from "../../__ziko__/__ui__.js";
4
- // __init__global__()
4
+ __init__global__()
5
5
  class UIElementCore extends UINode{
6
6
  constructor(){
7
7
  super()
@@ -0,0 +1,4 @@
1
+ import type { Complex } from '../complex'
2
+ export declare function adapted_cos(x: Complex): Complex;
3
+ export declare function adapted_cos(x: number): number;
4
+
@@ -16,7 +16,7 @@ export declare class Complex {
16
16
 
17
17
  isComplex(): true;
18
18
  toString(): string;
19
-
19
+ readonly __mapfun__ : boolean
20
20
  readonly clone: Complex;
21
21
  readonly z: number;
22
22
  readonly phi: number;
@@ -0,0 +1,87 @@
1
+ import { Complex } from "../../../src/math/index.js";
2
+ import { Matrix } from "../../../src/math/matrix/index.js";
3
+
4
+ /**
5
+ * Objects that behave like primitives for mapfun,
6
+ * meaning fun(x) is applied directly without recursion.
7
+ */
8
+ export interface MapfunPrimitiveLike {
9
+ __mapfun__?: boolean;
10
+ }
11
+
12
+ export type PrimitiveLike =
13
+ | number
14
+ | boolean
15
+ | string
16
+ | bigint
17
+ | undefined
18
+ | null
19
+ | { readonly __mapfun__: boolean };
20
+
21
+ export type Mappable =
22
+ | number
23
+ | string
24
+ | boolean
25
+ | bigint
26
+ | undefined
27
+ | null
28
+ | Matrix
29
+ | MapfunPrimitiveLike
30
+ | any[]
31
+ | Set<any>
32
+ | Map<any, any>
33
+ | object;
34
+
35
+ /**
36
+ * mapfun transform rules
37
+ */
38
+ export type MapfunResult<F extends (x: any) => any, T> =
39
+ // Objects with __mapfun__ → treat as primitive (call fun(x))
40
+ // T extends MapfunPrimitiveLike
41
+ // ? ReturnType<F> :
42
+
43
+ // Matrix → always return Matrix (your JS logic rebuilds a new Matrix)
44
+
45
+ T extends PrimitiveLike
46
+ ? ReturnType<F> :
47
+ // T extends Complex
48
+ // ? T :
49
+ T extends Matrix
50
+ ? T :
51
+
52
+ // Array → deep-map
53
+ T extends Array<infer U>
54
+ ? Array<MapfunResult<F, U>> :
55
+
56
+ // Set → deep-map
57
+ T extends Set<infer U>
58
+ ? Set<MapfunResult<F, U>> :
59
+
60
+ // Map → deep-map values
61
+ T extends Map<infer K, infer V>
62
+ ? Map<K, MapfunResult<F, V>> :
63
+
64
+ // Other objects → recursively map fields
65
+ T extends object
66
+ ? { [K in keyof T]: MapfunResult<F, T[K]> } :
67
+
68
+ // Primitive
69
+ ReturnType<F>;
70
+
71
+ /**
72
+ * If only one argument → return mapped value
73
+ * If multiple → return tuple of mapped values
74
+ */
75
+ type UnwrapSingle<T extends unknown[]> =
76
+ T extends [infer U] ? U : { [K in keyof T]: T[K] };
77
+
78
+ /**
79
+ * mapfun main declaration
80
+ */
81
+ export declare function mapfun<
82
+ F extends (x: any) => any,
83
+ A extends Mappable[]
84
+ >(
85
+ fun: F,
86
+ ...values: A
87
+ ): UnwrapSingle<{ [K in keyof A]: MapfunResult<F, A[K]> }>;