@Before public void setUp() { this.a = new SymbolicInteger("a"); this.b = new SymbolicInteger("b"); this.x = new SymbolicReal("x"); this.y = new SymbolicReal("y"); this.space = RealVectorSpace.forDimensions(a, b, x, y); }
@Test public void evaluatorShouldUseAssignmentForRealVariables() { RealVector p = space.makeVector().set(x, 2.89).build(); assertThat(evaluate(x, p).doubleValue(), equalTo(2.89)); }
@Test public void evaluatorShouldUseAssignmentForIntegerVariables() { RealVector p = space.makeVector().set(a, 42).build(); assertThat(evaluate(a, p).intValue(), equalTo(42)); }
@Test public void evaluatorShouldUseRealConstants() { RealVector p = space.makeVector().build(); assertThat(evaluate(new RealConstant(3.14), p).doubleValue(), equalTo(3.14)); }
@Test public void evaluatorShouldUseIntegerConstants() { RealVector p = space.makeVector().build(); assertThat(evaluate(new IntegerConstant(23), p).intValue(), equalTo(23)); }
private RealVector realPoint(double xVal, double yVal) { return space.makeVector().set(x, xVal).set(y, yVal).build(); }
private RealVector intPoint(int aVal, int bVal) { return space.makeVector().set(a, aVal).set(b, bVal).build(); }