AlgART Home

net.algart.math.functions
Class ConstantFunc

java.lang.Object
  extended by net.algart.math.functions.ConstantFunc
All Implemented Interfaces:
Func

public abstract class ConstantFunc
extends java.lang.Object
implements Func

Trivial constant function: f(x0, x1, ..., xn-1) = c, where c is a constant. The get(double...) method of the instance of this class may process any number of arguments.

This class is immutable and thread-safe: there are no ways to modify settings of the created instance.

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
 
Method Summary
Modifier and Type Method and Description
abstract  double get()
          Equivalent to get(new double[0]).
abstract  double get(double... x)
          Returns the result of this function for the given arguments: f(x0, x1, ..., xx.length-1).
abstract  double get(double x0)
          Equivalent to get(new double[] {x0}).
abstract  double get(double x0, double x1)
          Equivalent to get(new double[] {x0, x1}).
abstract  double get(double x0, double x1, double x2)
          Equivalent to get(new double[] {x0, x1, x2}).
abstract  double get(double x0, double x1, double x2, double x3)
          Equivalent to get(new double[] {x0, x1, x2, x3}).
static ConstantFunc getInstance(double c)
          Returns an instance of this class that always returns the passed constant c.
 java.lang.String toString()
          Returns a brief string description of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static ConstantFunc getInstance(double c)
Returns an instance of this class that always returns the passed constant c.

Parameters:
c - the constant returned by get(double...) method.
Returns:
an instance of this class.


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 abstract double get()
Description copied from interface: Func
Equivalent to get(new double[0]). Provides better performance because it does not require Java array creation.

Specified by:
get in interface Func
Returns:
the function result.

get

public abstract double get(double x0)
Description copied from interface: Func
Equivalent to get(new double[] {x0}). Provides better performance because it does not require Java array creation.

Specified by:
get in interface Func
Parameters:
x0 - the function argument.
Returns:
the function result.

get

public abstract double get(double x0,
                           double x1)
Description copied from interface: Func
Equivalent to get(new double[] {x0, x1}). Provides better performance because it does not require Java array creation.

Specified by:
get in interface Func
Parameters:
x0 - the first function argument.
x1 - the second function argument.
Returns:
the function result.

get

public abstract double get(double x0,
                           double x1,
                           double x2)
Description copied from interface: Func
Equivalent to get(new double[] {x0, x1, x2}). Provides better performance because it does not require Java array creation.

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.

get

public abstract double get(double x0,
                           double x1,
                           double x2,
                           double x3)
Description copied from interface: Func
Equivalent to get(new double[] {x0, x1, x2, x3}). Provides better performance because it does not require Java array creation.

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.

toString

public java.lang.String toString()
Returns a brief string description of this object.

Overrides:
toString in class java.lang.Object
Returns:
a brief string description of this object.