ziko 0.0.11 → 0.0.13
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/README.md +6 -3
- package/dist/ziko.cjs +5640 -4532
- package/dist/ziko.js +5640 -4532
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +5602 -4532
- package/package.json +39 -12
- package/src/__helpers__/index.js +41 -0
- package/src/app/accessibility/index.js +0 -0
- package/src/app/app.js +46 -0
- package/src/app/component/index.js +38 -0
- package/src/app/globals/index.js +20 -0
- package/src/app/index.js +12 -0
- package/src/app/params/index.js +40 -0
- package/src/app/router/index.js +67 -0
- package/src/app/seo/index.js +43 -0
- package/src/app/themes/dark.js +885 -0
- package/src/app/themes/index.js +11 -0
- package/src/app/themes/light.js +255 -0
- package/src/data/api/fetchdom.js +14 -0
- package/src/data/api/index.js +4 -0
- package/src/data/api/preload.js +11 -0
- package/src/data/converter/adoc.js +130 -0
- package/src/data/converter/array.js +43 -0
- package/src/data/converter/canvas.js +25 -0
- package/src/data/converter/csv.js +33 -0
- package/src/data/converter/idea.txt +10 -0
- package/src/data/converter/index.js +34 -0
- package/src/data/converter/json.js +80 -0
- package/src/data/converter/markdown.js +95 -0
- package/src/data/converter/object.js +70 -0
- package/src/data/converter/svg.js +11 -0
- package/src/data/decorators.js +0 -0
- package/src/data/index.js +74 -0
- package/src/data/parser/markdown.js +0 -0
- package/src/data/parser/xml.js +47 -0
- package/src/data/string/index.js +1 -0
- package/src/data/string/patterns.js +12 -0
- package/src/data/string/string.js +170 -0
- package/src/graphics/canvas/_canvas_offscreen +0 -0
- package/src/graphics/canvas/canvas.js +189 -0
- package/src/graphics/canvas/elements/Basic/arc.js +43 -0
- package/src/graphics/canvas/elements/Basic/image.js +0 -0
- package/src/graphics/canvas/elements/Basic/line.js +26 -0
- package/src/graphics/canvas/elements/Basic/path.js +0 -0
- package/src/graphics/canvas/elements/Basic/points.js +48 -0
- package/src/graphics/canvas/elements/Basic/polygon.js +7 -0
- package/src/graphics/canvas/elements/Basic/polyline.js +0 -0
- package/src/graphics/canvas/elements/Basic/rect.js +46 -0
- package/src/graphics/canvas/elements/Basic/text.js +0 -0
- package/src/graphics/canvas/elements/Chart/histogram.js +0 -0
- package/src/graphics/canvas/elements/Chart/plot.js +0 -0
- package/src/graphics/canvas/elements/Chart/scatter.js +2 -0
- package/src/graphics/canvas/elements/Chart/stem.js +0 -0
- package/src/graphics/canvas/elements/Element.js +115 -0
- package/src/graphics/canvas/elements/Groupe.js +0 -0
- package/src/graphics/canvas/elements/grid.js +0 -0
- package/src/graphics/canvas/elements/index.js +13 -0
- package/src/graphics/canvas/filter/index.js +0 -0
- package/src/graphics/canvas/index.js +15 -0
- package/src/graphics/canvas/paint/index.js +0 -0
- package/src/graphics/canvas/utils/color.js +8 -0
- package/src/graphics/canvas/utils/floodFill.js +58 -0
- package/src/graphics/index.js +69 -0
- package/src/graphics/svg/Elements/Basic/circle.js +26 -0
- package/src/graphics/svg/Elements/Basic/ellipse.js +21 -0
- package/src/graphics/svg/Elements/Basic/foreignObject.js +33 -0
- package/src/graphics/svg/Elements/Basic/groupe.js +29 -0
- package/src/graphics/svg/Elements/Basic/image.js +33 -0
- package/src/graphics/svg/Elements/Basic/line.js +29 -0
- package/src/graphics/svg/Elements/Basic/link.js +30 -0
- package/src/graphics/svg/Elements/Basic/path.js +59 -0
- package/src/graphics/svg/Elements/Basic/polygon.js +32 -0
- package/src/graphics/svg/Elements/Basic/polyline.js +4 -0
- package/src/graphics/svg/Elements/Basic/rect.js +43 -0
- package/src/graphics/svg/Elements/Basic/text.js +26 -0
- package/src/graphics/svg/Elements/Derived/grid.js +9 -0
- package/src/graphics/svg/Elements/ZikoSvgElement.js +46 -0
- package/src/graphics/svg/Elements/index.js +14 -0
- package/src/graphics/svg/index.js +2 -0
- package/src/graphics/svg/svg.js +115 -0
- package/src/index.js +88 -0
- package/src/math/absract.js +1 -0
- package/src/math/calculus/index.js +1 -0
- package/src/math/calculus/special-functions/bessel.js +31 -0
- package/src/math/calculus/special-functions/beta.js +38 -0
- package/src/math/calculus/special-functions/gamma.js +30 -0
- package/src/math/calculus/special-functions/index.js +4 -0
- package/src/math/complex/Fractals/julia.js +0 -0
- package/src/math/complex/index.js +203 -0
- package/src/math/const.js +3 -0
- package/src/math/discret/Combinaison/index.js +34 -0
- package/src/math/discret/Conversion/index.js +86 -0
- package/src/math/discret/Logic/index.js +46 -0
- package/src/math/discret/Permutation/index.js +31 -0
- package/src/math/discret/Set/index.js +2 -0
- package/src/math/discret/Set/power-set.js +15 -0
- package/src/math/discret/Set/sub-set.js +10 -0
- package/src/math/discret/index.js +23 -0
- package/src/math/functions/index.js +182 -0
- package/src/math/index.js +189 -0
- package/src/math/matrix/Decomposition.js +90 -0
- package/src/math/matrix/LinearSystem.js +10 -0
- package/src/math/matrix/Matrix.js +717 -0
- package/src/math/matrix/index.js +3 -0
- package/src/math/numeric/index.js +0 -0
- package/src/math/random/index.js +173 -0
- package/src/math/signal/__np.py.txt +40 -0
- package/src/math/signal/conv.js +175 -0
- package/src/math/signal/fft.js +55 -0
- package/src/math/signal/filter.js +39 -0
- package/src/math/signal/functions.js +146 -0
- package/src/math/signal/index.js +110 -0
- package/src/math/statistics/Functions/index.js +100 -0
- package/src/math/statistics/index.js +16 -0
- package/src/math/utils/arithmetic.js +139 -0
- package/src/math/utils/checkers.js +29 -0
- package/src/math/utils/comparaison.js +1 -0
- package/src/math/utils/conversions.js +19 -0
- package/src/math/utils/discret.js +51 -0
- package/src/math/utils/index.js +102 -0
- package/src/math/utils/mapfun.js +50 -0
- package/src/reactivity/events/Global/Click.js +56 -0
- package/src/reactivity/events/Global/Clipboard.js +84 -0
- package/src/reactivity/events/Global/CustomEvent.js +53 -0
- package/src/reactivity/events/Global/Drag.js +137 -0
- package/src/reactivity/events/Global/Focus.js +56 -0
- package/src/reactivity/events/Global/Key.js +104 -0
- package/src/reactivity/events/Global/Mouse.js +230 -0
- package/src/reactivity/events/Global/Pointer.js +234 -0
- package/src/reactivity/events/Global/Swipe.js +147 -0
- package/src/reactivity/events/Global/Touch.js +0 -0
- package/src/reactivity/events/Global/Wheel.js +44 -0
- package/src/reactivity/events/Partiel/Hash.js +44 -0
- package/src/reactivity/events/Partiel/Input.js +59 -0
- package/src/reactivity/events/Partiel/Media.js +1 -0
- package/src/reactivity/events/ZikoEvent.js +91 -0
- package/src/reactivity/events/index.js +63 -0
- package/src/reactivity/hooks/Contexte/index.js +1 -0
- package/src/reactivity/hooks/Contexte/useSuccesifKeys.js +14 -0
- package/src/reactivity/hooks/Decorators/index.js +6 -0
- package/src/reactivity/hooks/Decorators/time.js +17 -0
- package/src/reactivity/hooks/Decorators/type.js +88 -0
- package/src/reactivity/hooks/Interactions/index.js +4 -0
- package/src/reactivity/hooks/Interactions/useBluetooth.js +48 -0
- package/src/reactivity/hooks/Interactions/useChannel.js +50 -0
- package/src/reactivity/hooks/Interactions/useEventEmmiter.js +64 -0
- package/src/reactivity/hooks/Interactions/useSerial.js +0 -0
- package/src/reactivity/hooks/Interactions/useThread.js +44 -0
- package/src/reactivity/hooks/Interactions/useUsb.js +0 -0
- package/src/reactivity/hooks/Sensors/index.js +2 -0
- package/src/reactivity/hooks/Sensors/useBattery.js +36 -0
- package/src/reactivity/hooks/Sensors/useCamera.js +0 -0
- package/src/reactivity/hooks/Sensors/useGeolocation.js +17 -0
- package/src/reactivity/hooks/Sensors/useMicro.js +0 -0
- package/src/reactivity/hooks/Sensors/useOrientation.js +0 -0
- package/src/reactivity/hooks/Storage/index.js +1 -0
- package/src/reactivity/hooks/Storage/useCookie.js +0 -0
- package/src/reactivity/hooks/Storage/useIndexedDb.js +0 -0
- package/src/reactivity/hooks/Storage/useStorage.js +73 -0
- package/src/reactivity/hooks/UI/index.js +5 -0
- package/src/reactivity/hooks/UI/useCssLink.js +0 -0
- package/src/reactivity/hooks/UI/useCssText.js +21 -0
- package/src/reactivity/hooks/UI/useFavIcon.js +38 -0
- package/src/reactivity/hooks/UI/useLinearGradient.js +0 -0
- package/src/reactivity/hooks/UI/useMediaQuery.js +43 -0
- package/src/reactivity/hooks/UI/useRadialGradient.js +0 -0
- package/src/reactivity/hooks/UI/useStyle.js +79 -0
- package/src/reactivity/hooks/UI/useTheme.js +62 -0
- package/src/reactivity/hooks/UI/useTitle.js +30 -0
- package/src/reactivity/hooks/index.js +85 -0
- package/src/reactivity/hooks/todo.md +26 -0
- package/src/reactivity/idea +2 -0
- package/src/reactivity/index.js +22 -0
- package/src/reactivity/observer/attributes.js +28 -0
- package/src/reactivity/observer/children.js +37 -0
- package/src/reactivity/observer/index.js +44 -0
- package/src/reactivity/observer/intersection.js +44 -0
- package/src/reactivity/observer/mutation.js +113 -0
- package/src/reactivity/observer/resize.js +47 -0
- package/src/reactivity/observer/screen.js +45 -0
- package/src/reactivity/observer/screen.js.txt +84 -0
- package/src/reactivity/observer/screen.txt +13 -0
- package/src/time/animation.js +76 -0
- package/src/time/index.js +54 -0
- package/src/time/loop.js +87 -0
- package/src/time/utils/decorators.js +17 -0
- package/src/time/utils/ease.js +144 -0
- package/src/time/utils/index.js +18 -0
- package/src/time/utils/performance.js +16 -0
- package/src/time/utils/ui.js +26 -0
- package/src/user-interface/elements/derived/Flex.js +103 -0
- package/src/user-interface/elements/derived/Grid.js +33 -0
- package/src/user-interface/elements/derived/elements/Notification.js +0 -0
- package/src/user-interface/elements/derived/elements/Popover.js +0 -0
- package/src/user-interface/elements/derived/elements/Popup.js +0 -0
- package/src/user-interface/elements/derived/elements/Swipper.js +4 -0
- package/src/user-interface/elements/derived/elements/Timeline.js +0 -0
- package/src/user-interface/elements/derived/elements/Toast.js +0 -0
- package/src/user-interface/elements/derived/elements/Treeview.js +0 -0
- package/src/user-interface/elements/derived/elements/accordion/accordion.js +45 -0
- package/src/user-interface/elements/derived/elements/accordion/collapsible.js +82 -0
- package/src/user-interface/elements/derived/elements/accordion/index.js +2 -0
- package/src/user-interface/elements/derived/elements/alert/alert.js +80 -0
- package/src/user-interface/elements/derived/elements/alert/index.js +1 -0
- package/src/user-interface/elements/derived/elements/alert/palette.js +52 -0
- package/src/user-interface/elements/derived/elements/carousel/index.js +50 -0
- package/src/user-interface/elements/derived/elements/code-note/SubElements.js.txt +105 -0
- package/src/user-interface/elements/derived/elements/code-note/code-cell.js +195 -0
- package/src/user-interface/elements/derived/elements/code-note/code-note.js +72 -0
- package/src/user-interface/elements/derived/elements/code-note/index.js +2 -0
- package/src/user-interface/elements/derived/elements/code-note/sub-elements.js +67 -0
- package/src/user-interface/elements/derived/elements/columns.js +1 -0
- package/src/user-interface/elements/derived/elements/fab.js +0 -0
- package/src/user-interface/elements/derived/elements/index.js +9 -0
- package/src/user-interface/elements/derived/elements/menu/index.js +1 -0
- package/src/user-interface/elements/derived/elements/menu/menu3d.js +260 -0
- package/src/user-interface/elements/derived/elements/modal/index.js +92 -0
- package/src/user-interface/elements/derived/elements/pagination/breadcrumbs.js +54 -0
- package/src/user-interface/elements/derived/elements/pagination/index.js +1 -0
- package/src/user-interface/elements/derived/elements/splitter/__ZikoUISplitter__.js +62 -0
- package/src/user-interface/elements/derived/elements/splitter/hsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/splitter/index.js +2 -0
- package/src/user-interface/elements/derived/elements/splitter/vsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/tabs/index.js +180 -0
- package/src/user-interface/elements/derived/index.js +3 -0
- package/src/user-interface/elements/primitives/ZikoUIContainerElement.js +127 -0
- package/src/user-interface/elements/primitives/ZikoUIElement.js +478 -0
- package/src/user-interface/elements/primitives/embaded/index.js +1 -0
- package/src/user-interface/elements/primitives/index.js +8 -0
- package/src/user-interface/elements/primitives/io/Form/index.js +42 -0
- package/src/user-interface/elements/primitives/io/Form/index.js.txt +104 -0
- package/src/user-interface/elements/primitives/io/Inputs/__helpers__.js +52 -0
- package/src/user-interface/elements/primitives/io/Inputs/index.js +12 -0
- package/src/user-interface/elements/primitives/io/Inputs/input/index.js +98 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-camera/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-checkbox/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-color/index.js +16 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/index.js +3 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/index.js +2 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-email.js +15 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-password.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/index.js +1 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-file.js +0 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-image.js +43 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-number/index.js +37 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-radio/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-search/index.js +45 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-slider/index.js +34 -0
- package/src/user-interface/elements/primitives/io/Select/index.js +20 -0
- package/src/user-interface/elements/primitives/io/Textarea/index.js +18 -0
- package/src/user-interface/elements/primitives/io/index.js +4 -0
- package/src/user-interface/elements/primitives/list/elements.js +0 -0
- package/src/user-interface/elements/primitives/list/index.js +139 -0
- package/src/user-interface/elements/primitives/media/Audio/index.js +17 -0
- package/src/user-interface/elements/primitives/media/Image/figure.js +19 -0
- package/src/user-interface/elements/primitives/media/Image/image.js +36 -0
- package/src/user-interface/elements/primitives/media/Image/index.js +2 -0
- package/src/user-interface/elements/primitives/media/Video/index.js +27 -0
- package/src/user-interface/elements/primitives/media/__ZikoUIDynamicMediaELement__.js +47 -0
- package/src/user-interface/elements/primitives/media/index.js +3 -0
- package/src/user-interface/elements/primitives/misc/index.js +99 -0
- package/src/user-interface/elements/primitives/semantic/index.js +82 -0
- package/src/user-interface/elements/primitives/table/elements.js +94 -0
- package/src/user-interface/elements/primitives/table/index.js +3 -0
- package/src/user-interface/elements/primitives/table/table.js +115 -0
- package/src/user-interface/elements/primitives/table/utils.js +12 -0
- package/src/user-interface/elements/primitives/text/__ZikoUIText__.js +71 -0
- package/src/user-interface/elements/primitives/text/heading.js +36 -0
- package/src/user-interface/elements/primitives/text/index.js +3 -0
- package/src/user-interface/elements/primitives/text/p.js +26 -0
- package/src/user-interface/elements/primitives/text/pre.js +0 -0
- package/src/user-interface/elements/primitives/text/text.js +81 -0
- package/src/user-interface/index.js +188 -0
- package/src/user-interface/style/index.js +510 -0
- package/src/user-interface/utils/index.js +70 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import ZikoMath from "../absract.js";
|
|
2
|
+
import{
|
|
3
|
+
cos,
|
|
4
|
+
sin,
|
|
5
|
+
tan,
|
|
6
|
+
pow,
|
|
7
|
+
floor,
|
|
8
|
+
hypot,
|
|
9
|
+
cosh,
|
|
10
|
+
sinh,
|
|
11
|
+
sqrtn,
|
|
12
|
+
atan2,
|
|
13
|
+
sqrt,
|
|
14
|
+
ln
|
|
15
|
+
}from "../functions/index.js"
|
|
16
|
+
import { Matrix } from "../matrix/index.js";
|
|
17
|
+
import {sum,prod,deg2rad} from "../utils/index.js";
|
|
18
|
+
class Complex extends ZikoMath{
|
|
19
|
+
constructor(a = 0, b = 0) {
|
|
20
|
+
super()
|
|
21
|
+
if(a instanceof Complex){
|
|
22
|
+
this.a=a.a;
|
|
23
|
+
this.b=a.b;
|
|
24
|
+
}
|
|
25
|
+
else if(typeof(a)==="object"){
|
|
26
|
+
if(("a" in b && "b" in a)){
|
|
27
|
+
this.a=a.a;
|
|
28
|
+
this.b=a.b;
|
|
29
|
+
}
|
|
30
|
+
else if(("a" in b && "z" in a)){
|
|
31
|
+
this.a=a.a;
|
|
32
|
+
this.b=sqrt((a.z**2)-(a.a**2));
|
|
33
|
+
}
|
|
34
|
+
else if(("a" in b && "phi" in a)){
|
|
35
|
+
this.a=a.a;
|
|
36
|
+
this.b=a.a*tan(a.phi);
|
|
37
|
+
}
|
|
38
|
+
else if(("b" in b && "z" in a)){
|
|
39
|
+
this.b=a.b;
|
|
40
|
+
this.a=sqrt((a.z**2)-(a.b**2));
|
|
41
|
+
}
|
|
42
|
+
else if(("b" in b && "phi" in a)){
|
|
43
|
+
this.b=b;
|
|
44
|
+
this.a=a.b/tan(a.phi);
|
|
45
|
+
}
|
|
46
|
+
else if(("z" in b && "phi" in a)){
|
|
47
|
+
this.a=a.z*cos(a.phi);
|
|
48
|
+
this.a=a.z*sin(a.phi);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if(typeof(a)==="number"&&typeof(b)==="number"){
|
|
52
|
+
this.a = +a.toFixed(32);
|
|
53
|
+
this.b = +b.toFixed(32);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
toString(){
|
|
57
|
+
let str = "";
|
|
58
|
+
if (this.a !== 0)
|
|
59
|
+
this.b >= 0
|
|
60
|
+
? (str = `${this.a}+${this.b}*i`)
|
|
61
|
+
: (str = `${this.a}-${Math.abs(this.b)}*i`);
|
|
62
|
+
else
|
|
63
|
+
this.b >= 0
|
|
64
|
+
? (str = `${this.b}*i`)
|
|
65
|
+
: (str = `-${Math.abs(this.b)}*i`);
|
|
66
|
+
return str;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get clone() {
|
|
70
|
+
return new Complex(this.a, this.b);
|
|
71
|
+
}
|
|
72
|
+
get z(){
|
|
73
|
+
return hypot(this.a,this.b);
|
|
74
|
+
}
|
|
75
|
+
get phi(){
|
|
76
|
+
return atan2(this.b , this.a);
|
|
77
|
+
}
|
|
78
|
+
static Zero() {
|
|
79
|
+
return new Complex(0, 0);
|
|
80
|
+
}
|
|
81
|
+
get conj() {
|
|
82
|
+
return new Complex(this.a, -this.b);
|
|
83
|
+
}
|
|
84
|
+
get inv() {
|
|
85
|
+
return new Complex(this.a / (pow(this.a, 2) + pow(this.b, 2)), -this.b / (pow(this.a, 2) + pow(this.b, 2)));
|
|
86
|
+
}
|
|
87
|
+
add(...z) {
|
|
88
|
+
for (let i = 0; i < z.length; i++) {
|
|
89
|
+
if (typeof z[i] === "number") z[i] = new Complex(z[i], 0);
|
|
90
|
+
}
|
|
91
|
+
let re = z.map((n) => n.a);
|
|
92
|
+
let im = z.map((n) => n.b);
|
|
93
|
+
this.a+=+sum(...re).toFixed(15);
|
|
94
|
+
this.b+=+sum(...im).toFixed(15);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
sub(...z) {
|
|
98
|
+
for (let i = 0; i < z.length; i++) {
|
|
99
|
+
if (typeof z[i] === "number") z[i] = new Complex(z[i], 0);
|
|
100
|
+
}
|
|
101
|
+
let re = z.map((n) => n.a);
|
|
102
|
+
let im = z.map((n) => n.b);
|
|
103
|
+
this.a-=+sum(...re).toFixed(15);
|
|
104
|
+
this.b-=+sum(...im).toFixed(15);
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
mul(...z){
|
|
108
|
+
for (let i = 0; i < z.length; i++) {
|
|
109
|
+
if (typeof z[i] === "number") z[i] = new Complex(z[i], 0);
|
|
110
|
+
}
|
|
111
|
+
let Z=+prod(this.z,...z.map(n=>n.z)).toFixed(15);
|
|
112
|
+
let phi=+sum(this.phi,...z.map(n=>n.phi)).toFixed(15);
|
|
113
|
+
this.a=+(Z*cos(phi).toFixed(15)).toFixed(14);
|
|
114
|
+
this.b=+(Z*sin(phi).toFixed(15)).toFixed(14);
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
div(...z) {
|
|
118
|
+
for (let i = 0; i < z.length; i++) {
|
|
119
|
+
if (typeof z[i] === "number") z[i] = new Complex(z[i], 0);
|
|
120
|
+
}
|
|
121
|
+
let Z=+(this.z/prod(...z.map(n=>n.z))).toFixed(15);
|
|
122
|
+
let phi=+(this.phi-sum(...z.map(n=>n.phi))).toFixed(15);
|
|
123
|
+
this.a=+(Z*cos(phi).toFixed(15)).toFixed(15);
|
|
124
|
+
this.b=+(Z*sin(phi).toFixed(15)).toFixed(15);
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
pow(n) {
|
|
128
|
+
if (floor(n) === n && n > 0) {
|
|
129
|
+
let z=+(this.z**n).toFixed(15);
|
|
130
|
+
let phi=+(this.phi*n).toFixed(15);
|
|
131
|
+
this.a=+(z*cos(phi).toFixed(15)).toFixed(15);
|
|
132
|
+
this.b=+(z*sin(phi).toFixed(15)).toFixed(15);
|
|
133
|
+
}
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
static fromExpo(z, phi) {
|
|
137
|
+
return new Complex(
|
|
138
|
+
+(z * cos(phi)).toFixed(13),
|
|
139
|
+
+(z * sin(phi)).toFixed(13)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
get expo() {
|
|
143
|
+
return [this.z, this.phi];
|
|
144
|
+
}
|
|
145
|
+
static add(c,...z) {
|
|
146
|
+
return c.clone.add(...z);
|
|
147
|
+
}
|
|
148
|
+
static sub(c,...z) {
|
|
149
|
+
return c.clone.sub(...z);
|
|
150
|
+
}
|
|
151
|
+
static mul(c,...z) {
|
|
152
|
+
return c.clone.mul(...z);
|
|
153
|
+
}
|
|
154
|
+
static div(c,...z) {
|
|
155
|
+
return c.clone.div(...z);
|
|
156
|
+
}
|
|
157
|
+
static pow(z,n){
|
|
158
|
+
return z.clone.pow(n);
|
|
159
|
+
}
|
|
160
|
+
static xpowZ(x){
|
|
161
|
+
return complex((x**this.a)*cos(this.b*ln(x)),(x**this.a)*sin(this.b*ln(x)));
|
|
162
|
+
}
|
|
163
|
+
sqrtn(n=2){
|
|
164
|
+
return complex(sqrtn(this.z,n)*cos(this.phi/n),sqrtn(this.z,n)*sin(this.phi/n));
|
|
165
|
+
}
|
|
166
|
+
get sqrt(){
|
|
167
|
+
return this.sqrtn(2);
|
|
168
|
+
}
|
|
169
|
+
get log(){
|
|
170
|
+
return complex(this.z,this.phi);
|
|
171
|
+
}
|
|
172
|
+
get cos(){
|
|
173
|
+
return complex(cos(this.a)*cosh(this.b),sin(this.a)*sinh(this.b))
|
|
174
|
+
}
|
|
175
|
+
get sin(){
|
|
176
|
+
return complex(sin(this.a)*cosh(this.b),cos(this.a)*sinh(this.b))
|
|
177
|
+
}
|
|
178
|
+
get tan(){
|
|
179
|
+
const de=cos(this.a*2)+cosh(this.b*2);
|
|
180
|
+
return complex(sin(2*this.a)/de,sinh(2*this.b)/de);
|
|
181
|
+
}
|
|
182
|
+
printInConsole() {
|
|
183
|
+
let string = this.a + " + " + this.b + " * i";
|
|
184
|
+
console.log(string);
|
|
185
|
+
return string;
|
|
186
|
+
}
|
|
187
|
+
print() {
|
|
188
|
+
//return text(this.a + " + i * " + this.b);
|
|
189
|
+
}
|
|
190
|
+
UI() {
|
|
191
|
+
return "<span>" + this.a + " + i * " + this.b + "</span>";
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const complex=(a,b)=>{
|
|
195
|
+
if((a instanceof Array||ArrayBuffer.isView(a)) && (b instanceof Array||ArrayBuffer.isView(a)))return a.map((n,i)=>complex(a[i],b[i]));
|
|
196
|
+
if(a instanceof Matrix && b instanceof Matrix){
|
|
197
|
+
if((a.shape[0]!==b.shape[0])||(a.shape[1]!==b.shape[1]))return Error(0)
|
|
198
|
+
const arr=a.arr.map((n,i)=>complex(a.arr[i],b.arr[i]))
|
|
199
|
+
return new Matrix(a.rows,a.cols,...arr)
|
|
200
|
+
}
|
|
201
|
+
return new Complex(a,b)
|
|
202
|
+
}
|
|
203
|
+
export{complex,Complex}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
class Combinaison {
|
|
2
|
+
static withDiscount(comboOptions, comboLength) {
|
|
3
|
+
if (comboLength === 1) {
|
|
4
|
+
return comboOptions.map((comboOption) => [comboOption]);
|
|
5
|
+
}
|
|
6
|
+
const combos = [];
|
|
7
|
+
comboOptions.forEach((currentOption, optionIndex) => {
|
|
8
|
+
const smallerCombos = this.withDiscount(comboOptions.slice(optionIndex), comboLength - 1);
|
|
9
|
+
smallerCombos.forEach((smallerCombo) => {
|
|
10
|
+
combos.push([currentOption].concat(smallerCombo));
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
return combos;
|
|
14
|
+
}
|
|
15
|
+
static withoutDiscount(comboOptions, comboLength) {
|
|
16
|
+
if (comboLength === 1) {
|
|
17
|
+
return comboOptions.map((comboOption) => [comboOption]);
|
|
18
|
+
}
|
|
19
|
+
const combos = [];
|
|
20
|
+
comboOptions.forEach((currentOption, optionIndex) => {
|
|
21
|
+
const smallerCombos = this.withoutDiscount(comboOptions.slice(optionIndex + 1), comboLength - 1);
|
|
22
|
+
smallerCombos.forEach((smallerCombo) => {
|
|
23
|
+
combos.push([currentOption].concat(smallerCombo));
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return combos;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const combinaison=(comboOptions, comboLength, discount=false)=>Combinaison[discount?"withDiscount":"withoutDiscount"](comboOptions, comboLength)
|
|
31
|
+
export{
|
|
32
|
+
Combinaison,
|
|
33
|
+
combinaison
|
|
34
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Complex } from "../../complex/index.js";
|
|
2
|
+
import { Matrix } from "../../matrix/Matrix.js";
|
|
3
|
+
const Base={
|
|
4
|
+
_mode:Number,
|
|
5
|
+
_map:function(func,number,toBase){
|
|
6
|
+
if (number instanceof Matrix)
|
|
7
|
+
return new Matrix(
|
|
8
|
+
number.rows,
|
|
9
|
+
number.cols,
|
|
10
|
+
number.arr.flat(1).map(n=>func(n,toBase))
|
|
11
|
+
);
|
|
12
|
+
else if (number instanceof Complex) return new Complex(func(number.a,toBase),func(number.b,toBase));
|
|
13
|
+
else if (number instanceof Array) return number.map((n) =>func(n,toBase));
|
|
14
|
+
},
|
|
15
|
+
dec2base(dec,base){
|
|
16
|
+
base<=10?this._mode=Number:this._mode=String
|
|
17
|
+
//this._mode=String
|
|
18
|
+
if (typeof dec === "number") return this._mode((dec >>> 0).toString(base));
|
|
19
|
+
return this._map(this.dec2base,dec,base)
|
|
20
|
+
},
|
|
21
|
+
dec2bin(dec){
|
|
22
|
+
return this.dec2base(dec,2);
|
|
23
|
+
},
|
|
24
|
+
dec2oct(dec){
|
|
25
|
+
return this.dec2base(dec,8);
|
|
26
|
+
},
|
|
27
|
+
dec2hex(dec){
|
|
28
|
+
return this.dec2base(dec,16);
|
|
29
|
+
},
|
|
30
|
+
bin2base(bin, base) {
|
|
31
|
+
return this.dec2base(this.bin2dec(bin),base)
|
|
32
|
+
},
|
|
33
|
+
bin2dec(bin){
|
|
34
|
+
return this._mode("0b"+bin);
|
|
35
|
+
},
|
|
36
|
+
bin2oct(bin){
|
|
37
|
+
return this.bin2base(bin,8);
|
|
38
|
+
},
|
|
39
|
+
bin2hex(bin){
|
|
40
|
+
return this.bin2base(bin,16);
|
|
41
|
+
},
|
|
42
|
+
oct2dec(oct){
|
|
43
|
+
return this._mode("0o"+oct);
|
|
44
|
+
},
|
|
45
|
+
oct2bin(oct){
|
|
46
|
+
return this.dec2bin(this.oct2dec(oct))
|
|
47
|
+
},
|
|
48
|
+
oct2hex(oct){
|
|
49
|
+
return this.dec2hex(this.oct2dec(oct))
|
|
50
|
+
},
|
|
51
|
+
oct2base(oct, base) {
|
|
52
|
+
return this.dec2base(this.oct2dec(oct),base)
|
|
53
|
+
},
|
|
54
|
+
hex2dec(hex){
|
|
55
|
+
return this._mode("0x"+hex);
|
|
56
|
+
},
|
|
57
|
+
hex2bin(hex){
|
|
58
|
+
return this.dec2bin(this.hex2dec(hex))
|
|
59
|
+
},
|
|
60
|
+
hex2oct(hex){
|
|
61
|
+
return this.dec2oct(this.hex2dec(hex))
|
|
62
|
+
},
|
|
63
|
+
hex2base(hex, base) {
|
|
64
|
+
return this.dec2base(this.hex2dec(hex),base)
|
|
65
|
+
},
|
|
66
|
+
IEEE32toDec(Bin){
|
|
67
|
+
let IEEE32=Bin.split(" ").join("").padEnd(32,"0");
|
|
68
|
+
let s=IEEE32[0];
|
|
69
|
+
let e=2**(+("0b"+IEEE32.slice(1,9))-127)
|
|
70
|
+
let m=IEEE32.slice(9,32).split("").map(n=>+n)
|
|
71
|
+
let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
|
|
72
|
+
let dec=(-1)**s*(1+M)*e;
|
|
73
|
+
return dec
|
|
74
|
+
},
|
|
75
|
+
IEEE64toDec(Bin){
|
|
76
|
+
let IEEE64=Bin.split(" ").join("").padEnd(64,"0");
|
|
77
|
+
let s=IEEE64[0];
|
|
78
|
+
let e=2**(+("0b"+IEEE64.slice(1,12))-1023)
|
|
79
|
+
let m=IEEE64.slice(13,64).split("").map(n=>+n)
|
|
80
|
+
let M=m.map((n,i)=>n*(2**(-i-1))).reduce((a,b)=>a+b,0);
|
|
81
|
+
let dec=(-1)**s*(1+M)*e;
|
|
82
|
+
return dec;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export{Base}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Complex } from "../../complex/index.js";
|
|
2
|
+
import { Matrix } from "../../matrix/Matrix.js";
|
|
3
|
+
const Logic={
|
|
4
|
+
_mode:Number,
|
|
5
|
+
_map:function(func,a,b){
|
|
6
|
+
if (a instanceof Matrix)
|
|
7
|
+
return new Matrix(
|
|
8
|
+
a.rows,
|
|
9
|
+
a.cols,
|
|
10
|
+
a.arr.flat(1).map((n) => func(n, b))
|
|
11
|
+
);
|
|
12
|
+
else if (a instanceof Complex) return new Complex(func(a.a, b), func(a.b, b));
|
|
13
|
+
else if (a instanceof Array) return a.map((n) => func(n, b));
|
|
14
|
+
},
|
|
15
|
+
not:function(input){
|
|
16
|
+
if(["number","boolean"].includes(typeof input)) return Logic._mode(!input);
|
|
17
|
+
else return this._map(this.not,input)
|
|
18
|
+
},
|
|
19
|
+
and:function(a, ...b){
|
|
20
|
+
if(["number","boolean"].includes(typeof a))return Logic._mode(b.reduce((n, m) => (n &= m), a));
|
|
21
|
+
else return this._map(this.and,a,b)
|
|
22
|
+
},
|
|
23
|
+
or:function(a, ...b) {
|
|
24
|
+
if(["number","boolean"].includes(typeof a)) return Logic._mode(b.reduce((n, m) => (n |= m), a));
|
|
25
|
+
else return this._map(this.or,a,b);
|
|
26
|
+
},
|
|
27
|
+
nand:function(a, ...b) {
|
|
28
|
+
return this.not(this.and(a, b));
|
|
29
|
+
},
|
|
30
|
+
nor:function(a, ...b) {
|
|
31
|
+
return this.not(this.or(a, b));
|
|
32
|
+
},
|
|
33
|
+
xor:function(a,...b){
|
|
34
|
+
let arr=[a,...b]
|
|
35
|
+
if(["number","boolean"].includes(typeof a))return this._mode(arr.reduce((length,cur)=>{
|
|
36
|
+
if(+cur===1)length+=1;
|
|
37
|
+
return length;
|
|
38
|
+
},0)===1);
|
|
39
|
+
else return this._map(this.xor,a,b);
|
|
40
|
+
},
|
|
41
|
+
xnor:function(a,...b){
|
|
42
|
+
return Logic.not(Logic.xor(a,b))
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
export{Logic}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class Permutation {
|
|
2
|
+
static withDiscount(arr, l = arr.length) {
|
|
3
|
+
if (l === 1) return arr.map((n) => [n]);
|
|
4
|
+
const permutations = [];
|
|
5
|
+
let smallerPermutations;
|
|
6
|
+
smallerPermutations = this.withDiscount(arr, l - 1);
|
|
7
|
+
arr.forEach((currentOption) => {
|
|
8
|
+
smallerPermutations.forEach((smallerPermutation) => {
|
|
9
|
+
permutations.push([currentOption].concat(smallerPermutation));
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
return permutations;
|
|
13
|
+
}
|
|
14
|
+
static withoutDiscount(arr) {
|
|
15
|
+
const l = arr.length;
|
|
16
|
+
if (l === 1) return arr.map((n) => [n]);
|
|
17
|
+
const permutations = [];
|
|
18
|
+
const smallerPermutations = this.withoutDiscount(arr.slice(1));
|
|
19
|
+
const firstOption = arr[0];
|
|
20
|
+
for (let i = 0; i < smallerPermutations.length; i++) {
|
|
21
|
+
const smallerPermutation = smallerPermutations[i];
|
|
22
|
+
for (let j = 0; j <= smallerPermutation.length; j++) {
|
|
23
|
+
const permutationPrefix = smallerPermutation.slice(0, j);
|
|
24
|
+
const permutationSuffix = smallerPermutation.slice(j);
|
|
25
|
+
permutations.push(permutationPrefix.concat([firstOption], permutationSuffix));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return permutations;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export { Permutation }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const powerSet=originalSet=>{
|
|
2
|
+
const subSets = [];
|
|
3
|
+
const NUMBER_OF_COMBINATIONS = 2 ** originalSet.length;
|
|
4
|
+
for (let i = 0; i < NUMBER_OF_COMBINATIONS; i += 1) {
|
|
5
|
+
const subSet = [];
|
|
6
|
+
for (let j = 0; j < originalSet.length; j += 1) {
|
|
7
|
+
if (i & (1 << j)) {
|
|
8
|
+
subSet.push(originalSet[j]);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
subSets.push(subSet);
|
|
12
|
+
}
|
|
13
|
+
return subSets;
|
|
14
|
+
}
|
|
15
|
+
export{powerSet}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { arange } from "../../utils/index.js";
|
|
2
|
+
|
|
3
|
+
// const subSet = (...arr) => {
|
|
4
|
+
// let list = arange(0, 2 ** arr.length, 1);
|
|
5
|
+
// let bin = list.map((n) => n.toString(2).padStart(arr.length, '0')).map((n) => n.split("").map((n) => +n));
|
|
6
|
+
// let sub = bin.map((n) => n.map((m, i) => (m === 1 ? arr[i] : null))).map((n) => n.filter((x) => x !== null));
|
|
7
|
+
// return sub;
|
|
8
|
+
// };
|
|
9
|
+
const subSet = null
|
|
10
|
+
export { subSet };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { powerSet , subSet } from "./Set/index.js";
|
|
2
|
+
import { Base } from "./Conversion/index.js";
|
|
3
|
+
import { Logic } from "./Logic/index.js";
|
|
4
|
+
import {
|
|
5
|
+
Permutation,
|
|
6
|
+
} from "./Permutation/index.js"
|
|
7
|
+
import {
|
|
8
|
+
Combinaison,
|
|
9
|
+
combinaison,
|
|
10
|
+
} from "./Combinaison/index.js"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const Discret={
|
|
14
|
+
Logic,
|
|
15
|
+
Base,
|
|
16
|
+
Permutation,
|
|
17
|
+
Combinaison,
|
|
18
|
+
combinaison,
|
|
19
|
+
powerSet,
|
|
20
|
+
subSet
|
|
21
|
+
}
|
|
22
|
+
export default Discret;
|
|
23
|
+
export{Logic,Base,Permutation,Combinaison,powerSet,subSet}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Complex } from "../complex/index.js";
|
|
2
|
+
import { mapfun } from "../utils/mapfun.js";
|
|
3
|
+
import {
|
|
4
|
+
min,
|
|
5
|
+
max
|
|
6
|
+
}from "../statistics/index.js";
|
|
7
|
+
import {
|
|
8
|
+
gamma,
|
|
9
|
+
bessel,
|
|
10
|
+
beta
|
|
11
|
+
} from "../calculus/index.js";
|
|
12
|
+
export const Fixed={
|
|
13
|
+
cos:x=>+Math.cos(x).toFixed(15),
|
|
14
|
+
sin:x=>+Math.sin(x).toFixed(15),
|
|
15
|
+
tan:x=>+Math.tan(x).toFixed(31),
|
|
16
|
+
sinc:x=>+Math.sin(Math.PI*x)/(Math.PI*x),
|
|
17
|
+
sec:x=>+1/Math.cos(x).toFixed(15),
|
|
18
|
+
csc:x=>+1/Math.sin(x).toFixed(15),
|
|
19
|
+
cot:x=>+1/Math.tan(x).toFixed(15),
|
|
20
|
+
acos:x=>+Math.acos(x).toFixed(15),
|
|
21
|
+
asin:x=>+Math.asin(x).toFixed(15),
|
|
22
|
+
atan:x=>+Math.atan(x).toFixed(15),
|
|
23
|
+
acot:x=>+Math.PI/2-Math.atan(x).toFixed(15),
|
|
24
|
+
cosh:x=>+Math.cosh(x).toFixed(15),
|
|
25
|
+
sinh:x=>+Math.sinh(x).toFixed(15),
|
|
26
|
+
tanh:x=>+Math.tanh(x).toFixed(15),
|
|
27
|
+
coth:n=>+(1/2*Math.log((1+n)/(1-n))).toFixed(15),
|
|
28
|
+
acosh:x=>+Math.acosh(x).toFixed(15),
|
|
29
|
+
asinh:x=>+Math.asinh(x).toFixed(15),
|
|
30
|
+
atanh:x=>+Math.atanh(x).toFixed(15),
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
const abs=(...x)=>mapfun(Math.abs,...x);
|
|
35
|
+
const sqrt=(...x)=>mapfun(Math.sqrt,...x);
|
|
36
|
+
const pow=(x,n)=>{
|
|
37
|
+
if(typeof x === "number"){
|
|
38
|
+
if(typeof n === "number")return Math.pow(x,n);
|
|
39
|
+
else if(n instanceof Complex)return Complex.fromExpo(x**n.a,n.b*ln(x))
|
|
40
|
+
else return mapfun(a=>pow(x,a),...n);
|
|
41
|
+
}
|
|
42
|
+
else if(x instanceof Complex){
|
|
43
|
+
if(typeof n === "number")return Complex.fromExpo(x.z**n,x.phi*n);
|
|
44
|
+
else if(n instanceof Complex)return Complex.fromExpo(
|
|
45
|
+
x.z**n.a*e(-x.phi*n.b),
|
|
46
|
+
ln(x.z)*n.b+n.a*x.phi
|
|
47
|
+
)
|
|
48
|
+
else return mapfun(a=>pow(x,a),...n);
|
|
49
|
+
}
|
|
50
|
+
else if(x instanceof Array){
|
|
51
|
+
if(typeof n === "number") return mapfun(a=>pow(a,n),...x);
|
|
52
|
+
else if(n instanceof Array){
|
|
53
|
+
const Y=[];
|
|
54
|
+
for(let i=0;i<x.length;i++){
|
|
55
|
+
Y.push(mapfun(a=>pow(x[i],a),...n))
|
|
56
|
+
}
|
|
57
|
+
return Y;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const sqrtn=(x,n)=>{
|
|
62
|
+
if(typeof x === "number"){
|
|
63
|
+
if(typeof n === "number")return Math.pow(x,1/n);
|
|
64
|
+
else return mapfun(a=>sqrtn(x,a),...n);
|
|
65
|
+
}
|
|
66
|
+
else if(x instanceof Complex){
|
|
67
|
+
if(typeof n === "number")return Complex.fromExpo(sqrtn(x.z,n),x.phi/n);
|
|
68
|
+
else return mapfun(a=>sqrtn(x,a),...n);
|
|
69
|
+
}
|
|
70
|
+
else if(x instanceof Array){
|
|
71
|
+
if(typeof n === "number") return mapfun(a=>sqrtn(a,n),...x);
|
|
72
|
+
else if(n instanceof Array){
|
|
73
|
+
const Y=[];
|
|
74
|
+
for(let i=0;i<x.length;i++){
|
|
75
|
+
Y.push(mapfun(a=>sqrtn(x[i],a),...n))
|
|
76
|
+
}
|
|
77
|
+
return Y;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const e=(...x)=>mapfun(Math.exp,...x);
|
|
82
|
+
const ln=(...x)=>mapfun(Math.log,...x);
|
|
83
|
+
const cos=(...x)=>mapfun(Fixed.cos,...x);
|
|
84
|
+
const sin=(...x)=>mapfun(Fixed.sin,...x);
|
|
85
|
+
const tan=(...x)=>mapfun(Fixed.tan,...x);
|
|
86
|
+
const sec=(...x)=>mapfun(Fixed.sec,...x);
|
|
87
|
+
const sinc=(...x)=>mapfun(Fixed.sinc,...x)
|
|
88
|
+
const csc=(...x)=>mapfun(Fixed.csc,...x);
|
|
89
|
+
const cot=(...x)=>mapfun(Fixed.cot,...x);
|
|
90
|
+
const acos=(...x)=>mapfun(Fixed.acos,...x);
|
|
91
|
+
const asin=(...x)=>mapfun(Fixed.asin,...x);
|
|
92
|
+
const atan=(...x)=>mapfun(Fixed.atan,...x);
|
|
93
|
+
const acot=(...x)=>mapfun(Fixed.acot,...x);
|
|
94
|
+
const cosh=(...x)=>mapfun(Fixed.cosh,...x);
|
|
95
|
+
const sinh=(...x)=>mapfun(Fixed.sinh,...x);
|
|
96
|
+
const tanh=(...x)=>mapfun(Fixed.tanh,...x);
|
|
97
|
+
const coth=(...x)=>mapfun(Fixed.coth,...x);
|
|
98
|
+
const acosh=(...x)=>mapfun(Fixed.acosh,...x);
|
|
99
|
+
const asinh=(...x)=>mapfun(Fixed.asinh,...x);
|
|
100
|
+
const atanh=(...x)=>mapfun(Fixed.atanh,...x);
|
|
101
|
+
const ceil=(...x)=>mapfun(Math.ceil,...x);
|
|
102
|
+
const floor=(...x)=>mapfun(Math.floor,...x);
|
|
103
|
+
const round=(...x)=>mapfun(Math.round,...x);
|
|
104
|
+
const atan2=(x,y,rad=true)=>{
|
|
105
|
+
if(typeof x === "number"){
|
|
106
|
+
if(typeof y === "number")return rad?Math.atan2(x,y):Math.atan2(x,y)*180/Math.PI;
|
|
107
|
+
else return mapfun(a=>atan2(x,a,rad),...y);
|
|
108
|
+
}
|
|
109
|
+
// else if(x instanceof Complex){
|
|
110
|
+
// if(typeof n === "number")return Complex.fromExpo(x.z**n,x.phi*n);
|
|
111
|
+
// else return mapfun(a=>pow(x,a),...n);
|
|
112
|
+
// }
|
|
113
|
+
else if(x instanceof Array){
|
|
114
|
+
if(typeof y === "number") return mapfun(a=>atan2(a,y,rad),...x);
|
|
115
|
+
else if(y instanceof Array){
|
|
116
|
+
const Y=[];
|
|
117
|
+
for(let i=0;i<x.length;i++){
|
|
118
|
+
Y.push(mapfun(a=>pow(x[i],a,rad),...y))
|
|
119
|
+
}
|
|
120
|
+
return Y;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const fact=(...x)=>mapfun(n=> {
|
|
125
|
+
let i,
|
|
126
|
+
y = 1;
|
|
127
|
+
if (n == 0) y = 1;
|
|
128
|
+
else if (n > 0) for (i = 1; i <= n; i++) y *= i;
|
|
129
|
+
else y = NaN;
|
|
130
|
+
return y;
|
|
131
|
+
},...x);
|
|
132
|
+
const sign=(...x)=>mapfun(Math.sign,...x);
|
|
133
|
+
|
|
134
|
+
const sig=(...x)=>mapfun(n=>1/(1+e(-n)),...x);
|
|
135
|
+
|
|
136
|
+
const hypot=(...x)=>{
|
|
137
|
+
if(x.every(n=>typeof n === "number"))return Math.hypot(...x);
|
|
138
|
+
if(x.every(n=>n instanceof Array))return mapfun(
|
|
139
|
+
Math.hypot,
|
|
140
|
+
...x
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export{
|
|
145
|
+
cos,
|
|
146
|
+
sin,
|
|
147
|
+
tan,
|
|
148
|
+
sinc,
|
|
149
|
+
cot,
|
|
150
|
+
sec,
|
|
151
|
+
csc,
|
|
152
|
+
abs,
|
|
153
|
+
sqrt,
|
|
154
|
+
pow,
|
|
155
|
+
sqrtn,
|
|
156
|
+
e,
|
|
157
|
+
ln,
|
|
158
|
+
acos,
|
|
159
|
+
asin,
|
|
160
|
+
atan,
|
|
161
|
+
acot,
|
|
162
|
+
cosh,
|
|
163
|
+
sinh,
|
|
164
|
+
tanh,
|
|
165
|
+
coth,
|
|
166
|
+
acosh,
|
|
167
|
+
asinh,
|
|
168
|
+
atanh,
|
|
169
|
+
min,
|
|
170
|
+
max,
|
|
171
|
+
sign,
|
|
172
|
+
floor,
|
|
173
|
+
ceil,
|
|
174
|
+
round,
|
|
175
|
+
fact,
|
|
176
|
+
hypot,
|
|
177
|
+
sig,
|
|
178
|
+
atan2,
|
|
179
|
+
gamma,
|
|
180
|
+
bessel,
|
|
181
|
+
beta
|
|
182
|
+
};
|