fix atan2,rename {hypot,hypot3} to {norm2,norm3}
[liba.git] / quickjs / src / mf.c
blob2405a6ca03a9a4c260e25f9e9b4484373e8f2a3b
1 #include "mf.h"
3 JSValue liba_mf_gauss(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
5 a_float x;
6 unsigned int i;
7 double arg[] = {0, 0, 0};
8 for (i = 0; i < A_LEN(arg); ++i)
10 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
12 (void)this_val;
13 (void)argc;
14 x = a_mf_gauss((a_float)arg[0], (a_float)arg[1], (a_float)arg[2]);
15 return JS_NewFloat64(ctx, (double)x);
18 JSValue liba_mf_gauss2(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
20 a_float x;
21 unsigned int i;
22 double arg[] = {0, 0, 0, 0, 0};
23 for (i = 0; i < A_LEN(arg); ++i)
25 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
27 (void)this_val;
28 (void)argc;
29 x = a_mf_gauss2((a_float)arg[0], (a_float)arg[1], (a_float)arg[2], (a_float)arg[3], (a_float)arg[4]);
30 return JS_NewFloat64(ctx, (double)x);
33 JSValue liba_mf_gbell(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
35 a_float x;
36 unsigned int i;
37 double arg[] = {0, 0, 0, 0};
38 for (i = 0; i < A_LEN(arg); ++i)
40 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
42 (void)this_val;
43 (void)argc;
44 x = a_mf_gbell((a_float)arg[0], (a_float)arg[1], (a_float)arg[2], (a_float)arg[3]);
45 return JS_NewFloat64(ctx, (double)x);
48 JSValue liba_mf_sig(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
50 a_float x;
51 unsigned int i;
52 double arg[] = {0, 0, 0};
53 for (i = 0; i < A_LEN(arg); ++i)
55 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
57 (void)this_val;
58 (void)argc;
59 x = a_mf_sig((a_float)arg[0], (a_float)arg[1], (a_float)arg[2]);
60 return JS_NewFloat64(ctx, (double)x);
63 JSValue liba_mf_dsig(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
65 a_float x;
66 unsigned int i;
67 double arg[] = {0, 0, 0, 0, 0};
68 for (i = 0; i < A_LEN(arg); ++i)
70 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
72 (void)this_val;
73 (void)argc;
74 x = a_mf_dsig((a_float)arg[0], (a_float)arg[1], (a_float)arg[2], (a_float)arg[3], (a_float)arg[4]);
75 return JS_NewFloat64(ctx, (double)x);
78 JSValue liba_mf_psig(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
80 a_float x;
81 unsigned int i;
82 double arg[] = {0, 0, 0, 0, 0};
83 for (i = 0; i < A_LEN(arg); ++i)
85 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
87 (void)this_val;
88 (void)argc;
89 x = a_mf_psig((a_float)arg[0], (a_float)arg[1], (a_float)arg[2], (a_float)arg[3], (a_float)arg[4]);
90 return JS_NewFloat64(ctx, (double)x);
93 JSValue liba_mf_trap(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
95 a_float x;
96 unsigned int i;
97 double arg[] = {0, 0, 0, 0, 0};
98 for (i = 0; i < A_LEN(arg); ++i)
100 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
102 (void)this_val;
103 (void)argc;
104 x = a_mf_trap((a_float)arg[0], (a_float)arg[1], (a_float)arg[2], (a_float)arg[3], (a_float)arg[4]);
105 return JS_NewFloat64(ctx, (double)x);
108 JSValue liba_mf_tri(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
110 a_float x;
111 unsigned int i;
112 double arg[] = {0, 0, 0, 0};
113 for (i = 0; i < A_LEN(arg); ++i)
115 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
117 (void)this_val;
118 (void)argc;
119 x = a_mf_tri((a_float)arg[0], (a_float)arg[1], (a_float)arg[2], (a_float)arg[3]);
120 return JS_NewFloat64(ctx, (double)x);
123 JSValue liba_mf_lins(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
125 a_float x;
126 unsigned int i;
127 double arg[] = {0, 0, 0};
128 for (i = 0; i < A_LEN(arg); ++i)
130 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
132 (void)this_val;
133 (void)argc;
134 x = a_mf_lins((a_float)arg[0], (a_float)arg[1], (a_float)arg[2]);
135 return JS_NewFloat64(ctx, (double)x);
138 JSValue liba_mf_linz(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
140 a_float x;
141 unsigned int i;
142 double arg[] = {0, 0, 0};
143 for (i = 0; i < A_LEN(arg); ++i)
145 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
147 (void)this_val;
148 (void)argc;
149 x = a_mf_linz((a_float)arg[0], (a_float)arg[1], (a_float)arg[2]);
150 return JS_NewFloat64(ctx, (double)x);
153 JSValue liba_mf_s(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
155 a_float x;
156 unsigned int i;
157 double arg[] = {0, 0, 0};
158 for (i = 0; i < A_LEN(arg); ++i)
160 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
162 (void)this_val;
163 (void)argc;
164 x = a_mf_s((a_float)arg[0], (a_float)arg[1], (a_float)arg[2]);
165 return JS_NewFloat64(ctx, (double)x);
168 JSValue liba_mf_z(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
170 a_float x;
171 unsigned int i;
172 double arg[] = {0, 0, 0};
173 for (i = 0; i < A_LEN(arg); ++i)
175 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
177 (void)this_val;
178 (void)argc;
179 x = a_mf_z((a_float)arg[0], (a_float)arg[1], (a_float)arg[2]);
180 return JS_NewFloat64(ctx, (double)x);
183 JSValue liba_mf_pi(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
185 a_float x;
186 unsigned int i;
187 double arg[] = {0, 0, 0, 0, 0};
188 for (i = 0; i < A_LEN(arg); ++i)
190 if (JS_ToFloat64(ctx, &arg[i], argv[i])) { return JS_EXCEPTION; }
192 (void)this_val;
193 (void)argc;
194 x = a_mf_pi((a_float)arg[0], (a_float)arg[1], (a_float)arg[2], (a_float)arg[3], (a_float)arg[4]);
195 return JS_NewFloat64(ctx, (double)x);