public class Centroid extends java.lang.Object implements NumberVector
NumberVector.Factory<V extends NumberVector>
Modifier and Type | Field and Description |
---|---|
protected double[] |
elements
Vector elements.
|
protected double |
wsum
The current weight.
|
ATTRIBUTE_SEPARATOR, FIELD, FIELD_1D, FIELD_2D, VARIABLE_LENGTH
TYPE
Constructor and Description |
---|
Centroid(int dim)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
doubleValue(int dimension)
Returns the value in the specified dimension as double.
|
double[] |
getArrayRef()
Low-level access to the element array.
|
int |
getDimensionality()
The dimensionality of the vector space where of this FeatureVector of V is
an element.
|
long |
longValue(int dimension)
Returns the value in the specified dimension as long.
|
static Centroid |
make(Relation<? extends NumberVector> relation,
DBIDs 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.
|
double[] |
toArray()
Returns a double array copy of this vector.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
byteValue, floatValue, getMax, getMin, getValue, intValue, shortValue
toString
protected double wsum
protected double[] elements
public void put(double[] val)
val
- Valuepublic void put(double[] val, double weight)
val
- dataweight
- weightpublic void put(NumberVector val)
val
- Valuepublic void put(NumberVector val, double weight)
val
- dataweight
- weightpublic double doubleValue(int dimension)
NumberVector
getValue(dim).doubleValue()
, but usually this is much more
efficient due to boxing/unboxing cost.doubleValue
in interface NumberVector
dimension
- the desired dimension, where 0 ≤ dimension <
this.getDimensionality()
public long longValue(int dimension)
NumberVector
getValue(dim).longValue()
, but usually this is much more efficient
due to boxing/unboxing cost.longValue
in interface NumberVector
dimension
- the desired dimension, where 0 ≤ dimension <
this.getDimensionality()
public int getDimensionality()
FeatureVector
getDimensionality
in interface FeatureVector<java.lang.Number>
getDimensionality
in interface SpatialComparable
public double[] toArray()
NumberVector
toArray
in interface NumberVector
double[]
public static Centroid make(Relation<? extends NumberVector> relation, DBIDs ids)
relation
- Relation to useids
- IDs to usepublic double[] getArrayRef()
Copyright © 2019 ELKI Development Team. License information.