Package de.das.encrypter.fourier
Class Complex
java.lang.Object
de.das.encrypter.fourier.Complex
Class to represent complex numbers.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ComplexAdds two given complex numbers.static ComplexDivides a given complex number by a real value.static doubleCalculates and returns the absolute value of a given complex number.static ComplexMultiplies two given complex numbers.static ComplexSubtracts a given complex numbers from anther given complex number.
-
Field Details
-
re
public double re -
im
public double im
-
-
Constructor Details
-
Complex
public Complex(double re, double im) Creates an instance of a complex number.- Parameters:
re- the real part of the complex number.im- the imaginary part of the complex number.
-
-
Method Details
-
add
Adds two given complex numbers.- Parameters:
z1- the complex number one.z2- the complex number two.- Returns:
- the sum of the given complex numbers.
-
subtract
Subtracts a given complex numbers from anther given complex number.- Parameters:
z1- the complex number one.z2- the complex number two.- Returns:
- the difference of z2 subtracted from z1.
-
multiply
Multiplies two given complex numbers.- Parameters:
z1- the complex number one.z2- the complex number two.- Returns:
- the product of the given complex numbers.
-
divideR
Divides a given complex number by a real value.- Parameters:
z- a complex number.r- a real value.- Returns:
- the quotient of z1 divided by z2.
-
magnitude
Calculates and returns the absolute value of a given complex number.- Parameters:
z- a given complex number.- Returns:
- the magnitude of a given complex number.
-