- java.lang.Object
-
- org.scijava.ops.image.util.BigComplex
-
- All Implemented Interfaces:
ComplexType<BigComplex>,NumericType<BigComplex>,Add<BigComplex>,Div<BigComplex>,Mul<BigComplex>,MulFloatingPoint,Pow<BigComplex>,PowFloatingPoint,SetOne,SetZero,Sub<BigComplex>,ValueEquals<BigComplex>,Type<BigComplex>
public class BigComplex extends Object implements ComplexType<BigComplex>
A complex number that stores values in BigDecimal (arbitrary) precision. Besides providing precise numeric operations this class is useful for supporting DataType translations with minimal data loss. Some methods may round values to 50 decimal places of precision.- Author:
- Barry DeZonia
-
-
Constructor Summary
Constructors Constructor Description BigComplex()Default constructor: value = (0,0).BigComplex(double r, double i)Constructor from doubles.BigComplex(long r, long i)Constructor from longs.BigComplex(String r, String i)Constructor from Strings.BigComplex(BigDecimal r, BigDecimal i)Constructor from BigDecimals.BigComplex(BigInteger r, BigInteger i)Constructor from BigIntegers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(BigComplex other)Adds another BigComplex value to self.voidadd(BigComplex a, BigComplex b)Set self to the result of addition between two BigComplex values.voidcomplexConjugate()Does complex conjugation on self.BigComplexcopy()Creates a new BigComplex whose values are taken from this BigComplex.BigComplexcreateVariable()Creates a new BigComplex initialized to (0,0).voiddiv(BigComplex other)Divides self by another BigComplex value.voiddiv(BigComplex a, BigComplex b)Set self to the result of division between two BigComplex values.voidE()Fills self with the representation of e for the given type.BigDecimalgetImag()Gets imaginary component of this complex number as a BigDecimal.doublegetImaginaryDouble()Gets imaginary component as a double (narrowing possible).floatgetImaginaryFloat()Gets imaginary component as a float (narrowing possible).BigDecimalgetPhase()Gets phase as a BigDecimal.doublegetPhaseDouble()Gets phase as a double (narrowing possible).floatgetPhaseFloat()Gets phase as a float (narrowing possible).BigDecimalgetPower()Gets magnitude as a BigDecimal.doublegetPowerDouble()Gets magnitude as a double (narrowing possible).floatgetPowerFloat()Gets magnitude as a float (narrowing possible).BigDecimalgetReal()Gets real component of this complex number as a BigDecimal.doublegetRealDouble()Gets real component as a double (narrowing possible).floatgetRealFloat()Gets real component as a float (narrowing possible).voidmul(double c)Multiplies self by a scalar (double) constant.voidmul(float c)Multiplies self by a scalar (float) constant.voidmul(BigComplex other)Multiplies another BigComplex value with self.voidmul(BigComplex a, BigComplex b)Set self to the result of multiplication between two BigComplex values.voidPI()Fills self with the representation of pi for the given type.voidpow(double power)voidpow(BigComplex c)voidset(double r, double i)Sets the real and imaginary components of this BigComplex to given double values.voidset(long r, long i)Sets the real and imaginary components of this BigComplex to given long values.voidset(String r, String i)Sets the real and imaginary components of this BigComplex to given String values.voidset(BigDecimal r, BigDecimal i)Sets the real and imaginary components of this BigComplex to given BigDecimal values.voidset(BigInteger r, BigInteger i)Sets the real and imaginary components of this BigComplex to given BigInteger values.voidset(BigComplex other)Sets the real and imaginary components of this BigComplex to match those of another.voidsetComplexNumber(double r, double i)Sets the real and imaginary components of this BigComplex to given double values.voidsetComplexNumber(float r, float i)Sets the real and imaginary components of this BigComplex to given float values.voidsetComplexNumber(String r, String i)Sets the real and imaginary components of this BigComplex to given String values.voidsetComplexNumber(BigDecimal r, BigDecimal i)Sets the real and imaginary components of this BigComplex to given BigDecimal values.voidsetImag(double i)Sets the imaginary component of this BigComplex to given double value.voidsetImag(long i)Sets the imaginary component of this BigComplex to given long value.voidsetImag(String i)Sets the imaginary component of this BigComplex to given String value.voidsetImag(BigDecimal i)Sets the imaginary component of this BigComplex to given BigDecimal value.voidsetImag(BigInteger i)Sets the imaginary component of this BigComplex to given BigInteger value.voidsetImaginary(double f)Sets the imaginary component of this BigComplex to given double value.voidsetImaginary(float f)Sets the imaginary component of this BigComplex to given float value.voidsetOne()Sets this BigComplex to the unity value.voidsetReal(double r)Sets the real component of this BigComplex to given double value.voidsetReal(float f)Sets the real component of this BigComplex to given float value.voidsetReal(long r)Sets the real component of this BigComplex to given long value.voidsetReal(String r)Sets the real component of this BigComplex to given String value.voidsetReal(BigDecimal r)Sets the real component of this BigComplex to given BigDecimal value.voidsetReal(BigInteger r)Sets the real component of this BigComplex to given BigInteger value.voidsetZero()Sets this BigComplex to the zero value.voidsub(BigComplex other)Subtracts another BigComplex value from self.voidsub(BigComplex a, BigComplex b)Set self to the result of subtraction between two BigComplex values.booleanvalueEquals(BigComplex t)
-
-
-
Constructor Detail
-
BigComplex
public BigComplex()
Default constructor: value = (0,0).
-
BigComplex
public BigComplex(long r, long i)Constructor from longs.
-
BigComplex
public BigComplex(double r, double i)Constructor from doubles.
-
BigComplex
public BigComplex(BigInteger r, BigInteger i)
Constructor from BigIntegers.
-
BigComplex
public BigComplex(BigDecimal r, BigDecimal i)
Constructor from BigDecimals.
-
-
Method Detail
-
getReal
public BigDecimal getReal()
Gets real component of this complex number as a BigDecimal.
-
getImag
public BigDecimal getImag()
Gets imaginary component of this complex number as a BigDecimal.
-
set
public void set(BigComplex other)
Sets the real and imaginary components of this BigComplex to match those of another.- Specified by:
setin interfaceType<BigComplex>
-
set
public void set(long r, long i)Sets the real and imaginary components of this BigComplex to given long values.
-
set
public void set(double r, double i)Sets the real and imaginary components of this BigComplex to given double values.
-
set
public void set(BigInteger r, BigInteger i)
Sets the real and imaginary components of this BigComplex to given BigInteger values.
-
set
public void set(BigDecimal r, BigDecimal i)
Sets the real and imaginary components of this BigComplex to given BigDecimal values.
-
set
public void set(String r, String i)
Sets the real and imaginary components of this BigComplex to given String values. The strings must represent numbers that BigDecimal can parse.
-
setReal
public void setReal(long r)
Sets the real component of this BigComplex to given long value.
-
setReal
public void setReal(float f)
Sets the real component of this BigComplex to given float value.- Specified by:
setRealin interfaceComplexType<BigComplex>
-
setReal
public void setReal(double r)
Sets the real component of this BigComplex to given double value.- Specified by:
setRealin interfaceComplexType<BigComplex>
-
setReal
public void setReal(BigInteger r)
Sets the real component of this BigComplex to given BigInteger value.
-
setReal
public void setReal(BigDecimal r)
Sets the real component of this BigComplex to given BigDecimal value.
-
setReal
public void setReal(String r)
Sets the real component of this BigComplex to given String value. The string must represent a number that BigDecimal can parse.
-
setImag
public void setImag(long i)
Sets the imaginary component of this BigComplex to given long value.
-
setImag
public void setImag(double i)
Sets the imaginary component of this BigComplex to given double value.
-
setImag
public void setImag(BigInteger i)
Sets the imaginary component of this BigComplex to given BigInteger value.
-
setImag
public void setImag(BigDecimal i)
Sets the imaginary component of this BigComplex to given BigDecimal value.
-
setImag
public void setImag(String i)
Sets the imaginary component of this BigComplex to given String value. The string must represent a number that BigDecimal can parse.
-
setImaginary
public void setImaginary(float f)
Sets the imaginary component of this BigComplex to given float value.- Specified by:
setImaginaryin interfaceComplexType<BigComplex>
-
setImaginary
public void setImaginary(double f)
Sets the imaginary component of this BigComplex to given double value.- Specified by:
setImaginaryin interfaceComplexType<BigComplex>
-
setComplexNumber
public void setComplexNumber(float r, float i)Sets the real and imaginary components of this BigComplex to given float values.- Specified by:
setComplexNumberin interfaceComplexType<BigComplex>
-
setComplexNumber
public void setComplexNumber(double r, double i)Sets the real and imaginary components of this BigComplex to given double values.- Specified by:
setComplexNumberin interfaceComplexType<BigComplex>
-
setComplexNumber
public void setComplexNumber(BigDecimal r, BigDecimal i)
Sets the real and imaginary components of this BigComplex to given BigDecimal values.
-
setComplexNumber
public void setComplexNumber(String r, String i)
Sets the real and imaginary components of this BigComplex to given String values. The strings must represent numbers that BigDecimal can parse.
-
setZero
public void setZero()
Sets this BigComplex to the zero value.
-
setOne
public void setOne()
Sets this BigComplex to the unity value.
-
createVariable
public BigComplex createVariable()
Creates a new BigComplex initialized to (0,0).- Specified by:
createVariablein interfaceType<BigComplex>
-
copy
public BigComplex copy()
Creates a new BigComplex whose values are taken from this BigComplex.- Specified by:
copyin interfaceType<BigComplex>
-
add
public void add(BigComplex a, BigComplex b)
Set self to the result of addition between two BigComplex values.
-
add
public void add(BigComplex other)
Adds another BigComplex value to self.- Specified by:
addin interfaceAdd<BigComplex>
-
sub
public void sub(BigComplex a, BigComplex b)
Set self to the result of subtraction between two BigComplex values.
-
sub
public void sub(BigComplex other)
Subtracts another BigComplex value from self.- Specified by:
subin interfaceSub<BigComplex>
-
mul
public void mul(BigComplex a, BigComplex b)
Set self to the result of multiplication between two BigComplex values.
-
mul
public void mul(BigComplex other)
Multiplies another BigComplex value with self.- Specified by:
mulin interfaceMul<BigComplex>
-
div
public void div(BigComplex a, BigComplex b)
Set self to the result of division between two BigComplex values. Precision loss is possible.
-
div
public void div(BigComplex other)
Divides self by another BigComplex value. Precision loss is possible.- Specified by:
divin interfaceDiv<BigComplex>
-
mul
public void mul(float c)
Multiplies self by a scalar (float) constant.- Specified by:
mulin interfaceMulFloatingPoint
-
mul
public void mul(double c)
Multiplies self by a scalar (double) constant.- Specified by:
mulin interfaceMulFloatingPoint
-
pow
public void pow(BigComplex c)
- Specified by:
powin interfacePow<BigComplex>
-
pow
public void pow(double power)
- Specified by:
powin interfacePowFloatingPoint
-
complexConjugate
public void complexConjugate()
Does complex conjugation on self.- Specified by:
complexConjugatein interfaceComplexType<BigComplex>
-
getRealDouble
public double getRealDouble()
Gets real component as a double (narrowing possible).- Specified by:
getRealDoublein interfaceComplexType<BigComplex>
-
getRealFloat
public float getRealFloat()
Gets real component as a float (narrowing possible).- Specified by:
getRealFloatin interfaceComplexType<BigComplex>
-
getImaginaryDouble
public double getImaginaryDouble()
Gets imaginary component as a double (narrowing possible).- Specified by:
getImaginaryDoublein interfaceComplexType<BigComplex>
-
getImaginaryFloat
public float getImaginaryFloat()
Gets imaginary component as a float (narrowing possible).- Specified by:
getImaginaryFloatin interfaceComplexType<BigComplex>
-
getPowerFloat
public float getPowerFloat()
Gets magnitude as a float (narrowing possible).- Specified by:
getPowerFloatin interfaceComplexType<BigComplex>
-
getPowerDouble
public double getPowerDouble()
Gets magnitude as a double (narrowing possible).- Specified by:
getPowerDoublein interfaceComplexType<BigComplex>
-
getPower
public BigDecimal getPower()
Gets magnitude as a BigDecimal.
-
getPhaseFloat
public float getPhaseFloat()
Gets phase as a float (narrowing possible).- Specified by:
getPhaseFloatin interfaceComplexType<BigComplex>
-
getPhaseDouble
public double getPhaseDouble()
Gets phase as a double (narrowing possible).- Specified by:
getPhaseDoublein interfaceComplexType<BigComplex>
-
getPhase
public BigDecimal getPhase()
Gets phase as a BigDecimal.
-
PI
public void PI()
Fills self with the representation of pi for the given type.
-
E
public void E()
Fills self with the representation of e for the given type.
-
valueEquals
public boolean valueEquals(BigComplex t)
- Specified by:
valueEqualsin interfaceValueEquals<BigComplex>
-
-