## org.apache.mahout.math
Class Centroid

    java.lang.Object
      org.apache.mahout.math.DelegatingVector
          org.apache.mahout.math.WeightedVector
              org.apache.mahout.math.Centroid

All Implemented Interfaces:
  Cloneable, Vector

    public class Centroid

extends WeightedVector

A centroid is a weighted vector. We have it delegate to the vector itself for lots of operations to make it easy to use vector search classes and such.

Nested Class Summary

Nested classes/interfaces inherited from interface org.apache.mahout.math.Vector
`Vector.Element`

Field Summary

Fields inherited from class org.apache.mahout.math.DelegatingVector
`delegate`

Constructor Summary
`Centroid(int key, Vector initialValue)`
`Centroid(int key, Vector initialValue, double weight)`
`Centroid(WeightedVector original)`

Method Summary
`void` `addWeight(double newWeight)`
`Centroid` `clone()` Return a copy of the recipient
`static Centroid` `create(int key, Vector initialValue)`
`int` `getKey()` Deprecated.
`Centroid` `like()` Return an empty vector of the same underlying class as the receiver
`String` `toString()`
`void` `update(Vector v)`
`void` `update(Vector other, double wy)`

Methods inherited from class org.apache.mahout.math.WeightedVector
`getIndex, getWeight, project, project, setIndex, setWeight`

Methods inherited from class org.apache.mahout.math.DelegatingVector

`aggregate, aggregate, all, asFormatString, assign, assign, assign, assign, assign, assign, cross, divide, dot, equals, get, getDistanceSquared, getElement, getIteratorAdvanceCost, getLengthSquared, getLookupCost, getNumNondefaultElements, getNumNonZeroElements, getQuick, getVector, hashCode, incrementQuick, invalidateCachedLength, isAddConstantTime, isDense, isSequentialAccess, logNormalize, logNormalize, maxValue, maxValueIndex, mergeUpdates, minus, minValue, minValueIndex, nonZeroes, norm, normalize, normalize, plus, plus, set, setQuick, size, times, times, viewPart, zSum`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Centroid

    public Centroid(WeightedVector original)

### Centroid

    public Centroid(int key,
                    Vector initialValue)

### Centroid

    public Centroid(int key,
                    Vector initialValue,
                    double weight)

Method Detail

### create

    public static Centroid create(int key,
                                  Vector initialValue)

### update

    public void update(Vector v)

### update

    public void update(Vector other,
                       double wy)

### like

    public Centroid like()

  Description copied from interface: `Vector`
  Return an empty vector of the same underlying class as the receiver

  Specified by:
    `like` in interface `Vector`
  Overrides:
    `like` in class `WeightedVector`
  Returns:
    a Vector

### getKey

    @Deprecated
    public int getKey()

  Deprecated.

  Gets the index of this centroid. Use getIndex instead to maintain standard names.

### addWeight

    public void addWeight(double newWeight)

### toString

    public String toString()

  Overrides:
    `toString` in class `WeightedVector`

### clone

    public Centroid clone()

  Description copied from interface: `Vector`
  Return a copy of the recipient

  Specified by:
    `clone` in interface `Vector`
  Overrides:
    `clone` in class `WeightedVector`
  Returns:
    a new Vector

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.