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.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +13 -0
- data/changelog.md +24 -0
- data/ext/bigdecimal/math_r/algofunc.h +203 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/check_precise.h +12 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/infinity.h +6 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/minus_infinity.h +5 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/minus_one.h +6 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/minus_zero.h +6 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/nan.h +6 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/one.h +6 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/sign.h +10 -0
- data/ext/bigdecimal/math_r/api/bigdecimal/zero.h +6 -0
- data/ext/bigdecimal/math_r/api/bigmath/api_call1.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/api_call2.h +6 -0
- data/ext/bigdecimal/math_r/api/bigmath/atan.h +7 -0
- data/ext/bigdecimal/math_r/api/bigmath/atan_adopt.h +42 -0
- data/ext/bigdecimal/math_r/api/bigmath/cabs.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/carg.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/cexp.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/clog.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/const.h +39 -0
- data/ext/bigdecimal/math_r/api/bigmath/const_e.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/const_log10.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/const_log2.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/const_log_pi.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/const_pi.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/const_sqrt2.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/const_sqrt3.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/cpow.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/csqrt.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/degree_sparg.h +199 -0
- data/ext/bigdecimal/math_r/api/bigmath/escalb.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/exp.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/expxt.h +18 -0
- data/ext/bigdecimal/math_r/api/bigmath/hypot.h +10 -0
- data/ext/bigdecimal/math_r/api/bigmath/ipow.h +14 -0
- data/ext/bigdecimal/math_r/api/bigmath/l2norm.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/log.h +7 -0
- data/ext/bigdecimal/math_r/api/bigmath/pow.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/quadrant.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/sincos.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/sqrt.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/to_rad.h +41 -0
- data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal.h +6 -0
- data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal1.h +6 -0
- data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal_flo.h +9 -0
- data/ext/bigdecimal/math_r/api/kernel/rb_ImaginaryZ.h +8 -0
- data/ext/bigdecimal/math_r/api/numanalysis/condition_p.h +26 -0
- data/ext/bigdecimal/math_r/api/numanalysis/make_n.h +9 -0
- data/ext/bigdecimal/math_r/api/numeric/abs.h +7 -0
- data/ext/bigdecimal/math_r/api/numeric/canonicalize.h +140 -0
- data/ext/bigdecimal/math_r/api/numeric/cmpeql.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/equal_p.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/finite_p.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/imag.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/infinite_p.h +7 -0
- data/ext/bigdecimal/math_r/api/numeric/nan_p.h +5 -0
- data/ext/bigdecimal/math_r/api/numeric/negative_p.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/nonzero_p.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/notequal_p.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/numeric_p.h +5 -0
- data/ext/bigdecimal/math_r/api/numeric/positive_p.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/real.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/real_p.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/round.h +56 -0
- data/ext/bigdecimal/math_r/api/numeric/uminus.h +6 -0
- data/ext/bigdecimal/math_r/api/numeric/zero_p.h +6 -0
- data/ext/bigdecimal/math_r/api.c +13 -0
- data/ext/bigdecimal/math_r/api.h +69 -0
- data/ext/bigdecimal/math_r/const.c +186 -0
- data/ext/bigdecimal/math_r/decl.h +203 -0
- data/ext/bigdecimal/math_r/edf.c +180 -0
- data/ext/bigdecimal/math_r/erf.c +80 -0
- data/ext/bigdecimal/math_r/euler_f.c +572 -0
- data/ext/bigdecimal/math_r/exp.c +72 -0
- data/ext/bigdecimal/math_r/extconf.rb +185 -0
- data/ext/bigdecimal/math_r/gamma_r.c +251 -0
- data/ext/bigdecimal/math_r/hyperb.c +172 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/E/ser.h +22 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG10/ser.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG2/BBP2002.h +36 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG_PI/builtin.h +7 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/PI/machin.h +48 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT2/builtin.h +5 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT3/builtin.h +5 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/branch.h +25 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/edom.h +15 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/logrep.h +19 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acos/ser.h +34 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/branch.h +19 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/edom.h +17 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/logrep.h +14 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acot/branch.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acot/logrep.h +13 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/branch.h +20 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/edom.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/logrep.h +33 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/branch.h +21 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/edom.h +20 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/logrep.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsch/branch.h +25 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsch/logrep.h +25 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/branch.h +22 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/edom.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/logrep.h +21 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/branch.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/edom.h +19 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/logrep.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/branch.h +22 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/edom.h +20 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/logrep.h +15 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/ser.h +32 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/branch.h +26 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/logrep.h +24 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/ser.h +48 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/branch.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/logrep.h +14 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/ser_euler.h +84 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/ser_usual.h +41 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/branch.h +24 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/edom.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/logrep.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/ser.h +33 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cabs/formula.h +8 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacos/branch.h +38 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacos/logrep.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacosh/branch.h +34 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacosh/logrep.h +17 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacot/branch.h +39 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacot/logrep.h +17 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacoth/branch.h +29 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacoth/logrep.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsc/branch.h +28 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsc/logrep.h +19 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsch/branch.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsch/logrep.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/carg/formula.h +8 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casec/branch.h +29 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casec/logrep.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casech/branch.h +38 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casech/logrep.h +9 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casin/branch.h +35 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casin/logrep.h +14 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casinh/branch.h +59 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casinh/logrep.h +13 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catan/branch.h +46 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catan/logrep.h +17 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catanh/branch.h +26 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catanh/logrep.h +10 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccbrt/formula.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccos/branch.h +41 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccos/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccosh/branch.h +37 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccosh/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccot/branch.h +46 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccot/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccoth/branch.h +43 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccoth/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsc/branch.h +42 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsc/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsch/branch.h +38 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsch/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp/branch.h +42 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp/eulerf.h +21 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp2/branch.h +42 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp2/eulerf.h +12 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog/branch.h +54 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog/formula.h +13 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog10/formula.h +12 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog1p/branch.h +34 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog2/formula.h +12 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/branch.h +21 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/ser.h +12 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/branch.h +22 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/formula.h +30 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/ser.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/branch.h +28 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/ser.h +12 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/branch.h +23 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/formula.h +30 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/ser.h +13 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cpow/formula.h +20 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/branch.h +28 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/ser.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/branch.h +23 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/formula.h +31 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/ser.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csec/branch.h +42 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csec/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csech/branch.h +38 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csech/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csin/branch.h +44 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csin/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csinh/branch.h +41 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csinh/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csqrt/formula.h +66 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ctan/branch.h +46 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ctan/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ctanh/branch.h +43 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ctanh/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cuberoot/newton.h +42 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/algo911.h +41 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/branch.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/cf.h +51 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_inf.h +53 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_zero.h +45 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/algo911.h +27 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/branch.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/cf.h +49 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/escalb/edf.h +87 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/branch.h +29 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/builtin.h +6 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/edf.h +23 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp2/branch.h +29 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp2/edf.h +19 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/expxt/edf.h +31 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/f_euler/formula.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/branch.h +25 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/l2norm.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/mmm.h +38 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ipow/edf.h +33 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/l2norm/formula.h +48 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/branch.h +40 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/builtin.h +12 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edf.h +10 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edom.h +10 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/mercator.h +34 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/ser_okumura.h +57 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/branch.h +40 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/edf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/mercator.h +35 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/branch.h +34 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/p_adic.h +37 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/ser_mercator.h +35 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/branch.h +40 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/edf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/mercator.h +35 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/logxt/edf.h +33 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/pow/formula.h +30 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/quadrant/formula.h +352 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm10/edf.h +34 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm2/edf.h +34 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/branch.h +27 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/ser.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/branch.h +21 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/formula.h +25 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/ser.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/branch.h +23 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/ser.h +13 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sincos/ser.h +50 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/branch.h +23 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/formula.h +26 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/ser.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinhcosh/ser.h +70 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/branch.h +16 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/builtin.h +12 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/edom.h +9 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/newton.h +36 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/branch.h +26 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/ser.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/branch.h +23 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/eulerf.h +11 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/formula.h +27 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/ser.h +14 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/trig/f_euler.h +290 -0
- data/ext/bigdecimal/math_r/log.c +256 -0
- data/ext/bigdecimal/math_r/logrep.c +537 -0
- data/ext/bigdecimal/math_r/math_r/bigdecimal.h +30 -0
- data/ext/bigdecimal/math_r/math_r/bigmath.h +61 -0
- data/ext/bigdecimal/math_r/math_r/bigmath_r.h +9 -0
- data/ext/bigdecimal/math_r/math_r/ext_extern.h +18 -0
- data/ext/bigdecimal/math_r/math_r/globals.h +71 -0
- data/ext/bigdecimal/math_r/math_r/numdiff.h +18 -0
- data/ext/bigdecimal/math_r/math_r/numeric.h +63 -0
- data/ext/bigdecimal/math_r/math_r.c +130 -0
- data/ext/bigdecimal/math_r/nucomp.c +158 -0
- data/ext/bigdecimal/math_r/overrides.c +91 -0
- data/ext/bigdecimal/math_r/power.c +207 -0
- data/ext/bigdecimal/math_r/solver.c +1516 -0
- data/ext/bigdecimal/math_r/trig.c +205 -0
- data/lib/bigdecimal/math_r/const/EulerGamma_engel.rb +46 -0
- data/lib/bigdecimal/math_r/const/LOG2_bbp2007.rb +39 -0
- data/lib/bigdecimal/math_r/const/PI_chudnovsky.rb +59 -0
- data/lib/bigdecimal/math_r/const/PI_euler.rb +40 -0
- data/lib/bigdecimal/math_r/const/PI_ramanujan1.rb +45 -0
- data/lib/bigdecimal/math_r/const/PI_ramanujan2.rb +46 -0
- data/lib/bigdecimal/math_r/const/b053977/b053977.txt +306 -0
- data/lib/bigdecimal/math_r/version.rb +7 -0
- data/lib/bigdecimal/math_r.rb +12 -0
- data/lib/bigdecimal/math_r.so +0 -0
- data/sig/bigdecimal/math_r.rbs +6 -0
- metadata +393 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
#ifndef RB_BIGMATHR_GLOBALS_H_INCLUDED
|
2
|
+
#define RB_BIGMATHR_GLOBALS_H_INCLUDED
|
3
|
+
|
4
|
+
#include <ruby/internal/value.h> // VALUE
|
5
|
+
#include "ext_extern.h"
|
6
|
+
|
7
|
+
RUBY_EXT_EXTERN VALUE rb_cBigDecimal;
|
8
|
+
RUBY_EXT_EXTERN VALUE rb_mBigMath;
|
9
|
+
|
10
|
+
RUBY_EXT_EXTERN VALUE rb_mBigMathR;
|
11
|
+
RUBY_EXT_EXTERN VALUE rb_mMathSolver;
|
12
|
+
RUBY_EXT_EXTERN VALUE rb_mConst;
|
13
|
+
RUBY_EXT_EXTERN VALUE rb_mConstPI;
|
14
|
+
RUBY_EXT_EXTERN VALUE rb_mConstE;
|
15
|
+
RUBY_EXT_EXTERN VALUE rb_mConstLOG2;
|
16
|
+
RUBY_EXT_EXTERN VALUE rb_mConstEulerGamma;
|
17
|
+
RUBY_EXT_EXTERN VALUE rb_mEDF;
|
18
|
+
RUBY_EXT_EXTERN VALUE rb_mExp;
|
19
|
+
RUBY_EXT_EXTERN VALUE rb_mLog;
|
20
|
+
RUBY_EXT_EXTERN VALUE rb_mTrig;
|
21
|
+
RUBY_EXT_EXTERN VALUE rb_mHyperb;
|
22
|
+
RUBY_EXT_EXTERN VALUE rb_mComplexPlane;
|
23
|
+
RUBY_EXT_EXTERN VALUE rb_mEulerF;
|
24
|
+
RUBY_EXT_EXTERN VALUE rb_mLogRep;
|
25
|
+
RUBY_EXT_EXTERN VALUE rb_mPower;
|
26
|
+
RUBY_EXT_EXTERN VALUE rb_mGammaR;
|
27
|
+
RUBY_EXT_EXTERN VALUE rb_mErf;
|
28
|
+
RUBY_EXT_EXTERN VALUE rb_mSolver;
|
29
|
+
|
30
|
+
RUBY_EXT_EXTERN ID mf_exp;
|
31
|
+
RUBY_EXT_EXTERN ID mf_exp2;
|
32
|
+
RUBY_EXT_EXTERN ID mf_expm1;
|
33
|
+
|
34
|
+
RUBY_EXT_EXTERN ID mf_log;
|
35
|
+
RUBY_EXT_EXTERN ID mf_log2;
|
36
|
+
RUBY_EXT_EXTERN ID mf_log10;
|
37
|
+
RUBY_EXT_EXTERN ID mf_log1p;
|
38
|
+
|
39
|
+
RUBY_EXT_EXTERN ID mf_sqrt;
|
40
|
+
RUBY_EXT_EXTERN ID mf_cbrt;
|
41
|
+
|
42
|
+
RUBY_EXT_EXTERN ID mf_sin;
|
43
|
+
RUBY_EXT_EXTERN ID mf_cos;
|
44
|
+
RUBY_EXT_EXTERN ID mf_tan;
|
45
|
+
RUBY_EXT_EXTERN ID mf_csc;
|
46
|
+
RUBY_EXT_EXTERN ID mf_sec;
|
47
|
+
RUBY_EXT_EXTERN ID mf_cot;
|
48
|
+
|
49
|
+
RUBY_EXT_EXTERN ID mf_sinh;
|
50
|
+
RUBY_EXT_EXTERN ID mf_cosh;
|
51
|
+
RUBY_EXT_EXTERN ID mf_tanh;
|
52
|
+
RUBY_EXT_EXTERN ID mf_csch;
|
53
|
+
RUBY_EXT_EXTERN ID mf_sech;
|
54
|
+
RUBY_EXT_EXTERN ID mf_coth;
|
55
|
+
|
56
|
+
RUBY_EXT_EXTERN ID mf_asin;
|
57
|
+
RUBY_EXT_EXTERN ID mf_acos;
|
58
|
+
RUBY_EXT_EXTERN ID mf_atan;
|
59
|
+
RUBY_EXT_EXTERN ID mf_acsc;
|
60
|
+
RUBY_EXT_EXTERN ID mf_asec;
|
61
|
+
RUBY_EXT_EXTERN ID mf_acot;
|
62
|
+
|
63
|
+
RUBY_EXT_EXTERN ID mf_asinh;
|
64
|
+
RUBY_EXT_EXTERN ID mf_acosh;
|
65
|
+
RUBY_EXT_EXTERN ID mf_atanh;
|
66
|
+
RUBY_EXT_EXTERN ID mf_acsch;
|
67
|
+
RUBY_EXT_EXTERN ID mf_asech;
|
68
|
+
RUBY_EXT_EXTERN ID mf_acoth;
|
69
|
+
|
70
|
+
|
71
|
+
#endif /* RB_BIGMATHR_GLOBALS_H_INCLUDED */
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#ifndef INTERNAL_API_NUMDIFF
|
2
|
+
#define INTERNAL_API_NUMDIFF
|
3
|
+
|
4
|
+
/* API for Numerical Differentiation */
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Query if the condition for exiting the iterator has been reached.
|
8
|
+
* It is use in numerical derivatives.
|
9
|
+
*/
|
10
|
+
bool rb_numdiff_condition_p(VALUE y, VALUE d, VALUE n, VALUE *m);
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Add BigDecimal#double_fig to the arbitrary precision number.
|
14
|
+
* The precision must be greater than or equal to 1.
|
15
|
+
*/
|
16
|
+
VALUE rb_numdiff_make_n(VALUE prec);
|
17
|
+
|
18
|
+
#endif /* INTERNAL_API_NUMDIFF */
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#ifndef INTERNAL_API_NUMERIC
|
2
|
+
#define INTERNAL_API_NUMERIC
|
3
|
+
|
4
|
+
/* API for Numeric */
|
5
|
+
|
6
|
+
VALUE rb_num_abs(VALUE x);
|
7
|
+
|
8
|
+
VALUE rb_num_uminus(VALUE x);
|
9
|
+
|
10
|
+
VALUE rb_num_real(VALUE z);
|
11
|
+
VALUE rb_num_imag(VALUE z);
|
12
|
+
|
13
|
+
bool rb_num_positive_p(VALUE z);
|
14
|
+
bool rb_num_negative_p(VALUE z);
|
15
|
+
|
16
|
+
bool rb_num_equal_p(VALUE lhs, VALUE rhs);
|
17
|
+
bool rb_num_notequal_p(VALUE lhs, VALUE rhs);
|
18
|
+
VALUE rb_num_cmpeql(VALUE lhs, VALUE rhs);
|
19
|
+
|
20
|
+
bool rb_num_zero_p(VALUE z);
|
21
|
+
bool rb_num_nonzero_p(VALUE z);
|
22
|
+
bool rb_num_real_p(VALUE z);
|
23
|
+
bool rb_num_finite_p(VALUE z);
|
24
|
+
int rb_num_infinite_p(VALUE z);
|
25
|
+
bool rb_num_nan_p(VALUE z);
|
26
|
+
|
27
|
+
bool rb_num_numeric_p(VALUE self);
|
28
|
+
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Rounds the argument +x+ to an arbitrary precision +prec+. <br>
|
32
|
+
* It targets real numbers, but also supports Complex class. <br>
|
33
|
+
*
|
34
|
+
*/
|
35
|
+
VALUE rb_num_round(VALUE x, VALUE prec);
|
36
|
+
|
37
|
+
#define ARG_REAL false
|
38
|
+
#define ARG_COMPLEX true
|
39
|
+
#define ARG_RAWVALUE false
|
40
|
+
#define ARG_RECIPROCAL true
|
41
|
+
|
42
|
+
VALUE
|
43
|
+
rb_num_canonicalize(VALUE x, VALUE prec, bool complex_form, bool inversion);
|
44
|
+
|
45
|
+
#define SIGN_PLUS false
|
46
|
+
#define SIGN_MINUS true
|
47
|
+
|
48
|
+
/**
|
49
|
+
* ```Ruby
|
50
|
+
* def rb_ImaginaryZ(z, signbit)
|
51
|
+
* if signbit
|
52
|
+
* -Complex::I * z
|
53
|
+
* else
|
54
|
+
* Complex::I * z
|
55
|
+
* end
|
56
|
+
* end
|
57
|
+
* ```
|
58
|
+
*/
|
59
|
+
VALUE rb_ImaginaryZ(VALUE z, bool signbit);
|
60
|
+
|
61
|
+
#define rb_funcall1(lhs, ops, rhs) rb_funcall((lhs), (ops), 1, (rhs))
|
62
|
+
|
63
|
+
#endif /* INTERNAL_API_NUMERIC */
|
@@ -0,0 +1,130 @@
|
|
1
|
+
/*******************************************************************************
|
2
|
+
math_r.c -- Entrypoint
|
3
|
+
|
4
|
+
Author: tribusonz
|
5
|
+
Licence: MIT
|
6
|
+
*******************************************************************************/
|
7
|
+
#include <ruby.h>
|
8
|
+
#define DEFINE_SYMBOL
|
9
|
+
#include "math_r/globals.h"
|
10
|
+
|
11
|
+
void InitVM_Overrides(void);
|
12
|
+
void InitVM_Const(void);
|
13
|
+
void InitVM_EDF(void);
|
14
|
+
void InitVM_Exp(void);
|
15
|
+
void InitVM_Log(void);
|
16
|
+
void InitVM_Trig(void);
|
17
|
+
void InitVM_Hyperb(void);
|
18
|
+
void InitVM_ComplexPlane(void);
|
19
|
+
void InitVM_EulerF(void);
|
20
|
+
void InitVM_LogRep(void);
|
21
|
+
void InitVM_Power(void);
|
22
|
+
void InitVM_Erf(void);
|
23
|
+
void InitVM_GammaR(void);
|
24
|
+
void InitVM_Solver(void);
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Document-module: BigMathR
|
28
|
+
*
|
29
|
+
* Refined BigMath module.
|
30
|
+
* It is a total solution for mathematics that also supports complex numbers.
|
31
|
+
*
|
32
|
+
* Reference::
|
33
|
+
* Utsukusii Suugaku wo egaku π, e, to Euler no teisuu γ (Japanese) - WAKAHARA Tatsuhiko (Kohdan-sha Editorial)
|
34
|
+
*/
|
35
|
+
void
|
36
|
+
Init_math_r(void)
|
37
|
+
{
|
38
|
+
mf_exp = rb_intern_const("exp");
|
39
|
+
mf_exp2 = rb_intern_const("exp2");
|
40
|
+
mf_expm1 = rb_intern_const("expm1");
|
41
|
+
|
42
|
+
mf_log = rb_intern_const("log");
|
43
|
+
mf_log2 = rb_intern_const("log2");
|
44
|
+
mf_log10 = rb_intern_const("log10");
|
45
|
+
mf_log1p = rb_intern_const("log1p");
|
46
|
+
|
47
|
+
mf_sqrt = rb_intern_const("sqrt");
|
48
|
+
mf_cbrt = rb_intern_const("cbrt");
|
49
|
+
|
50
|
+
mf_sin = rb_intern_const("sin");
|
51
|
+
mf_cos = rb_intern_const("cos");
|
52
|
+
mf_tan = rb_intern_const("tan");
|
53
|
+
mf_csc = rb_intern_const("csc");
|
54
|
+
mf_sec = rb_intern_const("sec");
|
55
|
+
mf_cot = rb_intern_const("cot");
|
56
|
+
|
57
|
+
mf_sinh = rb_intern_const("sinh");
|
58
|
+
mf_cosh = rb_intern_const("cosh");
|
59
|
+
mf_tanh = rb_intern_const("tanh");
|
60
|
+
mf_csch = rb_intern_const("csch");
|
61
|
+
mf_sech = rb_intern_const("sech");
|
62
|
+
mf_coth = rb_intern_const("coth");
|
63
|
+
|
64
|
+
mf_asin = rb_intern_const("asin");
|
65
|
+
mf_acos = rb_intern_const("acos");
|
66
|
+
mf_atan = rb_intern_const("atan");
|
67
|
+
mf_acsc = rb_intern_const("acsc");
|
68
|
+
mf_asec = rb_intern_const("asec");
|
69
|
+
mf_acot = rb_intern_const("acot");
|
70
|
+
|
71
|
+
mf_asinh = rb_intern_const("asinh");
|
72
|
+
mf_acosh = rb_intern_const("acosh");
|
73
|
+
mf_atanh = rb_intern_const("atanh");
|
74
|
+
mf_acsch = rb_intern_const("acsch");
|
75
|
+
mf_asech = rb_intern_const("asech");
|
76
|
+
mf_acoth = rb_intern_const("acoth");
|
77
|
+
|
78
|
+
rb_require("bigdecimal/math");
|
79
|
+
rb_cBigDecimal = rb_const_get_at(rb_cObject, rb_intern("BigDecimal"));
|
80
|
+
rb_mBigMath = rb_const_get_at(rb_cObject, rb_intern("BigMath"));
|
81
|
+
|
82
|
+
rb_mBigMathR = rb_define_module("BigMathR");
|
83
|
+
rb_mMathSolver = rb_define_module_under(rb_mBigMathR, "Solver");
|
84
|
+
|
85
|
+
InitVM(Overrides);
|
86
|
+
|
87
|
+
rb_mConst = rb_define_module_under(rb_mBigMathR, "Const");
|
88
|
+
rb_mConstPI = rb_define_module_under(rb_mConst, "PI");
|
89
|
+
rb_mConstE = rb_define_module_under(rb_mConst, "E");
|
90
|
+
rb_mConstLOG2 = rb_define_module_under(rb_mConst, "LOG2");
|
91
|
+
rb_mConstEulerGamma = rb_define_module_under(rb_mConst, "EulerGamma");
|
92
|
+
InitVM(Const);
|
93
|
+
|
94
|
+
rb_mEDF = rb_define_module_under(rb_mBigMathR, "EDF");
|
95
|
+
InitVM(EDF);
|
96
|
+
|
97
|
+
rb_mExp = rb_define_module_under(rb_mBigMathR, "Exp");
|
98
|
+
InitVM(Exp);
|
99
|
+
|
100
|
+
rb_mLog = rb_define_module_under(rb_mBigMathR, "Log");
|
101
|
+
InitVM(Log);
|
102
|
+
|
103
|
+
rb_mTrig = rb_define_module_under(rb_mBigMathR, "Trig");
|
104
|
+
InitVM(Trig);
|
105
|
+
|
106
|
+
rb_mHyperb = rb_define_module_under(rb_mBigMathR, "Hyperb");
|
107
|
+
InitVM(Hyperb);
|
108
|
+
|
109
|
+
rb_mComplexPlane = rb_define_module_under(rb_mBigMathR, "ComplexPlane");
|
110
|
+
InitVM(ComplexPlane);
|
111
|
+
|
112
|
+
rb_mEulerF = rb_define_module_under(rb_mBigMathR, "EulerF");
|
113
|
+
InitVM(EulerF);
|
114
|
+
|
115
|
+
rb_mLogRep = rb_define_module_under(rb_mBigMathR, "LogRep");
|
116
|
+
InitVM(LogRep);
|
117
|
+
|
118
|
+
rb_mPower = rb_define_module_under(rb_mBigMathR, "Power");
|
119
|
+
InitVM(Power);
|
120
|
+
|
121
|
+
rb_mErf = rb_define_module_under(rb_mBigMathR, "Erf");
|
122
|
+
InitVM(Erf);
|
123
|
+
|
124
|
+
rb_mGammaR = rb_define_module_under(rb_mBigMathR, "GammaR");
|
125
|
+
InitVM(GammaR);
|
126
|
+
|
127
|
+
rb_mSolver = rb_define_module_under(rb_mBigMathR, "Solver");
|
128
|
+
InitVM(Solver);
|
129
|
+
}
|
130
|
+
|
@@ -0,0 +1,158 @@
|
|
1
|
+
/*******************************************************************************
|
2
|
+
nucomp.c -- Complex Plane
|
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
|
+
/**
|
13
|
+
* @overload l2norm(*args, prec)
|
14
|
+
* Return solve of the euclidean norm (L2-norm) for argument as numerical sequence.
|
15
|
+
*
|
16
|
+
* @param *args [Array] Numerical sequence
|
17
|
+
* @param prec [Integer] Arbitrary precision
|
18
|
+
* @return [BigDecimal] Real solution
|
19
|
+
* @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
|
20
|
+
* @raise [TypeError] Occurs when +z+ is not a numeric class.
|
21
|
+
* @example
|
22
|
+
* BigMathR::ComplexPlane.l2norm(2, 4, 5, 20)
|
23
|
+
* #=> 0.670820393249936908923e1
|
24
|
+
* @since 0.1.0
|
25
|
+
*/
|
26
|
+
static VALUE
|
27
|
+
__impl_nucomp_l2norm(VALUE unused_obj, VALUE args)
|
28
|
+
{
|
29
|
+
if (RARRAY_LEN(args) < 2)
|
30
|
+
rb_raise(rb_eArgError,
|
31
|
+
"wrong number of arguments (given %ld, expected 2..)",
|
32
|
+
RARRAY_LEN(args));
|
33
|
+
VALUE prec = rb_ary_pop(args);
|
34
|
+
rb_check_precise(prec);
|
35
|
+
return rb_bigmath_l2norm(args, prec);
|
36
|
+
}
|
37
|
+
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Returns the hypotenuse of a right triangle with side lengths of +a+ and +b+.
|
41
|
+
* <br>
|
42
|
+
* The return value will definitely be a positive real number.
|
43
|
+
* <br>
|
44
|
+
* It is implemented by the norm,
|
45
|
+
* so even if the argument is a complex number,
|
46
|
+
* it will be a positive real number.
|
47
|
+
*
|
48
|
+
* @param a [Numeric] adjacent side or opposite side
|
49
|
+
* @param b [Numeric] adjacent side or opposite side
|
50
|
+
* @param prec [Integer] Arbitrary precision
|
51
|
+
* @return [BigDecimal] Real solution
|
52
|
+
* @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
|
53
|
+
* @raise [TypeError] Occurs when +x+ is not a numeric class.
|
54
|
+
* @since 0.1.0
|
55
|
+
*/
|
56
|
+
static VALUE
|
57
|
+
__impl_bigmathr_hypot(VALUE unused_obj, VALUE a, VALUE b, VALUE prec)
|
58
|
+
{
|
59
|
+
return rb_bigmath_hypot(a, b, prec);
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Return complex absolute of +z+.
|
64
|
+
*
|
65
|
+
* @param z [Numeric] Complex variable
|
66
|
+
* @param prec [Integer] Arbitrary precision
|
67
|
+
* @return [BigDecimal] Real solution
|
68
|
+
* @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
|
69
|
+
* @raise [TypeError] Occurs when +z+ is not a numeric class.
|
70
|
+
* @since 0.1.0
|
71
|
+
*/
|
72
|
+
static VALUE
|
73
|
+
__impl_nucomp_cabs(VALUE unused_obj, VALUE z, VALUE prec)
|
74
|
+
{
|
75
|
+
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
76
|
+
return rb_bigmath_cabs(z, prec);
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Consider where the value is in quadrant XY and computes the inverse tangent of +y/x+.
|
81
|
+
*
|
82
|
+
* @param x [Numeric] X-axis
|
83
|
+
* @param y [Numeric] Y-axis
|
84
|
+
* @param prec [Integer] Arbitrary precision
|
85
|
+
* @return [BigDecimal] Real solution
|
86
|
+
* @return [Complex] Complex solution
|
87
|
+
* @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
|
88
|
+
* @raise [TypeError] Occurs when +x+ is not a numeric class.
|
89
|
+
* @since 0.1.0
|
90
|
+
*/
|
91
|
+
static VALUE
|
92
|
+
__impl_nucomp_quadrant(VALUE unused_obj, VALUE x, VALUE y, VALUE prec)
|
93
|
+
{
|
94
|
+
return rb_bigmath_quadrant(x, y, prec);
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Consider where the value is in quadrant XY and computes the inverse tangent of +y/x+.
|
99
|
+
*
|
100
|
+
* @param y [Numeric] Y-axis
|
101
|
+
* @param x [Numeric] X-axis
|
102
|
+
* @param prec [Integer] Arbitrary precision
|
103
|
+
* @return [BigDecimal] Real solution
|
104
|
+
* @return [Complex] Complex solution
|
105
|
+
* @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
|
106
|
+
* @raise [TypeError] Occurs when +x+ is not a numeric class.
|
107
|
+
* @since 0.1.0
|
108
|
+
*/
|
109
|
+
static VALUE
|
110
|
+
__impl_bigmathr_atan2(VALUE unused_obj, VALUE y, VALUE x, VALUE prec)
|
111
|
+
{
|
112
|
+
return rb_bigmath_quadrant(x, y, prec);
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Return complex argument of +z+.
|
117
|
+
*
|
118
|
+
* @param z [Numeric] Complex variable
|
119
|
+
* @param prec [Integer] Arbitrary precision
|
120
|
+
* @return [BigDecimal] Real solution
|
121
|
+
* @raise [ArgumentError] Occurs when +prec+ is not a positive integer.
|
122
|
+
* @raise [TypeError] Occurs when +z+ is not a numeric class.
|
123
|
+
* @since 0.1.0
|
124
|
+
*/
|
125
|
+
static VALUE
|
126
|
+
__impl_nucomp_carg(VALUE unused_obj, VALUE z, VALUE prec)
|
127
|
+
{
|
128
|
+
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
129
|
+
return rb_bigmath_carg(z, prec);
|
130
|
+
}
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Document-module: BigMathR::ComplexPlane
|
134
|
+
*
|
135
|
+
* A module that provides whole of functions related to the complex plane.
|
136
|
+
* It is used internally.
|
137
|
+
* <br>
|
138
|
+
* == Synopsis
|
139
|
+
* The function names defined are the same as those in the C/C++ standard.
|
140
|
+
* <br>
|
141
|
+
* - Complex argument: +:carg+ <br>
|
142
|
+
* - Complex absolute: +:cabs+ <br>
|
143
|
+
* Follow, the name defined in C/C++ standard though, the function names are different.
|
144
|
+
* <br>
|
145
|
+
* - Quadrant XY: +:quadrant+ ( +:atan2+ in C/C++ ) <br>
|
146
|
+
*/
|
147
|
+
void
|
148
|
+
InitVM_ComplexPlane(void)
|
149
|
+
{
|
150
|
+
rb_define_module_function(rb_mComplexPlane, "l2norm", __impl_nucomp_l2norm, -2);
|
151
|
+
rb_define_module_function(rb_mComplexPlane, "cabs", __impl_nucomp_cabs, 2);
|
152
|
+
rb_define_module_function(rb_mComplexPlane, "quadrant", __impl_nucomp_quadrant, 3);
|
153
|
+
rb_define_module_function(rb_mComplexPlane, "carg", __impl_nucomp_carg, 2);
|
154
|
+
|
155
|
+
rb_define_module_function(rb_mBigMathR, "hypot", __impl_bigmathr_hypot, 3);
|
156
|
+
rb_define_module_function(rb_mBigMathR, "atan2", __impl_bigmathr_atan2, 3);
|
157
|
+
|
158
|
+
}
|
@@ -0,0 +1,91 @@
|
|
1
|
+
/*******************************************************************************
|
2
|
+
overrides.c -- Overriddem Methods
|
3
|
+
|
4
|
+
Author: tribusonz
|
5
|
+
License: 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
|
+
/**
|
13
|
+
* The #nan? method for primitive. Always return false.
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* 1.nan? #=> false
|
17
|
+
* @return [false] Whether self is Not a Number(NaN).
|
18
|
+
*/
|
19
|
+
static VALUE
|
20
|
+
numeric_nan_p(VALUE self)
|
21
|
+
{
|
22
|
+
return Qfalse;
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Calculates "i z" so inverts the real and imaginary maps of +z+.
|
27
|
+
*
|
28
|
+
* @example
|
29
|
+
* Complex.imaginary_z(1+2i) #=> (-2+1i)
|
30
|
+
* -Complex.imaginary_z(1+2i) #=> (2-1i)
|
31
|
+
* @param z [Numeric] Numerical argument
|
32
|
+
* @return [Complex] Solve
|
33
|
+
*/
|
34
|
+
static VALUE
|
35
|
+
__impl_nucomp_s_imaginary_z(VALUE self, VALUE z)
|
36
|
+
{
|
37
|
+
return rb_ImaginaryZ(z, SIGN_PLUS);
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Returns a boolean whether the object is a numeric class.
|
42
|
+
*
|
43
|
+
* @example
|
44
|
+
* 1.numeric? #=> true
|
45
|
+
* 1.0.numric? #=> true
|
46
|
+
* (1+1i).numeric? #=> true
|
47
|
+
* (1/3r).numeric? #=> true
|
48
|
+
* nil.numeric? #=> false
|
49
|
+
* "1.0".numeric? #=> false
|
50
|
+
* @return [bool] Whether +self+ is a numeric class
|
51
|
+
*/
|
52
|
+
static VALUE
|
53
|
+
__impl_obj_numeric_p(VALUE self)
|
54
|
+
{
|
55
|
+
return rb_num_numeric_p(self) ? Qtrue : Qfalse;
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Returns the reciprocal of itself with +prec+ as decimal precision.
|
60
|
+
* <br>
|
61
|
+
* If it is a complex number,
|
62
|
+
* computes (x / ||w||) - (y / ||w||) * i).
|
63
|
+
* <br>
|
64
|
+
* Where ||w|| = x^2 + y^2.
|
65
|
+
*
|
66
|
+
* @example
|
67
|
+
* 3.reciprocal(20) #=> 0.33333333333333333333e0
|
68
|
+
* -0.0.reciprocal(20) #=> -Infinity
|
69
|
+
* 1/3r.reciprocal(20) #=> 0.300000000000000000003e1
|
70
|
+
* (3.5r+1.5ri).reciprocal(20) #=> (0.24137931034482758621e0-0.10344827586206896552e0i)
|
71
|
+
* @param prec [Integer] Arbitrary precision
|
72
|
+
* @return [BigDecimal] Real solution
|
73
|
+
* @return [Complex] Complex solution
|
74
|
+
*/
|
75
|
+
static VALUE
|
76
|
+
__impl_numeric_reciprocal(VALUE self, VALUE prec)
|
77
|
+
{
|
78
|
+
if (rb_num_real_p(self))
|
79
|
+
return rb_num_canonicalize(self, prec, ARG_REAL, ARG_RECIPROCAL);
|
80
|
+
else
|
81
|
+
return rb_num_canonicalize(self, prec, ARG_COMPLEX, ARG_RECIPROCAL);
|
82
|
+
}
|
83
|
+
|
84
|
+
void
|
85
|
+
InitVM_Overrides(void)
|
86
|
+
{
|
87
|
+
rb_define_method(rb_cNumeric, "nan?", numeric_nan_p, 0);
|
88
|
+
rb_define_singleton_method(rb_cComplex, "imaginary_z", __impl_nucomp_s_imaginary_z, 1);
|
89
|
+
rb_define_method(rb_cObject, "numeric?", __impl_obj_numeric_p, 0);
|
90
|
+
rb_define_method(rb_cNumeric, "reciprocal", __impl_numeric_reciprocal, 1);
|
91
|
+
}
|