Examples of JEP


Examples of org.nfunk.jep.JEP

      }
    }
  }

  private static JEP getJEP(final String formula) {
    JEP jep = new JEP();
    jep.addStandardFunctions();
    jep.addStandardConstants();
    jep.setAllowUndeclared(true);
    jep.setImplicitMul(true);
    jep.parseExpression(formula);
    return jep;
  }
View Full Code Here

Examples of org.nfunk.jep.JEP

    public double expandFieldValue(int index, BigInteger bits) {       
        FieldDefinition fd = getField(index);
        BigInteger raw = extractFieldValue(fd.getName(), bits);
        String expression = fd.getOperands();
        JEP expressionParser = new JEP();
       
       
        if PropertiesUtil.isEmpty(expression) ) {
            return raw.doubleValue();
        }
      
       
        if (expression.indexOf('[') != -1 ) {
            // this is a look up expresion
            double []vals = parseLookupTable(expression);
           
            return vals[raw.intValue()];       
        }
       
        List ids = parseIdentifiers(expression);
       
        if ( ids.size() != 0 ) {
            expression = removeIdentifiers(expression);
           
            Iterator tor = ids.iterator();
            while (tor.hasNext()) {
                String idName = (String) tor.next();
                FieldDefinition fieldDefinition = (FieldDefinition) getField(idName);
               
                if ( fieldDefinition == null ) {
                    throw new IllegalArgumentException("unknown field: " + idName);
                }
               
                if ( fieldDefinition.getOffset() < fd.getOffset() ) {
                    throw new IllegalStateException("cannot access downstream field: " + idName);
                }
               
                expressionParser.addVariable(idName, expandFieldValue(fieldDefinition.getIndex(), bits));               
            }
        }
       
        expressionParser.addVariable("x", raw.floatValue());
        expressionParser.addVariable("fieldWidth", fd.getWidth());
        expressionParser.addVariable("maxValue", EncodingUtil.getMaxValue(fd.getWidth()).floatValue());
        expressionParser.parseExpression(expression);
       
        
        return expressionParser.getValue();       
    }
View Full Code Here

Examples of org.nfunk.jep.JEP

    public ParserExpressao(List<String> var) {

        int i;
       
        j = new JEP();
       
        for (i=0;i<var.size();i++)
            j.addConstant(var.get(i), (Object) 0);

        j.addConstant("ß0", (Object) 0);
View Full Code Here

Examples of org.nfunk.jep.JEP

    public ParserEquacao(List<String> var) {

        int i;
       
        j = new JEP();
       
        for (i=0;i<var.size();i++)
            j.addConstant(var.get(i), (Object) 0);

        j.addConstant("ß0", (Object) 0);
View Full Code Here

Examples of org.nfunk.jep.JEP

        // set gradient
        gjep = new JEP[super.variables.length];
        for (int i=0; i<super.variables.length; i++)
        {
            gjep[i] = new JEP();
            gjep[i].addStandardFunctions();
            gjep[i].addStandardConstants();
            for (String var:super.variables)
                gjep[i].addVariable(var, 0);
            gjep[i].parseExpression(_derivatives[i]);
View Full Code Here

Examples of org.nfunk.jep.JEP

  private JEP evaluator;
  private List<Function> functions;
  private List<Operator> operators;

  public EvaluatorFacade() {
    evaluator = new JEP();
    evaluator.addStandardConstants();
    evaluator.addStandardFunctions();
   
    collectOperators();
    collectFunctions();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.