edu.umd.cloud9.example.clustering
Class PVector

java.lang.Object
  extended by edu.umd.cloud9.example.clustering.PVector

public final class PVector
extends Object

Parameter vector.


Field Summary
 double[] array
           
 
Constructor Summary
PVector(int dim)
          Class constructor.
 
Method Summary
 PVector clone()
          Creates and returns a copy of the instance.
 double dot(PVector v2)
           
static boolean equals(PVector v1, PVector v2)
          Verifies if two vectors are similar.
 int getDimension()
          Returns vector's dimension.
 PVector minus(PVector v2)
           
 double norm2()
          Computes the Euclidean norm of the current vector \f$ v \f$.
 PVector plus(PVector v2)
           
static PVector sampleRandomDistribution(int dim)
          Generates of a random vector \f$ v = (x_1, x_2, \cdots )\f$ where each component is drawn uniformly in \f$ \mathcal{U}(0,1)\f$.
static PVector sampleRandomVector(int dim)
          Generates of a random vector \f$ v = (x_1, x_2, \cdots )\f$ where each component is drawn uniformly in \f$ \mathcal{U}(0,1)\f$.
 PVector times(double lambda)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

array

public double[] array
Constructor Detail

PVector

public PVector(int dim)
Class constructor.

Parameters:
dim - dimension of the vector
Method Detail

plus

public PVector plus(PVector v2)

minus

public PVector minus(PVector v2)

times

public PVector times(double lambda)

dot

public double dot(PVector v2)

sampleRandomVector

public static PVector sampleRandomVector(int dim)
Generates of a random vector \f$ v = (x_1, x_2, \cdots )\f$ where each component is drawn uniformly in \f$ \mathcal{U}(0,1)\f$.

Parameters:
dim - dimension of the vector
Returns:
random vector

sampleRandomDistribution

public static PVector sampleRandomDistribution(int dim)
Generates of a random vector \f$ v = (x_1, x_2, \cdots )\f$ where each component is drawn uniformly in \f$ \mathcal{U}(0,1)\f$. The vector is normalized such as \f$ \sum_i x_i = 1 \f$.

Parameters:
dim - dimension of the vector
Returns:
random vector

equals

public static boolean equals(PVector v1,
                             PVector v2)
Verifies if two vectors are similar.

Parameters:
v1 - vector \f$ v_1 \f$
v2 - vector \f$ v_2 \f$
Returns:
true if \f$ v_1 = v_2 \f$, false otherwise

norm2

public double norm2()
Computes the Euclidean norm of the current vector \f$ v \f$.

Returns:
\f$ \|v\|_2 \f$

toString

public String toString()
Overrides:
toString in class Object

clone

public PVector clone()
Creates and returns a copy of the instance.

Overrides:
clone in class Object
Returns:
a clone of the instance.

getDimension

public int getDimension()
Returns vector's dimension.

Returns:
vector's dimension.