/** * Get the result of applying this function. * * @param incoming the arguments to this function (supplied in order to match that * of the parameter definitions * @return the result of applying this function. When the optype is * categorical or ordinal, an index into the values of the output definition * is returned. * @throws Exception if there is a problem computing the result of this function */ public double getResult(double[] incoming) throws Exception { if (m_parameterDefs == null) { throw new Exception("[BuiltInMath] incoming parameter structure has not been set"); } if (!m_func.legalNumParams(incoming.length)) { throw new Exception("[BuiltInMath] wrong number of parameters!"); } double result = m_func.eval(incoming); return result; }
public String toString() { String result = m_func.toString() + "("; for (int i = 0; i < m_parameterDefs.size(); i++) { result += m_parameterDefs.get(i).name(); if (i != m_parameterDefs.size() - 1) { result += ", "; } else { result += ")"; } } return result; } }
} else if (name.equals("/")) { result = new BuiltInArithmetic(BuiltInArithmetic.Operator.DIVISION); } else if (name.equals(BuiltInMath.MathFunc.MIN.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.MIN); } else if (name.equals(BuiltInMath.MathFunc.MAX.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.MAX); } else if (name.equals(BuiltInMath.MathFunc.SUM.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.SUM); } else if (name.equals(BuiltInMath.MathFunc.AVG.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.AVG); } else if (name.equals(BuiltInMath.MathFunc.LOG10.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.LOG10); } else if (name.equals(BuiltInMath.MathFunc.LN.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.LN); } else if (name.equals(BuiltInMath.MathFunc.SQRT.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.SQRT); } else if (name.equals(BuiltInMath.MathFunc.ABS.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.ABS); } else if (name.equals(BuiltInMath.MathFunc.EXP.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.EXP); } else if (name.equals(BuiltInMath.MathFunc.POW.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.POW); } else if (name.equals(BuiltInMath.MathFunc.THRESHOLD.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.THRESHOLD); } else if (name.equals(BuiltInMath.MathFunc.FLOOR.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.FLOOR); } else if (name.equals(BuiltInMath.MathFunc.CEIL.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.CEIL); } else if (name.equals(BuiltInMath.MathFunc.ROUND.toString())) {
} else if (name.equals("/")) { result = new BuiltInArithmetic(BuiltInArithmetic.Operator.DIVISION); } else if (name.equals(BuiltInMath.MathFunc.MIN.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.MIN); } else if (name.equals(BuiltInMath.MathFunc.MAX.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.MAX); } else if (name.equals(BuiltInMath.MathFunc.SUM.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.SUM); } else if (name.equals(BuiltInMath.MathFunc.AVG.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.AVG); } else if (name.equals(BuiltInMath.MathFunc.LOG10.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.LOG10); } else if (name.equals(BuiltInMath.MathFunc.LN.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.LN); } else if (name.equals(BuiltInMath.MathFunc.SQRT.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.SQRT); } else if (name.equals(BuiltInMath.MathFunc.ABS.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.ABS); } else if (name.equals(BuiltInMath.MathFunc.EXP.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.EXP); } else if (name.equals(BuiltInMath.MathFunc.POW.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.POW); } else if (name.equals(BuiltInMath.MathFunc.THRESHOLD.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.THRESHOLD); } else if (name.equals(BuiltInMath.MathFunc.FLOOR.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.FLOOR); } else if (name.equals(BuiltInMath.MathFunc.CEIL.toString())) { result = new BuiltInMath(BuiltInMath.MathFunc.CEIL); } else if (name.equals(BuiltInMath.MathFunc.ROUND.toString())) {
/** * Get the result of applying this function. * * @param incoming the arguments to this function (supplied in order to match that * of the parameter definitions * @return the result of applying this function. When the optype is * categorical or ordinal, an index into the values of the output definition * is returned. * @throws Exception if there is a problem computing the result of this function */ public double getResult(double[] incoming) throws Exception { if (m_parameterDefs == null) { throw new Exception("[BuiltInMath] incoming parameter structure has not been set"); } if (!m_func.legalNumParams(incoming.length)) { throw new Exception("[BuiltInMath] wrong number of parameters!"); } double result = m_func.eval(incoming); return result; }
/** * Set the structure of the parameters that are expected as input by * this function. This must be called before getOutputDef() is called. * * @param paramDefs the structure of the input parameters * @throws Exception if the number or types of parameters are not acceptable by * this function */ public void setParameterDefs(ArrayList<Attribute> paramDefs) throws Exception { m_parameterDefs = paramDefs; if (!m_func.legalNumParams(m_parameterDefs.size())) { throw new Exception("[BuiltInMath] illegal number of parameters for function: " + m_functionName); } }
/** * Set the structure of the parameters that are expected as input by * this function. This must be called before getOutputDef() is called. * * @param paramDefs the structure of the input parameters * @throws Exception if the number or types of parameters are not acceptable by * this function */ public void setParameterDefs(ArrayList<Attribute> paramDefs) throws Exception { m_parameterDefs = paramDefs; if (!m_func.legalNumParams(m_parameterDefs.size())) { throw new Exception("[BuiltInMath] illegal number of parameters for function: " + m_functionName); } }
public String toString() { String result = m_func.toString() + "("; for (int i = 0; i < m_parameterDefs.size(); i++) { result += m_parameterDefs.get(i).name(); if (i != m_parameterDefs.size() - 1) { result += ", "; } else { result += ")"; } } return result; } }
/** * Returns an array of the names of the parameters expected * as input by this function. May return null if the function * can accept an unbounded number of arguments. * * @return an array of the parameter names (or null if the function * can accept any number of arguments). */ public String[] getParameterNames() { return m_func.getParameterNames(); }
/** * Returns an array of the names of the parameters expected * as input by this function. May return null if the function * can accept an unbounded number of arguments. * * @return an array of the parameter names (or null if the function * can accept any number of arguments). */ public String[] getParameterNames() { return m_func.getParameterNames(); }
/** * Get the structure of the result produced by this function. * Subclasses must implement. * * @return the structure of the result produced by this function. */ public Attribute getOutputDef() { return new Attribute("BuiltInMathResult:" + m_func.toString()); }
/** * Construct a new built-in pmml Math function. * @param func the math function to use */ public BuiltInMath(MathFunc func) { m_func = func; m_functionName = m_func.toString(); }
/** * Get the structure of the result produced by this function. * Subclasses must implement. * * @return the structure of the result produced by this function. */ public Attribute getOutputDef() { return new Attribute("BuiltInMathResult:" + m_func.toString()); }
/** * Construct a new built-in pmml Math function. * @param func the math function to use */ public BuiltInMath(MathFunc func) { m_func = func; m_functionName = m_func.toString(); }