Methods Summary |
---|
public Complex | add(Complex other)Add another Complex to this one
return add(this, other);
|
public static Complex | add(Complex c1, Complex c2)Add two Complexs
return new Complex(c1.r+c2.r, c1.i+c2.i);
|
public double | getImaginary()Return just the Real part
return i;
|
public double | getReal()Return just the Real part
return r;
|
public double | magnitude()Return the magnitude of a complex number
return Math.sqrt(r*r + i*i);
|
public Complex | multiply(Complex other)Multiply this Complex times another one
return multiply(this, other);
|
public static Complex | multiply(Complex c1, Complex c2)Multiply two Complexs
return new Complex(c1.r*c2.r - c1.i*c2.i, c1.r*c2.i + c1.i*c2.r);
|
public Complex | subtract(Complex other)Subtract another Complex from this one
return subtract(this, other);
|
public static Complex | subtract(Complex c1, Complex c2)Subtract two Complexs
return new Complex(c1.r-c2.r, c1.i-c2.i);
|
public java.lang.String | toString()Display the current Complex as a String, for use in
println() and elsewhere.
StringBuffer sb = new StringBuffer().append(r);
if (i>0)
sb.append('+"); // else append(i) appends - sign
return sb.append(i).append('i").toString();
|