net.sourceforge.webcompmath.awt
Class ExpressionInput.EI

java.lang.Object
  extended by net.sourceforge.webcompmath.awt.ExpressionInput.EI
All Implemented Interfaces:
java.io.Serializable, Expression, Value
Enclosing class:
ExpressionInput

protected class ExpressionInput.EI
extends java.lang.Object
implements Expression

The expression associated with an ExpressionInput belongs to this class. So is any derivative of such a function. Note that derivatives must be recomputed when the expression changes. This is done via "lazy evaluation", that is, only when necessary. When a derivative is used, it tests whether it is out of date by comparing its serialNumber to the serial number of the expression that it is the derivative of. If they don't match, then the expression is recomputed and the serial number is updated. The serial number and defintion of the main expresssion is changed by checkInput() whenever the user's input has changed.

See Also:
Serialized Form

Method Summary
 boolean dependsOn(Variable x)
          Get whether this expression depends on a particular variable
 Expression derivative(Variable wrt)
          Get the derivative of the expression
 double getVal()
          Returns the value of the expression
 double getValueWithCases(Cases c)
          Returns the value of the expression
 java.lang.String toString()
          Convert the expression to a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getVal

public double getVal()
Returns the value of the expression

Specified by:
getVal in interface Value
Returns:
the value

getValueWithCases

public double getValueWithCases(Cases c)
Returns the value of the expression

Specified by:
getValueWithCases in interface Expression
Parameters:
c - the cases to use
Returns:
the value

toString

public java.lang.String toString()
Convert the expression to a string

Specified by:
toString in interface Expression
Overrides:
toString in class java.lang.Object
Returns:
the string

derivative

public Expression derivative(Variable wrt)
Get the derivative of the expression

Specified by:
derivative in interface Expression
Parameters:
wrt - variable with respect to
Returns:
the derivative

dependsOn

public boolean dependsOn(Variable x)
Get whether this expression depends on a particular variable

Specified by:
dependsOn in interface Expression
Parameters:
x - the valiable to check
Returns:
true or false