    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class JSci.maths.DoubleSparseVector

    java.lang.Object
       |
       +----JSci.maths.MathVector
               |
               +----JSci.maths.DoubleVector
                       |
                       +----JSci.maths.DoubleSparseVector

public final class DoubleSparseVector
extends DoubleVector

The DoubleSparseVector class encapsulates sparse vectors. Uses Morse-coding.

##

SPARSE
  Storage format identifier.
storageFormat

##

DoubleSparseVector(double[])
  Constructs a vector from an array.
DoubleSparseVector(int)
  Constructs an empty vector.

##

add(DoubleSparseVector)
  Returns the addition of this vector and another.
add(DoubleVector)
  Returns the addition of this vector and another.
dimension()
  Returns the vector's dimension.
equals(Object)
  Compares two vectors for equality.
finalize()
  Finalize.
getComponent(int)
  Returns a component of this vector.
mapComponents(Mapping)
  Applies a function on all the vector components.
mass()
  Returns the mass.
norm()
  Returns the l2-norm (magnitude).
normalize()
  Make the norm of this vector equal to 1.
scalarDivide(double)
  Returns the division of this vector by a scalar.
scalarMultiply(double)
  Returns the multiplication of this vector by a scalar.
scalarProduct(DoubleSparseVector)
  Returns the scalar product of this vector and another.
scalarProduct(DoubleVector)
  Returns the scalar product of this vector and another.
setComponent(int, double)
  Sets the value of a component of this vector.
subtract(DoubleSparseVector)
  Returns the subtraction of this vector by another.
subtract(DoubleVector)
  Returns the subtraction of this vector by another.
sumSquares()
  Returns the sum of the squares of the components.
toString()
  Returns a comma delimited string representing the value of this vector.

##

SPARSE

     protected static final int SPARSE

  Storage format identifier.

storageFormat

     protected static final int storageFormat

##

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.

##

finalize

     protected void finalize() throws Throwable

  Finalize.

  Throws: Throwable
    Any that occur.
  Overrides:
    finalize in class Object

equals

     public boolean equals(Object a)

  Compares two vectors for equality.

  Parameters:
    a - a double sparse vector
  Overrides:
    equals in class DoubleVector

toString

     public String toString()

  Returns a comma delimited string representing the value of this vector.

  Overrides:
    toString in class DoubleVector

getComponent

     public 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.
  Overrides:
    getComponent in class DoubleVector

setComponent

     public 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.
  Overrides:
    setComponent in class DoubleVector

dimension

     public int dimension()

  Returns the vector's dimension.

  Overrides:
    dimension in class DoubleVector

normalize

     public void normalize()

  Make the norm of this vector equal to 1.

norm

     public double norm()

  Returns the l2-norm (magnitude).

  Overrides:
    norm in class DoubleVector

sumSquares

     public double sumSquares()

  Returns the sum of the squares of the components.

mass

     public double mass()

  Returns the mass.

add

     public DoubleVector add(DoubleVector v)

  Returns the addition of this vector and another.

  Parameters:
    v - a double vector
  Throws: VectorDimensionException
    If the vectors are different sizes.
  Overrides:
    add in class DoubleVector

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 DoubleVector subtract(DoubleVector v)

  Returns the subtraction of this vector by another.

  Parameters:
    v - a double vector
  Throws: VectorDimensionException
    If the vectors are different sizes.
  Overrides:
    subtract in class DoubleVector

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 DoubleVector scalarMultiply(double x)

  Returns the multiplication of this vector by a scalar.

  Parameters:
    x - a double
  Overrides:
    scalarMultiply in class DoubleVector

scalarDivide

     public DoubleVector scalarDivide(double x)

  Returns the division of this vector by a scalar.

  Parameters:
    x - a double
  Throws: ArithmeticException
    If divide by zero.
  Overrides:
    scalarDivide in class DoubleVector

scalarProduct

     public double scalarProduct(DoubleVector v)

  Returns the scalar product of this vector and another.

  Parameters:
    v - a double vector
  Throws: VectorDimensionException
    If the vectors are different sizes.
  Overrides:
    scalarProduct in class DoubleVector

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.

mapComponents

     public DoubleVector mapComponents(Mapping f)

  Applies a function on all the vector components.

  Parameters:
    f - a user-defined function
  Returns:
    a double sparse vector
  Overrides:
    mapComponents in class DoubleVector

    All Packages  Class Hierarchy  This Package  Previous  Next  Index