mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
parent
60448d1d3b
commit
7cb15a7191
2 changed files with 13 additions and 6 deletions
16
bignum.c
16
bignum.c
|
@ -1023,17 +1023,21 @@ sexp sexp_complex_asin (sexp ctx, sexp z) {
|
|||
sexp_gc_preserve2(ctx, res, tmp);
|
||||
res = sexp_complex_mul(ctx, z, z);
|
||||
tmp = sexp_make_complex(ctx, SEXP_ONE, SEXP_ZERO);
|
||||
res = sexp_complex_sub(ctx, tmp, res);
|
||||
res = sexp_complex_sqrt(ctx, res);
|
||||
res = sexp_sub(ctx, tmp, res);
|
||||
res = sexp_sqrt(ctx, NULL, 1, res);
|
||||
/* tmp = iz */
|
||||
sexp_complex_real(tmp) = sexp_complex_imag(z);
|
||||
sexp_negate(sexp_complex_real(tmp));
|
||||
sexp_complex_imag(tmp) = sexp_complex_real(z);
|
||||
res = sexp_complex_add(ctx, tmp, res);
|
||||
tmp = sexp_complex_log(ctx, res);
|
||||
res = sexp_add(ctx, tmp, res);
|
||||
tmp = sexp_log(ctx, NULL, 1, res);
|
||||
/* res = -i*tmp */
|
||||
res = sexp_complex_copy(ctx, tmp);
|
||||
sexp_negate(sexp_complex_imag(res));
|
||||
if (sexp_complexp(tmp)) {
|
||||
res = sexp_complex_copy(ctx, tmp);
|
||||
sexp_negate(sexp_complex_imag(res));
|
||||
} else {
|
||||
res = tmp;
|
||||
}
|
||||
sexp_gc_release2(ctx);
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -848,6 +848,9 @@
|
|||
(test 0.0 (inexact (acos 1))) ;; may return exact number
|
||||
(test 3.14159265358979 (acos -1))
|
||||
|
||||
(test 0.0 (asin 0+0.0i))
|
||||
(test 1.5707963267948966 (acos 0+0.0i))
|
||||
|
||||
(test 0.0 (atan 0.0 1.0))
|
||||
(test -0.0 (atan -0.0 1.0))
|
||||
(test 0.785398163397448 (atan 1.0 1.0))
|
||||
|
|
Loading…
Add table
Reference in a new issue