public final class DoubleSparseVector extends DoubleVector
Modifier and Type | Field and Description |
---|---|
protected static int |
SPARSE
Storage format identifier.
|
ARRAY_1D, vector
CLASS_SPECIFIC, N, storageFormat
Constructor and Description |
---|
DoubleSparseVector(double[] array)
Constructs a vector from an array.
|
DoubleSparseVector(int dim)
Constructs an empty vector.
|
Modifier and Type | Method and Description |
---|---|
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.
|
add, hashCode, infNorm, negate, norm, scalarDivide, scalarMultiply, subtract, toComplexVector, toIntegerVector
dimension, getInvalidComponentMsg
protected static final int SPARSE
public DoubleSparseVector(int dim)
dim
- the dimension of the vector.public DoubleSparseVector(double[] array)
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- Any that occur.public boolean equals(java.lang.Object a)
equals
in class DoubleVector
a
- a double sparse vectorpublic java.lang.String toString()
toString
in class DoubleVector
public double getComponent(int n)
getComponent
in class DoubleVector
n
- index of the vector componentVectorDimensionException
- If attempting to access an invalid component.public void setComponent(int n, double x)
setComponent
in class DoubleVector
n
- index of the vector componentx
- a numberVectorDimensionException
- If attempting to access an invalid component.public double norm()
norm
in interface BanachSpace.Member
norm
in class DoubleVector
public void normalize()
normalize
in class DoubleVector
public double sumSquares()
public double mass()
public DoubleVector add(DoubleVector v)
add
in class DoubleVector
v
- a double vectorVectorDimensionException
- If the vectors are different sizes.public DoubleSparseVector add(DoubleSparseVector v)
v
- a double sparse vectorVectorDimensionException
- If the vectors are different sizes.public DoubleVector subtract(DoubleVector v)
subtract
in class DoubleVector
v
- a double vectorVectorDimensionException
- If the vectors are different sizes.public DoubleSparseVector subtract(DoubleSparseVector v)
v
- a double sparse vectorVectorDimensionException
- If the vectors are different sizes.public DoubleVector scalarMultiply(double x)
scalarMultiply
in class DoubleVector
x
- a doublepublic DoubleVector scalarDivide(double x)
scalarDivide
in class DoubleVector
x
- a doublejava.lang.ArithmeticException
- If divide by zero.public double scalarProduct(DoubleVector v)
scalarProduct
in class DoubleVector
v
- a double vectorVectorDimensionException
- If the vectors are different sizes.public double scalarProduct(DoubleSparseVector v)
v
- a double sparse vectorVectorDimensionException
- If the vectors are different sizes.public DoubleSparseMatrix tensorProduct(DoubleSparseVector v)
public DoubleVector mapComponents(Mapping f)
mapComponents
in class DoubleVector
f
- a user-defined function