/**
* Test divide.
*/
public void testDivide() {
ComplexArray1D a =
new ComplexArray1D(new Complex[] { new Complex(1, 2),
new Complex(3, 4), new Complex(5, 6) });
// initial tests ... we can't have too many of them :)
assertTrue(a.getComplex(0).equals(new Complex(1, 2)));
assertTrue(a.getComplex(1).equals(new Complex(3, 4)));
assertTrue(a.getComplex(2).equals(new Complex(5, 6)));
// testing divide(int, int, int)
a.divide(0, 1, 2);
assertTrue(a.getComplex(0).equals(new Complex(39.0 / 61, 2.0 / 61)));
assertTrue(a.getComplex(1).equals(new Complex(3, 4)));
assertTrue(a.getComplex(2).equals(new Complex(5, 6)));
// testing divide(int, int, double, double)
a.divide(0, 1, 1.5, -4.75);
assertTrue(a.getComplex(0).equals(new Complex(-232d / 397, 324d / 397)));
assertTrue(a.getComplex(1).equals(new Complex(3, 4)));
assertTrue(a.getComplex(2).equals(new Complex(5, 6)));
// testing divide(int, double, double, double, double)
a.divide(2, 4.0, 2.0, -1.0, -8.0);
assertTrue(a.getComplex(0).equals(new Complex(-232d / 397, 324d / 397)));
assertTrue(a.getComplex(1).equals(new Complex(3, 4)));
assertTrue(a.getComplex(2).equals(new Complex(-4d / 13, 6d / 13)));
// testing divide(int, double, double, int)
a.divide(1, 1.0, 1.0, 2);
assertTrue(a.getComplex(0).equals(new Complex(-232d / 397, 324d / 397)));
System.out.println(a.getComplex(1));
assertTrue(a.getComplex(1).equals(new Complex(1d / 2, -5d / 2)));
assertTrue(a.getComplex(2).equals(new Complex(-4d / 13, 6d / 13)));
}