com.singularsys.aa
Class EquationSystem

java.lang.Object
  extended by com.singularsys.aa.EquationSystem

public class EquationSystem
extends java.lang.Object

Represents an equation system with any number of equations.


Constructor Summary
EquationSystem()
          Creates a new EquationSystem.
 
Method Summary
 void addEquation(Expression ex)
          Adds an equation to the system of equations.
 void addEquation(java.lang.String eqStr)
          Adds an equation to the system of equations.
 Expression getEquation(int i)
          Returns the equation identified by the index i,
 int getNumEquations()
          Returns the number of equations.
 java.lang.Object[] getValues(java.util.Hashtable variables)
          Evaluates each of the equations in this equation system, and returns their results in as an array.
 java.util.Vector getVariables()
          Returns a list of all variables in the equation system.
 EquationSystem removeSubset(int[] subset)
          Removes a set of equations from this equation system, and returns them as a new EquationSystem.
 void simplify()
          Simplifies each equation in the system.
 Solution solve()
          Attempts to find a solution for the set of equations.
 void substitute(Solution sol)
           
 java.lang.String toString()
          Returns a String of the equation system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EquationSystem

public EquationSystem()
Creates a new EquationSystem.

Method Detail

addEquation

public void addEquation(java.lang.String eqStr)
                 throws java.lang.Exception
Adds an equation to the system of equations.

Throws:
java.lang.Exception

addEquation

public void addEquation(Expression ex)
Adds an equation to the system of equations.


getEquation

public Expression getEquation(int i)
Returns the equation identified by the index i,
null
if the index is out of bounds.


getNumEquations

public int getNumEquations()
Returns the number of equations.


solve

public Solution solve()
               throws java.lang.Exception
Attempts to find a solution for the set of equations.

Throws:
java.lang.Exception

simplify

public void simplify()
Simplifies each equation in the system.


getVariables

public java.util.Vector getVariables()
Returns a list of all variables in the equation system.


toString

public java.lang.String toString()
Returns a String of the equation system.

Overrides:
toString in class java.lang.Object

getValues

public java.lang.Object[] getValues(java.util.Hashtable variables)
                             throws java.lang.Exception
Evaluates each of the equations in this equation system, and returns their results in as an array.

Throws:
java.lang.Exception

removeSubset

public EquationSystem removeSubset(int[] subset)
Removes a set of equations from this equation system, and returns them as a new EquationSystem.

Important: the variables list for this equation is not updated to reflect the changes caused by removing some of the equations.

Parameters:
subset - the array of indexes of equations to be removed.
Returns:
the new equation system formed.

substitute

public void substitute(Solution sol)