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,JxnComplexAlgebraandJxnRealArrayAlgebra.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJxnComplexArrayAlgebra()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 arraysreandim.JxnComplexArrayAlgebra(double[] re, double[] im, boolean copyInput)Creates a complex array instance from two double arraysreandim.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 JxnRealArrayAlgebraabs(JxnComplexArrayAlgebra z)Return the magnitude of each element of the internal array ofz.JxnComplexArrayAlgebraadd(double d)Addsdto this.static JxnComplexArrayAlgebraadd(double d, JxnComplexArrayAlgebra caa)Returnsd + caa.JxnComplexArrayAlgebraadd(JxnComplexAlgebra cx)Addscxto this.JxnComplexArrayAlgebraadd(JxnComplexArrayAlgebra z)Addszto this.JxnCloneableAlgebracloneThis()Called internally.static JxnComplexArrayAlgebraconj(JxnComplexArrayAlgebra z)Return the conjugate complex for each element of the internal array ofz.static JxnComplexArrayAlgebracos(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.cos(JxnComplexAlgebra)for each element of the internal array ofz.static JxnComplexArrayAlgebracosh(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.cosh(JxnComplexAlgebra)for each element of the internal array ofz.JxnComplexArrayAlgebradiv(double d)Divides this byd.static JxnComplexArrayAlgebradiv(double d, JxnComplexArrayAlgebra caa)Returnsd / caa.JxnComplexArrayAlgebradiv(JxnComplexAlgebra cx)Divides this bycx.JxnComplexArrayAlgebradiv(JxnComplexArrayAlgebra z)Divides this byz.booleanequals(Object other)JxnComplexArrayAlgebraobjects are equal, if all corresponding array elements areequal.static JxnComplexArrayAlgebraexp(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.exp(JxnComplexAlgebra)for each element of the internal array ofz.JxnComplexAlgebraget(double t)Returns aJxnComplexAlgebrafor positiontby linear interpolation of both real and imaginary part between the adjacent elements of the internal arrays of thisJxnComplexArrayAlgebra.JxnComplexAlgebraget(int i)Return the ithe element of this.JxnComplexAlgebra[]getComplexArray()ReturnstoArray().JxnComplexAlgebragetValue(double t)Same asget(t).JxnComplexAlgebragetValue(int i)Same asget(i).JxnComplexAlgebragetValue(JxnComplexArrayAlgebra caa, double t)static JxnComplexAlgebragetValue(JxnComplexArrayAlgebra caa, int i)Return the ith element ofcaa.static JxnRealArrayAlgebraimag(JxnComplexArrayAlgebra z)Returns the imaginary parts ofz.JxnComplexArrayAlgebrainv()Replaces this by its reciprocal.static intlength(JxnComplexArrayAlgebra z)Returns the length of the internal arrays ofz.static JxnComplexArrayAlgebralog(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.log(JxnComplexAlgebra)for each element of the internal array ofz.JxnComplexArrayAlgebramul(double d)(Post)Multiplies this byd.static JxnComplexArrayAlgebramul(double d, JxnComplexArrayAlgebra caa)Returnsd * caa.JxnComplexArrayAlgebramul(JxnComplexAlgebra cx)(Post)Multiplies this bycx.JxnComplexArrayAlgebramul(JxnComplexArrayAlgebra z)(Post)Multiplies this byz.JxnComplexArrayAlgebramulL(double d)(Pre)Multiplies this byd.static JxnRealArrayAlgebraphi(JxnComplexArrayAlgebra z)Returns the argument (phase angle) of each element of the internal array ofz.static JxnRealArrayAlgebraphiD(JxnComplexArrayAlgebra z)Returns the argument (phase angle) in degrees of each element of the internal array ofz.JxnComplexArrayAlgebrapow(double exponent)Replaces this by its power ofd.JxnComplexArrayAlgebrapow(JxnRealArrayAlgebra ra)Replaces this by its power ofra.static JxnRealArrayAlgebrareal(JxnComplexArrayAlgebra z)Returns the real parts ofz.static JxnComplexArrayAlgebrasin(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.sin(JxnComplexAlgebra)for each element of the internal array ofz.static JxnComplexArrayAlgebrasinh(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.sinh(JxnComplexAlgebra)for each element of the internal array ofz.intsize()Returns the length of the internal arrays.static JxnComplexArrayAlgebrasqrt(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.sqrt(JxnComplexAlgebra)for each element of the internal array ofz.JxnComplexArrayAlgebrasub(double d)Subtractsdfrom this.static JxnComplexArrayAlgebrasub(double d, JxnComplexArrayAlgebra caa)Returnsd - caa.JxnComplexArrayAlgebrasub(JxnComplexAlgebra cx)Subtractscxfrom this.JxnComplexArrayAlgebrasub(JxnComplexArrayAlgebra z)Subtractszfrom this.static JxnComplexArrayAlgebratan(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.tan(JxnComplexAlgebra)for each element of the internal array ofz.static JxnComplexArrayAlgebratanh(JxnComplexArrayAlgebra z)CallsJxnComplexAlgebra.tanh(JxnComplexAlgebra)for each element of the internal array ofz.JxnComplexAlgebra[]toArray()Return this as an arry ofJxnComplexAlgebra.StringtoString()
-
-
-
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 arraysreandim. CallsJxnComplexArrayAlgebra( re, im, false ).
Note: This constructor exists for performance and memory reasons and stores references toreandimas the internal array representations. Consequently modifications of the array elements ofreandimmodify 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 arraysreandim.- Parameters:
copyInput- if true, stores copies of the arraysreandim, otherwise stores references to the arraysreandim.
-
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:JxnCloneableAlgebraCalled internally. Required to avoid overwriting the left side operandopndLeftinopndLeft op opndRght, ifopis implemented asopndLeft.op(opndRght)and the instance methodopmodifies the instance.- Specified by:
cloneThisin 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)
JxnComplexArrayAlgebraobjects are equal, if all corresponding array elements areequal.
-
add
public JxnComplexArrayAlgebra add(JxnComplexArrayAlgebra z)
Addszto this.
-
sub
public JxnComplexArrayAlgebra sub(JxnComplexArrayAlgebra z)
Subtractszfrom 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)
Addsdto this.
-
sub
public JxnComplexArrayAlgebra sub(double d)
Subtractsdfrom 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)
Addscxto this.
-
sub
public JxnComplexArrayAlgebra sub(JxnComplexAlgebra cx)
Subtractscxfrom 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
JxnRealArrayAlgebrainstance. - 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
JxnRealArrayAlgebrainstance. - 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
JxnRealArrayAlgebrainstance. - See Also:
JxnComplexAlgebra.phiD(JxnComplexAlgebra)
-
real
public static JxnRealArrayAlgebra real(JxnComplexArrayAlgebra z)
Returns the real parts ofz.- Returns:
JxnRealArrayAlgebrainstance 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:
JxnRealArrayAlgebrainstance 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
JxnComplexArrayAlgebrainstance.
-
sqrt
public static JxnComplexArrayAlgebra sqrt(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sqrt(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
exp
public static JxnComplexArrayAlgebra exp(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.exp(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
log
public static JxnComplexArrayAlgebra log(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.log(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
sin
public static JxnComplexArrayAlgebra sin(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sin(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
cos
public static JxnComplexArrayAlgebra cos(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.cos(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
tan
public static JxnComplexArrayAlgebra tan(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.tan(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
sinh
public static JxnComplexArrayAlgebra sinh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.sinh(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
cosh
public static JxnComplexArrayAlgebra cosh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.cosh(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
tanh
public static JxnComplexArrayAlgebra tanh(JxnComplexArrayAlgebra z)
CallsJxnComplexAlgebra.tanh(JxnComplexAlgebra)for each element of the internal array ofz.- Returns:
- the result in a new
JxnComplexArrayAlgebrainstance.
-
get
public JxnComplexAlgebra get(int i)
Return the ithe element of this.
-
get
public JxnComplexAlgebra get(double t)
Returns aJxnComplexAlgebrafor positiontby linear interpolation of both real and imaginary part between the adjacent elements of the internal arrays of thisJxnComplexArrayAlgebra.
Fori <= t <= i+1returnsre_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.
-
-