public abstract class AbstractMetric extends java.lang.Object implements DistanceMetric
distance(double[], double[])
). This method has to be implemented by classes actually implementing a certain
metric.DistanceMetric.SparcseMetricModes
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PACKAGE_NAME |
Constructor and Description |
---|
AbstractMetric() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkDimensions(double[] vector1,
double[] vector2)
Performs a check on wether the given vectors have the same dimension.
|
protected void |
checkDimensions(cern.colt.matrix.DoubleMatrix1D vector1,
cern.colt.matrix.DoubleMatrix1D vector2)
Performs a check on wether the given vectors have the same dimension.
|
int |
compareTo(DistanceMetric o) |
abstract double |
distance(double[] vector1,
double[] vector2)
Calculates the distance between two vectors provided by argument
vector1 and vector2 . |
double |
distance(double[] vector1,
cern.colt.matrix.DoubleMatrix1D vector2)
Calculates the distance between two vectors provided by argument
vector1 and vector2 . |
double |
distance(double[] vector,
InputDatum data)
Calculates the distance between two vectors provided by argument
vector and datum . |
double |
distance(cern.colt.matrix.DoubleMatrix1D vector1,
double[] vector2)
Calculates the distance between two vectors provided by argument
vector1 and vector2 . |
double |
distance(cern.colt.matrix.DoubleMatrix1D vector1,
cern.colt.matrix.DoubleMatrix1D vector2)
Calculates the distance between two vectors provided by argument
vector1 and vector2 . |
double |
distance(cern.colt.matrix.DoubleMatrix1D vector,
InputDatum datum)
Calculates the distance between two vectors provided by argument
vector and datum . |
double |
distance(InputDatum data,
double[] vector)
Calculates the distance between two vectors provided by argument
datum and vector . |
double |
distance(InputDatum datum,
cern.colt.matrix.DoubleMatrix1D vector)
Calculates the distance between two vectors provided by argument
datum and vector . |
double |
distance(InputDatum datum,
InputDatum datum2)
Calculates the distance between two vectors provided by argument
datum and datum2 . |
static DistanceMetric |
instantiate(java.lang.String mName)
Instantiates a certain distance metric class specified by argument
mName .Note: for backwards compatibility, if the metric name contains the package prefix at.ec3.somtoolbox ,
this will be replaced by at.tuwien.ifs.somtoolbox . |
static DistanceMetric |
instantiateNice(java.lang.String metricName)
Same as
instantiate(String) , but tries to get the metric with the specified name, and then with the
package prefix, and throwing only a SOMToolboxException with the root cause nested. |
static double[] |
meanVector(double[] vector1,
double[] vector2)
Calculates the mean vector of two double array vectors.
|
protected static void |
performanceTest(DistanceMetric metric,
int dim)
Can be used to do some performance testing to compare colt vs.
|
void |
setMetricParams(java.lang.String metricParamString)
Empty implementation, subclasses needing to set parameters have to override this class.
|
double |
transformValue(double value) |
double[] |
transformVector(double[] vector) |
public static DistanceMetric instantiate(java.lang.String mName) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
mName
.prefix at.ec3.somtoolbox
,
this will be replaced by at.tuwien.ifs.somtoolbox
.mName
- the name of the metric.mName
.java.lang.ClassNotFoundException
- if class denoted by argument mName
is not found.java.lang.InstantiationException
- if if this Class represents an abstract class, an interface, an array class, a
primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails
for some other reason.java.lang.IllegalAccessException
- if the class or its nullary constructor is not accessible.public static DistanceMetric instantiateNice(java.lang.String metricName) throws SOMToolboxException
instantiate(String)
, but tries to get the metric with the specified name, and then with the
package prefix, and throwing only a SOMToolboxException
with the root cause nested.SOMToolboxException
public static double[] meanVector(double[] vector1, double[] vector2) throws MetricException
vector1
- first vector.vector2
- second vector.MetricException
- if the dimensionalities of the two vectors differ.protected static void performanceTest(DistanceMetric metric, int dim)
public abstract double distance(double[] vector1, double[] vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.vector1
and vector2
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(double[], double[])
public double distance(double[] vector1, cern.colt.matrix.DoubleMatrix1D vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.vector1
and vector2
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(double[], cern.colt.matrix.DoubleMatrix1D)
public double distance(double[] vector, InputDatum data) throws MetricException
DistanceMetric
vector
and datum
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
vector
- first vector.data
- input datum.vector
and datum
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(double[],
at.tuwien.ifs.somtoolbox.data.InputDatum)
public double distance(cern.colt.matrix.DoubleMatrix1D vector1, double[] vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.vector1
and vector2
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(cern.colt.matrix.DoubleMatrix1D, double[])
public double distance(cern.colt.matrix.DoubleMatrix1D vector1, cern.colt.matrix.DoubleMatrix1D vector2) throws MetricException
DistanceMetric
vector1
and vector2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
vector1
- first vector.vector2
- second vector.vector1
and vector2
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(cern.colt.matrix.DoubleMatrix1D,
cern.colt.matrix.DoubleMatrix1D)
public double distance(cern.colt.matrix.DoubleMatrix1D vector, InputDatum datum) throws MetricException
DistanceMetric
vector
and datum
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
vector
- first vector.datum
- input datum.vector
and datum
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(cern.colt.matrix.DoubleMatrix1D,
at.tuwien.ifs.somtoolbox.data.InputDatum)
public double distance(InputDatum data, double[] vector) throws MetricException
DistanceMetric
datum
and vector
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
data
- input datum.vector
- first vector.datum
and vector
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(at.tuwien.ifs.somtoolbox.data.InputDatum,
double[])
public double distance(InputDatum datum, cern.colt.matrix.DoubleMatrix1D vector) throws MetricException
DistanceMetric
datum
and vector
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
datum
- input datum.vector
- first vector.datum
and vector
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(at.tuwien.ifs.somtoolbox.data.InputDatum,
cern.colt.matrix.DoubleMatrix1D)
public double distance(InputDatum datum, InputDatum datum2) throws MetricException
DistanceMetric
datum
and datum2
. A
MetricException
is thrown, if the dimensionalities of the two vectors differ.distance
in interface DistanceMetric
datum
- first input datum.datum2
- second input datum.datum
and vector
.MetricException
- if the dimensionalities of the two vectors differ.DistanceMetric.distance(at.tuwien.ifs.somtoolbox.data.InputDatum,
at.tuwien.ifs.somtoolbox.data.InputDatum)
protected void checkDimensions(double[] vector1, double[] vector2) throws MetricException
MetricException
- If the given vectors have different dimensions.protected void checkDimensions(cern.colt.matrix.DoubleMatrix1D vector1, cern.colt.matrix.DoubleMatrix1D vector2) throws MetricException
MetricException
- If the given vectors have different dimensions.public double transformValue(double value)
transformValue
in interface DistanceMetric
public double[] transformVector(double[] vector)
transformVector
in interface DistanceMetric
public void setMetricParams(java.lang.String metricParamString) throws SOMToolboxException
setMetricParams
in interface DistanceMetric
SOMToolboxException
public int compareTo(DistanceMetric o)
compareTo
in interface java.lang.Comparable<DistanceMetric>