Package org.encog.ml.prg.expvalue

Examples of org.encog.ml.prg.expvalue.ExpressionValue


    this.program = theProgram;
    return renderNode(this.program.getRootNode());
  }

  private String handleConst(ProgramNode node) {
    ExpressionValue v = node.getData()[0];
    return v.toStringValue();
  }
View Full Code Here


    Assert.assertEquals( -0.0015, EncogProgram.parseFloat("-1.5e-3"),Encog.DEFAULT_DOUBLE_EQUAL);
    Assert.assertEquals( 1.2345678, EncogProgram.parseFloat("1.2345678"),Encog.DEFAULT_DOUBLE_EQUAL);
  }
 
  public void testTypes() {
    ExpressionValue exp = EncogProgram.parseExpression("cint(1.2345678)");
    Assert.assertTrue(exp.isInt());
    Assert.assertEquals( 1, exp.toIntValue());
 
    exp = EncogProgram.parseExpression("cstr(1.2345678)");
    Assert.assertTrue(exp.isString());
    Assert.assertEquals( "1.2345678", exp.toStringValue());
   
    exp = EncogProgram.parseExpression("cfloat(\"1.2345678\")");
    Assert.assertTrue(exp.isFloat());
    Assert.assertEquals( "1.2345678", exp.toStringValue());
   
  }
View Full Code Here

          "Variable "
              + mapping.getName()
              + " already defined, simply set its value, do not redefine.");
    } else {
      this.varMap.put(mapping.getName(), this.variables.size());
      this.variables.add(new ExpressionValue(mapping.getVariableType()));
    }
  }
View Full Code Here

   *            The index.
   * @param value
   *            The value.
   */
  public void setVariable(final int index, final double value) {
    this.variables.set(index, new ExpressionValue(value));

  }
View Full Code Here

   *            The name.
   * @param d
   *            The value.
   */
  public void setVariable(final String name, final double d) {
    setVariable(name, new ExpressionValue(d));
  }
View Full Code Here

    this.data = new ExpressionValue[theTemplate.getDataSize()];
    this.template = theTemplate;
    addChildNodes(theArgs);

    for (int i = 0; i < this.data.length; i++) {
      this.data[i] = new ExpressionValue(0);
    }
  }
View Full Code Here

    final ProgramNode result = targetProgram.getContext().getFunctions()
        .factorProgramNode(name, targetProgram, args);

    // now copy the expression data for the node
    for (int i = 0; i < sourceBranch.getData().length; i++) {
      result.getData()[i] = new ExpressionValue(sourceBranch.getData()[i]);
    }

    // return the new node
    return result;
  }
View Full Code Here

    ProgramNode v = this.holder.getFunctions().factorProgramNode("#const",
        holder, new ProgramNode[] {});

    if (isFloat) {
      v.getData()[0] = new ExpressionValue(value);
    } else {
      v.getData()[0] = new ExpressionValue((int) value);
    }

    outputQueue(v);
  }
View Full Code Here

      if (neg) {
        throw new EACompileError("Invalid negative sign.");
      }
      ProgramNode v = this.holder.getFunctions().factorProgramNode("#const",
          holder, new ProgramNode[] {});
      v.getData()[0] = new ExpressionValue(true);
      outputQueue(v);
    } else if (varName.toString().equals("false")) {
      if (neg) {
        throw new EACompileError("Invalid negative sign.");
      }
      ProgramNode v = this.holder.getFunctions().factorProgramNode("#const",
          holder, new ProgramNode[] {});
      v.getData()[0] = new ExpressionValue(false);
      outputQueue(v);
    } else if (this.parser.peek() != '(') {
      ProgramNode v;
      // either a variable or a const, see which
      if (this.holder.getFunctions().isDefined(varName.toString(), 0)) {
        v = this.holder.getFunctions().factorProgramNode(
            varName.toString(), holder, new ProgramNode[] {});
      } else {
        this.holder.getVariables().setVariable(varName.toString(),
            new ExpressionValue(0));
        v = this.holder.getFunctions().factorProgramNode("#var", holder,
            new ProgramNode[] {});
        v.getData()[0] = new ExpressionValue((int) this.holder.getVariables()
            .getVariableIndex(varName.toString()));
      }

      if (neg) {
        v = this.holder.getFunctions().factorProgramNode("-", holder,
View Full Code Here

      throw (new EACompileError("Unterminated string"));
    }

    ProgramNode v = this.holder.getFunctions().factorProgramNode("#const",
        holder, new ProgramNode[] {});
    v.getData()[0] = new ExpressionValue(str.toString());
    outputQueue(v);
  }
View Full Code Here

TOP

Related Classes of org.encog.ml.prg.expvalue.ExpressionValue

Copyright © 2018 www.massapicom. 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.