de.congrace.exp4j
Class CustomFunction

java.lang.Object
  extended by de.congrace.exp4j.CustomFunction

public abstract class CustomFunction
extends Object

this classed is used to create custom functions for exp4j

Example

        
 CustomFunction fooFunc = new CustomFunction("foo") {
                public double applyFunction(double value) {
                        return value*Math.E;
                }
 };
 double varX=12d;
 Calculable calc = new ExpressionBuilder("foo(x)").withCustomFunction(fooFunc).withVariable("x",varX).build();
 assertTrue(calc.calculate() == Math.E * varX);
 }

Author:
frank asseg

Constructor Summary
protected CustomFunction(String name)
          create a new single value input CustomFunction with a set name
protected CustomFunction(String name, int argumentCount)
          create a new single value input CustomFunction with a set name
 
Method Summary
abstract  double applyFunction(double... args)
           
 int getArgumentCount()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomFunction

protected CustomFunction(String name)
                  throws InvalidCustomFunctionException
create a new single value input CustomFunction with a set name

Parameters:
value - the name of the function (e.g. foo)
Throws:
InvalidCustomFunctionException

CustomFunction

protected CustomFunction(String name,
                         int argumentCount)
                  throws InvalidCustomFunctionException
create a new single value input CustomFunction with a set name

Parameters:
value - the name of the function (e.g. foo)
Throws:
InvalidCustomFunctionException
Method Detail

getArgumentCount

public int getArgumentCount()

applyFunction

public abstract double applyFunction(double... args)


Copyright © 2012. All Rights Reserved.