jsci.maths
Class Complex
- java.lang.Object
-
- jsci.maths.Complex
-
- All Implemented Interfaces:
- java.io.Serializable, Algebra.Member, BanachSpace.Member, CStarAlgebra.Member, Module.Member, VectorSpace.Member, Field.Member, Ring.Member, AbelianGroup.Member, Member
public final class Complex extends java.lang.Object implements Field.Member, CStarAlgebra.Member
The Complex class encapsulates complex numbers.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static ComplexIThe complex number 0+1i.static ComplexONEThe complex number 1+0i.static ComplexZEROThe complex number 0+0i.
-
Constructor Summary
Constructors Constructor and Description Complex(double x, double y)Constructs the complex number x+iy.Complex(java.lang.String s)Constructs the complex number represented by a string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static Complexacos(Complex z)Returns the arc cosine of a complex number, in the range of (0.0 through
,
0.0 through
).static Complexacosh(Complex z)Returns the arc hyperbolic cosine of a complex number, in the range of (0.0 through
,
0.0 through
).AbelianGroup.Memberadd(AbelianGroup.Member x)Returns the addition of this number and another.Complexadd(Complex z)Returns the addition of this complex number and another.ComplexaddImag(double imag)Returns the addition of this complex number with an imaginary part.ComplexaddReal(double real)Returns the addition of this complex number with a real part.doublearg()Returns the argument of this complex number.static Complexasin(Complex z)Returns the arc sine of a complex number, in the range of (-
/2 through
/2,
-
through
).static Complexasinh(Complex z)Returns the arc hyperbolic sine of a complex number, in the range of (-
through
,
-
/2 through
/2).static Complexatan(Complex z)Returns the arc tangent of a complex number, in the range of (-
/2 through
/2,
-
through
).static Complexatanh(Complex z)Returns the arc hyperbolic tangent of a complex number, in the range of (-
through
,
-
/2 through
/2).Complexconjugate()Returns the complex conjugate of this complex number.static Complexcos(Complex z)Returns the trigonometric cosine of a complex angle.static Complexcosh(Complex z)Returns the hyperbolic cosine of a complex number.Complexdivide(Complex z)Returns the division of this complex number by another.Complexdivide(double x)Returns the division of this complex number by a scalar.Field.Memberdivide(Field.Member x)Returns the division of this number and another.booleanequals(double real, double imag)Compares two complex numbers for equality.booleanequals(double real, double imag, double tol)booleanequals(java.lang.Object obj)Compares two complex numbers for equality.booleanequals(java.lang.Object obj, double tol)static Complexexp(Complex z)Returns the exponential number e (2.718...) raised to the power of a complex number.java.lang.ObjectgetSet()inthashCode()Returns a hashcode for this complex number.doubleimag()Returns the imaginary part of this complex number.Field.Memberinverse()Returns the inverse of this complex number.CStarAlgebra.Memberinvolution()Returns the involution of this complex number.booleanisInfinite()Returns true if either the real or imaginary part is infinite.booleanisNaN()Returns true if either the real or imaginary part is NaN.booleanisZero()Returns true if the modulus of this complex number is within the zero tolerance.static Complexlog(Complex z)Returns the natural logarithm (base e) of a complex number.doublemod()Returns the modulus of this complex number.doublemodSqr()Returns the square of the modulus of this complex number.Complexmultiply(Complex z)Returns the multiplication of this complex number and another.Complexmultiply(double x)Returns the multiplication of this complex number by a scalar.Ring.Membermultiply(Ring.Member x)Returns the multiplication of this number and another.AbelianGroup.Membernegate()Returns the negative of this complex number.doublenorm()Returns the C* norm.static Complexpolar(double mod, double arg)Creates a complex number with the given modulus and argument.Complexpow(Complex z)Returns this complex number raised to the power of another.Complexpow(double x)Returns this complex number raised to the power of a scalar.doublereal()Returns the real part of this complex number.VectorSpace.MemberscalarDivide(Field.Member x)Returns the division of this number by a complex scalar.Module.MemberscalarMultiply(Ring.Member x)Returns the multiplication of this number by a complex scalar.static Complexsin(Complex z)Returns the trigonometric sine of a complex angle.static Complexsinh(Complex z)Returns the hyperbolic sine of a complex number.Complexsqr()Returns the square of this complex number.Complexsqrt()Returns the square root of this complex number.AbelianGroup.Membersubtract(AbelianGroup.Member x)Returns the subtraction of this number and another.Complexsubtract(Complex z)Returns the subtraction of this complex number by another.ComplexsubtractImag(double imag)Returns the subtraction of this complex number by an imaginary part.ComplexsubtractReal(double real)Returns the subtraction of this complex number by a real part.static Complextan(Complex z)Returns the trigonometric tangent of a complex angle.static Complextanh(Complex z)Returns the hyperbolic tangent of a complex number.java.lang.StringtoString()Returns a string representing the value of this complex number.static java.lang.StringtoString(double real, double imag)Returns a string representing the value of this complex number.
-
-
-
Field Detail
-
I
public static final Complex I
The complex number 0+1i.
-
ONE
public static final Complex ONE
The complex number 1+0i.
-
ZERO
public static final Complex ZERO
The complex number 0+0i.
-
-
Constructor Detail
-
Complex
public Complex(double x, double y)Constructs the complex number x+iy.- Parameters:
x- the real value of a complex number.y- the imaginary value of a complex number.
-
Complex
public Complex(java.lang.String s) throws java.lang.NumberFormatExceptionConstructs the complex number represented by a string.- Parameters:
s- a string representing a complex number.- Throws:
java.lang.NumberFormatException- if the string does not contain a parsable number.
-
-
Method Detail
-
polar
public static Complex polar(double mod, double arg)
Creates a complex number with the given modulus and argument.- Parameters:
mod- the modulus of a complex number.arg- the argument of a complex number.
-
equals
public boolean equals(java.lang.Object obj)
Compares two complex numbers for equality.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- a complex number.
-
equals
public boolean equals(java.lang.Object obj, double tol)
-
equals
public boolean equals(double real, double imag)Compares two complex numbers for equality.
-
equals
public boolean equals(double real, double imag, double tol)
-
toString
public java.lang.String toString()
Returns a string representing the value of this complex number.- Overrides:
toStringin classjava.lang.Object
-
toString
public static java.lang.String toString(double real, double imag)Returns a string representing the value of this complex number.
-
hashCode
public int hashCode()
Returns a hashcode for this complex number.- Overrides:
hashCodein classjava.lang.Object
-
isZero
public boolean isZero()
Returns true if the modulus of this complex number is within the zero tolerance.
-
isNaN
public boolean isNaN()
Returns true if either the real or imaginary part is NaN.
-
isInfinite
public boolean isInfinite()
Returns true if either the real or imaginary part is infinite.
-
real
public double real()
Returns the real part of this complex number.
-
imag
public double imag()
Returns the imaginary part of this complex number.
-
mod
public double mod()
Returns the modulus of this complex number.
-
modSqr
public double modSqr()
Returns the square of the modulus of this complex number.
-
arg
public double arg()
Returns the argument of this complex number.
-
norm
public double norm()
Returns the C* norm.- Specified by:
normin interfaceBanachSpace.Member
-
negate
public AbelianGroup.Member negate()
Returns the negative of this complex number.- Specified by:
negatein interfaceAbelianGroup.Member
-
inverse
public Field.Member inverse()
Returns the inverse of this complex number.- Specified by:
inversein interfaceField.Member
-
involution
public CStarAlgebra.Member involution()
Returns the involution of this complex number.- Specified by:
involutionin interfaceCStarAlgebra.Member
-
conjugate
public Complex conjugate()
Returns the complex conjugate of this complex number.
-
add
public AbelianGroup.Member add(AbelianGroup.Member x)
Returns the addition of this number and another.- Specified by:
addin interfaceAbelianGroup.Member- Parameters:
x- a group member
-
add
public Complex add(Complex z)
Returns the addition of this complex number and another.- Parameters:
z- a complex number.
-
addReal
public Complex addReal(double real)
Returns the addition of this complex number with a real part.- Parameters:
real- a real part.
-
addImag
public Complex addImag(double imag)
Returns the addition of this complex number with an imaginary part.- Parameters:
imag- an imaginary part.
-
subtract
public AbelianGroup.Member subtract(AbelianGroup.Member x)
Returns the subtraction of this number and another.- Specified by:
subtractin interfaceAbelianGroup.Member- Parameters:
x- a group member
-
subtract
public Complex subtract(Complex z)
Returns the subtraction of this complex number by another.- Parameters:
z- a complex number.
-
subtractReal
public Complex subtractReal(double real)
Returns the subtraction of this complex number by a real part.- Parameters:
real- a real part.
-
subtractImag
public Complex subtractImag(double imag)
Returns the subtraction of this complex number by an imaginary part.- Parameters:
imag- an imaginary part.
-
scalarMultiply
public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this number by a complex scalar.- Specified by:
scalarMultiplyin interfaceModule.Member- Parameters:
x- a ring member
-
multiply
public Ring.Member multiply(Ring.Member x)
Returns the multiplication of this number and another.- Specified by:
multiplyin interfaceRing.Member- Parameters:
x- a ring member
-
multiply
public Complex multiply(Complex z)
Returns the multiplication of this complex number and another.- Parameters:
z- a complex number.
-
multiply
public Complex multiply(double x)
Returns the multiplication of this complex number by a scalar.- Parameters:
x- a real number.
-
scalarDivide
public VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this number by a complex scalar.- Specified by:
scalarDividein interfaceVectorSpace.Member- Parameters:
x- a field member
-
divide
public Field.Member divide(Field.Member x)
Returns the division of this number and another.- Specified by:
dividein interfaceField.Member- Parameters:
x- a field member
-
divide
public Complex divide(Complex z)
Returns the division of this complex number by another.- Parameters:
z- a complex number.- Throws:
java.lang.ArithmeticException- If divide by zero.
-
divide
public Complex divide(double x)
Returns the division of this complex number by a scalar.- Parameters:
x- a real number.- Throws:
java.lang.ArithmeticException- If divide by zero.
-
pow
public Complex pow(Complex z)
Returns this complex number raised to the power of another.- Parameters:
z- a complex number.
-
pow
public Complex pow(double x)
Returns this complex number raised to the power of a scalar.- Parameters:
x- a real number.
-
sqr
public Complex sqr()
Returns the square of this complex number.
-
sqrt
public Complex sqrt()
Returns the square root of this complex number.
-
exp
public static Complex exp(Complex z)
Returns the exponential number e (2.718...) raised to the power of a complex number.- Parameters:
z- a complex number.
-
log
public static Complex log(Complex z)
Returns the natural logarithm (base e) of a complex number.- Parameters:
z- a complex number.
-
sin
public static Complex sin(Complex z)
Returns the trigonometric sine of a complex angle.- Parameters:
z- an angle that is measured in radians.
-
cos
public static Complex cos(Complex z)
Returns the trigonometric cosine of a complex angle.- Parameters:
z- an angle that is measured in radians.
-
tan
public static Complex tan(Complex z)
Returns the trigonometric tangent of a complex angle.- Parameters:
z- an angle that is measured in radians.
-
sinh
public static Complex sinh(Complex z)
Returns the hyperbolic sine of a complex number.- Parameters:
z- a complex number.
-
cosh
public static Complex cosh(Complex z)
Returns the hyperbolic cosine of a complex number.- Parameters:
z- a complex number.
-
tanh
public static Complex tanh(Complex z)
Returns the hyperbolic tangent of a complex number.- Parameters:
z- a complex number.
-
asin
public static Complex asin(Complex z)
Returns the arc sine of a complex number, in the range of (-
/2 through
/2,
-
through
).- Parameters:
z- a complex number.
-
acos
public static Complex acos(Complex z)
Returns the arc cosine of a complex number, in the range of (0.0 through
,
0.0 through
).- Parameters:
z- a complex number.
-
atan
public static Complex atan(Complex z)
Returns the arc tangent of a complex number, in the range of (-
/2 through
/2,
-
through
).- Parameters:
z- a complex number.
-
asinh
public static Complex asinh(Complex z)
Returns the arc hyperbolic sine of a complex number, in the range of (-
through
,
-
/2 through
/2).- Parameters:
z- a complex number.
-
acosh
public static Complex acosh(Complex z)
Returns the arc hyperbolic cosine of a complex number, in the range of (0.0 through
,
0.0 through
).- Parameters:
z- a complex number.
-
-
DMelt 3.0 © DataMelt by jWork.ORG