protected void compute() { if (inputFunction != null) function.set(inputFunction); function.setInterval(getDouble(from), getDouble(to)); // Application.debug(function.getFunction().evaluate(new double[] {1,1})); }
/** * Construct a function * * @param cons * @param label * @param f (x,y) function * @param from "from" values for each var * @param to "to" values for each var */ public AlgoFunctionNVarND( Construction cons, String label, GeoFunctionNVar f, NumberValue[] from, NumberValue[] to) { this(cons, from, to); inputFunction = f; // function = new GeoFunctionNVar(cons, inputFunction.getFunction());//(GeoFunctionNVar) // inputFunction.copy(); function = (GeoFunctionNVar) inputFunction.copy(); // end of construction setInputOutput((NumberValue[]) null, (GeoNumeric[]) null); compute(); function.setLabel(label); }
/** * Construct a function * * @param cons * @param label * @param coords description of the function * @param localVar var of the function * @param from "from" values for each var * @param to "to" values for each var */ public AlgoFunctionNVarND( Construction cons, String label, NumberValue[] coords, GeoNumeric[] localVar, NumberValue[] from, NumberValue[] to) { this(cons, from, to); // we need to create Function objects for the coord NumberValues, // so let's get the expressions of xcoord and ycoord and replace // the localVar by a functionVar FunctionVariable[] funVar = new FunctionVariable[localVar.length]; for (int i = 0; i < localVar.length; i++) { funVar[i] = new FunctionVariable(kernel); funVar[i].setVarString(localVar[i].getLabel()); } ExpressionNode[] exp = new ExpressionNode[coords.length]; FunctionNVar[] fun = new FunctionNVar[coords.length]; for (int i = 0; i < coords.length; i++) { exp[i] = kernel.convertNumberValueToExpressionNode(coords[i]); for (int j = 0; j < localVar.length; j++) exp[i].replace(localVar[j], funVar[j]); fun[i] = new FunctionNVar(exp[i], funVar); } // create the function function = new GeoFunctionNVar(cons, fun[0]); // end of construction setInputOutput(coords, localVar); compute(); function.setLabel(label); }