package algorithmrepository;

public interface Interpolation1D {
    public final static double tolFrac2 = 1e-10; //square tolerance for deciding if things are equally spaced, as a fraction of the actual knot-knot difference

    /** Out of bounds requests return the given constant value */
    public static final int EXTRAPOLATE_CONSTANT_VALUE = 1;
    /** Out of bounds requests return the value of the end knot in that direction */
    public static final int EXTRAPOLATE_CONSTANT_END_KNOT = 2;
    /** Out of bounds requests return a linear extrapolation of the last 2 knots */ 
    public static final int EXTRAPOLATE_LINEAR = 3;
    /** Out of bounds requests throw an exception */
    public static final int EXTRAPOLATE_EXCEPTION = 4;
    

    public int getExtrapolationMode();
    public double getExtrapolationValue();
    public void setExtrapolation(int extrapolationMode, double extrapolationValue);
    
    /**
     * Returns true if the points are regarded as equally spaced,
     * false otherwise.
     * 
     * If the points are equally spaced a faster lookup is used.
     * 
     * @return True if the points at which the function is given are
     * equally spaced, false otherwise. 
     */
    public boolean isEquallySpaced();
    

    /**
     * Returns the x coordinates.
     * 
     * @return The x coordinates.
     */
    public double[] getX();
    
    /**
     * Returns the vector of function values.
     * 
     * @return The vector of function values.
     */
    public double[] getF();
    
    /**
     * Sets the vector of function values.
     * 
     */
    public void setF(double[] fp);

    
    public double[] eval(double[] x, double[] der);
    public double[] eval(double[] x);
    public double eval(double x);

}
