gpsys.primitives
Class Div

java.lang.Object
  |
  +--gpsys.Primitive
        |
        +--gpsys.Function
              |
              +--gpsys.primitives.Div

public class Div
extends Function

	<typeX> Div(<typeX> num1, <typeX> num2)
 
Div is a generic function that returns the result of dividing the first argument by the second argument. Div needs to be Type instantiated during construction to work with particular argument Types. The supported argument Types include BYTE, SHORT, INT, LONG, FLOAT and DOUBLE. Div generates a DivisionByZero exception when the numerator is 0.

Version:
$Revision: 1.1 $, $Date: 2000/07/05 16:24:33 $
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.
See Also:
Type, Primitive, Function, Serialized Form

Fields inherited from class gpsys.Function
argTypes
 
Fields inherited from class gpsys.Primitive
type
 
Constructor Summary
Div(Type type)
          Constructs a Div Function that works with the specified Type.
 
Method Summary
 byte evaluateByte(Individual i, Gene[] arguments)
          Used to divide arguments of BYTE Types.
 double evaluateDouble(Individual i, Gene[] arguments)
          Used to divide arguments of DOUBLE Types.
 float evaluateFloat(Individual i, Gene[] arguments)
          Used to divide arguments of FLOAT Types.
 int evaluateInt(Individual i, Gene[] arguments)
          Used to divide arguments of INT Types.
 long evaluateLong(Individual i, Gene[] arguments)
          Used to divide arguments of LONG Types.
 short evaluateShort(Individual i, Gene[] arguments)
          Used to divide arguments of SHORT Types.
 Primitive instance()
          Creates an instance of this Div object.
 java.lang.String toString()
          Returns a String representation of this Function.
 
Methods inherited from class gpsys.Function
evaluateBoolean, evaluateChar, evaluateObject
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

Div

public Div(Type type)
Constructs a Div Function that works with the specified Type. The supported Types include BYTE, SHORT, INT, LONG, FLOAT and DOUBLE.
Parameters:
type - The Type of this Div Function.
Method Detail

evaluateByte

public final byte evaluateByte(Individual i,
                               Gene[] arguments)
                        throws EvaluationException
Used to divide arguments of BYTE Types.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be divided.
Returns:
A byte representing the result of the division.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateByte in class Function

evaluateShort

public final short evaluateShort(Individual i,
                                 Gene[] arguments)
                          throws EvaluationException
Used to divide arguments of SHORT Types.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be divided.
Returns:
A short representing the result of the division.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateShort in class Function

evaluateInt

public final int evaluateInt(Individual i,
                             Gene[] arguments)
                      throws EvaluationException
Used to divide arguments of INT Types.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be divided.
Returns:
A int representing the result of the division.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateInt in class Function

evaluateLong

public final long evaluateLong(Individual i,
                               Gene[] arguments)
                        throws EvaluationException
Used to divide arguments of LONG Types.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be divided.
Returns:
A long representing the result of the division.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateLong in class Function

evaluateFloat

public final float evaluateFloat(Individual i,
                                 Gene[] arguments)
                          throws EvaluationException
Used to divide arguments of FLOAT Types.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be divided.
Returns:
A float representing the result of the division.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateFloat in class Function

evaluateDouble

public final double evaluateDouble(Individual i,
                                   Gene[] arguments)
                            throws EvaluationException
Used to divide arguments of DOUBLE Types.
Parameters:
i - The individual being evaluated.
arguments - The Gene trees representing the arguments to be divided.
Returns:
A double representing the result of the division.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateDouble in class Function

instance

public final Primitive instance()
Creates an instance of this Div object. The Type instantiation is preserved so that if an INT Div is being cloned, the clone will also be INT instantiated.
Returns:
A reference to this Object (yes the same object, since the type information is to be the same, there are therefore no instance variables to be modified.
Overrides:
instance in class Primitive

toString

public java.lang.String toString()
Returns a String representation of this Function.
Returns:
A String containing the name of the Function.
Overrides:
toString in class Primitive