Maths
Interface FunctionParser


public interface FunctionParser

Interface for a function parser. That is a class that parses a string of the form "function[double1,double2,...]" and return a numerical function of it. MathsParse implements some common functions used in phylogenetics and is a useful example of how to implement this class. The chnages to this injterface mean implementations of it for version 1.1 or less will need updating although this should be a simple addition.

Version:
1.2

Method Summary
 double evaluate(java.lang.String function, java.lang.Double[] variables)
          A function that evaluates all the functions implemented
 java.util.List<java.lang.String> implemented()
          Returns a list of function names that this class can calculate
 int numberInputs(java.lang.String function)
          Returns the number of inputs a function expects to be passed
 

Method Detail

evaluate

double evaluate(java.lang.String function,
                java.lang.Double[] variables)
                throws WrongNumberOfVariables,
                       NoSuchFunction
A function that evaluates all the functions implemented

Parameters:
function - The function name
variables - An array of inputs in the order they appear in the function call
Returns:
The numerical result of the function
Throws:
WrongNumberOfVariables - Thrown when the incorrect number of imputs to that function is passed.
NoSuchFunction - Thrown when the class can't parse a function of that name

numberInputs

int numberInputs(java.lang.String function)
                 throws NoSuchFunction
Returns the number of inputs a function expects to be passed

Parameters:
function - The function name
Returns:
The number of inputs expected
Throws:
NoSuchFunction - Thrown if the fucntion parser does not implement a function with that name

implemented

java.util.List<java.lang.String> implemented()
Returns a list of function names that this class can calculate

Returns:
A list of functions the class implements