bigdecimal-math_r 0.2.0 → 0.2.2
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/README.md +63 -10
- data/changelog.md +32 -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/domain_p.h +7 -0
- 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/acos/branch.h +11 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acosh/branch.h +2 -2
- 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/branch.h +4 -4
- 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/branch.h +3 -4
- 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/branch.h +3 -9
- data/ext/bigdecimal/math_r/internal/algo/bigmath/acsch/logrep.h +7 -6
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/branch.h +7 -4
- 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/branch.h +2 -5
- 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/branch.h +4 -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/branch.h +1 -1
- 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 +4 -50
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atan/ser_usual.h +2 -9
- data/ext/bigdecimal/math_r/internal/algo/bigmath/atanh/branch.h +4 -3
- 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 +9 -7
- 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/branch.h +2 -1
- 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 +5 -5
- 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/numeric.h +1 -0
- data/ext/bigdecimal/math_r/math_r.c +14 -3
- data/ext/bigdecimal/math_r/solver.c +75 -21
- 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
- metadata +21 -11
- data/.ruby-version +0 -1
- data/LICENSE.txt +0 -21
- data/lib/bigdecimal/math_r.so +0 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
VALUE
|
2
|
+
cexpm1_branch(VALUE z, VALUE prec, bigmath_func1 cexpm1_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
|
+
w = rb_Complex(BIG_NAN, BIG_NAN);
|
10
|
+
else
|
11
|
+
w = cexpm1_cb(z, prec);
|
12
|
+
return w;
|
13
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
VALUE
|
2
|
+
cexpm1_identity(VALUE x, VALUE prec)
|
3
|
+
{
|
4
|
+
VALUE y = Qundef;
|
5
|
+
VALUE two = rb_BigDecimal1(INT2FIX(2));
|
6
|
+
VALUE n;
|
7
|
+
|
8
|
+
rb_check_precise(prec);
|
9
|
+
n = rb_numdiff_make_n(prec);
|
10
|
+
|
11
|
+
x = rb_funcall1(x, '/', two);
|
12
|
+
|
13
|
+
y = rb_funcall1(rb_bigmath_cexp(x, n), '*', csinh_branch(x, n, csinh_eulerf));
|
14
|
+
y = rb_funcall1(two, '*', y);
|
15
|
+
|
16
|
+
return rb_num_round(y, prec);
|
17
|
+
}
|
@@ -5,15 +5,17 @@ clog_branch(VALUE z, VALUE prec, bigmath_func1 clog_cb)
|
|
5
5
|
|
6
6
|
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
7
7
|
|
8
|
-
if (
|
8
|
+
if (rb_num_nan_p(z))
|
9
9
|
{
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
w = rb_Complex(BIG_NAN, BIG_NAN);
|
11
|
+
}
|
12
|
+
else if (!rb_num_finite_p(z))
|
13
|
+
{
|
14
|
+
int re_inf_sgn = rb_num_infinite_p(rb_num_real(z));
|
15
|
+
int im_inf_sgn = rb_num_infinite_p(rb_num_imag(z));
|
16
|
+
if (re_inf_sgn != 0 && im_inf_sgn == 0)
|
15
17
|
{
|
16
|
-
switch (
|
18
|
+
switch (re_inf_sgn) {
|
17
19
|
case -1:
|
18
20
|
arg = rb_num_imag(clog_cb(BIG_MINUS_ONE, prec));
|
19
21
|
w = rb_Complex(BIG_INF, arg);
|
@@ -23,7 +25,7 @@ clog_branch(VALUE z, VALUE prec, bigmath_func1 clog_cb)
|
|
23
25
|
break;
|
24
26
|
}
|
25
27
|
}
|
26
|
-
else if (
|
28
|
+
else if (re_inf_sgn == 0 && im_inf_sgn != 0)
|
27
29
|
{
|
28
30
|
switch (rb_num_infinite_p(rb_num_imag(z))) {
|
29
31
|
case -1:
|
@@ -40,10 +42,7 @@ clog_branch(VALUE z, VALUE prec, bigmath_func1 clog_cb)
|
|
40
42
|
}
|
41
43
|
else /* log(INF +i INF) */
|
42
44
|
{
|
43
|
-
w =
|
44
|
-
rb_BigDecimal1(rb_num_real(z)),
|
45
|
-
rb_BigDecimal1(rb_num_imag(z))
|
46
|
-
);
|
45
|
+
w = z;
|
47
46
|
}
|
48
47
|
}
|
49
48
|
if (w == Qundef)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
VALUE
|
2
|
+
clog10_branch(VALUE z, VALUE prec, bigmath_func1 clog10_cb)
|
3
|
+
{
|
4
|
+
VALUE w = Qundef, arg = 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_inf_sgn = rb_num_infinite_p(rb_num_real(z));
|
15
|
+
int im_inf_sgn = rb_num_infinite_p(rb_num_imag(z));
|
16
|
+
if (re_inf_sgn != 0 && im_inf_sgn == 0)
|
17
|
+
{
|
18
|
+
switch (re_inf_sgn) {
|
19
|
+
case -1:
|
20
|
+
arg = rb_num_imag(clog10_cb(BIG_MINUS_ONE, prec));
|
21
|
+
w = rb_Complex(BIG_INF, arg);
|
22
|
+
break;
|
23
|
+
case 1:
|
24
|
+
w = rb_Complex(BIG_INF, BIG_ZERO);
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
else if (re_inf_sgn == 0 && im_inf_sgn != 0)
|
29
|
+
{
|
30
|
+
switch (rb_num_infinite_p(rb_num_imag(z))) {
|
31
|
+
case -1:
|
32
|
+
arg = rb_num_imag(
|
33
|
+
clog10_cb(rb_Complex(BIG_ZERO, BIG_MINUS_ONE), prec));
|
34
|
+
w = rb_Complex(BIG_INF, arg);
|
35
|
+
break;
|
36
|
+
case 1:
|
37
|
+
arg = rb_num_imag(
|
38
|
+
clog10_cb(rb_Complex(BIG_ZERO, BIG_ONE), prec));
|
39
|
+
w = rb_Complex(BIG_INF, arg);
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
else /* log(INF +i INF) */
|
44
|
+
{
|
45
|
+
w = z;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
if (w == Qundef)
|
49
|
+
{
|
50
|
+
w = clog10_cb(z, prec);
|
51
|
+
}
|
52
|
+
return w;
|
53
|
+
}
|
@@ -1,12 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
clog10_formula(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 =
|
9
|
-
w = rb_funcall1(w, '/', rb_bigmath_const_log10(
|
9
|
+
w = rb_bigmath_clog(z, n);
|
10
|
+
w = rb_funcall1(w, '/', rb_bigmath_const_log10(n));
|
10
11
|
|
11
12
|
return rb_num_round(w, prec);
|
12
13
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
VALUE
|
2
|
+
clog2_branch(VALUE z, VALUE prec, bigmath_func1 clog2_cb)
|
3
|
+
{
|
4
|
+
VALUE w = Qundef, arg = 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_inf_sgn = rb_num_infinite_p(rb_num_real(z));
|
15
|
+
int im_inf_sgn = rb_num_infinite_p(rb_num_imag(z));
|
16
|
+
if (re_inf_sgn != 0 && im_inf_sgn == 0)
|
17
|
+
{
|
18
|
+
switch (re_inf_sgn) {
|
19
|
+
case -1:
|
20
|
+
arg = rb_num_imag(clog2_cb(BIG_MINUS_ONE, prec));
|
21
|
+
w = rb_Complex(BIG_INF, arg);
|
22
|
+
break;
|
23
|
+
case 1:
|
24
|
+
w = rb_Complex(BIG_INF, BIG_ZERO);
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
else if (re_inf_sgn == 0 && im_inf_sgn != 0)
|
29
|
+
{
|
30
|
+
switch (rb_num_infinite_p(rb_num_imag(z))) {
|
31
|
+
case -1:
|
32
|
+
arg = rb_num_imag(
|
33
|
+
clog2_cb(rb_Complex(BIG_ZERO, BIG_MINUS_ONE), prec));
|
34
|
+
w = rb_Complex(BIG_INF, arg);
|
35
|
+
break;
|
36
|
+
case 1:
|
37
|
+
arg = rb_num_imag(
|
38
|
+
clog2_cb(rb_Complex(BIG_ZERO, BIG_ONE), prec));
|
39
|
+
w = rb_Complex(BIG_INF, arg);
|
40
|
+
break;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
else /* log(INF +i INF) */
|
44
|
+
{
|
45
|
+
w = z;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
if (w == Qundef)
|
49
|
+
{
|
50
|
+
w = clog2_cb(z, prec);
|
51
|
+
}
|
52
|
+
return w;
|
53
|
+
}
|
@@ -1,12 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
clog2_formula(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 =
|
9
|
-
w = rb_funcall1(w, '/', rb_bigmath_const_log2(
|
9
|
+
w = rb_bigmath_clog(z, n);
|
10
|
+
w = rb_funcall1(w, '/', rb_bigmath_const_log2(n));
|
10
11
|
|
11
12
|
return rb_num_round(w, prec);
|
12
13
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
cos_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
|
-
|
10
|
-
|
9
|
+
w = trig_f_euler(mf_cos, rb_ImaginaryZ(z, SIGN_PLUS), n);
|
10
|
+
w = rb_num_real(w);
|
11
|
+
|
12
|
+
return rb_num_round(w, prec);
|
11
13
|
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
cos_ser(VALUE x, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE cos;
|
4
|
+
VALUE cos, n;
|
5
5
|
|
6
6
|
rb_check_precise(prec);
|
7
|
+
n = rb_numdiff_make_n(prec);
|
7
8
|
|
8
|
-
rb_bigmath_sincos(x,
|
9
|
-
cos = rb_num_round(cos, prec);
|
9
|
+
rb_bigmath_sincos(x, n, NULL, &cos);
|
10
10
|
|
11
|
-
return cos;
|
11
|
+
return rb_num_round(cos, prec);
|
12
12
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
cosh_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 = trig_f_euler(mf_cos, x,
|
9
|
+
y = trig_f_euler(mf_cos, x, n);
|
10
|
+
y = rb_num_real(y);
|
9
11
|
|
10
|
-
return
|
12
|
+
return rb_num_round(y, prec);
|
11
13
|
}
|
@@ -5,8 +5,8 @@ cosh_formula(VALUE x, VALUE prec)
|
|
5
5
|
VALUE n, t, y, two;
|
6
6
|
|
7
7
|
rb_check_precise(prec);
|
8
|
-
|
9
8
|
n = rb_numdiff_make_n(prec);
|
9
|
+
|
10
10
|
t = rb_bigmath_exp(x, n);
|
11
11
|
y = Qundef;
|
12
12
|
two = rb_BigDecimal1(INT2FIX(2));
|
@@ -15,16 +15,16 @@ cosh_formula(VALUE x, VALUE prec)
|
|
15
15
|
{
|
16
16
|
y = rb_Rational(INT2FIX(1), t);
|
17
17
|
y = rb_funcall1(t, '+', y);
|
18
|
-
y = rb_funcall(rb_BigDecimal(y, n), div, 2, two,
|
18
|
+
y = rb_funcall(rb_BigDecimal(y, n), div, 2, two, n);
|
19
19
|
}
|
20
20
|
else if (rb_num_infinite_p(t) != 0)
|
21
21
|
y = BIG_INF;
|
22
22
|
else
|
23
23
|
{
|
24
|
-
y = rb_num_canonicalize(t,
|
24
|
+
y = rb_num_canonicalize(t, n, ARG_REAL, ARG_RECIPROCAL);
|
25
25
|
y = rb_funcall1(t, '+', y);
|
26
|
-
y = rb_funcall(y, div, 2, two,
|
26
|
+
y = rb_funcall(y, div, 2, two, n);
|
27
27
|
}
|
28
28
|
|
29
|
-
return y;
|
29
|
+
return rb_num_round(y, prec);
|
30
30
|
}
|
@@ -1,11 +1,12 @@
|
|
1
1
|
VALUE
|
2
2
|
cosh_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, NULL, &y);
|
9
10
|
|
10
|
-
return y;
|
11
|
+
return rb_num_round(y, prec);
|
11
12
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
cot_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);
|
10
|
+
w = rb_num_canonicalize(w, n, ARG_REAL, ARG_RECIPROCAL);
|
9
11
|
|
10
|
-
return
|
12
|
+
return rb_num_round(w, prec);
|
11
13
|
}
|
@@ -2,11 +2,12 @@ VALUE
|
|
2
2
|
cot_ser(VALUE x, VALUE prec)
|
3
3
|
{
|
4
4
|
const ID div = rb_intern("div");
|
5
|
-
VALUE sin, cos;
|
5
|
+
VALUE sin, cos, n;
|
6
6
|
|
7
7
|
rb_check_precise(prec);
|
8
|
+
n = rb_numdiff_make_n(prec);
|
8
9
|
|
9
|
-
rb_bigmath_sincos(x,
|
10
|
+
rb_bigmath_sincos(x, n, &sin, &cos);
|
10
11
|
|
11
12
|
return rb_funcall(cos, div, 2, sin, prec);
|
12
13
|
}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
coth_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
9
|
y = rb_ImaginaryZ(trig_f_euler(mf_tan, x, prec), 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
|
}
|
@@ -1,12 +1,13 @@
|
|
1
1
|
VALUE
|
2
2
|
coth_ser(VALUE x, VALUE prec)
|
3
3
|
{
|
4
|
-
VALUE y = Qundef, sinh = Qundef, cosh = Qundef;
|
4
|
+
VALUE y = Qundef, sinh = Qundef, cosh = Qundef, n;
|
5
5
|
const ID div = rb_intern("div");
|
6
6
|
|
7
7
|
rb_check_precise(prec);
|
8
|
+
n = rb_numdiff_make_n(prec);
|
8
9
|
|
9
|
-
sinhcosh_ser(x,
|
10
|
+
sinhcosh_ser(x, n, &sinh, &cosh);
|
10
11
|
y = rb_funcall(cosh, div, 2, sinh, prec);
|
11
12
|
|
12
13
|
return y;
|
@@ -1,20 +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
|
-
if (
|
9
|
+
if (rb_num_positive_p(rb_num_real(z)) &&
|
10
|
+
rb_num_zero_p(rb_num_imag(z)) && rb_num_zero_p(rb_num_imag(w)))
|
9
11
|
{
|
10
|
-
a = pow_formula(rb_num_real(z), rb_num_real(w),
|
11
|
-
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);
|
12
14
|
}
|
13
15
|
else
|
14
16
|
{
|
15
|
-
a = rb_bigmath_clog(z,
|
17
|
+
a = rb_bigmath_clog(z, n);
|
16
18
|
a = rb_funcall1(w, '*', a);
|
17
|
-
a = rb_bigmath_cexp(a,
|
19
|
+
a = rb_bigmath_cexp(a, n);
|
18
20
|
}
|
19
|
-
return a;
|
21
|
+
return rb_num_round(a, prec);
|
20
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
|
+
}
|