Package ca.nengo.math

Examples of ca.nengo.math.Function.map()


    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
    TestUtil.assertClose(5f, ((Float) l.get(1)).floatValue(), .0001f);
    assertEquals("+", l.get(2).toString());
    TestUtil.assertClose(6f, f.map(new float[]{1f, 1f}), tolerance);
   
    f = interpreter.parse("x0 + 1.5", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
View Full Code Here


    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
    TestUtil.assertClose(1.5f, ((Float) l.get(1)).floatValue(), .0001f);
    assertEquals("+", l.get(2).toString());
    TestUtil.assertClose(2.5f, f.map(new float[]{1f, 1f}), tolerance);
   
    f = interpreter.parse("x0 + 0.5", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
View Full Code Here

    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
    TestUtil.assertClose(0.5f, ((Float) l.get(1)).floatValue(), .0001f);
    assertEquals("+", l.get(2).toString());
    TestUtil.assertClose(1.5f, f.map(new float[]{1f, 1f}), tolerance);
   
    f = interpreter.parse("x0 + .5", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
View Full Code Here

    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
    TestUtil.assertClose(0.5f, ((Float) l.get(1)).floatValue(), .0001f);
    assertEquals("+", l.get(2).toString());
    TestUtil.assertClose(1.5f, f.map(new float[]{1f, 1f}), tolerance);
   
    f = interpreter.parse("x0 + pi", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
View Full Code Here

    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertTrue(l.get(1) instanceof Float);
    TestUtil.assertClose((float) Math.PI, ((Float) l.get(1)).floatValue(), .0001f);
    assertEquals("+", l.get(2).toString());
    TestUtil.assertClose(1f + (float) Math.PI, f.map(new float[]{1f, 1f}), tolerance);

    //dimension ...
    f = interpreter.parse("x0", 5);
    assertEquals(5, f.getDimension());
View Full Code Here

    assertEquals(Integer.valueOf(3), l.get(9));
    assertEquals("^", l.get(10).toString());
    assertTrue(l.get(11) instanceof SimpleFunctions.Sin);   
    assertEquals("/", l.get(12).toString());
    assertEquals("+", l.get(13).toString());
    TestUtil.assertClose(2f * (float) Math.PI - 1 / .13235175f, f.map(new float[]{2f, 2f, 3f, 2f}), tolerance);
   
  }

}
View Full Code Here

        new float[]{0.0f, 0.5f, 1.0f}, Units.UNK);
    Function f = new TimeSeriesFunction(ts , 0);
//    FunctionInput input = new FunctionInput("input", new Function[]{f}, Units.UNK);

    //now for a little test
    TestUtil.assertClose(.2f, f.map(new float[]{.2f}), .00001f);
  }

    //functional test
    public static void main(String[] args) {
        Function f = new SineFunction(10);
View Full Code Here

    float[][] values = new float[frequencies.length][];
    for (int i = 0; i < frequencies.length; i++) {
      Function component = new FourierFunction(new float[]{frequencies[i]}, new float[]{1}, new float[]{phases[i]});
      values[i] = new float[evalPoints.length];
      for (int j = 0; j < evalPoints.length; j++) {
        values[i][j] = component.map(evalPoints[j]);
      }
    }
   
    WeightedCostApproximator.Factory factory = new WeightedCostApproximator.Factory(0f);
    LinearApproximator approximator = factory.getApproximator(evalPoints, values);
View Full Code Here

    float[][][] valuesig = new float[frequencies.length][1][];
    for (int i = 0; i < frequencies.length; i++) {
      Function component = new FourierFunction(new float[]{frequencies[i]}, new float[]{1}, new float[]{phases[i]});
      valuesig[i][0] = new float[times.length];
      for (int j = 0; j < times.length; j++) {
        valuesig[i][0][j] = component.map(new float[]{times[j]});
      }
    }
    float[][][] evalsigs = new float[1][1][];
    evalsigs[0][0] = times;
    factory = new WeightedCostApproximator.Factory(0f);
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.