Package ca.nengo.math

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


    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(0f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(1f, f.map(new float[]{0f}), .00001f);
    TestUtil.assertClose(2f, f.map(new float[]{0f}), .00001f);
  }
}
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]);
      }
    }
   
    GradientDescentApproximator.Constraints constraints = new GradientDescentApproximator.Constraints() {
      private static final long serialVersionUID = 1L;
View Full Code Here

          float[] args = new float[f.getDimension()];
          for (int dim = args.length-1; dim >= 0; dim--) {
            args[dim] = ((Float) stack.pop()).floatValue();
          }

          stack.push(new Float(f.map(args)));
        }
      }

      result = ((Float) stack.pop()).floatValue();
View Full Code Here

    } catch (RuntimeException e) { // failure after too many attempts
    }
   
    func = new FourierFunction(new float[]{1, 0.5f, 1}, new float[]{1, 1, 0.5f}, new float[]{0, -0.5f, 0.2f});
    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
    func = new IdentityFunction(1, 0);
    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
View Full Code Here

    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
    func = new IdentityFunction(1, 0);
    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
    func = new PiecewiseConstantFunction(new float[]{-1,1}, new float[]{2,0,-2});
    try {
      root = nrf.findRoot(func, -5, 15, 0.0001f);
    } catch (RuntimeException e) { // failure after too many attempts
View Full Code Here

    } catch (RuntimeException e) { // failure after too many attempts
    }
   
    func = new Polynomial(new float[]{4f, 2f, -3f, 1f});
    root = nrf.findRoot(func, -5, 15, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
    func = new SigmoidFunction(-1f, 0.3f, -0.5f, 1f);
    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
View Full Code Here

    root = nrf.findRoot(func, -5, 15, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
    func = new SigmoidFunction(-1f, 0.3f, -0.5f, 1f);
    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
    func = new SineFunction(0.5f);
    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
  }
View Full Code Here

    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
   
    func = new SineFunction(0.5f);
    root = nrf.findRoot(func, -5, 5, 0.0001f);
    TestUtil.assertClose(func.map(new float[]{root}), 0, 0.001f);
  }
}
View Full Code Here

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

    f = interpreter.parse("x0 - x1", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
    assertEquals("-", l.get(2).toString());
    TestUtil.assertClose(0f, f.map(new float[]{1f, 1f}), tolerance);
   
    f = interpreter.parse("x0 * x1", 2);
    l = ((PostfixFunction) f).getExpressionList();
    assertEquals(Integer.valueOf(0), l.get(0));
    assertEquals(Integer.valueOf(1), l.get(1));
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.