Skip to content

Commit 5edb134

Browse files
committed
Fix merge fail
1 parent 6020bfa commit 5edb134

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

loopy/target/c/codegen/expression.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def __init__(self, codegen_state, fortran_abi=False, type_inf_mapper=None):
5858
self.codegen_state.callables_table)
5959
self.type_inf_mapper = type_inf_mapper
6060

61+
self.allow_complex = codegen_state.allow_complex
62+
6163
self.fortran_abi = fortran_abi
6264

6365
# {{{ helpers
@@ -512,10 +514,23 @@ def complex_type_name(self, dtype):
512514
raise LoopyError("could not map '%s' to a complex type name." % dtype)
513515

514516
def map_quotient(self, expr, type_context):
515-
num = self.rec(expr.numerator, type_context)
516-
517-
# analogous to ^{-1}
518-
denom = self.rec(expr.denominator, type_context)
517+
def base_impl(expr, type_context, num_tgt_dtype=None):
518+
num = self.rec(expr.numerator, type_context, num_tgt_dtype)
519+
520+
# analogous to ^{-1}
521+
denom = self.rec(expr.denominator, type_context)
522+
523+
if (n_dtype.kind not in "fc"
524+
and d_dtype.kind not in "fc"):
525+
# must both be integers
526+
if type_context == "f":
527+
num = var("(float) ")(num)
528+
denom = var("(float) ")(denom)
529+
elif type_context == "d":
530+
num = var("(double) ")(num)
531+
denom = var("(double) ")(denom)
532+
533+
return type(expr)(num, denom)
519534

520535
n_dtype = self.infer_type(expr.numerator).numpy_dtype
521536
d_dtype = self.infer_type(expr.denominator).numpy_dtype

0 commit comments

Comments
 (0)