AlgART Home

net.algart.math.functions
Class AbstractFunc

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

public abstract class AbstractFunc
extends java.lang.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).

AlgART Laboratory 2007-2013

Since:
JDK 1.5
Version:
1.2
Author:
Daniel Alievsky

Nested Class Summary
Modifier and Type Interface and Description
 
Nested classes/interfaces inherited from interface net.algart.math.functions.Func
Func.Updatable
 
Field Summary
Modifier and Type Field and Description
 
Fields inherited from interface net.algart.math.functions.Func
ABS, ABS_DIFF, HALF_X_MINUS_Y, HALF_X_PLUS_Y, HALF_Y_MINUS_X, IDENTITY, MAX, MIN, POSITIVE_DIFF, REVERSE, SELECT, SELECT_FROM_8_DIRECTIONS_2D, SELECT_IF_GREATER, SELECT_IF_GREATER_OR_EQUAL, SHIFTS_ALONG_8_DIRECTIONS_2D, UPDATABLE_IDENTITY, X_MINUS_Y, X_PLUS_Y, Y_MINUS_X
 
Constructor Summary
Constructor and Description
AbstractFunc()
           
 
Method Summary
Modifier and Type Method and Description
 double get()
          This implementation calls get(EMPTY), where EMPTY is a constant array double[0].
abstract  double get(double... x)
          Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).
 double get(double x0)
          This implementation calls get(new double[] {x0}).
 double get(double x0, double x1)
          This implementation calls get(new double[] {x0, x1}).
 double get(double x0, double x1, double x2)
          This implementation calls get(new double[] {x0, x1, x2}).
 double get(double x0, double x1, double x2, double x3)
          This implementation calls get(new double[] {x0, x1, x2, x3}).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractFunc

public AbstractFunc()
Method Detail

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:
java.lang.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:
java.lang.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:
java.lang.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:
java.lang.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:
java.lang.IndexOutOfBoundsException - may be thrown this function requires at least 3 arguments.