Package fi.iki.jmtilli.javafastcomplex
Class ComplexBuffer
java.lang.Object
fi.iki.jmtilli.javafastcomplex.ComplexBuffer
- All Implemented Interfaces:
ComplexNumber,java.io.Serializable
public class ComplexBuffer extends java.lang.Object implements ComplexNumber, java.io.Serializable
A mutable complex number.
An instance of this class refers to a complex number the value of
which can be changed. This allows higher performance, as if the
value of the number can be changed, not that many small objects
need to be created.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description ComplexBuffer()Create a complex buffer that initially has zero real and imaginary parts.ComplexBuffer(double re)Create a complex buffer that initially the specified real part and zero as the imaginary part.ComplexBuffer(double re, double im)Create a complex buffer that initially has the specified real and imaginary partsComplexBuffer(ComplexNumber num)Create a complex buffer that initially stores the specified complex number.ComplexBuffer(ComplexNumberArray num, int j)Create a complex buffer that initially stores the specified complex number. -
Method Summary
Modifier and Type Method Description doubleabs()Calculate the absolute value of the complex number in this complex buffer.ComplexBufferacoshInPlace()Calculate the inverse hyperbolic cosine of the value of the buffer and store the result in this bufferComplexBufferacosInPlace()Calculate the inverse cosine of the value of the buffer and store the result in this bufferComplexBufferaddInPlace(double d)Add a real number to this buffer and store the result in this bufferComplexBufferaddInPlace(ComplexNumber c)Add another complex number to this buffer and store the result in this bufferComplexBufferaddInPlace(ComplexNumberArray c, int j)Add another complex number to this buffer and store the result in this bufferdoublearg()Calculate the argument of the complex number in this complex buffer.ComplexBufferasinhInPlace()Calculate the inverse hyperbolic sine of the value of the buffer and store the result in this bufferComplexBufferasinInPlace()Calculate the inverse sine of the value of the buffer and store the result in this bufferComplexBufferatanhInPlace()Calculate the inverse hyperbolic tangent of the value of the buffer and store the result in this bufferComplexBufferatanInPlace()Calculate the inverse tangent of the value of the buffer and store the result in this bufferComplexBufferconjugateInPlace()Calculate the conjugate of the value of this buffer and store the result in this bufferComplexBuffercoshInPlace()Calculate the hyperbolic cosine of the value of the buffer and store the result in this bufferComplexBuffercosInPlace()Calculate the cosine of the value of the buffer and store the result in this bufferComplexBufferdivideInPlace(double d)Divide the value of this complex buffer by a real number and store the result in this bufferComplexBufferdivideInPlace(ComplexNumber c)Divide the value of this complex buffer by another complex number and store the result in this bufferComplexBufferdivideInPlace(ComplexNumberArray c, int j)Divide the value of this complex buffer by another complex number and store the result in this bufferComplexBufferdivideReversedInPlace(double d)Divide a real number by the value of this complex buffer and store the result in this bufferComplexBufferdivideReversedInPlace(ComplexNumber c)Divide another complex number by the value of this complex buffer and store the result in this bufferComplexBufferdivideReversedInPlace(ComplexNumberArray c, int j)Divide another complex number by the value of this complex buffer and store the result in this bufferComplexBufferexpInPlace()Calculate the exponential of the value of this buffer and store the result in this bufferComplexBufferexpm1InPlace()Calculate exp(this)-1 and store the result in this bufferComplexget()Get the value of this complex buffer as an immutable objectdoublegetImag()Returns the imaginary part of the complex number.doublegetReal()Returns the real part of the complex number.ComplexBufferinvertInPlace()Calculate the inverse of the value of this buffer and store the result in this bufferbooleanisInfinite()Check whether the complex number in this buffer is infinite.booleanisNaN()Check whether the complex number in this buffer is NaN (not-a-numer).ComplexBufferlog1pInPlace()Calculate the logarithm of 1 added to the value of this buffer and store the result in this bufferComplexBufferlogInPlace()Calculate the logarithm of the value of this buffer and store the result in this bufferComplexBuffermultiplyInPlace(double d)Multiply the value of this complex buffer by a real number and store the result in this bufferComplexBuffermultiplyInPlace(int i)Multiply the value of this complex buffer by an integer and store the result in this bufferComplexBuffermultiplyInPlace(ComplexNumber c)Multiply the value of this complex buffer by another complex number and store the result in this bufferComplexBuffermultiplyInPlace(ComplexNumberArray c, int j)Multiply the value of this complex buffer by another complex number and store the result in this bufferComplexBuffernegateInPlace()Negate the value of this buffer and store the result in this bufferComplexBufferpowInPlace(double b)Raise this complex number to a real power and store the result in this bufferComplexBufferpowInPlace(ComplexNumber b)Raise this complex number to a complex power and store the result in this bufferComplexBufferpowInPlace(ComplexNumberArray b, int j)Raise this complex number to a complex power and store the result in this bufferComplexBufferset(double re)Modify the real part of this complex buffer and set imaginary part to zero.ComplexBufferset(double re, double im)Modify the real and imaginary parts of this complex bufferComplexBufferset(ComplexNumber num)Modify the value of this complex bufferComplexBufferset(ComplexNumberArray num, int j)Modify the value of this complex bufferComplexBuffersinhInPlace()Calculate the hyperbolic sine of the value of the buffer and store the result in this bufferComplexBuffersinInPlace()Calculate the sine of the value of the buffer and store the result in this bufferComplexBuffersqrtInPlace()Calculate the square root of the value of this buffer and store the result in this bufferComplexBuffersubtractInPlace(double d)Subtract a real number from this buffer and store the result in this bufferComplexBuffersubtractInPlace(ComplexNumber c)Subtract another complex number from this buffer and store the result in this bufferComplexBuffersubtractInPlace(ComplexNumberArray c, int j)Subtract another complex number from this buffer and store the result in this bufferComplexBuffersubtractReversedInPlace(double d)Subtract the value of this buffer from a real number and store the result in this bufferComplexBuffersubtractReversedInPlace(ComplexNumber c)Subtract the value of this buffer from another complex number and store the result in this bufferComplexBuffersubtractReversedInPlace(ComplexNumberArray c, int j)Subtract the value of this buffer from another complex number and store the result in this bufferComplexBuffertanhInPlace()Calculate the hyperbolic tangent of the value of the buffer and store the result in this bufferComplexBuffertanInPlace()Calculate the tangent of the value of the buffer and store the result in this bufferjava.lang.StringtoString()Returns a String representation of the complex number in this complex buffer.
-
Constructor Details
-
ComplexBuffer
Create a complex buffer that initially stores the specified complex number.- Parameters:
num- The specified complex number
-
ComplexBuffer
Create a complex buffer that initially stores the specified complex number.- Parameters:
num- The specified complex numberarrayj- The array inex
-
ComplexBuffer
public ComplexBuffer()Create a complex buffer that initially has zero real and imaginary parts. -
ComplexBuffer
public ComplexBuffer(double re)Create a complex buffer that initially the specified real part and zero as the imaginary part.- Parameters:
re- The initial real part
-
ComplexBuffer
public ComplexBuffer(double re, double im)Create a complex buffer that initially has the specified real and imaginary parts- Parameters:
re- The initial real partim- The initial imaginary part
-
-
Method Details
-
set
Modify the real part of this complex buffer and set imaginary part to zero.- Parameters:
re- The new real part- Returns:
- this
-
set
Modify the real and imaginary parts of this complex buffer- Parameters:
re- The new real partim- The new imaginary part- Returns:
- this
-
set
Modify the value of this complex buffer- Parameters:
num- The new value- Returns:
- this
-
set
Modify the value of this complex buffer- Parameters:
num- The new value arrayj- The array index- Returns:
- this
-
get
Get the value of this complex buffer as an immutable object- Returns:
- A new immutable complex number that has the same value as this buffer
-
addInPlace
Add another complex number to this buffer and store the result in this buffer- Parameters:
c- The other complex number- Returns:
- this
-
addInPlace
Add another complex number to this buffer and store the result in this buffer- Parameters:
c- The other complex number arrayj- The array index- Returns:
- this
-
addInPlace
Add a real number to this buffer and store the result in this buffer- Parameters:
d- The real number- Returns:
- this
-
subtractInPlace
Subtract another complex number from this buffer and store the result in this buffer- Parameters:
c- The other complex number- Returns:
- this
-
subtractInPlace
Subtract another complex number from this buffer and store the result in this buffer- Parameters:
c- The other complex number arrayj- The array index- Returns:
- this
-
subtractInPlace
Subtract a real number from this buffer and store the result in this buffer- Parameters:
d- The real number- Returns:
- this
-
subtractReversedInPlace
Subtract the value of this buffer from another complex number and store the result in this buffer- Parameters:
c- The other complex number- Returns:
- this
-
subtractReversedInPlace
Subtract the value of this buffer from another complex number and store the result in this buffer- Parameters:
c- The other complex number arrayj- The array index- Returns:
- this
-
subtractReversedInPlace
Subtract the value of this buffer from a real number and store the result in this buffer- Parameters:
d- The real number- Returns:
- this
-
negateInPlace
Negate the value of this buffer and store the result in this buffer- Returns:
- this
-
conjugateInPlace
Calculate the conjugate of the value of this buffer and store the result in this buffer- Returns:
- this
-
invertInPlace
Calculate the inverse of the value of this buffer and store the result in this buffer- Returns:
- this
-
sqrtInPlace
Calculate the square root of the value of this buffer and store the result in this buffer- Returns:
- this
-
expInPlace
Calculate the exponential of the value of this buffer and store the result in this buffer- Returns:
- this
-
logInPlace
Calculate the logarithm of the value of this buffer and store the result in this buffer- Returns:
- this
-
log1pInPlace
Calculate the logarithm of 1 added to the value of this buffer and store the result in this buffer- Returns:
- this
-
expm1InPlace
Calculate exp(this)-1 and store the result in this buffer- Returns:
- this
-
acoshInPlace
Calculate the inverse hyperbolic cosine of the value of the buffer and store the result in this buffer- Returns:
- this
-
asinhInPlace
Calculate the inverse hyperbolic sine of the value of the buffer and store the result in this buffer- Returns:
- this
-
atanhInPlace
Calculate the inverse hyperbolic tangent of the value of the buffer and store the result in this buffer- Returns:
- this
-
acosInPlace
Calculate the inverse cosine of the value of the buffer and store the result in this buffer- Returns:
- this
-
asinInPlace
Calculate the inverse sine of the value of the buffer and store the result in this buffer- Returns:
- this
-
atanInPlace
Calculate the inverse tangent of the value of the buffer and store the result in this buffer- Returns:
- this
-
cosInPlace
Calculate the cosine of the value of the buffer and store the result in this buffer- Returns:
- this
-
sinInPlace
Calculate the sine of the value of the buffer and store the result in this buffer- Returns:
- this
-
tanInPlace
Calculate the tangent of the value of the buffer and store the result in this buffer- Returns:
- this
-
coshInPlace
Calculate the hyperbolic cosine of the value of the buffer and store the result in this buffer- Returns:
- this
-
sinhInPlace
Calculate the hyperbolic sine of the value of the buffer and store the result in this buffer- Returns:
- this
-
tanhInPlace
Calculate the hyperbolic tangent of the value of the buffer and store the result in this buffer- Returns:
- this
-
powInPlace
Raise this complex number to a real power and store the result in this buffer- Parameters:
b- The real power- Returns:
- this
-
powInPlace
Raise this complex number to a complex power and store the result in this buffer- Parameters:
b- The complex power- Returns:
- this
-
powInPlace
Raise this complex number to a complex power and store the result in this buffer- Parameters:
b- The complex power arrayj- The array index- Returns:
- this
-
multiplyInPlace
Multiply the value of this complex buffer by another complex number and store the result in this buffer- Parameters:
c- The other complex number- Returns:
- this
-
multiplyInPlace
Multiply the value of this complex buffer by another complex number and store the result in this buffer- Parameters:
c- The other complex number arrayj- The array index- Returns:
- this
-
multiplyInPlace
Multiply the value of this complex buffer by a real number and store the result in this buffer- Parameters:
d- The real number- Returns:
- this
-
multiplyInPlace
Multiply the value of this complex buffer by an integer and store the result in this buffer- Parameters:
i- The integer- Returns:
- this
-
divideInPlace
Divide the value of this complex buffer by another complex number and store the result in this buffer- Parameters:
c- The other complex number- Returns:
- this
-
divideInPlace
Divide the value of this complex buffer by another complex number and store the result in this buffer- Parameters:
c- The other complex number arrayj- The array index- Returns:
- this
-
divideInPlace
Divide the value of this complex buffer by a real number and store the result in this buffer- Parameters:
d- The real number- Returns:
- this
-
divideReversedInPlace
Divide another complex number by the value of this complex buffer and store the result in this buffer- Parameters:
c- The other complex number- Returns:
- this
-
divideReversedInPlace
Divide another complex number by the value of this complex buffer and store the result in this buffer- Parameters:
c- The other complex number arrayj- The array index- Returns:
- this
-
divideReversedInPlace
Divide a real number by the value of this complex buffer and store the result in this buffer- Parameters:
d- The real number- Returns:
- this
-
getReal
public double getReal()Returns the real part of the complex number.- Specified by:
getRealin interfaceComplexNumber- Returns:
- The real part
-
getImag
public double getImag()Returns the imaginary part of the complex number.- Specified by:
getImagin interfaceComplexNumber- Returns:
- The imaginary part
-
abs
public double abs()Calculate the absolute value of the complex number in this complex buffer.- Specified by:
absin interfaceComplexNumber- Returns:
- x≥0 The absolute value
-
arg
public double arg()Calculate the argument of the complex number in this complex buffer. The argument is the angle between the positive real axis and the point that represents this number in the complex plane.- Specified by:
argin interfaceComplexNumber- Returns:
- -pi≤x≤pi The argument
-
isNaN
public boolean isNaN()Check whether the complex number in this buffer is NaN (not-a-numer). A complex number is considered NaN if either the real or the imaginary part is NaN.- Specified by:
isNaNin interfaceComplexNumber- Returns:
- Whether the complex number in this buffer is NaN
-
isInfinite
public boolean isInfinite()Check whether the complex number in this buffer is infinite. A complex number is considered infinite if either the real or the imaginary part is infinite. If either the real of imaginary part is NaN, the number is not considered infinite, so isNaN() and isInfinite() cannot be true at the same time.- Specified by:
isInfinitein interfaceComplexNumber- Returns:
- Whether the complex number in this buffer is infinite
-
toString
public java.lang.String toString()Returns a String representation of the complex number in this complex buffer.- Specified by:
toStringin interfaceComplexNumber- Overrides:
toStringin classjava.lang.Object- Returns:
- "NaN" if NaN
re if purely real
im + "i" if purely imaginary
re " + " + im + "i" if imaginary part positive
re " - " + (-im) + "i" if imaginary part negative
-