org.strbio.math
Class DVectorSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by org.strbio.math.DVectorSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess

public class DVectorSet
extends java.util.Vector

A class to encapsulate a set of points, where each point is represented as a DVector. The minimum dimension of each DVector can be specified to ensure the set contains 2D, 3D data (although this can be circumvented by unscrupulous programs)

  Version 1.1, 7/6/99 - added findNClosest
  Version 1.0, 4/16/99 - original version.
  

Version:
1.1, 7/6/99
Author:
JMC
See Also:
DVector, Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
DVectorSet()
          Create an empty set of points, with no minimum dimension
DVectorSet(DMatrix y)
          Create a set from a DMatrix, creating a new point for each row in the matrix.
DVectorSet(DVectorSet y)
          Create a set by copying another set, but not the DVectors in it.
DVectorSet(int minimumDimension)
          Create an empty set of points, with a particular minimum dimension.
 
Method Summary
 void add(DVector q)
          add in a single point to this set, without duplicating it.
 void add(DVectorSet q)
          add in another set of DVectors, without duplicating them.
 void addFast(DVector q)
          add in a single point, without checking dimensionality.
 void clear()
          Delete all info on this set, but not the points themselves.
 IVector findNClosest(int n, DVector v)
          What are the indices of the N closest values to a DVector?
 DVector getDimension(int d)
          get a DVector of returning the d'th coordinate for each point.
 double max(int d)
          Get maximum value in dimension d (i.e. 0 = x, 1 = y)
 double min(int d)
          Get minimum value in dimension d (i.e. 0 = x, 1 = y)
 int n()
          How many DVectors are in the set?
 DVector p(int i)
          short for point(i)
 DVector point(int i)
          Return the i'th point in the set.
 void remove(DVector q)
          Remove a DVector from the set.
 java.lang.Object remove(int i)
          Remove DVector number i from the set, and return it.
 void setPointAt(int i, DVector p)
          set the i'th point in the set.
 void setPointAtFast(int i, DVector p)
          set the i'th point in the set.
 DMatrix toDMatrix()
          Return the DVector set expressed as a matrix, with one row per point, and one column per dimension.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

DVectorSet

public DVectorSet()
Create an empty set of points, with no minimum dimension


DVectorSet

public DVectorSet(int minimumDimension)
Create an empty set of points, with a particular minimum dimension.


DVectorSet

public DVectorSet(DVectorSet y)
Create a set by copying another set, but not the DVectors in it.


DVectorSet

public DVectorSet(DMatrix y)
Create a set from a DMatrix, creating a new point for each row in the matrix. i.e. a 3x10 matrix would become 10 3D points. minimumDimension will become whatever the number of columns is.

Method Detail

n

public int n()
How many DVectors are in the set?


point

public DVector point(int i)
Return the i'th point in the set.


setPointAt

public void setPointAt(int i,
                       DVector p)
set the i'th point in the set.


setPointAtFast

public void setPointAtFast(int i,
                           DVector p)
set the i'th point in the set.


p

public DVector p(int i)
short for point(i)


getDimension

public DVector getDimension(int d)
get a DVector of returning the d'th coordinate for each point.


clear

public void clear()
Delete all info on this set, but not the points themselves.

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List
Overrides:
clear in class java.util.Vector

toDMatrix

public DMatrix toDMatrix()
Return the DVector set expressed as a matrix, with one row per point, and one column per dimension. I.e. a set of 10 3D points will be returned as a 3x10 matrix.


add

public final void add(DVector q)
add in a single point to this set, without duplicating it.


addFast

public final void addFast(DVector q)
add in a single point, without checking dimensionality.


remove

public final void remove(DVector q)
Remove a DVector from the set.


remove

public final java.lang.Object remove(int i)
Remove DVector number i from the set, and return it.

Specified by:
remove in interface java.util.List
Overrides:
remove in class java.util.Vector

add

public final void add(DVectorSet q)
add in another set of DVectors, without duplicating them.


min

public final double min(int d)
Get minimum value in dimension d (i.e. 0 = x, 1 = y)


max

public final double max(int d)
Get maximum value in dimension d (i.e. 0 = x, 1 = y)


findNClosest

public final IVector findNClosest(int n,
                                  DVector v)
What are the indices of the N closest values to a DVector? This uses distance(), so be sure the DVectors in the set have enough dimensionality to be compared to v. This will return a smaller IVector if this set is smaller than N.