bigdecimal-math_r 0.2.7 → 0.2.8
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 +2 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/branch.h +1 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/asec/edom.h +4 -0
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacos/branch.h +15 -7
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacosh/branch.h +6 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cacsch/branch.h +0 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casec/branch.h +8 -4
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casech/branch.h +2 -10
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casin/branch.h +23 -8
- data/ext/bigdecimal/math_r/internal/algo/bigmath/casinh/branch.h +24 -29
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catan/branch.h +12 -9
- data/ext/bigdecimal/math_r/internal/algo/bigmath/catanh/branch.h +14 -7
- data/ext/bigdecimal/math_r/internal/algo/bigmath/ccosh/branch.h +3 -1
- data/ext/bigdecimal/math_r/internal/algo/bigmath/cpow/formula.h +6 -2
- data/ext/bigdecimal/math_r/internal/algo/bigmath/trig/f_euler.h +9 -3
- data/lib/bigdecimal/math_r/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e81ef8bf762b9147ddb484f578dff41f43fbede81f4b8e875b554528540dc299
|
|
4
|
+
data.tar.gz: bc13ee261dc7a056eef1eb231f1059190bdf97c8cde0ede2e2206f6c335ede09
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ce5aadd6303fea558e215f3a1a9b51953246fe192f0370958c67e247f59483f537944b56a135537c11b6791a2fe495163771c35159b75a230a705991a9d4a61
|
|
7
|
+
data.tar.gz: ef35daded47e2bf1d127fffe99f0ecb00b0c7fe814cf85b9fa39ac083a50fe396ac3de6c48585cfd428edffe0acc4436cb8aef1ed9ce6d809e2b8068ec65c7fc
|
data/README.md
CHANGED
|
@@ -23,7 +23,8 @@ Mathematical functions are compatible with both real and complex solutions.
|
|
|
23
23
|
|
|
24
24
|
Constants:
|
|
25
25
|
```
|
|
26
|
-
:E (Constant e)
|
|
26
|
+
:E (Constant e)
|
|
27
|
+
:EulerGamma (Euler-Mascheroni Constant)
|
|
27
28
|
:LOG2 (Natural logarithm of 2)
|
|
28
29
|
:LOG_PI (Natural logarithm of pi)
|
|
29
30
|
:LOG10 (Natural logarithm of 10)
|
|
@@ -14,7 +14,7 @@ asec_branch(VALUE x, VALUE prec, bigmath_func1 asec_cb)
|
|
|
14
14
|
y = rb_funcall(rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
|
|
15
15
|
else if (rb_num_equal_p(x, INT2FIX(-1)))
|
|
16
16
|
y = rb_bigmath_const_pi(prec);
|
|
17
|
-
else if (rb_num_equal_p(x, INT2FIX(
|
|
17
|
+
else if (rb_num_equal_p(x, INT2FIX(1)))
|
|
18
18
|
y = BIG_ZERO;
|
|
19
19
|
else if (rb_num_domain_p(p_domain, x) || rb_num_domain_p(m_domain, x))
|
|
20
20
|
y = asec_cb(x, prec);
|
|
@@ -8,9 +8,13 @@ asec_edom(VALUE x, VALUE prec)
|
|
|
8
8
|
|
|
9
9
|
x = rb_num_canonicalize(x, n, ARG_REAL, ARG_RECIPROCAL);
|
|
10
10
|
t = rb_funcall1(BIG_ONE, '-', rb_funcall1(x, '*', x));
|
|
11
|
+
// Bug-fix: Below, if the argument is -0.0, the calculation is Infinity-Infinity, resulting in NaN.
|
|
11
12
|
t = rb_funcall1(rb_bigmath_sqrt(rb_num_uminus(t), n), '+', x);
|
|
12
13
|
arg = rb_num_negative_p(x) ? rb_bigmath_const_pi(n) : BIG_ZERO;
|
|
13
14
|
imag = rb_bigmath_log(rb_num_abs(t), n);
|
|
15
|
+
// Bug-Fix: Set to -Infinity if NaN
|
|
16
|
+
if (rb_num_nan_p(imag))
|
|
17
|
+
imag = BIG_MINUS_INF;
|
|
14
18
|
y = rb_Complex(arg, imag);
|
|
15
19
|
|
|
16
20
|
return rb_num_round(y, prec);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
VALUE
|
|
2
2
|
cacos_branch(VALUE z, VALUE prec, bigmath_func1 cacos_cb)
|
|
3
3
|
{
|
|
4
|
+
const ID mult = rb_intern("mult");
|
|
5
|
+
const ID div = rb_intern("div");
|
|
4
6
|
int z_re_inf = rb_num_infinite_p(rb_num_real(z));
|
|
5
7
|
int z_im_inf = rb_num_infinite_p(rb_num_imag(z));
|
|
6
8
|
|
|
@@ -14,20 +16,26 @@ cacos_branch(VALUE z, VALUE prec, bigmath_func1 cacos_cb)
|
|
|
14
16
|
(rb_num_zero_p(rb_num_imag(z)) &&
|
|
15
17
|
z_re_inf == 1) ?
|
|
16
18
|
BIG_ZERO : rb_bigmath_const_pi(prec);
|
|
17
|
-
VALUE imag =
|
|
19
|
+
VALUE imag = BIG_MINUS_INF;
|
|
18
20
|
return rb_Complex(real, imag);
|
|
19
21
|
}
|
|
20
22
|
else if (z_re_inf == 0 && z_im_inf != 0)
|
|
21
23
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return rb_Complex(
|
|
24
|
+
VALUE real = rb_bigmath_const_pi(prec);
|
|
25
|
+
VALUE imag = z_im_inf == 1 ? BIG_MINUS_INF : BIG_INF;
|
|
26
|
+
if (!rb_num_negative_p(rb_num_real(z)))
|
|
27
|
+
real = rb_funcall(real, div, 2, INT2FIX(2), prec);
|
|
28
|
+
return rb_Complex(real, imag);
|
|
27
29
|
}
|
|
28
30
|
else
|
|
29
31
|
{
|
|
30
|
-
|
|
32
|
+
VALUE real = rb_bigmath_const_pi(prec);
|
|
33
|
+
VALUE imag = z_im_inf == -1 ? BIG_INF : BIG_MINUS_INF;
|
|
34
|
+
real = z_re_inf == -1 ?
|
|
35
|
+
rb_funcall(real, mult, 2,
|
|
36
|
+
rb_rational_new(INT2FIX(3), INT2FIX(4)), prec) :
|
|
37
|
+
rb_funcall(real, div, 2, INT2FIX(4), prec);
|
|
38
|
+
return rb_Complex(real, imag);
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
else
|
|
@@ -17,14 +17,16 @@ cacosh_branch(VALUE z, VALUE prec, bigmath_func1 cacosh_cb)
|
|
|
17
17
|
}
|
|
18
18
|
else if (z_re_inf == 0 && z_im_inf != 0)
|
|
19
19
|
{
|
|
20
|
+
const ID div = rb_intern("div");
|
|
20
21
|
VALUE real = BIG_INF;
|
|
21
|
-
VALUE imag =
|
|
22
|
+
VALUE imag = rb_funcall(rb_bigmath_const_pi(prec),
|
|
23
|
+
div, 2, INT2FIX(2), prec);
|
|
24
|
+
if (z_im_inf == -1)
|
|
25
|
+
imag = rb_num_uminus(imag);
|
|
22
26
|
return rb_Complex(real, imag);
|
|
23
27
|
}
|
|
24
|
-
else if (z_re_inf == -1 && z_im_inf == 1)
|
|
25
|
-
return rb_Complex(BIG_NAN, BIG_NAN);
|
|
26
28
|
else
|
|
27
|
-
return rb_Complex(
|
|
29
|
+
return rb_Complex(BIG_INF, BIG_NAN);
|
|
28
30
|
}
|
|
29
31
|
else
|
|
30
32
|
{
|
|
@@ -4,26 +4,30 @@ casec_branch(VALUE z, VALUE prec, bigmath_func1 casec_cb)
|
|
|
4
4
|
int z_re_inf = rb_num_infinite_p(rb_num_real(z));
|
|
5
5
|
int z_im_inf = rb_num_infinite_p(rb_num_imag(z));
|
|
6
6
|
|
|
7
|
+
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
|
8
|
+
|
|
7
9
|
if (rb_num_nan_p(z))
|
|
8
10
|
{
|
|
9
11
|
return rb_Complex(BIG_NAN, BIG_NAN);
|
|
10
12
|
}
|
|
11
13
|
else if (z_re_inf || z_im_inf)
|
|
12
14
|
{
|
|
13
|
-
|
|
15
|
+
const ID div = rb_intern("div");
|
|
16
|
+
VALUE real = rb_bigmath_const_pi(prec);
|
|
17
|
+
real = rb_funcall(real, div, 2, INT2FIX(2), prec);
|
|
18
|
+
return rb_Complex(real, BIG_ZERO);
|
|
14
19
|
}
|
|
15
20
|
else if (rb_num_zero_p(z))
|
|
16
21
|
{
|
|
17
22
|
int zero_sign = NUM2INT(rb_BigDecimal_sign(rb_num_real(z)));
|
|
18
23
|
VALUE real =
|
|
19
|
-
(rb_num_nonzero_p(rb_num_imag(z)) || zero_sign ==
|
|
24
|
+
(rb_num_nonzero_p(rb_num_imag(z)) || zero_sign == 1) ?
|
|
20
25
|
BIG_ZERO : rb_bigmath_const_pi(prec);
|
|
21
|
-
VALUE imag = 1 == zero_sign ? BIG_MINUS_INF : BIG_INF;
|
|
26
|
+
VALUE imag = -1 == zero_sign ? BIG_MINUS_INF : BIG_INF;
|
|
22
27
|
return rb_Complex(real, imag);
|
|
23
28
|
}
|
|
24
29
|
else
|
|
25
30
|
{
|
|
26
|
-
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
|
27
31
|
return casec_cb(z, prec);
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -10,20 +10,13 @@ casech_branch(VALUE z, VALUE prec, bigmath_func1 casech_cb)
|
|
|
10
10
|
else if (z_re_inf || z_im_inf)
|
|
11
11
|
{
|
|
12
12
|
const ID div = rb_intern("div");
|
|
13
|
-
if (z_re_inf != 0 && z_im_inf == 0)
|
|
13
|
+
if ((z_re_inf != 0 && z_im_inf == 0) ||
|
|
14
|
+
(z_re_inf == 0 && z_im_inf != 0))
|
|
14
15
|
{
|
|
15
16
|
VALUE imag = rb_funcall(rb_bigmath_const_pi(prec), div,
|
|
16
17
|
2, INT2FIX(2), prec);
|
|
17
18
|
w = rb_Complex(BIG_ZERO, imag);
|
|
18
19
|
}
|
|
19
|
-
else if (z_re_inf == 0 && z_im_inf != 0)
|
|
20
|
-
{
|
|
21
|
-
VALUE imag = rb_funcall(rb_bigmath_const_pi(prec), div,
|
|
22
|
-
2, INT2FIX(-2 * z_im_inf), prec);
|
|
23
|
-
w = rb_Complex(BIG_ZERO, imag);
|
|
24
|
-
}
|
|
25
|
-
else if (z_re_inf == -1 && z_im_inf == 1)
|
|
26
|
-
w = rb_Complex(BIG_NAN, BIG_NAN);
|
|
27
20
|
else
|
|
28
21
|
w = rb_Complex(BIG_ZERO, BIG_ZERO);
|
|
29
22
|
}
|
|
@@ -35,4 +28,3 @@ casech_branch(VALUE z, VALUE prec, bigmath_func1 casech_cb)
|
|
|
35
28
|
|
|
36
29
|
return w;
|
|
37
30
|
}
|
|
38
|
-
|
|
@@ -9,23 +9,38 @@ casin_branch(VALUE z, VALUE prec, bigmath_func1 casin_cb)
|
|
|
9
9
|
else if (z_re_inf || z_im_inf)
|
|
10
10
|
{
|
|
11
11
|
const ID div = rb_intern("div");
|
|
12
|
+
const ID mult = rb_intern("mult");
|
|
13
|
+
VALUE real, imag;
|
|
12
14
|
if (z_re_inf != 0 && z_im_inf == 0)
|
|
13
15
|
{
|
|
14
|
-
|
|
16
|
+
real =
|
|
15
17
|
rb_funcall(rb_bigmath_const_pi(prec), div, 2,
|
|
16
|
-
INT2FIX(z_re_inf * 2), prec)
|
|
17
|
-
|
|
18
|
-
VALUE imag = z_re_inf == 1 ? BIG_MINUS_INF : BIG_INF;
|
|
18
|
+
INT2FIX(z_re_inf * 2), prec);
|
|
19
|
+
imag = z_re_inf == 1 ? BIG_MINUS_INF : BIG_INF;
|
|
19
20
|
return rb_Complex(real, imag);
|
|
20
21
|
}
|
|
21
22
|
else if (z_re_inf == 0 && z_im_inf != 0)
|
|
22
23
|
{
|
|
23
|
-
|
|
24
|
+
real = rb_bigmath_const_pi(prec);
|
|
25
|
+
imag = BIG_MINUS_INF;
|
|
26
|
+
if (z_im_inf == -1)
|
|
27
|
+
real = rb_funcall(real, div, 2, INT2FIX(2), prec);
|
|
28
|
+
return rb_Complex(real, imag);
|
|
24
29
|
}
|
|
25
|
-
else if (z_re_inf == -1 && z_im_inf == 1)
|
|
26
|
-
return rb_Complex(BIG_NAN, BIG_NAN);
|
|
27
30
|
else
|
|
28
|
-
|
|
31
|
+
{
|
|
32
|
+
VALUE rat = Qundef;
|
|
33
|
+
real = rb_bigmath_const_pi(prec);
|
|
34
|
+
imag = BIG_MINUS_INF;
|
|
35
|
+
if (z_re_inf == 1 && z_im_inf == 1)
|
|
36
|
+
rat = rb_rational_new(INT2FIX(5), INT2FIX(4));
|
|
37
|
+
else if (z_re_inf == 1 && z_im_inf == -1)
|
|
38
|
+
rat = rb_rational_new(INT2FIX(3), INT2FIX(4));
|
|
39
|
+
else
|
|
40
|
+
rat = rb_rational_new(INT2FIX(1), INT2FIX(4));
|
|
41
|
+
real = rb_funcall(real, mult, 2, rat, prec);
|
|
42
|
+
return rb_Complex(real, imag);
|
|
43
|
+
}
|
|
29
44
|
}
|
|
30
45
|
else
|
|
31
46
|
{
|
|
@@ -3,13 +3,18 @@ casinh_branch(VALUE z, VALUE prec, bigmath_func1 casinh_cb)
|
|
|
3
3
|
{
|
|
4
4
|
VALUE y = Qundef;
|
|
5
5
|
|
|
6
|
+
int z_re_inf = rb_num_infinite_p(rb_num_real(z));
|
|
7
|
+
int z_im_inf = rb_num_infinite_p(rb_num_imag(z));
|
|
8
|
+
|
|
6
9
|
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
|
7
10
|
|
|
8
|
-
if (
|
|
11
|
+
if (rb_num_nan_p(z))
|
|
12
|
+
y = rb_Complex(BIG_NAN, BIG_NAN);
|
|
13
|
+
else if (!rb_num_finite_p(z))
|
|
9
14
|
{
|
|
10
|
-
if (
|
|
15
|
+
if (z_re_inf != 0 && z_im_inf == 0)
|
|
11
16
|
{
|
|
12
|
-
switch (
|
|
17
|
+
switch (z_re_inf) {
|
|
13
18
|
case 1:
|
|
14
19
|
y = rb_Complex(BIG_INF, BIG_ZERO);
|
|
15
20
|
break;
|
|
@@ -18,37 +23,27 @@ casinh_branch(VALUE z, VALUE prec, bigmath_func1 casinh_cb)
|
|
|
18
23
|
break;
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
|
-
else if (
|
|
26
|
+
else if (z_re_inf == 0 && z_im_inf != 0)
|
|
22
27
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
else
|
|
35
|
-
{
|
|
36
|
-
const ID div = rb_intern("div");
|
|
37
|
-
VALUE pi_2 = rb_funcall(rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
|
|
38
|
-
switch (rb_num_infinite_p(rb_num_imag(z))) {
|
|
39
|
-
case 1:
|
|
40
|
-
y = rb_Complex(BIG_INF, pi_2);
|
|
41
|
-
break;
|
|
42
|
-
case -1:
|
|
43
|
-
pi_2 = rb_num_uminus(pi_2);
|
|
44
|
-
y = rb_Complex(BIG_ZERO, pi_2);
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
28
|
+
const ID div = rb_intern("div");
|
|
29
|
+
VALUE pi_2 = rb_funcall(rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
|
|
30
|
+
switch (z_im_inf) {
|
|
31
|
+
case 1:
|
|
32
|
+
y = rb_Complex(BIG_INF, pi_2);
|
|
33
|
+
break;
|
|
34
|
+
case -1:
|
|
35
|
+
pi_2 = rb_num_uminus(pi_2);
|
|
36
|
+
y = rb_Complex(BIG_INF, pi_2);
|
|
37
|
+
break;
|
|
47
38
|
}
|
|
48
39
|
}
|
|
49
40
|
else
|
|
50
41
|
{
|
|
51
|
-
|
|
42
|
+
VALUE real = BIG_INF;
|
|
43
|
+
VALUE imag = BIG_NAN;
|
|
44
|
+
if (z_re_inf == -1)
|
|
45
|
+
real = rb_num_uminus(real);
|
|
46
|
+
y = rb_Complex(real, imag);
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
49
|
if (y == Qundef)
|
|
@@ -10,27 +10,30 @@ catan_branch(VALUE z, VALUE prec, bigmath_func1 catan_cb)
|
|
|
10
10
|
return rb_Complex(BIG_NAN, BIG_NAN);
|
|
11
11
|
else if (z_re_inf || z_im_inf)
|
|
12
12
|
{
|
|
13
|
+
const ID mult = rb_intern("mult");
|
|
13
14
|
const ID div = rb_intern("div");
|
|
15
|
+
VALUE real, imag;
|
|
14
16
|
if (z_re_inf != 0 && z_im_inf == 0)
|
|
15
17
|
{
|
|
16
|
-
|
|
17
|
-
rb_funcall(rb_bigmath_const_pi(prec), div, 2,
|
|
18
|
+
real = rb_funcall(rb_bigmath_const_pi(prec), div, 2,
|
|
18
19
|
INT2FIX(z_re_inf * 2), prec);
|
|
19
|
-
|
|
20
|
+
imag = BIG_ZERO;
|
|
20
21
|
return rb_Complex(real, imag);
|
|
21
22
|
}
|
|
22
23
|
else if (z_re_inf == 0 && z_im_inf != 0)
|
|
23
24
|
{
|
|
24
|
-
|
|
25
|
-
rb_funcall(rb_bigmath_const_pi(prec), div, 2,
|
|
25
|
+
real = rb_funcall(rb_bigmath_const_pi(prec), div, 2,
|
|
26
26
|
INT2FIX(z_im_inf * 2), prec);
|
|
27
|
-
|
|
27
|
+
imag = BIG_ZERO;
|
|
28
28
|
return rb_Complex(real, imag);
|
|
29
29
|
}
|
|
30
|
-
else if (z_re_inf == -1 && z_im_inf == 1)
|
|
31
|
-
return rb_Complex(BIG_NAN, BIG_NAN);
|
|
32
30
|
else
|
|
33
|
-
|
|
31
|
+
{
|
|
32
|
+
real = rb_funcall(rb_bigmath_const_pi(prec), mult, 2,
|
|
33
|
+
rb_rational_new(INT2FIX(z_im_inf * 3), INT2FIX(4)), prec);
|
|
34
|
+
imag = BIG_ZERO;
|
|
35
|
+
return rb_Complex(real, imag);
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
else if (rb_num_equal_p(z, rb_Complex_I))
|
|
36
39
|
return rb_Complex(BIG_ZERO, BIG_INF);
|
|
@@ -2,19 +2,26 @@ VALUE
|
|
|
2
2
|
catanh_branch(VALUE z, VALUE prec, bigmath_func1 catanh_cb)
|
|
3
3
|
{
|
|
4
4
|
VALUE w = Qundef;
|
|
5
|
+
int z_re_inf = rb_num_infinite_p(rb_num_real(z));
|
|
6
|
+
int z_im_inf = rb_num_infinite_p(rb_num_imag(z));
|
|
5
7
|
|
|
6
8
|
z = rb_num_canonicalize(z, prec, ARG_COMPLEX, ARG_RAWVALUE);
|
|
7
9
|
|
|
8
10
|
if (rb_num_nan_p(z))
|
|
9
11
|
w = rb_Complex(BIG_NAN, BIG_NAN);
|
|
10
|
-
else if (
|
|
12
|
+
else if (z_re_inf || z_im_inf)
|
|
11
13
|
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (z_re_inf != 0 && z_im_inf != 0)
|
|
15
|
+
w = rb_Complex(BIG_NAN, BIG_NAN);
|
|
16
|
+
else
|
|
17
|
+
{
|
|
18
|
+
const ID div = rb_intern("div");
|
|
19
|
+
VALUE pi_2 = rb_funcall(
|
|
20
|
+
rb_bigmath_const_pi(prec), div, 2, INT2FIX(2), prec);
|
|
21
|
+
if (z_re_inf == 1 || z_im_inf == -1)
|
|
22
|
+
pi_2 = rb_num_uminus(pi_2);
|
|
23
|
+
w = rb_Complex(BIG_ZERO, pi_2);
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
else
|
|
20
27
|
{
|
|
@@ -2,7 +2,9 @@ VALUE
|
|
|
2
2
|
ccosh_branch(VALUE z, VALUE prec, bigmath_func1 ccosh_cb)
|
|
3
3
|
{
|
|
4
4
|
VALUE w = Qundef;
|
|
5
|
-
if (
|
|
5
|
+
if (rb_num_nan_p(z))
|
|
6
|
+
w = rb_Complex(BIG_NAN, BIG_NAN);
|
|
7
|
+
else if (!rb_num_finite_p(z))
|
|
6
8
|
{
|
|
7
9
|
if (rb_num_infinite_p(z) != 0 && rb_num_zero_p(rb_num_imag(z)))
|
|
8
10
|
{
|
|
@@ -5,8 +5,12 @@ cpow_formula(VALUE z, VALUE w, VALUE prec)
|
|
|
5
5
|
|
|
6
6
|
rb_check_precise(prec);
|
|
7
7
|
n = rb_numdiff_make_n(prec);
|
|
8
|
-
|
|
9
|
-
if (
|
|
8
|
+
|
|
9
|
+
if (!rb_num_finite_p(z) || !rb_num_finite_p(w))
|
|
10
|
+
{
|
|
11
|
+
a = rb_Complex(BIG_NAN, BIG_NAN);
|
|
12
|
+
}
|
|
13
|
+
else if (rb_num_positive_p(rb_num_real(z)) &&
|
|
10
14
|
rb_num_zero_p(rb_num_imag(z)) && rb_num_zero_p(rb_num_imag(w)))
|
|
11
15
|
{
|
|
12
16
|
a = pow_formula(rb_num_real(z), rb_num_real(w), n);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Make euler's formula, e^i(theta) as *exppz and e^-i(theta) as *expmz
|
|
1
2
|
static inline void
|
|
2
3
|
f_euler2(VALUE theta, VALUE prec, VALUE *exppz, VALUE *expmz)
|
|
3
4
|
{
|
|
@@ -6,7 +7,7 @@ f_euler2(VALUE theta, VALUE prec, VALUE *exppz, VALUE *expmz)
|
|
|
6
7
|
*expmz = rb_funcall(*exppz, conj, 0);
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
// Make euler's formula of complex exponent, e^(theta) as *exppz and e^-(theta) as *expmz
|
|
10
11
|
static inline void
|
|
11
12
|
f_euler_e2(VALUE theta, VALUE prec, VALUE *exppz, VALUE *expmz)
|
|
12
13
|
{
|
|
@@ -33,7 +34,7 @@ f_euler_e2(VALUE theta, VALUE prec, VALUE *exppz, VALUE *expmz)
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
// Euler's formula for cos()
|
|
37
38
|
static inline VALUE
|
|
38
39
|
f_euler_cos(VALUE exppz, VALUE expmz)
|
|
39
40
|
{
|
|
@@ -44,6 +45,7 @@ f_euler_cos(VALUE exppz, VALUE expmz)
|
|
|
44
45
|
return y;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
// Euler's formula for sin(), when argument is infinite
|
|
47
49
|
static inline VALUE
|
|
48
50
|
f_euler_sin_infinite(VALUE y)
|
|
49
51
|
{
|
|
@@ -97,6 +99,7 @@ f_euler_sin_infinite(VALUE y)
|
|
|
97
99
|
return w;
|
|
98
100
|
}
|
|
99
101
|
|
|
102
|
+
// Euler's formula for sin()
|
|
100
103
|
static inline VALUE
|
|
101
104
|
f_euler_sin(VALUE exppz, VALUE expmz)
|
|
102
105
|
{
|
|
@@ -112,6 +115,7 @@ f_euler_sin(VALUE exppz, VALUE expmz)
|
|
|
112
115
|
return y;
|
|
113
116
|
}
|
|
114
117
|
|
|
118
|
+
// Euler's formula for tan()
|
|
115
119
|
static inline VALUE
|
|
116
120
|
f_euler_tan(VALUE exppz, VALUE expmz)
|
|
117
121
|
{
|
|
@@ -128,6 +132,7 @@ f_euler_tan(VALUE exppz, VALUE expmz)
|
|
|
128
132
|
return rb_funcall1(sin, '/', cos);
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
// Euler's formula for sin and cos
|
|
131
136
|
static inline VALUE
|
|
132
137
|
f_euler_sc(const ID func, VALUE theta, VALUE prec)
|
|
133
138
|
{
|
|
@@ -208,7 +213,7 @@ f_euler_t(VALUE theta, VALUE prec)
|
|
|
208
213
|
return rb_ImaginaryZ(y, SIGN_MINUS);
|
|
209
214
|
}
|
|
210
215
|
|
|
211
|
-
|
|
216
|
+
// For hyperbolic
|
|
212
217
|
static inline VALUE
|
|
213
218
|
f_euler_h(const ID func, VALUE theta, VALUE prec)
|
|
214
219
|
{
|
|
@@ -230,6 +235,7 @@ f_euler_h(const ID func, VALUE theta, VALUE prec)
|
|
|
230
235
|
return rb_num_round(y, prec);
|
|
231
236
|
}
|
|
232
237
|
|
|
238
|
+
// Mix Euler's formula of exponent and sincos
|
|
233
239
|
static inline VALUE
|
|
234
240
|
f_euler_esc(const ID func, VALUE z, VALUE prec)
|
|
235
241
|
{
|