All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class term.Funktion

java.lang.Object
   |
   +----term.TermBaum
           |
           +----term.Funktion

public abstract class Funktion
extends TermBaum
TermBaum of a Funktion.

This is the superclass of the implementations of various functions. New functions can be added by adding new sub classes to this package.

New function classes are instantiated dynamically by name if they occur in the parsed function.

Implemented functionsdescription
ABS(p1) calculates the absolute value (?)
ABS(p1) = { (p1) if p1>=0, (-p1) if p1<0 }
SGN(p1) sign finction
SGN( p1 ) = { (-1) if p1<0, (0) if p1=0, (1) if p1>0 }
CEIL(p1), FLOOR(p1) round up/down
CEIL ( 0.1 ) = 1, FLOOR( 0.9 ) = 0
COS(p1), SIN(p1) cosine, sine
Warning: the calculation of these functions is very inaccurate due to a neccessary conversion into "double" precision.
DIFF(v,p1) generates the symbolic derivation of the term p1 with respect to the variable v
DIV(p1,p2), MOD(p1,p2) integer division and modulo (?)
DIV( a*b+c, b ) = a
MOD( a*b+c, b ) = c
Note: p1 and p2 have to be integers to apply this function !
EXP(p1), LN(p1) natural power function and logarithm
FAK(p1) factorial
FAK( p1 ) = p1*(p1-1)*(p1-2)* ... * 1


Constructor Index

 o Funktion()
protected Constructor for subclasses
 o Funktion(TermBaum)
Special Constructor for subclasses with one operand.

Method Index

 o ableitung(String)
Abstract method that generates the derivation of a specific function.
Non differentiable functions are encouraged to throw a TermFaultException at this point.
 o AnzOperanden()
The number of the parameters this function expects.
 o berechne(VariableTable, int)
Calculate the function value for the given value of the variables.
 o cloneTerm()
copies a complete TermBaum
 o errorNoDerivation()
Throws an exception to report a non differentiable function.
 o parse2Liste(String, int)
Parses the single parameters of a function into a list.
 o parseFunktion(String, int)
Parse a Term like 'F(p1,p2,...)', returning an object representing the function that was recognized.
New functions can be added by writing sub classes of this one that will be instantiated by name if they occur in the parsed function.
 o toString()
Returns a String representatin of the function and its parameters.
 o vereinfache()
Sub classes should return a new TermBaum that is simplified as much as possible.

Constructors

 o Funktion
 protected Funktion(TermBaum operand)
Special Constructor for subclasses with one operand.

 o Funktion
 protected Funktion()
protected Constructor for subclasses

Methods

 o ableitung
 public abstract TermBaum ableitung(String variable)
Abstract method that generates the derivation of a specific function.
Non differentiable functions are encouraged to throw a TermFaultException at this point.

Overrides:
ableitung in class TermBaum
 o AnzOperanden
 protected abstract int AnzOperanden()
The number of the parameters this function expects. If the number in the parsed term differes from the return value here, an Exception will be generated.

 o berechne
 public abstract BigDecimal berechne(VariableTable variables,
                                     int Genauigkeit)
Calculate the function value for the given value of the variables. The second parameter gives the number of decimals.

Overrides:
berechne in class TermBaum
 o cloneTerm
 public TermBaum cloneTerm()
copies a complete TermBaum

Overrides:
cloneTerm in class TermBaum
 o errorNoDerivation
 protected final TermBaum errorNoDerivation()
Throws an exception to report a non differentiable function.

 o parse2Liste
 protected void parse2Liste(String Term,
                            int Offset) throws TermFaultException
Parses the single parameters of a function into a list.

 o parseFunktion
 public static Funktion parseFunktion(String Term,
                                      int Offset) throws TermFaultException
Parse a Term like 'F(p1,p2,...)', returning an object representing the function that was recognized.
New functions can be added by writing sub classes of this one that will be instantiated by name if they occur in the parsed function.

 o toString
 public String toString()
Returns a String representatin of the function and its parameters.

Overrides:
toString in class TermBaum
 o vereinfache
 public abstract TermBaum vereinfache()
Sub classes should return a new TermBaum that is simplified as much as possible.

Overrides:
vereinfache in class TermBaum

All Packages  Class Hierarchy  This Package  Previous  Next  Index