Skip to content
Snippets Groups Projects

Integer functions

Merged Daniel Bauer requested to merge hyteg/pystencils:bauerd/integer-fun into backend-rework
All threads resolved!

Adds support (freezing, typing, printing) for the following integer functions from sympyextensions.integer_functions:

  • bit_shift_left
  • bit_shift_right
  • bitwise_and
  • bitwise_or
  • bitwise_xor
  • int_div
  • int_power_of_2
  • modulo_floor

The following are left for future work because they can be conveniently implemented with an if expression (the ternary if operator ?: in C) which is currently not available.

  • modulo_ceil
  • div_ceil

div_floor is also not implemented because to me the semantics of this function are unclear. Is it supposed to compute

ab\lfloor \frac ab \rfloor
(as the name suggests) or the C-like round-to-zero integer division (as the documentation suggests)?

The typifier tries to infer the integer type of the arguments/result and always raises if the type is non-integer. Note that this can lead to cases in which an exception is raised because the inference fails. For example int_div(2, 3) where both arguments are untyped constants. This could be improved in the typifier, e.g. by adding type constraints to deferred constants (also left for future work).

Edited by Daniel Bauer

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Daniel Bauer added 2 commits

    added 2 commits

    • 10bc7bac - clarify semantics of PsIntDiv and remove support for div_floor
    • df9b0a8e - add integer function printing test

    Compare with previous version

  • Daniel Bauer changed the description

    changed the description

  • Frederik Hennig added 1 commit

    added 1 commit

    • ebc36d2d - temporarily remove modulo_floor

    Compare with previous version

  • Frederik Hennig resolved all threads

    resolved all threads

  • Frederik Hennig enabled an automatic merge when the pipeline for ebc36d2d succeeds

    enabled an automatic merge when the pipeline for ebc36d2d succeeds

  • Frederik Hennig canceled the automatic merge

    canceled the automatic merge

  • Frederik Hennig mentioned in commit 075ae357

    mentioned in commit 075ae357

  • mentioned in issue #88 (closed)

  • Please register or sign in to reply
    Loading