예제 #1
0
파일: Complex.java 프로젝트: HMC-TI/3daudio
  // sample client for testing
  public static void main(String[] args) {
    Complex a = new Complex(5.0, 6.0);
    Complex b = new Complex(-3.0, 4.0);

    System.out.println("a            = " + a);
    System.out.println("b            = " + b);
    System.out.println("Re(a)        = " + a.re());
    System.out.println("Im(a)        = " + a.im());
    System.out.println("b + a        = " + b.plus(a));
    System.out.println("a - b        = " + a.minus(b));
    System.out.println("a * b        = " + a.times(b));
    System.out.println("b * a        = " + b.times(a));
    System.out.println("a / b        = " + a.divides(b));
    System.out.println("(a / b) * b  = " + a.divides(b).times(b));
    System.out.println("conj(a)      = " + a.conjugate());
    System.out.println("|a|          = " + a.abs());
    System.out.println("tan(a)       = " + a.tan());
  }
예제 #2
0
 public void testConjugateInfiinite() {
   Complex z = new Complex(0, inf);
   assertEquals(neginf, z.conjugate().getImaginary(), 0);
   z = new Complex(0, neginf);
   assertEquals(inf, z.conjugate().getImaginary(), 0);
 }
예제 #3
0
 public void testConjugate() {
   Complex x = new Complex(3.0, 4.0);
   Complex z = x.conjugate();
   assertEquals(3.0, z.getReal(), 1.0e-5);
   assertEquals(-4.0, z.getImaginary(), 1.0e-5);
 }