|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<java.lang.Integer,java.lang.Double>
de.uni_leipzig.mcl.cluster.SparseVector
public class SparseVector
SparseVector represents a sparse vector.
Conventions: except for the inherited methods and normalise(double), operations leave this ummodified (immutable) if there is a return value. Within operations, no pruning of values close to zero is done. Pruning can be controlled via the prune() method.
![]() |
![]() |
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
| Constructor Summary | |
|---|---|
SparseVector()
create empty vector |
|
SparseVector(double[] x)
create vector from dense vector |
|
SparseVector(int i)
create empty vector with length |
|
SparseVector(SparseVector v)
copy constructor |
|
| Method Summary | |
|---|---|
void |
add(int i,
double a)
mutable add |
void |
add(SparseVector v)
mutable add |
SparseVector |
copy()
copy the contents of the sparse vector |
double |
expSum(int p)
exponential sum, i.e., sum (elements^p) |
void |
factor(double a)
mutable factorisation |
java.lang.Double |
get(java.lang.Object key)
get ensures it returns 0 for empty hash values or if index exceeds length. |
double[] |
getDense()
get dense represenation |
int |
getLength()
get the length of the vector |
void |
hadamardPower(double s)
mutable Hadamard power |
void |
hadamardProduct(SparseVector v)
mutable Hadamard product (elementwise multiplication) |
double |
max()
maximum element value |
void |
mult(int i,
double a)
mutable mult |
void |
normalise()
normalises the vector to 1. |
double |
normalise(double newsum)
normalises the vector to newsum |
void |
prune(double threshold)
remove all elements whose magnitude is < threshold |
java.lang.Double |
put(java.lang.Integer key,
java.lang.Double value)
put increases the matrix size if the index exceeds the current size. |
void |
setLength(int length)
set the new length of the vector (regardless of the maximum index). |
SparseVector |
setSignum(double a)
Change signum |
void |
setSignum(int i,
double a)
mutable mult |
double |
sum(double s)
power sum of the elements |
double |
times(SparseVector v)
immutable scalar product |
java.lang.String |
toString()
|
| Methods inherited from class java.util.HashMap |
|---|
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public SparseVector()
public SparseVector(double[] x)
x - public SparseVector(int i)
public SparseVector(SparseVector v)
v - | Method Detail |
|---|
public void add(int i,
double a)
i - a - public void add(SparseVector v)
v - public SparseVector copy()
public double expSum(int p)
p -
public void factor(double a)
a - public java.lang.Double get(java.lang.Object key)
get in interface java.util.Map<java.lang.Integer,java.lang.Double>get in class java.util.HashMap<java.lang.Integer,java.lang.Double>key -
public double[] getDense()
public final int getLength()
public void hadamardPower(double s)
s - public void hadamardProduct(SparseVector v)
v - public double max()
public void mult(int i,
double a)
i - indexa - valuepublic void normalise()
public double normalise(double newsum)
the - value to which the element sum
public void prune(double threshold)
threshold -
public java.lang.Double put(java.lang.Integer key,
java.lang.Double value)
put in interface java.util.Map<java.lang.Integer,java.lang.Double>put in class java.util.HashMap<java.lang.Integer,java.lang.Double>key - value -
public final void setLength(int length)
length - public SparseVector setSignum(double a)
a -
public void setSignum(int i,
double a)
i - indexa - valuepublic double sum(double s)
public double times(SparseVector v)
v -
public java.lang.String toString()
toString in class java.util.AbstractMap<java.lang.Integer,java.lang.Double>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||