Package org.apfloat
Class FixedPrecisionApcomplexHelper
java.lang.Object
org.apfloat.FixedPrecisionApcomplexHelper
- Direct Known Subclasses:
FixedPrecisionApfloatHelper
Fixed-precision mathematical functions for complex numbers.
All results of the mathematical operations are set to have the specified precision.
Also all input arguments are set to the specified precision before the operation.
If the specified precision is not infinite, this helper class also avoids
InfiniteExpansionException
e.g. in case where it would happen with
ApcomplexMath.acos(Apcomplex.ZERO)
.
- Since:
- 1.5
- Version:
- 1.10.1
- Author:
- Mikko Tommila
-
Constructor Summary
ConstructorsConstructorDescriptionFixedPrecisionApcomplexHelper(long precision)
Constructs an apcomplex fixed-precison helper with the specified precision. -
Method Summary
Modifier and TypeMethodDescriptionAbsolute value.Arc cosine.Hyperbolic arc cosine.Addition.Arithmetic-geometric mean.All branches of a root.Complex angle.Arc sine.Hyperbolic arc sine.Arc tangent.Hyperbolic arc tangent.Cube root.Complex conjugate.Cosine.Hyperbolic cosine.Division.Exponential function.Gamma function.Incomplete gamma function.Generalized incomplete gamma function.Imaginary part.inverseRoot(Apcomplex z, long n)
Inverse root.inverseRoot(Apcomplex z, long n, long k)
Inverse root with branch.Natural logarithm.Logarithm in specified base.Multiplication.Negation.Norm.Integer power.Power.long
Returns the precision, which is used for the results.Product.Real part.Root.Root with branch.Move the radix point.Sine.Hyperbolic sine.Square root.Subtraction.Sum.Tangent.Hyperbolic tangent.Unit in the last place.Returns the value with the specified precision.Lambert W function.Lambert W function for the specified branch.
-
Constructor Details
-
FixedPrecisionApcomplexHelper
Constructs an apcomplex fixed-precison helper with the specified precision. The results of all mathematical operations are set to the specified precision.- Parameters:
precision
- The precision of the results.- Throws:
IllegalArgumentException
- In case the precision is invalid.
-
-
Method Details
-
valueOf
Returns the value with the specified precision.- Parameters:
z
- The value.- Returns:
- The value with to the specified precision.
- Throws:
ApfloatRuntimeException
-
negate
Negation.- Parameters:
z
- The value to negate.- Returns:
-z
.- Throws:
ApfloatRuntimeException
-
conj
Complex conjugate.- Parameters:
z
- The operand.- Returns:
x - i y
wherez
isx + i y
.- Throws:
ApfloatRuntimeException
-
add
Addition.- Parameters:
z
- The first operand.w
- The second operand.- Returns:
z + w
.- Throws:
ApfloatRuntimeException
-
subtract
Subtraction.- Parameters:
z
- The first operand.w
- The second operand.- Returns:
z - w
.- Throws:
ApfloatRuntimeException
-
multiply
Multiplication.- Parameters:
z
- The first operand.w
- The second operand.- Returns:
z * w
.- Throws:
ApfloatRuntimeException
-
divide
public Apcomplex divide(Apcomplex z, Apcomplex w) throws ArithmeticException, ApfloatRuntimeExceptionDivision.- Parameters:
z
- The first operand.w
- The second operand.- Returns:
z / w
.- Throws:
ArithmeticException
- Ifw
is zero.ApfloatRuntimeException
-
pow
Power.- Parameters:
z
- The first operand.w
- The second operand.- Returns:
zw
.- Throws:
ArithmeticException
- Ifz
andw
are zero.ApfloatRuntimeException
-
pow
Integer power.- Parameters:
z
- The first operand.n
- The first operand.- Returns:
zn
.- Throws:
ArithmeticException
- Ifz
andn
are zero, orz
is zero andn
is negative.ApfloatRuntimeException
-
arg
Complex angle.- Parameters:
z
- The operand.- Returns:
- The angle of
z
on the complex plane. - Throws:
ArithmeticException
- Ifz
is zero.ApfloatRuntimeException
-
imag
Imaginary part.- Parameters:
z
- The operand.- Returns:
- The imaginary part of
z
.
-
real
Real part.- Parameters:
z
- The operand.- Returns:
- The real part of
z
.
-
abs
Absolute value.- Parameters:
z
- The operand.- Returns:
- The absolute value of
z
. - Throws:
ApfloatRuntimeException
-
norm
Norm.- Parameters:
z
- The operand.- Returns:
x2 + y2
wherez
isx + i y
.- Throws:
ApfloatRuntimeException
-
acos
Arc cosine.- Parameters:
z
- The operand.- Returns:
- The arc cosine of
z
. - Throws:
ApfloatRuntimeException
-
acosh
Hyperbolic arc cosine.- Parameters:
z
- The operand.- Returns:
- The hyperbolic arc cosine of
z
. - Throws:
ApfloatRuntimeException
-
asin
Arc sine.- Parameters:
z
- The operand.- Returns:
- The arc sine of
z
. - Throws:
ApfloatRuntimeException
-
asinh
Hyperbolic arc sine.- Parameters:
z
- The operand.- Returns:
- The hyperbolic arc sine of
z
. - Throws:
ApfloatRuntimeException
-
atan
Arc tangent.- Parameters:
z
- The operand.- Returns:
- The arc tangent of
z
. - Throws:
ArithmeticException
- Ifz
isi
.ApfloatRuntimeException
-
atanh
Hyperbolic arc tangent.- Parameters:
z
- The operand.- Returns:
- The hyperbolic arc tangent of
z
. - Throws:
ArithmeticException
- Ifz
is 1 or -1.ApfloatRuntimeException
-
cbrt
Cube root.- Parameters:
z
- The operand.- Returns:
- The cube root of
z
. - Throws:
ApfloatRuntimeException
-
cos
Cosine.- Parameters:
z
- The operand.- Returns:
- The cosine of
z
. - Throws:
ApfloatRuntimeException
-
cosh
Hyperbolic cosine.- Parameters:
z
- The operand.- Returns:
- The hyperbolic cosine of
z
. - Throws:
ApfloatRuntimeException
-
exp
Exponential function.- Parameters:
z
- The operand.- Returns:
ez
.- Throws:
ApfloatRuntimeException
-
log
Natural logarithm.- Parameters:
z
- The operand.- Returns:
- The natural logarithm of
z
. - Throws:
ArithmeticException
- Ifz
is zero.ApfloatRuntimeException
-
log
Logarithm in specified base.- Parameters:
z
- The operand.w
- The base.- Returns:
- The base-
w
logarithm ofz
. - Throws:
ArithmeticException
- Ifz
orw
is zero.ApfloatRuntimeException
- Since:
- 1.6
-
sin
Sine.- Parameters:
z
- The operand.- Returns:
- The sine of
z
. - Throws:
ApfloatRuntimeException
-
sinh
Hyperbolic sine.- Parameters:
z
- The operand.- Returns:
- The hyperbolic sine of
z
. - Throws:
ApfloatRuntimeException
-
sqrt
Square root.- Parameters:
z
- The operand.- Returns:
- The square root of
z
. - Throws:
ApfloatRuntimeException
-
tan
Tangent.- Parameters:
z
- The operand.- Returns:
- The tangent of
z
. - Throws:
ArithmeticException
- Ifz
is π/2 + n π where n is an integer.ApfloatRuntimeException
-
tanh
Hyperbolic tangent.- Parameters:
z
- The operand.- Returns:
- The hyperbolic tangent of
z
. - Throws:
ArithmeticException
- Ifz
is i (π/2 + n π) where n is an integer.ApfloatRuntimeException
-
agm
Arithmetic-geometric mean.- Parameters:
a
- The first operand.b
- The first operand.- Returns:
- The arithmetic-geometric mean of
a
andb
. - Throws:
ApfloatRuntimeException
-
inverseRoot
public Apcomplex inverseRoot(Apcomplex z, long n) throws ArithmeticException, ApfloatRuntimeExceptionInverse root.- Parameters:
z
- The operand.n
- Which inverse root to take.- Returns:
z-1/n
.- Throws:
ArithmeticException
- Ifz
orn
is zero.ApfloatRuntimeException
-
inverseRoot
public Apcomplex inverseRoot(Apcomplex z, long n, long k) throws ArithmeticException, ApfloatRuntimeExceptionInverse root with branch.- Parameters:
z
- The operand.n
- Which inverse root to take.k
- Which branch to take.- Returns:
z-1/ne-i2πk/n
.- Throws:
ArithmeticException
- Ifz
orn
is zero.ApfloatRuntimeException
-
root
Root.- Parameters:
z
- The operand.n
- Which root to take.- Returns:
z1/n
.- Throws:
ArithmeticException
- Ifn
is zero, orz
is zero andn
is negative.ApfloatRuntimeException
-
root
public Apcomplex root(Apcomplex z, long n, long k) throws ArithmeticException, ApfloatRuntimeExceptionRoot with branch.- Parameters:
z
- The operand.n
- Which root to take.k
- Which branch to take.- Returns:
z1/nei2πsk/n
wheres
is the signum of the imaginary part ofz
.- Throws:
ArithmeticException
- Ifn
is zero, orz
is zero andn
is negative.ApfloatRuntimeException
-
allRoots
public Apcomplex[] allRoots(Apcomplex z, int n) throws ArithmeticException, ApfloatRuntimeExceptionAll branches of a root.- Parameters:
z
- The operand.n
- Which root to take.- Returns:
z1/n
.- Throws:
ArithmeticException
- Ifn
is zero, orz
is zero andn
is negative.ApfloatRuntimeException
-
scale
Move the radix point.- Parameters:
z
- The operand.scale
- The amount to move the radix point.- Returns:
z * z.radix()scale
.- Throws:
ApfloatRuntimeException
-
w
Lambert W function.- Parameters:
z
- The operand.- Returns:
W0(z)
.- Throws:
ApfloatRuntimeException
- Since:
- 1.8.0
-
w
Lambert W function for the specified branch.- Parameters:
z
- The operand.k
- The branch.- Returns:
Wk(z)
.- Throws:
ApfloatRuntimeException
- Since:
- 1.8.0
-
product
Product.- Parameters:
z
- The operand(s).- Returns:
- The product of the operands.
- Throws:
ApfloatRuntimeException
-
sum
Sum.- Parameters:
z
- The operand(s).- Returns:
- The sum of the operands.
- Throws:
ApfloatRuntimeException
-
gamma
Gamma function.- Parameters:
z
- The operand.- Returns:
Γ(z)
.- Throws:
ArithmeticException
- Ifz
is a nonpositive integer.ApfloatRuntimeException
- Since:
- 1.9.0
-
gamma
public Apcomplex gamma(Apcomplex a, Apcomplex z) throws ArithmeticException, ApfloatRuntimeExceptionIncomplete gamma function.- Parameters:
a
- The first operand.z
- The second operand.- Returns:
Γ(a, z)
.- Throws:
ArithmeticException
- Ifa
is a nonpositive integer andz
is zero.ApfloatRuntimeException
- Since:
- 1.10.0
-
gamma
public Apcomplex gamma(Apcomplex a, Apcomplex z0, Apcomplex z1) throws ArithmeticException, ApfloatRuntimeExceptionGeneralized incomplete gamma function.- Parameters:
a
- The first operand.z0
- The second operand.z1
- The third operand.- Returns:
Γ(a, z0)
-Γ(a, z1)
.- Throws:
ArithmeticException
- Ifa
is a nonpositive integer and eitherz0
orz1
is zero.ApfloatRuntimeException
- Since:
- 1.10.0
-
ulp
Unit in the last place.- Parameters:
z
- The operand.- Returns:
- The unit in the last place.
- Throws:
ApfloatRuntimeException
- Since:
- 1.10.0
-
precision
public long precision()Returns the precision, which is used for the results.- Returns:
- The precision of the results.
-