Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-686

Add methods negate() / reciprocal() to the FieldElement interface

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Labels:
      None

      Description

      As discussed on the mailing list, it is proposed to add two methods to the FieldElement interface

      • negate() : returns the additive inverse of this element.
      • reciprocal() : returns the multiplicative inverse of this element.

      Several name couples have been proposed by Phil

      1. negate, invert
      2. opposite, reciprocal
      3. additiveInverse, multiplicativeInverse

      Looking at the classes implementing this interface in the core CM library, we find that

      • Complex, Dfp, BigFraction and Fraction already have a negate() method.
      • Besides, BigFraction and Fraction already have a reciprocal() method.

      So the best naming option would seem to be (for the time being) a mixture of what Phil proposed. I realize it's not completely satisfactory because one is a noun and one a verb. Do we want to have good grammar, or preserve what's already implemented? I tend to favour the first option (consistently change the name of existing methods).

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              celestin Sebastien Brisard
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: