[Mathlib-commitlog] mathlib/Source/MathLib/Functions ExternalElementWiseFunction.java, NONE, 1.1 E
Status: Beta
Brought to you by:
st_mueller
|
From: Stefan M. <st_...@us...> - 2007-01-10 18:49:54
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20377/Source/MathLib/Functions Modified Files: ExternalFunction.java Added Files: ExternalElementWiseFunction.java Log Message: converted evaluation to ExternalElementWiseFunction --- NEW FILE: ExternalElementWiseFunction.java --- package MathLib.Functions; import MathLib.Tokens.NumberToken; import MathLib.Tokens.OperandToken; import MathLib.Tokens.Token; /**Base class for all external function classes which work element wise*/ abstract public class ExternalElementWiseFunction extends ExternalFunction { /** * standard function for evaluation of general external functions * @param operands * @retrun */ public OperandToken evaluate(Token[] operands) { // function works for one argument only if (getNArgIn(operands)!=1) throwMathLibException(name + " number of arguments < 1"); // works on numbers only if (!(operands[0] instanceof NumberToken)) throwMathLibException(name + " only works on numbers"); // get number token NumberToken numOp = (NumberToken)operands[0]; // get dimension of number token (2dimensional, 3dim, ....) int[] dim = numOp.getSize(); // ceate array of correct size with dimensions "dim" NumberToken num = new NumberToken(dim, null, null); // call element evaluation for all values inside the NumberToken for (int i=0; i< numOp.getNumberOfElements(); i++) { num.setValueComplex(i, evaluateValue( numOp.getValueComplex(i) )); } return num; } // end evaluate // all subclasses of this cluss MUST implement the method below abstract public double[] evaluateValue(double[] complex); } Index: ExternalFunction.java =================================================================== RCS file: /cvsroot/mathlib/mathlib/Source/MathLib/Functions/ExternalFunction.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ExternalFunction.java 14 Nov 2004 19:07:59 -0000 1.7 --- ExternalFunction.java 10 Jan 2007 18:49:47 -0000 1.8 *************** *** 4,7 **** --- 4,14 ---- abstract public class ExternalFunction extends Function { + + /**Index for real values within array*/ + protected static final int REAL = 0; + + /**Index for Imaginary values within array*/ + protected static final int IMAG = 1; + /**Number of paramaters take by the function*/ private int paramCount; |