Skip to content

Commit

Permalink
Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
justinethier committed Mar 15, 2024
1 parent 7c0ae41 commit 7cb02e3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
26 changes: 14 additions & 12 deletions scheme/inexact.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,28 +406,30 @@ object k_73116 = args[0];
return_direct_with_clo1(data, k_73116, (((closure) k_73116)->fn), obj_int2obj(0));;
}

static object __lambda_42(void *data, object ptr, object z) { double complex unboxed;
static object __lambda_42(void *data, object ptr, object z) { 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;
}
static void __lambda_41(void *data, object _, int argc, object *args) {object k = args[0];object z = args[1]; double complex result;
Cyc_check_num(data, z);
if (obj_is_int(z)) {
Expand Down
29 changes: 14 additions & 15 deletions scheme/inexact.sld
Original file line number Diff line number Diff line change
Expand Up @@ -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;
")
))

0 comments on commit 7cb02e3

Please sign in to comment.