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

Functions could be more object-oriented without losing any power.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0
    • 2.1
    • None
    • None
    • all

    Description

      UnivariateRealFunction, for example, is a map from R to R. The set of such functions has tons and tons of structure: in addition to being an algebra, equipped with +,-,*, and scaling by constants, it maps the same space into itself, so it is composable, both pre and post.

      I'd propose we add:

        UnivariateRealFunction plus(UnivariateRealFunction other);
        UnivariateRealFunction minus(UnivariateRealFunction other);
        UnivariateRealFunction times(UnivariateRealFunction other);
        UnivariateRealFunction times(double scale);
        UnivariateRealFunction preCompose(UnivariateRealFunction other);
        UnivariateRealFunction postCompose(UnivariateRealFunction other);
      

      to the interface, and then implement them in an AbstractUnivariateRealFunction base class. No implementer would need to notice, other than switching to extend this class rather than implement UnivariateRealFunction.

      Many people don't need or use this, but... it makes for some powerfully easy code:

      UnivariateRealFunction gaussian = Exp.preCompose(Negate.preCompose(Pow2));

      which is even nicer when done anonymously passing into a map/collect method (a la MATH-312).

      Attachments

        Activity

          People

            Unassigned Unassigned
            jake.mannix Jake Mannix
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: