@Test public void testMultiplyBySingularPolynomial() { // Test singular case - multiplying by 1 Polynomial simplePoly = Polynomial.getSingularPolynomial(); String[] params = new String[] {"A", "B"}; // Ax^2 + Bx + C ParametrisedPolynomial paramPoly1 = new ParametrisedPolynomial(params); ParametrisedPolynomial resultPoly1 = paramPoly1.multiplyByPolynomial(simplePoly); assertArrayEquals(new Double[] {1.0, 0.0}, resultPoly1.getParamValuesForDegreeAsArray(1)); assertArrayEquals(new Double[] {0.0, 1.0}, resultPoly1.getParamValuesForDegreeAsArray(0)); }
@Test public void testMultiplyBySingleArgumentBinomial() { // Let's multiply by x Polynomial poly = Polynomial.getSingleArgumentPolynomialOfDegree(1); String[] params = new String[] {"A", "B"}; // Ax^2 + Bx + C ParametrisedPolynomial paramPoly1 = new ParametrisedPolynomial(params); ParametrisedPolynomial resultPoly1 = paramPoly1.multiplyByPolynomial(poly); assertArrayEquals(new Double[] {1.0, 0.0}, resultPoly1.getParamValuesForDegreeAsArray(2)); assertArrayEquals(new Double[] {0.0, 1.0}, resultPoly1.getParamValuesForDegreeAsArray(1)); assertArrayEquals(new Double[] {0.0, 0.0}, resultPoly1.getParamValuesForDegreeAsArray(0)); }