@Test public void testSimpleDifferentiation() { String[] params = new String[] {"A"}; ParametrisedPolynomial simplePoly = new ParametrisedPolynomial(params); ParametrisedPolynomial diffedPoly = simplePoly.differentiate(); Double[][] paramMatrix = diffedPoly.getParamMatrix(); assertEquals(new Double(0.0), paramMatrix[0][0]); }
@Test public void testBiggerDifferentiation() { String[] params = new String[] {"A", "B", "C"}; ParametrisedPolynomial simplePoly = new ParametrisedPolynomial(params); ParametrisedPolynomial diffedPoly = simplePoly.differentiate(); Double[][] paramMatrix = diffedPoly.getParamMatrix(); assertEquals(new Double(2.0), paramMatrix[1][0]); // 2*A*x assertEquals(new Double(1.0), paramMatrix[2][1]); // B }
@Test public void testGetParamMatrix() { String[] params = new String[] {"A"}; ParametrisedPolynomial simplePoly = new ParametrisedPolynomial(params); Double[][] paramMatrix = simplePoly.getParamMatrix(); assertTrue(paramMatrix[0][0] == 1.0); assertTrue(paramMatrix.length == 1); assertTrue(paramMatrix[0].length == 1); String[] params2 = new String[] {"A", "B"}; ParametrisedPolynomial poly = new ParametrisedPolynomial(params2); Double[][] paramMatrix2 = poly.getParamMatrix(); assertTrue(paramMatrix2[0][0] == 1.0); assertTrue(paramMatrix2[0][1] == 0.0); assertTrue(paramMatrix2[1][0] == 0.0); assertTrue(paramMatrix2[1][1] == 1.0); assertTrue(paramMatrix2.length == 2); assertTrue(paramMatrix2[0].length == 2); }