Package ca.nengo.math.impl

Examples of ca.nengo.math.impl.PostfixFunction


    public ConfigSchema getSchema() {
        String expression = null;
        int dim = myInputDimensions;

        PostfixFunction function = getFunction();

        if (function != null) {
            expression = function.getExpression();

            if (isInputDimEditable) {
                dim = function.getDimension();
            }
        }

        pExpression = new PString(EXPRESSION_STR, EXPRESSION_DESC, expression);
        pDimensions = new PInt(DIMENSION_STR, DIMENSION_DESC, dim);
View Full Code Here


      Network network = new NetworkImpl();
     
      //this "function input" is Probeable ...    
      Function[] funcs = new Function[2];
      for(int i=0; i<funcs.length; ++i) {
        funcs[i] = new PostfixFunction("sin(x0)^"+(i+1), 1);
      }
      String name = "functions of time";
      FunctionInput fi = new FunctionInput(name, funcs, Units.uAcm2);
      network.addNode(fi);
     
View Full Code Here

  /*
   * Test method for 'ca.nengo.math.impl.PostfixFunction.getDimension()'
   */
  public void testGetDimension() {
    int dim = 10;
    PostfixFunction f = new PostfixFunction(new ArrayList<Serializable>(), "", dim);
    assertEquals(dim, f.getDimension());
  }
View Full Code Here

   * Test method for 'ca.nengo.math.impl.PostfixFunction.map(float[])'
   */
  public void testMap() {

    //some basic tests follow, and a more exhaustive list is included in DefaultFunctionInterpreterTest
    PostfixFunction f = null;
   
    ArrayList<Serializable> l = new ArrayList<Serializable>();
    l.add(new Float(5.5f));
    f = new PostfixFunction(l, "", 0);
    TestUtil.assertClose(5.5f, f.map(new float[0]), .0001f);

    l.clear();
    l.add(Integer.valueOf(0));
    f = new PostfixFunction(l, "", 1);
    TestUtil.assertClose(1f, f.map(new float[]{1f}), .0001f);

    l.clear();
    l.add(Integer.valueOf(0));
    l.add(new SineFunction(1));
    f = new PostfixFunction(l, "", 1);
    TestUtil.assertClose(0f, f.map(new float[]{(float) Math.PI}), .0001f);
  }
View Full Code Here

   * Test method for 'ca.nengo.math.impl.PostfixFunction.multiMap(float[][])'
   */
  public void testMultiMap() {
    ArrayList<Serializable> l = new ArrayList<Serializable>();
    l.add(Integer.valueOf(0));
    PostfixFunction f = new PostfixFunction(l, "", 1);
    float[] values = f.multiMap(new float[][]{new float[]{1f}, new float[]{2f}});
    TestUtil.assertClose(1f, values[0], .0001f);
    TestUtil.assertClose(2f, values[1], .0001f);
  }
View Full Code Here

    TestUtil.assertClose(1f, values[0], .0001f);
    TestUtil.assertClose(2f, values[1], .0001f);
  }
 
  public void testClone() throws CloneNotSupportedException {
    PostfixFunction f1 = new PostfixFunction("x0 + x1^2", 2);
    PostfixFunction f2 = (PostfixFunction) f1.clone();
    f2.setExpression("x1");
    assertEquals("x0 + x1^2", f1.getExpression());
    assertTrue(f1.map(new float[]{0, 2}) - f2.map(new float[]{0, 2}) > 1);
  }
View Full Code Here

      for(Function f: fns)
      {
        String exp;
        if(f instanceof PostfixFunction)
        {
          PostfixFunction pf = (PostfixFunction) f;
          exp = pf.getExpression();
         
          exp=exp.replaceAll("\\^","**");
          exp=exp.replaceAll("!"," not ");
          exp=exp.replaceAll("&"," and ");
          exp=exp.replaceAll("\\|"," or ");
View Full Code Here

   */
  public void testGetOutput() throws StructuralException {
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = ef.make("test", 70, new float[]{1, 1, 1});
    DecodedOrigin origin = (DecodedOrigin) ensemble.addDecodedOrigin("test",
        new Function[]{new PostfixFunction("x1", 3), new PostfixFunction("x2", 3)}, Neuron.AXON);
   
    float[][] input = MU.uniform(500, 3, 1);
    float[][] directOutput = NEFUtil.getOutput(origin, input, SimulationMode.DIRECT);
    float[][] constantOutput = NEFUtil.getOutput(origin, input, SimulationMode.CONSTANT_RATE);
    float[][] defaultOutput = NEFUtil.getOutput(origin, input, SimulationMode.DEFAULT);   
View Full Code Here

   */
  public void testRegisterFunction() {
    Function c = new ConstantFunction(2, 1f);
    DefaultFunctionInterpreter interpreter = new DefaultFunctionInterpreter();
    interpreter.registerFunction("const", c);
    PostfixFunction f = (PostfixFunction) interpreter.parse("const(x0, x1)", 2);
    List<Serializable> l = f.getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
    assertEquals(c, l.get(2));
   
    try {
View Full Code Here

                                func.getFundamental(),
                                func.getCutoff(),
                                func.getRms(),
                                func.getSeed()));
                } else if (myFunctions[i] instanceof PostfixFunction) {
                    PostfixFunction func = (PostfixFunction)myFunctions[i];

                    py.append(String.format("%s = PostfixFunction('%s', %d)\n",
                          functionName,
                                func.getExpression(),
                                func.getDimension()));
                }

                funcs.append(functionName);
               
                if ((i + 1) < myFunctions.length) {
View Full Code Here

TOP

Related Classes of ca.nengo.math.impl.PostfixFunction

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.