de.lmu.ifi.dbs.elki.math.linearalgebra
Class Centroid

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.math.linearalgebra.Vector
      extended by de.lmu.ifi.dbs.elki.math.linearalgebra.Centroid
All Implemented Interfaces:
MatrixLike<Vector>, Serializable, Cloneable
Direct Known Subclasses:
ProjectedCentroid

public class Centroid
extends Vector

Class to compute the centroid of some data. Note: this class abstracts the efficient and numerical stable computation of centroids. See DatabaseUtil for easier to use APIs.

See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          Serial version
protected  double wsum
          The current weight
 
Fields inherited from class de.lmu.ifi.dbs.elki.math.linearalgebra.Vector
elements
 
Constructor Summary
Centroid(int dim)
          Constructor.
 
Method Summary
static Centroid make(Matrix mat)
          Static Constructor from an existing matrix columns.
static Centroid make(Relation<? extends NumberVector<?,?>> relation)
          Static constructor from an existing relation.
static Centroid make(Relation<? extends NumberVector<?,?>> relation, Iterable<DBID> ids)
          Static constructor from an existing relation.
 void put(double[] val)
          Add a single value with weight 1.0
 void put(double[] val, double weight)
          Add data with a given weight.
 void put(NumberVector<?,?> val)
          Add a single value with weight 1.0
 void put(NumberVector<?,?> val, double weight)
          Add data with a given weight.
 void put(Vector val)
          Add a single value with weight 1.0
 void put(Vector val, double weight)
          Add data with a given weight.
<F extends NumberVector<? extends F,?>>
F
toVector(Relation<? extends F> relation)
          Get the data as vector
 
Methods inherited from class de.lmu.ifi.dbs.elki.math.linearalgebra.Vector
clone, copy, equals, euclideanLength, get, get, getArrayCopy, getArrayRef, getColumnDimensionality, getColumnVector, getDimensionality, getRowDimensionality, hashCode, increment, inverseVector, minus, minusEquals, minusEquals, minusTimes, minusTimesEquals, normalize, normF, plus, plusEquals, plusEquals, plusTimes, plusTimesEquals, projection, randomNormalizedVector, scalarProduct, set, set, setZero, sqrtVector, times, times, timesEquals, timesTranspose, toString, toStringNoWhitespace, transpose, transposeTimes, transposeTimes, unitVector
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serial version

See Also:
Constant Field Values

wsum

protected double wsum
The current weight

Constructor Detail

Centroid

public Centroid(int dim)
Constructor.

Parameters:
dim - Dimensionality
Method Detail

put

public void put(double[] val)
Add a single value with weight 1.0

Parameters:
val - Value

put

public void put(double[] val,
                double weight)
Add data with a given weight.

Parameters:
val - data
weight - weight

put

public final void put(Vector val)
Add a single value with weight 1.0

Parameters:
val - Value

put

public final void put(Vector val,
                      double weight)
Add data with a given weight.

Parameters:
val - data
weight - weight

put

public void put(NumberVector<?,?> val)
Add a single value with weight 1.0

Parameters:
val - Value

put

public void put(NumberVector<?,?> val,
                double weight)
Add data with a given weight.

Parameters:
val - data
weight - weight

toVector

public <F extends NumberVector<? extends F,?>> F toVector(Relation<? extends F> relation)
Get the data as vector

Returns:
the data

make

public static Centroid make(Matrix mat)
Static Constructor from an existing matrix columns.

Parameters:
mat - Matrix to use the columns from.

make

public static Centroid make(Relation<? extends NumberVector<?,?>> relation)
Static constructor from an existing relation.

Parameters:
relation - Relation to use
Returns:
Centroid of relation

make

public static Centroid make(Relation<? extends NumberVector<?,?>> relation,
                            Iterable<DBID> ids)
Static constructor from an existing relation.

Parameters:
relation - Relation to use
ids - IDs to use

Release 0.4.0 (2011-09-20_1324)