|
|
|||||||||||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.lmu.ifi.dbs.elki.logging.AbstractLoggable
de.lmu.ifi.dbs.elki.utilities.Util
public final class Util
Field Summary | |
---|---|
private static StaticLogger |
logger
The logger of this class. |
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debug |
Constructor Summary | |
---|---|
private |
Util()
|
Method Summary | ||
---|---|---|
static void |
addFlag(List<String> parameters,
Flag flag)
Adds the specified flag to the beginning of the given parameter list. |
|
static void |
addFlag(List<String> parameters,
OptionID optionID)
Adds the specified optionID of a flag to the beginning of the given parameter list. |
|
static String[] |
addFlag(String[] parameters,
Flag flag)
Adds the specified flag to the beginning of the given parameter array. |
|
static void |
addParameter(List<String> parameters,
OptionID optionID,
String value)
Adds the specified optionID and its value to the beginning of the given parameter list. |
|
static void |
addParameter(List<String> parameters,
Parameter<?,?> parameter,
String value)
Adds the specified parameter and the specified value to the beginning of the given parameter list. |
|
static String[] |
addParameter(String[] parameters,
OptionID optionID,
String value)
Adds the specified optionID and its value to the beginning of the given parameter array. |
|
static String[] |
addParameter(String[] parameters,
Parameter<?,?> parameter,
String value)
Adds the specified parameter and its value to the beginning of the given parameter array. |
|
static
|
centroid(Database<O> database)
Returns the centroid as a RealVector object of the specified database. |
|
static
|
centroid(Database<V> database,
Collection<Integer> ids)
Returns the centroid as a RealVector object of the specified objects stored in the given database. |
|
static
|
centroid(Database<V> database,
Collection<Integer> ids,
BitSet bitSet)
Returns the centroid w.r.t. the dimensions specified by the given BitSet as a RealVector object of the specified objects stored in the given database. |
|
static Vector |
centroid(Matrix data)
Returns the centroid as a Vector object of the specified data matrix. |
|
static double[] |
convertToDoubles(float[] values)
Converts the specified array of doubles to an array of floats. |
|
static double[] |
convertToDoubles(List<Double> values)
Converts the specified list of Double objects to an array of doubles. |
|
static float[] |
convertToFloat(double[] values)
Converts the specified array of doubles to an array of floats. |
|
static List<Float> |
convertToFloat(List<Double> values)
Converts the specified list of double objects to a list of float objects. |
|
static double[] |
copy(double[] array)
Returns a new double array containng the same objects as are contained in the given array. |
|
static String[] |
copy(String[] array)
Returns a new String array containing the same objects as are contained in the given array. |
|
static
|
covarianceMatrix(Database<O> database)
Determines the covariance matrix of the objects stored in the given database. |
|
static
|
covarianceMatrix(Database<V> database,
Collection<Integer> ids)
Determines the covariance matrix of the objects stored in the given database. |
|
static Matrix |
covarianceMatrix(Matrix data)
Determines the d x d covariance matrix of the given n x d data matrix. |
|
static String |
format(BitSet bitSet,
int dim,
String sep)
Returns a string representation of the specified bit set. |
|
static String |
format(boolean b)
Formats the boolean b. |
|
static String |
format(boolean[] b,
String sep)
Formats the boolean array b with ',' as separator. |
|
static String |
format(byte[] a)
Formats the byte array a for printing purposes. |
|
static String |
format(double d)
Formats the double d with 2 fraction digits. |
|
static String |
format(double[] d)
Formats the double array d with ',' as separator and 2 fraction digits. |
|
static String |
format(double[][] d)
Formats the double array d with ',' as separator and 2 fraction digits. |
|
static String |
format(double[][] d,
String sep1,
String sep2,
int digits)
Formats the array of double arrays d with 'the specified separators and fraction digits. |
|
static String |
format(double[] d,
NumberFormat nf)
Formats the double array d with the specified number format. |
|
static String |
format(double[] d,
String sep)
Formats the double array d with the specified separator. |
|
static String |
format(double[] d,
String sep,
int digits)
Formats the double array d with the specified separator and the specified fraction digits. |
|
static String |
format(double[] d,
String sep,
NumberFormat nf)
Formats the double array d with the specified number format. |
|
static String |
format(double d,
int digits)
Formats the double d with the specified fraction digits. |
|
static String |
format(double d,
NumberFormat nf)
Formats the double d with the specified number format. |
|
static String |
format(float[] f)
Formats the float array f with ',' as separator and 2 fraction digits. |
|
static String |
format(float[] f,
String sep,
int digits)
Formats the float array f with the specified separator and the specified fraction digits. |
|
static String |
format(int[] a)
Formats the int array a for printing purposes. |
|
static String |
format(int[] a,
String sep)
Formats the int array a for printing purposes. |
|
static String |
format(int dim,
BitSet bitSet)
Returns a string representation of the specified bit set. |
|
static String |
format(long[] a)
Formats the long array a for printing purposes. |
|
static SortedSet<ClassLabel<?>> |
getClassLabels(Database<?> database)
Retrieves all class labels within the database. |
|
static
|
getDatabaseIDs(Database<O> db)
Returns a collection of the ids of the objects stored in the specified database. |
|
static String |
getFilePrefix(String fileName)
Returns the prefix of the specidfied fileName (i.e. the name of the file without extension). |
|
static int |
getIndexOfMaximum(double[] values)
Returns the index of the maximum of the given values. |
|
static
|
instantiate(Class<T> type,
String className)
Returns a new instance of the given type for the specified className. |
|
static BitSet |
int2Bit(int n)
Converts the specified positive integer value into a bit representation, where bit 0 denotes 20, bit 1 denotes 21 etc. |
|
static
|
intersection(Set<O> s1,
Set<O> s2,
Set<O> result)
Provides the intersection of the two specified sets in the given result set. |
|
static
|
max(D d1,
D d2)
Returns the maximum of the given Distances or the first, if none is greater than the other one. |
|
static double[][] |
min_max(Database<RealVector<?,?>> database)
Determines the minimum and maximum values in each dimension of all objects stored in the given database. |
|
static
|
min(D d1,
D d2)
Returns the minimum of the given Distances or the first, if none is less than the other one. |
|
static
|
optionsNamesToString(List<O> options)
Returns a string representation of the specified list of options containing the names of the options. |
|
static String[] |
parameterDifference(String[] complete,
String[] part)
Returns an array that contains all elements of the first parameter array that are not contained by the second parameter array. |
|
static
|
parameterNamesAndValuesToString(List<N> parameters)
Returns a string representation of the list of number parameters containing the names and the values of the parameters. |
|
static BitSet |
parseBitSet(char[] s)
Returns a new BitSet initialized to the values
represented by the specified char array only containing '0' and '1' values. |
|
static BitSet |
parseBitSet(String s)
Returns a new BitSet initialized to the values
represented by the specified String only containing 0 and 1 values. |
|
static double[] |
parseDoubles(String s)
Returns a new Double array initialized to the values
represented by the specified String and separated by
comma, as performed by the valueOf method of class
Double . |
|
static float[] |
parseFloats(String s)
Returns a new Float array initialized to the values
represented by the specified String and separated by
comma, as performed by the valueOf method of class
Float . |
|
static String |
parseSelectedBits(BitSet b,
String sep)
Returns a string that represents the selected bits of the specified BitSet , while the first bit starts with 1. |
|
static
|
print(List<O> list,
String separator,
PrintStream out)
Prints the given list to the specified PrintStream. |
|
static String |
status(Progress progress)
Provides a status report line with leading carriage return. |
|
static String |
status(Progress progress,
int clusters)
Provides a status report line with leading carriage return. |
|
static String |
transposedGnuplotScript(String filename,
int datasetSize,
int dimensionality)
Provides a script-text for a gnuplot script to use for transposed view of a specific file of given size of data set. |
|
static double[] |
unbox(Double[] array)
Returns the unboxed double array of the given Object Double array. |
|
static double[] |
unbox(Number[] array)
Returns the unboxed double array of the given Object Number array. |
|
static float[] |
unboxToFloat(Number[] array)
Returns the unboxed float array of the given Object Number array. |
|
static
|
variances(Database<O> database)
Determines the variances in each dimension of all objects stored in the given database. |
|
static double[] |
variances(Database<RealVector<?,?>> database,
RealVector<?,?> centroid,
Collection<Integer>[] ids)
Determines the variances in each dimension of the specified objects stored in the given database. |
|
static
|
variances(Database<V> database,
Collection<Integer> ids)
Determines the variances in each dimension of the specified objects stored in the given database. |
|
static
|
variances(Database<V> database,
V centroid,
Collection<Integer> ids)
Determines the variances in each dimension of the specified objects stored in the given database. |
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable |
---|
debugFine, debugFiner, debugFinest, exception, message, progress, progress, progress, verbose, verbose, warning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static StaticLogger logger
Constructor Detail |
---|
private Util()
Method Detail |
---|
public static <D extends Distance<D>> D max(D d1, D d2)
d1
- first Distanced2
- second Distance
public static <D extends Distance<D>> D min(D d1, D d2)
d1
- first Distanced2
- second Distance
public static String format(double d)
d
- the double to be formatted
public static String format(double d, int digits)
d
- the double array to be formatteddigits
- the number of fraction digits
public static String format(double d, NumberFormat nf)
d
- the double array to be formattednf
- the number format to be used for formatting
public static String format(double[] d)
d
- the double array to be formatted
public static String format(double[][] d)
d
- the double array to be formatted
public static String format(double[][] d, String sep1, String sep2, int digits)
d
- the double array to be formattedsep1
- the first separator of the outer arraysep2
- the second separator of the inner arraydigits
- the number of fraction digits
public static String format(double[] d, String sep)
d
- the double array to be formattedsep
- the seperator between the single values of the double array,
e.g. ','
public static String format(double[] d, String sep, int digits)
d
- the double array to be formattedsep
- the seperator between the single values of the double array,
e.g. ','digits
- the number of fraction digits
public static String format(double[] d, NumberFormat nf)
d
- the double array to be formattednf
- the number format to be used for formatting
public static String format(double[] d, String sep, NumberFormat nf)
d
- the double array to be formattedsep
- the seperator between the single values of the double array,
e.g. ','nf
- the number format to be used for formatting
public static String format(float[] f, String sep, int digits)
f
- the float array to be formattedsep
- the seperator between the single values of the float array,
e.g. ','digits
- the number of fraction digits
public static String format(float[] f)
f
- the float array to be formatted
public static String format(int[] a, String sep)
a
- the int array to be formattedsep
- the seperator between the single values of the float array,
e.g. ','
public static String format(int[] a)
a
- the int array to be formatted
public static String format(long[] a)
a
- the long array to be formatted
public static String format(byte[] a)
a
- the byte array to be formatted
public static String format(boolean b)
b
- the boolean to be formatted
public static String format(boolean[] b, String sep)
b
- the boolean array to be formattedsep
- the seperator between the single values of the double array,
e.g. ','
public static String getFilePrefix(String fileName)
fileName
- the name of the file
public static String[] copy(String[] array)
array
- an array to copy
public static double[] copy(double[] array)
array
- an array to copy
public static double[] unbox(Double[] array)
array
- the array to be unboxed
public static double[] unbox(Number[] array)
array
- the array to be unboxed
public static float[] unboxToFloat(Number[] array)
array
- the array to be unboxed
public static <V extends RealVector<V,?>> V centroid(Database<V> database, Collection<Integer> ids)
RealVector
.
database
- the database storing the objectsids
- the ids of the objects
IllegalArgumentException
- if the id list is emptypublic static <V extends RealVector<V,?>> V centroid(Database<V> database, Collection<Integer> ids, BitSet bitSet)
RealVector
.
database
- the database storing the objectsids
- the identifiable objectsbitSet
- the bitSet specifiying the dimensions to be considered
IllegalArgumentException
- if the id list is emptypublic static <O extends RealVector<O,?>> O centroid(Database<O> database)
RealVector
.
database
- the database storing the objects
IllegalArgumentException
- if the database is emptypublic static Vector centroid(Matrix data)
data
- the data matrix, where the data vectors are column vectors
public static <V extends RealVector<V,?>> Matrix covarianceMatrix(Database<V> database, Collection<Integer> ids)
database
- the database storing the objectsids
- the ids of the objects
public static <O extends RealVector<O,?>> Matrix covarianceMatrix(Database<O> database)
database
- the database storing the objects
public static Matrix covarianceMatrix(Matrix data)
data
- the database storing the objects
public static <O extends RealVector<O,?>> double[] variances(Database<O> database)
database
- the database storing the objects
public static <V extends RealVector<V,?>> double[] variances(Database<V> database, Collection<Integer> ids)
variances(database, centroid(database, ids), ids)
database
- the database storing the objectsids
- the ids of the objects
public static <V extends RealVector<V,?>> double[] variances(Database<V> database, V centroid, Collection<Integer> ids)
database
- the database storing the objectsids
- the ids of the objectscentroid
- the centroid or reference vector of the ids
public static double[] variances(Database<RealVector<?,?>> database, RealVector<?,?> centroid, Collection<Integer>[] ids)
database
- the database storing the objectsids
- the array of ids of the objects to be considered in each diemsnioncentroid
- the centroid or reference vector of the ids
public static double[][] min_max(Database<RealVector<?,?>> database)
database
- the database storing the objects
public static double[] parseDoubles(String s)
Double
array initialized to the values
represented by the specified String
and separated by
comma, as performed by the valueOf
method of class
Double
.
s
- the string to be parsed.
Double
array represented by spublic static float[] parseFloats(String s)
Float
array initialized to the values
represented by the specified String
and separated by
comma, as performed by the valueOf
method of class
Float
.
s
- the string to be parsed.
Float
array represented by spublic static List<Float> convertToFloat(List<Double> values)
values
- the list of double objects to be converted
public static float[] convertToFloat(double[] values)
values
- the array of doubles to be converted
public static double[] convertToDoubles(float[] values)
values
- the array of doubles to be converted
public static double[] convertToDoubles(List<Double> values)
values
- the list of Double objects to be converted
public static String transposedGnuplotScript(String filename, int datasetSize, int dimensionality)
filename
- the filename of the transposed file to be plotteddatasetSize
- the size of the transposed data setdimensionality
- the dimensionality of the transposed data set
public static <T> T instantiate(Class<T> type, String className) throws UnableToComplyException
type
- desired Class type of the Object to retrieveclassName
- name of the class to instantiate
UnableToComplyException
- if the instantiation cannot be performed successfullypublic static String status(Progress progress, int clusters)
progress
- the progress statusclusters
- current number of clusters
public static String status(Progress progress)
progress
- the progress status
public static <O> void print(List<O> list, String separator, PrintStream out)
list
- the list to be printedseparator
- the separator to separate entries of the listout
- the target PrintStreampublic static int getIndexOfMaximum(double[] values) throws ArrayIndexOutOfBoundsException
values
- the values to find the index of the maximum
ArrayIndexOutOfBoundsException
- if values.length==0
public static SortedSet<ClassLabel<?>> getClassLabels(Database<?> database)
database
- the database to be scanned for class labels
public static String[] parameterDifference(String[] complete, String[] part) throws IllegalArgumentException
complete
- the complete arraypart
- an array that contains only elements of the first parameter array
IllegalArgumentException
- if the first array, complete
is not as long as
the second array, part
or the second,
part
, contains entries that are not contained
by the first, complete
public static String format(BitSet bitSet, int dim, String sep)
bitSet
- the bitSetdim
- the overall dimensionality of the bit setsep
- the separator
public static String format(int dim, BitSet bitSet)
dim
- the overall dimensionality of the bit setbitSet
- the bitSet
public static BitSet parseBitSet(String s)
BitSet
initialized to the values
represented by the specified String
only containing 0 and 1 values.
s
- the string to be parsed.
BitSet
represented by spublic static BitSet parseBitSet(char[] s)
BitSet
initialized to the values
represented by the specified char
array only containing '0' and '1' values.
s
- the char array to be parsed.
BitSet
represented by spublic static String parseSelectedBits(BitSet b, String sep)
BitSet
, while the first bit starts with 1.
The selected bits are separated
by the specified separator sep
.
b
- the bit set to be parsedsep
- the separator
BitSet
public static <O> void intersection(Set<O> s1, Set<O> s2, Set<O> result)
s1
- the first sets2
- the second setresult
- the result setpublic static BitSet int2Bit(int n)
n
- the positive integer value to be converted
public static <O extends DatabaseObject> Collection<Integer> getDatabaseIDs(Database<O> db)
db
- the database storing the objects
public static String[] addFlag(String[] parameters, Flag flag)
parameters
- the array of parametersflag
- the flag to be added
parameters
and
the specified flag
.public static String[] addParameter(String[] parameters, Parameter<?,?> parameter, String value)
parameters
- the array of parametersparameter
- the parameter to be addedvalue
- the value of the parameter to be added
parameters
and
the specified parameter
and its value
.public static String[] addParameter(String[] parameters, OptionID optionID, String value)
parameters
- the array of parametersoptionID
- the optionID to be addedvalue
- the value of the optionID to be added
parameters
and
the specified optionID
and its value
.public static void addFlag(List<String> parameters, Flag flag)
parameters
- the list of parametersflag
- the flag to be addedpublic static void addFlag(List<String> parameters, OptionID optionID)
parameters
- the list of parametersoptionID
- the optionID to be addedpublic static void addParameter(List<String> parameters, OptionID optionID, String value)
parameters
- the list of parametersoptionID
- the optionID of the parameter to be addedvalue
- the value of the parameter to be addedpublic static void addParameter(List<String> parameters, Parameter<?,?> parameter, String value)
parameters
- the list of parametersparameter
- the parameter to be addedvalue
- the value of the parameter to be addedpublic static <O extends Option<?>> String optionsNamesToString(List<O> options)
options
- the list of options
public static <N extends NumberParameter<?>> String parameterNamesAndValuesToString(List<N> parameters)
parameters
- the list of number parameters
|
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |