jsci.maths.vectors
Class ComplexVector
- java.lang.Object
-
- jsci.maths.vectors.MathVector
-
- jsci.maths.vectors.AbstractComplexVector
-
- jsci.maths.vectors.ComplexVector
-
- All Implemented Interfaces:
- java.io.Serializable, BanachSpace.Member, HilbertSpace.Member, Module.Member, VectorSpace.Member, AbelianGroup.Member, Member
public class ComplexVector extends AbstractComplexVector
An array-based implementation of a complex vector.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description ComplexVector(Complex[] array)Constructs a vector from an array.ComplexVector(double[] real, double[] imag)Constructs a vector by wrapping two arrays.ComplexVector(int dim)Constructs an empty vector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbelianGroup.Memberadd(AbelianGroup.Member v)Returns the addition of this vector and another.AbstractComplexVectoradd(AbstractComplexVector v)Returns the addition of this vector and another.AbstractComplexVectoradd(AbstractDoubleVector v)Returns the addition of this vector and another.AbstractComplexVectoradd(AbstractIntegerVector v)Returns the addition of this vector and another.ComplexVectoradd(ComplexVector v)ComplexVectoradd(DoubleVector v)ComplexVectoradd(IntegerVector v)AbstractComplexVectorconjugate()Returns the complex conjugate of this vector.booleanequals(java.lang.Object a, double tol)Compares two complex vectors for equality.ComplexgetComponent(int n)Returns a component of this vector.doublegetImagComponent(int n)doublegetRealComponent(int n)AbstractDoubleVectorimag()Returns the imaginary part of this complex vector.doubleinfNorm()Returns the l
-norm.AbstractComplexVectormapComponents(ComplexMapping f)Applies a function on all the vector components.AbelianGroup.Membernegate()Returns the negative of this vector.doublenorm()Returns the l2-norm (magnitude).AbstractDoubleVectorreal()Returns the real part of this complex vector.AbstractComplexVectorscalarDivide(Complex z)Returns the division of this vector by a scalar.AbstractComplexVectorscalarDivide(double x)Returns the division of this vector by a scalar.VectorSpace.MemberscalarDivide(Field.Member x)Returns the division of this vector by a scalar.AbstractComplexVectorscalarMultiply(Complex z)Returns the multiplication of this vector by a scalar.AbstractComplexVectorscalarMultiply(double x)Returns the multiplication of this vector by a scalar.Module.MemberscalarMultiply(Ring.Member x)Returns the multiplication of this vector by a scalar.ComplexscalarProduct(AbstractComplexVector v)Returns the scalar product of this vector and another.ComplexscalarProduct(HilbertSpace.Member v)Returns the scalar product of this vector and another.voidsetComponent(int n, Complex z)Sets the value of a component of this vector.voidsetComponent(int n, double x, double y)Sets the value of a component of this vector.AbelianGroup.Membersubtract(AbelianGroup.Member v)Returns the subtraction of this vector by another.AbstractComplexVectorsubtract(AbstractComplexVector v)Returns the subtraction of this vector by another.AbstractComplexVectorsubtract(AbstractDoubleVector v)Returns the subtraction of this vector by another.AbstractComplexVectorsubtract(AbstractIntegerVector v)Returns the subtraction of this vector by another.ComplexVectorsubtract(ComplexVector v)ComplexVectorsubtract(DoubleVector v)ComplexVectorsubtract(IntegerVector v)java.lang.StringtoString()Returns a comma delimited string representing the value of this vector.-
Methods inherited from class jsci.maths.vectors.AbstractComplexVector
equals, getSet, hashCode, normalize
-
Methods inherited from class jsci.maths.vectors.MathVector
dimension
-
-
-
-
Constructor Detail
-
ComplexVector
public ComplexVector(int dim)
Constructs an empty vector.- Parameters:
dim- the dimension of the vector.
-
ComplexVector
public ComplexVector(double[] real, double[] imag)Constructs a vector by wrapping two arrays.- Parameters:
real- an array of real valuesimag- an array of imaginary values
-
ComplexVector
public ComplexVector(Complex[] array)
Constructs a vector from an array.- Parameters:
array- an assigned value
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object a, double tol)Compares two complex vectors for equality.- Overrides:
equalsin classAbstractComplexVector- Parameters:
a- a complex vector
-
toString
public java.lang.String toString()
Returns a comma delimited string representing the value of this vector.- Overrides:
toStringin classAbstractComplexVector
-
real
public AbstractDoubleVector real()
Returns the real part of this complex vector.- Specified by:
realin classAbstractComplexVector
-
imag
public AbstractDoubleVector imag()
Returns the imaginary part of this complex vector.- Specified by:
imagin classAbstractComplexVector
-
getComponent
public Complex getComponent(int n)
Returns a component of this vector.- Specified by:
getComponentin classAbstractComplexVector- Parameters:
n- index of the vector component- Throws:
VectorDimensionException- If attempting to access an invalid component.
-
getRealComponent
public double getRealComponent(int n)
- Specified by:
getRealComponentin classAbstractComplexVector
-
getImagComponent
public double getImagComponent(int n)
- Specified by:
getImagComponentin classAbstractComplexVector
-
setComponent
public void setComponent(int n, Complex z)Sets the value of a component of this vector. Should only be used to initialise this vector.- Specified by:
setComponentin classAbstractComplexVector- Parameters:
n- index of the vector componentz- a complex number- Throws:
VectorDimensionException- If attempting to access an invalid component.
-
setComponent
public void setComponent(int n, double x, double y)Sets the value of a component of this vector. Should only be used to initialise this vector.- Specified by:
setComponentin classAbstractComplexVector- Parameters:
n- index of the vector componentx- the real part of a complex numbery- the imaginary part of a complex number- Throws:
VectorDimensionException- If attempting to access an invalid component.
-
norm
public double norm()
Returns the l2-norm (magnitude).- Specified by:
normin interfaceBanachSpace.Member- Overrides:
normin classAbstractComplexVector
-
infNorm
public double infNorm()
Returns the l
-norm.- Overrides:
infNormin classAbstractComplexVector
-
negate
public AbelianGroup.Member negate()
Returns the negative of this vector.
-
conjugate
public AbstractComplexVector conjugate()
Returns the complex conjugate of this vector.- Specified by:
conjugatein classAbstractComplexVector
-
add
public AbelianGroup.Member add(AbelianGroup.Member v)
Returns the addition of this vector and another.- Parameters:
v- a group member
-
add
public AbstractComplexVector add(AbstractComplexVector v)
Returns the addition of this vector and another.- Specified by:
addin classAbstractComplexVector- Parameters:
v- a complex vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
add
public ComplexVector add(ComplexVector v)
-
add
public AbstractComplexVector add(AbstractDoubleVector v)
Returns the addition of this vector and another.- Parameters:
v- a double vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
add
public ComplexVector add(DoubleVector v)
-
add
public AbstractComplexVector add(AbstractIntegerVector v)
Returns the addition of this vector and another.- Parameters:
v- an integer vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
add
public ComplexVector add(IntegerVector v)
-
subtract
public AbelianGroup.Member subtract(AbelianGroup.Member v)
Returns the subtraction of this vector by another.- Parameters:
v- a group member
-
subtract
public AbstractComplexVector subtract(AbstractComplexVector v)
Returns the subtraction of this vector by another.- Specified by:
subtractin classAbstractComplexVector- Parameters:
v- a complex vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
subtract
public ComplexVector subtract(ComplexVector v)
-
subtract
public AbstractComplexVector subtract(AbstractDoubleVector v)
Returns the subtraction of this vector by another.- Parameters:
v- a double vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
subtract
public ComplexVector subtract(DoubleVector v)
-
subtract
public AbstractComplexVector subtract(AbstractIntegerVector v)
Returns the subtraction of this vector by another.- Parameters:
v- an integer vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
subtract
public ComplexVector subtract(IntegerVector v)
-
scalarMultiply
public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this vector by a scalar.- Parameters:
x- a ring member
-
scalarMultiply
public AbstractComplexVector scalarMultiply(Complex z)
Returns the multiplication of this vector by a scalar.- Specified by:
scalarMultiplyin classAbstractComplexVector- Parameters:
z- a complex number
-
scalarMultiply
public AbstractComplexVector scalarMultiply(double x)
Returns the multiplication of this vector by a scalar.- Specified by:
scalarMultiplyin classAbstractComplexVector- Parameters:
x- a double
-
scalarDivide
public VectorSpace.Member scalarDivide(Field.Member x)
Returns the division of this vector by a scalar.- Parameters:
x- a field member
-
scalarDivide
public AbstractComplexVector scalarDivide(Complex z)
Returns the division of this vector by a scalar.- Specified by:
scalarDividein classAbstractComplexVector- Parameters:
z- a complex number- Throws:
java.lang.ArithmeticException- If divide by zero.
-
scalarDivide
public AbstractComplexVector scalarDivide(double x)
Returns the division of this vector by a scalar.- Specified by:
scalarDividein classAbstractComplexVector- Parameters:
x- a double- Throws:
java.lang.ArithmeticException- If divide by zero.
-
scalarProduct
public Complex scalarProduct(HilbertSpace.Member v)
Returns the scalar product of this vector and another.- Parameters:
v- a Hilbert space vector
-
scalarProduct
public Complex scalarProduct(AbstractComplexVector v)
Returns the scalar product of this vector and another.- Specified by:
scalarProductin classAbstractComplexVector- Parameters:
v- a complex vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
mapComponents
public AbstractComplexVector mapComponents(ComplexMapping f)
Applies a function on all the vector components.- Specified by:
mapComponentsin classAbstractComplexVector- Parameters:
f- a user-defined function- Returns:
- a complex vector
-
-
DMelt 3.0 © DataMelt by jWork.ORG