|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectJSci.maths.MathVector
JSci.maths.DoubleVector
JSci.maths.DoubleSparseVector
public final class DoubleSparseVector
The DoubleSparseVector class encapsulates sparse vectors. Uses Morse-coding.
| Field Summary | |
|---|---|
protected static int |
SPARSE
Storage format identifier. |
| Fields inherited from class JSci.maths.DoubleVector |
|---|
ARRAY_1D, vector |
| Fields inherited from class JSci.maths.MathVector |
|---|
CLASS_SPECIFIC, N, storageFormat |
| Constructor Summary | |
|---|---|
DoubleSparseVector(double[] array)
Constructs a vector from an array. |
|
DoubleSparseVector(int dim)
Constructs an empty vector. |
|
| Method Summary | |
|---|---|
DoubleSparseVector |
add(DoubleSparseVector v)
Returns the addition of this vector and another. |
DoubleVector |
add(DoubleVector v)
Returns the addition of this vector and another. |
boolean |
equals(java.lang.Object a)
Compares two vectors for equality. |
protected void |
finalize()
Finalize. |
double |
getComponent(int n)
Returns a component of this vector. |
DoubleVector |
mapComponents(Mapping f)
Applies a function on all the vector components. |
double |
mass()
Returns the mass. |
double |
norm()
Returns the l2-norm (magnitude). |
void |
normalize()
Makes the norm of this vector equal to 1. |
DoubleVector |
scalarDivide(double x)
Returns the division of this vector by a scalar. |
DoubleVector |
scalarMultiply(double x)
Returns the multiplication of this vector by a scalar. |
double |
scalarProduct(DoubleSparseVector v)
Returns the scalar product of this vector and another. |
double |
scalarProduct(DoubleVector v)
Returns the scalar product of this vector and another. |
void |
setComponent(int n,
double x)
Sets the value of a component of this vector. |
DoubleSparseVector |
subtract(DoubleSparseVector v)
Returns the subtraction of this vector by another. |
DoubleVector |
subtract(DoubleVector v)
Returns the subtraction of this vector by another. |
double |
sumSquares()
Returns the sum of the squares of the components. |
DoubleSparseMatrix |
tensorProduct(DoubleSparseVector v)
Returns the tensor product of this vector and another. |
java.lang.String |
toString()
Returns a comma delimited string representing the value of this vector. |
| Methods inherited from class JSci.maths.DoubleVector |
|---|
add, hashCode, infNorm, negate, norm, scalarDivide, scalarMultiply, subtract, toComplexVector, toIntegerVector |
| Methods inherited from class JSci.maths.MathVector |
|---|
dimension, getInvalidComponentMsg |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final int SPARSE
| Constructor Detail |
|---|
public DoubleSparseVector(int dim)
dim - the dimension of the vector.public DoubleSparseVector(double[] array)
| Method Detail |
|---|
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable - Any that occur.public boolean equals(java.lang.Object a)
equals in class DoubleVectora - a double sparse vectorpublic java.lang.String toString()
toString in class DoubleVectorpublic double getComponent(int n)
getComponent in class DoubleVectorn - index of the vector component
VectorDimensionException - If attempting to access an invalid component.
public void setComponent(int n,
double x)
setComponent in class DoubleVectorn - index of the vector componentx - a number
VectorDimensionException - If attempting to access an invalid component.public double norm()
norm in interface BanachSpace.Membernorm in class DoubleVectorpublic void normalize()
normalize in class DoubleVectorpublic double sumSquares()
public double mass()
public DoubleVector add(DoubleVector v)
add in class DoubleVectorv - a double vector
VectorDimensionException - If the vectors are different sizes.public DoubleSparseVector add(DoubleSparseVector v)
v - a double sparse vector
VectorDimensionException - If the vectors are different sizes.public DoubleVector subtract(DoubleVector v)
subtract in class DoubleVectorv - a double vector
VectorDimensionException - If the vectors are different sizes.public DoubleSparseVector subtract(DoubleSparseVector v)
v - a double sparse vector
VectorDimensionException - If the vectors are different sizes.public DoubleVector scalarMultiply(double x)
scalarMultiply in class DoubleVectorx - a doublepublic DoubleVector scalarDivide(double x)
scalarDivide in class DoubleVectorx - a double
java.lang.ArithmeticException - If divide by zero.public double scalarProduct(DoubleVector v)
scalarProduct in class DoubleVectorv - a double vector
VectorDimensionException - If the vectors are different sizes.public double scalarProduct(DoubleSparseVector v)
v - a double sparse vector
VectorDimensionException - If the vectors are different sizes.public DoubleSparseMatrix tensorProduct(DoubleSparseVector v)
public DoubleVector mapComponents(Mapping f)
mapComponents in class DoubleVectorf - a user-defined function
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||