Package ca.nengo.math

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


    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
    assertEquals(Integer.valueOf(2), l.get(2));
    assertEquals("*", l.get(3).toString());
    assertEquals("+", l.get(4).toString());
    TestUtil.assertClose(7f, f.map(new float[]{1f, 2f, 3f}), tolerance);
   
    f = interpreter.parse("x0 + x1 * -x2", 3);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
View Full Code Here


    assertEquals(Integer.valueOf(1), l.get(1));
    assertEquals(Integer.valueOf(2), l.get(2));
    assertEquals("~", l.get(3).toString());
    assertEquals("*", l.get(4).toString());
    assertEquals("+", l.get(5).toString());
    TestUtil.assertClose(-5f, f.map(new float[]{1f, 2f, 3f}), tolerance);
   
    f = interpreter.parse("x0 * x1 ^ x2", 3);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
View Full Code Here

    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
    assertEquals(Integer.valueOf(2), l.get(2));
    assertEquals("^", l.get(3).toString());
    assertEquals("*", l.get(4).toString());
    TestUtil.assertClose(8f, f.map(new float[]{1f, 2f, 3f}), tolerance);
   
    f = interpreter.parse("x0 * x1 ^ x2 & x3", 4);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
View Full Code Here

    assertEquals(Integer.valueOf(2), l.get(2));
    assertEquals("^", l.get(3).toString());
    assertEquals("*", l.get(4).toString());
    assertEquals(Integer.valueOf(3), l.get(5));
    assertEquals("&", l.get(6).toString());
    TestUtil.assertClose(1f, f.map(new float[]{1f, 2f, 3f, 1f}), tolerance);
   
    //brackets ...
    f = interpreter.parse("x0 * (x1 + x2)", 3);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
View Full Code Here

    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
    assertEquals(Integer.valueOf(2), l.get(2));
    assertEquals("+", l.get(3).toString());
    assertEquals("*", l.get(4).toString());
    TestUtil.assertClose(5f, f.map(new float[]{1f, 2f, 3f}), tolerance);
   
    f = interpreter.parse("(x0 * x1) ^ (x2 & x3)", 4);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
View Full Code Here

    assertEquals("*", l.get(2).toString());
    assertEquals(Integer.valueOf(2), l.get(3));
    assertEquals(Integer.valueOf(3), l.get(4));
    assertEquals("&", l.get(5).toString());
    assertEquals("^", l.get(6).toString());
    TestUtil.assertClose(2f, f.map(new float[]{1f, 2f, 3f, 4f}), tolerance);
   
    f = interpreter.parse("x0 ^ (x1 * (x2 + x3))", 4);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
View Full Code Here

    assertEquals(Integer.valueOf(2), l.get(2));
    assertEquals(Integer.valueOf(3), l.get(3));
    assertEquals("+", l.get(4).toString());
    assertEquals("*", l.get(5).toString());
    assertEquals("^", l.get(6).toString());
    TestUtil.assertClose(16384f, f.map(new float[]{2f, 2f, 3f, 4f}), tolerance);
   
    //functions ...
    f = interpreter.parse("x0 + sin(x1)", 4);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
View Full Code Here

    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
    assertTrue(l.get(2) instanceof SimpleFunctions.Sin);
    assertEquals("+", l.get(3).toString());
    TestUtil.assertClose(2f, f.map(new float[]{2f, (float) Math.PI, 1f, 1f}), tolerance);
   
    f = interpreter.parse("x0 + sin(x1 + x2)", 4);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
View Full Code Here

    assertEquals(Integer.valueOf(1), l.get(1));
    assertEquals(Integer.valueOf(2), l.get(2));
    assertEquals("+", l.get(3).toString());
    assertTrue(l.get(4) instanceof SimpleFunctions.Sin);
    assertEquals("+", l.get(5).toString());
    TestUtil.assertClose(2f, f.map(new float[]{2f, (float) Math.PI / 2f, (float) Math.PI / 2f, 1f}), tolerance);
   
    //constants ...
    f = interpreter.parse("1.1", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertTrue(l.get(0) instanceof Float);
View Full Code Here

    //constants ...
    f = interpreter.parse("1.1", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertTrue(l.get(0) instanceof Float);
    TestUtil.assertClose(1.1f, ((Float) l.get(0)).floatValue(), .0001f);
    TestUtil.assertClose(1.1f, 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

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.