jsci.maths.vectors
Class DoubleSparseVector
- java.lang.Object
-
- jsci.maths.vectors.MathVector
-
- jsci.maths.vectors.AbstractDoubleVector
-
- jsci.maths.vectors.DoubleSparseVector
-
- All Implemented Interfaces:
- java.io.Serializable, BanachSpace.Member, Module.Member, VectorSpace.Member, AbelianGroup.Member, Member
public final class DoubleSparseVector extends AbstractDoubleVector
The DoubleSparseVector class encapsulates sparse vectors. Uses Morse-coding.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description DoubleSparseVector(double[] array)Constructs a vector from an array.DoubleSparseVector(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.AbstractDoubleVectoradd(AbstractDoubleVector v)Returns the addition of this vector and another.DoubleSparseVectoradd(DoubleSparseVector v)Returns the addition of this vector and another.DoubleVectoradd(DoubleVector v)booleanequals(java.lang.Object obj, double tol)Compares two vectors for equality.doublegetComponent(int n)Returns a component of this vector.AbstractDoubleVectormapComponents(Mapping f)Applies a function on all the vector components.doublemass()Returns the mass.AbelianGroup.Membernegate()Returns the negative of this vector.doublenorm()Returns the l2-norm (magnitude).AbstractDoubleVectorscalarDivide(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.AbstractDoubleVectorscalarMultiply(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.doublescalarProduct(AbstractDoubleVector v)Returns the scalar product of this vector and another.doublescalarProduct(DoubleSparseVector v)Returns the scalar product of this vector and another.doublescalarProduct(DoubleVector v)voidsetComponent(int n, double x)Sets the value of a component of this vector.AbelianGroup.Membersubtract(AbelianGroup.Member v)Returns the subtraction of this vector by another.AbstractDoubleVectorsubtract(AbstractDoubleVector v)Returns the subtraction of this vector by another.DoubleSparseVectorsubtract(DoubleSparseVector v)Returns the subtraction of this vector by another.DoubleVectorsubtract(DoubleVector v)doublesumSquares()Returns the sum of the squares of the components.DoubleSparseMatrixtensorProduct(DoubleSparseVector v)Returns the tensor product of this vector and another.-
Methods inherited from class jsci.maths.vectors.AbstractDoubleVector
equals, getSet, hashCode, infNorm, norm, normalize, toString
-
Methods inherited from class jsci.maths.vectors.MathVector
dimension
-
-
-
-
Constructor Detail
-
DoubleSparseVector
public DoubleSparseVector(int dim)
Constructs an empty vector.- Parameters:
dim- the dimension of the vector.
-
DoubleSparseVector
public DoubleSparseVector(double[] array)
Constructs a vector from an array.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj, double tol)Compares two vectors for equality.- Overrides:
equalsin classAbstractDoubleVector- Parameters:
obj- a double sparse vector
-
getComponent
public double getComponent(int n)
Returns a component of this vector.- Specified by:
getComponentin classAbstractDoubleVector- Parameters:
n- index of the vector component- Throws:
VectorDimensionException- If attempting to access an invalid component.
-
setComponent
public void setComponent(int n, double x)Sets the value of a component of this vector.- Specified by:
setComponentin classAbstractDoubleVector- Parameters:
n- index of the vector componentx- a 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 classAbstractDoubleVector
-
sumSquares
public double sumSquares()
Returns the sum of the squares of the components.
-
mass
public double mass()
Returns the mass.- Overrides:
massin classAbstractDoubleVector
-
negate
public AbelianGroup.Member negate()
Returns the negative of this vector.
-
add
public AbelianGroup.Member add(AbelianGroup.Member v)
Returns the addition of this vector and another.- Parameters:
v- a group member
-
add
public AbstractDoubleVector add(AbstractDoubleVector v)
Returns the addition of this vector and another.- Specified by:
addin classAbstractDoubleVector- Parameters:
v- a double vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
add
public DoubleVector add(DoubleVector v)
-
add
public DoubleSparseVector add(DoubleSparseVector v)
Returns the addition of this vector and another.- Parameters:
v- a double sparse vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
subtract
public AbelianGroup.Member subtract(AbelianGroup.Member v)
Returns the subtraction of this vector by another.- Parameters:
v- a group member
-
subtract
public AbstractDoubleVector subtract(AbstractDoubleVector v)
Returns the subtraction of this vector by another.- Specified by:
subtractin classAbstractDoubleVector- Parameters:
v- a double vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
subtract
public DoubleVector subtract(DoubleVector v)
-
subtract
public DoubleSparseVector subtract(DoubleSparseVector v)
Returns the subtraction of this vector by another.- Parameters:
v- a double sparse vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
scalarMultiply
public Module.Member scalarMultiply(Ring.Member x)
Returns the multiplication of this vector by a scalar.- Parameters:
x- a ring member
-
scalarMultiply
public AbstractDoubleVector scalarMultiply(double x)
Returns the multiplication of this vector by a scalar.- Specified by:
scalarMultiplyin classAbstractDoubleVector- 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 AbstractDoubleVector scalarDivide(double x)
Returns the division of this vector by a scalar.- Specified by:
scalarDividein classAbstractDoubleVector- Parameters:
x- a double- Throws:
java.lang.ArithmeticException- If divide by zero.
-
scalarProduct
public double scalarProduct(AbstractDoubleVector v)
Returns the scalar product of this vector and another.- Specified by:
scalarProductin classAbstractDoubleVector- Parameters:
v- a double vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
scalarProduct
public double scalarProduct(DoubleVector v)
-
scalarProduct
public double scalarProduct(DoubleSparseVector v)
Returns the scalar product of this vector and another.- Parameters:
v- a double sparse vector- Throws:
VectorDimensionException- If the vectors are different sizes.
-
tensorProduct
public DoubleSparseMatrix tensorProduct(DoubleSparseVector v)
Returns the tensor product of this vector and another.
-
mapComponents
public AbstractDoubleVector mapComponents(Mapping f)
Applies a function on all the vector components.- Specified by:
mapComponentsin classAbstractDoubleVector- Parameters:
f- a user-defined function- Returns:
- a double sparse vector
-
-
DMelt 3.0 © DataMelt by jWork.ORG