|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectprea.datastructure.DenseVector
public class DenseVector
This class implements dense vector with array-based implementation. Note that we use UJMP package (http://www.ujmp.org) to implement this class.
Field Summary | |
---|---|
private org.ujmp.core.Matrix |
map
The UJMP matrix to store data. |
private int |
N
The length (maximum number of items to be stored) of sparse vector. |
Constructor Summary | |
---|---|
DenseVector()
Construct an empty dense vector, with capacity 0. |
|
DenseVector(int n)
Construct a new dense vector with size n. |
|
DenseVector(org.ujmp.core.Matrix m)
Construct a new dense vector, having same data with the given UJMP matrix. |
Method Summary | |
---|---|
double |
absoluteSum()
Sum of absolute value of every element in the vector. |
DenseVector |
add(double alpha)
Scalar addition operator. |
double |
average()
Average of every element. |
DenseVector |
commonMinus(DenseVector b)
Vector subtraction (a - b), for only existing values. |
DenseVector |
copy()
Copy the whole dense vector and make a clone. |
DenseVector |
exp(double alpha)
Exponential of a given constant. |
double |
getValue(int i)
Retrieve a stored value from the given index. |
org.ujmp.core.Matrix |
getVector()
Get an UJMP matrix. |
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(DenseVector b)
Inner product of two vectors. |
int |
itemCount()
Actual number of items in the vector. |
int |
length()
Capacity of this vector |
DenseVector |
minus(DenseVector b)
Vector subtraction (a - b) |
double |
norm()
2-norm of the vector. |
DenseMatrix |
outerProduct(DenseVector b)
Outer product of two vectors. |
double |
partInnerProduct(DenseVector b,
int[] indexList)
Inner-product for indices only in the given indices. |
DenseVector |
partMinus(DenseVector b,
int[] indexList)
Vector subtraction (a - b) for indices only in the given indices. |
DenseMatrix |
partOuterProduct(DenseVector b,
int[] indexList)
Outer-product for indices only in the given indices. |
DenseVector |
partPlus(DenseVector b,
int[] indexList)
Vector sum (a + b) for indices only in the given indices. |
DenseVector |
plus(DenseVector b)
Vector sum (a + b) |
DenseVector |
power(double alpha)
Scalar power operator. |
void |
remove(int i)
Delete a value stored at the given index. |
DenseVector |
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. |
DenseVector |
sub(double alpha)
Scalar subtraction operator. |
double |
sum()
Sum of every element in the vector. |
DenseVector |
toDenseSubset(int[] indexList)
Convert the vector into a sparse vector, but only with the selected indices. |
SparseVector |
toSparseVector()
Convert the vector into the sparse vector. |
java.lang.String |
toString()
Convert the vector to a printable string. |
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 org.ujmp.core.Matrix map
private int N
Constructor Detail |
---|
public DenseVector()
public DenseVector(int n)
n
- The capacity of new dense vector.public DenseVector(org.ujmp.core.Matrix m)
m
- An UJMP matrix.Method Detail |
---|
public org.ujmp.core.Matrix getVector()
public void setValue(int i, double value)
i
- The index to store new value.value
- The value to store.
java.lang.ArrayIndexOutOfBoundsException
- when the index is out of range.public double getValue(int i)
i
- The index to retrieve.
java.lang.ArrayIndexOutOfBoundsException
- when the index is out of range.public void remove(int i)
i
- The index to delete the value in it.public DenseVector copy()
public int[] indexList()
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 SparseVector toSparseVector()
public DenseVector toDenseSubset(int[] indexList)
indexList
- The list of indices converting to sparse vector.
public int length()
public int itemCount()
public void setLength(int n)
n
- The new capacity value.public DenseVector add(double alpha)
alpha
- The scalar value to be added to the original vector.
public DenseVector sub(double alpha)
alpha
- The scalar value to be subtracted from the original vector.
public DenseVector scale(double alpha)
alpha
- The scalar value to be multiplied to the original vector.
public DenseVector power(double alpha)
alpha
- The scalar value to be powered to the original vector.
public DenseVector exp(double alpha)
alpha
- The exponent.
public double norm()
public double sum()
public double absoluteSum()
public double average()
public double variance()
public double stdev()
public DenseVector plus(DenseVector b)
b
- The vector to be added to this vector.
java.lang.RuntimeException
- when vector lengths disagree.public DenseVector minus(DenseVector b)
b
- The vector to be subtracted from this vector.
java.lang.RuntimeException
- when vector lengths disagree.public DenseVector commonMinus(DenseVector b)
b
- The vector to be subtracted from this vector.
public double innerProduct(DenseVector b)
b
- The vector to be inner-producted with this vector.
public DenseMatrix outerProduct(DenseVector b)
b
- The vector to be outer-producted with this vector.
public DenseVector partPlus(DenseVector b, int[] indexList)
b
- The vector to be added to this vector.indexList
- The list of indices to be applied summation.
java.lang.RuntimeException
- when vector lengths disagree.public DenseVector partMinus(DenseVector b, int[] indexList)
b
- The vector to be subtracted from this vector.indexList
- The list of indices to be applied subtraction.
java.lang.RuntimeException
- when vector lengths disagree.public double partInnerProduct(DenseVector b, int[] indexList)
b
- The vector to be inner-producted with this vector.indexList
- The list of indices to be applied inner-product.
public DenseMatrix partOuterProduct(DenseVector 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 |