com.epochx.representation.dbl
Class SquareFunction

java.lang.Object
  extended by com.epochx.representation.Node<TYPE>
      extended by com.epochx.representation.FunctionNode<java.lang.Double>
          extended by com.epochx.representation.dbl.SquareFunction
All Implemented Interfaces:
java.lang.Cloneable

public class SquareFunction
extends FunctionNode<java.lang.Double>

A FunctionNode which performs the arithmetic function of squaring, that is - raising to the second power. It is equivalent to the PowerFunction where the second child is the double literal 2.0.


Constructor Summary
SquareFunction()
          Construct a SquareFunction with no children.
SquareFunction(Node<java.lang.Double> child)
          Construct a SquareFunction with one child.
 
Method Summary
 java.lang.Double evaluate()
          Evaluating a SquareFunction involves evaluating the child then raising the result to the power of 2.
 java.lang.String getFunctionName()
          Get the unique name that identifies this function.
 
Methods inherited from class com.epochx.representation.FunctionNode
equals, toString
 
Methods inherited from class com.epochx.representation.Node
clone, getArity, getChild, getChildren, getDepth, getFunctionNodes, getLength, getNodesAtDepth, getNoDistinctFunctions, getNoDistinctTerminals, getNoFunctions, getNoTerminals, getNthNode, getTerminalNodes, hashCode, setChild, setChildren, setNthNode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SquareFunction

public SquareFunction()
Construct a SquareFunction with no children.


SquareFunction

public SquareFunction(Node<java.lang.Double> child)
Construct a SquareFunction with one child. When evaluated, the child will be evaluated with the result then raised to the power of 2.

Parameters:
child - The child which will be squared.
Method Detail

evaluate

public java.lang.Double evaluate()
Evaluating a SquareFunction involves evaluating the child then raising the result to the power of 2.

Specified by:
evaluate in class Node<java.lang.Double>
Returns:
The result of evaluating the candidate program.

getFunctionName

public java.lang.String getFunctionName()
Get the unique name that identifies this function.

Specified by:
getFunctionName in class FunctionNode<java.lang.Double>
Returns:
the unique name for the SquareFunction which is SQUARE.