public class SparseVector extends AbstractVector implements ISparseVector
Vector.Normsize| Constructor and Description |
|---|
SparseVector(int size)
Constructor for SparseVector.
|
SparseVector(int size,
int nz)
Constructor for SparseVector.
|
SparseVector(int size,
int[] index,
double[] data)
Constructor for SparseVector
|
SparseVector(int size,
int[] index,
double[] data,
boolean deep)
Constructor for SparseVector
|
SparseVector(Vector x)
Constructor for SparseVector, and copies the contents from the supplied
vector.
|
SparseVector(Vector x,
boolean deep)
Constructor for SparseVector, and copies the contents from the supplied
vector.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
double value)
x(index) += value |
void |
compact()
Compacts the vector
|
SparseVector |
copy()
Creates a deep copy of the vector
|
double |
dot(Vector y)
xT*y |
double |
get(int index)
Returns
x(index) |
double[] |
getData()
Returns the internal value array.
|
int[] |
getIndex()
Returns the used indices
|
double[] |
getRawData()
Gets the raw internal data array.
|
int[] |
getRawIndex()
Gets the raw internal index array.
|
int |
getUsed()
Number of entries used in the sparse structure
|
Iterator<VectorEntry> |
iterator() |
protected double |
norm1() |
protected double |
norm2_robust() |
protected double |
norm2() |
protected double |
normInf() |
SparseVector |
scale(double alpha)
x=alpha*x |
void |
set(int index,
double value)
x(index) = value |
Vector |
set(Vector y)
x=y |
SparseVector |
zero()
Zeros all the entries in the vector, while preserving any underlying
structure
|
add, add, check, checkSize, norm, set, size, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic SparseVector(int size,
int nz)
size - Size of the vectornz - Initial number of non-zerospublic SparseVector(Vector x, boolean deep)
x - Vector to copy fromdeep - True if a deep copy is to be made. If the copy is shallow,
x must be a SparseVectorpublic SparseVector(Vector x)
x - Vector to copy from. A deep copy is madepublic SparseVector(int size)
size - Size of the vectorpublic SparseVector(int size,
int[] index,
double[] data,
boolean deep)
size - Size of the vectorindex - Indices of the vectordata - Entries of the vectordeep - True for a deep copy. For shallow copies, the given indices
will be used internallypublic SparseVector(int size,
int[] index,
double[] data)
size - Size of the vectorindex - The vector indices are copies from this arraydata - The vector entries are copies from this arraypublic void set(int index,
double value)
Vectorx(index) = valueset in interface Vectorset in class AbstractVectorpublic void add(int index,
double value)
Vectorx(index) += valueadd in interface Vectoradd in class AbstractVectorpublic double get(int index)
Vectorx(index)get in interface Vectorget in class AbstractVectorpublic SparseVector copy()
Vectorcopy in interface Vectorcopy in class AbstractVectorpublic SparseVector zero()
Vectorzero in interface Vectorzero in class AbstractVectorpublic SparseVector scale(double alpha)
Vectorx=alpha*xscale in interface Vectorscale in class AbstractVectorpublic double dot(Vector y)
VectorxT*ydot in interface Vectordot in class AbstractVectorprotected double norm1()
norm1 in class AbstractVectorprotected double norm2()
norm2 in class AbstractVectorprotected double norm2_robust()
norm2_robust in class AbstractVectorprotected double normInf()
normInf in class AbstractVectorpublic double[] getData()
public int[] getIndex()
getIndex in interface ISparseVectorpublic int[] getRawIndex()
public double[] getRawData()
public int getUsed()
getUsed in interface ISparseVectorpublic void compact()
public Iterator<VectorEntry> iterator()
iterator in interface Iterable<VectorEntry>iterator in class AbstractVectorCopyright © 2015. All Rights Reserved.