Hello. Le ven. 12 août 2022 à 16:31, <michael.sch...@dlr.de> a écrit : > > Hello math community! > > The current math4.legacy.analysis.interpolation.SplineInterpolator implements > an unclamped (natural) spline. We recently implemented the clamped spline > which offers additional parameterization of starting and ending slopes. This > extension we would like to contribute as a pull request to your GitHub > repository.
Welcome; and thanks for your interest! > Still, we are new to Apache Commons Math and have some basic questions: > > > 1. What do we have to be aware of regarding the transition from math3 to > math4? Is math4.legacy the designated package for future development? For the very near future, yes; the next official release (out soonish, I hope) will be version 4.0 based on the current contents of the "master" branch. In the longer term, the aim is to continue with modularizing the library (e.g. a new module dedicated to "interpolation" would make sense). How soon this is achieved will depend on people stepping in to help. > If not, where to put new functions? > 2. Should we simply create a new spline class which partially duplicates > code of the original SplineInterpolator, or should we do some refactoring > which distinguishes between unclamped and clamped spline implementations > elegantly? Without hesitation, let's aim at elegance and avoid duplication. ;-) > I thought about a higher-level super class of a generic spline which bundles > common functions in order to avoid code duplication in the implementations of > both the unclamped and clamped spline. The original unclamped spline could > stay the default method which would ensure backwards compatibility. How about "SplineInterpolator" provide a factory method to select one or the other implementation? I.e. something like ---CUT--- public SplineInterpolator implements UnivariateInterpolator { /** Interpolation algorithm variant. */ private final BiFunction<double[], double[], UnivariateFunction> algo; /** * Factory method. * @param clamped ... * @return a new interpolator instance. */ public static SplineInterpolator create(boolean clamped) { if (clamped) { algo = new Clamped(); } else { algo = new Unclamped(); } } @Override public PolynomialSplineFunction interpolate(double[] x, double[] y) { return algo.apply(x, y); } private static class Unclamped implements BiFunction<double[], double[], PolynomialSplineFunction> { // ... current implementation ... } private static class Clamped implements BiFunction<double[], double[], PolynomialSplineFunction> { // ... your proposed functionality ... } // Commons functions ... } ---CUT--- Best regards, Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org