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.


Variable Index

 o SPARSE
Storage format identifier.
 o storageFormat

Constructor Index

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

Method Index

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

Variables

 o SPARSE
 protected static final int SPARSE
Storage format identifier.

 o storageFormat
 protected static final int storageFormat

Constructors

 o DoubleSparseVector
 public DoubleSparseVector(int dim)
Constructs an empty vector.

Parameters:
dim - the dimension of the vector.
 o DoubleSparseVector
 public DoubleSparseVector(double array[])
Constructs a vector from an array.

Methods

 o finalize
 protected void finalize() throws Throwable
Finalize.

Throws: Throwable
Any that occur.
Overrides:
finalize in class Object
 o equals
 public boolean equals(Object a)
Compares two vectors for equality.

Parameters:
a - a double sparse vector
Overrides:
equals in class DoubleVector
 o toString
 public String toString()
Returns a comma delimited string representing the value of this vector.

Overrides:
toString in class DoubleVector
 o 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
 o 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
 o dimension
 public int dimension()
Returns the vector's dimension.

Overrides:
dimension in class DoubleVector
 o normalize
 public void normalize()
Make the norm of this vector equal to 1.

 o norm
 public double norm()
Returns the l2-norm (magnitude).

Overrides:
norm in class DoubleVector
 o sumSquares
 public double sumSquares()
Returns the sum of the squares of the components.

 o mass
 public double mass()
Returns the mass.

 o 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
 o 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.
 o 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
 o 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.
 o scalarMultiply
 public DoubleVector scalarMultiply(double x)
Returns the multiplication of this vector by a scalar.

Parameters:
x - a double
Overrides:
scalarMultiply in class DoubleVector
 o 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
 o 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
 o 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.
 o 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