Skip to content

inconsistent semantics of gcd, lcm #56166

Open
@nsajko

Description

Regarding the greatest common divisor (GCD) and least common multiple (LCM), as binary operators, it seems that two incompatible meanings exist:

@cyanescent and @barucden point out in #55379 and #56113 that:

  • lcm is currently broken for arrays of nonintegral numbers
  • the breakage stems from a faulty, non-identity, init argument to reduce (the lcm for array arguments is implemented in terms of reduce and the binary lcm)

@cyanescent further points out in the linked PR that perhaps a valid value for init doesn't exist. It seems to me that @cyanescent is correct and the attempt at supporting empty collections is misguided, because it corresponds to the second meaning above, while Julia otherwise uses the first meaning above.

The init arguments should be removed, I guess, while breaking support for empty arrays, as per @barucden's suggestion in the linked issue. I'll try to guide @cyanescent in forming their PR to fix this (mostly just tests are necessary). Also I guess a PkgEval will be necessary.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    mathsMathematical functionsminor changeMarginal behavior change acceptable for a minor release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions