|
|
@@ -1,4 +1,4 @@ |
|
|
|
package com.example.ueberwachungssystem.Signalverarbeitung; |
|
|
|
package com.example.ueberwachungssystem.Detector.Signalverarbeitung; |
|
|
|
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
@@ -12,7 +12,7 @@ public class Complex { |
|
|
|
im = imag; |
|
|
|
} |
|
|
|
|
|
|
|
// return a string representation of the invoking com.example.ueberwachungssystem.Signalverarbeitung.Complex object |
|
|
|
// return a string representation of the invoking com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object |
|
|
|
public String toString() { |
|
|
|
if (im == 0) return re + ""; |
|
|
|
if (re == 0) return im + "i"; |
|
|
@@ -30,7 +30,7 @@ public class Complex { |
|
|
|
return Math.atan2(im, re); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is (this + b) |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this + b) |
|
|
|
public Complex plus(Complex b) { |
|
|
|
Complex a = this; // invoking object |
|
|
|
double real = a.re + b.re; |
|
|
@@ -38,7 +38,7 @@ public class Complex { |
|
|
|
return new Complex(real, imag); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is (this - b) |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this - b) |
|
|
|
public Complex minus(Complex b) { |
|
|
|
Complex a = this; |
|
|
|
double real = a.re - b.re; |
|
|
@@ -46,7 +46,7 @@ public class Complex { |
|
|
|
return new Complex(real, imag); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is (this * b) |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is (this * b) |
|
|
|
public Complex times(Complex b) { |
|
|
|
Complex a = this; |
|
|
|
double real = a.re * b.re - a.im * b.im; |
|
|
@@ -59,12 +59,12 @@ public class Complex { |
|
|
|
return new Complex(alpha * re, alpha * im); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the conjugate of this |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the conjugate of this |
|
|
|
public Complex conjugate() { |
|
|
|
return new Complex(re, -im); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the reciprocal of this |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the reciprocal of this |
|
|
|
public Complex reciprocal() { |
|
|
|
double scale = re * re + im * im; |
|
|
|
return new Complex(re / scale, -im / scale); |
|
|
@@ -85,22 +85,22 @@ public class Complex { |
|
|
|
return a.times(b.reciprocal()); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex exponential of this |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex exponential of this |
|
|
|
public Complex exp() { |
|
|
|
return new Complex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im)); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex sine of this |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex sine of this |
|
|
|
public Complex sin() { |
|
|
|
return new Complex(Math.sin(re) * Math.cosh(im), Math.cos(re) * Math.sinh(im)); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex cosine of this |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex cosine of this |
|
|
|
public Complex cos() { |
|
|
|
return new Complex(Math.cos(re) * Math.cosh(im), -Math.sin(re) * Math.sinh(im)); |
|
|
|
} |
|
|
|
|
|
|
|
// return a new com.example.ueberwachungssystem.Signalverarbeitung.Complex object whose value is the complex tangent of this |
|
|
|
// return a new com.example.ueberwachungssystem.Detector.Signalverarbeitung.Complex object whose value is the complex tangent of this |
|
|
|
public Complex tan() { |
|
|
|
return sin().divides(cos()); |
|
|
|
} |