Beispiel #1
0
 public static ComplexNumber multiply(ComplexNumber a, ComplexNumber b)
 {
     return(new ComplexNumber(a.real * b.real - a.imaginary * b.imaginary, a.real * b.imaginary + a.imaginary * b.real));
 }
Beispiel #2
0
 public static ComplexNumber divide(ComplexNumber a, ComplexNumber b)
 {
     return(divideWithReal(multiply(a, conjugate(b)), module(b)));
 }
Beispiel #3
0
 public static ComplexNumber substract(ComplexNumber a, ComplexNumber b)
 {
     return(new ComplexNumber(a.real - b.real, a.imaginary - b.imaginary));
 }
Beispiel #4
0
 public static ComplexNumber add(ComplexNumber a, ComplexNumber b)
 {
     return(new ComplexNumber(a.real + b.real, a.imaginary + b.imaginary));
 }
Beispiel #5
0
 public static ComplexNumber divideWithReal(ComplexNumber a, double ratio)
 {
     return(new ComplexNumber(a.real / ratio, a.imaginary / ratio));
 }
Beispiel #6
0
 public static ComplexNumber conjugate(ComplexNumber a)
 {
     return(new ComplexNumber(a.real, -a.imaginary));
 }
Beispiel #7
0
 public static double module(ComplexNumber a)
 {
     return(Math.Sqrt(a.real * a.real + a.imaginary * a.imaginary));
 }