bigdecimal-math_r 0.2.1 → 0.2.3
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 +4 -4
- data/changelog.md +16 -0
- data/ext/bigdecimal/math_r/algofunc.h +11 -1
- data/ext/bigdecimal/math_r/api/bigmath/const_e.h +1 -1
- data/ext/bigdecimal/math_r/api/bigmath/const_euler_gamma.h +5 -0
- data/ext/bigdecimal/math_r/api/bigmath/csqrt.h +1 -1
- data/ext/bigdecimal/math_r/api/kernel/rb_BigDecimal_flo.h +8 -2
- data/ext/bigdecimal/math_r/api/numeric/nan_p.h +4 -1
- data/ext/bigdecimal/math_r/api.h +2 -0
- data/ext/bigdecimal/math_r/const.c +42 -5
- data/ext/bigdecimal/math_r/decl.h +11 -1
- data/ext/bigdecimal/math_r/exp.c +45 -3
- data/ext/bigdecimal/math_r/extconf.rb +5 -1
- data/ext/bigdecimal/math_r/{gamma_r.c → gamma_beta.c} +11 -78
- data/ext/bigdecimal/math_r/internal/algo/bigmath/E/{ser.h → napier.h} +1 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/EulerGamma/borwein_bailey.h +37 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG10/ser.h +4 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/LOG_PI/builtin.h +3 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT2/builtin.h +4 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/SQRT3/builtin.h +4 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/edom.h +7 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acot/logrep.h +9 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/edom.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acoth/logrep.h +5 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/edom.h +7 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsc/logrep.h +6 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsch/logrep.h +7 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/edom.h +7 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/logrep.h +8 -7
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/edom.h +10 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asech/logrep.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/edom.h +6 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/logrep.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asin/ser.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/logrep.h +6 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asinh/ser.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/logrep.h +7 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/ser_euler.h +2 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/edom.h +6 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/logrep.h +2 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/ser.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cabs/formula.h +6 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacos/logrep.h +7 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacosh/logrep.h +6 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacot/logrep.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacoth/logrep.h +8 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsc/logrep.h +5 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsch/logrep.h +7 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/carg/formula.h +6 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casec/logrep.h +5 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casech/logrep.h +3 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casin/logrep.h +6 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casinh/logrep.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catan/logrep.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catanh/logrep.h +5 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccbrt/branch.h +40 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccbrt/formula.h +5 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccos/eulerf.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccosh/eulerf.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccot/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccoth/eulerf.h +4 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsc/eulerf.h +4 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccsch/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp/eulerf.h +10 -7
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexp2/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexpm1/branch.h +13 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cexpm1/identity.h +17 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog/branch.h +11 -12
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog10/branch.h +53 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog10/formula.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog2/branch.h +53 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/clog2/formula.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/eulerf.h +6 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cos/ser.h +4 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/formula.h +5 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cosh/ser.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cot/ser.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/eulerf.h +4 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/formula.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/coth/ser.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cpow/formula.h +7 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/eulerf.h +4 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csc/ser.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/formula.h +2 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csch/ser.h +6 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csec/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csech/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csin/eulerf.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csinh/eulerf.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csqrt/branch.h +40 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/csqrt/formula.h +13 -43
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ctan/eulerf.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ctanh/eulerf.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cuberoot/branch.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cuberoot/newton.h +4 -12
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/algo911.h +7 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/cf.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_inf.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erf/ser_zero.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/algo911.h +5 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/erfc/cf.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/escalb/edf.h +2 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/builtin.h +7 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp/edf.h +6 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/exp2/edf.h +9 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/expm1/branch.h +13 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/expm1/identity.h +18 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/expxt/edf.h +1 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/f_euler/formula.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/l2norm.h +5 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/hypot/mmm.h +1 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ipow/edf.h +6 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/l2norm/formula.h +6 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/branch.h +6 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/builtin.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edf.h +8 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/edom.h +10 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/mercator.h +7 -9
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log/ser_okumura.h +4 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/edf.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log10/mercator.h +9 -9
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/branch.h +8 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log1p/ser_mercator.h +16 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/branch.h +1 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/edf.h +3 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/log2/mercator.h +9 -9
- data/ext/bigdecimal/math_r/internal/algo/bigmath/logxt/edf.h +6 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/pow/formula.h +13 -8
- data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm10/edf.h +10 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/rcm2/edf.h +11 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sec/ser.h +6 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/formula.h +8 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sech/ser.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/eulerf.h +5 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sin/ser.h +4 -5
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sincos/ser.h +9 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/formula.h +8 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinh/ser.h +4 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sinhcosh/ser.h +10 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/builtin.h +2 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/sqrt/edom.h +1 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tan/ser.h +3 -8
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/eulerf.h +5 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/formula.h +7 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/tanh/ser.h +3 -3
- data/ext/bigdecimal/math_r/internal/algo/bigmath/trig/f_euler.h +11 -5
- data/ext/bigdecimal/math_r/log.c +2 -2
- data/ext/bigdecimal/math_r/math_r/bigdecimal.h +5 -1
- data/ext/bigdecimal/math_r/math_r/bigmath.h +2 -0
- data/ext/bigdecimal/math_r/math_r/globals.h +1 -1
- data/ext/bigdecimal/math_r/math_r.c +5 -3
- data/lib/bigdecimal/math_r/const/E_euler.rb +46 -0
- data/lib/bigdecimal/math_r/version.rb +1 -1
- data/lib/bigdecimal/math_r.rb +1 -0
- data/lib/bigdecimal/math_r.so +0 -0
- metadata +20 -9
- data/.ruby-version +0 -1
@@ -1,21 +1,22 @@
|
|
1
1
|
VALUE
|
2
2
|
cpow_formula(VALUE z, VALUE w, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE a = Qundef;
|
4
|
+
VALUE a = Qundef, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
9
|
if (rb_num_positive_p(rb_num_real(z)) &&
|
9
10
|
rb_num_zero_p(rb_num_imag(z)) && rb_num_zero_p(rb_num_imag(w)))
|
10
11
|
{
|
11
|
-
a = pow_formula(rb_num_real(z), rb_num_real(w),
|
12
|
-
a = rb_num_canonicalize(a,
|
12
|
+
a = pow_formula(rb_num_real(z), rb_num_real(w), n);
|
13
|
+
a = rb_num_canonicalize(a, n, ARG_COMPLEX, ARG_RAWVALUE);
|
13
14
|
}
|
14
15
|
else
|
15
16
|
{
|
16
|
-
a = rb_bigmath_clog(z,
|
17
|
+
a = rb_bigmath_clog(z, n);
|
17
18
|
a = rb_funcall1(w, '*', a);
|
18
|
-
a = rb_bigmath_cexp(a,
|
19
|
+
a = rb_bigmath_cexp(a, n);
|
19
20
|
}
|
20
|
-
return a;
|
21
|
+
return rb_num_round(a, prec);
|
21
22
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
csc_eulerf(VALUE z, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
9
|
w = trig_f_euler(mf_sin, rb_ImaginaryZ(z, SIGN_PLUS), prec);
|
10
|
+
w = rb_num_canonicalize(w, n, ARG_REAL, ARG_RECIPROCAL);
|
9
11
|
|
10
|
-
return
|
12
|
+
return rb_num_round(w, prec);
|
11
13
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
csc_ser(VALUE x, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE sin;
|
4
|
+
VALUE sin, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
rb_bigmath_sincos(x,
|
9
|
+
rb_bigmath_sincos(x, n, &sin, NULL);
|
10
|
+
sin = rb_num_canonicalize(sin, n, ARG_REAL, ARG_RECIPROCAL);
|
9
11
|
|
10
|
-
return
|
12
|
+
return rb_num_round(sin, prec);
|
11
13
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
csch_eulerf(VALUE x, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE y;
|
4
|
+
VALUE y, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
y = rb_ImaginaryZ(trig_f_euler(mf_sin, x,
|
9
|
+
y = rb_ImaginaryZ(trig_f_euler(mf_sin, x, n), SIGN_PLUS);
|
10
|
+
y = rb_num_canonicalize(y, n, ARG_REAL, ARG_RECIPROCAL);
|
9
11
|
|
10
|
-
return
|
12
|
+
return rb_num_round(y, prec);
|
11
13
|
}
|
@@ -6,8 +6,8 @@ csch_formula(VALUE x, VALUE prec)
|
|
6
6
|
int sign;
|
7
7
|
|
8
8
|
rb_check_precise(prec);
|
9
|
-
|
10
9
|
n = rb_numdiff_make_n(prec);
|
10
|
+
|
11
11
|
t = rb_bigmath_exp(x, n);
|
12
12
|
y = Qundef;
|
13
13
|
two = rb_BigDecimal1(INT2FIX(2));
|
@@ -22,7 +22,7 @@ csch_formula(VALUE x, VALUE prec)
|
|
22
22
|
y = sign == 1 ? BIG_ZERO : BIG_MINUS_ZERO;
|
23
23
|
else
|
24
24
|
{
|
25
|
-
y = rb_num_canonicalize(t,
|
25
|
+
y = rb_num_canonicalize(t, n, ARG_REAL, ARG_RECIPROCAL);
|
26
26
|
y = rb_funcall1(t, '-', y);
|
27
27
|
y = rb_funcall(two, div, 2, y, prec);
|
28
28
|
}
|
@@ -1,11 +1,14 @@
|
|
1
1
|
VALUE
|
2
2
|
csch_ser(VALUE x, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE y = Qundef;
|
4
|
+
VALUE y = Qundef, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
sinhcosh_ser(x,
|
9
|
+
sinhcosh_ser(x, n, &y, NULL);
|
9
10
|
|
10
|
-
|
11
|
+
y = rb_num_canonicalize(y, n, ARG_REAL, ARG_RECIPROCAL);
|
12
|
+
|
13
|
+
return rb_num_round(y, prec);
|
11
14
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
csec_eulerf(VALUE z, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
w = trig_f_euler(mf_cos, rb_ImaginaryZ(z, SIGN_PLUS),
|
9
|
+
w = trig_f_euler(mf_cos, rb_ImaginaryZ(z, SIGN_PLUS), n);
|
10
|
+
w = rb_num_canonicalize(w, n, ARG_COMPLEX, ARG_RECIPROCAL);
|
9
11
|
|
10
|
-
return
|
12
|
+
return rb_num_round(w, prec);
|
11
13
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
csech_eulerf(VALUE z, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
w = trig_f_euler(mf_cos, z,
|
9
|
+
w = trig_f_euler(mf_cos, z, n);
|
10
|
+
w = rb_num_canonicalize(w, n, ARG_COMPLEX, ARG_RECIPROCAL);
|
9
11
|
|
10
|
-
return
|
12
|
+
return rb_num_round(w, prec);
|
11
13
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
csin_eulerf(VALUE z, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
w = trig_f_euler(mf_sin, rb_ImaginaryZ(z, SIGN_PLUS),
|
9
|
+
w = trig_f_euler(mf_sin, rb_ImaginaryZ(z, SIGN_PLUS), n);
|
9
10
|
|
10
|
-
return w;
|
11
|
+
return rb_num_round(w, prec);
|
11
12
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
csinh_eulerf(VALUE z, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
w = rb_ImaginaryZ(trig_f_euler(mf_sin, z,
|
9
|
+
w = rb_ImaginaryZ(trig_f_euler(mf_sin, z, n), SIGN_PLUS);
|
9
10
|
|
10
|
-
return w;
|
11
|
+
return rb_num_round(w, prec);
|
11
12
|
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
VALUE
|
2
|
+
csqrt_branch(VALUE z, VALUE prec, bigmath_func1 csqrt_cb)
|
3
|
+
{
|
4
|
+
VALUE w = Qundef;
|
5
|
+
|
6
|
+
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
7
|
+
|
8
|
+
if (rb_num_nan_p(z))
|
9
|
+
{
|
10
|
+
w = rb_Complex(BIG_NAN, BIG_NAN);
|
11
|
+
}
|
12
|
+
else if (!rb_num_finite_p(z))
|
13
|
+
{
|
14
|
+
int re_sgn = rb_num_infinite_p(rb_num_real(z));
|
15
|
+
int im_sgn = rb_num_infinite_p(rb_num_imag(z));
|
16
|
+
if (re_sgn != 0 && im_sgn == 0)
|
17
|
+
{
|
18
|
+
switch (re_sgn) {
|
19
|
+
case 1:
|
20
|
+
w = rb_Complex1(BIG_INF);
|
21
|
+
break;
|
22
|
+
case -1:
|
23
|
+
w = rb_Complex(BIG_ZERO, BIG_INF);
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
else
|
28
|
+
{
|
29
|
+
w = rb_Complex(
|
30
|
+
BIG_INF,
|
31
|
+
rb_num_coerce_bin(im_sgn, BIG_INF, '*')
|
32
|
+
);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
if (w == Qundef)
|
36
|
+
{
|
37
|
+
w = csqrt_cb(z, prec);
|
38
|
+
}
|
39
|
+
return w;
|
40
|
+
}
|
@@ -16,51 +16,21 @@ csqrt_term(VALUE abs, VALUE a, VALUE prec, ID ops)
|
|
16
16
|
VALUE
|
17
17
|
csqrt_formula(VALUE z, VALUE prec)
|
18
18
|
{
|
19
|
-
|
19
|
+
const ID add = rb_intern("add"), sub = rb_intern("sub");
|
20
|
+
VALUE w = Qundef, abs, re, im, sgn, n;
|
20
21
|
|
21
22
|
rb_check_precise(prec);
|
23
|
+
n = rb_numdiff_make_n(prec);
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
(rb_num_infinite_p(rb_num_imag(z))) != 0)
|
28
|
-
{
|
29
|
-
switch (re_sgn) {
|
30
|
-
case 1:
|
31
|
-
w = rb_Complex1(BIG_INF);
|
32
|
-
break;
|
33
|
-
case -1:
|
34
|
-
w = rb_Complex(BIG_ZERO, BIG_INF);
|
35
|
-
break;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
else if ((im_sgn = rb_num_infinite_p(rb_num_imag(z))) != 0)
|
39
|
-
{
|
40
|
-
w = rb_Complex(
|
41
|
-
BIG_INF,
|
42
|
-
rb_num_coerce_bin(im_sgn, BIG_INF, '*')
|
43
|
-
);
|
44
|
-
}
|
45
|
-
else
|
46
|
-
{
|
47
|
-
w = rb_Complex(BIG_NAN, BIG_NAN);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
else // if (rb_num_finite_p(z))
|
51
|
-
{
|
52
|
-
const ID add = rb_intern("add"), sub = rb_intern("sub");
|
53
|
-
VALUE abs = rb_bigmath_cabs(z, prec),
|
54
|
-
re = csqrt_term(abs, rb_num_real(z), prec, add),
|
55
|
-
im = csqrt_term(abs, rb_num_real(z), prec, sub),
|
56
|
-
sgn = rb_num_cmpeql(rb_num_imag(z), INT2NUM(0));
|
57
|
-
if (rb_num_nonzero_p(sgn))
|
58
|
-
w = rb_Complex(re, rb_num_coerce_bin(sgn, im, '*'));
|
59
|
-
else
|
60
|
-
w = rb_Complex(re, im);
|
61
|
-
}
|
62
|
-
if (w == Qundef)
|
63
|
-
rb_raise(rb_eRuntimeError, "no solution");
|
25
|
+
abs = rb_bigmath_cabs(z, n);
|
26
|
+
re = csqrt_term(abs, rb_num_real(z), n, add);
|
27
|
+
im = csqrt_term(abs, rb_num_real(z), n, sub);
|
28
|
+
sgn = rb_num_cmpeql(rb_num_imag(z), INT2NUM(0));
|
64
29
|
|
65
|
-
|
30
|
+
if (rb_num_nonzero_p(sgn))
|
31
|
+
w = rb_Complex(re, rb_num_coerce_bin(sgn, im, '*'));
|
32
|
+
else
|
33
|
+
w = rb_Complex(re, im);
|
34
|
+
|
35
|
+
return rb_num_round(w, prec);
|
66
36
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
ctan_eulerf(VALUE z, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
w = trig_f_euler(mf_tan, rb_ImaginaryZ(z, SIGN_PLUS),
|
9
|
+
w = trig_f_euler(mf_tan, rb_ImaginaryZ(z, SIGN_PLUS), n);
|
9
10
|
|
10
|
-
return w;
|
11
|
+
return rb_num_round(w, prec);
|
11
12
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
ctanh_eulerf(VALUE z, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
w = rb_ImaginaryZ(trig_f_euler(mf_tan, z,
|
9
|
+
w = rb_ImaginaryZ(trig_f_euler(mf_tan, z, n), SIGN_PLUS);
|
9
10
|
|
10
|
-
return w;
|
11
|
+
return rb_num_round(w, prec);
|
11
12
|
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
VALUE
|
2
|
+
cuberoot_branch(VALUE x, VALUE prec, bigmath_func1 cuberoot_cb)
|
3
|
+
{
|
4
|
+
bool positive;
|
5
|
+
|
6
|
+
x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RAWVALUE);
|
7
|
+
|
8
|
+
if (!rb_num_finite_p(x) || rb_num_zero_p(x))
|
9
|
+
return x;
|
10
|
+
positive = rb_num_positive_p(x) ? true : false;
|
11
|
+
|
12
|
+
if (!positive)
|
13
|
+
x = rb_num_uminus(x);
|
14
|
+
|
15
|
+
x = cuberoot_cb(x, prec);
|
16
|
+
|
17
|
+
return positive ? x : rb_num_uminus(x);
|
18
|
+
}
|
@@ -2,19 +2,11 @@ VALUE
|
|
2
2
|
cuberoot_newton(VALUE x, VALUE prec)
|
3
3
|
{
|
4
4
|
const ID div = rb_intern("div");
|
5
|
-
VALUE s = Qundef, t = Qundef, prev = Qundef;
|
5
|
+
VALUE s = Qundef, t = Qundef, prev = Qundef, n;
|
6
6
|
VALUE two, three;
|
7
|
-
bool positive;
|
8
7
|
|
9
|
-
x = rb_num_canonicalize(x, prec, ARG_REAL, ARG_RAWVALUE);
|
10
8
|
rb_check_precise(prec);
|
11
|
-
|
12
|
-
if (!rb_num_finite_p(x) || rb_num_zero_p(x))
|
13
|
-
return x;
|
14
|
-
positive = rb_num_positive_p(x) ? true : false;
|
15
|
-
|
16
|
-
if (!positive)
|
17
|
-
x = rb_num_uminus(x);
|
9
|
+
n = rb_numdiff_make_n(prec);
|
18
10
|
|
19
11
|
if (RTEST(rb_num_coerce_cmp(x, INT2FIX(1), '>')))
|
20
12
|
s = x;
|
@@ -29,7 +21,7 @@ cuberoot_newton(VALUE x, VALUE prec)
|
|
29
21
|
t = rb_funcall1(s, '*', s);
|
30
22
|
t = rb_funcall1(x, '/', t);
|
31
23
|
t = rb_funcall1(t, '+', rb_funcall1(two, '*', s));
|
32
|
-
s = rb_funcall(t, div, 2, three,
|
24
|
+
s = rb_funcall(t, div, 2, three, n);
|
33
25
|
} while (RTEST(rb_num_coerce_cmp(s, prev, '<')));
|
34
26
|
|
35
27
|
RB_GC_GUARD(s);
|
@@ -38,5 +30,5 @@ cuberoot_newton(VALUE x, VALUE prec)
|
|
38
30
|
RB_GC_GUARD(two);
|
39
31
|
RB_GC_GUARD(three);
|
40
32
|
|
41
|
-
return
|
33
|
+
return rb_num_round(prev, prec);
|
42
34
|
}
|
@@ -4,15 +4,18 @@ erf_algo911(VALUE x, VALUE prec)
|
|
4
4
|
const ID div = rb_intern("div");
|
5
5
|
const ID leq = rb_intern("<=");
|
6
6
|
const ID pow = rb_intern("**");
|
7
|
-
VALUE absx, bc, n, y = Qundef;
|
7
|
+
VALUE absx, bc, log10, n, y = Qundef;
|
8
8
|
VALUE zero_six = rb_BigDecimal1(rb_str_new_cstr("0.6"));
|
9
9
|
VALUE four_one = rb_BigDecimal1(rb_str_new_cstr("4.1"));
|
10
10
|
|
11
|
+
rb_check_precise(prec);
|
11
12
|
n = rb_numdiff_make_n(prec);
|
12
13
|
|
13
14
|
absx = rb_num_abs(x);
|
14
|
-
|
15
|
-
|
15
|
+
log10 = rb_bigmath_const_log10(n);
|
16
|
+
|
17
|
+
bc = rb_BigDecimal1(rb_funcall1(n, '+', INT2FIX(21)));
|
18
|
+
bc = rb_funcall1(bc, '*', log10);
|
16
19
|
bc = rb_bigmath_sqrt(bc, n);
|
17
20
|
bc = rb_funcall(bc, div, 2, INT2FIX(5), n);
|
18
21
|
if (rb_num_coerce_cmp(absx, bc, leq))
|
@@ -21,7 +24,7 @@ erf_algo911(VALUE x, VALUE prec)
|
|
21
24
|
goto retval;
|
22
25
|
}
|
23
26
|
bc = rb_funcall1(prec, '+', INT2FIX(6));
|
24
|
-
bc = rb_funcall1(bc, '*',
|
27
|
+
bc = rb_funcall1(bc, '*', log10);
|
25
28
|
bc = rb_funcall1(bc, pow, zero_six);
|
26
29
|
bc = rb_funcall(bc, div, 2, four_one, n);
|
27
30
|
if (rb_num_coerce_cmp(absx, bc, leq))
|
@@ -4,14 +4,17 @@ erfc_algo911(VALUE x, VALUE prec)
|
|
4
4
|
const ID div = rb_intern("div");
|
5
5
|
const ID leq = rb_intern("<=");
|
6
6
|
const ID pow = rb_intern("**");
|
7
|
-
VALUE bc, n, y = Qundef;
|
7
|
+
VALUE bc, n, log10, y = Qundef;
|
8
8
|
VALUE zero_seven = rb_BigDecimal1(rb_str_new_cstr("0.7"));
|
9
9
|
VALUE nine = rb_BigDecimal1(INT2FIX(9));
|
10
10
|
|
11
|
+
rb_check_precise(prec);
|
11
12
|
n = rb_numdiff_make_n(prec);
|
12
13
|
|
14
|
+
log10 = rb_bigmath_const_log10(n);
|
15
|
+
|
13
16
|
bc = rb_funcall1(prec, '+', INT2FIX(6));
|
14
|
-
bc = rb_funcall1(bc, '*',
|
17
|
+
bc = rb_funcall1(bc, '*', log10);
|
15
18
|
bc = rb_funcall1(bc, pow, zero_seven);
|
16
19
|
bc = rb_funcall(bc, div, 2, nine, n);
|
17
20
|
if (rb_num_coerce_cmp(x, bc, leq))
|
@@ -8,6 +8,8 @@ escalb_edf(VALUE a, VALUE x, VALUE prec, VALUE *exp, VALUE *fra)
|
|
8
8
|
const ID MAX_10_EXP = rb_intern("MAX_10_EXP");
|
9
9
|
VALUE max_10_exp = rb_const_get_at(rb_cFloat, MAX_10_EXP);
|
10
10
|
|
11
|
+
rb_check_precise(prec);
|
12
|
+
|
11
13
|
if (!rb_num_finite_p(a) && !rb_num_positive_p(a))
|
12
14
|
rb_raise(rb_eRangeError, "parameter a must be positive finite");
|
13
15
|
switch (TYPE(x)) {
|
@@ -1,6 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
exp_builtin(VALUE x, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE y
|
4
|
+
VALUE y, n;
|
5
|
+
|
6
|
+
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
8
|
+
|
9
|
+
y = rb_funcall(rb_mBigMath, mf_exp, 2, x, n);
|
10
|
+
|
5
11
|
return rb_num_round(y, prec);
|
6
12
|
}
|
@@ -2,22 +2,23 @@ VALUE
|
|
2
2
|
exp_edf(VALUE x, VALUE prec)
|
3
3
|
{
|
4
4
|
const ID mult = rb_intern("mult");
|
5
|
-
VALUE exp = Qundef, fra = Qundef;
|
5
|
+
VALUE exp = Qundef, fra = Qundef, n;
|
6
6
|
|
7
7
|
rb_check_precise(prec);
|
8
|
+
n = rb_numdiff_make_n(prec);
|
8
9
|
|
9
10
|
if (rb_num_notequal_p(x, x))
|
10
11
|
return BIG_NAN;
|
11
|
-
rb_bigmath_escalb(rb_bigmath_const_e(
|
12
|
+
rb_bigmath_escalb(rb_bigmath_const_e(n), x, n, &exp, &fra);
|
12
13
|
if (exp == Qundef || fra == Qundef)
|
13
14
|
rb_raise(rb_eRuntimeError, "no solution");
|
14
15
|
if (rb_num_infinite_p(exp) ||
|
15
16
|
rb_num_zero_p(exp) ||
|
16
17
|
rb_num_zero_p(fra))
|
17
|
-
return rb_num_round(exp,
|
18
|
-
fra = rb_bigmath_expxt(fra, BIG_ONE,
|
18
|
+
return rb_num_round(exp, n);
|
19
|
+
fra = rb_bigmath_expxt(fra, BIG_ONE, n);
|
19
20
|
if (CLASS_OF(exp) != rb_cBigDecimal)
|
20
|
-
exp = rb_num_canonicalize(exp,
|
21
|
+
exp = rb_num_canonicalize(exp, n, ARG_REAL, ARG_RAWVALUE);
|
21
22
|
|
22
23
|
return rb_funcall(exp, mult, 2, fra, prec);
|
23
24
|
}
|
@@ -2,18 +2,22 @@ VALUE
|
|
2
2
|
exp2_edf(VALUE x, VALUE prec)
|
3
3
|
{
|
4
4
|
const ID mult = rb_intern("mult");
|
5
|
-
VALUE exp = Qundef, fra = Qundef;
|
5
|
+
VALUE exp = Qundef, fra = Qundef, n;
|
6
|
+
|
7
|
+
rb_check_precise(prec);
|
8
|
+
n = rb_numdiff_make_n(prec);
|
9
|
+
|
6
10
|
if (rb_num_notequal_p(x, x))
|
7
11
|
return BIG_NAN;
|
8
|
-
rb_bigmath_escalb(INT2FIX(2), x,
|
12
|
+
rb_bigmath_escalb(INT2FIX(2), x, n, &exp, &fra);
|
9
13
|
if (exp == Qundef || fra == Qundef)
|
10
14
|
rb_raise(rb_eRuntimeError, "no solution");
|
11
15
|
if (rb_num_infinite_p(exp) ||
|
12
16
|
rb_num_zero_p(exp) ||
|
13
17
|
rb_num_zero_p(fra))
|
14
|
-
return rb_num_round(exp,
|
15
|
-
fra = rb_bigmath_expxt(fra, rb_bigmath_const_log2(
|
18
|
+
return rb_num_round(exp, n);
|
19
|
+
fra = rb_bigmath_expxt(fra, rb_bigmath_const_log2(n), n);
|
16
20
|
if (CLASS_OF(exp) != rb_cBigDecimal)
|
17
|
-
exp = rb_num_canonicalize(exp,
|
21
|
+
exp = rb_num_canonicalize(exp, n, ARG_REAL, ARG_RAWVALUE);
|
18
22
|
return rb_funcall(exp, mult, 2, fra, prec);
|
19
23
|
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
VALUE
|
2
|
+
expm1_identity(VALUE x, VALUE prec)
|
3
|
+
{
|
4
|
+
const ID mult = rb_intern("mult");
|
5
|
+
VALUE y = Qundef;
|
6
|
+
VALUE two = rb_BigDecimal1(INT2FIX(2));
|
7
|
+
VALUE n;
|
8
|
+
|
9
|
+
rb_check_precise(prec);
|
10
|
+
n = rb_numdiff_make_n(prec);
|
11
|
+
|
12
|
+
x = rb_funcall1(x, '/', two);
|
13
|
+
|
14
|
+
y = rb_funcall1(rb_bigmath_exp(x, n), '*', sinh_branch(x, n, sinh_formula));
|
15
|
+
y = rb_funcall(two, mult, 2, y, prec);
|
16
|
+
|
17
|
+
return y;
|
18
|
+
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
f_euler_formula(VALUE theta, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE sin, cos;
|
4
|
+
VALUE sin, cos, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
rb_bigmath_sincos(theta,
|
9
|
+
rb_bigmath_sincos(theta, n, &sin, &cos);
|
9
10
|
|
10
11
|
return rb_Complex(cos, sin);
|
11
12
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
hypot_l2norm(VALUE a, VALUE b, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE w;
|
4
|
+
VALUE w, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
8
|
+
|
9
|
+
w = rb_bigmath_l2norm(rb_assoc_new(a, b), n);
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
return w;
|
11
|
+
return rb_num_round(w, prec);
|
11
12
|
}
|