commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <>
Subject [jira] Created: (MATH-535) Closing the loop in function objects
Date Thu, 24 Feb 2011 16:05:45 GMT
Closing the loop in function objects

                 Key: MATH-535
             Project: Commons Math
          Issue Type: New Feature
            Reporter: Gilles
            Priority: Minor
             Fix For: 3.0

Some function classes (in package "analysis.function") now contains a "Parametric" inner class
that provides a parametric version of the function represented by the enclosing class.

# We could enhance the "UnivariateRealFunction" interface to contain:
  public ParametricUnivariateRealFunction createParametricFunction();
which, e.g. for the "Gaussian" concrete class, would translate to:
  public Gaussian.Parametric createParametricFunction() {
    return new Gaussian.Parametric();
# We could enhance the "ParametricUnivariateRealFunction" interface to contain:
  public UnivariateRealFunction createFunction(double[] param);
which, in "Gaussian.Parametric", would translate to:
  public Gaussian createFunction(double[] param) {
    return new Gaussian(param[0], param[1], param[2]);

In both cases, it would allow programming against interfaces.

For the first case, not all current implementations of "UnivariateRealFunction" provide a
"Parametric" version (and for most there are no parameters). So either we create a new "AbstractUnivariateRealFunction"
that provides a default implementation of "createParametricFunction" (throwing an exception)
and make all current function classes extends this one, or we create a new interface (something
like "ParametricFactory") that declares the new "createParametricFunction()" and add the "implements
ParametricFactory" clause to any class that provides a parametric version.
I think that the latter is the cleanest. Or is there still another possibility?

This message is automatically generated by JIRA.
For more information on JIRA, see:


View raw message