This commit is contained in:
Justin Ethier 2024-03-14 19:42:42 -07:00
parent 07e747a08f
commit 82b0f9f3e2

View file

@ -121,30 +121,29 @@
assign_complex_num((&cn), result);
return_closcall1(data, k, &cn);
} "
; "(void *data, object ptr, object z)"
; " return_inexact_double_or_cplx_op_no_cps(data, ptr, sqrt, csqrt, z);"
"(void *data, object ptr, object z)"
" double complex unboxed;
" double complex result;
Cyc_check_num(data, z);
if (obj_is_int(z)) {
unboxed = csqrt(obj_obj2int(z));
result = csqrt(obj_obj2int(z));
} else if (type_of(z) == integer_tag) {
unboxed = csqrt(((integer_type *)z)->value);
result = csqrt(((integer_type *)z)->value);
} else if (type_of(z) == bignum_tag) {
unboxed = csqrt(mp_get_double(&bignum_value(z)));
result = csqrt(mp_get_double(&bignum_value(z)));
} else if (type_of(z) == complex_num_tag) {
unboxed = csqrt(complex_num_value(z));
assign_complex_num(ptr, unboxed);
return ptr;
result = csqrt(complex_num_value(z));
} else {
unboxed = csqrt(((double_type *)z)->value);
result = csqrt(((double_type *)z)->value);
}
if (cimag(unboxed) == 0.0) {
assign_double(ptr, creal(unboxed));
if (cimag(result) == 0.0) {
if (obj_is_int(z) && creal(result) == round(creal(result))) {
return obj_int2obj(creal(result));
}
assign_double(ptr, creal(result));
} else {
assign_double(ptr, unboxed);
assign_complex_num(ptr, result);
}
return ptr; ")
return ptr;
")
))