public class SparseVector extends AbstractVector implements ISparseVector
Vector.Norm
size
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 data
|
int[] |
getIndex()
Returns the indices
|
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, toString
public 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 SparseVector
public 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)
Vector
x(index) = value
set
in interface Vector
set
in class AbstractVector
public void add(int index, double value)
Vector
x(index) += value
add
in interface Vector
add
in class AbstractVector
public double get(int index)
Vector
x(index)
get
in interface Vector
get
in class AbstractVector
public SparseVector copy()
Vector
copy
in interface Vector
copy
in class AbstractVector
public SparseVector zero()
Vector
zero
in interface Vector
zero
in class AbstractVector
public SparseVector scale(double alpha)
Vector
x=alpha*x
scale
in interface Vector
scale
in class AbstractVector
public double dot(Vector y)
Vector
xT*y
dot
in interface Vector
dot
in class AbstractVector
protected double norm1()
norm1
in class AbstractVector
protected double norm2()
norm2
in class AbstractVector
protected double norm2_robust()
norm2_robust
in class AbstractVector
protected double normInf()
normInf
in class AbstractVector
public double[] getData()
public int[] getIndex()
getIndex
in interface ISparseVector
public int getUsed()
getUsed
in interface ISparseVector
public void compact()
public Iterator<VectorEntry> iterator()
iterator
in interface Iterable<VectorEntry>
iterator
in class AbstractVector
Copyright © 2013. All Rights Reserved.