|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprea.data.structure.SparseVector
public class SparseVector
This class implements sparse vector, containing empty values for most space.
Field Summary | |
---|---|
private DataMap<java.lang.Integer,java.lang.Double> |
map
Data map for |
private int |
N
The length (maximum number of items to be stored) of sparse vector. |
Constructor Summary | |
---|---|
SparseVector()
Construct an empty sparse vector, with capacity 0. |
|
SparseVector(int n)
Construct a new sparse vector with size n. |
Method Summary | |
---|---|
double |
absoluteSum()
Sum of absolute value of every element in the vector. |
SparseVector |
add(double alpha)
Scalar addition operator. |
double |
average()
Average of every element. |
SparseVector |
commonMinus(SparseVector b)
Vector subtraction (a - b), for only existing values. |
SparseVector |
copy()
Copy the whole sparse vector and make a clone. |
SparseVector |
exp(double alpha)
Exponential of a given constant. |
double |
getValue(int i)
Retrieve a stored value from the given index. |
int[] |
indexList()
Get a list of existing indices. |
void |
initialize(double value)
Set a same value to every element. |
void |
initialize(int[] index,
double value)
Set same value to given indices. |
double |
innerProduct(SparseVector b)
Inner product of two vectors. |
int |
itemCount()
Actual number of items in the vector. |
int |
length()
Capacity of this vector. |
double |
max()
The value of maximum element in the vector. |
double |
min()
The value of minimum element in the vector. |
SparseVector |
minus(SparseVector b)
Vector subtraction (a - b) |
double |
norm()
2-norm of the vector. |
SparseMatrix |
outerProduct(SparseVector b)
Outer product of two vectors. |
double |
partInnerProduct(SparseVector b,
int[] indexList)
Inner-product for indices only in the given indices. |
SparseVector |
partMinus(SparseVector b,
int[] indexList)
Vector subtraction (a - b) for indices only in the given indices. |
SparseMatrix |
partOuterProduct(SparseVector b,
int[] indexList)
Outer-product for indices only in the given indices. |
SparseVector |
partPlus(SparseVector b,
int[] indexList)
Vector sum (a + b) for indices only in the given indices. |
SparseVector |
plus(SparseVector b)
Vector sum (a + b) |
SparseVector |
power(double alpha)
Scalar power operator. |
void |
remove(int i)
Delete a value stored at the given index. |
SparseVector |
scale(double alpha)
Scalar multiplication operator. |
void |
setLength(int n)
Set a new capacity of the vector. |
void |
setValue(int i,
double value)
Set a new value at the given index. |
double |
stdev()
Standard Deviation of every element. |
SparseVector |
sub(double alpha)
Scalar subtraction operator. |
double |
sum()
Sum of every element in the vector. |
DenseVector |
toDenseSubset(int[] indexList)
Convert the vector into the array-based dense representation, but only with the selected indices. |
DenseVector |
toDenseVector()
Convert the vector into the array-based dense representation. |
java.lang.String |
toString()
Convert the vector to a printable string. |
double[] |
valueList()
Get a list of existing values in array form. |
double |
variance()
Variance of every element. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int N
private DataMap<java.lang.Integer,java.lang.Double> map
Constructor Detail |
---|
public SparseVector()
public SparseVector(int n)
n
- The capacity of new sparse vector.Method Detail |
---|
public void setValue(int i, double value)
i
- The index to store new value.value
- The value to store.public double getValue(int i)
i
- The index to retrieve.
public void remove(int i)
i
- The index to delete the value in it.public SparseVector copy()
public int[] indexList()
public double[] valueList()
public void initialize(double value)
value
- The value to assign to every element.public void initialize(int[] index, double value)
index
- The list of indices, which will be assigned the new value.value
- The new value to be assigned.public DenseVector toDenseVector()
public DenseVector toDenseSubset(int[] indexList)
indexList
- The list of indices converting to dense vector.
public int length()
public int itemCount()
public void setLength(int n)
n
- The new capacity value.public SparseVector add(double alpha)
alpha
- The scalar value to be added to the original vector.
public SparseVector sub(double alpha)
alpha
- The scalar value to be subtracted from the original vector.
public SparseVector scale(double alpha)
alpha
- The scalar value to be multiplied to the original vector.
public SparseVector power(double alpha)
alpha
- The scalar value to be powered to the original vector.
public SparseVector exp(double alpha)
alpha
- The exponent.
public double norm()
public double sum()
public double max()
public double min()
public double absoluteSum()
public double average()
public double variance()
public double stdev()
public SparseVector plus(SparseVector b)
b
- The vector to be added to this vector.
public SparseVector minus(SparseVector b)
b
- The vector to be subtracted from this vector.
public SparseVector commonMinus(SparseVector b)
b
- The vector to be subtracted from this vector.
public double innerProduct(SparseVector b)
b
- The vector to be inner-producted with this vector.
public SparseMatrix outerProduct(SparseVector b)
b
- The vector to be outer-producted with this vector.
public SparseVector partPlus(SparseVector b, int[] indexList)
b
- The vector to be added to this vector.indexList
- The list of indices to be applied summation.
public SparseVector partMinus(SparseVector b, int[] indexList)
b
- The vector to be subtracted from this vector.indexList
- The list of indices to be applied subtraction.
public double partInnerProduct(SparseVector b, int[] indexList)
b
- The vector to be inner-producted with this vector.indexList
- The list of indices to be applied inner-product.
public SparseMatrix partOuterProduct(SparseVector b, int[] indexList)
b
- The vector to be outer-producted with this vector.indexList
- The list of indices to be applied outer-product.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |