/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ /* interface for creating predefined Function objects for simple math functions these functions can be used simply by "implementing" this interface e.g.: class X implements MathFunctions { ... exp ... sin ... } */ interface MathFunctions { static RealFunction exp = new RealFunction() { public double at(double x) { return Math.exp(x); } public String toString() { return "exp(x)"; } }; static RealFunction log = new RealFunction() { public double at(double x) { return Math.log(x); } public String toString() { return "log(x)"; } }; static RealFunction sin = new RealFunction() { public double at(double x) { return Math.sin(x); } public String toString() { return "sin(x)"; } }; static RealFunction sqr = new RealFunction() { public double at(double x) { return x * x; } public String toString() { return "x * x"; } }; }