jsci.maths.vectors
Class AbstractDoubleVector
- java.lang.Object
-
- jsci.maths.vectors.MathVector
-
- jsci.maths.vectors.AbstractDoubleVector
-
- All Implemented Interfaces:
- java.io.Serializable, BanachSpace.Member, Module.Member, VectorSpace.Member, AbelianGroup.Member, Member
- Direct Known Subclasses:
- Double2Vector, Double3Vector, DoubleSparseVector, DoubleVector
public abstract class AbstractDoubleVector extends MathVector implements BanachSpace.Member
The AbstractDoubleVector class encapsulates vectors containing doubles.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract AbstractDoubleVectoradd(AbstractDoubleVector v)Returns the addition of this vector and another.booleanequals(java.lang.Object obj)Compares two double vectors for equality.booleanequals(java.lang.Object obj, double tol)abstract doublegetComponent(int n)Returns a component of this vector.java.lang.ObjectgetSet()inthashCode()Returns a hashcode for this vector.doubleinfNorm()Returns the l
-norm.abstract AbstractDoubleVectormapComponents(Mapping f)Applies a function on all the vector components.doublemass()Returns the mass (l1-norm).doublenorm()Returns the l2-norm (magnitude).doublenorm(int n)Returns the ln-norm.AbstractDoubleVectornormalize()Returns a normalised vector (a vector with norm equal to one).abstract AbstractDoubleVectorscalarDivide(double x)Returns the division of this vector by a scalar.abstract AbstractDoubleVectorscalarMultiply(double x)Returns the multiplication of this vector by a scalar.abstract doublescalarProduct(AbstractDoubleVector v)Returns the scalar product of this vector and another.abstract voidsetComponent(int n, double x)Sets the value of a component of this vector.abstract AbstractDoubleVectorsubtract(AbstractDoubleVector v)Returns the subtraction of this vector by another.java.lang.StringtoString()Returns a comma delimited string representing the value of this vector.-
Methods inherited from class jsci.maths.vectors.MathVector
dimension
-
Methods inherited from interface jsci.maths.algebras.VectorSpace.Member
scalarDivide
-
Methods inherited from interface jsci.maths.algebras.Module.Member
scalarMultiply
-
Methods inherited from interface jsci.maths.groups.AbelianGroup.Member
add, negate, subtract
-
-
-
-
Method Detail
-
equals
public final boolean equals(java.lang.Object obj)
Compares two double vectors for equality. Two vectors are considered to be equal if the norm of their difference is within the zero tolerance.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- a double vector
-
equals
public boolean equals(java.lang.Object obj, double tol)
-
toString
public java.lang.String toString()
Returns a comma delimited string representing the value of this vector.- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
Returns a hashcode for this vector.- Overrides:
hashCodein classjava.lang.Object
-
getComponent
public abstract double getComponent(int n)
Returns a component of this vector.- Parameters:
n- index of the vector component.- Throws:
VectorDimensionException- If attempting to access an invalid component.
-
setComponent
public abstract void setComponent(int n, double x)Sets the value of a component of this vector.- Parameters:
n- index of the vector component.x- a number.- Throws:
VectorDimensionException- If attempting to access an invalid component.
-
norm
public double norm(int n)
Returns the ln-norm.
-
norm
public double norm()
Returns the l2-norm (magnitude).- Specified by:
normin interfaceBanachSpace.Member- Specified by:
normin classMathVector
-
infNorm
public double infNorm()
Returns the l
-norm.
-
mass
public double mass()
Returns the mass (l1-norm).
-
add
public abstract AbstractDoubleVector add(AbstractDoubleVector v)
Returns the addition of this vector and another.- Parameters:
v- a double vector.- Throws:
VectorDimensionException- If the vectors are different sizes.
-
subtract
public abstract AbstractDoubleVector subtract(AbstractDoubleVector v)
Returns the subtraction of this vector by another.- Parameters:
v- a double vector.- Throws:
VectorDimensionException- If the vectors are different sizes.
-
scalarMultiply
public abstract AbstractDoubleVector scalarMultiply(double x)
Returns the multiplication of this vector by a scalar.- Parameters:
x- a double.
-
scalarDivide
public abstract AbstractDoubleVector scalarDivide(double x)
Returns the division of this vector by a scalar.- Parameters:
x- a double.- Throws:
java.lang.ArithmeticException- If divide by zero.
-
normalize
public AbstractDoubleVector normalize()
Returns a normalised vector (a vector with norm equal to one).
-
scalarProduct
public abstract double scalarProduct(AbstractDoubleVector v)
Returns the scalar product of this vector and another.- Parameters:
v- a double vector.- Throws:
VectorDimensionException- If the vectors are different sizes.
-
mapComponents
public abstract AbstractDoubleVector mapComponents(Mapping f)
Applies a function on all the vector components.- Parameters:
f- a user-defined function.- Returns:
- a double vector.
-
-
DMelt 3.0 © DataMelt by jWork.ORG