> > What do you think of creating a "function" package that would contain all
> > the usual functions as classes implementing the "UnivariateRealFunction"
> > interface? I.e. for example:
> > ---CUT---
> > package org.apache.commons.math.function;
> >
> > import org.apache.commons.math.util.FastMath;
> >
> > public class Cos implements UnivariateRealFunction {
> > public double value(double x) {
> > return FastMath.cos(x);
> > }
> > }
> Where is the big difference/advantage instead of using a static import
> like this:
>
> import static org.apache.commons.math.analysis.ComposableFunction.*
>
> and using COS from there?
>
> Now you can create composed functions like this:
>
> UnivariateRealFunction f = COS.of(SIN)
Thanks for pointing out that "ComposableFunction" existed; I didn't know! :-}
Concerning my goal of simplifying the code in "ArrayRealVector", I wonder
why it doesn't override only "map" and "mapToSelf" from the parent class,
instead of overriding all the "mapXxx"...
Concerning the "ComposableFunction" class itself, at first look, I feel a
little bit uncomfortable with the static import... I think I'd prefer a
base class "ComposableFunction" from which classes "Cos", "Sin", etc. would
inherit; but I'm not sure yet :-)
Also why is the "compose" functionality given the name "of"? Since there is
a "postCompose", the relationship would be clearer with the former name.
If a short name is wanted, then "o" could be a reminder of the mathematical
symbol for composition.
Gilles
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]