Constructors
|
public Complex()
|
|
public Complex(double real, double imag)
|
|
public Complex(double real)
|
|
public Complex(Complex c)
|
|
Set Values
|
public void setReal(double real)
|
|
public void setImag(double imag)
|
|
public void reset(double real, double imag)
|
|
public void polar(double mod, double argRad)
|
|
public void polarRad(double mod, double argRad)
|
|
public void polarDeg(double mod, double argDeg)
|
|
Get Values
|
public double getReal()
|
|
public double getImag()
|
|
public int hashCode()
|
|
Input and Output
|
|
public static Complex readComplex(String prompt, String default)
|
|
public static Complex readComplex(String prompt)
|
|
public static Complex readComplex()
|
public void print(String message)
|
|
public void print()
|
|
public void println(String message)
|
|
public void println()
|
|
|
public static void println(String message, Complex cc[])
|
|
public static void println(Complex cc[])
|
|
public static void print(String message, Complex cc[])
|
|
public static void print(Complex cc[])
|
|
public static void setj()
|
|
public static void seti()
|
|
public static char getjori()
|
Truncate mantissae to n places
|
public Complex truncate(int n)
|
public static Complex truncate(Complex x, int n)
|
Swap two complex numbers
|
|
public static Complex swap(Complex aa, Complex bb)
|
Conversions
|
|
public static Complex parseComplex(String ss)
|
|
public static Complex valueOf(String ss)
|
public String toString()
|
public static String toString(Complex aa)
|
public int hashCode()
|
|
Modulus
|
public double abs()
|
public static double abs(Complex a)
|
public double squareAbs()
|
public static double squareAbs(Complex a)
|
Argument
|
public double arg()
|
public static double arg(Complex a)
|
public double argRad()
|
public static double argRad(Complex a)
|
public double argDeg()
|
public static double argDeg(Complex a)
|
Conjugate
|
public Complex conjugate()
|
public static Complex conjugate(Complex a)
|
Addition
|
public Complex plus(Complex a)
|
public static Complex plus(Complex a, Complex b)
|
public Complex plus(double a)
|
public static Complex plus(Complex a, double b)
|
|
public static Complex plus(double a, Complex b)
|
|
public static Complex plus(double a, double b)
|
public void plusEquals(Complex a )
|
|
public void plusEquals(double a )
|
|
Subtraction
|
public Complex minus(Complex a)
|
public static Complex minus(Complex a, Complex b)
|
public Complex minus(double a)
|
public static Complex minus(Complex a, double b)
|
public Complex transposedMinus(double a)
|
public static Complex minus(double a, Complex b)
|
|
public static Complex minus(double a, double b)
|
public void minusEquals(Complex a )
|
|
public void minusEquals(double a )
|
|
Infinity Handling Option for multiplication and division
|
|
public static void setInfOption(boolean opt)
|
|
public static void setInfOption(int opt)
|
|
public static boolean getInfOption()
|
Multiplication
|
public Complex times(Complex a)
|
public static Complex times(Complex a, Complex b)
|
public Complex times(double a)
|
public static Complex times(Complex a, double b)
|
|
public static Complex times(double a, Complex b)
|
|
public static Complex times(double a, double b)
|
public void timesEquals(Complex a )
|
|
public void timesEquals(double a )
|
|
Division
|
public Complex over(Complex a)
|
public static Complex over(Complex a, Complex b)
|
public Complex over(double a)
|
public static Complex over(Complex a, double b)
|
public Complex transposedOver(double a)
|
public static Complex over(double a, Complex b)
|
|
public static Complex over(double a, double b)
|
public void overEquals(Complex a )
|
|
public void overEquals(double a )
|
|
Reciprocal
|
public Complex inverse()
|
public static Complex inverse(Complex a)
|
Negation
|
public Complex negate()
|
public static Complex negate(Complex a)
|
Exponential
|
public Complex exp()
|
public static Complex exp(Complex aa)
|
|
public static Complex exp(double aa)
|
|
public static Complex expPlusJayArg(double arg)
|
|
public static Complex expMinusJayArg(double arg)
|
Logarithm
|
public Complex log()
| public static Complex log(Complex aa )
|
Root
|
public Complex sqrt()
|
public static Complex sqrt(Complex aa )
|
public Complex nthRoot(int n)
|
public static Complex nthRoot(Complex aa, int n
)
|
Power
|
public Complex square()
|
public static Complex square(Complex aa)
|
public Complex pow(int b)
|
public static Complex pow(Complex a, int b)
|
public Complex pow(double b)
|
public static Complex pow(Complex a, double b)
|
public Complex pow(Complex b)
|
public static Complex pow(Complex a, Complex b)
|
|
public static Complex pow(int a, Complex b)
|
|
public static Complex pow(double a, Complex b)
|
Trigonometric Functions
|
public Complex sin()
|
public static Complex sin(Complex aa )
|
public Complex asin()
|
public static Complex asin(Complex aa )
|
public Complex cos()
|
public static Complex cos(Complex aa )
|
public Complex acos()
|
public static Complex acos(Complex aa )
|
public Complex tan()
|
public static Complex tan(Complex aa )
|
public Complex atan()
|
public static Complex atan(Complex aa )
|
public Complex cot()
|
public static Complex cot(Complex aa )
|
public Complex acot()
|
public static Complex acot(Complex aa )
|
public Complex sec()
|
public static Complex sec(Complex aa )
|
public Complex asec()
|
public static Complex asec(Complex aa )
|
public Complex csc()
|
public static Complex csc(Complex aa )
|
public Complex acsc()
|
public static Complex acsc(Complex aa )
|
public Complex exsec()
|
public static Complex exsec(Complex aa )
|
public Complex aexsec()
|
public static Complex aexsec(Complex aa )
|
public Complex vers()
|
public static Complex vers(Complex aa )
|
public Complex avers()
|
public static Complex avers(Complex aa )
|
public Complex covers()
|
public static Complex covers(Complex aa )
|
public Complex acovers()
|
public static Complex acovers(Complex aa )
|
public Complex hav()
|
public static Complex hav(Complex aa )
|
public Complex ahav()
|
public static Complex ahav(Complex aa )
|
public Complex sinh()
|
public static Complex sinh(Complex aa )
|
public Complex asinh()
|
public static Complex asinh(Complex aa )
|
public Complex cosh()
|
public static Complex cosh(Complex aa )
|
public Complex acosh()
|
public static Complex acosh(Complex aa )
|
public Complex tanh()
|
public static Complex tanh(Complex aa )
|
public Complex atanh()
|
public static Complex atanh(Complex aa )
|
public Complex coth()
|
public static Complex coth(Complex aa )
|
public Complex acoth()
|
public static Complex acoth(Complex aa )
|
public Complex sech()
|
public static Complex sech(Complex aa )
|
public Complex asech()
|
public static Complex asech(Complex aa )
|
public Complex csch()
|
public static Complex csch(Complex aa )
|
public Complex acsch()
|
public static Complex acsch(Complex aa )
|
Hypotenuse
|
|
public static double hypot(Complex aa, Complex bb)
|
Logical Tests
|
public boolean equals(Complex x)
public boolean isEqual(Complex x)
|
public static boolean isEqual(Complex a, Complex b)
|
public boolean equalsWithinLimits(Complex x, double limit)
public boolean isEqualWithinLimits(Complex x, double limit)
|
public static boolean isEqualWithinLimits(Complex a, Complex b, double limit)
|
public boolean isReal()
|
public static boolean isReal(Complex a)
|
|
public static boolean isReal(Complex[ ] a)
|
public boolean isReal(double limit)
|
public static boolean isReal(Complex a, double limit)
|
|
public static boolean isRealPerCent(Complex[ ] a, double limit)
|
public boolean isRealPerCent(double percentage)
|
public static boolean isRealPerCent(Complex a, double percentage)
|
|
public static boolean isReal(Complex[ ] a, double percentage)
|
public boolean isZero()
|
public static boolean isZero(Complex a)
|
public boolean isInfinite()
|
public static boolean isInfinite(Complex a)
|
public boolean isPlusInfinity()
|
public static boolean isPlusInfinity(Complex a)
|
public boolean isMinusInfinity()
|
public static boolean isMinusInfinity(Complex a)
|
public boolean isNaN()
|
public static boolean isNaN(Complex a)
|
Arrays
see Input and Output
for printing complex arrays
|
|
public static Complex[] oneDarray(int n)
|
|
public static Complex[] oneDarray(int n, double a, double b)
|
|
public static Complex[] oneDarray(int n, Complex xx)
|
|
public static Complex mean(Complex[] xx)
|
|
public static Complex[][] twoDarray(int n, int m)
|
|
public static Complex[][] twoDarray(int n, int m, double a, double b)
|
|
public static Complex[][] twoDarray(int n, int m, Complex xx)
|
|
public static Complex[][][] threeDarray(int n, int m, int k)
|
|
public static Complex[][][] threeDarray(int n, int m, int k, double a, double b)
|
|
public static Complex[][][] threeDarray(int n, int m, int k, Complex xx)
|
Deep Copy
|
public Complex copy()
|
public static Complex copy(Complex a)
|
public Object clone()
|
|
|
public static Complex[] copy(Complex[] a)
|
|
public static Complex[][] copy(Complex[][] a)
|
|
public static Complex[][][] copy(Complex[][][] a)
|
Some Useful Numbers
|
|
public static Complex zero()
|
|
public static Complex plusOne()
|
|
public static Complex minusOne()
|
|
public static Complex plusJay()
|
|
public static Complex minusJay()
|
|
public static Complex pi()
|
|
public static Complex twoPiJay()
|
|
public static Complex plusInfinty()
|
|
public static Complex minusInfinty()
|
public static void setInfOption(boolean opt)
public static void setInfOption(int opt)
Usage:
Complex.setInfOpt(opt);
If the argument opt is set to true or to 0:
- a complex number, with both real and imaginary parts equal to Double.PLUS_INFINITY, will be returned when:
- any multiplication of two complex numbers occurs in which either number's real and/or imaginary part is equal to Infinity and if one of the numbers does not have both real and imaginary part equal to zero
- any multiplication of a complex number and a real number occurs in which either the real and/or imaginary part is equal to Infinity or the real number is equal to Infinity and if the complex number does not have both real and imaginary part equal to zero or the real number is not zero
- a complex number, with both real and imaginary parts equal to zero, will be returned when:
- any division of a complex number by a complex number occurs in which the divisor's real and/or imaginary part is equal to Infinity and if the dividend does not have a real and/or imaginary part equal to Infinity
- any division of a complex number by a real number occurs in which the divisor is equal to Infinity and if the dividend does not have a real and/or imaginary part equal to Infinity
- any division of a real number by a complex number occurs in which the divisor's real and/or imaginary part is equal to Infinity and if the dividend is not equal to Infinity
If the argument opt is set to false or to 1:
- Standard Java arithmetic is performed throughout all multiplication and division methods
public static boolean getInfOption()
Usage:
opt = Complex.getInfOpt();
Returns the infinity handling option as true or false with the meanings listed above.
MULTIPLICATION
Instance methods
public Complex times(Complex a)
public Complex times(double a)
Usage:
z = x.times(y);
Performs the operation z = x*y where z and x are Complex and y may be either Complex or double (i.e. real)
Static methods
public static Complex times(Complex a, Complex b)
public static Complex times(Complex a, double
b)
public static Complex times(double a, Complex
b)
public static Complex times(double a, double b)
Usage:
z = Complex.times(x, y);
Performs the operation z = x*y where z is Complex and x and y may be either Complex or double (i.e. real)
Equivalence of the *= operator
public void timesEquals(Complex a )
public void timesEquals(double a )
Usage:
x.timesEquals(y);
Performs the operation x = x*y where x is Complex and y may be either Complex or double (i.e. real)
DIVISION
Instance methods
public Complex over(Complex a)
public Complex over(double a)
Usage:
z = x.over(y);
Performs the operation z = x/y where z and x are Complex and y may be either Complex or double (i.e. real)
public Complex transposedOver(double a)
Usage:
z = x.transposedOver(y);
Performs the operation z = y/x where z and x are Complex and y is double (i.e. real)
Static methods
public static Complex over(Complex a, Complex b)
public static Complex over(Complex a, double
b)
public static Complex over(double a, Complex
b)
public static Complex over(double a, double b)
Usage:
z = Complex.over(x, y);
Performs the operation z = x/y where z is Complex and x and y may be either Complex or double (i.e. real)
Equivalence of the /= operator
public void overEquals(Complex a )
public void overEquals(double a )
Usage:
x.overEquals(y);
Performs the operation x = x/y where x is Complex and y may be either Complex or double (i.e. real)
RECIPROCAL
Invert a complex number
public Complex inverse()
public static Complex inverse(Complex a)
Usage:
x = y.inverse(); Usage:
x = Complex.inverse(y);
Performs the operation x = 1.0/y.
NEGATION
Negate a Complex number
public Complex negate()
public static Complex negate(Complex a)
Usage:
x = y.negate();
Usage:
x = Complex.negate(y);
Performs the operation x = -y.
CONJUGATE
Complex conjugate
public Complex conjugate()
public static Complex conjugate(Complex a)
Usage:
x = y.conjugate(); Usage:
x = Complex.conjugate(y);
Returns the complex conjugate of y to x.
EXPONENTIALS
NOTE! ez is periodic with the imaginary period 2πj; ez = ez±2nπj n = 0, 1, 2, . . . .
Exponential of a complex number
public Complex exp()
public static Complex exp(Complex aa)
public static Complex exp(double aa)
Usage:
x = y.exp();
where x and y are Complex.
Usage:
x = Complex.exp(y);
where x is Complex and y may be either Complex or real (a double).
Exponential of +j.arg where arg is real. Result returned as Complex.
public static Complex expPlusJayArg(double aa)
Usage:
x = Complex.expPlusJayArg(y);
where x is Complex and y is real (a double).
Exponential of -j.arg where arg is real. Result returned as Complex.
public static Complex expMinusJayArg(double aa)
Usage:
x = Complex.expMinusJayArg(y);
where x is Complex and y is real (a double).
LOGARITHM OF A COMPEX NUMBER
Principal value of the natural log of an Complex number
public Complex log()
public static Complex log(Complex aa)
Usage:
x = y.log();
Usage:
x = Complex.log(y);
ROOT OF A COMPLEX NUMBER
The square root of a complex number
public Complex sqrt()
public static Complex sqrt(Complex aa )
Usage:
x = y.sqrt();
Usage:
x = Complex.sqrt(y);
-x is also a valid square root of y.
Principal value of the nth root of a complex number (n = integer > 0)
public Complex nthRootint n)
public static Complex nthRoot(Complex aa, int n)
Usage:
x = y.nthRoot(n);
Usage:
x = Complex.nthRoot(y, n);
Performs the operation x = the nth root of y where y is Complex and n is an integer (type int) greater than zero.
POWER OF A COMPEX NUMBER
Square of a complex number
public Complex square()
public static Complex square(Complex aa)
Usage:
x = y.square();
Usage:
x = Complex.square(y);
Complex number raised to a power
public Complex pow(int b)
public Complex pow(double b)
public Complex pow(Complex b)
public static Complex pow(Complex a, int b)
public static Complex pow(Complex a, double b)
public static Complex pow(Complex a, Complex b)
Usage:
z = x.pow(y);
Usage:
z = Complex.pow(x, y);
The complex number, x, raised to the power y which may be int, double or Complex.
Integer or double raised to a Complex power
public static Complex pow(int a, Complex b)
public static Complex pow(double a, Complex b)
Usage:
z = Complex.pow(x, y);
The int or double, x, is raised to the power y which is Complex
MODULUS
Absolute value (modulus) of a complex number
public double abs()
public static double abs(Complex a)
Usage:
x = y.abs();
Usage:
x = Complex.abs(y);
Square of the absolute value (modulus) of a complex number
public double squareAbs()
public static double squareAbs(Complex a)
Usage:
x = y.squareAbs();
Usage:
x = Complex.squareAbs(y);
ARGUMENT
Argument of a complex number returned as radians
public double arg()
public static double arg(Complex a)
public double argRad()
public static double argRad(Complex a)
Usage:
x = y.arg();
Usage:
x = y.argRad();
Usage:
x = Complex.arg(y);
Usage:
x = Complex.argRad(y);
Argument of a complex number returned as degrees
public double argDeg()
public static double argDeg(Complex a)
Usage:
x = y.argDeg();
Usage:
x = Complex.argDeg(y);
TRIGONOMETRIC FUNCTIONS
General
Usage: x = y.funct();
General
Usage: x = Complex.funct(y);
where funct is the trigonometric function, e.g. sin.
Sine of an Complex number
public Complex sin()
public static Complex sin(Complex aa )
Cosine of an Complex number
public Complex cos()
public static Complex cos(Complex aa )
Tangent of an Complex number
public Complex tan()
public static Complex tan(Complex aa )
Cotangent of an Complex number
public Complex cot()
public static Complex cot(Complex aa )
Secant of an Complex number
public Complex sec()
public static Complex sec(Complex aa )
Cosecant of an Complex number
public Complex csc()
public static Complex csc(Complex aa )
Exsecant of an Complex number
public Complex exsec()
public static Complex exsec(Complex aa )
Versine of an Complex number
public Complex vers()
public static Complex vers(Complex aa )
Coversine of an Complex number
public Complex covers()
public static Complex covers(Complex aa )
Haversine of an Complex number
public Complex hav()
public static Complex hav(Complex aa )
Hyperbolic sine of a Complex number
public Complex sinh()
public static Complex sinh(Complex a )
Hyperbolic cosine of a Complex number
public Complex cosh()
public static Complex cosh(Complex a )
Hyperbolic tangent of a Complex number
public Complex tanh()
public static Complex tanh(Complex a )
Hyperbolic cotangent of a Complex number
public Complex coth()
public static Complex coth(Complex a )
Hyperbolic secant of a Complex number
public Complex sech()
public static Complex sech(Complex a )
Hyperbolic cosecant of a Complex number
public Complex csch()
public static Complex csch(Complex a )
Inverse sine of a Complex number
public Complex asin()
public static Complex asin(Complex a )
Inverse cosine of a Complex number
public Complex acos()
public static Complex acos(Complex a )
Inverse tangent of a Complex number
public Complex atan()
public static Complex atan(Complex a )
Inverse cotangent of an Complex number
public Complex acot()
public static Complex acot(Complex aa )
Inverse secant of an Complex number
public Complex asec()
public static Complex asec(Complex aa )
Inverse cosecant of an Complex number
public Complex acsc()
public static Complex acsc(Complex aa )
Inverse exsecant of an Complex number
public Complex aexsec()
public static Complex aexsec(Complex aa )
Inverse versine of an Complex number
public Complex avers()
public static Complex avers(Complex aa )
Inverse coversine of an Complex number
public Complex acovers()
public static Complex acovers(Complex aa )
Inverse haversine of an Complex number
public Complex ahav()
public static Complex ahav(Complex aa )
Inverse hyperbolic sine of a Complex number
public Complex asinh()
public static Complex asinh(Complex a )
Inverse hyperbolic cosine of a Complex number
public Complex acosh()
public static Complex acosh(Complex a )
Inverse hyperbolic tangent of a Complex number
public Complex atanh()
public static Complex atanh(Complex a )
Inverse hyperbolic cotangent of a Complex number
public Complex acoth()
public static Complex acoth(Complex a )
Inverse hyperbolic secant of a Complex number
public Complex asech()
public static Complex asech(Complex a )
Inverse hyperbolic cosecant of a Complex number
public Complex acsch()
public static Complex acsch(Complex a )
HYPOTENUSE
Returns the length of the hypotenuse of a and b, i.e. sqrt(abs(a)*abs(a)+abs(b)*abs(b))
where a and b are Complex. This method avoids unecessary overflow or underflow.
public static double hypot(Complex a, Complex b)
Usage:
d = Complex.hypot(a,b);
LOGICAL FUNCTIONS
public boolean equals(Complex x)
public boolean isEqual(Complex x)
public static boolean isEqual(Complex a, Complex b)
Returns true if the real and imaginary parts of the complex numbers represented by the two Complex instances are identical; returns false if they are not.
Follows the Sun Java convention of treating two NaNs as equal which does not satisfy the IEEE 754 specification but does let hashtables operate properly.
Example of
Usage: if (a.equals(b)){   . . .
Example of
Usage: if (a.isEqual(b)){
  . . . Example of
Usage: if (Complex.isEqual(a, b)){
  . . .
where a and b are complex
REMEMBER: if(a==b) does not test for equality of the
contents of instances of objects, a and b, it only tests the referencing.
public boolean equalsWithinLimits(Complex x, double limit)
public boolean isEqualWithinLimits(Complex x, double limit)
public static boolean isEqualWithinLimits(Complex a, Complex b,
double limit)
Returns true if the differences between the real and imaginary parts
of two complex numbers are less the argument limit times the larger of the real and imaginary parts;
returns false if they are not.
Example of
Usage: if (a.equalsWithinLimits(b, limit)){
  . . .
Example of
Usage: if (a.isEqualWithinLimits(b, limit)){
  . . .
Example of
Usage: if (Complex.isEqualWithinLimits(a, b, limit)){
  . . .
where a and b are complex and limit is double
public boolean isReal()
public static boolean isReal(Complex a)
public static boolean isReal(Complex[ ] a)
Returns true if the Complex number has a zero imaginary part, i.e. is a real number, or if all the elements of the array of Complex have a zero imaginary part, i.e. are real numbers;
returns false if it does not or they are not.
Example of
Usage:
if a.isReal()){   . . .
Example of
Usage:
if (Complex.isReal(a)){   . . . where a is Complex or Complex[].
public boolean isReal(double limit)
public static boolean isReal(Complex a, double limit)
public static boolean isRealPerCent(Complex[ ] a, double limit)
Returns true if the Complex number has a imaginary part less than the limit, limit, or if all the elements of the array of Complex have an imaginary part less than the limit, limit;
returns false if it does not or they have not.
Example of
Usage:
if a.isReal(limit)){   . . .
Example of
Usage:
if (Complex.isReal(a, limit)){   . . . where a is Complex or Complex[].
public boolean isRealPerCent(double percentage)
public static boolean isRealPerCent(Complex a, double percentage)
public static boolean isReal(Complex[ ] a, double percentage)
Returns true if the Complex number has a imaginary part less than the percentage, percentage, of the real part, or if all the elements of the array of Complex have an imaginary part less than the percentage, percentage, of the real part;
returns false if it does not or they have not.
Example of
Usage:
if a.isRealPerCent(percentage)){   . . .
Example of
Usage:
if (Complex.isRealPerCent(a, percentage)){   . . . where a is Complex or Complex[].
public boolean isZero()
public static boolean isZero(Complex a)
Returns true if the Complex number has a zero real and a zero imaginary part i.e. has a
zero modulus; returns false if it does not. Example of
Usage:
if (a.isZero()){ . . .
Example of
Usage:
if (Complex.isZero(a)){ . . .
where a is complex
public boolean isInfinite()
public static boolean isInfinite(Complex a)
Returns true if either the real or the imaginary part of the Complex number is equal to
either plus infinity or minus infinity; returns false if they are not.
Example of
Usage:
if (a.isInfinite()){ . . .
Example of
Usage:
if (Complex.isInfinite(a)){ . . . where a is complex
public boolean isPlusInfinity()
public static boolean isPlusInfinity(Complex a)
Returns true if either the real or the imaginary part of the Complex number is equal to
plus infinity; returns false if they are not.
Example of
Usage:
if (a.isPlusInfinity()){ . . .
Example of
Usage:
if (Complex.isPlusInfinity(a)){ . . . where a is complex
public boolean isMinusInfinity()
public static boolean isMinusInfinity(Complex a)
Returns true if either the real or the imaginary part of the Complex number is equal to
minus infinity; returns false if they are not.
Example of
Usage:
if (a.isMinusInfinity()){ . . .
Example of
Usage:
if (Complex.isMinusInfinity(a)){ . . .
where a is complex
public boolean isNaN()
public static boolean isNaN(Complex a)
Returns true if the Complex number is NaN (not-a-number)
i.e. is the result of an uninterpretable mathematical operation; returns false if it is
not.
Example of
Usage:
if (a.isNaN()){ . . .
Example of
Usage:
if (Complex.isNaN(a)){ . . .
where a is complex
TYPE CONVERSIONS
String to Complex
public static Complex parseComplex(String ss)
Usage:
aa = Complex.parseComplex(ss);
If the String, ss, is the String representation of a Complex, i.e. is 'sxs+sjsys', 'sxs-sjsys', 'sxs+sisys' or 'sxs-sisys' where s is
any number of spaces (including no spaces) the complex number is returned, as a Complex, to aa
public static Complex valueOf(String ss)
Usage:
aa = Complex.valueOf(ss);
Method as for parseComplex above. Complex.valueOf overides java.lang.Object.valueOf
Complex to String
public String toString()
public static String toString(Complex aa)
Usage:
ss = aa.toString();
Usage:
ss = Complex.toString(aa);
Converts the complex number in aa to a string (referenced by ss in the above example) of the form x + jy.
This method overides java.lang.String.toString(). Consequently you may add a complex number to the string in the
standard output methods, e.g. System.out.print(), System.out.println(), g.drawString, and it will automatically be converted
to the x + jy format on output.
Complex to hashcode
public int hashCode()
Usage:
hc = aa.hashCode();
The hashcode for aa is returned to hc.
Overides java.lang.Object.hashCode()
ARRAYS
See Input and output above for printing arrays
Single dimension
public static Complex[] oneDarray(int n)
public static Complex[] oneDarray(int n, double a, double b)
public static Complex[] oneDarray(int n, Complex xx)
Create a one dimensional array of Complex objects of length n with all real = zero and all imag = zero
Usage:
Complex[] aa = Complex.oneDarray(n);
Create a one dimensional array of Complex objects of length n with all real = x and all imag = y
Usage:
Complex[] aa = Complex.oneDarray(n, x, y);
Create a one dimensional array of Complex objects of length n with all array objects = the Complex zz
Usage:
Complex[] aa = Complex.oneDarray(n, zz);
Arithmetic mean of a one dimensional array
public static Complex mean(Complex[] xx)
Usage:
Complex mean = Complex.mean(xx);
Returns the arithmetic mean of the complex variables in the array of Complex, xx.
Weighted and unweighted arithmetic means, harmonic means, generalised means, standard deviations and variances of one-dimensional arrays of Complex may be found in the Stat class.
Two dimensions
public static Complex[][] twoDarray(int n, int m)
public static Complex[][] twoDarray(int n, int m, double a, double
b)
public static Complex[][] twoDarray(int n, int m, Complex xx)
Create a two dimensional array (matrix) of Complex objects of dimensions n and m with all real = zero and all imag =
zero
Usage:
Complex[][] aa = Complex.twoDarray(n, m);
Create a two dimensional array of Complex objects of dimensions n and m with all real = a and all imag = b
Usage:
Complex[][] aa = Complex.twoDarray(n, m, x, y);
Create a two dimensional array of Complex objects of dimensions n and m with all Complex objects in the matrix
= the Complex zz
Usage:
Complex[][] aa = Complex.twoDarray(n, m, zz);
Three dimensions
public static Complex[][][] threeDarray(int n, int m, int k)
public static Complex[][][] threeDarray(int n, int m, int k, double a, double
b)
public static Complex[][][] threeDarray(int n, int m, int k, Complex xx)
Create a three dimensional array of Complex objects of dimensions n, m and k with all real = zero and all imag = zero
Usage:
Complex[][][] aa = Complex.threeDarray(n, m, k);
Create a three dimensional array of Complex objects of dimensions n, m and k with all real = a and all imag = b
Usage:
Complex[][][] aa = Complex.threeDarray(n, m, k, x, y);
Create a three dimensional array of Complex objects of dimensions n, m and k with all Complex objects in the matrix
= the Complex zz
Usage:
Complex[][][] aa = Complex.threeDarray(n, m, k, zz);
DEEP COPY
REMEMBER: aa = bb; does not copy bb into aa when aa and bb are objects, instead aa becomes a reference (pointer) to bb.
public Complex copy()
public Object clone()
public static Complex copy(Complex a)
public static Complex[] copy(Complex[] a)
public static Complex[][] copy(Complex[][] a)
public static Complex[][][] copy(Complex[][][] a)
Copy a single complex number
Usage:
aa = bb.copy();
Usage:
aa = Complex.copy(bb);
The complex number, bb, is copied and returned to aa.
Clone a single complex number
Usage:
aa = (Complex) bb.clone();
The complex number, bb, is copied and returned to aa. This method overrides java.lang.Object.clone().
Copy a 1D array of complex numbers (deep copy)
Usage:
aa = Complex.copy(bb);
The complex 1D array, bb, is copied and returned to aa.
Copy a 2D array of complex numbers (deep copy)
Usage:
aa = Complex.copy(bb);
The complex 2D array, bb, is copied and returned to aa.
Copy a 3D array of complex numbers (deep copy)
Usage:
aa = Complex.copy(bb);
The complex 3D array, bb, is copied and returned to aa.
SOME USEFUL NUMBERS
Return the number zero (0) as a complex number
public static Complex zero()
Usage:
x = Complex.zero();
Returns 0 + j0 to x
Return the number one (+1) as a complex number
public static Complex plusOne()
Usage:
x = Complex.plusOne();
Returns 1 + j0 to x
Return the number minus one (-1) as a complex number
public static Complex minusOne()
Usage:
x = Complex.minusOne();
Returns -1 + j0 to x
Return +j
public static Complex plusJay()
Usage:
x = Complex.plusJay();
Returns 0 + j to x
Return -j
public static Complex minusJay()
Usage:
x = Complex.minusJay();
Returns 0 - j to x
Return pi as a complex number
public static Complex pi()
Usage:
x = Complex.plusOne();
Returns pi + j0 to x
Return positive infinity
public static Complex plusInfinity()
Usage:
x = Complex.plusInfinity();
Returns Double.POSITIVE_INFINITY + j.Double.POSITIVE_INFINITY to x
Return negative infinity
public static Complex minusInfinity()
Usage:
x = Complex.minusInfinity();
Returns Double.NEGATIVE_INFINITY + j.Double.NEGATIVE_INFINITY to x
STATISTICAL ANALISIS OF COMPLEX ONE-DIMENSIONAL ARRAYS
The statistics class, Stat, contains the following methods for the analysis of Complex one-dimensional arrays:
ARITHMETIC OPERATIONS ON COMPLEX ONE-DIMENSIONAL ARRAYS
The ArrayMaths class contains the following methods for the analysis of Complex one-dimensional arrays:
in addition to a wide range of operations common to both complex and real arrays.
OTHER CLASSES USED BY THIS CLASS
This class uses the following classes in this library:
This page was prepared by Dr Michael Thomas Flanagan
|