edu.stanford.nlp.linalg
Interface Array

All Superinterfaces:
Cloneable
All Known Implementing Classes:
AbstractArray

public interface Array
extends Cloneable

Interface for dense or sparse arrays which store numbers.


Method Summary
 Array add(Array addend)
          Returns this + addend does not change receiver.
 int cardinality()
          Returns number of nonzero entries in array
 Object clone()
          Returns deep copy of Array
 int columnIndex()
          Returns column index of column vector
 boolean containsKey(int key)
          Returns true if the array contains index key
 double distance(Array other)
          Returns Euclidean distance from this to other
 Array divide(Array dividend)
          Returns componentwise divide: this/dividend
 Array divide(double dividend)
          Scalar divide
 double dot(Array other)
          Returns dot product of this with other
 Set entrySet()
          Returns a set view of the Entries contained in this array.
 boolean equals(Object o)
          Returns true if o==this
 double get(int index)
          Gets double value of element at index i
 Iterator iterator()
          Returns an iterator over the entries in the matrix
 Array multiply(Array multiplicand)
          Returns componentwise multiply
 Array multiply(double multiplicand)
          Scalar multiply
 Array newInstance(int size)
          Returns an empty Array of the same dynamic type with given size
 double norm()
          Returns L2 norm of vector
 Array normalize()
          Returns vector with euclidian distance normalized to 1.
 Array scale(double factor)
          Returns this * factor does not change receiver.
 void set(int i, double val)
          Sets value of element at index i to val
 void setAll(double value)
          Sets all elements = value (in sparse matrices, sets all nonzero elements = value)
 void setColumnIndex(int ci)
          Sets column index of column vector.
 int size()
          Returns number of elements in Array
 Array toLogSpace()
          Transforms the array to log space.
 String toString()
          Returns String representation of Array
 

Method Detail

setColumnIndex

public void setColumnIndex(int ci)
Sets column index of column vector. the default is -1;


columnIndex

public int columnIndex()
Returns column index of column vector


setAll

public void setAll(double value)
Sets all elements = value (in sparse matrices, sets all nonzero elements = value)


get

public double get(int index)
Gets double value of element at index i


set

public void set(int i,
                double val)
Sets value of element at index i to val


size

public int size()
Returns number of elements in Array


entrySet

public Set entrySet()
Returns a set view of the Entries contained in this array. Note: this differs from java.util.AbstractMap.entrySet() in that it returns a Set of Entries, rather than a set of objects.


containsKey

public boolean containsKey(int key)
Returns true if the array contains index key


iterator

public Iterator iterator()
Returns an iterator over the entries in the matrix


equals

public boolean equals(Object o)
Returns true if o==this

Overrides:
equals in class Object

toString

public String toString()
Returns String representation of Array

Overrides:
toString in class Object

clone

public Object clone()
Returns deep copy of Array

Overrides:
clone in class Object

newInstance

public Array newInstance(int size)
Returns an empty Array of the same dynamic type with given size


add

public Array add(Array addend)
Returns this + addend does not change receiver.


scale

public Array scale(double factor)
Returns this * factor does not change receiver.


norm

public double norm()
Returns L2 norm of vector


distance

public double distance(Array other)
Returns Euclidean distance from this to other


dot

public double dot(Array other)
Returns dot product of this with other


multiply

public Array multiply(Array multiplicand)
Returns componentwise multiply


divide

public Array divide(Array dividend)
Returns componentwise divide: this/dividend


multiply

public Array multiply(double multiplicand)
Scalar multiply


divide

public Array divide(double dividend)
Scalar divide


normalize

public Array normalize()
Returns vector with euclidian distance normalized to 1. does not change reciever.


cardinality

public int cardinality()
Returns number of nonzero entries in array


toLogSpace

public Array toLogSpace()
Transforms the array to log space. this is kind of a hack, so try to fix it later, by defining things like componentwise array functions, etc. takes the log of each component in array



Stanford NLP Group