bigdecimal-math_r 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -0
  3. data/CODE_OF_CONDUCT.md +132 -0
  4. data/LICENSE +21 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +41 -0
  7. data/Rakefile +13 -0
  8. data/changelog.md +24 -0
  9. data/ext/bigdecimal/math_r/algofunc.h +203 -0
  10. data/ext/bigdecimal/math_r/api/bigdecimal/check_precise.h +12 -0
  11. data/ext/bigdecimal/math_r/api/bigdecimal/infinity.h +6 -0
  12. data/ext/bigdecimal/math_r/api/bigdecimal/minus_infinity.h +5 -0
  13. data/ext/bigdecimal/math_r/api/bigdecimal/minus_one.h +6 -0
  14. data/ext/bigdecimal/math_r/api/bigdecimal/minus_zero.h +6 -0
  15. data/ext/bigdecimal/math_r/api/bigdecimal/nan.h +6 -0
  16. data/ext/bigdecimal/math_r/api/bigdecimal/one.h +6 -0
  17. data/ext/bigdecimal/math_r/api/bigdecimal/sign.h +10 -0
  18. data/ext/bigdecimal/math_r/api/bigdecimal/zero.h +6 -0
  19. data/ext/bigdecimal/math_r/api/bigmath/api_call1.h +5 -0
  20. data/ext/bigdecimal/math_r/api/bigmath/api_call2.h +6 -0
  21. data/ext/bigdecimal/math_r/api/bigmath/atan.h +7 -0
  22. data/ext/bigdecimal/math_r/api/bigmath/atan_adopt.h +42 -0
  23. data/ext/bigdecimal/math_r/api/bigmath/cabs.h +5 -0
  24. data/ext/bigdecimal/math_r/api/bigmath/carg.h +5 -0
  25. data/ext/bigdecimal/math_r/api/bigmath/cexp.h +5 -0
  26. data/ext/bigdecimal/math_r/api/bigmath/clog.h +5 -0
  27. data/ext/bigdecimal/math_r/api/bigmath/const.h +39 -0
  28. data/ext/bigdecimal/math_r/api/bigmath/const_e.h +5 -0
  29. data/ext/bigdecimal/math_r/api/bigmath/const_log10.h +5 -0
  30. data/ext/bigdecimal/math_r/api/bigmath/const_log2.h +5 -0
  31. data/ext/bigdecimal/math_r/api/bigmath/const_log_pi.h +5 -0
  32. data/ext/bigdecimal/math_r/api/bigmath/const_pi.h +5 -0
  33. data/ext/bigdecimal/math_r/api/bigmath/const_sqrt2.h +5 -0
  34. data/ext/bigdecimal/math_r/api/bigmath/const_sqrt3.h +5 -0
  35. data/ext/bigdecimal/math_r/api/bigmath/cpow.h +5 -0
  36. data/ext/bigdecimal/math_r/api/bigmath/csqrt.h +5 -0
  37. data/ext/bigdecimal/math_r/api/bigmath/degree_sparg.h +199 -0
  38. data/ext/bigdecimal/math_r/api/bigmath/escalb.h +5 -0
  39. data/ext/bigdecimal/math_r/api/bigmath/exp.h +5 -0
  40. data/ext/bigdecimal/math_r/api/bigmath/expxt.h +18 -0
  41. data/ext/bigdecimal/math_r/api/bigmath/hypot.h +10 -0
  42. data/ext/bigdecimal/math_r/api/bigmath/ipow.h +14 -0
  43. data/ext/bigdecimal/math_r/api/bigmath/l2norm.h +5 -0
  44. data/ext/bigdecimal/math_r/api/bigmath/log.h +7 -0
  45. data/ext/bigdecimal/math_r/api/bigmath/pow.h +5 -0
  46. data/ext/bigdecimal/math_r/api/bigmath/quadrant.h +5 -0
  47. data/ext/bigdecimal/math_r/api/bigmath/sincos.h +5 -0
  48. data/ext/bigdecimal/math_r/api/bigmath/sqrt.h +5 -0
  49. data/ext/bigdecimal/math_r/api/bigmath/to_rad.h +41 -0
  50. data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal.h +6 -0
  51. data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal1.h +6 -0
  52. data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal_flo.h +9 -0
  53. data/ext/bigdecimal/math_r/api/kernel/rb_ImaginaryZ.h +8 -0
  54. data/ext/bigdecimal/math_r/api/numanalysis/condition_p.h +26 -0
  55. data/ext/bigdecimal/math_r/api/numanalysis/make_n.h +9 -0
  56. data/ext/bigdecimal/math_r/api/numeric/abs.h +7 -0
  57. data/ext/bigdecimal/math_r/api/numeric/canonicalize.h +140 -0
  58. data/ext/bigdecimal/math_r/api/numeric/cmpeql.h +6 -0
  59. data/ext/bigdecimal/math_r/api/numeric/equal_p.h +6 -0
  60. data/ext/bigdecimal/math_r/api/numeric/finite_p.h +6 -0
  61. data/ext/bigdecimal/math_r/api/numeric/imag.h +6 -0
  62. data/ext/bigdecimal/math_r/api/numeric/infinite_p.h +7 -0
  63. data/ext/bigdecimal/math_r/api/numeric/nan_p.h +5 -0
  64. data/ext/bigdecimal/math_r/api/numeric/negative_p.h +6 -0
  65. data/ext/bigdecimal/math_r/api/numeric/nonzero_p.h +6 -0
  66. data/ext/bigdecimal/math_r/api/numeric/notequal_p.h +6 -0
  67. data/ext/bigdecimal/math_r/api/numeric/numeric_p.h +5 -0
  68. data/ext/bigdecimal/math_r/api/numeric/positive_p.h +6 -0
  69. data/ext/bigdecimal/math_r/api/numeric/real.h +6 -0
  70. data/ext/bigdecimal/math_r/api/numeric/real_p.h +6 -0
  71. data/ext/bigdecimal/math_r/api/numeric/round.h +56 -0
  72. data/ext/bigdecimal/math_r/api/numeric/uminus.h +6 -0
  73. data/ext/bigdecimal/math_r/api/numeric/zero_p.h +6 -0
  74. data/ext/bigdecimal/math_r/api.c +13 -0
  75. data/ext/bigdecimal/math_r/api.h +69 -0
  76. data/ext/bigdecimal/math_r/const.c +186 -0
  77. data/ext/bigdecimal/math_r/decl.h +203 -0
  78. data/ext/bigdecimal/math_r/edf.c +180 -0
  79. data/ext/bigdecimal/math_r/erf.c +80 -0
  80. data/ext/bigdecimal/math_r/euler_f.c +572 -0
  81. data/ext/bigdecimal/math_r/exp.c +72 -0
  82. data/ext/bigdecimal/math_r/extconf.rb +185 -0
  83. data/ext/bigdecimal/math_r/gamma_r.c +251 -0
  84. data/ext/bigdecimal/math_r/hyperb.c +172 -0
  85. data/ext/bigdecimal/math_r/internal/algo/bigmath/E/ser.h +22 -0
  86. data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG10/ser.h +16 -0
  87. data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG2/BBP2002.h +36 -0
  88. data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG_PI/builtin.h +7 -0
  89. data/ext/bigdecimal/math_r/internal/algo/bigmath/PI/machin.h +48 -0
  90. data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT2/builtin.h +5 -0
  91. data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT3/builtin.h +5 -0
  92. data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/branch.h +25 -0
  93. data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/edom.h +15 -0
  94. data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/logrep.h +19 -0
  95. data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/ser.h +34 -0
  96. data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/branch.h +19 -0
  97. data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/edom.h +17 -0
  98. data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/logrep.h +14 -0
  99. data/ext/bigdecimal/math_r/internal/algo/bigmath/acot/branch.h +16 -0
  100. data/ext/bigdecimal/math_r/internal/algo/bigmath/acot/logrep.h +13 -0
  101. data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/branch.h +20 -0
  102. data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/edom.h +18 -0
  103. data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/logrep.h +33 -0
  104. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/branch.h +21 -0
  105. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/edom.h +20 -0
  106. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/logrep.h +16 -0
  107. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsch/branch.h +25 -0
  108. data/ext/bigdecimal/math_r/internal/algo/bigmath/acsch/logrep.h +25 -0
  109. data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/branch.h +22 -0
  110. data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/edom.h +16 -0
  111. data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/logrep.h +21 -0
  112. data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/branch.h +18 -0
  113. data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/edom.h +19 -0
  114. data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/logrep.h +16 -0
  115. data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/branch.h +22 -0
  116. data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/edom.h +20 -0
  117. data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/logrep.h +15 -0
  118. data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/ser.h +32 -0
  119. data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/branch.h +26 -0
  120. data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/logrep.h +24 -0
  121. data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/ser.h +48 -0
  122. data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/branch.h +16 -0
  123. data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/logrep.h +14 -0
  124. data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/ser_euler.h +84 -0
  125. data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/ser_usual.h +41 -0
  126. data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/branch.h +24 -0
  127. data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/edom.h +16 -0
  128. data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/logrep.h +16 -0
  129. data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/ser.h +33 -0
  130. data/ext/bigdecimal/math_r/internal/algo/bigmath/cabs/formula.h +8 -0
  131. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacos/branch.h +38 -0
  132. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacos/logrep.h +16 -0
  133. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacosh/branch.h +34 -0
  134. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacosh/logrep.h +17 -0
  135. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacot/branch.h +39 -0
  136. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacot/logrep.h +17 -0
  137. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacoth/branch.h +29 -0
  138. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacoth/logrep.h +11 -0
  139. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsc/branch.h +28 -0
  140. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsc/logrep.h +19 -0
  141. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsch/branch.h +18 -0
  142. data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsch/logrep.h +11 -0
  143. data/ext/bigdecimal/math_r/internal/algo/bigmath/carg/formula.h +8 -0
  144. data/ext/bigdecimal/math_r/internal/algo/bigmath/casec/branch.h +29 -0
  145. data/ext/bigdecimal/math_r/internal/algo/bigmath/casec/logrep.h +18 -0
  146. data/ext/bigdecimal/math_r/internal/algo/bigmath/casech/branch.h +38 -0
  147. data/ext/bigdecimal/math_r/internal/algo/bigmath/casech/logrep.h +9 -0
  148. data/ext/bigdecimal/math_r/internal/algo/bigmath/casin/branch.h +35 -0
  149. data/ext/bigdecimal/math_r/internal/algo/bigmath/casin/logrep.h +14 -0
  150. data/ext/bigdecimal/math_r/internal/algo/bigmath/casinh/branch.h +59 -0
  151. data/ext/bigdecimal/math_r/internal/algo/bigmath/casinh/logrep.h +13 -0
  152. data/ext/bigdecimal/math_r/internal/algo/bigmath/catan/branch.h +46 -0
  153. data/ext/bigdecimal/math_r/internal/algo/bigmath/catan/logrep.h +17 -0
  154. data/ext/bigdecimal/math_r/internal/algo/bigmath/catanh/branch.h +26 -0
  155. data/ext/bigdecimal/math_r/internal/algo/bigmath/catanh/logrep.h +10 -0
  156. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccbrt/formula.h +11 -0
  157. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccos/branch.h +41 -0
  158. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccos/eulerf.h +11 -0
  159. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccosh/branch.h +37 -0
  160. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccosh/eulerf.h +11 -0
  161. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccot/branch.h +46 -0
  162. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccot/eulerf.h +11 -0
  163. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccoth/branch.h +43 -0
  164. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccoth/eulerf.h +11 -0
  165. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsc/branch.h +42 -0
  166. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsc/eulerf.h +11 -0
  167. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsch/branch.h +38 -0
  168. data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsch/eulerf.h +11 -0
  169. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp/branch.h +42 -0
  170. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp/eulerf.h +21 -0
  171. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp2/branch.h +42 -0
  172. data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp2/eulerf.h +12 -0
  173. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog/branch.h +54 -0
  174. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog/formula.h +13 -0
  175. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog10/formula.h +12 -0
  176. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog1p/branch.h +34 -0
  177. data/ext/bigdecimal/math_r/internal/algo/bigmath/clog2/formula.h +12 -0
  178. data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/branch.h +21 -0
  179. data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/eulerf.h +11 -0
  180. data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/ser.h +12 -0
  181. data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/branch.h +22 -0
  182. data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/eulerf.h +11 -0
  183. data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/formula.h +30 -0
  184. data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/ser.h +11 -0
  185. data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/branch.h +28 -0
  186. data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/eulerf.h +11 -0
  187. data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/ser.h +12 -0
  188. data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/branch.h +23 -0
  189. data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/eulerf.h +11 -0
  190. data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/formula.h +30 -0
  191. data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/ser.h +13 -0
  192. data/ext/bigdecimal/math_r/internal/algo/bigmath/cpow/formula.h +20 -0
  193. data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/branch.h +28 -0
  194. data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/eulerf.h +11 -0
  195. data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/ser.h +11 -0
  196. data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/branch.h +23 -0
  197. data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/eulerf.h +11 -0
  198. data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/formula.h +31 -0
  199. data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/ser.h +11 -0
  200. data/ext/bigdecimal/math_r/internal/algo/bigmath/csec/branch.h +42 -0
  201. data/ext/bigdecimal/math_r/internal/algo/bigmath/csec/eulerf.h +11 -0
  202. data/ext/bigdecimal/math_r/internal/algo/bigmath/csech/branch.h +38 -0
  203. data/ext/bigdecimal/math_r/internal/algo/bigmath/csech/eulerf.h +11 -0
  204. data/ext/bigdecimal/math_r/internal/algo/bigmath/csin/branch.h +44 -0
  205. data/ext/bigdecimal/math_r/internal/algo/bigmath/csin/eulerf.h +11 -0
  206. data/ext/bigdecimal/math_r/internal/algo/bigmath/csinh/branch.h +41 -0
  207. data/ext/bigdecimal/math_r/internal/algo/bigmath/csinh/eulerf.h +11 -0
  208. data/ext/bigdecimal/math_r/internal/algo/bigmath/csqrt/formula.h +66 -0
  209. data/ext/bigdecimal/math_r/internal/algo/bigmath/ctan/branch.h +46 -0
  210. data/ext/bigdecimal/math_r/internal/algo/bigmath/ctan/eulerf.h +11 -0
  211. data/ext/bigdecimal/math_r/internal/algo/bigmath/ctanh/branch.h +43 -0
  212. data/ext/bigdecimal/math_r/internal/algo/bigmath/ctanh/eulerf.h +11 -0
  213. data/ext/bigdecimal/math_r/internal/algo/bigmath/cuberoot/newton.h +42 -0
  214. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/algo911.h +41 -0
  215. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/branch.h +18 -0
  216. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/cf.h +51 -0
  217. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_inf.h +53 -0
  218. data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_zero.h +45 -0
  219. data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/algo911.h +27 -0
  220. data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/branch.h +18 -0
  221. data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/cf.h +49 -0
  222. data/ext/bigdecimal/math_r/internal/algo/bigmath/escalb/edf.h +87 -0
  223. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/branch.h +29 -0
  224. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/builtin.h +6 -0
  225. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/edf.h +23 -0
  226. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp2/branch.h +29 -0
  227. data/ext/bigdecimal/math_r/internal/algo/bigmath/exp2/edf.h +19 -0
  228. data/ext/bigdecimal/math_r/internal/algo/bigmath/expxt/edf.h +31 -0
  229. data/ext/bigdecimal/math_r/internal/algo/bigmath/f_euler/formula.h +11 -0
  230. data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/branch.h +25 -0
  231. data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/l2norm.h +11 -0
  232. data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/mmm.h +38 -0
  233. data/ext/bigdecimal/math_r/internal/algo/bigmath/ipow/edf.h +33 -0
  234. data/ext/bigdecimal/math_r/internal/algo/bigmath/l2norm/formula.h +48 -0
  235. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/branch.h +40 -0
  236. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/builtin.h +12 -0
  237. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edf.h +10 -0
  238. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edom.h +10 -0
  239. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/mercator.h +34 -0
  240. data/ext/bigdecimal/math_r/internal/algo/bigmath/log/ser_okumura.h +57 -0
  241. data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/branch.h +40 -0
  242. data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/edf.h +11 -0
  243. data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/mercator.h +35 -0
  244. data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/branch.h +34 -0
  245. data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/p_adic.h +37 -0
  246. data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/ser_mercator.h +35 -0
  247. data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/branch.h +40 -0
  248. data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/edf.h +11 -0
  249. data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/mercator.h +35 -0
  250. data/ext/bigdecimal/math_r/internal/algo/bigmath/logxt/edf.h +33 -0
  251. data/ext/bigdecimal/math_r/internal/algo/bigmath/pow/formula.h +30 -0
  252. data/ext/bigdecimal/math_r/internal/algo/bigmath/quadrant/formula.h +352 -0
  253. data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm10/edf.h +34 -0
  254. data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm2/edf.h +34 -0
  255. data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/branch.h +27 -0
  256. data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/eulerf.h +11 -0
  257. data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/ser.h +11 -0
  258. data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/branch.h +21 -0
  259. data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/eulerf.h +11 -0
  260. data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/formula.h +25 -0
  261. data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/ser.h +11 -0
  262. data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/branch.h +23 -0
  263. data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/eulerf.h +11 -0
  264. data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/ser.h +13 -0
  265. data/ext/bigdecimal/math_r/internal/algo/bigmath/sincos/ser.h +50 -0
  266. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/branch.h +23 -0
  267. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/eulerf.h +11 -0
  268. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/formula.h +26 -0
  269. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/ser.h +11 -0
  270. data/ext/bigdecimal/math_r/internal/algo/bigmath/sinhcosh/ser.h +70 -0
  271. data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/branch.h +16 -0
  272. data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/builtin.h +12 -0
  273. data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/edom.h +9 -0
  274. data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/newton.h +36 -0
  275. data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/branch.h +26 -0
  276. data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/eulerf.h +11 -0
  277. data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/ser.h +18 -0
  278. data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/branch.h +23 -0
  279. data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/eulerf.h +11 -0
  280. data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/formula.h +27 -0
  281. data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/ser.h +14 -0
  282. data/ext/bigdecimal/math_r/internal/algo/bigmath/trig/f_euler.h +290 -0
  283. data/ext/bigdecimal/math_r/log.c +256 -0
  284. data/ext/bigdecimal/math_r/logrep.c +537 -0
  285. data/ext/bigdecimal/math_r/math_r/bigdecimal.h +30 -0
  286. data/ext/bigdecimal/math_r/math_r/bigmath.h +61 -0
  287. data/ext/bigdecimal/math_r/math_r/bigmath_r.h +9 -0
  288. data/ext/bigdecimal/math_r/math_r/ext_extern.h +18 -0
  289. data/ext/bigdecimal/math_r/math_r/globals.h +71 -0
  290. data/ext/bigdecimal/math_r/math_r/numdiff.h +18 -0
  291. data/ext/bigdecimal/math_r/math_r/numeric.h +63 -0
  292. data/ext/bigdecimal/math_r/math_r.c +130 -0
  293. data/ext/bigdecimal/math_r/nucomp.c +158 -0
  294. data/ext/bigdecimal/math_r/overrides.c +91 -0
  295. data/ext/bigdecimal/math_r/power.c +207 -0
  296. data/ext/bigdecimal/math_r/solver.c +1516 -0
  297. data/ext/bigdecimal/math_r/trig.c +205 -0
  298. data/lib/bigdecimal/math_r/const/EulerGamma_engel.rb +46 -0
  299. data/lib/bigdecimal/math_r/const/LOG2_bbp2007.rb +39 -0
  300. data/lib/bigdecimal/math_r/const/PI_chudnovsky.rb +59 -0
  301. data/lib/bigdecimal/math_r/const/PI_euler.rb +40 -0
  302. data/lib/bigdecimal/math_r/const/PI_ramanujan1.rb +45 -0
  303. data/lib/bigdecimal/math_r/const/PI_ramanujan2.rb +46 -0
  304. data/lib/bigdecimal/math_r/const/b053977/b053977.txt +306 -0
  305. data/lib/bigdecimal/math_r/version.rb +7 -0
  306. data/lib/bigdecimal/math_r.rb +12 -0
  307. data/lib/bigdecimal/math_r.so +0 -0
  308. data/sig/bigdecimal/math_r.rbs +6 -0
  309. metadata +393 -0
@@ -0,0 +1,1516 @@
1
+ /*******************************************************************************
2
+ solver.c -- BigMathR::Solver
3
+
4
+ Author: tribusonz
5
+ Licence: MIT
6
+ *******************************************************************************/
7
+ #include <ruby.h>
8
+ #include "math_r/globals.h"
9
+ #include "math_r/bigmath_r.h"
10
+ #include "decl.h"
11
+
12
+ bigmath_func1 cb_exp;
13
+ bigmath_func1 cb_cexp;
14
+ bigmath_func1 cb_exp2;
15
+ bigmath_func1 cb_cexp2;
16
+ bigmath_func1 cb_log;
17
+ bigmath_func1 cb_clog;
18
+ bigmath_func1 cb_log2;
19
+ bigmath_func1 cb_clog2;
20
+ bigmath_func1 cb_log10;
21
+ bigmath_func1 cb_clog10;
22
+ bigmath_func1 cb_log1p;
23
+ bigmath_func1 cb_clog1p;
24
+
25
+ bigmath_func1 cb_sin;
26
+ bigmath_func1 cb_csin;
27
+ bigmath_func1 cb_cos;
28
+ bigmath_func1 cb_ccos;
29
+ bigmath_func1 cb_tan;
30
+ bigmath_func1 cb_ctan;
31
+ bigmath_func1 cb_csc;
32
+ bigmath_func1 cb_ccsc;
33
+ bigmath_func1 cb_sec;
34
+ bigmath_func1 cb_csec;
35
+ bigmath_func1 cb_cot;
36
+ bigmath_func1 cb_ccot;
37
+
38
+ bigmath_func1 cb_asin;
39
+ bigmath_func1 cb_casin;
40
+ bigmath_func1 cb_acos;
41
+ bigmath_func1 cb_cacos;
42
+ bigmath_func1 cb_atan;
43
+ bigmath_func1 cb_catan;
44
+ bigmath_func1 cb_acsc;
45
+ bigmath_func1 cb_cacsc;
46
+ bigmath_func1 cb_asec;
47
+ bigmath_func1 cb_casec;
48
+ bigmath_func1 cb_acot;
49
+ bigmath_func1 cb_cacot;
50
+
51
+ bigmath_func1 cb_sinh;
52
+ bigmath_func1 cb_csinh;
53
+ bigmath_func1 cb_cosh;
54
+ bigmath_func1 cb_ccosh;
55
+ bigmath_func1 cb_tanh;
56
+ bigmath_func1 cb_ctanh;
57
+ bigmath_func1 cb_csch;
58
+ bigmath_func1 cb_ccsch;
59
+ bigmath_func1 cb_sech;
60
+ bigmath_func1 cb_csech;
61
+ bigmath_func1 cb_coth;
62
+ bigmath_func1 cb_ccoth;
63
+
64
+ bigmath_func1 cb_asinh;
65
+ bigmath_func1 cb_casinh;
66
+ bigmath_func1 cb_acosh;
67
+ bigmath_func1 cb_cacosh;
68
+ bigmath_func1 cb_atanh;
69
+ bigmath_func1 cb_catanh;
70
+ bigmath_func1 cb_acsch;
71
+ bigmath_func1 cb_cacsch;
72
+ bigmath_func1 cb_asech;
73
+ bigmath_func1 cb_casech;
74
+ bigmath_func1 cb_acoth;
75
+ bigmath_func1 cb_cacoth;
76
+
77
+
78
+
79
+ static bool
80
+ domain_p(VALUE range, VALUE x)
81
+ {
82
+ const ID cover_p = rb_intern("cover?");
83
+ VALUE ans = rb_funcall(range, cover_p, 1, x);
84
+ return ans == Qtrue ? true : false;
85
+ }
86
+
87
+ static void
88
+ rb_id_includes(int n, const ID *funcs, ID func)
89
+ {
90
+ bool func_match = false;
91
+ for (int i = 0; i < n; i++)
92
+ {
93
+ if (funcs[i] == func)
94
+ {
95
+ func_match = true;
96
+ break;
97
+ }
98
+ }
99
+ if (!func_match)
100
+ rb_raise(rb_eArgError,
101
+ "no includes function: %"PRIsVALUE"", ID2SYM(func));
102
+ }
103
+
104
+ #define CHECK_NUMARG(x) \
105
+ if (!rb_num_numeric_p(x)) {\
106
+ VALUE self; \
107
+ switch(TYPE(x)) { \
108
+ case T_NIL: case T_TRUE: case T_FALSE: \
109
+ self = rb_inspect(x); \
110
+ break; \
111
+ default: \
112
+ self = CLASS_OF(x); \
113
+ break; \
114
+ } \
115
+ rb_raise(rb_eTypeError, \
116
+ "can't convert %"PRIsVALUE" into Numeric", self); \
117
+ }
118
+
119
+
120
+ static VALUE
121
+ solver_exp(ID func, VALUE z, VALUE prec)
122
+ {
123
+ const ID funcs[4] = { mf_exp, mf_exp2 };
124
+ VALUE w = Qundef;
125
+ rb_id_includes(2, funcs, func);
126
+ CHECK_NUMARG(z);
127
+ rb_check_precise(prec);
128
+ if (!rb_num_finite_p(z))
129
+ {
130
+ if (func == mf_exp)
131
+ w = cexp_branch(z, prec, cb_cexp);
132
+ else if (func == mf_exp2)
133
+ w = cexp2_branch(z, prec, cb_cexp2);
134
+ if (rb_num_real_p(z) && rb_num_positive_p(z))
135
+ w = rb_num_real(w);
136
+ }
137
+ if (w == Qundef)
138
+ {
139
+ VALUE r = Qundef, theta = Qundef;
140
+ // Real
141
+ {
142
+ if (func == mf_exp)
143
+ r = exp_branch(rb_num_real(z), prec, cb_exp);
144
+ else if (func == mf_exp2)
145
+ r = exp2_branch(rb_num_real(z), prec, cb_exp2);
146
+ }
147
+ // Imaginary
148
+ {
149
+ VALUE t, v_sin, v_cos;
150
+ theta = rb_num_imag(z);
151
+ if (func == mf_exp2)
152
+ {
153
+ theta = rb_funcall1(theta, '*', rb_bigmath_const_log2(prec));
154
+ }
155
+ theta = rb_bigmath_to_rad(theta, prec, &t);
156
+ if (-1 == rb_bigmath_degree_sparg(t, prec, &v_sin, &v_cos))
157
+ rb_bigmath_sincos(theta, prec, &v_sin, &v_cos);
158
+ theta = rb_Complex(v_cos, v_sin);
159
+ }
160
+ w = rb_funcall1(r, '*', theta); w = rb_num_round(w, prec);
161
+ }
162
+ return w;
163
+
164
+ }
165
+
166
+ /**
167
+ * This is a public API for exponential solver.
168
+ *
169
+ * @param func [Symbol] The name of the target function. [:exp, :exp2]
170
+ * @param z [Numeric] Numerical argument
171
+ * @param prec [Integer] Arbitrary precision
172
+ * @return [BigDecimal] Real solution
173
+ * @return [Complex] Complex solution
174
+ * @raise [ArgumentError] Target function name no match found.
175
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
176
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
177
+ */
178
+ static VALUE
179
+ __impl_solver_exp(VALUE unused_obj, VALUE func, VALUE z, VALUE prec)
180
+ {
181
+ return solver_exp(SYM2ID(func), z, prec);
182
+ }
183
+
184
+ /**
185
+ * Computes exponential function of +z+.
186
+ *
187
+ * @param z [Numeric] Numerical argument
188
+ * @param prec [Integer] Arbitrary precision
189
+ * @return [BigDecimal] Real solution
190
+ * @return [Complex] Complex solution
191
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
192
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
193
+ * @since 0.1.0
194
+ */
195
+ static VALUE
196
+ __impl_bigmath_exp(VALUE unused_obj, VALUE z, VALUE prec)
197
+ {
198
+ return solver_exp(mf_exp, z, prec);
199
+ }
200
+
201
+ /**
202
+ * Computes base-2 (binary) exponent of +z+.
203
+ *
204
+ * @param z [Numeric] Numerical argument
205
+ * @param prec [Integer] Arbitrary precision
206
+ * @return [BigDecimal] Real solution
207
+ * @return [Complex] Complex solution
208
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
209
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
210
+ * @since 0.1.0
211
+ */
212
+ static VALUE
213
+ __impl_bigmath_exp2(VALUE unused_obj, VALUE z, VALUE prec)
214
+ {
215
+ return solver_exp(mf_exp2, z, prec);
216
+ }
217
+
218
+
219
+ static VALUE
220
+ solver_log(ID func, VALUE z, VALUE prec)
221
+ {
222
+ const ID funcs[4] = { mf_log, mf_log2, mf_log10, mf_log1p };
223
+ VALUE w = Qundef;
224
+ rb_id_includes(4, funcs, func);
225
+ CHECK_NUMARG(z);
226
+ rb_check_precise(prec);
227
+ if (!rb_num_finite_p(z))
228
+ {
229
+ if (func == mf_log)
230
+ w = clog_branch(z, prec, cb_clog);
231
+ else if (func == mf_log1p)
232
+ w = clog1p_branch(z, prec, cb_clog1p);
233
+ else if (func == mf_log2)
234
+ w = clog_branch(z, prec, cb_clog2);
235
+ else if (func == mf_log10)
236
+ w = clog_branch(z, prec, cb_clog10);
237
+ if (rb_num_real_p(z) && rb_num_positive_p(z))
238
+ w = rb_num_real(w);
239
+ }
240
+ if (w == Qundef)
241
+ {
242
+ if (rb_num_real_p(z) && !rb_num_negative_p(z))
243
+ {
244
+ if (func == mf_log)
245
+ w = log_branch(z, prec, cb_log);
246
+ else if (func == mf_log1p)
247
+ w = log1p_branch(z, prec, cb_log1p);
248
+ else if (func == mf_log2)
249
+ w = log2_branch(z, prec, cb_log2);
250
+ else if (func == mf_log10)
251
+ w = log10_branch(z, prec, cb_log10);
252
+ }
253
+ else
254
+ {
255
+ if (func == mf_log)
256
+ w = clog_branch(z, prec, cb_clog);
257
+ else if (func == mf_log1p)
258
+ w = clog1p_branch(z, prec, cb_clog1p);
259
+ else if (func == mf_log2)
260
+ w = clog_branch(z, prec, cb_clog2);
261
+ else if (func == mf_log10)
262
+ w = clog_branch(z, prec, cb_clog10);
263
+ }
264
+ }
265
+ return w;
266
+ }
267
+
268
+ /**
269
+ * This is a public API for logarithmic solver.
270
+ *
271
+ * @param func [Symbol] The name of the target function. [:log, :log1p, :log2, :log10]
272
+ * @param z [Numeric] Numerical argument
273
+ * @param prec [Integer] Arbitrary precision
274
+ * @return [BigDecimal] Real solution
275
+ * @return [Complex] Complex solution
276
+ * @raise [ArgumentError] Target function name no match found.
277
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
278
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
279
+ */
280
+ static VALUE
281
+ __impl_solver_log(VALUE unused_obj, VALUE func, VALUE z, VALUE prec)
282
+ {
283
+ return solver_log(SYM2ID(func), z, prec);
284
+ }
285
+
286
+ /**
287
+ * @overload log(z, prec)
288
+ * Computes the Natural logarithm of +z+.
289
+
290
+ * @param z [Numeric] Numerical argument
291
+ * @param prec [Integer] Arbitrary precision
292
+ * @return [BigDecimal] Real solution
293
+ * @return [Complex] Complex solution
294
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
295
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
296
+ * @since 0.1.0
297
+ * @overload log(z, b, prec)
298
+ * Computes the Natural logarithm of +z+ on base +b+.
299
+ *
300
+ * @param z [Numeric] Numerical argument
301
+ * @param b [Numeric] The base. Specified a real number
302
+ * @param prec [Integer] Arbitrary precision
303
+ * @return [BigDecimal] Real solution
304
+ * @return [Complex] Complex solution
305
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
306
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
307
+ * @since 0.1.0
308
+ */
309
+ static VALUE
310
+ __impl_bigmath_log(int argc, VALUE *argv, VALUE unused_obj)
311
+ {
312
+ VALUE z = Qundef, b = Qundef, prec = Qundef;
313
+ rb_check_arity(argc, 2, 3);
314
+ switch (argc) {
315
+ case 2:
316
+ rb_scan_args(argc, argv, "20", &z, &prec);
317
+ z = solver_log(mf_log, z, prec);
318
+ break;
319
+ case 3:
320
+ rb_scan_args(argc, argv, "30", &z, &b, &prec);
321
+
322
+ rb_check_precise(prec);
323
+ CHECK_NUMARG(z);
324
+ b = rb_num_canonicalize(b, prec, ARG_REAL, ARG_RAWVALUE);
325
+ if (rb_num_nan_p(b))
326
+ z = rb_num_real_p(z) && !rb_num_negative_p(z) ?
327
+ BIG_NAN : rb_Complex(BIG_NAN, BIG_NAN);
328
+ else if (rb_num_infinite_p(b))
329
+ z = rb_num_real_p(z) && !rb_num_negative_p(z) ?
330
+ BIG_ZERO : rb_Complex(BIG_ZERO, BIG_ZERO);
331
+ else if (rb_num_zero_p(b))
332
+ z = rb_num_zero_p(z) ?
333
+ rb_num_real_p(z) ?
334
+ BIG_NAN :
335
+ rb_Complex(BIG_NAN, BIG_NAN) :
336
+ rb_num_real_p(z) && !rb_num_negative_p(z) ?
337
+ BIG_ZERO :
338
+ rb_Complex(BIG_ZERO, BIG_ZERO);
339
+ else if (rb_num_equal_p(b, BIG_ONE))
340
+ z = rb_Complex(BIG_INF, BIG_INF);
341
+ else
342
+ {
343
+ z = solver_log(mf_log, z, prec);
344
+ b = solver_log(mf_log, b, prec);
345
+ z = rb_funcall1(z, '/', b);
346
+ z = rb_num_round(z, prec);
347
+ }
348
+ break;
349
+ }
350
+ return z;
351
+ }
352
+
353
+ /**
354
+ * Computes natural logarithm of 1 plus +z+.
355
+ *
356
+ * @param z [Numeric] Numerical argument
357
+ * @param prec [Integer] Arbitrary precision
358
+ * @return [BigDecimal] Real solution
359
+ * @return [Complex] Complex solution
360
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
361
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
362
+ * @since 0.1.0
363
+ */
364
+ static VALUE
365
+ __impl_bigmath_log1p(VALUE unused_obj, VALUE z, VALUE prec)
366
+ {
367
+ return solver_log(mf_log1p, z, prec);
368
+ }
369
+
370
+ /**
371
+ * Computes binary logarithm of +z+.
372
+ *
373
+ * @param z [Numeric] Numerical argument
374
+ * @param prec [Integer] Arbitrary precision
375
+ * @return [BigDecimal] Real solution
376
+ * @return [Complex] Complex solution
377
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
378
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
379
+ * @since 0.1.0
380
+ */
381
+ static VALUE
382
+ __impl_bigmath_log2(VALUE unused_obj, VALUE z, VALUE prec)
383
+ {
384
+ return solver_log(mf_log2, z, prec);
385
+ }
386
+
387
+ /**
388
+ * Computes common logarithm of +z+.
389
+ *
390
+ * @param z [Numeric] Numerical argument
391
+ * @param prec [Integer] Arbitrary precision
392
+ * @return [BigDecimal] Real solution
393
+ * @return [Complex] Complex solution
394
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
395
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
396
+ * @since 0.1.0
397
+ */
398
+ static VALUE
399
+ __impl_bigmath_log10(VALUE unused_obj, VALUE z, VALUE prec)
400
+ {
401
+ return solver_log(mf_log10, z, prec);
402
+ }
403
+
404
+ static VALUE
405
+ solver_trig(ID func, VALUE z, VALUE prec)
406
+ {
407
+ const ID funcs[6] = { mf_sin, mf_cos, mf_tan, mf_csc, mf_sec, mf_cot };
408
+ VALUE w = Qundef;
409
+ rb_id_includes(6, funcs, func);
410
+ CHECK_NUMARG(z);
411
+ rb_check_precise(prec);
412
+
413
+ if (!rb_num_finite_p(z))
414
+ {
415
+ if (func == mf_sin)
416
+ w = csin_branch(z, prec, cb_csin);
417
+ else if (func == mf_cos)
418
+ w = ccos_branch(z, prec, cb_ccos);
419
+ else if (func == mf_tan)
420
+ w = ctan_branch(z, prec, cb_ctan);
421
+ else if (func == mf_csc)
422
+ w = ccsc_branch(z, prec, cb_ccsc);
423
+ else if (func == mf_sec)
424
+ w = csec_branch(z, prec, cb_csec);
425
+ else if (func == mf_cot)
426
+ w = ccot_branch(z, prec, cb_ccot);
427
+ }
428
+ if (w == Qundef)
429
+ {
430
+ if (rb_num_real_p(z) || rb_num_zero_p(rb_num_imag(z)))
431
+ {
432
+ if (func == mf_sin)
433
+ w = sin_branch(z, prec, cb_sin);
434
+ else if (func == mf_cos)
435
+ w = cos_branch(z, prec, cb_cos);
436
+ else if (func == mf_tan)
437
+ w = tan_branch(z, prec, cb_tan);
438
+ else if (func == mf_csc)
439
+ w = csc_branch(z, prec, cb_csc);
440
+ else if (func == mf_sec)
441
+ w = sec_branch(z, prec, cb_sec);
442
+ else if (func == mf_cot)
443
+ w = cot_branch(z, prec, cb_cot);
444
+ }
445
+ else if (rb_num_real_p(z) || rb_num_zero_p(rb_num_real(z)))
446
+ {
447
+ if (func == mf_sin)
448
+ {
449
+ w = sinh_branch(rb_num_imag(z), prec, cb_sinh);
450
+ w = rb_ImaginaryZ(w, SIGN_PLUS);
451
+ }
452
+ else if (func == mf_cos)
453
+ {
454
+ w = cosh_branch(rb_num_imag(z), prec, cb_cosh);
455
+ w = rb_Complex(w, BIG_ZERO);
456
+ }
457
+ else if (func == mf_tan)
458
+ {
459
+ w = tanh_branch(rb_num_imag(z), prec, cb_tanh);
460
+ w = rb_ImaginaryZ(w, SIGN_PLUS);
461
+ }
462
+ else if (func == mf_csc)
463
+ {
464
+ w = csch_branch(rb_num_imag(z), prec, cb_csch);
465
+ w = rb_ImaginaryZ(w, SIGN_MINUS);
466
+ }
467
+ else if (func == mf_sec)
468
+ {
469
+ w = sech_branch(z, prec, cb_sech);
470
+ w = rb_Complex(w, BIG_ZERO);
471
+ }
472
+ else if (func == mf_cot)
473
+ {
474
+ w = coth_branch(z, prec, cb_coth);
475
+ w = rb_ImaginaryZ(w, SIGN_MINUS);
476
+ }
477
+ if (rb_num_real(z))
478
+ w = rb_Complex(w, BIG_ZERO);
479
+ }
480
+ else
481
+ {
482
+ if (func == mf_sin)
483
+ w = csin_branch(z, prec, cb_csin);
484
+ else if (func == mf_cos)
485
+ w = ccos_branch(z, prec, cb_ccos);
486
+ else if (func == mf_tan)
487
+ w = ctan_branch(z, prec, cb_ctan);
488
+ else if (func == mf_csc)
489
+ w = ccsc_branch(z, prec, cb_ccsc);
490
+ else if (func == mf_sec)
491
+ w = csec_branch(z, prec, cb_csec);
492
+ else if (func == mf_cot)
493
+ w = ccot_branch(z, prec, cb_ccot);
494
+ }
495
+ }
496
+ if (rb_num_real(z) && rb_num_zero_p(rb_num_imag(z)))
497
+ w = rb_num_real(w);
498
+ return w;
499
+ }
500
+
501
+ /**
502
+ * This is a public API for trigonometric solver.
503
+ *
504
+ * @param func [Symbol] The name of the target function. [:sin, :cos, :tan, :csc, :sec, :cot]
505
+ * @param z [Numeric] Numerical argument
506
+ * @param prec [Integer] Arbitrary precision
507
+ * @return [BigDecimal] Real solution
508
+ * @return [Complex] Complex solution
509
+ * @raise [ArgumentError] Target function name no match found.
510
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
511
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
512
+ */
513
+ static VALUE
514
+ __impl_solver_trig(VALUE unused_obj, VALUE func, VALUE z, VALUE prec)
515
+ {
516
+ return solver_trig(SYM2ID(func), z, prec);
517
+ }
518
+
519
+ /**
520
+ * Computes sine of +z+.
521
+ *
522
+ * @param z [Numeric] Numerical argument
523
+ * @param prec [Integer] Arbitrary precision
524
+ * @return [BigDecimal] Real solution
525
+ * @return [Complex] Complex solution
526
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
527
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
528
+ * @since 0.1.0
529
+ */
530
+ static VALUE
531
+ __impl_bigmath_sin(VALUE unused_obj, VALUE z, VALUE prec)
532
+ {
533
+ return solver_trig(mf_sin, z, prec);
534
+ }
535
+
536
+ /**
537
+ * Computes cosine of +z+.
538
+ *
539
+ * @param z [Numeric] Numerical argument
540
+ * @param prec [Integer] Arbitrary precision
541
+ * @return [BigDecimal] Real solution
542
+ * @return [Complex] Complex solution
543
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
544
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
545
+ * @since 0.1.0
546
+ */
547
+ static VALUE
548
+ __impl_bigmath_cos(VALUE unused_obj, VALUE z, VALUE prec)
549
+ {
550
+ return solver_trig(mf_cos, z, prec);
551
+ }
552
+
553
+ /**
554
+ * Computes tangent of +z+.
555
+ *
556
+ * @param z [Numeric] Numerical argument
557
+ * @param prec [Integer] Arbitrary precision
558
+ * @return [BigDecimal] Real solution
559
+ * @return [Complex] Complex solution
560
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
561
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
562
+ * @since 0.1.0
563
+ */
564
+ static VALUE
565
+ __impl_bigmath_tan(VALUE unused_obj, VALUE z, VALUE prec)
566
+ {
567
+ return solver_trig(mf_tan, z, prec);
568
+ }
569
+
570
+ /**
571
+ * Computes cosecant of +z+.
572
+ *
573
+ * @param z [Numeric] Numerical argument
574
+ * @param prec [Integer] Arbitrary precision
575
+ * @return [BigDecimal] Real solution
576
+ * @return [Complex] Complex solution
577
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
578
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
579
+ * @since 0.1.0
580
+ */
581
+ static VALUE
582
+ __impl_bigmath_csc(VALUE unused_obj, VALUE z, VALUE prec)
583
+ {
584
+ return solver_trig(mf_csc, z, prec);
585
+ }
586
+
587
+ /**
588
+ * Computes secant of +z+.
589
+ *
590
+ * @param z [Numeric] Numerical argument
591
+ * @param prec [Integer] Arbitrary precision
592
+ * @return [BigDecimal] Real solution
593
+ * @return [Complex] Complex solution
594
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
595
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
596
+ * @since 0.1.0
597
+ */
598
+ static VALUE
599
+ __impl_bigmath_sec(VALUE unused_obj, VALUE z, VALUE prec)
600
+ {
601
+ return solver_trig(mf_sec, z, prec);
602
+ }
603
+
604
+ /**
605
+ * Computes cotangent of +z+.
606
+ *
607
+ * @param z [Numeric] Numerical argument
608
+ * @param prec [Integer] Arbitrary precision
609
+ * @return [BigDecimal] Real solution
610
+ * @return [Complex] Complex solution
611
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
612
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
613
+ * @since 0.1.0
614
+ */
615
+ static VALUE
616
+ __impl_bigmath_cot(VALUE unused_obj, VALUE z, VALUE prec)
617
+ {
618
+ return solver_trig(mf_cot, z, prec);
619
+ }
620
+
621
+ static VALUE
622
+ solver_hyperb(ID func, VALUE z, VALUE prec)
623
+ {
624
+ const ID funcs[6] = { mf_sinh, mf_cosh, mf_tanh, mf_csch, mf_sech, mf_coth };
625
+ VALUE w = Qundef;
626
+ rb_id_includes(6, funcs, func);
627
+ CHECK_NUMARG(z);
628
+ rb_check_precise(prec);
629
+
630
+ if (!rb_num_finite_p(z))
631
+ {
632
+ if (func == mf_sinh)
633
+ w = csinh_branch(z, prec, cb_csinh);
634
+ else if (func == mf_cosh)
635
+ w = ccosh_branch(z, prec, cb_ccosh);
636
+ else if (func == mf_tanh)
637
+ w = ctanh_branch(z, prec, cb_ctanh);
638
+ else if (func == mf_csch)
639
+ w = ccsch_branch(z, prec, cb_ccsch);
640
+ else if (func == mf_sech)
641
+ w = csech_branch(z, prec, cb_csech);
642
+ else if (func == mf_coth)
643
+ w = ccoth_branch(z, prec, cb_ccoth);
644
+ }
645
+ if (w == Qundef)
646
+ {
647
+ if (rb_num_real_p(z) || rb_num_zero_p(rb_num_imag(z)))
648
+ {
649
+ if (func == mf_sinh)
650
+ w = sinh_branch(z, prec, cb_sinh);
651
+ else if (func == mf_cosh)
652
+ w = cosh_branch(z, prec, cb_cosh);
653
+ else if (func == mf_tanh)
654
+ w = tanh_branch(z, prec, cb_tanh);
655
+ else if (func == mf_csch)
656
+ w = csch_branch(z, prec, cb_csch);
657
+ else if (func == mf_sech)
658
+ w = sech_branch(z, prec, cb_sech);
659
+ else if (func == mf_coth)
660
+ w = coth_branch(z, prec, cb_coth);
661
+ }
662
+ else if (rb_num_real_p(z) || rb_num_zero_p(rb_num_real(z)))
663
+ {
664
+ if (func == mf_sinh)
665
+ {
666
+ w = sin_branch(rb_num_imag(z), prec, cb_sin);
667
+ w = rb_ImaginaryZ(w, SIGN_PLUS);
668
+ }
669
+ else if (func == mf_cosh)
670
+ {
671
+ w = cos_branch(rb_num_imag(z), prec, cb_cos);
672
+ w = rb_Complex(w, BIG_ZERO);
673
+ }
674
+ else if (func == mf_tanh)
675
+ {
676
+ w = tan_branch(rb_num_imag(z), prec, cb_tan);
677
+ w = rb_ImaginaryZ(w, SIGN_PLUS);
678
+ }
679
+ else if (func == mf_csch)
680
+ {
681
+ w = csc_branch(rb_num_imag(z), prec, cb_csc);
682
+ w = rb_ImaginaryZ(w, SIGN_MINUS);
683
+ }
684
+ else if (func == mf_sech)
685
+ {
686
+ w = sec_branch(z, prec, cb_sec);
687
+ w = rb_Complex(w, BIG_ZERO);
688
+ }
689
+ else if (func == mf_coth)
690
+ {
691
+ w = cot_branch(z, prec, cb_cot);
692
+ w = rb_ImaginaryZ(w, SIGN_MINUS);
693
+ }
694
+ if (rb_num_real(z))
695
+ w = rb_Complex(w, BIG_ZERO);
696
+ }
697
+ else
698
+ {
699
+ if (func == mf_sinh)
700
+ w = csinh_branch(z, prec, cb_csinh);
701
+ else if (func == mf_cosh)
702
+ w = ccosh_branch(z, prec, cb_ccosh);
703
+ else if (func == mf_tanh)
704
+ w = ctanh_branch(z, prec, cb_ctanh);
705
+ else if (func == mf_csch)
706
+ w = ccsch_branch(z, prec, cb_ccsch);
707
+ else if (func == mf_sech)
708
+ w = csech_branch(z, prec, cb_csech);
709
+ else if (func == mf_coth)
710
+ w = ccoth_branch(z, prec, cb_ccoth);
711
+ }
712
+ }
713
+ if (rb_num_real(z) && rb_num_zero_p(rb_num_imag(z)))
714
+ w = rb_num_real(w);
715
+ return w;
716
+ }
717
+
718
+ /**
719
+ * This is a public API for hyperbolic solver.
720
+ *
721
+ * @param func [Symbol] The name of the target function. [:sinh, :cosh, :tanh, :csch, :sech, :coth]
722
+ * @param z [Numeric] Numerical argument
723
+ * @param prec [Integer] Arbitrary precision
724
+ * @return [BigDecimal] Real solution
725
+ * @return [Complex] Complex solution
726
+ * @raise [ArgumentError] Target function name no match found.
727
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
728
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
729
+ */
730
+ static VALUE
731
+ __impl_solver_hyperb(VALUE unused_obj, VALUE func, VALUE z, VALUE prec)
732
+ {
733
+ return solver_hyperb(SYM2ID(func), z, prec);
734
+ }
735
+
736
+ /**
737
+ * Computes hyperbolic sine of +z+.
738
+ *
739
+ * @param z [Numeric] Numerical argument
740
+ * @param prec [Integer] Arbitrary precision
741
+ * @return [BigDecimal] Real solution
742
+ * @return [Complex] Complex solution
743
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
744
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
745
+ * @since 0.1.0
746
+ */
747
+ static VALUE
748
+ __impl_bigmath_sinh(VALUE unused_obj, VALUE z, VALUE prec)
749
+ {
750
+ return solver_hyperb(mf_sinh, z, prec);
751
+ }
752
+
753
+ /**
754
+ * Computes hyperbolic cosine of +z+.
755
+ *
756
+ * @param z [Numeric] Numerical argument
757
+ * @param prec [Integer] Arbitrary precision
758
+ * @return [BigDecimal] Real solution
759
+ * @return [Complex] Complex solution
760
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
761
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
762
+ * @since 0.1.0
763
+ */
764
+ static VALUE
765
+ __impl_bigmath_cosh(VALUE unused_obj, VALUE z, VALUE prec)
766
+ {
767
+ return solver_hyperb(mf_cosh, z, prec);
768
+ }
769
+
770
+ /**
771
+ * Computes hyperbolic tangent of +z+.
772
+ *
773
+ * @param z [Numeric] Numerical argument
774
+ * @param prec [Integer] Arbitrary precision
775
+ * @return [BigDecimal] Real solution
776
+ * @return [Complex] Complex solution
777
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
778
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
779
+ * @since 0.1.0
780
+ */
781
+ static VALUE
782
+ __impl_bigmath_tanh(VALUE unused_obj, VALUE z, VALUE prec)
783
+ {
784
+ return solver_hyperb(mf_tanh, z, prec);
785
+ }
786
+
787
+ /**
788
+ * Computes hyperbolic cosecant of +z+.
789
+ *
790
+ * @param z [Numeric] Numerical argument
791
+ * @param prec [Integer] Arbitrary precision
792
+ * @return [BigDecimal] Real solution
793
+ * @return [Complex] Complex solution
794
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
795
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
796
+ * @since 0.1.0
797
+ */
798
+ static VALUE
799
+ __impl_bigmath_csch(VALUE unused_obj, VALUE z, VALUE prec)
800
+ {
801
+ return solver_hyperb(mf_csch, z, prec);
802
+ }
803
+
804
+ /**
805
+ * Computes hyperbolic secant of +z+.
806
+ *
807
+ * @param z [Numeric] Numerical argument
808
+ * @param prec [Integer] Arbitrary precision
809
+ * @return [BigDecimal] Real solution
810
+ * @return [Complex] Complex solution
811
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
812
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
813
+ * @since 0.1.0
814
+ */
815
+ static VALUE
816
+ __impl_bigmath_sech(VALUE unused_obj, VALUE z, VALUE prec)
817
+ {
818
+ return solver_hyperb(mf_sech, z, prec);
819
+ }
820
+
821
+ /**
822
+ * Computes hyperbolic cotangent of +z+.
823
+ *
824
+ * @param z [Numeric] Numerical argument
825
+ * @param prec [Integer] Arbitrary precision
826
+ * @return [BigDecimal] Real solution
827
+ * @return [Complex] Complex solution
828
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
829
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
830
+ * @since 0.1.0
831
+ */
832
+ static VALUE
833
+ __impl_bigmath_coth(VALUE unused_obj, VALUE z, VALUE prec)
834
+ {
835
+ return solver_hyperb(mf_coth, z, prec);
836
+ }
837
+
838
+
839
+ static VALUE
840
+ solver_triginv(ID func, VALUE z, VALUE prec)
841
+ {
842
+ const ID funcs[6] = { mf_asin, mf_acos, mf_atan, mf_acsc, mf_asec, mf_acot };
843
+ VALUE w = Qundef;
844
+ rb_id_includes(6, funcs, func);
845
+ CHECK_NUMARG(z);
846
+ rb_check_precise(prec);
847
+
848
+ if (!rb_num_finite_p(z))
849
+ {
850
+ if (func == mf_asin)
851
+ w = casin_branch(z, prec, cb_casin);
852
+ else if (func == mf_acos)
853
+ w = cacos_branch(z, prec, cb_cacos);
854
+ else if (func == mf_atan)
855
+ w = catan_branch(z, prec, cb_catan);
856
+ else if (func == mf_acsc)
857
+ w = cacsc_branch(z, prec, cb_cacsc);
858
+ else if (func == mf_asec)
859
+ w = casec_branch(z, prec, cb_casec);
860
+ else if (func == mf_acot)
861
+ w = cacot_branch(z, prec, cb_cacot);
862
+ }
863
+ if (w == Qundef)
864
+ {
865
+ if (rb_num_real_p(z) || rb_num_zero_p(rb_num_imag(z)))
866
+ {
867
+ if (func == mf_asin)
868
+ {
869
+ VALUE domain = rb_range_new(INT2FIX(-1), INT2FIX(1), 0);
870
+ if (domain_p(domain, z))
871
+ w = asin_branch(z, prec, cb_asin);
872
+ else
873
+ w = asin_edom(z, prec);
874
+ }
875
+ else if (func == mf_acos)
876
+ {
877
+ VALUE domain = rb_range_new(INT2FIX(-1), INT2FIX(1), 0);
878
+ if (domain_p(domain, z))
879
+ w = acos_branch(z, prec, cb_acos);
880
+ else
881
+ w = acos_edom(z, prec);
882
+ }
883
+ else if (func == mf_atan)
884
+ w = atan_branch(z, prec, cb_atan);
885
+ else if (func == mf_acsc)
886
+ {
887
+ VALUE m_domain = rb_range_new(BIG_MINUS_INF, BIG_MINUS_ONE, 0);
888
+ VALUE p_domain = rb_range_new(BIG_ONE, BIG_INF, 0);
889
+ if (domain_p(m_domain, z) || domain_p(p_domain, z))
890
+ w = acsc_branch(z, prec, cb_acsc);
891
+ else
892
+ w = acsc_edom(z, prec);
893
+ }
894
+ else if (func == mf_asec)
895
+ {
896
+ VALUE m_domain = rb_range_new(BIG_MINUS_INF, BIG_MINUS_ONE, 0);
897
+ VALUE p_domain = rb_range_new(BIG_ONE, BIG_INF, 0);
898
+ if (domain_p(m_domain, z) || domain_p(p_domain, z))
899
+ w = asec_branch(z, prec, cb_asec);
900
+ else
901
+ w = asec_edom(z, prec);
902
+ }
903
+ else if (func == mf_acot)
904
+ w = acot_branch(z, prec, cb_acot);
905
+ }
906
+ else
907
+ {
908
+ if (func == mf_asin)
909
+ w = casin_branch(z, prec, cb_casin);
910
+ else if (func == mf_acos)
911
+ w = cacos_branch(z, prec, cb_cacos);
912
+ else if (func == mf_atan)
913
+ w = catan_branch(z, prec, cb_catan);
914
+ else if (func == mf_acsc)
915
+ w = cacsc_branch(z, prec, cb_cacsc);
916
+ else if (func == mf_asec)
917
+ w = casec_branch(z, prec, cb_casec);
918
+ else if (func == mf_acot)
919
+ w = cacot_branch(z, prec, cb_cacot);
920
+ }
921
+ }
922
+ if (rb_num_real(z) && rb_num_zero_p(rb_num_imag(w)))
923
+ w = rb_num_real(w);
924
+ return w;
925
+ }
926
+
927
+ /**
928
+ * This is a public API for inverse trigonometric solver.
929
+ *
930
+ * @param func [Symbol] The name of the target function. [:asin, :acos, :atan, :acsc, :asec, :acot]
931
+ * @param z [Numeric] Numerical argument
932
+ * @param prec [Integer] Arbitrary precision
933
+ * @return [BigDecimal] Real solution
934
+ * @return [Complex] Complex solution
935
+ * @raise [ArgumentError] Target function name no match found.
936
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
937
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
938
+ */
939
+ static VALUE
940
+ __impl_solver_triginv(VALUE unused_obj, VALUE func, VALUE z, VALUE prec)
941
+ {
942
+ return solver_triginv(SYM2ID(func), z, prec);
943
+ }
944
+
945
+ /**
946
+ * Computes inverse sine of +z+.
947
+ *
948
+ * @param z [Numeric] Numerical argument
949
+ * @param prec [Integer] Arbitrary precision
950
+ * @return [BigDecimal] Real solution
951
+ * @return [Complex] Complex solution
952
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
953
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
954
+ * @since 0.1.0
955
+ */
956
+ static VALUE
957
+ __impl_bigmath_asin(VALUE unused_obj, VALUE z, VALUE prec)
958
+ {
959
+ return solver_triginv(mf_asin, z, prec);
960
+ }
961
+
962
+ /**
963
+ * Computes inverse cosine of +z+.
964
+ *
965
+ * @param z [Numeric] Numerical argument
966
+ * @param prec [Integer] Arbitrary precision
967
+ * @return [BigDecimal] Real solution
968
+ * @return [Complex] Complex solution
969
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
970
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
971
+ * @since 0.1.0
972
+ */
973
+ static VALUE
974
+ __impl_bigmath_acos(VALUE unused_obj, VALUE z, VALUE prec)
975
+ {
976
+ return solver_triginv(mf_acos, z, prec);
977
+ }
978
+
979
+ /**
980
+ * @overload atan(z, prec)
981
+ * Computes the inverse tangent +z+.
982
+ * @param z [Numeric] Numerical argument
983
+ * @param prec [Integer] Arbitrary precision
984
+ * @return [BigDecimal] Real solution
985
+ * @return [Complex] Complex solution
986
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
987
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
988
+ * @since 0.1.0
989
+ * @example
990
+ * BigMathR.atan(1, 20)
991
+ * #=> 0.78539816339744830963e0
992
+ * BigMathR.atan(1+1i, 20)
993
+ * #=> (0.10172219678978513677e1+0.40235947810852509365e0i)
994
+ * @overload atan(z, w, prec)
995
+ * Consider where the value is in quadrant XY and computes the inverse tangent of +w/z+.
996
+ * <br>
997
+ * This function is equivalent to +atan2(y, x)+, but the arguments are in a different order.
998
+ * @param z [Numeric] Numerical argument, as Quadrant XY of X
999
+ * @param w [Numeric] Numerical argument, as Quadrant XY of Y
1000
+ * @param prec [Integer] Arbitrary precision
1001
+ * @return [BigDecimal] Real solution
1002
+ * @return [Complex] Complex solution
1003
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1004
+ * @raise [TypeError] Occurs when +z+ or +w+ is not a numeric class.
1005
+ * @since 0.1.0
1006
+ * @example
1007
+ * BigMathR.atan(1, 2, 20)
1008
+ * #=> 0.11071487177940905031e1
1009
+ * BigMathR.atan(3i, 2i, 20)
1010
+ * #=> (0.58800260354756755124e0+0i)
1011
+ */
1012
+ static VALUE
1013
+ __impl_bigmath_atan(int argc, VALUE *argv, VALUE unused_obj)
1014
+ {
1015
+ VALUE z = Qundef, w = Qundef, prec = Qundef;
1016
+
1017
+ rb_check_arity(argc, 2, 3);
1018
+ switch (argc) {
1019
+ case 2:
1020
+ rb_scan_args(argc, argv, "20", &z, &prec);
1021
+ CHECK_NUMARG(z);
1022
+ rb_check_precise(prec);
1023
+ z = solver_triginv(mf_atan, z, prec);
1024
+ break;
1025
+ case 3:
1026
+ rb_scan_args(argc, argv, "30", &z, &w, &prec);
1027
+ CHECK_NUMARG(z);
1028
+ CHECK_NUMARG(w);
1029
+ rb_check_precise(prec);
1030
+ z = rb_bigmath_quadrant(z, w, prec);
1031
+ break;
1032
+ }
1033
+ return z;
1034
+ }
1035
+
1036
+ /**
1037
+ * Computes inverse cosecant of +z+.
1038
+ *
1039
+ * @param z [Numeric] Numerical argument
1040
+ * @param prec [Integer] Arbitrary precision
1041
+ * @return [BigDecimal] Real solution
1042
+ * @return [Complex] Complex solution
1043
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1044
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1045
+ * @since 0.1.0
1046
+ */
1047
+ static VALUE
1048
+ __impl_bigmath_acsc(VALUE unused_obj, VALUE z, VALUE prec)
1049
+ {
1050
+ return solver_triginv(mf_acsc, z, prec);
1051
+ }
1052
+
1053
+ /**
1054
+ * Computes inverse secant of +z+.
1055
+ *
1056
+ * @param z [Numeric] Numerical argument
1057
+ * @param prec [Integer] Arbitrary precision
1058
+ * @return [BigDecimal] Real solution
1059
+ * @return [Complex] Complex solution
1060
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1061
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1062
+ * @since 0.1.0
1063
+ */
1064
+ static VALUE
1065
+ __impl_bigmath_asec(VALUE unused_obj, VALUE z, VALUE prec)
1066
+ {
1067
+ return solver_triginv(mf_asec, z, prec);
1068
+ }
1069
+
1070
+ /**
1071
+ * Computes inverse cotangent of +z+.
1072
+ *
1073
+ * @param z [Numeric] Numerical argument
1074
+ * @param prec [Integer] Arbitrary precision
1075
+ * @return [BigDecimal] Real solution
1076
+ * @return [Complex] Complex solution
1077
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1078
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1079
+ * @since 0.1.0
1080
+ */
1081
+ static VALUE
1082
+ __impl_bigmath_acot(VALUE unused_obj, VALUE z, VALUE prec)
1083
+ {
1084
+ return solver_triginv(mf_acot, z, prec);
1085
+ }
1086
+
1087
+ static VALUE
1088
+ solver_hyperbinv(ID func, VALUE z, VALUE prec)
1089
+ {
1090
+ const ID funcs[6] = { mf_asinh, mf_acosh, mf_atanh,
1091
+ mf_acsch, mf_asech, mf_acoth };
1092
+ VALUE w = Qundef;
1093
+ rb_id_includes(6, funcs, func);
1094
+ CHECK_NUMARG(z);
1095
+ rb_check_precise(prec);
1096
+
1097
+ if (!rb_num_finite_p(z))
1098
+ {
1099
+ if (func == mf_asinh)
1100
+ w = casinh_branch(z, prec, cb_casinh);
1101
+ else if (func == mf_acosh)
1102
+ w = cacosh_branch(z, prec, cb_cacosh);
1103
+ else if (func == mf_atanh)
1104
+ w = catanh_branch(z, prec, cb_catanh);
1105
+ else if (func == mf_acsch)
1106
+ w = cacsch_branch(z, prec, cb_cacsch);
1107
+ else if (func == mf_asech)
1108
+ w = casech_branch(z, prec, cb_casech);
1109
+ else if (func == mf_acoth)
1110
+ w = cacoth_branch(z, prec, cb_cacoth);
1111
+ }
1112
+ if (w == Qundef)
1113
+ {
1114
+ if (rb_num_real_p(z) || rb_num_zero_p(rb_num_imag(z)))
1115
+ {
1116
+ if (func == mf_asinh)
1117
+ {
1118
+ w = asinh_branch(z, prec, cb_asinh);
1119
+ }
1120
+ else if (func == mf_acosh)
1121
+ {
1122
+ VALUE m_domain = rb_range_new(BIG_MINUS_INF, BIG_MINUS_ONE, 0);
1123
+ VALUE p_domain = rb_range_new(BIG_ONE, BIG_INF, 0);
1124
+ if (domain_p(p_domain, z))
1125
+ w = acosh_branch(z, prec, cb_acosh);
1126
+ else if (domain_p(m_domain, z))
1127
+ {
1128
+ z = rb_num_abs(z);
1129
+ w = acosh_branch(z, prec, cb_acosh);
1130
+ w = rb_Complex(w, rb_bigmath_const_pi(prec));
1131
+ }
1132
+ else
1133
+ w = acosh_edom(z, prec);
1134
+ }
1135
+ else if (func == mf_atanh)
1136
+ {
1137
+ VALUE domain = rb_range_new(INT2FIX(-1), INT2FIX(1), 0);
1138
+ if (domain_p(domain, z))
1139
+ w = atanh_branch(z, prec, cb_atanh);
1140
+ else
1141
+ w = atanh_edom(z, prec);
1142
+ }
1143
+ else if (func == mf_acsch)
1144
+ {
1145
+ w = acsch_branch(z, prec, cb_acsch);
1146
+ }
1147
+ else if (func == mf_asech)
1148
+ {
1149
+ VALUE m_domain = rb_range_new(BIG_MINUS_ONE, BIG_ZERO, 0);
1150
+ VALUE p_domain = rb_range_new(BIG_ZERO, BIG_ONE, 0);
1151
+ if (domain_p(p_domain, z))
1152
+ w = asech_branch(z, prec, cb_asech);
1153
+ else if (domain_p(m_domain, z))
1154
+ {
1155
+ w = asech_branch(z, prec, cb_asech);
1156
+ w = rb_Complex(w, rb_bigmath_const_pi(prec));
1157
+ }
1158
+ else
1159
+ w = asech_edom(z, prec);
1160
+ }
1161
+ else if (func == mf_acoth)
1162
+ {
1163
+ VALUE m_domain = rb_range_new(BIG_MINUS_INF, BIG_MINUS_ONE, 0);
1164
+ VALUE p_domain = rb_range_new(BIG_ONE, BIG_INF, 0);
1165
+ if (domain_p(m_domain, z) || domain_p(p_domain, z))
1166
+ w = acoth_branch(z, prec, cb_acoth);
1167
+ else
1168
+ w = acoth_edom(z, prec);
1169
+ }
1170
+ }
1171
+ else
1172
+ {
1173
+ if (func == mf_asinh)
1174
+ w = casinh_branch(z, prec, cb_casinh);
1175
+ else if (func == mf_acosh)
1176
+ w = cacosh_branch(z, prec, cb_cacosh);
1177
+ else if (func == mf_atanh)
1178
+ w = catanh_branch(z, prec, cb_catanh);
1179
+ else if (func == mf_acsch)
1180
+ w = cacsch_branch(z, prec, cb_cacsch);
1181
+ else if (func == mf_asech)
1182
+ w = casech_branch(z, prec, cb_casech);
1183
+ else if (func == mf_acoth)
1184
+ w = cacoth_branch(z, prec, cb_cacoth);
1185
+ }
1186
+ }
1187
+ if (rb_num_real(z) && rb_num_zero_p(rb_num_imag(w)))
1188
+ w = rb_num_real(w);
1189
+ return w;
1190
+ }
1191
+
1192
+ /**
1193
+ * This is a public API for inverse hyperbolic solver.
1194
+ *
1195
+ * @param func [Symbol] The name of the target function. [:asinh, :acosh, :atanh, :acsch, :asech, :acoth]
1196
+ * @param z [Numeric] Numerical argument
1197
+ * @param prec [Integer] Arbitrary precision
1198
+ * @return [BigDecimal] Real solution
1199
+ * @return [Complex] Complex solution
1200
+ * @raise [ArgumentError] Target function name no match found.
1201
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1202
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1203
+ */
1204
+ static VALUE
1205
+ __impl_solver_hyperbinv(VALUE unused_obj, VALUE func, VALUE z, VALUE prec)
1206
+ {
1207
+ return solver_hyperbinv(SYM2ID(func), z, prec);
1208
+ }
1209
+
1210
+ /**
1211
+ * Computes inverse hyperbolic sine of +z+.
1212
+ *
1213
+ * @param z [Numeric] Numerical argument
1214
+ * @param prec [Integer] Arbitrary precision
1215
+ * @return [BigDecimal] Real solution
1216
+ * @return [Complex] Complex solution
1217
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1218
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1219
+ * @since 0.1.0
1220
+ */
1221
+ static VALUE
1222
+ __impl_bigmath_asinh(VALUE unused_obj, VALUE z, VALUE prec)
1223
+ {
1224
+ return solver_hyperbinv(mf_asinh, z, prec);
1225
+ }
1226
+
1227
+ /**
1228
+ * Computes inverse hyperbolic cosine of +z+.
1229
+ *
1230
+ * @param z [Numeric] Numerical argument
1231
+ * @param prec [Integer] Arbitrary precision
1232
+ * @return [BigDecimal] Real solution
1233
+ * @return [Complex] Complex solution
1234
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1235
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1236
+ * @since 0.1.0
1237
+ */
1238
+ static VALUE
1239
+ __impl_bigmath_acosh(VALUE unused_obj, VALUE z, VALUE prec)
1240
+ {
1241
+ return solver_hyperbinv(mf_acosh, z, prec);
1242
+ }
1243
+
1244
+ /**
1245
+ * Computes inverse hyperbolic tangent of +z+.
1246
+ *
1247
+ * @param z [Numeric] Numerical argument
1248
+ * @param prec [Integer] Arbitrary precision
1249
+ * @return [BigDecimal] Real solution
1250
+ * @return [Complex] Complex solution
1251
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1252
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1253
+ * @since 0.1.0
1254
+ */
1255
+ static VALUE
1256
+ __impl_bigmath_atanh(VALUE unused_obj, VALUE z, VALUE prec)
1257
+ {
1258
+ return solver_hyperbinv(mf_atanh, z, prec);
1259
+ }
1260
+
1261
+ /**
1262
+ * Computes inverse hyperbolic cosecant of +z+.
1263
+ *
1264
+ * @param z [Numeric] Numerical argument
1265
+ * @param prec [Integer] Arbitrary precision
1266
+ * @return [BigDecimal] Real solution
1267
+ * @return [Complex] Complex solution
1268
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1269
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1270
+ * @since 0.1.0
1271
+ */
1272
+ static VALUE
1273
+ __impl_bigmath_acsch(VALUE unused_obj, VALUE z, VALUE prec)
1274
+ {
1275
+ return solver_hyperbinv(mf_acsch, z, prec);
1276
+ }
1277
+
1278
+ /**
1279
+ * Computes inverse hyperbolic secant of +z+.
1280
+ *
1281
+ * @param z [Numeric] Numerical argument
1282
+ * @param prec [Integer] Arbitrary precision
1283
+ * @return [BigDecimal] Real solution
1284
+ * @return [Complex] Complex solution
1285
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1286
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1287
+ * @since 0.1.0
1288
+ */
1289
+ static VALUE
1290
+ __impl_bigmath_asech(VALUE unused_obj, VALUE z, VALUE prec)
1291
+ {
1292
+ return solver_hyperbinv(mf_asech, z, prec);
1293
+ }
1294
+
1295
+ /**
1296
+ * Computes inverse hyperbolic cotangent of +z+.
1297
+ *
1298
+ * @param z [Numeric] Numerical argument
1299
+ * @param prec [Integer] Arbitrary precision
1300
+ * @return [BigDecimal] Real solution
1301
+ * @return [Complex] Complex solution
1302
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1303
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1304
+ * @since 0.1.0
1305
+ */
1306
+ static VALUE
1307
+ __impl_bigmath_acoth(VALUE unused_obj, VALUE z, VALUE prec)
1308
+ {
1309
+ return solver_hyperbinv(mf_acoth, z, prec);
1310
+ }
1311
+
1312
+ /**
1313
+ * Computes square root of +z+.
1314
+ *
1315
+ * @param z [Numeric] Numerical argument
1316
+ * @param prec [Integer] Arbitrary precision
1317
+ * @return [BigDecimal] Real solution
1318
+ * @return [Complex] Complex solution
1319
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1320
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1321
+ * @since 0.2.0
1322
+ * @example
1323
+ * BigMathR.sqrt(-1, 20) == Complex::I
1324
+ * #=> true
1325
+ * BigMathR.sqrt(2, 20)
1326
+ * #=> 0.14142135623730950488e1
1327
+ * BigMathR.sqrt(1+1i, 20)
1328
+ * #=> (0.109868411346780996604e1+0.4550898605622273413e0i)
1329
+ */
1330
+ static VALUE
1331
+ __impl_bigmath_sqrt(VALUE unused_obj, VALUE z, VALUE prec)
1332
+ {
1333
+ VALUE w = Qundef;
1334
+ if (rb_num_real_p(z))
1335
+ {
1336
+ z = rb_num_canonicalize(z, prec, ARG_REAL, ARG_RAWVALUE);
1337
+ if (rb_num_negative_p(z))
1338
+ w = sqrt_edom(z, prec);
1339
+ else
1340
+ w = sqrt_newton(z, prec);
1341
+ }
1342
+ else
1343
+ {
1344
+ z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
1345
+ w = csqrt_formula(z, prec);
1346
+ }
1347
+ return w;
1348
+ }
1349
+
1350
+ /**
1351
+ * Computes cubic root of +z+.
1352
+ * <br>
1353
+ * Note that the return value differs depending on the type of the argument.
1354
+ * <br>
1355
+ * For example, a negative argument returns a different value for real and complex solutions.
1356
+ *
1357
+ * @param z [Numeric] Numerical argument
1358
+ * @param prec [Integer] Arbitrary precision
1359
+ * @return [BigDecimal] Real solution
1360
+ * @return [Complex] Complex solution
1361
+ * @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
1362
+ * @raise [TypeError] Occurs when +z+ is not a numeric class.
1363
+ * @since 0.2.0
1364
+ * @example
1365
+ * BigMathR.cbrt(-1, 20)
1366
+ * #=> -0.1e1
1367
+ * BigMathR.cbrt(-1+0i, 20)
1368
+ * #=> (0.49999999999999999999e0+0.86602540378443864677e0i)
1369
+ */
1370
+ static VALUE
1371
+ __impl_bigmath_cbrt(VALUE unused_obj, VALUE z, VALUE prec)
1372
+ {
1373
+ VALUE w = Qundef;
1374
+ if (rb_num_real_p(z))
1375
+ {
1376
+ z = rb_num_canonicalize(z, prec, ARG_REAL, ARG_RAWVALUE);
1377
+ w = cuberoot_newton(z, prec);
1378
+ }
1379
+ else
1380
+ {
1381
+ z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
1382
+ w = ccbrt_formula(z, prec);
1383
+ }
1384
+ return w;
1385
+ }
1386
+
1387
+ /**
1388
+ * Document-module: BigMathR::Solver
1389
+ *
1390
+ * A module that provides a solver for mathematical functions.
1391
+ * It is used internally.
1392
+ */
1393
+ void
1394
+ InitVM_Solver(void)
1395
+ {
1396
+ cb_exp = exp_edf;
1397
+ cb_cexp = cexp_eulerf;
1398
+ cb_exp2 = exp2_edf;
1399
+ cb_cexp2 = cexp2_eulerf;
1400
+
1401
+ cb_log = log_edf;
1402
+ cb_log2 = log2_edf;
1403
+ cb_log10 = log10_edf;
1404
+ cb_log1p = log1p_ser_mercator;
1405
+ cb_clog = clog_formula;
1406
+ cb_clog2 = clog2_formula;
1407
+ cb_clog10 = clog10_formula;
1408
+ cb_clog1p = log1p_ser_mercator;
1409
+
1410
+ cb_sin = sin_ser;
1411
+ cb_cos = cos_ser;
1412
+ cb_tan = tan_ser;
1413
+ cb_csc = csc_ser;
1414
+ cb_sec = sec_ser;
1415
+ cb_cot = cot_ser;
1416
+
1417
+ cb_csin = csin_eulerf;
1418
+ cb_ccos = ccos_eulerf;
1419
+ cb_ctan = ctan_eulerf;
1420
+ cb_ccsc = ccsc_eulerf;
1421
+ cb_csec = csec_eulerf;
1422
+ cb_ccot = ccot_eulerf;
1423
+
1424
+ cb_sinh = sinh_formula;
1425
+ cb_cosh = cosh_formula;
1426
+ cb_tanh = tanh_formula;
1427
+ cb_csch = csch_formula;
1428
+ cb_sech = sech_formula;
1429
+ cb_coth = coth_formula;
1430
+
1431
+ cb_csinh = csinh_eulerf;
1432
+ cb_ccosh = ccosh_eulerf;
1433
+ cb_ctanh = ctanh_eulerf;
1434
+ cb_ccsch = ccsch_eulerf;
1435
+ cb_csech = csech_eulerf;
1436
+ cb_ccoth = ccoth_eulerf;
1437
+
1438
+ cb_asin = asin_logrep;
1439
+ cb_acos = acos_logrep;
1440
+ cb_atan = atan_logrep;
1441
+ cb_acsc = acsc_logrep;
1442
+ cb_asec = asec_logrep;
1443
+ cb_acot = acot_logrep;
1444
+
1445
+ cb_casin = casin_logrep;
1446
+ cb_cacos = cacos_logrep;
1447
+ cb_catan = catan_logrep;
1448
+ cb_cacsc = cacsc_logrep;
1449
+ cb_casec = casec_logrep;
1450
+ cb_cacot = cacot_logrep;
1451
+
1452
+ cb_asinh = asinh_logrep;
1453
+ cb_acosh = acosh_logrep;
1454
+ cb_atanh = atanh_logrep;
1455
+ cb_acsch = acsch_logrep;
1456
+ cb_asech = asech_logrep;
1457
+ cb_acoth = acoth_logrep;
1458
+
1459
+ cb_casinh = casinh_logrep;
1460
+ cb_cacosh = cacosh_logrep;
1461
+ cb_catanh = catanh_logrep;
1462
+ cb_cacsch = cacsch_logrep;
1463
+ cb_casech = casech_logrep;
1464
+ cb_cacoth = cacoth_logrep;
1465
+
1466
+ rb_define_singleton_method(rb_mSolver, "exp", __impl_solver_exp, 3);
1467
+
1468
+ rb_define_singleton_method(rb_mBigMathR, "exp", __impl_bigmath_exp, 2);
1469
+ rb_define_singleton_method(rb_mBigMathR, "exp2", __impl_bigmath_exp2, 2);
1470
+
1471
+ rb_define_singleton_method(rb_mSolver, "log", __impl_solver_log, 3);
1472
+
1473
+ rb_define_singleton_method(rb_mBigMathR, "log", __impl_bigmath_log, -1);
1474
+ rb_define_singleton_method(rb_mBigMathR, "log1p", __impl_bigmath_log1p, 2);
1475
+ rb_define_singleton_method(rb_mBigMathR, "log2", __impl_bigmath_log2, 2);
1476
+ rb_define_singleton_method(rb_mBigMathR, "log10", __impl_bigmath_log10, 2);
1477
+
1478
+ rb_define_singleton_method(rb_mSolver, "trig", __impl_solver_trig, 3);
1479
+
1480
+ rb_define_singleton_method(rb_mBigMathR, "sin", __impl_bigmath_sin, 2);
1481
+ rb_define_singleton_method(rb_mBigMathR, "cos", __impl_bigmath_cos, 2);
1482
+ rb_define_singleton_method(rb_mBigMathR, "tan", __impl_bigmath_tan, 2);
1483
+ rb_define_singleton_method(rb_mBigMathR, "csc", __impl_bigmath_csc, 2);
1484
+ rb_define_singleton_method(rb_mBigMathR, "sec", __impl_bigmath_sec, 2);
1485
+ rb_define_singleton_method(rb_mBigMathR, "cot", __impl_bigmath_cot, 2);
1486
+
1487
+ rb_define_singleton_method(rb_mSolver, "hyperb", __impl_solver_hyperb, 3);
1488
+
1489
+ rb_define_singleton_method(rb_mBigMathR, "sinh", __impl_bigmath_sinh, 2);
1490
+ rb_define_singleton_method(rb_mBigMathR, "cosh", __impl_bigmath_cosh, 2);
1491
+ rb_define_singleton_method(rb_mBigMathR, "tanh", __impl_bigmath_tanh, 2);
1492
+ rb_define_singleton_method(rb_mBigMathR, "csch", __impl_bigmath_csch, 2);
1493
+ rb_define_singleton_method(rb_mBigMathR, "sech", __impl_bigmath_sech, 2);
1494
+ rb_define_singleton_method(rb_mBigMathR, "coth", __impl_bigmath_coth, 2);
1495
+
1496
+ rb_define_singleton_method(rb_mSolver, "triginv", __impl_solver_triginv, 3);
1497
+
1498
+ rb_define_singleton_method(rb_mBigMathR, "asin", __impl_bigmath_asin, 2);
1499
+ rb_define_singleton_method(rb_mBigMathR, "acos", __impl_bigmath_acos, 2);
1500
+ rb_define_singleton_method(rb_mBigMathR, "atan", __impl_bigmath_atan, -1);
1501
+ rb_define_singleton_method(rb_mBigMathR, "acsc", __impl_bigmath_acsc, 2);
1502
+ rb_define_singleton_method(rb_mBigMathR, "asec", __impl_bigmath_asec, 2);
1503
+ rb_define_singleton_method(rb_mBigMathR, "acot", __impl_bigmath_acot, 2);
1504
+
1505
+ rb_define_singleton_method(rb_mSolver, "hyperbinv", __impl_solver_hyperbinv, 3);
1506
+
1507
+ rb_define_singleton_method(rb_mBigMathR, "asinh", __impl_bigmath_asinh, 2);
1508
+ rb_define_singleton_method(rb_mBigMathR, "acosh", __impl_bigmath_acosh, 2);
1509
+ rb_define_singleton_method(rb_mBigMathR, "atanh", __impl_bigmath_atanh, 2);
1510
+ rb_define_singleton_method(rb_mBigMathR, "acsch", __impl_bigmath_acsch, 2);
1511
+ rb_define_singleton_method(rb_mBigMathR, "asech", __impl_bigmath_asech, 2);
1512
+ rb_define_singleton_method(rb_mBigMathR, "acoth", __impl_bigmath_acoth, 2);
1513
+
1514
+ rb_define_singleton_method(rb_mBigMathR, "sqrt", __impl_bigmath_sqrt, 2);
1515
+ rb_define_singleton_method(rb_mBigMathR, "cbrt", __impl_bigmath_cbrt, 2);
1516
+ }