Class AbstractFunc

java.lang.Object
net.algart.math.functions.AbstractFunc
All Implemented Interfaces:
Func
Direct Known Subclasses:
HyperboloidOfRevolutionFunc, MaxFromTwoSelectedNumbersFunc, MinFromTwoSelectedNumbersFunc, ParaboloidOfRevolutionFunc, UpperHalfEllipsoidOfRevolutionFunc

public abstract class AbstractFunc extends Object implements Func

A skeletal implementation of the Func interface to minimize the effort required to implement this interface.

Warning: in most cases, we strongly recommend to override the overloaded versions of get method (get(), get(double), get(double, double), get(double, double, double)), if they are applicable for your function. The default implementations, provided by this class, work relatively slowly, because they allocate a little Java array for passing to the basic get(double...) method. For example, if you create a function with two arguments f(x0, x1) = x0/x1, you should override the version with two arguments: get(double, double).

Author:
Daniel Alievsky
  • Constructor Details

    • AbstractFunc

      public AbstractFunc()
  • Method Details

    • get

      public abstract double get(double... x)
      Description copied from interface: Func
      Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).

      This method must not change the values of x elements!

      Specified by:
      get in interface Func
      Parameters:
      x - the function arguments.
      Returns:
      the function result.
    • get

      public double get()
      This implementation calls get(EMPTY), where EMPTY is a constant array double[0].
      Specified by:
      get in interface Func
      Returns:
      the function result.
      Throws:
      IndexOutOfBoundsException - may be thrown this function requires at least 1 argument.
    • get

      public double get(double x0)
      This implementation calls get(new double[] {x0}). May be overridden to provide better performance.
      Specified by:
      get in interface Func
      Parameters:
      x0 - the function argument.
      Returns:
      the function result.
      Throws:
      IndexOutOfBoundsException - may be thrown this function requires at least 2 arguments.
    • get

      public double get(double x0, double x1)
      This implementation calls get(new double[] {x0, x1}). May be overridden to provide better performance.
      Specified by:
      get in interface Func
      Parameters:
      x0 - the first function argument.
      x1 - the second function argument.
      Returns:
      the function result.
      Throws:
      IndexOutOfBoundsException - may be thrown this function requires at least 3 arguments.
    • get

      public double get(double x0, double x1, double x2)
      This implementation calls get(new double[] {x0, x1, x2}). May be overridden to provide better performance.
      Specified by:
      get in interface Func
      Parameters:
      x0 - the first function argument.
      x1 - the second function argument.
      x2 - the third function argument.
      Returns:
      the function result.
      Throws:
      IndexOutOfBoundsException - may be thrown this function requires at least 3 arguments.
    • get

      public double get(double x0, double x1, double x2, double x3)
      This implementation calls get(new double[] {x0, x1, x2, x3}). May be overridden to provide better performance.
      Specified by:
      get in interface Func
      Parameters:
      x0 - the first function argument.
      x1 - the second function argument.
      x2 - the third function argument.
      x3 - the fourth function argument.
      Returns:
      the function result.
      Throws:
      IndexOutOfBoundsException - may be thrown this function requires at least 3 arguments.