vmm.functions
Class ComplexVariable

java.lang.Object
  extended by vmm.functions.ComplexVariable

public class ComplexVariable
extends java.lang.Object

A complex-valued variable. A ComplexVariable can be added to a Parser so that it can be used in the defintion of functions and expressions that are parsed by that parser. It is possible to change the value of a variable with the setVal(Complex) or setVal(double, double) method, which will affect the value of any expressions and functions in which it is used.


Constructor Summary
ComplexVariable(double re, double im)
          Create a ComplexVariable with a specified initial value and with name initially equal to null.
ComplexVariable(java.lang.String name)
          Create a ComplexVariable with a specified name and initial value zero.
ComplexVariable(java.lang.String name, double re, double im)
          Create a ComplexVariable with a specified name and initial value.
 
Method Summary
 double getIm()
          Gets the imaginary part of the value of this variable.
 java.lang.String getName()
          Get the name of this variable.
 double getRe()
          Gets the real part of the value of this variable.
 Complex getVal()
          Returns the value of this variable as an object of type Complex.
 void getVal(Complex c)
          Gets the current value of this variable by storing the value in a pre-existing object of type Complex.
 void setName(java.lang.String name)
          Sets the name of this variable.
 void setVal(Complex c)
          Set the value of this variable.
 void setVal(double re, double im)
          Sets the value of this variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComplexVariable

public ComplexVariable(java.lang.String name,
                       double re,
                       double im)
Create a ComplexVariable with a specified name and initial value.

Parameters:
name - the name of the variable. This can be null. If the variable is to be added to a Parser, then the name must be non-null and should be a legal identifier (starting with a letter and containing only letters, digits and the underscore character).
re - the real part of the initial value of the variable
im - the imaginary part of the initial value of the variable

ComplexVariable

public ComplexVariable(java.lang.String name)
Create a ComplexVariable with a specified name and initial value zero.


ComplexVariable

public ComplexVariable(double re,
                       double im)
Create a ComplexVariable with a specified initial value and with name initially equal to null.

Parameters:
re - the real part of the initial value of the variable
im - the imaginary part of the initial value of the variable
Method Detail

getRe

public double getRe()
Gets the real part of the value of this variable.


getIm

public double getIm()
Gets the imaginary part of the value of this variable.


getVal

public Complex getVal()
Returns the value of this variable as an object of type Complex.


getVal

public void getVal(Complex c)
Gets the current value of this variable by storing the value in a pre-existing object of type Complex.

Parameters:
c - the object where the value will be stored. This must be non-null.

setVal

public void setVal(double re,
                   double im)
Sets the value of this variable

Parameters:
re - the new value of the real part
im - the new value of the imaginary part

setVal

public void setVal(Complex c)
Set the value of this variable.

Parameters:
c - the new value of the variable. A null value is treated as zero.

getName

public java.lang.String getName()
Get the name of this variable. This can be null.


setName

public void setName(java.lang.String name)
Sets the name of this variable. The name should not be changed after the variable has been added to a Parser; even if the name is changed, the Parser will continue to use it under the name it had at the time it was added to the parser.