Package fi.iki.jmtilli.javafastcomplex
Class ComplexBufferArray
java.lang.Object
fi.iki.jmtilli.javafastcomplex.ComplexBufferArray
- All Implemented Interfaces:
ComplexNumberArray,java.io.Serializable
public class ComplexBufferArray extends java.lang.Object implements ComplexNumberArray, java.io.Serializable
A mutable complex number array.
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 ComplexBufferArray(int size)Create a complex buffer array -
Method Summary
Modifier and Type Method Description doubleabs(int i)Calculate the absolute value of the complex number in this complex buffer.ComplexBufferArrayacoshInPlace(int i)Calculate the inverse hyperbolic cosine of the value of the buffer and store the result in this bufferComplexBufferArrayacosInPlace(int i)Calculate the inverse cosine of the value of the buffer and store the result in this bufferComplexBufferArrayaddInPlace(int i, double d)Add a real number to this buffer and store the result in this bufferComplexBufferArrayaddInPlace(int i, ComplexNumber c)Add another complex number to this buffer and store the result in this bufferComplexBufferArrayaddInPlace(int i, ComplexNumberArray c, int j)Add another complex number to this buffer and store the result in this bufferdoublearg(int i)Calculate the argument of the complex number in this complex buffer.ComplexBufferArrayasinhInPlace(int i)Calculate the inverse hyperbolic sine of the value of the buffer and store the result in this bufferComplexBufferArrayasinInPlace(int i)Calculate the inverse sine of the value of the buffer and store the result in this bufferComplexBufferArrayatanhInPlace(int i)Calculate the inverse hyperbolic tangent of the value of the buffer and store the result in this bufferComplexBufferArrayatanInPlace(int i)Calculate the inverse tangent of the value of the buffer and store the result in this bufferComplexBufferArrayconjugateInPlace(int i)Calculate the conjugate of the value of this buffer and store the result in this bufferComplexBufferArraycoshInPlace(int i)Calculate the hyperbolic cosine of the value of the buffer and store the result in this bufferComplexBufferArraycosInPlace(int i)Calculate the cosine of the value of the buffer and store the result in this bufferComplexBufferArraydivideInPlace(int i, double d)Divide the value of this complex buffer by a real number and store the result in this bufferComplexBufferArraydivideInPlace(int i, ComplexNumber c)Divide the value of this complex buffer by another complex number and store the result in this bufferComplexBufferArraydivideInPlace(int i, ComplexNumberArray c, int j)Divide the value of this complex buffer by another complex number and store the result in this bufferComplexBufferArraydivideReversedInPlace(int i, double d)Divide a real number by the value of this complex buffer and store the result in this bufferComplexBufferArraydivideReversedInPlace(int i, ComplexNumber c)Divide another complex number by the value of this complex buffer and store the result in this bufferComplexBufferArraydivideReversedInPlace(int i, ComplexNumberArray c, int j)Divide another complex number by the value of this complex buffer and store the result in this bufferComplexBufferArrayexpInPlace(int i)Calculate the exponential of the value of this buffer and store the result in this bufferComplexBufferArrayexpm1InPlace(int i)Calculate exp(this)-1 and store the result in this bufferComplexget(int i)Get the value of this complex buffer as an immutable objectdoublegetImag(int i)Returns the imaginary part of the complex number.doublegetReal(int i)Returns the real part of the complex number.ComplexBufferArrayinvertInPlace(int i)Calculate the inverse of the value of this buffer and store the result in this bufferbooleanisInfinite(int i)Check whether the complex number in this buffer is infinite.booleanisNaN(int i)Check whether the complex number in this buffer is NaN (not-a-numer).ComplexBufferArraylog1pInPlace(int i)Calculate the logarithm of 1 added to the value of this buffer and store the result in this bufferComplexBufferArraylogInPlace(int i)Calculate the logarithm of the value of this buffer and store the result in this bufferComplexBufferArraymultiplyInPlace(int i, double d)Multiply the value of this complex buffer by a real number and store the result in this bufferComplexBufferArraymultiplyInPlace(int i, int x)Multiply the value of this complex buffer by an integer and store the result in this bufferComplexBufferArraymultiplyInPlace(int i, ComplexNumber c)Multiply the value of this complex buffer by another complex number and store the result in this bufferComplexBufferArraymultiplyInPlace(int i, ComplexNumberArray c, int j)Multiply the value of this complex buffer by another complex number and store the result in this bufferComplexBufferArraynegateInPlace(int i)Negate the value of this buffer and store the result in this bufferComplexBufferArraypowInPlace(int i, double b)Raise this complex number to a real power and store the result in this bufferComplexBufferArraypowInPlace(int i, ComplexNumber b)Raise this complex number to a complex power and store the result in this bufferComplexBufferArraypowInPlace(int i, ComplexNumberArray b, int j)Raise this complex number to a complex power and store the result in this bufferComplexBufferArrayset(int i, double re)Modify the real part of this complex buffer and set imaginary part to zero.ComplexBufferArrayset(int i, double re, double im)Modify the real and imaginary parts of this complex bufferComplexBufferArrayset(int i, ComplexNumber num)Modify the value of this complex bufferComplexBufferArrayset(int i, ComplexNumberArray num, int j)Modify the value of this complex bufferComplexBufferArraysinhInPlace(int i)Calculate the hyperbolic sine of the value of the buffer and store the result in this bufferComplexBufferArraysinInPlace(int i)Calculate the sine of the value of the buffer and store the result in this bufferintsize()Returns the size of the array.ComplexBufferArraysqrtInPlace(int i)Calculate the square root of the value of this buffer and store the result in this bufferComplexBufferArraysubtractInPlace(int i, double d)Subtract a real number from this buffer and store the result in this bufferComplexBufferArraysubtractInPlace(int i, ComplexNumber c)Subtract another complex number from this buffer and store the result in this bufferComplexBufferArraysubtractInPlace(int i, ComplexNumberArray c, int j)Subtract another complex number from this buffer and store the result in this bufferComplexBufferArraysubtractReversedInPlace(int i, double d)Subtract the value of this buffer from a real number and store the result in this bufferComplexBufferArraysubtractReversedInPlace(int i, ComplexNumber c)Subtract the value of this buffer from another complex number and store the result in this bufferComplexBufferArraysubtractReversedInPlace(int i, ComplexNumberArray c, int j)Subtract the value of this buffer from another complex number and store the result in this bufferComplexBufferArraytanhInPlace(int i)Calculate the hyperbolic tangent of the value of the buffer and store the result in this bufferComplexBufferArraytanInPlace(int i)Calculate the tangent of the value of the buffer and store the result in this bufferjava.lang.StringtoString(int i)Returns a String representation of the complex number in this complex buffer.
-
Constructor Details
-
ComplexBufferArray
public ComplexBufferArray(int size)Create a complex buffer array- Parameters:
size- The size of the array
-
-
Method Details
-
size
public int size()Returns the size of the array.- Specified by:
sizein interfaceComplexNumberArray- Returns:
- The size
-
set
Modify the real part of this complex buffer and set imaginary part to zero.- Parameters:
i- The array indexre- The new real part- Returns:
- this
-
set
Modify the real and imaginary parts of this complex buffer- Parameters:
i- The array indexre- The new real partim- The new imaginary part- Returns:
- this
-
getReal
public double getReal(int i)Returns the real part of the complex number.- Specified by:
getRealin interfaceComplexNumberArray- Parameters:
i- The array index- Returns:
- The real part
-
getImag
public double getImag(int i)Returns the imaginary part of the complex number.- Specified by:
getImagin interfaceComplexNumberArray- Parameters:
i- The array index- Returns:
- The imaginary part
-
set
Modify the value of this complex buffer- Parameters:
i- The array indexnum- The new value- Returns:
- this
-
set
Modify the value of this complex buffer- Parameters:
i- The array indexnum- The new value arrayj- The array index to the other array- Returns:
- this
-
get
Get the value of this complex buffer as an immutable object- Parameters:
i- The array index- 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:
i- The array indexc- The other complex number- Returns:
- this
-
addInPlace
Add another complex number to this buffer and store the result in this buffer- Parameters:
i- The array indexc- The other complex number arrayj- The array index to the other array- Returns:
- this
-
addInPlace
Add a real number to this buffer and store the result in this buffer- Parameters:
i- The array indexd- The real number- Returns:
- this
-
subtractInPlace
Subtract another complex number from this buffer and store the result in this buffer- Parameters:
i- The array indexc- The other complex number- Returns:
- this
-
subtractInPlace
Subtract another complex number from this buffer and store the result in this buffer- Parameters:
i- The array indexc- The other complex number arrayj- The array index to the other array- Returns:
- this
-
subtractInPlace
Subtract a real number from this buffer and store the result in this buffer- Parameters:
i- The array indexd- The real number- Returns:
- this
-
subtractReversedInPlace
Subtract the value of this buffer from another complex number and store the result in this buffer- Parameters:
i- The array indexc- 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:
i- The array indexc- The other complex number arrayj- The array index to the other array- Returns:
- this
-
subtractReversedInPlace
Subtract the value of this buffer from a real number and store the result in this buffer- Parameters:
i- The array indexd- The real number- Returns:
- this
-
negateInPlace
Negate the value of this buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
conjugateInPlace
Calculate the conjugate of the value of this buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
invertInPlace
Calculate the inverse of the value of this buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
sqrtInPlace
Calculate the square root of the value of this buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
expInPlace
Calculate the exponential of the value of this buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
logInPlace
Calculate the logarithm of the value of this buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
log1pInPlace
Calculate the logarithm of 1 added to the value of this buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
expm1InPlace
Calculate exp(this)-1 and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
acoshInPlace
Calculate the inverse hyperbolic cosine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
asinhInPlace
Calculate the inverse hyperbolic sine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
atanhInPlace
Calculate the inverse hyperbolic tangent of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
acosInPlace
Calculate the inverse cosine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
asinInPlace
Calculate the inverse sine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
atanInPlace
Calculate the inverse tangent of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
cosInPlace
Calculate the cosine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
sinInPlace
Calculate the sine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
tanInPlace
Calculate the tangent of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
coshInPlace
Calculate the hyperbolic cosine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
sinhInPlace
Calculate the hyperbolic sine of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
tanhInPlace
Calculate the hyperbolic tangent of the value of the buffer and store the result in this buffer- Parameters:
i- The array index- Returns:
- this
-
powInPlace
Raise this complex number to a real power and store the result in this buffer- Parameters:
i- The array indexb- The real power- Returns:
- this
-
powInPlace
Raise this complex number to a complex power and store the result in this buffer- Parameters:
i- The array indexb- The complex power- Returns:
- this
-
powInPlace
Raise this complex number to a complex power and store the result in this buffer- Parameters:
i- The array indexb- The complex power arrayj- The array index to the other array- Returns:
- this
-
multiplyInPlace
Multiply the value of this complex buffer by another complex number and store the result in this buffer- Parameters:
i- The array indexc- 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:
i- The array indexc- The other complex number arrayj- The array index to the other array- Returns:
- this
-
multiplyInPlace
Multiply the value of this complex buffer by a real number and store the result in this buffer- Parameters:
i- The array indexd- 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 array indexx- The integer- Returns:
- this
-
divideInPlace
Divide the value of this complex buffer by another complex number and store the result in this buffer- Parameters:
i- The array indexc- 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:
i- The array indexc- The other complex number arrayj- The array index to the other array- Returns:
- this
-
divideInPlace
Divide the value of this complex buffer by a real number and store the result in this buffer- Parameters:
i- The array indexd- 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:
i- The array indexc- 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:
i- The array indexc- The other complex number arrayj- The array index to the other array- Returns:
- this
-
divideReversedInPlace
Divide a real number by the value of this complex buffer and store the result in this buffer- Parameters:
i- The array indexd- The real number- Returns:
- this
-
abs
public double abs(int i)Calculate the absolute value of the complex number in this complex buffer.- Specified by:
absin interfaceComplexNumberArray- Parameters:
i- The array index- Returns:
- x≥0 The absolute value
-
arg
public double arg(int i)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 interfaceComplexNumberArray- Parameters:
i- The array index- Returns:
- -pi≤x≤pi The argument
-
isNaN
public boolean isNaN(int i)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 interfaceComplexNumberArray- Parameters:
i- The array index- Returns:
- Whether the complex number in this buffer is NaN
-
isInfinite
public boolean isInfinite(int i)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 interfaceComplexNumberArray- Parameters:
i- The array index- Returns:
- Whether the complex number in this buffer is infinite
-
toString
public java.lang.String toString(int i)Returns a String representation of the complex number in this complex buffer.- Specified by:
toStringin interfaceComplexNumberArray- Parameters:
i- The array index- 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
-