Package org.biojava.nbio.structure.math
Class SparseVector
java.lang.Object
org.biojava.nbio.structure.math.SparseVector
- All Implemented Interfaces:
 Serializable
A sparse vector, implemented using a symbol table.
  Derived from http://introcs.cs.princeton.edu/java/44st/SparseVector.java.html
  For additional documentation, see Section 4.4 of
  Introduction to Programming in Java: An Interdisciplinary Approach by Robert Sedgewick and Kevin Wayne.
- See Also:
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptiondoubledot(SparseVector b) Calculates the dot product of this vector a with bdoubleget(int i) get a valueintnnz()doublenorm()Calculates the 2-normplus(SparseVector b) Calcualtes return a + bvoidput(int i, double value) Setter method (should it be renamed to set?)scale(double alpha) Calculates alpha * aintsize()toString() 
- 
Constructor Details
- 
SparseVector
Constructor. initialize the all 0s vector of length N- Parameters:
 N-
 
 - 
 - 
Method Details
- 
put
Setter method (should it be renamed to set?)- Parameters:
 i- set symbolTable[i]value-
 - 
get
get a value- Parameters:
 i-- Returns:
 - return symbolTable[i]
 
 - 
nnz
 - 
size
 - 
dot
Calculates the dot product of this vector a with b- Parameters:
 b-- Returns:
 
 - 
norm
Calculates the 2-norm- Returns:
 
 - 
scale
Calculates alpha * a- Parameters:
 alpha-- Returns:
 
 - 
plus
Calcualtes return a + b- Parameters:
 b-- Returns:
 
 - 
toString
 
 -