|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectscpsolver.util.SparseVector
public class SparseVector
Implementation of a sparse vector
Constructor Summary | |
---|---|
SparseVector(double[] x)
Creates a new vector with entries taken from the array |
|
SparseVector(int[] index,
double[] data)
|
|
SparseVector(int size,
int nonzerosize)
Constructs a new SparseVector of a given size and with a given starting capacity. |
|
SparseVector(Matrix c)
Copies the matrix c. |
|
SparseVector(SparseVector v)
Copy-constructor for the SparseVector |
Method Summary | |
---|---|
SparseVector |
add(SparseVector v)
Adds two sparse vectors |
SparseVector |
clone()
Creates a deep copy of the vector |
double |
dot(double[] ydata)
Calculates the dot product of this vector and the vector y |
double |
dot(SparseVector y)
Calculates the dot product (or scalar product, inner product) of two vectors |
double |
dotdumb(SparseVector y)
Calculates the dot product of this vector and the vector y |
boolean |
equals(java.lang.Object o)
Compares two vectors. |
boolean |
equals(SparseVector v)
Compares two SparseVectors |
double[] |
get()
Returns the vector as a double array |
double |
get(int index)
Gets the value at index inpired by http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ressim/mtj/src/no/uib/cipr/matrix/sparse/SparseVector.java? |
double |
get(int row,
int column)
Gets the value of the vector at the position donated by row and column. |
int |
getColNum()
Returns the number of columns of the vector. |
double[] |
getData()
|
int[] |
getIndex()
|
int |
getIndex(int ind)
Sets the index of a sparse vector inpired by http://cvs.berlios.de/cgi-bin/viewcvs.cgi/ressim/mtj/src/no/uib/cipr/matrix/sparse/SparseVector.java? |
NonZeroElementIterator |
getNonZeroElementIterator()
|
int |
getRowNum()
Returns the number of rows of the vector. |
int |
getSize()
|
int |
getUsed()
|
void |
grow(int newsize,
boolean bottom)
Grows or shrinks the vector to the given size |
void |
grow(SparseVector v)
Grows a vector with another vector |
static void |
main(java.lang.String[] args)
|
SparseVector |
plus(Matrix y)
Adds a second vector to the vector |
void |
set(int in,
double value)
Sets the entry of the vector to a given value |
void |
set(int row,
int column,
double value)
Sets a certain entry of the vector to the given value. |
void |
setData(double[] data)
|
void |
setIndex(int[] index)
|
void |
setSize(int size)
|
void |
setUsed(int used)
|
SparseVector |
times(double c)
Multiplies the vector with a scalar |
Matrix |
times(Matrix multiplier)
Multiplies the vector with a matrix |
java.lang.String |
toString()
String representation of this sparse vector. |
Matrix |
transpose()
Transposes a vector |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SparseVector(int size, int nonzerosize)
size
- The actual size of the vectornonzerosize
- The starting capacity of the vectorpublic SparseVector(SparseVector v)
v
- The vector to be copiedpublic SparseVector(double[] x)
x
- The entries of the new vectorpublic SparseVector(int[] index, double[] data)
public SparseVector(Matrix c)
c
- The matrix to be copiedMethod Detail |
---|
public double[] getData()
public void setData(double[] data)
public int[] getIndex()
public void setIndex(int[] index)
public int getUsed()
public void setUsed(int used)
public int getSize()
public void setSize(int size)
public void grow(int newsize, boolean bottom)
newsize
- The new size of the vectorbottom
- Boolean indicating wether the elements are added on the top or bottompublic void grow(SparseVector v)
v
- The vector to be concatinatedbottom
- Wether v is added before or after the vectorpublic Matrix transpose()
transpose
in interface Matrix
public SparseVector clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int getIndex(int ind)
ind
- val
-
public void set(int in, double value)
in
- The entry of the vector to be alteredvalue
- The new valuepublic double get(int index)
index
-
public double[] get()
public double dot(SparseVector y)
y
- The second vector for the dot product
public SparseVector plus(Matrix y)
plus
in interface Matrix
y
- The second vector
public double dotdumb(SparseVector y)
y
- The second vector for the dot product
public double dot(double[] ydata)
ydata
- The second vector implicitly given as double array
public SparseVector times(double c)
c
- The scalar to be multiplied with the vector
public double get(int row, int column)
get
in interface Matrix
row
- The row of the entrycolumn
- The column of the entry
public int getColNum()
getColNum
in interface Matrix
public int getRowNum()
getRowNum
in interface Matrix
public Matrix times(Matrix multiplier)
times
in interface Matrix
multiplier
- The matrix with which the vector should be multiplied
public void set(int row, int column, double value)
set
in interface Matrix
public SparseVector add(SparseVector v)
v
- The vector to be added
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
v
- The vector to be compared to
public boolean equals(SparseVector v)
v
- The vector to be compared to
public static void main(java.lang.String[] args)
public NonZeroElementIterator getNonZeroElementIterator()
getNonZeroElementIterator
in interface Matrix
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |