An error occurred while fetching the assigned milestone of the selected merge_request.
Clarify semantics of fancy integer division functions.
1 unresolved thread
1 unresolved thread
Closes #88 (closed).
The goal of these functions is to provide fast, fp-free functions for semi-complicated semantics on positive integers (The old implementation did not behave sensibly for negative input). This MR clarifies the names and docstrings of the fancy integer divisions to make it clear that negative input is not always expected. Furthermore, the implementation is changed such that no remainders or conditionals must be evaluated.
The old names are still available but issue deprecation warnings.
Merge request reports
Activity
Filter activity
changed milestone to %Release 2.0
added API Update v2.0-dev labels
requested review from @da15siwa
assigned to @he66coqe
- Resolved by Frederik Hennig
- Resolved by Frederik Hennig
140 129 141 def __new__(cls, integer, divisor): 142 if is_integer_sequence((integer, divisor)): 143 return integer // divisor if integer % divisor == 0 else (integer // divisor) + 1 144 else: 145 return super().__new__(cls, integer, divisor) 130 def _eval_op(self, arg1, arg2): 131 from ..utils import c_intdiv 146 132 147 # TODO: Implement this in FreezeExpressions 148 # def to_c(self, print_func): 149 # dtype = collate_types((get_type_of_expression(self.args[0]), get_type_of_expression(self.args[1]))) 150 # assert dtype.is_int() 151 # code = "( ({0}) % ({1}) == 0 ? ({dtype})({0}) / ({dtype})({1}) : ( ({dtype})({0}) / ({dtype})({1}) ) +1 )" 152 # return code.format(print_func(self.args[0]), print_func(self.args[1]), dtype=dtype) 133 return sp.sympify(c_intdiv(arg1 + arg2 - 1, arg2)) changed this line in version 2 of the diff
- Resolved by Frederik Hennig
mentioned in commit eb02fcab