JADE v6.1

com.dautelle.math.functions
Class Function.Variable

java.lang.Object
  extended bycom.dautelle.realtime.LocalContext.Variable
      extended bycom.dautelle.math.functions.Function.Variable
All Implemented Interfaces:
java.lang.Comparable
Enclosing class:
Function

public static final class Function.Variable
extends LocalContext.Variable
implements java.lang.Comparable

This class represents a symbol on whose value a Function depends. The actual value can be context-local. For example:

 
     // f(x) = x² + x + 1, calculate f(1+2i)
     Polynomial x = Polynomial.valueOf(Complex.ONE, Variable.X);
     Constant one = Constant.valueOf(Complex.ONE);
     Polynomial fx = (Polynomial) x.pow(2).plus(x).plus(one);
     LocalContext.enter();
     try {
         Variable.X.setValue(Complex.valueOf(1, 2));
         Complex result = (Complex) fx.evaluate();
         System.out.println("f(1+2i) = " + result);
     } finally {
         LocalContext.exit();
     }
 
     > f(1+2i) = -1.0 + 6.0i 
 

Instances of this class are unique (the implementation guarantees that all instances have a different symbol).

See Also:
Variable -- from MathWorld, Function.evaluate()

Field Summary
static Function.Variable T
          The variable with symbol "t".
static Function.Variable X
          The variable with symbol "x".
static Function.Variable Y
          The variable with symbol "y".
static Function.Variable Z
          The variable with symbol "z".
 
Fields inherited from class com.dautelle.realtime.LocalContext.Variable
MAX
 
Method Summary
 int compareTo(java.lang.Object that)
          Compares this variable with the specified variable for order.
 java.lang.String getSymbol()
          Returns the symbol for this variable.
 java.lang.String toString()
          Returns the string representation of this variable.
static Function.Variable valueOf(java.lang.String symbol)
          Returns the variable having the specified symbol.
 
Methods inherited from class com.dautelle.realtime.LocalContext.Variable
getValue, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

X

public static final Function.Variable X
The variable with symbol "x".


Y

public static final Function.Variable Y
The variable with symbol "y".


Z

public static final Function.Variable Z
The variable with symbol "z".


T

public static final Function.Variable T
The variable with symbol "t".

Method Detail

valueOf

public static Function.Variable valueOf(java.lang.String symbol)
Returns the variable having the specified symbol.

Parameters:
symbol - the symbol of the variable to return.
Returns:
an existing or a new variable.
Throws:
java.lang.IllegalArgumentException - if symbol.length() == 0

getSymbol

public java.lang.String getSymbol()
Returns the symbol for this variable.

Returns:
this variable's symbol.

compareTo

public int compareTo(java.lang.Object that)
Compares this variable with the specified variable for order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
that - the variable to compare with.
Returns:
a negative integer, zero, or a positive integer as this variable is less than, equal to, or greater than the specified variable.
Throws:
java.lang.ClassCastException - if the specified object is not a variable.

toString

public java.lang.String toString()
Returns the string representation of this variable.

Returns:
this variable's symbol.

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.