01: /*************************************************************************
02: * *
03: * 1) This source code file, in unmodified form, and compiled classes *
04: * derived from it can be used and distributed without restriction, *
05: * including for commercial use. (Attribution is not required *
06: * but is appreciated.) *
07: * *
08: * 2) Modified versions of this file can be made and distributed *
09: * provided: the modified versions are put into a Java package *
10: * different from the original package, edu.hws; modified *
11: * versions are distributed under the same terms as the original; *
12: * and the modifications are documented in comments. (Modification *
13: * here does not include simply making subclasses that belong to *
14: * a package other than edu.hws, which can be done without any *
15: * restriction.) *
16: * *
17: * David J. Eck *
18: * Department of Mathematics and Computer Science *
19: * Hobart and William Smith Colleges *
20: * Geneva, New York 14456, USA *
21: * Email: eck@hws.edu WWW: http://math.hws.edu/eck/ *
22: * *
23: *************************************************************************/package edu.hws.jcm.data;
24:
25: /**
26: * A Function is a mathematical real-valued function of zero or more
27: * real-valued arguments. The number of arguments is called the arity
28: * of the function.
29: */
30: abstract public interface Function extends java.io.Serializable {
31:
32: /**
33: * Return the number of arguments of this function. This must
34: * be a non-negative integer.
35: */
36: public int getArity();
37:
38: /**
39: * Find the value of the function at the argument values
40: * given by arguments[0], arguments[1], ... The length
41: * of the array, arguments, should be equal to the arity of
42: * the function.
43: */
44: public double getVal(double[] arguments);
45:
46: /**
47: * Find the value of the function at the argument values
48: * given by arguments[0], arguments[1], ... The length
49: * of the array argument should be equal to the arity of
50: * the function. Information about "cases" is stored in
51: * the Cases parameter, if it is non-null. See the Cases
52: * class for more information.
53: */
54: public double getValueWithCases(double[] arguments, Cases cases);
55:
56: /**
57: * Return the derivative of the function with repect to
58: * argument number wrt. For example, derivative(1) returns
59: * the derivative function with respedt to the first argument.
60: * Note that argements are numbered starting from 1.
61: */
62: public Function derivative(int wrt);
63:
64: /**
65: * Return the derivative of the function with respect to the
66: * variable x. This will be non-zero only if x occurs somehow in
67: * the definition of x: For example, f(y) = sin(x*y);
68: * (This routine is required for the general function-differentiating
69: * code in the class FunctionParserExtension.)
70: */
71: public Function derivative(Variable x);
72:
73: /**
74: * Return true if the defintion of this function depends
75: * in some way on the variable x. If not, it's assumed
76: * that the derivative w.r.t. x of the function, applied to any
77: * arguments that do not themselves depend on x, is zero.
78: * (This routine is required for the general function-differentiating
79: * code in the class FunctionParserExtension.)
80: */
81: public boolean dependsOn(Variable x);
82:
83: }
|