index.js 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713
  1. const cephes = require('./cephes.js');
  2. // Export compiled promise, in Node.js this is just a dummy promise as the
  3. // WebAssembly program will be compiled synchronously. It takes about 20ms
  4. // as of Node.js v10.6.1.
  5. exports.compiled = cephes.compiled;
  6. // from cephes/isnan.c
  7. exports.signbit = function signbit(/* double */ x) {
  8. // argument: double x
  9. if (typeof x !== 'number') {
  10. throw new TypeError('x must be a number');
  11. }
  12. const carg_x = x;
  13. // return: int
  14. const fn_ret = cephes._cephes_signbit(carg_x) | 0;
  15. // No pointers, so just return fn_ret
  16. const ret = fn_ret;
  17. return ret;
  18. };
  19. // from cephes/isnan.c
  20. exports.isnan = function isnan(/* double */ x) {
  21. // argument: double x
  22. if (typeof x !== 'number') {
  23. throw new TypeError('x must be a number');
  24. }
  25. const carg_x = x;
  26. // return: int
  27. const fn_ret = cephes._cephes_isnan(carg_x) | 0;
  28. // No pointers, so just return fn_ret
  29. const ret = fn_ret;
  30. return ret;
  31. };
  32. // from cephes/isnan.c
  33. exports.isfinite = function isfinite(/* double */ x) {
  34. // argument: double x
  35. if (typeof x !== 'number') {
  36. throw new TypeError('x must be a number');
  37. }
  38. const carg_x = x;
  39. // return: int
  40. const fn_ret = cephes._cephes_isfinite(carg_x) | 0;
  41. // No pointers, so just return fn_ret
  42. const ret = fn_ret;
  43. return ret;
  44. };
  45. // from cephes/cbrt.c
  46. exports.cbrt = function cbrt(/* double */ x) {
  47. // argument: double x
  48. if (typeof x !== 'number') {
  49. throw new TypeError('x must be a number');
  50. }
  51. const carg_x = x;
  52. // return: double
  53. const fn_ret = cephes._cephes_cbrt(carg_x);
  54. // No pointers, so just return fn_ret
  55. const ret = fn_ret;
  56. return ret;
  57. };
  58. // from cephes/polevl.c
  59. exports.polevl = function polevl(/* double */ x, /* double[] */ coef, /* int */ N) {
  60. //Save the STACKTOP because the following code will do some stack allocs
  61. const stacktop = cephes.stackSave();
  62. // argument: double x
  63. if (typeof x !== 'number') {
  64. cephes.stackRestore(stacktop);
  65. throw new TypeError('x must be a number');
  66. }
  67. const carg_x = x;
  68. // argument: double[] coef
  69. if (!(coef instanceof Float64Array)) {
  70. cephes.stackRestore(stacktop);
  71. throw new TypeError('coef must be either a Float64Array');
  72. }
  73. const carg_coef = cephes.stackAlloc(coef.length << 3);
  74. cephes.writeArrayToMemory(new Uint8Array(coef.buffer, coef.byteOffset, coef.byteLength), carg_coef);
  75. // argument: int N
  76. if (typeof N !== 'number') {
  77. cephes.stackRestore(stacktop);
  78. throw new TypeError('N must be a number');
  79. }
  80. const carg_N = N | 0;
  81. // return: double
  82. const fn_ret = cephes._cephes_polevl(carg_x, carg_coef, carg_N);
  83. // No pointers, so just return fn_ret
  84. const ret = fn_ret;
  85. // Restore internal stacktop before returning
  86. cephes.stackRestore(stacktop);
  87. return ret;
  88. };
  89. // from cephes/chbevl.c
  90. exports.chbevl = function chbevl(/* double */ x, /* double[] */ array, /* int */ n) {
  91. //Save the STACKTOP because the following code will do some stack allocs
  92. const stacktop = cephes.stackSave();
  93. // argument: double x
  94. if (typeof x !== 'number') {
  95. cephes.stackRestore(stacktop);
  96. throw new TypeError('x must be a number');
  97. }
  98. const carg_x = x;
  99. // argument: double[] array
  100. if (!(array instanceof Float64Array)) {
  101. cephes.stackRestore(stacktop);
  102. throw new TypeError('array must be either a Float64Array');
  103. }
  104. const carg_array = cephes.stackAlloc(array.length << 3);
  105. cephes.writeArrayToMemory(new Uint8Array(array.buffer, array.byteOffset, array.byteLength), carg_array);
  106. // argument: int n
  107. if (typeof n !== 'number') {
  108. cephes.stackRestore(stacktop);
  109. throw new TypeError('n must be a number');
  110. }
  111. const carg_n = n | 0;
  112. // return: double
  113. const fn_ret = cephes._cephes_chbevl(carg_x, carg_array, carg_n);
  114. // No pointers, so just return fn_ret
  115. const ret = fn_ret;
  116. // Restore internal stacktop before returning
  117. cephes.stackRestore(stacktop);
  118. return ret;
  119. };
  120. // from cephes/round.c
  121. exports.round = function round(/* double */ x) {
  122. // argument: double x
  123. if (typeof x !== 'number') {
  124. throw new TypeError('x must be a number');
  125. }
  126. const carg_x = x;
  127. // return: double
  128. const fn_ret = cephes._cephes_round(carg_x);
  129. // No pointers, so just return fn_ret
  130. const ret = fn_ret;
  131. return ret;
  132. };
  133. // from cephes/floor.c
  134. exports.frexp = function frexp(/* double */ x) {
  135. //Save the STACKTOP because the following code will do some stack allocs
  136. const stacktop = cephes.stackSave();
  137. // argument: double x
  138. if (typeof x !== 'number') {
  139. cephes.stackRestore(stacktop);
  140. throw new TypeError('x must be a number');
  141. }
  142. const carg_x = x;
  143. // argument: int* pw2
  144. const carg_pw2 = cephes.stackAlloc(4); // No need to zero-set it.
  145. // return: double
  146. const fn_ret = cephes._cephes_frexp(carg_x, carg_pw2);
  147. // There are pointers, so return the values of thoese too
  148. const ret = [fn_ret, {
  149. 'pw2': cephes.getValue(carg_pw2, 'i32'),
  150. }];
  151. // Restore internal stacktop before returning
  152. cephes.stackRestore(stacktop);
  153. return ret;
  154. };
  155. // from cephes/floor.c
  156. exports.ldexp = function ldexp(/* double */ x, /* int */ pw2) {
  157. // argument: double x
  158. if (typeof x !== 'number') {
  159. throw new TypeError('x must be a number');
  160. }
  161. const carg_x = x;
  162. // argument: int pw2
  163. if (typeof pw2 !== 'number') {
  164. throw new TypeError('pw2 must be a number');
  165. }
  166. const carg_pw2 = pw2 | 0;
  167. // return: double
  168. const fn_ret = cephes._cephes_ldexp(carg_x, carg_pw2);
  169. // No pointers, so just return fn_ret
  170. const ret = fn_ret;
  171. return ret;
  172. };
  173. // from cephes/expx2.c
  174. exports.expx2 = function expx2(/* double */ x, /* int */ sign) {
  175. // argument: double x
  176. if (typeof x !== 'number') {
  177. throw new TypeError('x must be a number');
  178. }
  179. const carg_x = x;
  180. // argument: int sign
  181. if (typeof sign !== 'number') {
  182. throw new TypeError('sign must be a number');
  183. }
  184. const carg_sign = sign | 0;
  185. // return: double
  186. const fn_ret = cephes._cephes_expx2(carg_x, carg_sign);
  187. // No pointers, so just return fn_ret
  188. const ret = fn_ret;
  189. return ret;
  190. };
  191. // from cephes/sin.c
  192. exports.radian = function radian(/* double */ d, /* double */ m, /* double */ s) {
  193. // argument: double d
  194. if (typeof d !== 'number') {
  195. throw new TypeError('d must be a number');
  196. }
  197. const carg_d = d;
  198. // argument: double m
  199. if (typeof m !== 'number') {
  200. throw new TypeError('m must be a number');
  201. }
  202. const carg_m = m;
  203. // argument: double s
  204. if (typeof s !== 'number') {
  205. throw new TypeError('s must be a number');
  206. }
  207. const carg_s = s;
  208. // return: double
  209. const fn_ret = cephes._cephes_radian(carg_d, carg_m, carg_s);
  210. // No pointers, so just return fn_ret
  211. const ret = fn_ret;
  212. return ret;
  213. };
  214. // from cephes/sincos.c
  215. exports.sincos = function sincos(/* double */ x, /* int */ flg) {
  216. //Save the STACKTOP because the following code will do some stack allocs
  217. const stacktop = cephes.stackSave();
  218. // argument: double x
  219. if (typeof x !== 'number') {
  220. cephes.stackRestore(stacktop);
  221. throw new TypeError('x must be a number');
  222. }
  223. const carg_x = x;
  224. // argument: double* s
  225. const carg_s = cephes.stackAlloc(8); // No need to zero-set it.
  226. // argument: double* c
  227. const carg_c = cephes.stackAlloc(8); // No need to zero-set it.
  228. // argument: int flg
  229. if (typeof flg !== 'number') {
  230. cephes.stackRestore(stacktop);
  231. throw new TypeError('flg must be a number');
  232. }
  233. const carg_flg = flg | 0;
  234. // return: int
  235. const fn_ret = cephes._cephes_sincos(carg_x, carg_s, carg_c, carg_flg) | 0;
  236. // There are pointers, so return the values of thoese too
  237. const ret = [fn_ret, {
  238. 's': cephes.getValue(carg_s, 'double'),
  239. 'c': cephes.getValue(carg_c, 'double'),
  240. }];
  241. // Restore internal stacktop before returning
  242. cephes.stackRestore(stacktop);
  243. return ret;
  244. };
  245. // from cephes/tan.c
  246. exports.cot = function cot(/* double */ x) {
  247. // argument: double x
  248. if (typeof x !== 'number') {
  249. throw new TypeError('x must be a number');
  250. }
  251. const carg_x = x;
  252. // return: double
  253. const fn_ret = cephes._cephes_cot(carg_x);
  254. // No pointers, so just return fn_ret
  255. const ret = fn_ret;
  256. return ret;
  257. };
  258. // from cephes/tandg.c
  259. exports.cotdg = function cotdg(/* double */ x) {
  260. // argument: double x
  261. if (typeof x !== 'number') {
  262. throw new TypeError('x must be a number');
  263. }
  264. const carg_x = x;
  265. // return: double
  266. const fn_ret = cephes._cephes_cotdg(carg_x);
  267. // No pointers, so just return fn_ret
  268. const ret = fn_ret;
  269. return ret;
  270. };
  271. // from cephes/unity.c
  272. exports.log1p = function log1p(/* double */ x) {
  273. // argument: double x
  274. if (typeof x !== 'number') {
  275. throw new TypeError('x must be a number');
  276. }
  277. const carg_x = x;
  278. // return: double
  279. const fn_ret = cephes._cephes_log1p(carg_x);
  280. // No pointers, so just return fn_ret
  281. const ret = fn_ret;
  282. return ret;
  283. };
  284. // from cephes/unity.c
  285. exports.expm1 = function expm1(/* double */ x) {
  286. // argument: double x
  287. if (typeof x !== 'number') {
  288. throw new TypeError('x must be a number');
  289. }
  290. const carg_x = x;
  291. // return: double
  292. const fn_ret = cephes._cephes_expm1(carg_x);
  293. // No pointers, so just return fn_ret
  294. const ret = fn_ret;
  295. return ret;
  296. };
  297. // from cephes/unity.c
  298. exports.cosm1 = function cosm1(/* double */ x) {
  299. // argument: double x
  300. if (typeof x !== 'number') {
  301. throw new TypeError('x must be a number');
  302. }
  303. const carg_x = x;
  304. // return: double
  305. const fn_ret = cephes._cephes_cosm1(carg_x);
  306. // No pointers, so just return fn_ret
  307. const ret = fn_ret;
  308. return ret;
  309. };
  310. // from cephes/asin.c
  311. exports.acos = function acos(/* double */ x) {
  312. // argument: double x
  313. if (typeof x !== 'number') {
  314. throw new TypeError('x must be a number');
  315. }
  316. const carg_x = x;
  317. // return: double
  318. const fn_ret = cephes._cephes_acos(carg_x);
  319. // No pointers, so just return fn_ret
  320. const ret = fn_ret;
  321. return ret;
  322. };
  323. // from cephes/acosh.c
  324. exports.acosh = function acosh(/* double */ x) {
  325. // argument: double x
  326. if (typeof x !== 'number') {
  327. throw new TypeError('x must be a number');
  328. }
  329. const carg_x = x;
  330. // return: double
  331. const fn_ret = cephes._cephes_acosh(carg_x);
  332. // No pointers, so just return fn_ret
  333. const ret = fn_ret;
  334. return ret;
  335. };
  336. // from cephes/asinh.c
  337. exports.asinh = function asinh(/* double */ xx) {
  338. // argument: double xx
  339. if (typeof xx !== 'number') {
  340. throw new TypeError('xx must be a number');
  341. }
  342. const carg_xx = xx;
  343. // return: double
  344. const fn_ret = cephes._cephes_asinh(carg_xx);
  345. // No pointers, so just return fn_ret
  346. const ret = fn_ret;
  347. return ret;
  348. };
  349. // from cephes/atanh.c
  350. exports.atanh = function atanh(/* double */ x) {
  351. // argument: double x
  352. if (typeof x !== 'number') {
  353. throw new TypeError('x must be a number');
  354. }
  355. const carg_x = x;
  356. // return: double
  357. const fn_ret = cephes._cephes_atanh(carg_x);
  358. // No pointers, so just return fn_ret
  359. const ret = fn_ret;
  360. return ret;
  361. };
  362. // from cephes/asin.c
  363. exports.asin = function asin(/* double */ x) {
  364. // argument: double x
  365. if (typeof x !== 'number') {
  366. throw new TypeError('x must be a number');
  367. }
  368. const carg_x = x;
  369. // return: double
  370. const fn_ret = cephes._cephes_asin(carg_x);
  371. // No pointers, so just return fn_ret
  372. const ret = fn_ret;
  373. return ret;
  374. };
  375. // from cephes/atan.c
  376. exports.atan = function atan(/* double */ x) {
  377. // argument: double x
  378. if (typeof x !== 'number') {
  379. throw new TypeError('x must be a number');
  380. }
  381. const carg_x = x;
  382. // return: double
  383. const fn_ret = cephes._cephes_atan(carg_x);
  384. // No pointers, so just return fn_ret
  385. const ret = fn_ret;
  386. return ret;
  387. };
  388. // from cephes/atan.c
  389. exports.atan2 = function atan2(/* double */ y, /* double */ x) {
  390. // argument: double y
  391. if (typeof y !== 'number') {
  392. throw new TypeError('y must be a number');
  393. }
  394. const carg_y = y;
  395. // argument: double x
  396. if (typeof x !== 'number') {
  397. throw new TypeError('x must be a number');
  398. }
  399. const carg_x = x;
  400. // return: double
  401. const fn_ret = cephes._cephes_atan2(carg_y, carg_x);
  402. // No pointers, so just return fn_ret
  403. const ret = fn_ret;
  404. return ret;
  405. };
  406. // from cephes/sin.c
  407. exports.cos = function cos(/* double */ x) {
  408. // argument: double x
  409. if (typeof x !== 'number') {
  410. throw new TypeError('x must be a number');
  411. }
  412. const carg_x = x;
  413. // return: double
  414. const fn_ret = cephes._cephes_cos(carg_x);
  415. // No pointers, so just return fn_ret
  416. const ret = fn_ret;
  417. return ret;
  418. };
  419. // from cephes/sindg.c
  420. exports.cosdg = function cosdg(/* double */ x) {
  421. // argument: double x
  422. if (typeof x !== 'number') {
  423. throw new TypeError('x must be a number');
  424. }
  425. const carg_x = x;
  426. // return: double
  427. const fn_ret = cephes._cephes_cosdg(carg_x);
  428. // No pointers, so just return fn_ret
  429. const ret = fn_ret;
  430. return ret;
  431. };
  432. // from cephes/exp.c
  433. exports.exp = function exp(/* double */ x) {
  434. // argument: double x
  435. if (typeof x !== 'number') {
  436. throw new TypeError('x must be a number');
  437. }
  438. const carg_x = x;
  439. // return: double
  440. const fn_ret = cephes._cephes_exp(carg_x);
  441. // No pointers, so just return fn_ret
  442. const ret = fn_ret;
  443. return ret;
  444. };
  445. // from cephes/exp2.c
  446. exports.exp2 = function exp2(/* double */ x) {
  447. // argument: double x
  448. if (typeof x !== 'number') {
  449. throw new TypeError('x must be a number');
  450. }
  451. const carg_x = x;
  452. // return: double
  453. const fn_ret = cephes._cephes_exp2(carg_x);
  454. // No pointers, so just return fn_ret
  455. const ret = fn_ret;
  456. return ret;
  457. };
  458. // from cephes/exp10.c
  459. exports.exp10 = function exp10(/* double */ x) {
  460. // argument: double x
  461. if (typeof x !== 'number') {
  462. throw new TypeError('x must be a number');
  463. }
  464. const carg_x = x;
  465. // return: double
  466. const fn_ret = cephes._cephes_exp10(carg_x);
  467. // No pointers, so just return fn_ret
  468. const ret = fn_ret;
  469. return ret;
  470. };
  471. // from cephes/cosh.c
  472. exports.cosh = function cosh(/* double */ x) {
  473. // argument: double x
  474. if (typeof x !== 'number') {
  475. throw new TypeError('x must be a number');
  476. }
  477. const carg_x = x;
  478. // return: double
  479. const fn_ret = cephes._cephes_cosh(carg_x);
  480. // No pointers, so just return fn_ret
  481. const ret = fn_ret;
  482. return ret;
  483. };
  484. // from cephes/sinh.c
  485. exports.sinh = function sinh(/* double */ x) {
  486. // argument: double x
  487. if (typeof x !== 'number') {
  488. throw new TypeError('x must be a number');
  489. }
  490. const carg_x = x;
  491. // return: double
  492. const fn_ret = cephes._cephes_sinh(carg_x);
  493. // No pointers, so just return fn_ret
  494. const ret = fn_ret;
  495. return ret;
  496. };
  497. // from cephes/tanh.c
  498. exports.tanh = function tanh(/* double */ x) {
  499. // argument: double x
  500. if (typeof x !== 'number') {
  501. throw new TypeError('x must be a number');
  502. }
  503. const carg_x = x;
  504. // return: double
  505. const fn_ret = cephes._cephes_tanh(carg_x);
  506. // No pointers, so just return fn_ret
  507. const ret = fn_ret;
  508. return ret;
  509. };
  510. // from cephes/log.c
  511. exports.log = function log(/* double */ x) {
  512. // argument: double x
  513. if (typeof x !== 'number') {
  514. throw new TypeError('x must be a number');
  515. }
  516. const carg_x = x;
  517. // return: double
  518. const fn_ret = cephes._cephes_log(carg_x);
  519. // No pointers, so just return fn_ret
  520. const ret = fn_ret;
  521. return ret;
  522. };
  523. // from cephes/log2.c
  524. exports.log2 = function log2(/* double */ x) {
  525. // argument: double x
  526. if (typeof x !== 'number') {
  527. throw new TypeError('x must be a number');
  528. }
  529. const carg_x = x;
  530. // return: double
  531. const fn_ret = cephes._cephes_log2(carg_x);
  532. // No pointers, so just return fn_ret
  533. const ret = fn_ret;
  534. return ret;
  535. };
  536. // from cephes/log10.c
  537. exports.log10 = function log10(/* double */ x) {
  538. // argument: double x
  539. if (typeof x !== 'number') {
  540. throw new TypeError('x must be a number');
  541. }
  542. const carg_x = x;
  543. // return: double
  544. const fn_ret = cephes._cephes_log10(carg_x);
  545. // No pointers, so just return fn_ret
  546. const ret = fn_ret;
  547. return ret;
  548. };
  549. // from cephes/pow.c
  550. exports.pow = function pow(/* double */ x, /* double */ y) {
  551. // argument: double x
  552. if (typeof x !== 'number') {
  553. throw new TypeError('x must be a number');
  554. }
  555. const carg_x = x;
  556. // argument: double y
  557. if (typeof y !== 'number') {
  558. throw new TypeError('y must be a number');
  559. }
  560. const carg_y = y;
  561. // return: double
  562. const fn_ret = cephes._cephes_pow(carg_x, carg_y);
  563. // No pointers, so just return fn_ret
  564. const ret = fn_ret;
  565. return ret;
  566. };
  567. // from cephes/powi.c
  568. exports.powi = function powi(/* double */ x, /* int */ nn) {
  569. // argument: double x
  570. if (typeof x !== 'number') {
  571. throw new TypeError('x must be a number');
  572. }
  573. const carg_x = x;
  574. // argument: int nn
  575. if (typeof nn !== 'number') {
  576. throw new TypeError('nn must be a number');
  577. }
  578. const carg_nn = nn | 0;
  579. // return: double
  580. const fn_ret = cephes._cephes_powi(carg_x, carg_nn);
  581. // No pointers, so just return fn_ret
  582. const ret = fn_ret;
  583. return ret;
  584. };
  585. // from cephes/sin.c
  586. exports.sin = function sin(/* double */ x) {
  587. // argument: double x
  588. if (typeof x !== 'number') {
  589. throw new TypeError('x must be a number');
  590. }
  591. const carg_x = x;
  592. // return: double
  593. const fn_ret = cephes._cephes_sin(carg_x);
  594. // No pointers, so just return fn_ret
  595. const ret = fn_ret;
  596. return ret;
  597. };
  598. // from cephes/sindg.c
  599. exports.sindg = function sindg(/* double */ x) {
  600. // argument: double x
  601. if (typeof x !== 'number') {
  602. throw new TypeError('x must be a number');
  603. }
  604. const carg_x = x;
  605. // return: double
  606. const fn_ret = cephes._cephes_sindg(carg_x);
  607. // No pointers, so just return fn_ret
  608. const ret = fn_ret;
  609. return ret;
  610. };
  611. // from cephes/tan.c
  612. exports.tan = function tan(/* double */ x) {
  613. // argument: double x
  614. if (typeof x !== 'number') {
  615. throw new TypeError('x must be a number');
  616. }
  617. const carg_x = x;
  618. // return: double
  619. const fn_ret = cephes._cephes_tan(carg_x);
  620. // No pointers, so just return fn_ret
  621. const ret = fn_ret;
  622. return ret;
  623. };
  624. // from cephes/tandg.c
  625. exports.tandg = function tandg(/* double */ x) {
  626. // argument: double x
  627. if (typeof x !== 'number') {
  628. throw new TypeError('x must be a number');
  629. }
  630. const carg_x = x;
  631. // return: double
  632. const fn_ret = cephes._cephes_tandg(carg_x);
  633. // No pointers, so just return fn_ret
  634. const ret = fn_ret;
  635. return ret;
  636. };
  637. // from cephes/ei.c
  638. exports.ei = function ei(/* double */ x) {
  639. // argument: double x
  640. if (typeof x !== 'number') {
  641. throw new TypeError('x must be a number');
  642. }
  643. const carg_x = x;
  644. // return: double
  645. const fn_ret = cephes._cephes_ei(carg_x);
  646. // No pointers, so just return fn_ret
  647. const ret = fn_ret;
  648. return ret;
  649. };
  650. // from cephes/expn.c
  651. exports.expn = function expn(/* int */ n, /* double */ x) {
  652. // argument: int n
  653. if (typeof n !== 'number') {
  654. throw new TypeError('n must be a number');
  655. }
  656. const carg_n = n | 0;
  657. // argument: double x
  658. if (typeof x !== 'number') {
  659. throw new TypeError('x must be a number');
  660. }
  661. const carg_x = x;
  662. // return: double
  663. const fn_ret = cephes._cephes_expn(carg_n, carg_x);
  664. // No pointers, so just return fn_ret
  665. const ret = fn_ret;
  666. return ret;
  667. };
  668. // from cephes/shichi.c
  669. exports.shichi = function shichi(/* double */ x) {
  670. //Save the STACKTOP because the following code will do some stack allocs
  671. const stacktop = cephes.stackSave();
  672. // argument: double x
  673. if (typeof x !== 'number') {
  674. cephes.stackRestore(stacktop);
  675. throw new TypeError('x must be a number');
  676. }
  677. const carg_x = x;
  678. // argument: double* si
  679. const carg_si = cephes.stackAlloc(8); // No need to zero-set it.
  680. // argument: double* ci
  681. const carg_ci = cephes.stackAlloc(8); // No need to zero-set it.
  682. // return: int
  683. const fn_ret = cephes._cephes_shichi(carg_x, carg_si, carg_ci) | 0;
  684. // There are pointers, so return the values of thoese too
  685. const ret = [fn_ret, {
  686. 'si': cephes.getValue(carg_si, 'double'),
  687. 'ci': cephes.getValue(carg_ci, 'double'),
  688. }];
  689. // Restore internal stacktop before returning
  690. cephes.stackRestore(stacktop);
  691. return ret;
  692. };
  693. // from cephes/sici.c
  694. exports.sici = function sici(/* double */ x) {
  695. //Save the STACKTOP because the following code will do some stack allocs
  696. const stacktop = cephes.stackSave();
  697. // argument: double x
  698. if (typeof x !== 'number') {
  699. cephes.stackRestore(stacktop);
  700. throw new TypeError('x must be a number');
  701. }
  702. const carg_x = x;
  703. // argument: double* si
  704. const carg_si = cephes.stackAlloc(8); // No need to zero-set it.
  705. // argument: double* ci
  706. const carg_ci = cephes.stackAlloc(8); // No need to zero-set it.
  707. // return: int
  708. const fn_ret = cephes._cephes_sici(carg_x, carg_si, carg_ci) | 0;
  709. // There are pointers, so return the values of thoese too
  710. const ret = [fn_ret, {
  711. 'si': cephes.getValue(carg_si, 'double'),
  712. 'ci': cephes.getValue(carg_ci, 'double'),
  713. }];
  714. // Restore internal stacktop before returning
  715. cephes.stackRestore(stacktop);
  716. return ret;
  717. };
  718. // from cephes/beta.c
  719. exports.lbeta = function lbeta(/* double */ a, /* double */ b) {
  720. // argument: double a
  721. if (typeof a !== 'number') {
  722. throw new TypeError('a must be a number');
  723. }
  724. const carg_a = a;
  725. // argument: double b
  726. if (typeof b !== 'number') {
  727. throw new TypeError('b must be a number');
  728. }
  729. const carg_b = b;
  730. // return: double
  731. const fn_ret = cephes._cephes_lbeta(carg_a, carg_b);
  732. // No pointers, so just return fn_ret
  733. const ret = fn_ret;
  734. return ret;
  735. };
  736. // from cephes/beta.c
  737. exports.beta = function beta(/* double */ a, /* double */ b) {
  738. // argument: double a
  739. if (typeof a !== 'number') {
  740. throw new TypeError('a must be a number');
  741. }
  742. const carg_a = a;
  743. // argument: double b
  744. if (typeof b !== 'number') {
  745. throw new TypeError('b must be a number');
  746. }
  747. const carg_b = b;
  748. // return: double
  749. const fn_ret = cephes._cephes_beta(carg_a, carg_b);
  750. // No pointers, so just return fn_ret
  751. const ret = fn_ret;
  752. return ret;
  753. };
  754. // from cephes/fac.c
  755. exports.fac = function fac(/* int */ i) {
  756. // argument: int i
  757. if (typeof i !== 'number') {
  758. throw new TypeError('i must be a number');
  759. }
  760. const carg_i = i | 0;
  761. // return: double
  762. const fn_ret = cephes._cephes_fac(carg_i);
  763. // No pointers, so just return fn_ret
  764. const ret = fn_ret;
  765. return ret;
  766. };
  767. // from cephes/gamma.c
  768. exports.gamma = function gamma(/* double */ x) {
  769. // argument: double x
  770. if (typeof x !== 'number') {
  771. throw new TypeError('x must be a number');
  772. }
  773. const carg_x = x;
  774. // return: double
  775. const fn_ret = cephes._cephes_gamma(carg_x);
  776. // No pointers, so just return fn_ret
  777. const ret = fn_ret;
  778. return ret;
  779. };
  780. // from cephes/gamma.c
  781. exports.lgam = function lgam(/* double */ x) {
  782. // argument: double x
  783. if (typeof x !== 'number') {
  784. throw new TypeError('x must be a number');
  785. }
  786. const carg_x = x;
  787. // return: double
  788. const fn_ret = cephes._cephes_lgam(carg_x);
  789. // No pointers, so just return fn_ret
  790. const ret = fn_ret;
  791. return ret;
  792. };
  793. // from cephes/incbet.c
  794. exports.incbet = function incbet(/* double */ aa, /* double */ bb, /* double */ xx) {
  795. // argument: double aa
  796. if (typeof aa !== 'number') {
  797. throw new TypeError('aa must be a number');
  798. }
  799. const carg_aa = aa;
  800. // argument: double bb
  801. if (typeof bb !== 'number') {
  802. throw new TypeError('bb must be a number');
  803. }
  804. const carg_bb = bb;
  805. // argument: double xx
  806. if (typeof xx !== 'number') {
  807. throw new TypeError('xx must be a number');
  808. }
  809. const carg_xx = xx;
  810. // return: double
  811. const fn_ret = cephes._cephes_incbet(carg_aa, carg_bb, carg_xx);
  812. // No pointers, so just return fn_ret
  813. const ret = fn_ret;
  814. return ret;
  815. };
  816. // from cephes/incbi.c
  817. exports.incbi = function incbi(/* double */ aa, /* double */ bb, /* double */ yy0) {
  818. // argument: double aa
  819. if (typeof aa !== 'number') {
  820. throw new TypeError('aa must be a number');
  821. }
  822. const carg_aa = aa;
  823. // argument: double bb
  824. if (typeof bb !== 'number') {
  825. throw new TypeError('bb must be a number');
  826. }
  827. const carg_bb = bb;
  828. // argument: double yy0
  829. if (typeof yy0 !== 'number') {
  830. throw new TypeError('yy0 must be a number');
  831. }
  832. const carg_yy0 = yy0;
  833. // return: double
  834. const fn_ret = cephes._cephes_incbi(carg_aa, carg_bb, carg_yy0);
  835. // No pointers, so just return fn_ret
  836. const ret = fn_ret;
  837. return ret;
  838. };
  839. // from cephes/igam.c
  840. exports.igam = function igam(/* double */ a, /* double */ x) {
  841. // argument: double a
  842. if (typeof a !== 'number') {
  843. throw new TypeError('a must be a number');
  844. }
  845. const carg_a = a;
  846. // argument: double x
  847. if (typeof x !== 'number') {
  848. throw new TypeError('x must be a number');
  849. }
  850. const carg_x = x;
  851. // return: double
  852. const fn_ret = cephes._cephes_igam(carg_a, carg_x);
  853. // No pointers, so just return fn_ret
  854. const ret = fn_ret;
  855. return ret;
  856. };
  857. // from cephes/igam.c
  858. exports.igamc = function igamc(/* double */ a, /* double */ x) {
  859. // argument: double a
  860. if (typeof a !== 'number') {
  861. throw new TypeError('a must be a number');
  862. }
  863. const carg_a = a;
  864. // argument: double x
  865. if (typeof x !== 'number') {
  866. throw new TypeError('x must be a number');
  867. }
  868. const carg_x = x;
  869. // return: double
  870. const fn_ret = cephes._cephes_igamc(carg_a, carg_x);
  871. // No pointers, so just return fn_ret
  872. const ret = fn_ret;
  873. return ret;
  874. };
  875. // from cephes/igami.c
  876. exports.igami = function igami(/* double */ a, /* double */ y0) {
  877. // argument: double a
  878. if (typeof a !== 'number') {
  879. throw new TypeError('a must be a number');
  880. }
  881. const carg_a = a;
  882. // argument: double y0
  883. if (typeof y0 !== 'number') {
  884. throw new TypeError('y0 must be a number');
  885. }
  886. const carg_y0 = y0;
  887. // return: double
  888. const fn_ret = cephes._cephes_igami(carg_a, carg_y0);
  889. // No pointers, so just return fn_ret
  890. const ret = fn_ret;
  891. return ret;
  892. };
  893. // from cephes/psi.c
  894. exports.psi = function psi(/* double */ x) {
  895. // argument: double x
  896. if (typeof x !== 'number') {
  897. throw new TypeError('x must be a number');
  898. }
  899. const carg_x = x;
  900. // return: double
  901. const fn_ret = cephes._cephes_psi(carg_x);
  902. // No pointers, so just return fn_ret
  903. const ret = fn_ret;
  904. return ret;
  905. };
  906. // from cephes/rgamma.c
  907. exports.rgamma = function rgamma(/* double */ x) {
  908. // argument: double x
  909. if (typeof x !== 'number') {
  910. throw new TypeError('x must be a number');
  911. }
  912. const carg_x = x;
  913. // return: double
  914. const fn_ret = cephes._cephes_rgamma(carg_x);
  915. // No pointers, so just return fn_ret
  916. const ret = fn_ret;
  917. return ret;
  918. };
  919. // from cephes/ndtr.c
  920. exports.erf = function erf(/* double */ x) {
  921. // argument: double x
  922. if (typeof x !== 'number') {
  923. throw new TypeError('x must be a number');
  924. }
  925. const carg_x = x;
  926. // return: double
  927. const fn_ret = cephes._cephes_erf(carg_x);
  928. // No pointers, so just return fn_ret
  929. const ret = fn_ret;
  930. return ret;
  931. };
  932. // from cephes/ndtr.c
  933. exports.erfc = function erfc(/* double */ a) {
  934. // argument: double a
  935. if (typeof a !== 'number') {
  936. throw new TypeError('a must be a number');
  937. }
  938. const carg_a = a;
  939. // return: double
  940. const fn_ret = cephes._cephes_erfc(carg_a);
  941. // No pointers, so just return fn_ret
  942. const ret = fn_ret;
  943. return ret;
  944. };
  945. // from cephes/dawsn.c
  946. exports.dawsn = function dawsn(/* double */ xx) {
  947. // argument: double xx
  948. if (typeof xx !== 'number') {
  949. throw new TypeError('xx must be a number');
  950. }
  951. const carg_xx = xx;
  952. // return: double
  953. const fn_ret = cephes._cephes_dawsn(carg_xx);
  954. // No pointers, so just return fn_ret
  955. const ret = fn_ret;
  956. return ret;
  957. };
  958. // from cephes/fresnl.c
  959. exports.fresnl = function fresnl(/* double */ xxa) {
  960. //Save the STACKTOP because the following code will do some stack allocs
  961. const stacktop = cephes.stackSave();
  962. // argument: double xxa
  963. if (typeof xxa !== 'number') {
  964. cephes.stackRestore(stacktop);
  965. throw new TypeError('xxa must be a number');
  966. }
  967. const carg_xxa = xxa;
  968. // argument: double* ssa
  969. const carg_ssa = cephes.stackAlloc(8); // No need to zero-set it.
  970. // argument: double* cca
  971. const carg_cca = cephes.stackAlloc(8); // No need to zero-set it.
  972. // return: int
  973. const fn_ret = cephes._cephes_fresnl(carg_xxa, carg_ssa, carg_cca) | 0;
  974. // There are pointers, so return the values of thoese too
  975. const ret = [fn_ret, {
  976. 'ssa': cephes.getValue(carg_ssa, 'double'),
  977. 'cca': cephes.getValue(carg_cca, 'double'),
  978. }];
  979. // Restore internal stacktop before returning
  980. cephes.stackRestore(stacktop);
  981. return ret;
  982. };
  983. // from cephes/airy.c
  984. exports.airy = function airy(/* double */ x) {
  985. //Save the STACKTOP because the following code will do some stack allocs
  986. const stacktop = cephes.stackSave();
  987. // argument: double x
  988. if (typeof x !== 'number') {
  989. cephes.stackRestore(stacktop);
  990. throw new TypeError('x must be a number');
  991. }
  992. const carg_x = x;
  993. // argument: double* ai
  994. const carg_ai = cephes.stackAlloc(8); // No need to zero-set it.
  995. // argument: double* aip
  996. const carg_aip = cephes.stackAlloc(8); // No need to zero-set it.
  997. // argument: double* bi
  998. const carg_bi = cephes.stackAlloc(8); // No need to zero-set it.
  999. // argument: double* bip
  1000. const carg_bip = cephes.stackAlloc(8); // No need to zero-set it.
  1001. // return: int
  1002. const fn_ret = cephes._cephes_airy(carg_x, carg_ai, carg_aip, carg_bi, carg_bip) | 0;
  1003. // There are pointers, so return the values of thoese too
  1004. const ret = [fn_ret, {
  1005. 'ai': cephes.getValue(carg_ai, 'double'),
  1006. 'aip': cephes.getValue(carg_aip, 'double'),
  1007. 'bi': cephes.getValue(carg_bi, 'double'),
  1008. 'bip': cephes.getValue(carg_bip, 'double'),
  1009. }];
  1010. // Restore internal stacktop before returning
  1011. cephes.stackRestore(stacktop);
  1012. return ret;
  1013. };
  1014. // from cephes/j0.c
  1015. exports.j0 = function j0(/* double */ x) {
  1016. // argument: double x
  1017. if (typeof x !== 'number') {
  1018. throw new TypeError('x must be a number');
  1019. }
  1020. const carg_x = x;
  1021. // return: double
  1022. const fn_ret = cephes._cephes_j0(carg_x);
  1023. // No pointers, so just return fn_ret
  1024. const ret = fn_ret;
  1025. return ret;
  1026. };
  1027. // from cephes/j1.c
  1028. exports.j1 = function j1(/* double */ x) {
  1029. // argument: double x
  1030. if (typeof x !== 'number') {
  1031. throw new TypeError('x must be a number');
  1032. }
  1033. const carg_x = x;
  1034. // return: double
  1035. const fn_ret = cephes._cephes_j1(carg_x);
  1036. // No pointers, so just return fn_ret
  1037. const ret = fn_ret;
  1038. return ret;
  1039. };
  1040. // from cephes/jn.c
  1041. exports.jn = function jn(/* int */ n, /* double */ x) {
  1042. // argument: int n
  1043. if (typeof n !== 'number') {
  1044. throw new TypeError('n must be a number');
  1045. }
  1046. const carg_n = n | 0;
  1047. // argument: double x
  1048. if (typeof x !== 'number') {
  1049. throw new TypeError('x must be a number');
  1050. }
  1051. const carg_x = x;
  1052. // return: double
  1053. const fn_ret = cephes._cephes_jn(carg_n, carg_x);
  1054. // No pointers, so just return fn_ret
  1055. const ret = fn_ret;
  1056. return ret;
  1057. };
  1058. // from cephes/jv.c
  1059. exports.jv = function jv(/* double */ n, /* double */ x) {
  1060. // argument: double n
  1061. if (typeof n !== 'number') {
  1062. throw new TypeError('n must be a number');
  1063. }
  1064. const carg_n = n;
  1065. // argument: double x
  1066. if (typeof x !== 'number') {
  1067. throw new TypeError('x must be a number');
  1068. }
  1069. const carg_x = x;
  1070. // return: double
  1071. const fn_ret = cephes._cephes_jv(carg_n, carg_x);
  1072. // No pointers, so just return fn_ret
  1073. const ret = fn_ret;
  1074. return ret;
  1075. };
  1076. // from cephes/j0.c
  1077. exports.y0 = function y0(/* double */ x) {
  1078. // argument: double x
  1079. if (typeof x !== 'number') {
  1080. throw new TypeError('x must be a number');
  1081. }
  1082. const carg_x = x;
  1083. // return: double
  1084. const fn_ret = cephes._cephes_y0(carg_x);
  1085. // No pointers, so just return fn_ret
  1086. const ret = fn_ret;
  1087. return ret;
  1088. };
  1089. // from cephes/j1.c
  1090. exports.y1 = function y1(/* double */ x) {
  1091. // argument: double x
  1092. if (typeof x !== 'number') {
  1093. throw new TypeError('x must be a number');
  1094. }
  1095. const carg_x = x;
  1096. // return: double
  1097. const fn_ret = cephes._cephes_y1(carg_x);
  1098. // No pointers, so just return fn_ret
  1099. const ret = fn_ret;
  1100. return ret;
  1101. };
  1102. // from cephes/yn.c
  1103. exports.yn = function yn(/* int */ n, /* double */ x) {
  1104. // argument: int n
  1105. if (typeof n !== 'number') {
  1106. throw new TypeError('n must be a number');
  1107. }
  1108. const carg_n = n | 0;
  1109. // argument: double x
  1110. if (typeof x !== 'number') {
  1111. throw new TypeError('x must be a number');
  1112. }
  1113. const carg_x = x;
  1114. // return: double
  1115. const fn_ret = cephes._cephes_yn(carg_n, carg_x);
  1116. // No pointers, so just return fn_ret
  1117. const ret = fn_ret;
  1118. return ret;
  1119. };
  1120. // from cephes/struve.c
  1121. exports.yv = function yv(/* double */ v, /* double */ x) {
  1122. // argument: double v
  1123. if (typeof v !== 'number') {
  1124. throw new TypeError('v must be a number');
  1125. }
  1126. const carg_v = v;
  1127. // argument: double x
  1128. if (typeof x !== 'number') {
  1129. throw new TypeError('x must be a number');
  1130. }
  1131. const carg_x = x;
  1132. // return: double
  1133. const fn_ret = cephes._cephes_yv(carg_v, carg_x);
  1134. // No pointers, so just return fn_ret
  1135. const ret = fn_ret;
  1136. return ret;
  1137. };
  1138. // from cephes/i0.c
  1139. exports.i0 = function i0(/* double */ x) {
  1140. // argument: double x
  1141. if (typeof x !== 'number') {
  1142. throw new TypeError('x must be a number');
  1143. }
  1144. const carg_x = x;
  1145. // return: double
  1146. const fn_ret = cephes._cephes_i0(carg_x);
  1147. // No pointers, so just return fn_ret
  1148. const ret = fn_ret;
  1149. return ret;
  1150. };
  1151. // from cephes/i0.c
  1152. exports.i0e = function i0e(/* double */ x) {
  1153. // argument: double x
  1154. if (typeof x !== 'number') {
  1155. throw new TypeError('x must be a number');
  1156. }
  1157. const carg_x = x;
  1158. // return: double
  1159. const fn_ret = cephes._cephes_i0e(carg_x);
  1160. // No pointers, so just return fn_ret
  1161. const ret = fn_ret;
  1162. return ret;
  1163. };
  1164. // from cephes/i1.c
  1165. exports.i1 = function i1(/* double */ x) {
  1166. // argument: double x
  1167. if (typeof x !== 'number') {
  1168. throw new TypeError('x must be a number');
  1169. }
  1170. const carg_x = x;
  1171. // return: double
  1172. const fn_ret = cephes._cephes_i1(carg_x);
  1173. // No pointers, so just return fn_ret
  1174. const ret = fn_ret;
  1175. return ret;
  1176. };
  1177. // from cephes/i1.c
  1178. exports.i1e = function i1e(/* double */ x) {
  1179. // argument: double x
  1180. if (typeof x !== 'number') {
  1181. throw new TypeError('x must be a number');
  1182. }
  1183. const carg_x = x;
  1184. // return: double
  1185. const fn_ret = cephes._cephes_i1e(carg_x);
  1186. // No pointers, so just return fn_ret
  1187. const ret = fn_ret;
  1188. return ret;
  1189. };
  1190. // from cephes/iv.c
  1191. exports.iv = function iv(/* double */ v, /* double */ x) {
  1192. // argument: double v
  1193. if (typeof v !== 'number') {
  1194. throw new TypeError('v must be a number');
  1195. }
  1196. const carg_v = v;
  1197. // argument: double x
  1198. if (typeof x !== 'number') {
  1199. throw new TypeError('x must be a number');
  1200. }
  1201. const carg_x = x;
  1202. // return: double
  1203. const fn_ret = cephes._cephes_iv(carg_v, carg_x);
  1204. // No pointers, so just return fn_ret
  1205. const ret = fn_ret;
  1206. return ret;
  1207. };
  1208. // from cephes/k0.c
  1209. exports.k0 = function k0(/* double */ x) {
  1210. // argument: double x
  1211. if (typeof x !== 'number') {
  1212. throw new TypeError('x must be a number');
  1213. }
  1214. const carg_x = x;
  1215. // return: double
  1216. const fn_ret = cephes._cephes_k0(carg_x);
  1217. // No pointers, so just return fn_ret
  1218. const ret = fn_ret;
  1219. return ret;
  1220. };
  1221. // from cephes/k0.c
  1222. exports.k0e = function k0e(/* double */ x) {
  1223. // argument: double x
  1224. if (typeof x !== 'number') {
  1225. throw new TypeError('x must be a number');
  1226. }
  1227. const carg_x = x;
  1228. // return: double
  1229. const fn_ret = cephes._cephes_k0e(carg_x);
  1230. // No pointers, so just return fn_ret
  1231. const ret = fn_ret;
  1232. return ret;
  1233. };
  1234. // from cephes/k1.c
  1235. exports.k1 = function k1(/* double */ x) {
  1236. // argument: double x
  1237. if (typeof x !== 'number') {
  1238. throw new TypeError('x must be a number');
  1239. }
  1240. const carg_x = x;
  1241. // return: double
  1242. const fn_ret = cephes._cephes_k1(carg_x);
  1243. // No pointers, so just return fn_ret
  1244. const ret = fn_ret;
  1245. return ret;
  1246. };
  1247. // from cephes/k1.c
  1248. exports.k1e = function k1e(/* double */ x) {
  1249. // argument: double x
  1250. if (typeof x !== 'number') {
  1251. throw new TypeError('x must be a number');
  1252. }
  1253. const carg_x = x;
  1254. // return: double
  1255. const fn_ret = cephes._cephes_k1e(carg_x);
  1256. // No pointers, so just return fn_ret
  1257. const ret = fn_ret;
  1258. return ret;
  1259. };
  1260. // from cephes/kn.c
  1261. exports.kn = function kn(/* int */ nn, /* double */ x) {
  1262. // argument: int nn
  1263. if (typeof nn !== 'number') {
  1264. throw new TypeError('nn must be a number');
  1265. }
  1266. const carg_nn = nn | 0;
  1267. // argument: double x
  1268. if (typeof x !== 'number') {
  1269. throw new TypeError('x must be a number');
  1270. }
  1271. const carg_x = x;
  1272. // return: double
  1273. const fn_ret = cephes._cephes_kn(carg_nn, carg_x);
  1274. // No pointers, so just return fn_ret
  1275. const ret = fn_ret;
  1276. return ret;
  1277. };
  1278. // from cephes/hyperg.c
  1279. exports.hyperg = function hyperg(/* double */ a, /* double */ b, /* double */ x) {
  1280. // argument: double a
  1281. if (typeof a !== 'number') {
  1282. throw new TypeError('a must be a number');
  1283. }
  1284. const carg_a = a;
  1285. // argument: double b
  1286. if (typeof b !== 'number') {
  1287. throw new TypeError('b must be a number');
  1288. }
  1289. const carg_b = b;
  1290. // argument: double x
  1291. if (typeof x !== 'number') {
  1292. throw new TypeError('x must be a number');
  1293. }
  1294. const carg_x = x;
  1295. // return: double
  1296. const fn_ret = cephes._cephes_hyperg(carg_a, carg_b, carg_x);
  1297. // No pointers, so just return fn_ret
  1298. const ret = fn_ret;
  1299. return ret;
  1300. };
  1301. // from cephes/hyp2f1.c
  1302. exports.hyp2f1 = function hyp2f1(/* double */ a, /* double */ b, /* double */ c, /* double */ x) {
  1303. // argument: double a
  1304. if (typeof a !== 'number') {
  1305. throw new TypeError('a must be a number');
  1306. }
  1307. const carg_a = a;
  1308. // argument: double b
  1309. if (typeof b !== 'number') {
  1310. throw new TypeError('b must be a number');
  1311. }
  1312. const carg_b = b;
  1313. // argument: double c
  1314. if (typeof c !== 'number') {
  1315. throw new TypeError('c must be a number');
  1316. }
  1317. const carg_c = c;
  1318. // argument: double x
  1319. if (typeof x !== 'number') {
  1320. throw new TypeError('x must be a number');
  1321. }
  1322. const carg_x = x;
  1323. // return: double
  1324. const fn_ret = cephes._cephes_hyp2f1(carg_a, carg_b, carg_c, carg_x);
  1325. // No pointers, so just return fn_ret
  1326. const ret = fn_ret;
  1327. return ret;
  1328. };
  1329. // from cephes/ellpe.c
  1330. exports.ellpe = function ellpe(/* double */ x) {
  1331. // argument: double x
  1332. if (typeof x !== 'number') {
  1333. throw new TypeError('x must be a number');
  1334. }
  1335. const carg_x = x;
  1336. // return: double
  1337. const fn_ret = cephes._cephes_ellpe(carg_x);
  1338. // No pointers, so just return fn_ret
  1339. const ret = fn_ret;
  1340. return ret;
  1341. };
  1342. // from cephes/ellie.c
  1343. exports.ellie = function ellie(/* double */ phi, /* double */ m) {
  1344. // argument: double phi
  1345. if (typeof phi !== 'number') {
  1346. throw new TypeError('phi must be a number');
  1347. }
  1348. const carg_phi = phi;
  1349. // argument: double m
  1350. if (typeof m !== 'number') {
  1351. throw new TypeError('m must be a number');
  1352. }
  1353. const carg_m = m;
  1354. // return: double
  1355. const fn_ret = cephes._cephes_ellie(carg_phi, carg_m);
  1356. // No pointers, so just return fn_ret
  1357. const ret = fn_ret;
  1358. return ret;
  1359. };
  1360. // from cephes/ellpk.c
  1361. exports.ellpk = function ellpk(/* double */ x) {
  1362. // argument: double x
  1363. if (typeof x !== 'number') {
  1364. throw new TypeError('x must be a number');
  1365. }
  1366. const carg_x = x;
  1367. // return: double
  1368. const fn_ret = cephes._cephes_ellpk(carg_x);
  1369. // No pointers, so just return fn_ret
  1370. const ret = fn_ret;
  1371. return ret;
  1372. };
  1373. // from cephes/ellik.c
  1374. exports.ellik = function ellik(/* double */ phi, /* double */ m) {
  1375. // argument: double phi
  1376. if (typeof phi !== 'number') {
  1377. throw new TypeError('phi must be a number');
  1378. }
  1379. const carg_phi = phi;
  1380. // argument: double m
  1381. if (typeof m !== 'number') {
  1382. throw new TypeError('m must be a number');
  1383. }
  1384. const carg_m = m;
  1385. // return: double
  1386. const fn_ret = cephes._cephes_ellik(carg_phi, carg_m);
  1387. // No pointers, so just return fn_ret
  1388. const ret = fn_ret;
  1389. return ret;
  1390. };
  1391. // from cephes/ellpj.c
  1392. exports.ellpj = function ellpj(/* double */ u, /* double */ m) {
  1393. //Save the STACKTOP because the following code will do some stack allocs
  1394. const stacktop = cephes.stackSave();
  1395. // argument: double u
  1396. if (typeof u !== 'number') {
  1397. cephes.stackRestore(stacktop);
  1398. throw new TypeError('u must be a number');
  1399. }
  1400. const carg_u = u;
  1401. // argument: double m
  1402. if (typeof m !== 'number') {
  1403. cephes.stackRestore(stacktop);
  1404. throw new TypeError('m must be a number');
  1405. }
  1406. const carg_m = m;
  1407. // argument: double* sn
  1408. const carg_sn = cephes.stackAlloc(8); // No need to zero-set it.
  1409. // argument: double* cn
  1410. const carg_cn = cephes.stackAlloc(8); // No need to zero-set it.
  1411. // argument: double* dn
  1412. const carg_dn = cephes.stackAlloc(8); // No need to zero-set it.
  1413. // argument: double* ph
  1414. const carg_ph = cephes.stackAlloc(8); // No need to zero-set it.
  1415. // return: int
  1416. const fn_ret = cephes._cephes_ellpj(carg_u, carg_m, carg_sn, carg_cn, carg_dn, carg_ph) | 0;
  1417. // There are pointers, so return the values of thoese too
  1418. const ret = [fn_ret, {
  1419. 'sn': cephes.getValue(carg_sn, 'double'),
  1420. 'cn': cephes.getValue(carg_cn, 'double'),
  1421. 'dn': cephes.getValue(carg_dn, 'double'),
  1422. 'ph': cephes.getValue(carg_ph, 'double'),
  1423. }];
  1424. // Restore internal stacktop before returning
  1425. cephes.stackRestore(stacktop);
  1426. return ret;
  1427. };
  1428. // from cephes/btdtr.c
  1429. exports.btdtr = function btdtr(/* double */ a, /* double */ b, /* double */ x) {
  1430. // argument: double a
  1431. if (typeof a !== 'number') {
  1432. throw new TypeError('a must be a number');
  1433. }
  1434. const carg_a = a;
  1435. // argument: double b
  1436. if (typeof b !== 'number') {
  1437. throw new TypeError('b must be a number');
  1438. }
  1439. const carg_b = b;
  1440. // argument: double x
  1441. if (typeof x !== 'number') {
  1442. throw new TypeError('x must be a number');
  1443. }
  1444. const carg_x = x;
  1445. // return: double
  1446. const fn_ret = cephes._cephes_btdtr(carg_a, carg_b, carg_x);
  1447. // No pointers, so just return fn_ret
  1448. const ret = fn_ret;
  1449. return ret;
  1450. };
  1451. // from cephes/kolmogorov.c
  1452. exports.smirnov = function smirnov(/* int */ n, /* double */ e) {
  1453. // argument: int n
  1454. if (typeof n !== 'number') {
  1455. throw new TypeError('n must be a number');
  1456. }
  1457. const carg_n = n | 0;
  1458. // argument: double e
  1459. if (typeof e !== 'number') {
  1460. throw new TypeError('e must be a number');
  1461. }
  1462. const carg_e = e;
  1463. // return: double
  1464. const fn_ret = cephes._cephes_smirnov(carg_n, carg_e);
  1465. // No pointers, so just return fn_ret
  1466. const ret = fn_ret;
  1467. return ret;
  1468. };
  1469. // from cephes/kolmogorov.c
  1470. exports.kolmogorov = function kolmogorov(/* double */ y) {
  1471. // argument: double y
  1472. if (typeof y !== 'number') {
  1473. throw new TypeError('y must be a number');
  1474. }
  1475. const carg_y = y;
  1476. // return: double
  1477. const fn_ret = cephes._cephes_kolmogorov(carg_y);
  1478. // No pointers, so just return fn_ret
  1479. const ret = fn_ret;
  1480. return ret;
  1481. };
  1482. // from cephes/kolmogorov.c
  1483. exports.smirnovi = function smirnovi(/* int */ n, /* double */ p) {
  1484. // argument: int n
  1485. if (typeof n !== 'number') {
  1486. throw new TypeError('n must be a number');
  1487. }
  1488. const carg_n = n | 0;
  1489. // argument: double p
  1490. if (typeof p !== 'number') {
  1491. throw new TypeError('p must be a number');
  1492. }
  1493. const carg_p = p;
  1494. // return: double
  1495. const fn_ret = cephes._cephes_smirnovi(carg_n, carg_p);
  1496. // No pointers, so just return fn_ret
  1497. const ret = fn_ret;
  1498. return ret;
  1499. };
  1500. // from cephes/kolmogorov.c
  1501. exports.kolmogi = function kolmogi(/* double */ p) {
  1502. // argument: double p
  1503. if (typeof p !== 'number') {
  1504. throw new TypeError('p must be a number');
  1505. }
  1506. const carg_p = p;
  1507. // return: double
  1508. const fn_ret = cephes._cephes_kolmogi(carg_p);
  1509. // No pointers, so just return fn_ret
  1510. const ret = fn_ret;
  1511. return ret;
  1512. };
  1513. // from cephes/nbdtr.c
  1514. exports.nbdtri = function nbdtri(/* int */ k, /* int */ n, /* double */ p) {
  1515. // argument: int k
  1516. if (typeof k !== 'number') {
  1517. throw new TypeError('k must be a number');
  1518. }
  1519. const carg_k = k | 0;
  1520. // argument: int n
  1521. if (typeof n !== 'number') {
  1522. throw new TypeError('n must be a number');
  1523. }
  1524. const carg_n = n | 0;
  1525. // argument: double p
  1526. if (typeof p !== 'number') {
  1527. throw new TypeError('p must be a number');
  1528. }
  1529. const carg_p = p;
  1530. // return: double
  1531. const fn_ret = cephes._cephes_nbdtri(carg_k, carg_n, carg_p);
  1532. // No pointers, so just return fn_ret
  1533. const ret = fn_ret;
  1534. return ret;
  1535. };
  1536. // from cephes/stdtr.c
  1537. exports.stdtri = function stdtri(/* int */ k, /* double */ p) {
  1538. // argument: int k
  1539. if (typeof k !== 'number') {
  1540. throw new TypeError('k must be a number');
  1541. }
  1542. const carg_k = k | 0;
  1543. // argument: double p
  1544. if (typeof p !== 'number') {
  1545. throw new TypeError('p must be a number');
  1546. }
  1547. const carg_p = p;
  1548. // return: double
  1549. const fn_ret = cephes._cephes_stdtri(carg_k, carg_p);
  1550. // No pointers, so just return fn_ret
  1551. const ret = fn_ret;
  1552. return ret;
  1553. };
  1554. // from cephes/bdtr.c
  1555. exports.bdtr = function bdtr(/* int */ k, /* int */ n, /* double */ p) {
  1556. // argument: int k
  1557. if (typeof k !== 'number') {
  1558. throw new TypeError('k must be a number');
  1559. }
  1560. const carg_k = k | 0;
  1561. // argument: int n
  1562. if (typeof n !== 'number') {
  1563. throw new TypeError('n must be a number');
  1564. }
  1565. const carg_n = n | 0;
  1566. // argument: double p
  1567. if (typeof p !== 'number') {
  1568. throw new TypeError('p must be a number');
  1569. }
  1570. const carg_p = p;
  1571. // return: double
  1572. const fn_ret = cephes._cephes_bdtr(carg_k, carg_n, carg_p);
  1573. // No pointers, so just return fn_ret
  1574. const ret = fn_ret;
  1575. return ret;
  1576. };
  1577. // from cephes/bdtr.c
  1578. exports.bdtrc = function bdtrc(/* int */ k, /* int */ n, /* double */ p) {
  1579. // argument: int k
  1580. if (typeof k !== 'number') {
  1581. throw new TypeError('k must be a number');
  1582. }
  1583. const carg_k = k | 0;
  1584. // argument: int n
  1585. if (typeof n !== 'number') {
  1586. throw new TypeError('n must be a number');
  1587. }
  1588. const carg_n = n | 0;
  1589. // argument: double p
  1590. if (typeof p !== 'number') {
  1591. throw new TypeError('p must be a number');
  1592. }
  1593. const carg_p = p;
  1594. // return: double
  1595. const fn_ret = cephes._cephes_bdtrc(carg_k, carg_n, carg_p);
  1596. // No pointers, so just return fn_ret
  1597. const ret = fn_ret;
  1598. return ret;
  1599. };
  1600. // from cephes/bdtr.c
  1601. exports.bdtri = function bdtri(/* int */ k, /* int */ n, /* double */ y) {
  1602. // argument: int k
  1603. if (typeof k !== 'number') {
  1604. throw new TypeError('k must be a number');
  1605. }
  1606. const carg_k = k | 0;
  1607. // argument: int n
  1608. if (typeof n !== 'number') {
  1609. throw new TypeError('n must be a number');
  1610. }
  1611. const carg_n = n | 0;
  1612. // argument: double y
  1613. if (typeof y !== 'number') {
  1614. throw new TypeError('y must be a number');
  1615. }
  1616. const carg_y = y;
  1617. // return: double
  1618. const fn_ret = cephes._cephes_bdtri(carg_k, carg_n, carg_y);
  1619. // No pointers, so just return fn_ret
  1620. const ret = fn_ret;
  1621. return ret;
  1622. };
  1623. // from cephes/chdtr.c
  1624. exports.chdtr = function chdtr(/* double */ df, /* double */ x) {
  1625. // argument: double df
  1626. if (typeof df !== 'number') {
  1627. throw new TypeError('df must be a number');
  1628. }
  1629. const carg_df = df;
  1630. // argument: double x
  1631. if (typeof x !== 'number') {
  1632. throw new TypeError('x must be a number');
  1633. }
  1634. const carg_x = x;
  1635. // return: double
  1636. const fn_ret = cephes._cephes_chdtr(carg_df, carg_x);
  1637. // No pointers, so just return fn_ret
  1638. const ret = fn_ret;
  1639. return ret;
  1640. };
  1641. // from cephes/chdtr.c
  1642. exports.chdtrc = function chdtrc(/* double */ df, /* double */ x) {
  1643. // argument: double df
  1644. if (typeof df !== 'number') {
  1645. throw new TypeError('df must be a number');
  1646. }
  1647. const carg_df = df;
  1648. // argument: double x
  1649. if (typeof x !== 'number') {
  1650. throw new TypeError('x must be a number');
  1651. }
  1652. const carg_x = x;
  1653. // return: double
  1654. const fn_ret = cephes._cephes_chdtrc(carg_df, carg_x);
  1655. // No pointers, so just return fn_ret
  1656. const ret = fn_ret;
  1657. return ret;
  1658. };
  1659. // from cephes/chdtr.c
  1660. exports.chdtri = function chdtri(/* double */ df, /* double */ y) {
  1661. // argument: double df
  1662. if (typeof df !== 'number') {
  1663. throw new TypeError('df must be a number');
  1664. }
  1665. const carg_df = df;
  1666. // argument: double y
  1667. if (typeof y !== 'number') {
  1668. throw new TypeError('y must be a number');
  1669. }
  1670. const carg_y = y;
  1671. // return: double
  1672. const fn_ret = cephes._cephes_chdtri(carg_df, carg_y);
  1673. // No pointers, so just return fn_ret
  1674. const ret = fn_ret;
  1675. return ret;
  1676. };
  1677. // from cephes/fdtr.c
  1678. exports.fdtr = function fdtr(/* int */ ia, /* int */ ib, /* double */ x) {
  1679. // argument: int ia
  1680. if (typeof ia !== 'number') {
  1681. throw new TypeError('ia must be a number');
  1682. }
  1683. const carg_ia = ia | 0;
  1684. // argument: int ib
  1685. if (typeof ib !== 'number') {
  1686. throw new TypeError('ib must be a number');
  1687. }
  1688. const carg_ib = ib | 0;
  1689. // argument: double x
  1690. if (typeof x !== 'number') {
  1691. throw new TypeError('x must be a number');
  1692. }
  1693. const carg_x = x;
  1694. // return: double
  1695. const fn_ret = cephes._cephes_fdtr(carg_ia, carg_ib, carg_x);
  1696. // No pointers, so just return fn_ret
  1697. const ret = fn_ret;
  1698. return ret;
  1699. };
  1700. // from cephes/fdtr.c
  1701. exports.fdtrc = function fdtrc(/* int */ ia, /* int */ ib, /* double */ x) {
  1702. // argument: int ia
  1703. if (typeof ia !== 'number') {
  1704. throw new TypeError('ia must be a number');
  1705. }
  1706. const carg_ia = ia | 0;
  1707. // argument: int ib
  1708. if (typeof ib !== 'number') {
  1709. throw new TypeError('ib must be a number');
  1710. }
  1711. const carg_ib = ib | 0;
  1712. // argument: double x
  1713. if (typeof x !== 'number') {
  1714. throw new TypeError('x must be a number');
  1715. }
  1716. const carg_x = x;
  1717. // return: double
  1718. const fn_ret = cephes._cephes_fdtrc(carg_ia, carg_ib, carg_x);
  1719. // No pointers, so just return fn_ret
  1720. const ret = fn_ret;
  1721. return ret;
  1722. };
  1723. // from cephes/fdtr.c
  1724. exports.fdtri = function fdtri(/* int */ ia, /* int */ ib, /* double */ y) {
  1725. // argument: int ia
  1726. if (typeof ia !== 'number') {
  1727. throw new TypeError('ia must be a number');
  1728. }
  1729. const carg_ia = ia | 0;
  1730. // argument: int ib
  1731. if (typeof ib !== 'number') {
  1732. throw new TypeError('ib must be a number');
  1733. }
  1734. const carg_ib = ib | 0;
  1735. // argument: double y
  1736. if (typeof y !== 'number') {
  1737. throw new TypeError('y must be a number');
  1738. }
  1739. const carg_y = y;
  1740. // return: double
  1741. const fn_ret = cephes._cephes_fdtri(carg_ia, carg_ib, carg_y);
  1742. // No pointers, so just return fn_ret
  1743. const ret = fn_ret;
  1744. return ret;
  1745. };
  1746. // from cephes/gdtr.c
  1747. exports.gdtr = function gdtr(/* double */ a, /* double */ b, /* double */ x) {
  1748. // argument: double a
  1749. if (typeof a !== 'number') {
  1750. throw new TypeError('a must be a number');
  1751. }
  1752. const carg_a = a;
  1753. // argument: double b
  1754. if (typeof b !== 'number') {
  1755. throw new TypeError('b must be a number');
  1756. }
  1757. const carg_b = b;
  1758. // argument: double x
  1759. if (typeof x !== 'number') {
  1760. throw new TypeError('x must be a number');
  1761. }
  1762. const carg_x = x;
  1763. // return: double
  1764. const fn_ret = cephes._cephes_gdtr(carg_a, carg_b, carg_x);
  1765. // No pointers, so just return fn_ret
  1766. const ret = fn_ret;
  1767. return ret;
  1768. };
  1769. // from cephes/gdtr.c
  1770. exports.gdtrc = function gdtrc(/* double */ a, /* double */ b, /* double */ x) {
  1771. // argument: double a
  1772. if (typeof a !== 'number') {
  1773. throw new TypeError('a must be a number');
  1774. }
  1775. const carg_a = a;
  1776. // argument: double b
  1777. if (typeof b !== 'number') {
  1778. throw new TypeError('b must be a number');
  1779. }
  1780. const carg_b = b;
  1781. // argument: double x
  1782. if (typeof x !== 'number') {
  1783. throw new TypeError('x must be a number');
  1784. }
  1785. const carg_x = x;
  1786. // return: double
  1787. const fn_ret = cephes._cephes_gdtrc(carg_a, carg_b, carg_x);
  1788. // No pointers, so just return fn_ret
  1789. const ret = fn_ret;
  1790. return ret;
  1791. };
  1792. // from cephes/nbdtr.c
  1793. exports.nbdtr = function nbdtr(/* int */ k, /* int */ n, /* double */ p) {
  1794. // argument: int k
  1795. if (typeof k !== 'number') {
  1796. throw new TypeError('k must be a number');
  1797. }
  1798. const carg_k = k | 0;
  1799. // argument: int n
  1800. if (typeof n !== 'number') {
  1801. throw new TypeError('n must be a number');
  1802. }
  1803. const carg_n = n | 0;
  1804. // argument: double p
  1805. if (typeof p !== 'number') {
  1806. throw new TypeError('p must be a number');
  1807. }
  1808. const carg_p = p;
  1809. // return: double
  1810. const fn_ret = cephes._cephes_nbdtr(carg_k, carg_n, carg_p);
  1811. // No pointers, so just return fn_ret
  1812. const ret = fn_ret;
  1813. return ret;
  1814. };
  1815. // from cephes/nbdtr.c
  1816. exports.nbdtrc = function nbdtrc(/* int */ k, /* int */ n, /* double */ p) {
  1817. // argument: int k
  1818. if (typeof k !== 'number') {
  1819. throw new TypeError('k must be a number');
  1820. }
  1821. const carg_k = k | 0;
  1822. // argument: int n
  1823. if (typeof n !== 'number') {
  1824. throw new TypeError('n must be a number');
  1825. }
  1826. const carg_n = n | 0;
  1827. // argument: double p
  1828. if (typeof p !== 'number') {
  1829. throw new TypeError('p must be a number');
  1830. }
  1831. const carg_p = p;
  1832. // return: double
  1833. const fn_ret = cephes._cephes_nbdtrc(carg_k, carg_n, carg_p);
  1834. // No pointers, so just return fn_ret
  1835. const ret = fn_ret;
  1836. return ret;
  1837. };
  1838. // from cephes/ndtr.c
  1839. exports.ndtr = function ndtr(/* double */ a) {
  1840. // argument: double a
  1841. if (typeof a !== 'number') {
  1842. throw new TypeError('a must be a number');
  1843. }
  1844. const carg_a = a;
  1845. // return: double
  1846. const fn_ret = cephes._cephes_ndtr(carg_a);
  1847. // No pointers, so just return fn_ret
  1848. const ret = fn_ret;
  1849. return ret;
  1850. };
  1851. // from cephes/ndtri.c
  1852. exports.ndtri = function ndtri(/* double */ y0) {
  1853. // argument: double y0
  1854. if (typeof y0 !== 'number') {
  1855. throw new TypeError('y0 must be a number');
  1856. }
  1857. const carg_y0 = y0;
  1858. // return: double
  1859. const fn_ret = cephes._cephes_ndtri(carg_y0);
  1860. // No pointers, so just return fn_ret
  1861. const ret = fn_ret;
  1862. return ret;
  1863. };
  1864. // from cephes/pdtr.c
  1865. exports.pdtr = function pdtr(/* int */ k, /* double */ m) {
  1866. // argument: int k
  1867. if (typeof k !== 'number') {
  1868. throw new TypeError('k must be a number');
  1869. }
  1870. const carg_k = k | 0;
  1871. // argument: double m
  1872. if (typeof m !== 'number') {
  1873. throw new TypeError('m must be a number');
  1874. }
  1875. const carg_m = m;
  1876. // return: double
  1877. const fn_ret = cephes._cephes_pdtr(carg_k, carg_m);
  1878. // No pointers, so just return fn_ret
  1879. const ret = fn_ret;
  1880. return ret;
  1881. };
  1882. // from cephes/pdtr.c
  1883. exports.pdtrc = function pdtrc(/* int */ k, /* double */ m) {
  1884. // argument: int k
  1885. if (typeof k !== 'number') {
  1886. throw new TypeError('k must be a number');
  1887. }
  1888. const carg_k = k | 0;
  1889. // argument: double m
  1890. if (typeof m !== 'number') {
  1891. throw new TypeError('m must be a number');
  1892. }
  1893. const carg_m = m;
  1894. // return: double
  1895. const fn_ret = cephes._cephes_pdtrc(carg_k, carg_m);
  1896. // No pointers, so just return fn_ret
  1897. const ret = fn_ret;
  1898. return ret;
  1899. };
  1900. // from cephes/pdtr.c
  1901. exports.pdtri = function pdtri(/* int */ k, /* double */ y) {
  1902. // argument: int k
  1903. if (typeof k !== 'number') {
  1904. throw new TypeError('k must be a number');
  1905. }
  1906. const carg_k = k | 0;
  1907. // argument: double y
  1908. if (typeof y !== 'number') {
  1909. throw new TypeError('y must be a number');
  1910. }
  1911. const carg_y = y;
  1912. // return: double
  1913. const fn_ret = cephes._cephes_pdtri(carg_k, carg_y);
  1914. // No pointers, so just return fn_ret
  1915. const ret = fn_ret;
  1916. return ret;
  1917. };
  1918. // from cephes/stdtr.c
  1919. exports.stdtr = function stdtr(/* int */ k, /* double */ t) {
  1920. // argument: int k
  1921. if (typeof k !== 'number') {
  1922. throw new TypeError('k must be a number');
  1923. }
  1924. const carg_k = k | 0;
  1925. // argument: double t
  1926. if (typeof t !== 'number') {
  1927. throw new TypeError('t must be a number');
  1928. }
  1929. const carg_t = t;
  1930. // return: double
  1931. const fn_ret = cephes._cephes_stdtr(carg_k, carg_t);
  1932. // No pointers, so just return fn_ret
  1933. const ret = fn_ret;
  1934. return ret;
  1935. };
  1936. // from cephes/planck.c
  1937. exports.plancki = function plancki(/* double */ w, /* double */ T) {
  1938. // argument: double w
  1939. if (typeof w !== 'number') {
  1940. throw new TypeError('w must be a number');
  1941. }
  1942. const carg_w = w;
  1943. // argument: double T
  1944. if (typeof T !== 'number') {
  1945. throw new TypeError('T must be a number');
  1946. }
  1947. const carg_T = T;
  1948. // return: double
  1949. const fn_ret = cephes._cephes_plancki(carg_w, carg_T);
  1950. // No pointers, so just return fn_ret
  1951. const ret = fn_ret;
  1952. return ret;
  1953. };
  1954. // from cephes/planck.c
  1955. exports.planckc = function planckc(/* double */ w, /* double */ T) {
  1956. // argument: double w
  1957. if (typeof w !== 'number') {
  1958. throw new TypeError('w must be a number');
  1959. }
  1960. const carg_w = w;
  1961. // argument: double T
  1962. if (typeof T !== 'number') {
  1963. throw new TypeError('T must be a number');
  1964. }
  1965. const carg_T = T;
  1966. // return: double
  1967. const fn_ret = cephes._cephes_planckc(carg_w, carg_T);
  1968. // No pointers, so just return fn_ret
  1969. const ret = fn_ret;
  1970. return ret;
  1971. };
  1972. // from cephes/planck.c
  1973. exports.planckd = function planckd(/* double */ w, /* double */ T) {
  1974. // argument: double w
  1975. if (typeof w !== 'number') {
  1976. throw new TypeError('w must be a number');
  1977. }
  1978. const carg_w = w;
  1979. // argument: double T
  1980. if (typeof T !== 'number') {
  1981. throw new TypeError('T must be a number');
  1982. }
  1983. const carg_T = T;
  1984. // return: double
  1985. const fn_ret = cephes._cephes_planckd(carg_w, carg_T);
  1986. // No pointers, so just return fn_ret
  1987. const ret = fn_ret;
  1988. return ret;
  1989. };
  1990. // from cephes/planck.c
  1991. exports.planckw = function planckw(/* double */ T) {
  1992. // argument: double T
  1993. if (typeof T !== 'number') {
  1994. throw new TypeError('T must be a number');
  1995. }
  1996. const carg_T = T;
  1997. // return: double
  1998. const fn_ret = cephes._cephes_planckw(carg_T);
  1999. // No pointers, so just return fn_ret
  2000. const ret = fn_ret;
  2001. return ret;
  2002. };
  2003. // from cephes/spence.c
  2004. exports.spence = function spence(/* double */ x) {
  2005. // argument: double x
  2006. if (typeof x !== 'number') {
  2007. throw new TypeError('x must be a number');
  2008. }
  2009. const carg_x = x;
  2010. // return: double
  2011. const fn_ret = cephes._cephes_spence(carg_x);
  2012. // No pointers, so just return fn_ret
  2013. const ret = fn_ret;
  2014. return ret;
  2015. };
  2016. // from cephes/zetac.c
  2017. exports.zetac = function zetac(/* double */ x) {
  2018. // argument: double x
  2019. if (typeof x !== 'number') {
  2020. throw new TypeError('x must be a number');
  2021. }
  2022. const carg_x = x;
  2023. // return: double
  2024. const fn_ret = cephes._cephes_zetac(carg_x);
  2025. // No pointers, so just return fn_ret
  2026. const ret = fn_ret;
  2027. return ret;
  2028. };
  2029. // from cephes/zeta.c
  2030. exports.zeta = function zeta(/* double */ x, /* double */ q) {
  2031. // argument: double x
  2032. if (typeof x !== 'number') {
  2033. throw new TypeError('x must be a number');
  2034. }
  2035. const carg_x = x;
  2036. // argument: double q
  2037. if (typeof q !== 'number') {
  2038. throw new TypeError('q must be a number');
  2039. }
  2040. const carg_q = q;
  2041. // return: double
  2042. const fn_ret = cephes._cephes_zeta(carg_x, carg_q);
  2043. // No pointers, so just return fn_ret
  2044. const ret = fn_ret;
  2045. return ret;
  2046. };
  2047. // from cephes/struve.c
  2048. exports.struve = function struve(/* double */ v, /* double */ x) {
  2049. // argument: double v
  2050. if (typeof v !== 'number') {
  2051. throw new TypeError('v must be a number');
  2052. }
  2053. const carg_v = v;
  2054. // argument: double x
  2055. if (typeof x !== 'number') {
  2056. throw new TypeError('x must be a number');
  2057. }
  2058. const carg_x = x;
  2059. // return: double
  2060. const fn_ret = cephes._cephes_struve(carg_v, carg_x);
  2061. // No pointers, so just return fn_ret
  2062. const ret = fn_ret;
  2063. return ret;
  2064. };
  2065. // from cephes/polevl.c
  2066. exports.p1evl = function p1evl(/* double */ x, /* double[] */ coef, /* int */ N) {
  2067. //Save the STACKTOP because the following code will do some stack allocs
  2068. const stacktop = cephes.stackSave();
  2069. // argument: double x
  2070. if (typeof x !== 'number') {
  2071. cephes.stackRestore(stacktop);
  2072. throw new TypeError('x must be a number');
  2073. }
  2074. const carg_x = x;
  2075. // argument: double[] coef
  2076. if (!(coef instanceof Float64Array)) {
  2077. cephes.stackRestore(stacktop);
  2078. throw new TypeError('coef must be either a Float64Array');
  2079. }
  2080. const carg_coef = cephes.stackAlloc(coef.length << 3);
  2081. cephes.writeArrayToMemory(new Uint8Array(coef.buffer, coef.byteOffset, coef.byteLength), carg_coef);
  2082. // argument: int N
  2083. if (typeof N !== 'number') {
  2084. cephes.stackRestore(stacktop);
  2085. throw new TypeError('N must be a number');
  2086. }
  2087. const carg_N = N | 0;
  2088. // return: double
  2089. const fn_ret = cephes._cephes_p1evl(carg_x, carg_coef, carg_N);
  2090. // No pointers, so just return fn_ret
  2091. const ret = fn_ret;
  2092. // Restore internal stacktop before returning
  2093. cephes.stackRestore(stacktop);
  2094. return ret;
  2095. };
  2096. // from cephes/polylog.c
  2097. exports.polylog = function polylog(/* int */ n, /* double */ x) {
  2098. // argument: int n
  2099. if (typeof n !== 'number') {
  2100. throw new TypeError('n must be a number');
  2101. }
  2102. const carg_n = n | 0;
  2103. // argument: double x
  2104. if (typeof x !== 'number') {
  2105. throw new TypeError('x must be a number');
  2106. }
  2107. const carg_x = x;
  2108. // return: double
  2109. const fn_ret = cephes._cephes_polylog(carg_n, carg_x);
  2110. // No pointers, so just return fn_ret
  2111. const ret = fn_ret;
  2112. return ret;
  2113. };