ziko 0.0.1

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 (226) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +316 -0
  3. package/dist/ziko.cjs +9786 -0
  4. package/dist/ziko.js +9792 -0
  5. package/dist/ziko.min.js +9 -0
  6. package/dist/ziko.mjs +9567 -0
  7. package/package.json +55 -0
  8. package/src/App/Accessibility/index.js +0 -0
  9. package/src/App/Globals/__Target__.js +3 -0
  10. package/src/App/Globals/__UI__.js +38 -0
  11. package/src/App/Globals/__init__.js +8 -0
  12. package/src/App/Globals/index.js +3 -0
  13. package/src/App/Router/index.js +40 -0
  14. package/src/App/Seo/index.js +43 -0
  15. package/src/App/Themes/dark.js +885 -0
  16. package/src/App/Themes/index.js +11 -0
  17. package/src/App/Themes/light.js +255 -0
  18. package/src/App/app.js +37 -0
  19. package/src/App/index.js +11 -0
  20. package/src/Data/Api/fetchdom.js +14 -0
  21. package/src/Data/Api/index.js +4 -0
  22. package/src/Data/Api/preload.js +11 -0
  23. package/src/Data/Converter/canvas.js +25 -0
  24. package/src/Data/Converter/csv.js +33 -0
  25. package/src/Data/Converter/index.js +25 -0
  26. package/src/Data/Converter/json.js +80 -0
  27. package/src/Data/Converter/markdown.js +83 -0
  28. package/src/Data/Converter/svg.js +11 -0
  29. package/src/Data/Parser/markdown.js +0 -0
  30. package/src/Data/Parser/xml.js +47 -0
  31. package/src/Data/Strings/index.js +26 -0
  32. package/src/Data/decorators.js +0 -0
  33. package/src/Data/index.js +64 -0
  34. package/src/Graphics/Canvas/Elements/Basic/arc.js +43 -0
  35. package/src/Graphics/Canvas/Elements/Basic/image.js +0 -0
  36. package/src/Graphics/Canvas/Elements/Basic/line.js +26 -0
  37. package/src/Graphics/Canvas/Elements/Basic/path.js +0 -0
  38. package/src/Graphics/Canvas/Elements/Basic/points.js +48 -0
  39. package/src/Graphics/Canvas/Elements/Basic/polygon.js +7 -0
  40. package/src/Graphics/Canvas/Elements/Basic/polyline.js +0 -0
  41. package/src/Graphics/Canvas/Elements/Basic/rect.js +46 -0
  42. package/src/Graphics/Canvas/Elements/Basic/text.js +0 -0
  43. package/src/Graphics/Canvas/Elements/Chart/histogram.js +0 -0
  44. package/src/Graphics/Canvas/Elements/Chart/plot.js +0 -0
  45. package/src/Graphics/Canvas/Elements/Chart/scatter.js +2 -0
  46. package/src/Graphics/Canvas/Elements/Chart/stem.js +0 -0
  47. package/src/Graphics/Canvas/Elements/Element.js +115 -0
  48. package/src/Graphics/Canvas/Elements/Groupe.js +0 -0
  49. package/src/Graphics/Canvas/Elements/grid.js +0 -0
  50. package/src/Graphics/Canvas/Elements/index.js +13 -0
  51. package/src/Graphics/Canvas/Filter/index.js +0 -0
  52. package/src/Graphics/Canvas/Paint/index.js +0 -0
  53. package/src/Graphics/Canvas/Utils/color.js +8 -0
  54. package/src/Graphics/Canvas/Utils/floodFill.js +58 -0
  55. package/src/Graphics/Canvas/_canvas_offscreen +0 -0
  56. package/src/Graphics/Canvas/canvas.js +189 -0
  57. package/src/Graphics/Canvas/index.js +15 -0
  58. package/src/Graphics/Svg/Elements/ZikoSvgElement.js +28 -0
  59. package/src/Graphics/Svg/Elements/circle.js +34 -0
  60. package/src/Graphics/Svg/Elements/ellipse.js +29 -0
  61. package/src/Graphics/Svg/Elements/foreignObject.js +46 -0
  62. package/src/Graphics/Svg/Elements/grid.js +9 -0
  63. package/src/Graphics/Svg/Elements/groupe.js +29 -0
  64. package/src/Graphics/Svg/Elements/image.js +33 -0
  65. package/src/Graphics/Svg/Elements/line.js +29 -0
  66. package/src/Graphics/Svg/Elements/path.js +59 -0
  67. package/src/Graphics/Svg/Elements/polygon.js +31 -0
  68. package/src/Graphics/Svg/Elements/polyline.js +4 -0
  69. package/src/Graphics/Svg/Elements/rect.js +43 -0
  70. package/src/Graphics/Svg/Elements/text.js +26 -0
  71. package/src/Graphics/Svg/index.js +1 -0
  72. package/src/Graphics/Svg/svg.js +117 -0
  73. package/src/Graphics/index.js +61 -0
  74. package/src/Math/Calculus/Special Functions/bessel.js +31 -0
  75. package/src/Math/Calculus/Special Functions/beta.js +38 -0
  76. package/src/Math/Calculus/Special Functions/gamma.js +30 -0
  77. package/src/Math/Calculus/Special Functions/index.js +4 -0
  78. package/src/Math/Calculus/index.js +1 -0
  79. package/src/Math/Complex/Fractals/julia.js +0 -0
  80. package/src/Math/Complex/index.js +191 -0
  81. package/src/Math/Discret/Combinaison/index.js +34 -0
  82. package/src/Math/Discret/Conversion/index.js +86 -0
  83. package/src/Math/Discret/Logic/index.js +46 -0
  84. package/src/Math/Discret/Permutation/index.js +31 -0
  85. package/src/Math/Discret/Set/index.js +2 -0
  86. package/src/Math/Discret/Set/powerSet.js +15 -0
  87. package/src/Math/Discret/Set/subSet.js +10 -0
  88. package/src/Math/Discret/index.js +23 -0
  89. package/src/Math/Functions/index.js +182 -0
  90. package/src/Math/Matrix/Decomposition.js +90 -0
  91. package/src/Math/Matrix/LinearSystem.js +10 -0
  92. package/src/Math/Matrix/Matrix.js +712 -0
  93. package/src/Math/Matrix/index.js +3 -0
  94. package/src/Math/Numeric/index.js +0 -0
  95. package/src/Math/Random/index.js +173 -0
  96. package/src/Math/Signal/__np.py.txt +40 -0
  97. package/src/Math/Signal/conv.js +175 -0
  98. package/src/Math/Signal/fft.js +55 -0
  99. package/src/Math/Signal/filter.js +39 -0
  100. package/src/Math/Signal/functions.js +146 -0
  101. package/src/Math/Signal/index.js +110 -0
  102. package/src/Math/Statistics/Functions/index.js +100 -0
  103. package/src/Math/Statistics/index.js +16 -0
  104. package/src/Math/Utils/arithmetic.js +139 -0
  105. package/src/Math/Utils/checkers.js +11 -0
  106. package/src/Math/Utils/comparaison.js +1 -0
  107. package/src/Math/Utils/conversions.js +7 -0
  108. package/src/Math/Utils/discret.js +28 -0
  109. package/src/Math/Utils/index.js +102 -0
  110. package/src/Math/Utils/mapfun.js +43 -0
  111. package/src/Math/absract.js +1 -0
  112. package/src/Math/const.js +3 -0
  113. package/src/Math/index.js +193 -0
  114. package/src/Reactivity/Events/Global/Click.js +56 -0
  115. package/src/Reactivity/Events/Global/Clipboard.js +84 -0
  116. package/src/Reactivity/Events/Global/CustomEvent.js +53 -0
  117. package/src/Reactivity/Events/Global/Drag.js +137 -0
  118. package/src/Reactivity/Events/Global/Focus.js +56 -0
  119. package/src/Reactivity/Events/Global/Key.js +104 -0
  120. package/src/Reactivity/Events/Global/Pointer.js +214 -0
  121. package/src/Reactivity/Events/Partiel/Input.js +59 -0
  122. package/src/Reactivity/Events/ZikoEvent.js +91 -0
  123. package/src/Reactivity/Events/index.js +51 -0
  124. package/src/Reactivity/Observer/index.js +3 -0
  125. package/src/Reactivity/Observer/intersection.js +40 -0
  126. package/src/Reactivity/Observer/mutation.js +90 -0
  127. package/src/Reactivity/Observer/resize.js +47 -0
  128. package/src/Reactivity/Use/Contexte/index.js +1 -0
  129. package/src/Reactivity/Use/Contexte/useSuccesifKeys.js +14 -0
  130. package/src/Reactivity/Use/Decorators/index.js +4 -0
  131. package/src/Reactivity/Use/Interactions/index.js +4 -0
  132. package/src/Reactivity/Use/Interactions/useBluetooth.js +48 -0
  133. package/src/Reactivity/Use/Interactions/useChannel.js +50 -0
  134. package/src/Reactivity/Use/Interactions/useEventEmmiter.js +64 -0
  135. package/src/Reactivity/Use/Interactions/useSerial.js +0 -0
  136. package/src/Reactivity/Use/Interactions/useThread.js +44 -0
  137. package/src/Reactivity/Use/Interactions/useUsb.js +0 -0
  138. package/src/Reactivity/Use/Sensors/index.js +2 -0
  139. package/src/Reactivity/Use/Sensors/useBattery.js +36 -0
  140. package/src/Reactivity/Use/Sensors/useCamera.js +0 -0
  141. package/src/Reactivity/Use/Sensors/useGeolocation.js +17 -0
  142. package/src/Reactivity/Use/Sensors/useMicro.js +0 -0
  143. package/src/Reactivity/Use/Sensors/useOrientation.js +0 -0
  144. package/src/Reactivity/Use/Storage/index.js +1 -0
  145. package/src/Reactivity/Use/Storage/useCookie.js +0 -0
  146. package/src/Reactivity/Use/Storage/useIndexedDb.js +0 -0
  147. package/src/Reactivity/Use/Storage/useStorage.js +74 -0
  148. package/src/Reactivity/Use/UI/index.js +4 -0
  149. package/src/Reactivity/Use/UI/useCssLink.js +0 -0
  150. package/src/Reactivity/Use/UI/useCssText.js +21 -0
  151. package/src/Reactivity/Use/UI/useFavIcon.js +38 -0
  152. package/src/Reactivity/Use/UI/useLinearGradient.js +0 -0
  153. package/src/Reactivity/Use/UI/useMediaQuery.js +1 -0
  154. package/src/Reactivity/Use/UI/useRadialGradient.js +0 -0
  155. package/src/Reactivity/Use/UI/useStyle.js +54 -0
  156. package/src/Reactivity/Use/UI/useTheme.js +62 -0
  157. package/src/Reactivity/Use/UI/useTitle.js +30 -0
  158. package/src/Reactivity/Use/index.js +82 -0
  159. package/src/Reactivity/Use/todo.md +26 -0
  160. package/src/Reactivity/index.js +3 -0
  161. package/src/Time/animation.js +76 -0
  162. package/src/Time/index.js +54 -0
  163. package/src/Time/loop.js +83 -0
  164. package/src/Time/utils/decorators.js +17 -0
  165. package/src/Time/utils/ease.js +144 -0
  166. package/src/Time/utils/index.js +18 -0
  167. package/src/Time/utils/performance.js +16 -0
  168. package/src/Time/utils/ui.js +26 -0
  169. package/src/UI/CustomElement/Elements/Accordion/index.js +62 -0
  170. package/src/UI/CustomElement/Elements/Carousel/index.js +47 -0
  171. package/src/UI/CustomElement/Elements/CodeNote/CodeCell.js +176 -0
  172. package/src/UI/CustomElement/Elements/CodeNote/CodeNote.js +69 -0
  173. package/src/UI/CustomElement/Elements/CodeNote/SubElements.js +64 -0
  174. package/src/UI/CustomElement/Elements/CodeNote/index.js +2 -0
  175. package/src/UI/CustomElement/Elements/Columns.js +1 -0
  176. package/src/UI/CustomElement/Elements/FAB.js +0 -0
  177. package/src/UI/CustomElement/Elements/Menu.js +0 -0
  178. package/src/UI/CustomElement/Elements/Notification.js +0 -0
  179. package/src/UI/CustomElement/Elements/Popover.js +0 -0
  180. package/src/UI/CustomElement/Elements/Popup.js +0 -0
  181. package/src/UI/CustomElement/Elements/Swipper.js +4 -0
  182. package/src/UI/CustomElement/Elements/Tabs/index.js +111 -0
  183. package/src/UI/CustomElement/Elements/Timeline.js +0 -0
  184. package/src/UI/CustomElement/Elements/Toast.js +0 -0
  185. package/src/UI/CustomElement/Elements/Treeview.js +0 -0
  186. package/src/UI/CustomElement/Elements/index.js +4 -0
  187. package/src/UI/CustomElement/Flex.js +97 -0
  188. package/src/UI/CustomElement/Grid.js +30 -0
  189. package/src/UI/CustomElement/index.js +3 -0
  190. package/src/UI/Embaded/index.js +1 -0
  191. package/src/UI/Inputs/Primitives/btn.js +31 -0
  192. package/src/UI/Inputs/Primitives/elements.js +28 -0
  193. package/src/UI/Inputs/Primitives/inputs.js +334 -0
  194. package/src/UI/Inputs/Primitives/select.js +15 -0
  195. package/src/UI/Inputs/Primitives/textarea.js +16 -0
  196. package/src/UI/Inputs/camera.js +23 -0
  197. package/src/UI/Inputs/index.js +20 -0
  198. package/src/UI/List/elements.js +0 -0
  199. package/src/UI/List/index.js +130 -0
  200. package/src/UI/Media/Audio/index.js +26 -0
  201. package/src/UI/Media/Image/figure.js +17 -0
  202. package/src/UI/Media/Image/image.js +34 -0
  203. package/src/UI/Media/Image/index.js +2 -0
  204. package/src/UI/Media/Video/index.js +37 -0
  205. package/src/UI/Media/index.js +3 -0
  206. package/src/UI/Misc/index.js +49 -0
  207. package/src/UI/Semantic/index.js +68 -0
  208. package/src/UI/Style/index.js +499 -0
  209. package/src/UI/Table/elements.js +94 -0
  210. package/src/UI/Table/index.js +3 -0
  211. package/src/UI/Table/table.js +113 -0
  212. package/src/UI/Table/utils.js +12 -0
  213. package/src/UI/Text/heading.js +35 -0
  214. package/src/UI/Text/index.js +3 -0
  215. package/src/UI/Text/p.js +37 -0
  216. package/src/UI/Text/pre.js +0 -0
  217. package/src/UI/Text/text.js +66 -0
  218. package/src/UI/Utils/index.js +70 -0
  219. package/src/UI/ZikoUIElement.js +478 -0
  220. package/src/UI/index.js +154 -0
  221. package/src/__proto__/Array.js +74 -0
  222. package/src/__proto__/Function.js +0 -0
  223. package/src/__proto__/Number.js +76 -0
  224. package/src/__proto__/Object.js +0 -0
  225. package/src/__proto__/String.js +0 -0
  226. package/src/index.js +69 -0
@@ -0,0 +1,110 @@
1
+ import { mapfun } from "../Utils";
2
+ import { abs , sinc , sign , sin } from "../Functions/index.js"
3
+ import { Random } from "../Random/index.js";
4
+ import {
5
+ zeros,
6
+ ones,
7
+ nums,
8
+ arange,
9
+ linspace,
10
+ logspace,
11
+ geomspace,
12
+ map,
13
+ norm,
14
+ lerp,
15
+ clamp,
16
+ } from "./functions.js";
17
+ import{
18
+ fft,
19
+ ifft
20
+ } from "./fft.js"
21
+ import {
22
+ conv,
23
+ conv1d,
24
+ conv2d,
25
+ circularConv,
26
+ linearConv,
27
+ circularConv1d,
28
+ linearConv1d,
29
+ circularConv2d,
30
+ linearConv2d
31
+ } from "./conv.js";
32
+ import {
33
+ filter
34
+ } from "./filter.js";
35
+ //import { Matrix } from "../Matrix/index.js";
36
+ const Signal={
37
+ zeros,
38
+ ones,
39
+ nums,
40
+ arange,
41
+ linspace,
42
+ logspace,
43
+ geomspace,
44
+ map,
45
+ norm,
46
+ lerp,
47
+ clamp,
48
+ noise(n,min = 0,max = 1){
49
+ return Random.floats(n,min,max);
50
+ },
51
+ echelon(t,t0 = 0 , A = 1){
52
+ if(!(t instanceof Array))t=[t];
53
+ const Y = mapfun(n=>n>=t0?1:0,...t);
54
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A
55
+ },
56
+ rampe(t,t0 = 0 , A = 1){
57
+ if(!(t instanceof Array))t=[t]
58
+ const Y = mapfun(n=>n>=t0?n-t0:0,...t);
59
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A
60
+ },
61
+ sign(t,t0 = 0 , A = 1){
62
+ if(!(t instanceof Array))t=[t]
63
+ const Y = mapfun(n=>Math.sign(n-t0),...t);
64
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A
65
+ },
66
+ rect(t,T,t0 = 0, A = 1){
67
+ if(!(t instanceof Array))t=[t];
68
+ const Y = mapfun(n=>((t0-T/2 < n) && (t0+T/2 > n)? 1 - 2 * abs(n/T) : 0),...t)
69
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A
70
+ },
71
+ tri(t,T,t0 = 0 , A = 1){
72
+ if(!(t instanceof Array))t=[t]
73
+ const Y = mapfun(n=>((t0-T/2 < n) && (t0+T/2 > n)? 1 - 2 * abs(n/T) : 0),...t)
74
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
75
+ },
76
+ dirac(t,t0){
77
+ return mapfun(n=>n===t0?Infinity:0,...t);
78
+ },
79
+ lorentz(t , t0 = 0 , A = 1){
80
+ if(!(t instanceof Array))t=[t]
81
+ const Y = mapfun(n => 1/(1+(n-t0)**2),...t);
82
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
83
+ },
84
+ sinc(t , t0 , A = 1){
85
+ if(!(t instanceof Array))t=[t]
86
+ const Y = mapfun(n=>sinc(n-t0),...t);
87
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
88
+ },
89
+ square(t,T=1,A=1){
90
+ if(!(t instanceof Array))t=[t]
91
+ const Y = mapfun(n=>sign(sin(n*2*Math.PI/T)),...t);
92
+ return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
93
+ },
94
+ sawtooth(){
95
+
96
+ },
97
+ conv,
98
+ conv1d,
99
+ conv2d,
100
+ circularConv,
101
+ linearConv,
102
+ circularConv1d,
103
+ linearConv1d,
104
+ circularConv2d,
105
+ linearConv2d,
106
+ fft,
107
+ ifft,
108
+ filter,
109
+ }
110
+ export{Signal}
@@ -0,0 +1,100 @@
1
+ // Mixed calcul
2
+ const sum=(...x)=>{
3
+ if(x.every(n=>typeof n==="number")){
4
+ let s = x[0];
5
+ for (let i = 1; i < x.length; i++) s += x[i];
6
+ return s;
7
+ }
8
+ const Y=[];
9
+ for(let i=0;i<x.length;i++){
10
+ if(x[i] instanceof Array)Y.push(sum(...x[i]));
11
+ else if(x[i] instanceof Object){
12
+ Y.push(sum(...Object.values(x[i])))
13
+ }
14
+ }
15
+ return Y.length===1?Y[0]:Y;
16
+ }
17
+ const prod=(...x)=>{
18
+ if(x.every(n=>typeof n==="number")){
19
+ let p = x[0];
20
+ for (let i = 1; i < x.length; i++) p *= x[i];
21
+ return p;
22
+ }
23
+ const Y=[];
24
+ for(let i=0;i<x.length;i++){
25
+ if(x[i] instanceof Array)Y.push(prod(...x[i]));
26
+ else if(x[i] instanceof Object){
27
+ Y.push(prod(...Object.values(x[i])))
28
+ }
29
+ }
30
+ return Y.length===1?Y[0]:Y;
31
+ }
32
+ const min=(...num)=>{
33
+ if(num.every(n=>typeof n==="number"))return Math.min(...num);
34
+ const Y=[];
35
+ for(let i=0;i<num.length;i++){
36
+ if(num[i] instanceof Array)Y.push(min(...num[i]));
37
+ else if(num[i] instanceof Object){
38
+ Y.push(
39
+ Object.fromEntries(
40
+ [Object.entries(num[i]).sort((a,b)=>a[1]-b[1])[0]]
41
+ )
42
+ )
43
+ }
44
+ }
45
+ return Y.length===1?Y[0]:Y;
46
+ }
47
+ const max=(...num)=>{
48
+ if(num.every(n=>typeof n==="number"))return Math.max(...num);
49
+ const Y=[];
50
+ for(let i=0;i<num.length;i++){
51
+ if(num[i] instanceof Array)Y.push(min(...num[i]));
52
+ else if(num[i] instanceof Object){
53
+ Y.push(
54
+ Object.fromEntries(
55
+ [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
56
+ )
57
+ )
58
+ }
59
+ }
60
+ return Y.length===1?Y[0]:Y;
61
+ }
62
+ const accum=(...num)=>{
63
+ if(num.every(n=>typeof n==="number")){
64
+ let acc = num.reduce((x, y) => [...x, x[x.length - 1] + y], [0]);
65
+ acc.shift();
66
+ return acc;
67
+ }
68
+ const Y=[];
69
+ for(let i=0;i<num.length;i++){
70
+ if(num[i] instanceof Array)Y.push(accum(...num[i]));
71
+ else if(num[i] instanceof Object){
72
+ Y.push(null
73
+ // Object.fromEntries(
74
+ // [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
75
+ // )
76
+ )
77
+ }
78
+ }
79
+ return Y.length===1?Y[0]:Y;
80
+ }
81
+
82
+ // sort
83
+
84
+ export{
85
+ sum,
86
+ prod,
87
+ min,
88
+ max,
89
+ accum
90
+ }
91
+
92
+ //moy
93
+ //med
94
+ //variance
95
+ //std
96
+ //mode
97
+ //acccum
98
+ //min2max
99
+ //max2min
100
+ //percentile
@@ -0,0 +1,16 @@
1
+ import {
2
+ sum,
3
+ prod,
4
+ min,
5
+ max,
6
+ accum
7
+ } from "./Functions"
8
+ const Stats={
9
+ sum,
10
+ prod,
11
+ min,
12
+ max,
13
+ accum,
14
+ }
15
+ export default Stats;
16
+ export * from "./Functions"
@@ -0,0 +1,139 @@
1
+ import { Complex,complex} from "../Complex";
2
+ import { Matrix } from "../Matrix";
3
+ const _add=(a,b)=>{
4
+ if(typeof(a)==="number"){
5
+ 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);
8
+ else if (b instanceof Array)return b.map(n=>add(n,a));
9
+ }
10
+ else if(a instanceof Complex||a instanceof Matrix){
11
+ if(b instanceof Array)return b.map(n=>a.clone.add(n));
12
+ return a.clone.add(b);
13
+ }
14
+ else if(a instanceof Array){
15
+ if(b instanceof Array){
16
+ if(a.length === b.length)return a.map((n,i)=>add(n,b[i]))
17
+ }
18
+ else {
19
+ return a.map(n=>add(n,b));
20
+ }
21
+ }
22
+ }
23
+ const _sub=(a,b)=>{
24
+ if(typeof(a)==="number"){
25
+ 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);
28
+ else if (b instanceof Array)return b.map(n=>sub(n,a));
29
+ }
30
+ else if(a instanceof Complex||a instanceof Matrix){
31
+ if(b instanceof Array)return b.map(n=>a.clone.sub(n));
32
+ return a.clone.sub(b);
33
+ }
34
+ else if(a instanceof Array){
35
+ if(b instanceof Array){
36
+ if(b instanceof Array){
37
+ if(a.length === b.length)return a.map((n,i)=>sub(n,b[i]))
38
+ }
39
+ }
40
+ else {
41
+ return a.map(n=>sub(n,b));
42
+ }
43
+ }
44
+ }
45
+ const _mul=(a,b)=>{
46
+ if(typeof(a)==="number"){
47
+ 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);
50
+ else if (b instanceof Array)return b.map(n=>mul(a,n));
51
+ }
52
+ else if(a instanceof Complex||a instanceof Matrix){
53
+ if(b instanceof Array)return b.map(n=>a.clone.mul(n));
54
+ return a.clone.mul(b);
55
+ }
56
+ else if(a instanceof Array){
57
+ if(b instanceof Array){
58
+ if(b instanceof Array){
59
+ if(a.length === b.length)return a.map((n,i)=>mul(n,b[i]))
60
+ }
61
+ }
62
+ else {
63
+ return a.map(n=>mul(n,b));
64
+ }
65
+ }
66
+ }
67
+ const _div=(a,b)=>{
68
+ if(typeof(a)==="number"){
69
+ 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);
72
+ else if (b instanceof Array)return b.map(n=>div(a,n));
73
+ }
74
+ else if(a instanceof Complex||a instanceof Matrix){
75
+ if(b instanceof Array)return b.map(n=>a.clone.div(n));
76
+ return a.clone.div(b);
77
+ }
78
+ else if(a instanceof Array){
79
+ if(b instanceof Array){
80
+ if(b instanceof Array){
81
+ if(a.length === b.length)return a.map((n,i)=>div(n,b[i]))
82
+ }
83
+ }
84
+ else {
85
+ return a.map(n=>div(n,b));
86
+ }
87
+ }
88
+ }
89
+ const _modulo=(a,b)=>{
90
+ if(typeof(a)==="number"){
91
+ 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);
94
+ else if (b instanceof Array)return b.map(n=>div(a,n));
95
+ }
96
+ else if(a instanceof Complex||a instanceof Matrix){
97
+ if(b instanceof Array)return b.map(n=>a.clone.div(n));
98
+ return a.clone.div(b);
99
+ }
100
+ else if(a instanceof Array){
101
+ if(b instanceof Array){
102
+ }
103
+ else {
104
+ return a.map(n=>add(n,b));
105
+ }
106
+ }
107
+ }
108
+ const add=(a,...b)=>{
109
+ var res=a;
110
+ for(let i=0;i<b.length;i++)res=_add(res,b[i])
111
+ return res;
112
+ }
113
+ const sub=(a,...b)=>{
114
+ var res=a;
115
+ for(let i=0;i<b.length;i++)res=_sub(res,b[i])
116
+ return res;
117
+ }
118
+ const mul=(a,...b)=>{
119
+ var res=a;
120
+ for(let i=0;i<b.length;i++)res=_mul(res,b[i])
121
+ return res;
122
+ }
123
+ const div=(a,...b)=>{
124
+ var res=a;
125
+ for(let i=0;i<b.length;i++)res=_div(res,b[i])
126
+ return res;
127
+ }
128
+ const modulo=(a,...b)=>{
129
+ var res=a;
130
+ for(let i=0;i<b.length;i++)res=_modulo(res,b[i])
131
+ return res;
132
+ }
133
+ export{
134
+ add,
135
+ sub,
136
+ mul,
137
+ div,
138
+ modulo
139
+ }
@@ -0,0 +1,11 @@
1
+ const inRange=(x,a,b)=>{
2
+ const [min,max]=[Math.min(a,b),Math.max(a,b)]
3
+ return x>=min && x<=max
4
+ }
5
+ const isApproximatlyEqual=(a,b,Err=0.0001)=>{
6
+ return Math.abs(a-b)<=Err;
7
+ }
8
+ export{
9
+ inRange,
10
+ isApproximatlyEqual
11
+ }
@@ -0,0 +1 @@
1
+ // approximatly equal
@@ -0,0 +1,7 @@
1
+ import { mapfun } from "./mapfun.js";
2
+ const deg2rad=(...deg)=>mapfun(x=>x*Math.PI/180,...deg);
3
+ const rad2deg=(...rad)=>mapfun(x=>x/Math.PI*180,...rad);
4
+ export{
5
+ deg2rad,
6
+ rad2deg
7
+ }
@@ -0,0 +1,28 @@
1
+ import { floor } from "../Functions";
2
+ const cartesianProduct=(a, b)=>a.reduce((p, x) => [...p, ...b.map((y) => [x, y])], []);
3
+ const pgcd=(n1, n2)=>{
4
+ let i,
5
+ pgcd = 1;
6
+ if (n1 == floor(n1) && n2 == floor(n2)) {
7
+ for (i = 2; i <= n1 && i <= n2; ++i) {
8
+ if (n1 % i == 0 && n2 % i == 0) pgcd = i;
9
+ }
10
+ return pgcd;
11
+ } else console.log("error");
12
+ }
13
+ const ppcm=(n1, n2)=>{
14
+ let ppcm;
15
+ if (n1 == floor(n1) && n2 == floor(n2)) {
16
+ ppcm = n1 > n2 ? n1 : n2;
17
+ while (true) {
18
+ if (ppcm % n1 == 0 && ppcm % n2 == 0) break;
19
+ ++ppcm;
20
+ }
21
+ return ppcm;
22
+ } else console.log("error");
23
+ }
24
+ export{
25
+ cartesianProduct,
26
+ ppcm,
27
+ pgcd
28
+ }
@@ -0,0 +1,102 @@
1
+ import { mapfun } from "./mapfun.js";
2
+ import {
3
+ add,
4
+ sub,
5
+ mul,
6
+ div,
7
+ modulo
8
+ } from "./arithmetic.js";
9
+ import {
10
+ zeros,
11
+ ones,
12
+ nums,
13
+ norm,
14
+ lerp,
15
+ map,
16
+ clamp,
17
+ arange,
18
+ linspace,
19
+ logspace,
20
+ geomspace
21
+ } from "../Signal/functions.js"
22
+ import {
23
+ deg2rad,
24
+ rad2deg
25
+ } from "./conversions.js"
26
+ import{
27
+ sum,
28
+ prod,
29
+ accum
30
+ } from "../Statistics"
31
+ import{
32
+ inRange,
33
+ isApproximatlyEqual
34
+ } from "./checkers.js"
35
+ import{
36
+ cartesianProduct,
37
+ ppcm,
38
+ pgcd
39
+ } from "./discret.js"
40
+ const Utils={
41
+ add,
42
+ sub,
43
+ mul,
44
+ div,
45
+ modulo,
46
+
47
+ zeros,
48
+ ones,
49
+ nums,
50
+ norm,
51
+ lerp,
52
+ map,
53
+ clamp,
54
+ arange,
55
+ linspace,
56
+ logspace,
57
+ geomspace,
58
+
59
+ sum,
60
+ prod,
61
+ accum,
62
+
63
+ cartesianProduct,
64
+ ppcm,
65
+ pgcd,
66
+
67
+ deg2rad,
68
+ rad2deg,
69
+
70
+ inRange,
71
+ isApproximatlyEqual
72
+ }
73
+ export {
74
+ mapfun,
75
+ Utils,
76
+ zeros,
77
+ ones,
78
+ nums,
79
+ sum,
80
+ prod,
81
+ add,
82
+ mul,
83
+ sub,
84
+ div,
85
+ modulo,
86
+ rad2deg,
87
+ deg2rad,
88
+ arange,
89
+ linspace,
90
+ logspace,
91
+ geomspace,
92
+ norm,
93
+ lerp,
94
+ map,
95
+ clamp,
96
+ pgcd,
97
+ ppcm,
98
+ isApproximatlyEqual,
99
+ inRange,
100
+ cartesianProduct,
101
+ };
102
+
@@ -0,0 +1,43 @@
1
+ import { Matrix } from "../Matrix";
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/index.js";
5
+ const mapfun=(fun,...X)=>{
6
+ const Y=X.map(x=>{
7
+ if(x===null)return fun(null);
8
+ if(["number","string","boolean","bigint","undefined"].includes(typeof x))return fun(x);
9
+ if(x instanceof Array)return x.map(n=>mapfun(fun,n));
10
+ if(ArrayBuffer.isView(x))return x.map(n=>fun(n));
11
+ if(x instanceof Set)return new Set(mapfun(fun,...[...x]));
12
+ if(x instanceof Map)return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
13
+ if(x instanceof Matrix){
14
+ return new Matrix(x.rows,x.cols,mapfun(x.arr.flat(1)))
15
+ }
16
+ if(x instanceof Complex){
17
+ const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
18
+ switch(fun){
19
+ case Math.log:return complex(ln(z),phi); // Done
20
+ case Math.exp:return complex(e(a)*cos(b),e(a)*sin(b)); // Done
21
+ case Math.abs:return z; // Done
22
+ case Math.sqrt:return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
23
+ case Fixed.cos:return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
24
+ case Fixed.sin:return complex(sin(a)*cosh(b),cos(a)*sinh(b));
25
+ case Fixed.tan:{
26
+ const DEN=cos(2*a)+cosh(2*b);
27
+ return complex(sin(2*a)/DEN,sinh(2*b)/DEN);
28
+ }
29
+ case Fixed.cosh:return complex(cosh(a)*cos(b),sinh(a)*sin(b));
30
+ case Fixed.sinh:return complex(sinh(a)*cos(b),cosh(a)*sin(b));
31
+ case Fixed.tanh:{
32
+ const DEN=cosh(2*a)+cos(2*b);
33
+ return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
34
+ }
35
+ //default : return fun(x)
36
+ }
37
+ }
38
+ else if(x instanceof Object)return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
39
+
40
+ });
41
+ return Y.length==1?Y[0]:Y;
42
+ }
43
+ export {mapfun}
@@ -0,0 +1 @@
1
+ export default class AbstractZikoMath {}
@@ -0,0 +1,3 @@
1
+ const { PI, E } = Math;
2
+ const EPSILON=Number.EPSILON
3
+ export{PI,E,EPSILON}