ziko 0.52.0 → 0.53.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "0.52.0",
3
+ "version": "0.53.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",
@@ -69,7 +69,7 @@ class Complex{
69
69
  return str;
70
70
  }
71
71
 
72
- get clone() {
72
+ clone() {
73
73
  return new Complex(this.a, this.b);
74
74
  }
75
75
  get z(){
@@ -146,19 +146,19 @@ class Complex{
146
146
  return [this.z, this.phi];
147
147
  }
148
148
  static add(c,...z) {
149
- return c.clone.add(...z);
149
+ return c.clone().add(...z);
150
150
  }
151
151
  static sub(c,...z) {
152
- return c.clone.sub(...z);
152
+ return c.clone().sub(...z);
153
153
  }
154
154
  static mul(c,...z) {
155
- return c.clone.mul(...z);
155
+ return c.clone().mul(...z);
156
156
  }
157
157
  static div(c,...z) {
158
- return c.clone.div(...z);
158
+ return c.clone().div(...z);
159
159
  }
160
160
  static pow(z,n){
161
- return z.clone.pow(n);
161
+ return z.clone().pow(n);
162
162
  }
163
163
  static xpowZ(x){
164
164
  return complex((x**this.a)*cos(this.b*ln(x)),(x**this.a)*sin(this.b*ln(x)));
@@ -8,21 +8,68 @@ export const abs = (...x) => mapfun(
8
8
  ...x
9
9
  )
10
10
 
11
+ export const pow = (...x) => {
12
+ const n = x.pop();
13
+ return mapfun(
14
+ x => {
15
+ if(x.isComplex?.()) {
16
+ if(n.isComplex?.()) return new x.constructor({
17
+ z: Math.exp(n.a * Math.log(x.z) - n.b * x.phi),
18
+ phi: n.b * Math.log(x.z) + n.a * x.phi
19
+ })
20
+ return new x.constructor({z: x.z ** n, phi: x.phi * n});
21
+ }
22
+ if(n.isComplex?.()) return new x.constructor({
23
+ z: Math.exp(n.a * Math.log(x)),
24
+ phi: n.b * Math.log(x)
25
+ })
26
+ return Math.pow(x, n)
27
+ },
28
+ ...x
29
+ )
30
+ }
31
+
11
32
  export const sqrt = (...x) => mapfun(
12
33
  x=>{
13
- if(x.isComplex?.()){
14
- const {z, phi} = x
15
- return new x.constructor(
16
- Math.sqrt(z) * Math.cos(phi/2),
17
- Math.sqrt(z) * Math.sin(phi/2)
18
- );
19
- }
34
+ if(x.isComplex?.())
35
+ return new x.constructor({z: x.z**(1/2), phi: x.phi/2})
20
36
  return Math.sqrt(x);
21
37
  },
22
38
  ...x
23
- )
39
+ );
40
+
41
+ export const cbrt = (...x) => mapfun(
42
+ x=>{
43
+ if(x.isComplex?.())
44
+ return new x.constructor({z: x.z**(1/3), phi: x.phi/3})
45
+ return Math.sqrt(x);
46
+ },
47
+ ...x
48
+ );
24
49
 
25
- export const e = (...x) => mapfun(
50
+ export const nthr = (...x) => {
51
+ const n = x.pop();
52
+ return mapfun(
53
+ x => {
54
+ if(x.isComplex?.()) return new x.constructor({z: x.z ** 1/n, phi: x.phi / n});
55
+ return x**(1/n)
56
+ },
57
+ ...x
58
+ )
59
+ }
60
+
61
+ export const croot = (...x) =>{
62
+ const z = x.pop()
63
+ return mapfun(
64
+ x => {
65
+ if(x.isComplex?.()) return null
66
+ return null
67
+ },
68
+ ...x
69
+ )
70
+ }
71
+
72
+ export const exp = (...x) => mapfun(
26
73
  x => {
27
74
  if(x.isComplex?.()) return new x.constructor(
28
75
  Math.exp(x.a) * Math.cos(x.b),
@@ -55,6 +102,60 @@ export const sign = (...x) => mapfun(
55
102
  }
56
103
  ,...x
57
104
  );
105
+
106
+ export const floor = (...x) => mapfun(
107
+ x => {
108
+ if(x.isComplex?.()) return new x.constructor(
109
+ Math.floor(x.a),
110
+ Math.floor(x.b)
111
+ )
112
+ return Math.floor(x)
113
+ },
114
+ ...x
115
+ )
116
+ export const ceil = (...x) => mapfun(
117
+ x => {
118
+ if(x.isComplex?.()) return new x.constructor(
119
+ Math.ceil(x.a),
120
+ Math.ceil(x.b)
121
+ )
122
+ return Math.ceil(x)
123
+ },
124
+ ...x
125
+ )
126
+ export const round = (...x) => mapfun(
127
+ x => {
128
+ if(x.isComplex?.()) return new x.constructor(
129
+ Math.round(x.a),
130
+ Math.round(x.b)
131
+ )
132
+ return Math.round(x)
133
+ },
134
+ ...x
135
+ )
136
+
137
+ export const trunc = (...x) => mapfun(
138
+ x => {
139
+ if(x.isComplex?.()) return new x.constructor(
140
+ Math.trunc(x.a),
141
+ Math.trunc(x.b)
142
+ )
143
+ return Math.trunc(x)
144
+ },
145
+ ...x
146
+ )
147
+
148
+ export const fract = (...x) => mapfun(
149
+ x => {
150
+ if(x.isComplex?.()) return new x.constructor(
151
+ x.a - Math.trunc(x.a),
152
+ x.b - Math.trunc(x.b)
153
+ )
154
+ return x - Math.trunc(x)
155
+ },
156
+ ...x
157
+ )
158
+
58
159
  export const cos = (...x) => mapfun(
59
160
  x => {
60
161
  if(x.isComplex?.()) return new x.constructor(
@@ -80,10 +181,10 @@ export const sin = (...x) => mapfun(
80
181
  export const tan = (...x) => mapfun(
81
182
  x =>{
82
183
  if(x?.isComplex){
83
- const DEN = Math.cos(2*x.a) + Math.cosh(2*x.b);
184
+ const D = Math.cos(2*x.a) + Math.cosh(2*x.b);
84
185
  return new x.constructor(
85
- Math.sin(2*x.a) / DEN,
86
- Math.sinh(2*x.b) / DEN
186
+ Math.sin(2*x.a) / D,
187
+ Math.sinh(2*x.b) / D
87
188
  );
88
189
  }
89
190
  return Math.tan(x)
@@ -91,6 +192,16 @@ export const tan = (...x) => mapfun(
91
192
  ...x
92
193
  );
93
194
 
195
+ export const sec = (...x) => mapfun(
196
+ x => {
197
+ if(x.isComplex?.()) {
198
+
199
+ }
200
+ return 1 / Math.cos(x)
201
+ }
202
+ ,...x
203
+ );
204
+
94
205
  export const acos = (...x) => mapfun(
95
206
  x =>{
96
207
  if(x?.isComplex){
@@ -99,7 +210,6 @@ export const acos = (...x) => mapfun(
99
210
  const Rm = Math.hypot(a - 1, b);
100
211
  globalThis.Rp = Rp
101
212
  globalThis.Rm = Rm
102
- console.log({a, b, Rp, Rm})
103
213
  return new x.constructor(
104
214
  Math.acos((Rp - Rm) / 2),
105
215
  -Math.acosh((Rp + Rm) / 2),
@@ -140,6 +250,20 @@ export const atan = (...x) => mapfun(
140
250
  ...x
141
251
  );
142
252
 
253
+ export const acot = (...x) => mapfun(
254
+ x => {
255
+ if(x?.isComplex){
256
+ const { a, b } = x;
257
+ return new x.constructor(
258
+ Math.atan(2*a/(a**2+(b-1)*(b+1)))/2,
259
+ Math.log((a**2 + (b-1)**2)/(a**2 + (b+1)**2))/4
260
+ )
261
+ }
262
+ return Math.PI/2 - Math.atan(x);
263
+ },
264
+ ...x
265
+ );
266
+
143
267
 
144
268
  export const cosh = (...x) => mapfun(
145
269
  x =>{
@@ -164,13 +288,68 @@ export const sinh = (...x) => mapfun(
164
288
  export const tanh = (...x) => mapfun(
165
289
  x =>{
166
290
  if(x?.isComplex){
167
- const DEN=cosh(2*a)+cos(2*b);
291
+ const D=cosh(2*a)+cos(2*b);
168
292
  return new x.constructor(
169
- sinh(2*a)/DEN,
170
- sin(2*b)/DEN
293
+ sinh(2*a)/D,
294
+ sin(2*b)/D
171
295
  )
172
296
  }
173
297
  return tanh(x)
174
298
  },
175
299
  ...x
300
+ )
301
+
302
+ export const coth = (...x) => mapfun(
303
+ x =>{
304
+ if(x?.isComplex){
305
+ const {a, b} = x
306
+ const D = (Math.sinh(a)**2)*(Math.cos(b)**2) + (Math.cosh(a)**2)*(Math.sin(b)**2)
307
+ return new x.constructor(
308
+ Math.cosh(a) * Math.sinh(a) / D,
309
+ - Math.sin(b) * Math.cos(b) / D
310
+ )
311
+ }
312
+ return 1/Math.tanh(x)
313
+ },
314
+ ...x
315
+ )
316
+
317
+ export const acosh = (...x) => mapfun(
318
+ x =>{
319
+ if(x?.isComplex){
320
+ return ln(x.clone().add(sqrt(x.clone().mul(x.clone()).sub(1))))
321
+ }
322
+ return Math.acosh(x)
323
+ },
324
+ ...x
325
+ )
326
+
327
+ export const asinh = (...x) => mapfun(
328
+ x =>{
329
+ if(x?.isComplex){
330
+ return ln(x.clone().add(sqrt(x.clone().mul(x.clone()).add(1))))
331
+ }
332
+ return Math.asinh(x)
333
+ },
334
+ ...x
335
+ )
336
+
337
+ export const atanh = (...x) => mapfun(
338
+ x =>{
339
+ if(x?.isComplex){
340
+
341
+ }
342
+ return Math.atanh(x)
343
+ },
344
+ ...x
345
+ )
346
+
347
+ export const sig = (...x) => mapfun(
348
+ x =>{
349
+ if(x?.isComplex){
350
+
351
+ }
352
+ return 1/(1+Math.e(-x))
353
+ },
354
+ ...x
176
355
  )