Class JxnComplexArrayAlgebra
- java.lang.Object
-
- JxnComplexArrayAlgebra
-
- All Implemented Interfaces:
JxnCloneableAlgebra
public class JxnComplexArrayAlgebra extends Object implements JxnCloneableAlgebra
Implementation of a complex array algebra. Stores real and imaginary part in double precision arrays. Most of the methods perform element-wise operations on pairs of the array elements. Supports mixed operations withdouble
,JxnComplexAlgebra
andJxnRealArrayAlgebra
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JxnComplexArrayAlgebra()
JxnComplexArrayAlgebra(double re)
Creates a complex array instance for a single real valuere
(the imaginary part is 0).JxnComplexArrayAlgebra(double[] re)
Creates a complex array instance from a double arrayre
(the imaginary part is 0.).JxnComplexArrayAlgebra(double[] re, boolean copyInput)
Creates a complex array instance from a double arrayre
.JxnComplexArrayAlgebra(double[] re, double[] im)
Creates a complex array instance from two double arraysre
andim
.JxnComplexArrayAlgebra(double[] re, double[] im, boolean copyInput)
Creates a complex array instance from two double arraysre
andim
.JxnComplexArrayAlgebra(int[] re)
Creates a complex array instance an int array forre
.JxnComplexArrayAlgebra(JxnComplexAlgebra cx)
Creates a complex array instance for a single complex valuecx = re + j im
.JxnComplexArrayAlgebra(JxnComplexAlgebra[] cxa)
Creates a complex array instance from an array ofJxnComplexAlgebra
.JxnComplexArrayAlgebra(JxnComplexAlgebra cx, JxnRealArrayAlgebra ra)
Creates a complex array instance forcx * ra
.JxnComplexArrayAlgebra(JxnComplexArrayAlgebra z)
Creates a copy ofz
.JxnComplexArrayAlgebra(JxnRealArrayAlgebra re)
Creates a complex array instance forre
.JxnComplexArrayAlgebra(JxnRealArrayAlgebra ra, JxnComplexAlgebra cx)
Creates a complex array instance forra * cx
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JxnRealArrayAlgebra
abs(JxnComplexArrayAlgebra z)
Return the magnitude of each element of the internal array ofz
.JxnComplexArrayAlgebra
add(double d)
Addsd
to this.static JxnComplexArrayAlgebra
add(double d, JxnComplexArrayAlgebra caa)
Returnsd + caa
.JxnComplexArrayAlgebra
add(JxnComplexAlgebra cx)
Addscx
to this.JxnComplexArrayAlgebra
add(JxnComplexArrayAlgebra z)
Addsz
to this.JxnCloneableAlgebra
cloneThis()
Called internally.static JxnComplexArrayAlgebra
conj(JxnComplexArrayAlgebra z)
Return the conjugate complex for each element of the internal array ofz
.static JxnComplexArrayAlgebra
cos(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.cos(JxnComplexAlgebra)
for each element of the internal array ofz
.static JxnComplexArrayAlgebra
cosh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.cosh(JxnComplexAlgebra)
for each element of the internal array ofz
.JxnComplexArrayAlgebra
div(double d)
Divides this byd
.static JxnComplexArrayAlgebra
div(double d, JxnComplexArrayAlgebra caa)
Returnsd / caa
.JxnComplexArrayAlgebra
div(JxnComplexAlgebra cx)
Divides this bycx
.JxnComplexArrayAlgebra
div(JxnComplexArrayAlgebra z)
Divides this byz
.boolean
equals(Object other)
JxnComplexArrayAlgebra
objects are equal, if all corresponding array elements areequal
.static JxnComplexArrayAlgebra
exp(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.exp(JxnComplexAlgebra)
for each element of the internal array ofz
.JxnComplexAlgebra
get(double t)
Returns aJxnComplexAlgebra
for positiont
by linear interpolation of both real and imaginary part between the adjacent elements of the internal arrays of thisJxnComplexArrayAlgebra
.JxnComplexAlgebra
get(int i)
Return the ithe element of this.JxnComplexAlgebra[]
getComplexArray()
ReturnstoArray()
.JxnComplexAlgebra
getValue(double t)
Same asget(t)
.JxnComplexAlgebra
getValue(int i)
Same asget(i)
.JxnComplexAlgebra
getValue(JxnComplexArrayAlgebra caa, double t)
static JxnComplexAlgebra
getValue(JxnComplexArrayAlgebra caa, int i)
Return the ith element ofcaa
.static JxnRealArrayAlgebra
imag(JxnComplexArrayAlgebra z)
Returns the imaginary parts ofz
.JxnComplexArrayAlgebra
inv()
Replaces this by its reciprocal.static int
length(JxnComplexArrayAlgebra z)
Returns the length of the internal arrays ofz
.static JxnComplexArrayAlgebra
log(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.log(JxnComplexAlgebra)
for each element of the internal array ofz
.JxnComplexArrayAlgebra
mul(double d)
(Post)Multiplies this byd
.static JxnComplexArrayAlgebra
mul(double d, JxnComplexArrayAlgebra caa)
Returnsd * caa
.JxnComplexArrayAlgebra
mul(JxnComplexAlgebra cx)
(Post)Multiplies this bycx
.JxnComplexArrayAlgebra
mul(JxnComplexArrayAlgebra z)
(Post)Multiplies this byz
.JxnComplexArrayAlgebra
mulL(double d)
(Pre)Multiplies this byd
.static JxnRealArrayAlgebra
phi(JxnComplexArrayAlgebra z)
Returns the argument (phase angle) of each element of the internal array ofz
.static JxnRealArrayAlgebra
phiD(JxnComplexArrayAlgebra z)
Returns the argument (phase angle) in degrees of each element of the internal array ofz
.JxnComplexArrayAlgebra
pow(double exponent)
Replaces this by its power ofd
.JxnComplexArrayAlgebra
pow(JxnRealArrayAlgebra ra)
Replaces this by its power ofra
.static JxnRealArrayAlgebra
real(JxnComplexArrayAlgebra z)
Returns the real parts ofz
.static JxnComplexArrayAlgebra
sin(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sin(JxnComplexAlgebra)
for each element of the internal array ofz
.static JxnComplexArrayAlgebra
sinh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sinh(JxnComplexAlgebra)
for each element of the internal array ofz
.int
size()
Returns the length of the internal arrays.static JxnComplexArrayAlgebra
sqrt(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sqrt(JxnComplexAlgebra)
for each element of the internal array ofz
.JxnComplexArrayAlgebra
sub(double d)
Subtractsd
from this.static JxnComplexArrayAlgebra
sub(double d, JxnComplexArrayAlgebra caa)
Returnsd - caa
.JxnComplexArrayAlgebra
sub(JxnComplexAlgebra cx)
Subtractscx
from this.JxnComplexArrayAlgebra
sub(JxnComplexArrayAlgebra z)
Subtractsz
from this.static JxnComplexArrayAlgebra
tan(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.tan(JxnComplexAlgebra)
for each element of the internal array ofz
.static JxnComplexArrayAlgebra
tanh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.tanh(JxnComplexAlgebra)
for each element of the internal array ofz
.JxnComplexAlgebra[]
toArray()
Return this as an arry ofJxnComplexAlgebra
.String
toString()
-
-
-
Constructor Detail
-
JxnComplexArrayAlgebra
protected JxnComplexArrayAlgebra()
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(double re)
Creates a complex array instance for a single real valuere
(the imaginary part is 0).
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(JxnComplexAlgebra cx)
Creates a complex array instance for a single complex valuecx = re + j im
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(JxnRealArrayAlgebra re)
Creates a complex array instance forre
. The imaginary part is 0.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(double[] re, double[] im)
Creates a complex array instance from two double arraysre
andim
. CallsJxnComplexArrayAlgebra( re, im, false )
.
Note: This constructor exists for performance and memory reasons and stores references tore
andim
as the internal array representations. Consequently modifications of the array elements ofre
andim
modify the JxnRealArrayAlgebra object and vice versa. To store an independent internal copy of the external arrays useJxnRealArrayalgebra( re, im, true )
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(double[] re, double[] im, boolean copyInput)
Creates a complex array instance from two double arraysre
andim
.- Parameters:
copyInput
- if true, stores copies of the arraysre
andim
, otherwise stores references to the arraysre
andim
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(double[] re)
Creates a complex array instance from a double arrayre
(the imaginary part is 0.). CallsJxnComplexArrayAlgebra( re, false )
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(double[] re, boolean copyInput)
Creates a complex array instance from a double arrayre
. The imaginary part is 0.- Parameters:
copyInput
- if true, stores a copy of the arrayre
, otherwise stores a reference to the arrayre
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(int[] re)
Creates a complex array instance an int array forre
. The imaginary part is 0.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(JxnComplexAlgebra[] cxa)
Creates a complex array instance from an array ofJxnComplexAlgebra
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(JxnComplexArrayAlgebra z)
Creates a copy ofz
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(JxnComplexAlgebra cx, JxnRealArrayAlgebra ra)
Creates a complex array instance forcx * ra
.
-
JxnComplexArrayAlgebra
public JxnComplexArrayAlgebra(JxnRealArrayAlgebra ra, JxnComplexAlgebra cx)
Creates a complex array instance forra * cx
.
-
-
Method Detail
-
cloneThis
public JxnCloneableAlgebra cloneThis()
Description copied from interface:JxnCloneableAlgebra
Called internally. Required to avoid overwriting the left side operandopndLeft
inopndLeft op opndRght
, ifop
is implemented asopndLeft.op(opndRght)
and the instance methodop
modifies the instance.- Specified by:
cloneThis
in interfaceJxnCloneableAlgebra
- Returns:
- copy of this instance
-
size
public int size()
Returns the length of the internal arrays.
-
length
public static int length(JxnComplexArrayAlgebra z)
Returns the length of the internal arrays ofz
.
-
equals
public boolean equals(Object other)
JxnComplexArrayAlgebra
objects are equal, if all corresponding array elements areequal
.
-
add
public JxnComplexArrayAlgebra add(JxnComplexArrayAlgebra z)
Addsz
to this.
-
sub
public JxnComplexArrayAlgebra sub(JxnComplexArrayAlgebra z)
Subtractsz
from this.
-
mul
public JxnComplexArrayAlgebra mul(JxnComplexArrayAlgebra z)
(Post)Multiplies this byz
.
-
div
public JxnComplexArrayAlgebra div(JxnComplexArrayAlgebra z)
Divides this byz
.
-
inv
public JxnComplexArrayAlgebra inv()
Replaces this by its reciprocal.
-
add
public JxnComplexArrayAlgebra add(double d)
Addsd
to this.
-
sub
public JxnComplexArrayAlgebra sub(double d)
Subtractsd
from this.
-
mul
public JxnComplexArrayAlgebra mul(double d)
(Post)Multiplies this byd
.
-
mulL
public JxnComplexArrayAlgebra mulL(double d)
(Pre)Multiplies this byd
.
-
div
public JxnComplexArrayAlgebra div(double d)
Divides this byd
.
-
pow
public JxnComplexArrayAlgebra pow(double exponent)
Replaces this by its power ofd
.
-
add
public static JxnComplexArrayAlgebra add(double d, JxnComplexArrayAlgebra caa)
Returnsd + caa
.
-
sub
public static JxnComplexArrayAlgebra sub(double d, JxnComplexArrayAlgebra caa)
Returnsd - caa
.
-
mul
public static JxnComplexArrayAlgebra mul(double d, JxnComplexArrayAlgebra caa)
Returnsd * caa
.
-
div
public static JxnComplexArrayAlgebra div(double d, JxnComplexArrayAlgebra caa)
Returnsd / caa
.
-
add
public JxnComplexArrayAlgebra add(JxnComplexAlgebra cx)
Addscx
to this.
-
sub
public JxnComplexArrayAlgebra sub(JxnComplexAlgebra cx)
Subtractscx
from this.
-
mul
public JxnComplexArrayAlgebra mul(JxnComplexAlgebra cx)
(Post)Multiplies this bycx
.
-
div
public JxnComplexArrayAlgebra div(JxnComplexAlgebra cx)
Divides this bycx
.
-
pow
public JxnComplexArrayAlgebra pow(JxnRealArrayAlgebra ra)
Replaces this by its power ofra
.
-
abs
public static JxnRealArrayAlgebra abs(JxnComplexArrayAlgebra z)
Return the magnitude of each element of the internal array ofz
.- Returns:
- the result in a new
JxnRealArrayAlgebra
instance. - See Also:
JxnComplexAlgebra.abs(JxnComplexAlgebra)
-
phi
public static JxnRealArrayAlgebra phi(JxnComplexArrayAlgebra z)
Returns the argument (phase angle) of each element of the internal array ofz
.- Returns:
- the result in a new
JxnRealArrayAlgebra
instance. - See Also:
JxnComplexAlgebra.phi(JxnComplexAlgebra)
-
phiD
public static JxnRealArrayAlgebra phiD(JxnComplexArrayAlgebra z)
Returns the argument (phase angle) in degrees of each element of the internal array ofz
.- Returns:
- the result in a new
JxnRealArrayAlgebra
instance. - See Also:
JxnComplexAlgebra.phiD(JxnComplexAlgebra)
-
real
public static JxnRealArrayAlgebra real(JxnComplexArrayAlgebra z)
Returns the real parts ofz
.- Returns:
JxnRealArrayAlgebra
instance which shares a reference tore
(for an independent copy useJxnRealArrayAlgebra
( z.re, true)
-
imag
public static JxnRealArrayAlgebra imag(JxnComplexArrayAlgebra z)
Returns the imaginary parts ofz
.- Returns:
JxnRealArrayAlgebra
instance which shares a reference toim
(for an independent copy useJxnRealArrayAlgebra
( z.im, true)
-
conj
public static JxnComplexArrayAlgebra conj(JxnComplexArrayAlgebra z)
Return the conjugate complex for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
sqrt
public static JxnComplexArrayAlgebra sqrt(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sqrt(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
exp
public static JxnComplexArrayAlgebra exp(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.exp(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
log
public static JxnComplexArrayAlgebra log(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.log(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
sin
public static JxnComplexArrayAlgebra sin(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sin(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
cos
public static JxnComplexArrayAlgebra cos(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.cos(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
tan
public static JxnComplexArrayAlgebra tan(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.tan(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
sinh
public static JxnComplexArrayAlgebra sinh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sinh(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
cosh
public static JxnComplexArrayAlgebra cosh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.cosh(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
tanh
public static JxnComplexArrayAlgebra tanh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.tanh(JxnComplexAlgebra)
for each element of the internal array ofz
.- Returns:
- the result in a new
JxnComplexArrayAlgebra
instance.
-
get
public JxnComplexAlgebra get(int i)
Return the ithe element of this.
-
get
public JxnComplexAlgebra get(double t)
Returns aJxnComplexAlgebra
for positiont
by linear interpolation of both real and imaginary part between the adjacent elements of the internal arrays of thisJxnComplexArrayAlgebra
.
Fori <= t <= i+1
returnsre_t + j im_t
with
re_t = re[i] + ( t - i ) * ( re[i+1] - re[i] )
and
im_t = im[i] + ( t - i ) * ( im[i+1] - im[i] )
-
getValue
public JxnComplexAlgebra getValue(int i)
Same asget(i)
.
-
getValue
public static JxnComplexAlgebra getValue(JxnComplexArrayAlgebra caa, int i)
Return the ith element ofcaa
.
-
getValue
public JxnComplexAlgebra getValue(double t)
Same asget(t)
.
-
getValue
public JxnComplexAlgebra getValue(JxnComplexArrayAlgebra caa, double t)
-
getComplexArray
public JxnComplexAlgebra[] getComplexArray()
ReturnstoArray()
.
-
toArray
public JxnComplexAlgebra[] toArray()
Return this as an arry ofJxnComplexAlgebra
.
-
-