repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/BufferedLineReader.java | BufferedLineReader.lengthWithoutLinefeed | public static int lengthWithoutLinefeed(CharSequence line) {
int length = line.length();
while(length > 0) {
char last = line.charAt(length - 1);
if(last != '\n' && last != '\r') {
break;
}
--length;
}
return length;
} | java | public static int lengthWithoutLinefeed(CharSequence line) {
int length = line.length();
while(length > 0) {
char last = line.charAt(length - 1);
if(last != '\n' && last != '\r') {
break;
}
--length;
}
return length;
} | [
"public",
"static",
"int",
"lengthWithoutLinefeed",
"(",
"CharSequence",
"line",
")",
"{",
"int",
"length",
"=",
"line",
".",
"length",
"(",
")",
";",
"while",
"(",
"length",
">",
"0",
")",
"{",
"char",
"last",
"=",
"line",
".",
"charAt",
"(",
"length"... | Get the length of the string, not taking trailing linefeeds into account.
@param line Input line
@return Length | [
"Get",
"the",
"length",
"of",
"the",
"string",
"not",
"taking",
"trailing",
"linefeeds",
"into",
"account",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/BufferedLineReader.java#L185-L195 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/AbstractParameterization.java | AbstractParameterization.logAndClearReportedErrors | public synchronized void logAndClearReportedErrors() {
for(ParameterException e : getErrors()) {
if(LOG.isDebugging()) {
LOG.warning(e.getMessage(), e);
}
else {
LOG.warning(e.getMessage());
}
}
clearErrors();
} | java | public synchronized void logAndClearReportedErrors() {
for(ParameterException e : getErrors()) {
if(LOG.isDebugging()) {
LOG.warning(e.getMessage(), e);
}
else {
LOG.warning(e.getMessage());
}
}
clearErrors();
} | [
"public",
"synchronized",
"void",
"logAndClearReportedErrors",
"(",
")",
"{",
"for",
"(",
"ParameterException",
"e",
":",
"getErrors",
"(",
")",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugging",
"(",
")",
")",
"{",
"LOG",
".",
"warning",
"(",
"e",
".",
"... | Log any error that has accumulated. | [
"Log",
"any",
"error",
"that",
"has",
"accumulated",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/AbstractParameterization.java#L61-L71 | train |
elki-project/elki | elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/configurator/ConfiguratorPanel.java | ConfiguratorPanel.addParameter | public void addParameter(Object owner, Parameter<?> param, TrackParameters track) {
this.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
ParameterConfigurator cfg = null;
{ // Find
Object cur = owner;
while(cur != null) {
cfg = childconfig.get(cur);
if(cfg != null) {
break;
}
cur = track.getParent(cur);
}
}
if(cfg != null) {
cfg.addParameter(owner, param, track);
return;
}
else {
cfg = makeConfigurator(param);
cfg.addChangeListener(this);
children.add(cfg);
}
} | java | public void addParameter(Object owner, Parameter<?> param, TrackParameters track) {
this.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
ParameterConfigurator cfg = null;
{ // Find
Object cur = owner;
while(cur != null) {
cfg = childconfig.get(cur);
if(cfg != null) {
break;
}
cur = track.getParent(cur);
}
}
if(cfg != null) {
cfg.addParameter(owner, param, track);
return;
}
else {
cfg = makeConfigurator(param);
cfg.addChangeListener(this);
children.add(cfg);
}
} | [
"public",
"void",
"addParameter",
"(",
"Object",
"owner",
",",
"Parameter",
"<",
"?",
">",
"param",
",",
"TrackParameters",
"track",
")",
"{",
"this",
".",
"setBorder",
"(",
"new",
"SoftBevelBorder",
"(",
"SoftBevelBorder",
".",
"LOWERED",
")",
")",
";",
"... | Add parameter to this panel.
@param param Parameter to add
@param track Parameter tracking object | [
"Add",
"parameter",
"to",
"this",
"panel",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/configurator/ConfiguratorPanel.java#L87-L109 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/split/AbstractMTreeSplit.java | AbstractMTreeSplit.computeDistanceMatrix | protected static <E extends MTreeEntry, N extends AbstractMTreeNode<?, N, E>> double[][] computeDistanceMatrix(AbstractMTree<?, N, E, ?> tree, N node) {
final int n = node.getNumEntries();
double[][] distancematrix = new double[n][n];
// Build distance matrix
for(int i = 0; i < n; i++) {
E ei = node.getEntry(i);
double[] row_i = distancematrix[i];
for(int j = i + 1; j < n; j++) {
row_i[j] = distancematrix[j][i] = tree.distance(ei, node.getEntry(j));
}
}
return distancematrix;
} | java | protected static <E extends MTreeEntry, N extends AbstractMTreeNode<?, N, E>> double[][] computeDistanceMatrix(AbstractMTree<?, N, E, ?> tree, N node) {
final int n = node.getNumEntries();
double[][] distancematrix = new double[n][n];
// Build distance matrix
for(int i = 0; i < n; i++) {
E ei = node.getEntry(i);
double[] row_i = distancematrix[i];
for(int j = i + 1; j < n; j++) {
row_i[j] = distancematrix[j][i] = tree.distance(ei, node.getEntry(j));
}
}
return distancematrix;
} | [
"protected",
"static",
"<",
"E",
"extends",
"MTreeEntry",
",",
"N",
"extends",
"AbstractMTreeNode",
"<",
"?",
",",
"N",
",",
"E",
">",
">",
"double",
"[",
"]",
"[",
"]",
"computeDistanceMatrix",
"(",
"AbstractMTree",
"<",
"?",
",",
"N",
",",
"E",
",",
... | Compute the pairwise distances in the given node.
@param tree Tree
@param node Node
@return Distance matrix | [
"Compute",
"the",
"pairwise",
"distances",
"in",
"the",
"given",
"node",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/split/AbstractMTreeSplit.java#L66-L78 | train |
elki-project/elki | elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/AbstractAggarwalYuOutlier.java | AbstractAggarwalYuOutlier.sparsity | protected static double sparsity(final int setsize, final int dbsize, final int k, final double phi) {
// calculate sparsity c
final double fK = MathUtil.powi(1. / phi, k);
return (setsize - (dbsize * fK)) / FastMath.sqrt(dbsize * fK * (1 - fK));
} | java | protected static double sparsity(final int setsize, final int dbsize, final int k, final double phi) {
// calculate sparsity c
final double fK = MathUtil.powi(1. / phi, k);
return (setsize - (dbsize * fK)) / FastMath.sqrt(dbsize * fK * (1 - fK));
} | [
"protected",
"static",
"double",
"sparsity",
"(",
"final",
"int",
"setsize",
",",
"final",
"int",
"dbsize",
",",
"final",
"int",
"k",
",",
"final",
"double",
"phi",
")",
"{",
"// calculate sparsity c",
"final",
"double",
"fK",
"=",
"MathUtil",
".",
"powi",
... | Method to calculate the sparsity coefficient of.
@param setsize Size of subset
@param dbsize Size of database
@param k Dimensionality
@param phi Phi parameter
@return sparsity coefficient | [
"Method",
"to",
"calculate",
"the",
"sparsity",
"coefficient",
"of",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/AbstractAggarwalYuOutlier.java#L145-L149 | train |
elki-project/elki | elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/AbstractAggarwalYuOutlier.java | AbstractAggarwalYuOutlier.computeSubspace | protected DBIDs computeSubspace(int[] subspace, ArrayList<ArrayList<DBIDs>> ranges) {
HashSetModifiableDBIDs ids = DBIDUtil.newHashSet(ranges.get(subspace[0]).get(subspace[1]));
// intersect all selected dimensions
for(int i = 2, e = subspace.length - 1; i < e; i += 2) {
DBIDs current = ranges.get(subspace[i]).get(subspace[i + 1] - GENE_OFFSET);
ids.retainAll(current);
if(ids.isEmpty()) {
break;
}
}
return ids;
} | java | protected DBIDs computeSubspace(int[] subspace, ArrayList<ArrayList<DBIDs>> ranges) {
HashSetModifiableDBIDs ids = DBIDUtil.newHashSet(ranges.get(subspace[0]).get(subspace[1]));
// intersect all selected dimensions
for(int i = 2, e = subspace.length - 1; i < e; i += 2) {
DBIDs current = ranges.get(subspace[i]).get(subspace[i + 1] - GENE_OFFSET);
ids.retainAll(current);
if(ids.isEmpty()) {
break;
}
}
return ids;
} | [
"protected",
"DBIDs",
"computeSubspace",
"(",
"int",
"[",
"]",
"subspace",
",",
"ArrayList",
"<",
"ArrayList",
"<",
"DBIDs",
">",
">",
"ranges",
")",
"{",
"HashSetModifiableDBIDs",
"ids",
"=",
"DBIDUtil",
".",
"newHashSet",
"(",
"ranges",
".",
"get",
"(",
... | Method to get the ids in the given subspace.
@param subspace Subspace to process
@param ranges List of DBID ranges
@return ids | [
"Method",
"to",
"get",
"the",
"ids",
"in",
"the",
"given",
"subspace",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/AbstractAggarwalYuOutlier.java#L158-L169 | train |
elki-project/elki | elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/AbstractAggarwalYuOutlier.java | AbstractAggarwalYuOutlier.computeSubspaceForGene | protected DBIDs computeSubspaceForGene(short[] gene, ArrayList<ArrayList<DBIDs>> ranges) {
HashSetModifiableDBIDs m = null;
// intersect all present restrictions
for(int i = 0; i < gene.length; i++) {
if(gene[i] != DONT_CARE) {
DBIDs current = ranges.get(i).get(gene[i] - GENE_OFFSET);
if(m == null) {
m = DBIDUtil.newHashSet(current);
}
else {
m.retainAll(current);
}
}
}
assert (m != null) : "All genes set to '*', should not happen!";
return m;
} | java | protected DBIDs computeSubspaceForGene(short[] gene, ArrayList<ArrayList<DBIDs>> ranges) {
HashSetModifiableDBIDs m = null;
// intersect all present restrictions
for(int i = 0; i < gene.length; i++) {
if(gene[i] != DONT_CARE) {
DBIDs current = ranges.get(i).get(gene[i] - GENE_OFFSET);
if(m == null) {
m = DBIDUtil.newHashSet(current);
}
else {
m.retainAll(current);
}
}
}
assert (m != null) : "All genes set to '*', should not happen!";
return m;
} | [
"protected",
"DBIDs",
"computeSubspaceForGene",
"(",
"short",
"[",
"]",
"gene",
",",
"ArrayList",
"<",
"ArrayList",
"<",
"DBIDs",
">",
">",
"ranges",
")",
"{",
"HashSetModifiableDBIDs",
"m",
"=",
"null",
";",
"// intersect all present restrictions",
"for",
"(",
... | Get the DBIDs in the current subspace.
@param gene gene data
@param ranges Database ranges
@return resulting DBIDs | [
"Get",
"the",
"DBIDs",
"in",
"the",
"current",
"subspace",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/subspace/AbstractAggarwalYuOutlier.java#L178-L194 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/OPTICSXi.java | OPTICSXi.updateFilterSDASet | private static void updateFilterSDASet(double mib, List<SteepDownArea> sdaset, double ixi) {
Iterator<SteepDownArea> iter = sdaset.iterator();
while(iter.hasNext()) {
SteepDownArea sda = iter.next();
if(sda.getMaximum() * ixi <= mib) {
iter.remove();
}
else {
// Update
if(mib > sda.getMib()) {
sda.setMib(mib);
}
}
}
} | java | private static void updateFilterSDASet(double mib, List<SteepDownArea> sdaset, double ixi) {
Iterator<SteepDownArea> iter = sdaset.iterator();
while(iter.hasNext()) {
SteepDownArea sda = iter.next();
if(sda.getMaximum() * ixi <= mib) {
iter.remove();
}
else {
// Update
if(mib > sda.getMib()) {
sda.setMib(mib);
}
}
}
} | [
"private",
"static",
"void",
"updateFilterSDASet",
"(",
"double",
"mib",
",",
"List",
"<",
"SteepDownArea",
">",
"sdaset",
",",
"double",
"ixi",
")",
"{",
"Iterator",
"<",
"SteepDownArea",
">",
"iter",
"=",
"sdaset",
".",
"iterator",
"(",
")",
";",
"while"... | Update the mib values of SteepDownAreas, and remove obsolete areas.
@param mib Maximum in-between value
@param sdaset Set of steep down areas. | [
"Update",
"the",
"mib",
"values",
"of",
"SteepDownAreas",
"and",
"remove",
"obsolete",
"areas",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/optics/OPTICSXi.java#L380-L394 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/arrays/DoubleIntegerArrayQuickSort.java | DoubleIntegerArrayQuickSort.sort5 | private static void sort5(double[] keys, int[] vals, final int m1, final int m2, final int m3, final int m4, final int m5) {
if(keys[m1] > keys[m2]) {
swap(keys, vals, m1, m2);
}
if(keys[m3] > keys[m4]) {
swap(keys, vals, m3, m4);
}
// Merge 1+2 and 3+4
if(keys[m2] > keys[m4]) {
swap(keys, vals, m2, m4);
}
if(keys[m1] > keys[m3]) {
swap(keys, vals, m1, m3);
}
if(keys[m2] > keys[m3]) {
swap(keys, vals, m2, m3);
}
// Insertion sort m5:
if(keys[m4] > keys[m5]) {
swap(keys, vals, m4, m5);
if(keys[m3] > keys[m4]) {
swap(keys, vals, m3, m4);
if(keys[m2] > keys[m3]) {
swap(keys, vals, m2, m3);
if(keys[m1] > keys[m1]) {
swap(keys, vals, m1, m2);
}
}
}
}
} | java | private static void sort5(double[] keys, int[] vals, final int m1, final int m2, final int m3, final int m4, final int m5) {
if(keys[m1] > keys[m2]) {
swap(keys, vals, m1, m2);
}
if(keys[m3] > keys[m4]) {
swap(keys, vals, m3, m4);
}
// Merge 1+2 and 3+4
if(keys[m2] > keys[m4]) {
swap(keys, vals, m2, m4);
}
if(keys[m1] > keys[m3]) {
swap(keys, vals, m1, m3);
}
if(keys[m2] > keys[m3]) {
swap(keys, vals, m2, m3);
}
// Insertion sort m5:
if(keys[m4] > keys[m5]) {
swap(keys, vals, m4, m5);
if(keys[m3] > keys[m4]) {
swap(keys, vals, m3, m4);
if(keys[m2] > keys[m3]) {
swap(keys, vals, m2, m3);
if(keys[m1] > keys[m1]) {
swap(keys, vals, m1, m2);
}
}
}
}
} | [
"private",
"static",
"void",
"sort5",
"(",
"double",
"[",
"]",
"keys",
",",
"int",
"[",
"]",
"vals",
",",
"final",
"int",
"m1",
",",
"final",
"int",
"m2",
",",
"final",
"int",
"m3",
",",
"final",
"int",
"m4",
",",
"final",
"int",
"m5",
")",
"{",
... | An explicit sort, for the five pivot candidates.
Note that this <em>must</em> only be used with
{@code m1 < m2 < m3 < m4 < m5}.
@param keys Keys
@param vals Values
@param m1 Pivot candidate position
@param m2 Pivot candidate position
@param m3 Pivot candidate position
@param m4 Pivot candidate position
@param m5 Pivot candidate position | [
"An",
"explicit",
"sort",
"for",
"the",
"five",
"pivot",
"candidates",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/arrays/DoubleIntegerArrayQuickSort.java#L155-L185 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/arrays/DoubleIntegerArrayQuickSort.java | DoubleIntegerArrayQuickSort.swap | private static void swap(double[] keys, int[] vals, int j, int i) {
double td = keys[j];
keys[j] = keys[i];
keys[i] = td;
int ti = vals[j];
vals[j] = vals[i];
vals[i] = ti;
} | java | private static void swap(double[] keys, int[] vals, int j, int i) {
double td = keys[j];
keys[j] = keys[i];
keys[i] = td;
int ti = vals[j];
vals[j] = vals[i];
vals[i] = ti;
} | [
"private",
"static",
"void",
"swap",
"(",
"double",
"[",
"]",
"keys",
",",
"int",
"[",
"]",
"vals",
",",
"int",
"j",
",",
"int",
"i",
")",
"{",
"double",
"td",
"=",
"keys",
"[",
"j",
"]",
";",
"keys",
"[",
"j",
"]",
"=",
"keys",
"[",
"i",
"... | Swap two entries.
@param keys Keys
@param vals Values
@param j First index
@param i Second index | [
"Swap",
"two",
"entries",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/arrays/DoubleIntegerArrayQuickSort.java#L379-L386 | train |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java | EvaluationResult.newGroup | public EvaluationResult.MeasurementGroup newGroup(String string) {
EvaluationResult.MeasurementGroup g = new MeasurementGroup(string);
groups.add(g);
return g;
} | java | public EvaluationResult.MeasurementGroup newGroup(String string) {
EvaluationResult.MeasurementGroup g = new MeasurementGroup(string);
groups.add(g);
return g;
} | [
"public",
"EvaluationResult",
".",
"MeasurementGroup",
"newGroup",
"(",
"String",
"string",
")",
"{",
"EvaluationResult",
".",
"MeasurementGroup",
"g",
"=",
"new",
"MeasurementGroup",
"(",
"string",
")",
";",
"groups",
".",
"add",
"(",
"g",
")",
";",
"return",... | Add a new measurement group.
@param string Group name
@return Measurement group. | [
"Add",
"a",
"new",
"measurement",
"group",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java#L64-L68 | train |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java | EvaluationResult.findOrCreateGroup | public EvaluationResult.MeasurementGroup findOrCreateGroup(String label) {
for(EvaluationResult.MeasurementGroup g : groups) {
if(label.equals(g.getName())) {
return g;
}
}
return newGroup(label);
} | java | public EvaluationResult.MeasurementGroup findOrCreateGroup(String label) {
for(EvaluationResult.MeasurementGroup g : groups) {
if(label.equals(g.getName())) {
return g;
}
}
return newGroup(label);
} | [
"public",
"EvaluationResult",
".",
"MeasurementGroup",
"findOrCreateGroup",
"(",
"String",
"label",
")",
"{",
"for",
"(",
"EvaluationResult",
".",
"MeasurementGroup",
"g",
":",
"groups",
")",
"{",
"if",
"(",
"label",
".",
"equals",
"(",
"g",
".",
"getName",
... | Find or add a new measurement group.
@param label Group name
@return Measurement group. | [
"Find",
"or",
"add",
"a",
"new",
"measurement",
"group",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java#L76-L83 | train |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java | EvaluationResult.numLines | public int numLines() {
int r = header.size();
for(MeasurementGroup m : groups) {
r += 1 + m.measurements.size();
}
return r;
} | java | public int numLines() {
int r = header.size();
for(MeasurementGroup m : groups) {
r += 1 + m.measurements.size();
}
return r;
} | [
"public",
"int",
"numLines",
"(",
")",
"{",
"int",
"r",
"=",
"header",
".",
"size",
"(",
")",
";",
"for",
"(",
"MeasurementGroup",
"m",
":",
"groups",
")",
"{",
"r",
"+=",
"1",
"+",
"m",
".",
"measurements",
".",
"size",
"(",
")",
";",
"}",
"re... | Number of lines recommended for display.
@return Number of lines | [
"Number",
"of",
"lines",
"recommended",
"for",
"display",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java#L126-L132 | train |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java | EvaluationResult.findOrCreate | public static EvaluationResult findOrCreate(ResultHierarchy hierarchy, Result parent, String name, String shortname) {
ArrayList<EvaluationResult> ers = ResultUtil.filterResults(hierarchy, parent, EvaluationResult.class);
EvaluationResult ev = null;
for(EvaluationResult e : ers) {
if(shortname.equals(e.getShortName())) {
ev = e;
break;
}
}
if(ev == null) {
ev = new EvaluationResult(name, shortname);
hierarchy.add(parent, ev);
}
return ev;
} | java | public static EvaluationResult findOrCreate(ResultHierarchy hierarchy, Result parent, String name, String shortname) {
ArrayList<EvaluationResult> ers = ResultUtil.filterResults(hierarchy, parent, EvaluationResult.class);
EvaluationResult ev = null;
for(EvaluationResult e : ers) {
if(shortname.equals(e.getShortName())) {
ev = e;
break;
}
}
if(ev == null) {
ev = new EvaluationResult(name, shortname);
hierarchy.add(parent, ev);
}
return ev;
} | [
"public",
"static",
"EvaluationResult",
"findOrCreate",
"(",
"ResultHierarchy",
"hierarchy",
",",
"Result",
"parent",
",",
"String",
"name",
",",
"String",
"shortname",
")",
"{",
"ArrayList",
"<",
"EvaluationResult",
">",
"ers",
"=",
"ResultUtil",
".",
"filterResu... | Find or create an evaluation result.
@param hierarchy Result hierarchy.
@param parent Parent result
@param name Long name
@param shortname Short name
@return Evaluation result | [
"Find",
"or",
"create",
"an",
"evaluation",
"result",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/result/EvaluationResult.java#L143-L157 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/DOMCloner.java | DOMCloner.cloneDocument | public Document cloneDocument(DOMImplementation domImpl, Document document) {
Element root = document.getDocumentElement();
// New document
Document result = domImpl.createDocument(root.getNamespaceURI(), root.getNodeName(), null);
Element rroot = result.getDocumentElement();
// Cloning the document element is a bit tricky.
// This is adopted from DomUtilities#deepCloneDocument
boolean before = true;
for(Node n = document.getFirstChild(); n != null; n = n.getNextSibling()) {
if(n == root) {
before = false;
copyAttributes(result, root, rroot);
for(Node c = root.getFirstChild(); c != null; c = c.getNextSibling()) {
final Node cl = cloneNode(result, c);
if(cl != null) {
rroot.appendChild(cl);
}
}
}
else {
if(n.getNodeType() != Node.DOCUMENT_TYPE_NODE) {
final Node cl = cloneNode(result, n);
if(cl != null) {
if(before) {
result.insertBefore(cl, rroot);
}
else {
result.appendChild(cl);
}
}
}
}
}
return result;
} | java | public Document cloneDocument(DOMImplementation domImpl, Document document) {
Element root = document.getDocumentElement();
// New document
Document result = domImpl.createDocument(root.getNamespaceURI(), root.getNodeName(), null);
Element rroot = result.getDocumentElement();
// Cloning the document element is a bit tricky.
// This is adopted from DomUtilities#deepCloneDocument
boolean before = true;
for(Node n = document.getFirstChild(); n != null; n = n.getNextSibling()) {
if(n == root) {
before = false;
copyAttributes(result, root, rroot);
for(Node c = root.getFirstChild(); c != null; c = c.getNextSibling()) {
final Node cl = cloneNode(result, c);
if(cl != null) {
rroot.appendChild(cl);
}
}
}
else {
if(n.getNodeType() != Node.DOCUMENT_TYPE_NODE) {
final Node cl = cloneNode(result, n);
if(cl != null) {
if(before) {
result.insertBefore(cl, rroot);
}
else {
result.appendChild(cl);
}
}
}
}
}
return result;
} | [
"public",
"Document",
"cloneDocument",
"(",
"DOMImplementation",
"domImpl",
",",
"Document",
"document",
")",
"{",
"Element",
"root",
"=",
"document",
".",
"getDocumentElement",
"(",
")",
";",
"// New document",
"Document",
"result",
"=",
"domImpl",
".",
"createDo... | Deep-clone a document.
@param domImpl DOM implementation to use
@param document Original document
@return Cloned document | [
"Deep",
"-",
"clone",
"a",
"document",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/DOMCloner.java#L44-L78 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/DOMCloner.java | DOMCloner.cloneNode | public Node cloneNode(Document doc, Node eold) {
return doc.importNode(eold, true);
} | java | public Node cloneNode(Document doc, Node eold) {
return doc.importNode(eold, true);
} | [
"public",
"Node",
"cloneNode",
"(",
"Document",
"doc",
",",
"Node",
"eold",
")",
"{",
"return",
"doc",
".",
"importNode",
"(",
"eold",
",",
"true",
")",
";",
"}"
] | Clone an existing node.
@param doc Document
@param eold Existing node
@return Cloned node | [
"Clone",
"an",
"existing",
"node",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/DOMCloner.java#L87-L89 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/DOMCloner.java | DOMCloner.copyAttributes | public void copyAttributes(Document doc, Element eold, Element enew) {
if(eold.hasAttributes()) {
NamedNodeMap attr = eold.getAttributes();
int len = attr.getLength();
for(int i = 0; i < len; i++) {
enew.setAttributeNode((Attr) doc.importNode(attr.item(i), true));
}
}
} | java | public void copyAttributes(Document doc, Element eold, Element enew) {
if(eold.hasAttributes()) {
NamedNodeMap attr = eold.getAttributes();
int len = attr.getLength();
for(int i = 0; i < len; i++) {
enew.setAttributeNode((Attr) doc.importNode(attr.item(i), true));
}
}
} | [
"public",
"void",
"copyAttributes",
"(",
"Document",
"doc",
",",
"Element",
"eold",
",",
"Element",
"enew",
")",
"{",
"if",
"(",
"eold",
".",
"hasAttributes",
"(",
")",
")",
"{",
"NamedNodeMap",
"attr",
"=",
"eold",
".",
"getAttributes",
"(",
")",
";",
... | Copy the attributes from an existing node to a new node.
@param doc Target document
@param eold Existing node
@param enew Target node | [
"Copy",
"the",
"attributes",
"from",
"an",
"existing",
"node",
"to",
"a",
"new",
"node",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/xml/DOMCloner.java#L98-L106 | train |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java | TextWriter.getFilename | protected String getFilename(Object result, String filenamepre) {
if(filenamepre == null || filenamepre.length() == 0) {
filenamepre = "result";
}
for(int i = 0;; i++) {
String filename = i > 0 ? filenamepre + "-" + i : filenamepre;
Object existing = filenames.get(filename);
if(existing == null || existing == result) {
filenames.put(filename, result);
return filename;
}
}
} | java | protected String getFilename(Object result, String filenamepre) {
if(filenamepre == null || filenamepre.length() == 0) {
filenamepre = "result";
}
for(int i = 0;; i++) {
String filename = i > 0 ? filenamepre + "-" + i : filenamepre;
Object existing = filenames.get(filename);
if(existing == null || existing == result) {
filenames.put(filename, result);
return filename;
}
}
} | [
"protected",
"String",
"getFilename",
"(",
"Object",
"result",
",",
"String",
"filenamepre",
")",
"{",
"if",
"(",
"filenamepre",
"==",
"null",
"||",
"filenamepre",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"filenamepre",
"=",
"\"result\"",
";",
"}",
... | Try to find a unique file name.
@param result Result we print
@param filenamepre File name prefix to use
@return unique filename | [
"Try",
"to",
"find",
"a",
"unique",
"file",
"name",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java#L144-L156 | train |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java | TextWriter.output | @SuppressWarnings("unchecked")
public void output(Database db, Result r, StreamFactory streamOpener, Pattern filter) throws IOException {
List<Relation<?>> ra = new LinkedList<>();
List<OrderingResult> ro = new LinkedList<>();
List<Clustering<?>> rc = new LinkedList<>();
List<IterableResult<?>> ri = new LinkedList<>();
List<SettingsResult> rs = new LinkedList<>();
List<Result> otherres = new LinkedList<>();
// Split result objects in different known types:
{
List<Result> results = ResultUtil.filterResults(db.getHierarchy(), r, Result.class);
for(Result res : results) {
if(filter != null) {
final String nam = res.getShortName();
if(nam == null || !filter.matcher(nam).find()) {
continue;
}
}
if(res instanceof Database) {
continue;
}
if(res instanceof Relation) {
ra.add((Relation<?>) res);
continue;
}
if(res instanceof OrderingResult) {
ro.add((OrderingResult) res);
continue;
}
if(res instanceof Clustering) {
rc.add((Clustering<?>) res);
continue;
}
if(res instanceof IterableResult) {
ri.add((IterableResult<?>) res);
continue;
}
if(res instanceof SettingsResult) {
rs.add((SettingsResult) res);
continue;
}
otherres.add(res);
}
}
writeSettingsResult(streamOpener, rs);
for(IterableResult<?> rii : ri) {
writeIterableResult(streamOpener, rii);
}
for(Clustering<?> c : rc) {
NamingScheme naming = new SimpleEnumeratingScheme(c);
for(Cluster<?> clus : c.getAllClusters()) {
writeClusterResult(db, streamOpener, (Clustering<Model>) c, (Cluster<Model>) clus, ra, naming);
}
}
for(OrderingResult ror : ro) {
writeOrderingResult(db, streamOpener, ror, ra);
}
for(Result otherr : otherres) {
writeOtherResult(streamOpener, otherr);
}
} | java | @SuppressWarnings("unchecked")
public void output(Database db, Result r, StreamFactory streamOpener, Pattern filter) throws IOException {
List<Relation<?>> ra = new LinkedList<>();
List<OrderingResult> ro = new LinkedList<>();
List<Clustering<?>> rc = new LinkedList<>();
List<IterableResult<?>> ri = new LinkedList<>();
List<SettingsResult> rs = new LinkedList<>();
List<Result> otherres = new LinkedList<>();
// Split result objects in different known types:
{
List<Result> results = ResultUtil.filterResults(db.getHierarchy(), r, Result.class);
for(Result res : results) {
if(filter != null) {
final String nam = res.getShortName();
if(nam == null || !filter.matcher(nam).find()) {
continue;
}
}
if(res instanceof Database) {
continue;
}
if(res instanceof Relation) {
ra.add((Relation<?>) res);
continue;
}
if(res instanceof OrderingResult) {
ro.add((OrderingResult) res);
continue;
}
if(res instanceof Clustering) {
rc.add((Clustering<?>) res);
continue;
}
if(res instanceof IterableResult) {
ri.add((IterableResult<?>) res);
continue;
}
if(res instanceof SettingsResult) {
rs.add((SettingsResult) res);
continue;
}
otherres.add(res);
}
}
writeSettingsResult(streamOpener, rs);
for(IterableResult<?> rii : ri) {
writeIterableResult(streamOpener, rii);
}
for(Clustering<?> c : rc) {
NamingScheme naming = new SimpleEnumeratingScheme(c);
for(Cluster<?> clus : c.getAllClusters()) {
writeClusterResult(db, streamOpener, (Clustering<Model>) c, (Cluster<Model>) clus, ra, naming);
}
}
for(OrderingResult ror : ro) {
writeOrderingResult(db, streamOpener, ror, ra);
}
for(Result otherr : otherres) {
writeOtherResult(streamOpener, otherr);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"void",
"output",
"(",
"Database",
"db",
",",
"Result",
"r",
",",
"StreamFactory",
"streamOpener",
",",
"Pattern",
"filter",
")",
"throws",
"IOException",
"{",
"List",
"<",
"Relation",
"<",
"?",
"... | Stream output.
@param db Database object
@param r Result class
@param streamOpener output stream manager
@param filter Filter pattern
@throws IOException on IO error | [
"Stream",
"output",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java#L167-L230 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppLeafEntry.java | MkAppLeafEntry.writeExternal | @Override
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
out.writeObject(approximation);
} | java | @Override
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
out.writeObject(approximation);
} | [
"@",
"Override",
"public",
"void",
"writeExternal",
"(",
"ObjectOutput",
"out",
")",
"throws",
"IOException",
"{",
"super",
".",
"writeExternal",
"(",
"out",
")",
";",
"out",
".",
"writeObject",
"(",
"approximation",
")",
";",
"}"
] | Calls the super method and writes the polynomiale approximation of the knn
distances of this entry to the specified stream.
@param out the stream to write the object to
@throws java.io.IOException Includes any I/O exceptions that may occur | [
"Calls",
"the",
"super",
"method",
"and",
"writes",
"the",
"polynomiale",
"approximation",
"of",
"the",
"knn",
"distances",
"of",
"this",
"entry",
"to",
"the",
"specified",
"stream",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppLeafEntry.java#L107-L111 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppLeafEntry.java | MkAppLeafEntry.readExternal | @Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
approximation = (PolynomialApproximation) in.readObject();
} | java | @Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
approximation = (PolynomialApproximation) in.readObject();
} | [
"@",
"Override",
"public",
"void",
"readExternal",
"(",
"ObjectInput",
"in",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"super",
".",
"readExternal",
"(",
"in",
")",
";",
"approximation",
"=",
"(",
"PolynomialApproximation",
")",
"in",
"."... | Calls the super method and reads the the polynomial approximation of the
knn distances of this entry from the specified input stream.
@param in the stream to read data from in order to restore the object
@throws java.io.IOException if I/O errors occur
@throws ClassNotFoundException If the class for an object being restored
cannot be found. | [
"Calls",
"the",
"super",
"method",
"and",
"reads",
"the",
"the",
"polynomial",
"approximation",
"of",
"the",
"knn",
"distances",
"of",
"this",
"entry",
"from",
"the",
"specified",
"input",
"stream",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkapp/MkAppLeafEntry.java#L122-L126 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerHierarchyRepresentationResult.java | PointerHierarchyRepresentationResult.computeSubtreeSizes | private WritableIntegerDataStore computeSubtreeSizes(DBIDs order) {
WritableIntegerDataStore siz = DataStoreUtil.makeIntegerStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, 1);
DBIDVar v1 = DBIDUtil.newVar();
for(DBIDIter it = order.iter(); it.valid(); it.advance()) {
if(DBIDUtil.equal(it, parent.assignVar(it, v1))) {
continue;
}
siz.increment(v1, siz.intValue(it));
}
return siz;
} | java | private WritableIntegerDataStore computeSubtreeSizes(DBIDs order) {
WritableIntegerDataStore siz = DataStoreUtil.makeIntegerStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, 1);
DBIDVar v1 = DBIDUtil.newVar();
for(DBIDIter it = order.iter(); it.valid(); it.advance()) {
if(DBIDUtil.equal(it, parent.assignVar(it, v1))) {
continue;
}
siz.increment(v1, siz.intValue(it));
}
return siz;
} | [
"private",
"WritableIntegerDataStore",
"computeSubtreeSizes",
"(",
"DBIDs",
"order",
")",
"{",
"WritableIntegerDataStore",
"siz",
"=",
"DataStoreUtil",
".",
"makeIntegerStorage",
"(",
"ids",
",",
"DataStoreFactory",
".",
"HINT_HOT",
"|",
"DataStoreFactory",
".",
"HINT_T... | Compute the size of all subtrees.
@param order Object order
@return Subtree sizes | [
"Compute",
"the",
"size",
"of",
"all",
"subtrees",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerHierarchyRepresentationResult.java#L186-L196 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerHierarchyRepresentationResult.java | PointerHierarchyRepresentationResult.computeMaxHeight | private WritableDoubleDataStore computeMaxHeight() {
WritableDoubleDataStore maxheight = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, 0.);
DBIDVar v1 = DBIDUtil.newVar();
for(DBIDIter it = ids.iter(); it.valid(); it.advance()) {
double d = parentDistance.doubleValue(it);
if(d > maxheight.doubleValue(it)) {
maxheight.putDouble(it, d);
}
if(d > maxheight.doubleValue(parent.assignVar(it, v1))) {
maxheight.putDouble(v1, d);
}
}
return maxheight;
} | java | private WritableDoubleDataStore computeMaxHeight() {
WritableDoubleDataStore maxheight = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, 0.);
DBIDVar v1 = DBIDUtil.newVar();
for(DBIDIter it = ids.iter(); it.valid(); it.advance()) {
double d = parentDistance.doubleValue(it);
if(d > maxheight.doubleValue(it)) {
maxheight.putDouble(it, d);
}
if(d > maxheight.doubleValue(parent.assignVar(it, v1))) {
maxheight.putDouble(v1, d);
}
}
return maxheight;
} | [
"private",
"WritableDoubleDataStore",
"computeMaxHeight",
"(",
")",
"{",
"WritableDoubleDataStore",
"maxheight",
"=",
"DataStoreUtil",
".",
"makeDoubleStorage",
"(",
"ids",
",",
"DataStoreFactory",
".",
"HINT_HOT",
"|",
"DataStoreFactory",
".",
"HINT_TEMP",
",",
"0.",
... | Compute the maximum height of nodes.
This is necessary, because some linkages may sometimes yield anomalies,
where {@code d(a+b,c) < min(d(a,c), d(b,c))}.
@return Maximum height. | [
"Compute",
"the",
"maximum",
"height",
"of",
"nodes",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerHierarchyRepresentationResult.java#L206-L219 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerHierarchyRepresentationResult.java | PointerHierarchyRepresentationResult.topologicalSort | public ArrayDBIDs topologicalSort() {
ArrayModifiableDBIDs ids = DBIDUtil.newArray(this.ids);
if(mergeOrder != null) {
ids.sort(new DataStoreUtil.AscendingByIntegerDataStore(mergeOrder));
WritableDoubleDataStore maxheight = computeMaxHeight();
ids.sort(new Sorter(maxheight));
maxheight.destroy();
}
else {
ids.sort(new DataStoreUtil.DescendingByDoubleDataStoreAndId(parentDistance));
}
// We used to simply sort by merging distance
// But for e.g. Median Linkage, this would lead to problems, as links are
// not necessarily performed in ascending order anymore!
final int size = ids.size();
ModifiableDBIDs seen = DBIDUtil.newHashSet(size);
ArrayModifiableDBIDs order = DBIDUtil.newArray(size);
DBIDVar v1 = DBIDUtil.newVar(), prev = DBIDUtil.newVar();
// Process merges in descending order
for(DBIDIter it = ids.iter(); it.valid(); it.advance()) {
if(!seen.add(it)) {
continue;
}
final int begin = order.size();
order.add(it);
prev.set(it); // Copy
// Follow parents of prev -> v1 - these need to come before prev.
while(!DBIDUtil.equal(prev, parent.assignVar(prev, v1))) {
if(!seen.add(v1)) {
break;
}
order.add(v1);
prev.set(v1); // Copy
}
// Reverse the inserted path:
for(int i = begin, j = order.size() - 1; i < j; i++, j--) {
order.swap(i, j);
}
}
// Reverse everything
for(int i = 0, j = size - 1; i < j; i++, j--) {
order.swap(i, j);
}
return order;
} | java | public ArrayDBIDs topologicalSort() {
ArrayModifiableDBIDs ids = DBIDUtil.newArray(this.ids);
if(mergeOrder != null) {
ids.sort(new DataStoreUtil.AscendingByIntegerDataStore(mergeOrder));
WritableDoubleDataStore maxheight = computeMaxHeight();
ids.sort(new Sorter(maxheight));
maxheight.destroy();
}
else {
ids.sort(new DataStoreUtil.DescendingByDoubleDataStoreAndId(parentDistance));
}
// We used to simply sort by merging distance
// But for e.g. Median Linkage, this would lead to problems, as links are
// not necessarily performed in ascending order anymore!
final int size = ids.size();
ModifiableDBIDs seen = DBIDUtil.newHashSet(size);
ArrayModifiableDBIDs order = DBIDUtil.newArray(size);
DBIDVar v1 = DBIDUtil.newVar(), prev = DBIDUtil.newVar();
// Process merges in descending order
for(DBIDIter it = ids.iter(); it.valid(); it.advance()) {
if(!seen.add(it)) {
continue;
}
final int begin = order.size();
order.add(it);
prev.set(it); // Copy
// Follow parents of prev -> v1 - these need to come before prev.
while(!DBIDUtil.equal(prev, parent.assignVar(prev, v1))) {
if(!seen.add(v1)) {
break;
}
order.add(v1);
prev.set(v1); // Copy
}
// Reverse the inserted path:
for(int i = begin, j = order.size() - 1; i < j; i++, j--) {
order.swap(i, j);
}
}
// Reverse everything
for(int i = 0, j = size - 1; i < j; i++, j--) {
order.swap(i, j);
}
return order;
} | [
"public",
"ArrayDBIDs",
"topologicalSort",
"(",
")",
"{",
"ArrayModifiableDBIDs",
"ids",
"=",
"DBIDUtil",
".",
"newArray",
"(",
"this",
".",
"ids",
")",
";",
"if",
"(",
"mergeOrder",
"!=",
"null",
")",
"{",
"ids",
".",
"sort",
"(",
"new",
"DataStoreUtil",
... | Topological sort the object IDs.
Even when we have this predefined merge order, it may be sub-optimal.
Such cases arise for example when using NNChain with single-link, as it
does not guarantee to discover merges in ascending order.
Therefore, we employ the following logic:
We process merges in merge order, and note the maximum height of the
subtree.
We then order points by this maximum height, then by their merge order.
@return Sorted object ids. | [
"Topological",
"sort",
"the",
"object",
"IDs",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerHierarchyRepresentationResult.java#L235-L281 | train |
elki-project/elki | elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/SpacefillingKNNPreprocessor.java | SpacefillingKNNPreprocessor.range | public static int[] range(int start, int end) {
int[] out = new int[end - start];
for(int i = 0, j = start; j < end; i++, j++) {
out[i] = j;
}
return out;
} | java | public static int[] range(int start, int end) {
int[] out = new int[end - start];
for(int i = 0, j = start; j < end; i++, j++) {
out[i] = j;
}
return out;
} | [
"public",
"static",
"int",
"[",
"]",
"range",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"int",
"[",
"]",
"out",
"=",
"new",
"int",
"[",
"end",
"-",
"start",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"start",
";",
"j... | Initialize an integer value range.
@param start Starting value
@param end End value (exclusive)
@return Array of integers start..end, excluding end. | [
"Initialize",
"an",
"integer",
"value",
"range",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/SpacefillingKNNPreprocessor.java#L298-L304 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTree.java | MkCoPTree.doReverseKNNQuery | private void doReverseKNNQuery(int k, DBIDRef q, ModifiableDoubleDBIDList result, ModifiableDBIDs candidates) {
final ComparableMinHeap<MTreeSearchCandidate> pq = new ComparableMinHeap<>();
// push root
pq.add(new MTreeSearchCandidate(0., getRootID(), null, Double.NaN));
// search in tree
while(!pq.isEmpty()) {
MTreeSearchCandidate pqNode = pq.poll();
// FIXME: cache the distance to the routing object in the queue node!
MkCoPTreeNode<O> node = getNode(pqNode.nodeID);
// directory node
if(!node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPEntry entry = node.getEntry(i);
double distance = distance(entry.getRoutingObjectID(), q);
double minDist = entry.getCoveringRadius() > distance ? 0. : distance - entry.getCoveringRadius();
double approximatedKnnDist_cons = entry.approximateConservativeKnnDistance(k);
if(minDist <= approximatedKnnDist_cons) {
pq.add(new MTreeSearchCandidate(minDist, getPageID(entry), entry.getRoutingObjectID(), Double.NaN));
}
}
}
// data node
else {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) node.getEntry(i);
double distance = distance(entry.getRoutingObjectID(), q);
double approximatedKnnDist_prog = entry.approximateProgressiveKnnDistance(k);
if(distance <= approximatedKnnDist_prog) {
result.add(distance, entry.getRoutingObjectID());
}
else {
double approximatedKnnDist_cons = entry.approximateConservativeKnnDistance(k);
double diff = distance - approximatedKnnDist_cons;
if(diff <= 1E-10) {
candidates.add(entry.getRoutingObjectID());
}
}
}
}
}
} | java | private void doReverseKNNQuery(int k, DBIDRef q, ModifiableDoubleDBIDList result, ModifiableDBIDs candidates) {
final ComparableMinHeap<MTreeSearchCandidate> pq = new ComparableMinHeap<>();
// push root
pq.add(new MTreeSearchCandidate(0., getRootID(), null, Double.NaN));
// search in tree
while(!pq.isEmpty()) {
MTreeSearchCandidate pqNode = pq.poll();
// FIXME: cache the distance to the routing object in the queue node!
MkCoPTreeNode<O> node = getNode(pqNode.nodeID);
// directory node
if(!node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPEntry entry = node.getEntry(i);
double distance = distance(entry.getRoutingObjectID(), q);
double minDist = entry.getCoveringRadius() > distance ? 0. : distance - entry.getCoveringRadius();
double approximatedKnnDist_cons = entry.approximateConservativeKnnDistance(k);
if(minDist <= approximatedKnnDist_cons) {
pq.add(new MTreeSearchCandidate(minDist, getPageID(entry), entry.getRoutingObjectID(), Double.NaN));
}
}
}
// data node
else {
for(int i = 0; i < node.getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) node.getEntry(i);
double distance = distance(entry.getRoutingObjectID(), q);
double approximatedKnnDist_prog = entry.approximateProgressiveKnnDistance(k);
if(distance <= approximatedKnnDist_prog) {
result.add(distance, entry.getRoutingObjectID());
}
else {
double approximatedKnnDist_cons = entry.approximateConservativeKnnDistance(k);
double diff = distance - approximatedKnnDist_cons;
if(diff <= 1E-10) {
candidates.add(entry.getRoutingObjectID());
}
}
}
}
}
} | [
"private",
"void",
"doReverseKNNQuery",
"(",
"int",
"k",
",",
"DBIDRef",
"q",
",",
"ModifiableDoubleDBIDList",
"result",
",",
"ModifiableDBIDs",
"candidates",
")",
"{",
"final",
"ComparableMinHeap",
"<",
"MTreeSearchCandidate",
">",
"pq",
"=",
"new",
"ComparableMinH... | Performs a reverse knn query.
@param k the parameter k of the rknn query
@param q the id of the query object
@param result holds the true results (they need not to be refined)
@param candidates holds possible candidates for the result (they need a
refinement) | [
"Performs",
"a",
"reverse",
"knn",
"query",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTree.java#L246-L292 | train |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/LRUCache.java | LRUCache.expirePage | protected void expirePage(P page) {
if(LOG.isDebuggingFine()) {
LOG.debugFine("Write to backing:" + page.getPageID());
}
if (page.isDirty()) {
file.writePage(page);
}
} | java | protected void expirePage(P page) {
if(LOG.isDebuggingFine()) {
LOG.debugFine("Write to backing:" + page.getPageID());
}
if (page.isDirty()) {
file.writePage(page);
}
} | [
"protected",
"void",
"expirePage",
"(",
"P",
"page",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebuggingFine",
"(",
")",
")",
"{",
"LOG",
".",
"debugFine",
"(",
"\"Write to backing:\"",
"+",
"page",
".",
"getPageID",
"(",
")",
")",
";",
"}",
"if",
"(",
"pa... | Write page through to disk.
@param page page | [
"Write",
"page",
"through",
"to",
"disk",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/LRUCache.java#L133-L140 | train |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/LRUCache.java | LRUCache.setCacheSize | public void setCacheSize(int cacheSize) {
this.cacheSize = cacheSize;
long toDelete = map.size() - this.cacheSize;
if(toDelete <= 0) {
return;
}
List<Integer> keys = new ArrayList<>(map.keySet());
Collections.reverse(keys);
for(Integer id : keys) {
P page = map.remove(id);
file.writePage(page);
}
} | java | public void setCacheSize(int cacheSize) {
this.cacheSize = cacheSize;
long toDelete = map.size() - this.cacheSize;
if(toDelete <= 0) {
return;
}
List<Integer> keys = new ArrayList<>(map.keySet());
Collections.reverse(keys);
for(Integer id : keys) {
P page = map.remove(id);
file.writePage(page);
}
} | [
"public",
"void",
"setCacheSize",
"(",
"int",
"cacheSize",
")",
"{",
"this",
".",
"cacheSize",
"=",
"cacheSize",
";",
"long",
"toDelete",
"=",
"map",
".",
"size",
"(",
")",
"-",
"this",
".",
"cacheSize",
";",
"if",
"(",
"toDelete",
"<=",
"0",
")",
"{... | Sets the maximum size of this cache.
@param cacheSize the cache size to be set | [
"Sets",
"the",
"maximum",
"size",
"of",
"this",
"cache",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/LRUCache.java#L234-L249 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FileUtil.java | FileUtil.getFilenameExtension | public static String getFilenameExtension(String name) {
if(name == null) {
return null;
}
int index = name.lastIndexOf('.');
return index < 0 ? null : name.substring(index + 1).toLowerCase();
} | java | public static String getFilenameExtension(String name) {
if(name == null) {
return null;
}
int index = name.lastIndexOf('.');
return index < 0 ? null : name.substring(index + 1).toLowerCase();
} | [
"public",
"static",
"String",
"getFilenameExtension",
"(",
"String",
"name",
")",
"{",
"if",
"(",
"name",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"int",
"index",
"=",
"name",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"return",
"index",
... | Returns the lower case extension of the selected file.
If no file is selected, <code>null</code> is returned.
@param name File name
@return Returns the extension of the selected file in lower case or
<code>null</code> | [
"Returns",
"the",
"lower",
"case",
"extension",
"of",
"the",
"selected",
"file",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FileUtil.java#L70-L76 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FileUtil.java | FileUtil.tryGzipInput | public static InputStream tryGzipInput(InputStream in) throws IOException {
// try autodetecting gzip compression.
if(!in.markSupported()) {
PushbackInputStream pb = new PushbackInputStream(in, 16);
// read a magic from the file header, and push it back
byte[] magic = { 0, 0 };
int r = pb.read(magic);
pb.unread(magic, 0, r);
return (magic[0] == 31 && magic[1] == -117) ? new GZIPInputStream(pb) : pb;
}
// Mark is supported.
in.mark(16);
boolean isgzip = ((in.read() << 8) | in.read()) == GZIPInputStream.GZIP_MAGIC;
in.reset(); // Rewind
return isgzip ? new GZIPInputStream(in) : in;
} | java | public static InputStream tryGzipInput(InputStream in) throws IOException {
// try autodetecting gzip compression.
if(!in.markSupported()) {
PushbackInputStream pb = new PushbackInputStream(in, 16);
// read a magic from the file header, and push it back
byte[] magic = { 0, 0 };
int r = pb.read(magic);
pb.unread(magic, 0, r);
return (magic[0] == 31 && magic[1] == -117) ? new GZIPInputStream(pb) : pb;
}
// Mark is supported.
in.mark(16);
boolean isgzip = ((in.read() << 8) | in.read()) == GZIPInputStream.GZIP_MAGIC;
in.reset(); // Rewind
return isgzip ? new GZIPInputStream(in) : in;
} | [
"public",
"static",
"InputStream",
"tryGzipInput",
"(",
"InputStream",
"in",
")",
"throws",
"IOException",
"{",
"// try autodetecting gzip compression.",
"if",
"(",
"!",
"in",
".",
"markSupported",
"(",
")",
")",
"{",
"PushbackInputStream",
"pb",
"=",
"new",
"Push... | Try to open a stream as gzip, if it starts with the gzip magic.
@param in original input stream
@return old input stream or a {@link GZIPInputStream} if appropriate.
@throws IOException on IO error | [
"Try",
"to",
"open",
"a",
"stream",
"as",
"gzip",
"if",
"it",
"starts",
"with",
"the",
"gzip",
"magic",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FileUtil.java#L124-L139 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FileUtil.java | FileUtil.locateFile | public static File locateFile(String name, String basedir) {
// Try exact match first.
File f = new File(name);
if(f.exists()) {
return f;
}
// Try with base directory
if(basedir != null) {
if((f = new File(basedir, name)).exists()) {
return f;
}
}
// try stripping whitespace
String name2;
if(!name.equals(name2 = name.trim())) {
if((f = locateFile(name2, basedir)) != null) {
return f;
}
}
// try substituting path separators
if(!name.equals(name2 = name.replace('/', File.separatorChar))) {
if((f = locateFile(name2, basedir)) != null) {
return f;
}
}
if(!name.equals(name2 = name.replace('\\', File.separatorChar))) {
if((f = locateFile(name2, basedir)) != null) {
return f;
}
}
// try stripping extra characters, such as quotes.
if(name.length() > 2 && name.charAt(0) == '"' && name.charAt(name.length() - 1) == '"') {
if((f = locateFile(name.substring(1, name.length() - 1), basedir)) != null) {
return f;
}
}
return null;
} | java | public static File locateFile(String name, String basedir) {
// Try exact match first.
File f = new File(name);
if(f.exists()) {
return f;
}
// Try with base directory
if(basedir != null) {
if((f = new File(basedir, name)).exists()) {
return f;
}
}
// try stripping whitespace
String name2;
if(!name.equals(name2 = name.trim())) {
if((f = locateFile(name2, basedir)) != null) {
return f;
}
}
// try substituting path separators
if(!name.equals(name2 = name.replace('/', File.separatorChar))) {
if((f = locateFile(name2, basedir)) != null) {
return f;
}
}
if(!name.equals(name2 = name.replace('\\', File.separatorChar))) {
if((f = locateFile(name2, basedir)) != null) {
return f;
}
}
// try stripping extra characters, such as quotes.
if(name.length() > 2 && name.charAt(0) == '"' && name.charAt(name.length() - 1) == '"') {
if((f = locateFile(name.substring(1, name.length() - 1), basedir)) != null) {
return f;
}
}
return null;
} | [
"public",
"static",
"File",
"locateFile",
"(",
"String",
"name",
",",
"String",
"basedir",
")",
"{",
"// Try exact match first.",
"File",
"f",
"=",
"new",
"File",
"(",
"name",
")",
";",
"if",
"(",
"f",
".",
"exists",
"(",
")",
")",
"{",
"return",
"f",
... | Try to locate an file in the filesystem, given a partial name and a prefix.
@param name file name
@param basedir extra base directory to try
@return file, if the file could be found. {@code null} otherwise | [
"Try",
"to",
"locate",
"an",
"file",
"in",
"the",
"filesystem",
"given",
"a",
"partial",
"name",
"and",
"a",
"prefix",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FileUtil.java#L148-L185 | train |
elki-project/elki | elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java | DoubleIntegerDBIDArrayList.addInternal | protected void addInternal(double dist, int id) {
if(size == dists.length) {
grow();
}
dists[size] = dist;
ids[size] = id;
++size;
} | java | protected void addInternal(double dist, int id) {
if(size == dists.length) {
grow();
}
dists[size] = dist;
ids[size] = id;
++size;
} | [
"protected",
"void",
"addInternal",
"(",
"double",
"dist",
",",
"int",
"id",
")",
"{",
"if",
"(",
"size",
"==",
"dists",
".",
"length",
")",
"{",
"grow",
"(",
")",
";",
"}",
"dists",
"[",
"size",
"]",
"=",
"dist",
";",
"ids",
"[",
"size",
"]",
... | Add an entry, consisting of distance and internal index.
@param dist Distance
@param id Internal index | [
"Add",
"an",
"entry",
"consisting",
"of",
"distance",
"and",
"internal",
"index",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java#L132-L139 | train |
elki-project/elki | elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java | DoubleIntegerDBIDArrayList.grow | protected void grow() {
if(dists == EMPTY_DISTS) {
dists = new double[INITIAL_SIZE];
ids = new int[INITIAL_SIZE];
return;
}
final int len = dists.length;
final int newlength = len + (len >> 1) + 1;
double[] odists = dists;
dists = new double[newlength];
System.arraycopy(odists, 0, dists, 0, odists.length);
int[] oids = ids;
ids = new int[newlength];
System.arraycopy(oids, 0, ids, 0, oids.length);
} | java | protected void grow() {
if(dists == EMPTY_DISTS) {
dists = new double[INITIAL_SIZE];
ids = new int[INITIAL_SIZE];
return;
}
final int len = dists.length;
final int newlength = len + (len >> 1) + 1;
double[] odists = dists;
dists = new double[newlength];
System.arraycopy(odists, 0, dists, 0, odists.length);
int[] oids = ids;
ids = new int[newlength];
System.arraycopy(oids, 0, ids, 0, oids.length);
} | [
"protected",
"void",
"grow",
"(",
")",
"{",
"if",
"(",
"dists",
"==",
"EMPTY_DISTS",
")",
"{",
"dists",
"=",
"new",
"double",
"[",
"INITIAL_SIZE",
"]",
";",
"ids",
"=",
"new",
"int",
"[",
"INITIAL_SIZE",
"]",
";",
"return",
";",
"}",
"final",
"int",
... | Grow the data storage. | [
"Grow",
"the",
"data",
"storage",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java#L144-L158 | train |
elki-project/elki | elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java | DoubleIntegerDBIDArrayList.reverse | protected void reverse() {
for(int i = 0, j = size - 1; i < j; i++, j--) {
double tmpd = dists[j];
dists[j] = dists[i];
dists[i] = tmpd;
int tmpi = ids[j];
ids[j] = ids[i];
ids[i] = tmpi;
}
} | java | protected void reverse() {
for(int i = 0, j = size - 1; i < j; i++, j--) {
double tmpd = dists[j];
dists[j] = dists[i];
dists[i] = tmpd;
int tmpi = ids[j];
ids[j] = ids[i];
ids[i] = tmpi;
}
} | [
"protected",
"void",
"reverse",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"j",
"=",
"size",
"-",
"1",
";",
"i",
"<",
"j",
";",
"i",
"++",
",",
"j",
"--",
")",
"{",
"double",
"tmpd",
"=",
"dists",
"[",
"j",
"]",
";",
"dists",
"... | Reverse the list. | [
"Reverse",
"the",
"list",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java#L183-L192 | train |
elki-project/elki | elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java | DoubleIntegerDBIDArrayList.truncate | public void truncate(int newsize) {
if(newsize < size) {
double[] odists = dists;
dists = new double[newsize];
System.arraycopy(odists, 0, dists, 0, newsize);
int[] oids = ids;
ids = new int[newsize];
System.arraycopy(oids, 0, ids, 0, newsize);
size = newsize;
}
} | java | public void truncate(int newsize) {
if(newsize < size) {
double[] odists = dists;
dists = new double[newsize];
System.arraycopy(odists, 0, dists, 0, newsize);
int[] oids = ids;
ids = new int[newsize];
System.arraycopy(oids, 0, ids, 0, newsize);
size = newsize;
}
} | [
"public",
"void",
"truncate",
"(",
"int",
"newsize",
")",
"{",
"if",
"(",
"newsize",
"<",
"size",
")",
"{",
"double",
"[",
"]",
"odists",
"=",
"dists",
";",
"dists",
"=",
"new",
"double",
"[",
"newsize",
"]",
";",
"System",
".",
"arraycopy",
"(",
"... | Truncate the list to the given size, freeing the memory.
@param newsize New size | [
"Truncate",
"the",
"list",
"to",
"the",
"given",
"size",
"freeing",
"the",
"memory",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids-int/src/main/java/de/lmu/ifi/dbs/elki/database/ids/integer/DoubleIntegerDBIDArrayList.java#L230-L240 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java | OverviewPlot.arrangeVisualizations | private RectangleArranger<PlotItem> arrangeVisualizations(double width, double height) {
if(!(width > 0. && height > 0.)) {
LOG.warning("No size information during arrange()", new Throwable());
return new RectangleArranger<>(1., 1.);
}
RectangleArranger<PlotItem> plotmap = new RectangleArranger<>(width, height);
Hierarchy<Object> vistree = context.getVisHierarchy();
for(It<Projector> iter2 = vistree.iterAll().filter(Projector.class); iter2.valid(); iter2.advance()) {
Collection<PlotItem> projs = iter2.get().arrange(context);
for(PlotItem it : projs) {
if(it.w <= 0.0 || it.h <= 0.0) {
LOG.warning("Plot item with improper size information: " + it);
continue;
}
plotmap.put(it.w, it.h, it);
}
}
nextTask: for(It<VisualizationTask> iter2 = vistree.iterAll().filter(VisualizationTask.class); iter2.valid(); iter2.advance()) {
VisualizationTask task = iter2.get();
if(!task.isVisible()) {
continue;
}
if(vistree.iterParents(task).filter(Projector.class).valid()) {
continue nextTask;
}
if(task.getRequestedWidth() <= 0.0 || task.getRequestedHeight() <= 0.0) {
LOG.warning("Task with improper size information: " + task);
continue;
}
PlotItem it = new PlotItem(task.getRequestedWidth(), task.getRequestedHeight(), null);
it.tasks.add(task);
plotmap.put(it.w, it.h, it);
}
return plotmap;
} | java | private RectangleArranger<PlotItem> arrangeVisualizations(double width, double height) {
if(!(width > 0. && height > 0.)) {
LOG.warning("No size information during arrange()", new Throwable());
return new RectangleArranger<>(1., 1.);
}
RectangleArranger<PlotItem> plotmap = new RectangleArranger<>(width, height);
Hierarchy<Object> vistree = context.getVisHierarchy();
for(It<Projector> iter2 = vistree.iterAll().filter(Projector.class); iter2.valid(); iter2.advance()) {
Collection<PlotItem> projs = iter2.get().arrange(context);
for(PlotItem it : projs) {
if(it.w <= 0.0 || it.h <= 0.0) {
LOG.warning("Plot item with improper size information: " + it);
continue;
}
plotmap.put(it.w, it.h, it);
}
}
nextTask: for(It<VisualizationTask> iter2 = vistree.iterAll().filter(VisualizationTask.class); iter2.valid(); iter2.advance()) {
VisualizationTask task = iter2.get();
if(!task.isVisible()) {
continue;
}
if(vistree.iterParents(task).filter(Projector.class).valid()) {
continue nextTask;
}
if(task.getRequestedWidth() <= 0.0 || task.getRequestedHeight() <= 0.0) {
LOG.warning("Task with improper size information: " + task);
continue;
}
PlotItem it = new PlotItem(task.getRequestedWidth(), task.getRequestedHeight(), null);
it.tasks.add(task);
plotmap.put(it.w, it.h, it);
}
return plotmap;
} | [
"private",
"RectangleArranger",
"<",
"PlotItem",
">",
"arrangeVisualizations",
"(",
"double",
"width",
",",
"double",
"height",
")",
"{",
"if",
"(",
"!",
"(",
"width",
">",
"0.",
"&&",
"height",
">",
"0.",
")",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"... | Recompute the layout of visualizations.
@param width Initial width
@param height Initial height
@return Arrangement | [
"Recompute",
"the",
"layout",
"of",
"visualizations",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java#L190-L226 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java | OverviewPlot.initialize | public void initialize(double ratio) {
if(!(ratio > 0 && ratio < Double.POSITIVE_INFINITY)) {
LOG.warning("Invalid ratio: " + ratio, new Throwable());
ratio = 1.4;
}
this.ratio = ratio;
if(plot != null) {
LOG.warning("Already initialized.");
lazyRefresh();
return;
}
reinitialize();
// register context listener
context.addResultListener(this);
context.addVisualizationListener(this);
} | java | public void initialize(double ratio) {
if(!(ratio > 0 && ratio < Double.POSITIVE_INFINITY)) {
LOG.warning("Invalid ratio: " + ratio, new Throwable());
ratio = 1.4;
}
this.ratio = ratio;
if(plot != null) {
LOG.warning("Already initialized.");
lazyRefresh();
return;
}
reinitialize();
// register context listener
context.addResultListener(this);
context.addVisualizationListener(this);
} | [
"public",
"void",
"initialize",
"(",
"double",
"ratio",
")",
"{",
"if",
"(",
"!",
"(",
"ratio",
">",
"0",
"&&",
"ratio",
"<",
"Double",
".",
"POSITIVE_INFINITY",
")",
")",
"{",
"LOG",
".",
"warning",
"(",
"\"Invalid ratio: \"",
"+",
"ratio",
",",
"new"... | Initialize the plot.
@param ratio Initial ratio | [
"Initialize",
"the",
"plot",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java#L233-L248 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java | OverviewPlot.initializePlot | private void initializePlot() {
plot = new VisualizationPlot();
{ // Add a background element:
CSSClass cls = new CSSClass(this, "background");
final String bgcol = context.getStyleLibrary().getBackgroundColor(StyleLibrary.PAGE);
cls.setStatement(SVGConstants.CSS_FILL_PROPERTY, bgcol);
plot.addCSSClassOrLogError(cls);
Element background = plot.svgElement(SVGConstants.SVG_RECT_TAG);
background.setAttribute(SVGConstants.SVG_X_ATTRIBUTE, "0");
background.setAttribute(SVGConstants.SVG_Y_ATTRIBUTE, "0");
background.setAttribute(SVGConstants.SVG_WIDTH_ATTRIBUTE, "100%");
background.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "100%");
SVGUtil.setCSSClass(background, cls.getName());
// Don't export a white background:
if("white".equals(bgcol)) {
background.setAttribute(SVGPlot.NO_EXPORT_ATTRIBUTE, SVGPlot.NO_EXPORT_ATTRIBUTE);
}
plot.getRoot().appendChild(background);
}
{ // setup the hover CSS classes.
selcss = new CSSClass(this, "s");
if(DEBUG_LAYOUT) {
selcss.setStatement(SVGConstants.CSS_STROKE_PROPERTY, SVGConstants.CSS_RED_VALUE);
selcss.setStatement(SVGConstants.CSS_STROKE_WIDTH_PROPERTY, .00001 * StyleLibrary.SCALE);
selcss.setStatement(SVGConstants.CSS_STROKE_OPACITY_PROPERTY, "0.5");
}
selcss.setStatement(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_RED_VALUE);
selcss.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0");
selcss.setStatement(SVGConstants.CSS_CURSOR_PROPERTY, SVGConstants.CSS_POINTER_VALUE);
plot.addCSSClassOrLogError(selcss);
CSSClass hovcss = new CSSClass(this, "h");
hovcss.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0.25");
plot.addCSSClassOrLogError(hovcss);
// Hover listener.
hoverer = new CSSHoverClass(hovcss.getName(), null, true);
}
// Disable Batik default interactions (zoom, rotate, etc.)
if(single) {
plot.setDisableInteractions(true);
}
SVGEffects.addShadowFilter(plot);
SVGEffects.addLightGradient(plot);
} | java | private void initializePlot() {
plot = new VisualizationPlot();
{ // Add a background element:
CSSClass cls = new CSSClass(this, "background");
final String bgcol = context.getStyleLibrary().getBackgroundColor(StyleLibrary.PAGE);
cls.setStatement(SVGConstants.CSS_FILL_PROPERTY, bgcol);
plot.addCSSClassOrLogError(cls);
Element background = plot.svgElement(SVGConstants.SVG_RECT_TAG);
background.setAttribute(SVGConstants.SVG_X_ATTRIBUTE, "0");
background.setAttribute(SVGConstants.SVG_Y_ATTRIBUTE, "0");
background.setAttribute(SVGConstants.SVG_WIDTH_ATTRIBUTE, "100%");
background.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "100%");
SVGUtil.setCSSClass(background, cls.getName());
// Don't export a white background:
if("white".equals(bgcol)) {
background.setAttribute(SVGPlot.NO_EXPORT_ATTRIBUTE, SVGPlot.NO_EXPORT_ATTRIBUTE);
}
plot.getRoot().appendChild(background);
}
{ // setup the hover CSS classes.
selcss = new CSSClass(this, "s");
if(DEBUG_LAYOUT) {
selcss.setStatement(SVGConstants.CSS_STROKE_PROPERTY, SVGConstants.CSS_RED_VALUE);
selcss.setStatement(SVGConstants.CSS_STROKE_WIDTH_PROPERTY, .00001 * StyleLibrary.SCALE);
selcss.setStatement(SVGConstants.CSS_STROKE_OPACITY_PROPERTY, "0.5");
}
selcss.setStatement(SVGConstants.CSS_FILL_PROPERTY, SVGConstants.CSS_RED_VALUE);
selcss.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0");
selcss.setStatement(SVGConstants.CSS_CURSOR_PROPERTY, SVGConstants.CSS_POINTER_VALUE);
plot.addCSSClassOrLogError(selcss);
CSSClass hovcss = new CSSClass(this, "h");
hovcss.setStatement(SVGConstants.CSS_FILL_OPACITY_PROPERTY, "0.25");
plot.addCSSClassOrLogError(hovcss);
// Hover listener.
hoverer = new CSSHoverClass(hovcss.getName(), null, true);
}
// Disable Batik default interactions (zoom, rotate, etc.)
if(single) {
plot.setDisableInteractions(true);
}
SVGEffects.addShadowFilter(plot);
SVGEffects.addLightGradient(plot);
} | [
"private",
"void",
"initializePlot",
"(",
")",
"{",
"plot",
"=",
"new",
"VisualizationPlot",
"(",
")",
";",
"{",
"// Add a background element:",
"CSSClass",
"cls",
"=",
"new",
"CSSClass",
"(",
"this",
",",
"\"background\"",
")",
";",
"final",
"String",
"bgcol"... | Initialize the SVG plot. | [
"Initialize",
"the",
"SVG",
"plot",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java#L348-L391 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java | OverviewPlot.embedOrThumbnail | private Visualization embedOrThumbnail(final int thumbsize, PlotItem it, VisualizationTask task, Element parent) {
final Visualization vis;
if(!single) {
vis = task.getFactory().makeVisualizationOrThumbnail(context, task, plot, it.w, it.h, it.proj, thumbsize);
}
else {
vis = task.getFactory().makeVisualization(context, task, plot, it.w, it.h, it.proj);
}
if(vis == null || vis.getLayer() == null) {
LOG.warning("Visualization returned empty layer: " + vis);
return vis;
}
if(task.has(RenderFlag.NO_EXPORT)) {
vis.getLayer().setAttribute(SVGPlot.NO_EXPORT_ATTRIBUTE, SVGPlot.NO_EXPORT_ATTRIBUTE);
}
parent.appendChild(vis.getLayer());
return vis;
} | java | private Visualization embedOrThumbnail(final int thumbsize, PlotItem it, VisualizationTask task, Element parent) {
final Visualization vis;
if(!single) {
vis = task.getFactory().makeVisualizationOrThumbnail(context, task, plot, it.w, it.h, it.proj, thumbsize);
}
else {
vis = task.getFactory().makeVisualization(context, task, plot, it.w, it.h, it.proj);
}
if(vis == null || vis.getLayer() == null) {
LOG.warning("Visualization returned empty layer: " + vis);
return vis;
}
if(task.has(RenderFlag.NO_EXPORT)) {
vis.getLayer().setAttribute(SVGPlot.NO_EXPORT_ATTRIBUTE, SVGPlot.NO_EXPORT_ATTRIBUTE);
}
parent.appendChild(vis.getLayer());
return vis;
} | [
"private",
"Visualization",
"embedOrThumbnail",
"(",
"final",
"int",
"thumbsize",
",",
"PlotItem",
"it",
",",
"VisualizationTask",
"task",
",",
"Element",
"parent",
")",
"{",
"final",
"Visualization",
"vis",
";",
"if",
"(",
"!",
"single",
")",
"{",
"vis",
"=... | Produce thumbnail for a visualizer.
@param thumbsize Thumbnail size
@param it Plot item
@param task Task
@param parent Parent element to draw to | [
"Produce",
"thumbnail",
"for",
"a",
"visualizer",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java#L401-L418 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java | OverviewPlot.visibleInOverview | protected boolean visibleInOverview(VisualizationTask task) {
return task.isVisible() && !task.has(single ? RenderFlag.NO_EMBED : RenderFlag.NO_THUMBNAIL);
} | java | protected boolean visibleInOverview(VisualizationTask task) {
return task.isVisible() && !task.has(single ? RenderFlag.NO_EMBED : RenderFlag.NO_THUMBNAIL);
} | [
"protected",
"boolean",
"visibleInOverview",
"(",
"VisualizationTask",
"task",
")",
"{",
"return",
"task",
".",
"isVisible",
"(",
")",
"&&",
"!",
"task",
".",
"has",
"(",
"single",
"?",
"RenderFlag",
".",
"NO_EMBED",
":",
"RenderFlag",
".",
"NO_THUMBNAIL",
"... | Test whether a task should be displayed in the overview plot.
@param task Task to display
@return visibility | [
"Test",
"whether",
"a",
"task",
"should",
"be",
"displayed",
"in",
"the",
"overview",
"plot",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java#L483-L485 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java | OverviewPlot.recalcViewbox | private void recalcViewbox() {
final Element root = plot.getRoot();
// Reset plot attributes
SVGUtil.setAtt(root, SVGConstants.SVG_WIDTH_ATTRIBUTE, "20cm");
SVGUtil.setAtt(root, SVGConstants.SVG_HEIGHT_ATTRIBUTE, SVGUtil.fmt(20 * plotmap.getHeight() / plotmap.getWidth()) + "cm");
String vb = "0 0 " + SVGUtil.fmt(plotmap.getWidth()) + " " + SVGUtil.fmt(plotmap.getHeight());
SVGUtil.setAtt(root, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE, vb);
} | java | private void recalcViewbox() {
final Element root = plot.getRoot();
// Reset plot attributes
SVGUtil.setAtt(root, SVGConstants.SVG_WIDTH_ATTRIBUTE, "20cm");
SVGUtil.setAtt(root, SVGConstants.SVG_HEIGHT_ATTRIBUTE, SVGUtil.fmt(20 * plotmap.getHeight() / plotmap.getWidth()) + "cm");
String vb = "0 0 " + SVGUtil.fmt(plotmap.getWidth()) + " " + SVGUtil.fmt(plotmap.getHeight());
SVGUtil.setAtt(root, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE, vb);
} | [
"private",
"void",
"recalcViewbox",
"(",
")",
"{",
"final",
"Element",
"root",
"=",
"plot",
".",
"getRoot",
"(",
")",
";",
"// Reset plot attributes",
"SVGUtil",
".",
"setAtt",
"(",
"root",
",",
"SVGConstants",
".",
"SVG_WIDTH_ATTRIBUTE",
",",
"\"20cm\"",
")",... | Recompute the view box of the plot. | [
"Recompute",
"the",
"view",
"box",
"of",
"the",
"plot",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java#L490-L497 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java | OverviewPlot.triggerSubplotSelectEvent | protected void triggerSubplotSelectEvent(PlotItem it) {
// forward event to all listeners.
for(ActionListener actionListener : actionListeners) {
actionListener.actionPerformed(new DetailViewSelectedEvent(this, ActionEvent.ACTION_PERFORMED, null, 0, it));
}
} | java | protected void triggerSubplotSelectEvent(PlotItem it) {
// forward event to all listeners.
for(ActionListener actionListener : actionListeners) {
actionListener.actionPerformed(new DetailViewSelectedEvent(this, ActionEvent.ACTION_PERFORMED, null, 0, it));
}
} | [
"protected",
"void",
"triggerSubplotSelectEvent",
"(",
"PlotItem",
"it",
")",
"{",
"// forward event to all listeners.",
"for",
"(",
"ActionListener",
"actionListener",
":",
"actionListeners",
")",
"{",
"actionListener",
".",
"actionPerformed",
"(",
"new",
"DetailViewSele... | When a subplot was selected, forward the event to listeners.
@param it PlotItem selected | [
"When",
"a",
"subplot",
"was",
"selected",
"forward",
"the",
"event",
"to",
"listeners",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/gui/overview/OverviewPlot.java#L523-L528 | train |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GeneralizedParetoDistribution.java | GeneralizedParetoDistribution.cdf | public static double cdf(double val, double mu, double sigma, double xi) {
val = (val - mu) / sigma;
// Check support:
if(val < 0) {
return 0.;
}
if(xi < 0 && val > -1. / xi) {
return 1.;
}
return 1 - FastMath.pow(1 + xi * val, -1. / xi);
} | java | public static double cdf(double val, double mu, double sigma, double xi) {
val = (val - mu) / sigma;
// Check support:
if(val < 0) {
return 0.;
}
if(xi < 0 && val > -1. / xi) {
return 1.;
}
return 1 - FastMath.pow(1 + xi * val, -1. / xi);
} | [
"public",
"static",
"double",
"cdf",
"(",
"double",
"val",
",",
"double",
"mu",
",",
"double",
"sigma",
",",
"double",
"xi",
")",
"{",
"val",
"=",
"(",
"val",
"-",
"mu",
")",
"/",
"sigma",
";",
"// Check support:",
"if",
"(",
"val",
"<",
"0",
")",
... | CDF of GPD distribution
@param val Value
@param mu Location parameter mu
@param sigma Scale parameter sigma
@param xi Shape parameter xi (= -kappa)
@return CDF at position x. | [
"CDF",
"of",
"GPD",
"distribution"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GeneralizedParetoDistribution.java#L169-L179 | train |
elki-project/elki | elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GeneralizedParetoDistribution.java | GeneralizedParetoDistribution.quantile | public static double quantile(double val, double mu, double sigma, double xi) {
if(val < 0.0 || val > 1.0) {
return Double.NaN;
}
if(xi == 0.) {
return mu - sigma * FastMath.log(1 - val);
}
return mu - sigma / xi * (1 - FastMath.pow(1 - val, -xi));
} | java | public static double quantile(double val, double mu, double sigma, double xi) {
if(val < 0.0 || val > 1.0) {
return Double.NaN;
}
if(xi == 0.) {
return mu - sigma * FastMath.log(1 - val);
}
return mu - sigma / xi * (1 - FastMath.pow(1 - val, -xi));
} | [
"public",
"static",
"double",
"quantile",
"(",
"double",
"val",
",",
"double",
"mu",
",",
"double",
"sigma",
",",
"double",
"xi",
")",
"{",
"if",
"(",
"val",
"<",
"0.0",
"||",
"val",
">",
"1.0",
")",
"{",
"return",
"Double",
".",
"NaN",
";",
"}",
... | Quantile function of GPD distribution
@param val Value
@param mu Location parameter mu
@param sigma Scale parameter sigma
@param xi Shape parameter xi (= -kappa)
@return Quantile function at position x. | [
"Quantile",
"function",
"of",
"GPD",
"distribution"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GeneralizedParetoDistribution.java#L195-L203 | train |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/benchmark/RangeQueryBenchmarkAlgorithm.java | RangeQueryBenchmarkAlgorithm.run | public Result run(Database database, Relation<O> relation, Relation<NumberVector> radrel) {
if(queries != null) {
throw new AbortException("This 'run' method will not use the given query set!");
}
// Get a distance and kNN query instance.
DistanceQuery<O> distQuery = database.getDistanceQuery(relation, getDistanceFunction());
RangeQuery<O> rangeQuery = database.getRangeQuery(distQuery);
final DBIDs sample = DBIDUtil.randomSample(relation.getDBIDs(), sampling, random);
FiniteProgress prog = LOG.isVeryVerbose() ? new FiniteProgress("kNN queries", sample.size(), LOG) : null;
int hash = 0;
MeanVariance mv = new MeanVariance();
for(DBIDIter iditer = sample.iter(); iditer.valid(); iditer.advance()) {
double r = radrel.get(iditer).doubleValue(0);
DoubleDBIDList rres = rangeQuery.getRangeForDBID(iditer, r);
int ichecksum = 0;
for(DBIDIter it = rres.iter(); it.valid(); it.advance()) {
ichecksum += DBIDUtil.asInteger(it);
}
hash = Util.mixHashCodes(hash, ichecksum);
mv.put(rres.size());
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
if(LOG.isStatistics()) {
LOG.statistics("Result hashcode: " + hash);
LOG.statistics("Mean number of results: " + mv.getMean() + " +- " + mv.getNaiveStddev());
}
return null;
} | java | public Result run(Database database, Relation<O> relation, Relation<NumberVector> radrel) {
if(queries != null) {
throw new AbortException("This 'run' method will not use the given query set!");
}
// Get a distance and kNN query instance.
DistanceQuery<O> distQuery = database.getDistanceQuery(relation, getDistanceFunction());
RangeQuery<O> rangeQuery = database.getRangeQuery(distQuery);
final DBIDs sample = DBIDUtil.randomSample(relation.getDBIDs(), sampling, random);
FiniteProgress prog = LOG.isVeryVerbose() ? new FiniteProgress("kNN queries", sample.size(), LOG) : null;
int hash = 0;
MeanVariance mv = new MeanVariance();
for(DBIDIter iditer = sample.iter(); iditer.valid(); iditer.advance()) {
double r = radrel.get(iditer).doubleValue(0);
DoubleDBIDList rres = rangeQuery.getRangeForDBID(iditer, r);
int ichecksum = 0;
for(DBIDIter it = rres.iter(); it.valid(); it.advance()) {
ichecksum += DBIDUtil.asInteger(it);
}
hash = Util.mixHashCodes(hash, ichecksum);
mv.put(rres.size());
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
if(LOG.isStatistics()) {
LOG.statistics("Result hashcode: " + hash);
LOG.statistics("Mean number of results: " + mv.getMean() + " +- " + mv.getNaiveStddev());
}
return null;
} | [
"public",
"Result",
"run",
"(",
"Database",
"database",
",",
"Relation",
"<",
"O",
">",
"relation",
",",
"Relation",
"<",
"NumberVector",
">",
"radrel",
")",
"{",
"if",
"(",
"queries",
"!=",
"null",
")",
"{",
"throw",
"new",
"AbortException",
"(",
"\"Thi... | Run the algorithm, with separate radius relation
@param database Database
@param relation Relation
@param radrel Radius relation
@return Null result | [
"Run",
"the",
"algorithm",
"with",
"separate",
"radius",
"relation"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/benchmark/RangeQueryBenchmarkAlgorithm.java#L141-L170 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.random | public static long[] random(int card, int capacity, Random random) {
if(card < 0 || card > capacity) {
throw new IllegalArgumentException("Cannot set " + card + " out of " + capacity + " bits.");
}
// FIXME: Avoid recomputing the cardinality.
if(card < capacity >>> 1) {
long[] bitset = BitsUtil.zero(capacity);
for(int todo = card; todo > 0; //
todo = (todo == 1) ? (card - cardinality(bitset)) : (todo - 1)) {
setI(bitset, random.nextInt(capacity));
}
return bitset;
}
else {
long[] bitset = BitsUtil.ones(capacity);
for(int todo = capacity - card; todo > 0; //
todo = (todo == 1) ? (cardinality(bitset) - card) : (todo - 1)) {
clearI(bitset, random.nextInt(capacity));
}
return bitset;
}
} | java | public static long[] random(int card, int capacity, Random random) {
if(card < 0 || card > capacity) {
throw new IllegalArgumentException("Cannot set " + card + " out of " + capacity + " bits.");
}
// FIXME: Avoid recomputing the cardinality.
if(card < capacity >>> 1) {
long[] bitset = BitsUtil.zero(capacity);
for(int todo = card; todo > 0; //
todo = (todo == 1) ? (card - cardinality(bitset)) : (todo - 1)) {
setI(bitset, random.nextInt(capacity));
}
return bitset;
}
else {
long[] bitset = BitsUtil.ones(capacity);
for(int todo = capacity - card; todo > 0; //
todo = (todo == 1) ? (cardinality(bitset) - card) : (todo - 1)) {
clearI(bitset, random.nextInt(capacity));
}
return bitset;
}
} | [
"public",
"static",
"long",
"[",
"]",
"random",
"(",
"int",
"card",
",",
"int",
"capacity",
",",
"Random",
"random",
")",
"{",
"if",
"(",
"card",
"<",
"0",
"||",
"card",
">",
"capacity",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Can... | Creates a new BitSet of fixed cardinality with randomly set bits.
@param card the cardinality of the BitSet to create
@param capacity the capacity of the BitSet to create - the randomly
generated indices of the bits set to true will be uniformly
distributed between 0 (inclusive) and capacity (exclusive)
@param random a Random Object to create the sequence of indices set to true
- the same number occurring twice or more is ignored but the already
selected bit remains true
@return a new BitSet with randomly set bits | [
"Creates",
"a",
"new",
"BitSet",
"of",
"fixed",
"cardinality",
"with",
"randomly",
"set",
"bits",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L134-L155 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.copy | public static long[] copy(long[] v, int mincap) {
int words = ((mincap - 1) >>> LONG_LOG2_SIZE) + 1;
if(v.length == words) {
return Arrays.copyOf(v, v.length);
}
long[] ret = new long[words];
System.arraycopy(v, 0, ret, 0, Math.min(v.length, words));
return ret;
} | java | public static long[] copy(long[] v, int mincap) {
int words = ((mincap - 1) >>> LONG_LOG2_SIZE) + 1;
if(v.length == words) {
return Arrays.copyOf(v, v.length);
}
long[] ret = new long[words];
System.arraycopy(v, 0, ret, 0, Math.min(v.length, words));
return ret;
} | [
"public",
"static",
"long",
"[",
"]",
"copy",
"(",
"long",
"[",
"]",
"v",
",",
"int",
"mincap",
")",
"{",
"int",
"words",
"=",
"(",
"(",
"mincap",
"-",
"1",
")",
">>>",
"LONG_LOG2_SIZE",
")",
"+",
"1",
";",
"if",
"(",
"v",
".",
"length",
"==",
... | Copy a bitset.
Note: Bits beyond mincap <em>may</em> be retained!
@param v Array to copy
@param mincap Target <em>minimum</em> capacity
@return Copy with space for at least "capacity" bits | [
"Copy",
"a",
"bitset",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L176-L184 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.isZero | public static boolean isZero(long[] v) {
for(int i = 0; i < v.length; i++) {
if(v[i] != 0) {
return false;
}
}
return true;
} | java | public static boolean isZero(long[] v) {
for(int i = 0; i < v.length; i++) {
if(v[i] != 0) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"isZero",
"(",
"long",
"[",
"]",
"v",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"v",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"v",
"[",
"i",
"]",
"!=",
"0",
")",
"{",
"return",
"f... | Test for the bitstring to be all-zero.
@param v Bitstring
@return true when all zero | [
"Test",
"for",
"the",
"bitstring",
"to",
"be",
"all",
"-",
"zero",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L291-L298 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.setI | public static long[] setI(long[] v, long[] o) {
assert (o.length <= v.length) : "Bit set sizes do not agree.";
final int max = Math.min(v.length, o.length);
for(int i = 0; i < max; i++) {
v[i] = o[i];
}
return v;
} | java | public static long[] setI(long[] v, long[] o) {
assert (o.length <= v.length) : "Bit set sizes do not agree.";
final int max = Math.min(v.length, o.length);
for(int i = 0; i < max; i++) {
v[i] = o[i];
}
return v;
} | [
"public",
"static",
"long",
"[",
"]",
"setI",
"(",
"long",
"[",
"]",
"v",
",",
"long",
"[",
"]",
"o",
")",
"{",
"assert",
"(",
"o",
".",
"length",
"<=",
"v",
".",
"length",
")",
":",
"\"Bit set sizes do not agree.\"",
";",
"final",
"int",
"max",
"=... | Put o onto v in-place, i.e. v = o
@param v Primary object
@param o data to initialize to.
@return v | [
"Put",
"o",
"onto",
"v",
"in",
"-",
"place",
"i",
".",
"e",
".",
"v",
"=",
"o"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L381-L388 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.onesI | public static void onesI(long[] v, int bits) {
final int fillWords = bits >>> LONG_LOG2_SIZE;
final int fillBits = bits & LONG_LOG2_MASK;
Arrays.fill(v, 0, fillWords, LONG_ALL_BITS);
if(fillBits > 0) {
v[fillWords] = (1L << fillBits) - 1;
}
if(fillWords + 1 < v.length) {
Arrays.fill(v, fillWords + 1, v.length, 0L);
}
} | java | public static void onesI(long[] v, int bits) {
final int fillWords = bits >>> LONG_LOG2_SIZE;
final int fillBits = bits & LONG_LOG2_MASK;
Arrays.fill(v, 0, fillWords, LONG_ALL_BITS);
if(fillBits > 0) {
v[fillWords] = (1L << fillBits) - 1;
}
if(fillWords + 1 < v.length) {
Arrays.fill(v, fillWords + 1, v.length, 0L);
}
} | [
"public",
"static",
"void",
"onesI",
"(",
"long",
"[",
"]",
"v",
",",
"int",
"bits",
")",
"{",
"final",
"int",
"fillWords",
"=",
"bits",
">>>",
"LONG_LOG2_SIZE",
";",
"final",
"int",
"fillBits",
"=",
"bits",
"&",
"LONG_LOG2_MASK",
";",
"Arrays",
".",
"... | Fill a vector initialized with "bits" ones.
@param v Vector to fill.
@param bits Size | [
"Fill",
"a",
"vector",
"initialized",
"with",
"bits",
"ones",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L443-L453 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.xorI | public static long[] xorI(long[] v, long[] o) {
assert (o.length <= v.length) : "Bit set sizes do not agree.";
for(int i = 0; i < o.length; i++) {
v[i] ^= o[i];
}
return v;
} | java | public static long[] xorI(long[] v, long[] o) {
assert (o.length <= v.length) : "Bit set sizes do not agree.";
for(int i = 0; i < o.length; i++) {
v[i] ^= o[i];
}
return v;
} | [
"public",
"static",
"long",
"[",
"]",
"xorI",
"(",
"long",
"[",
"]",
"v",
",",
"long",
"[",
"]",
"o",
")",
"{",
"assert",
"(",
"o",
".",
"length",
"<=",
"v",
".",
"length",
")",
":",
"\"Bit set sizes do not agree.\"",
";",
"for",
"(",
"int",
"i",
... | XOR o onto v in-place, i.e. v ^= o
@param v Primary object
@param o data to xor
@return v | [
"XOR",
"o",
"onto",
"v",
"in",
"-",
"place",
"i",
".",
"e",
".",
"v",
"^",
"=",
"o"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L475-L481 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.orI | public static long[] orI(long[] v, long[] o) {
assert (o.length <= v.length) : "Bit set sizes do not agree.";
final int max = Math.min(v.length, o.length);
for(int i = 0; i < max; i++) {
v[i] |= o[i];
}
return v;
} | java | public static long[] orI(long[] v, long[] o) {
assert (o.length <= v.length) : "Bit set sizes do not agree.";
final int max = Math.min(v.length, o.length);
for(int i = 0; i < max; i++) {
v[i] |= o[i];
}
return v;
} | [
"public",
"static",
"long",
"[",
"]",
"orI",
"(",
"long",
"[",
"]",
"v",
",",
"long",
"[",
"]",
"o",
")",
"{",
"assert",
"(",
"o",
".",
"length",
"<=",
"v",
".",
"length",
")",
":",
"\"Bit set sizes do not agree.\"",
";",
"final",
"int",
"max",
"="... | OR o onto v in-place, i.e. v |= o
@param v Primary object
@param o data to or
@return v | [
"OR",
"o",
"onto",
"v",
"in",
"-",
"place",
"i",
".",
"e",
".",
"v",
"|",
"=",
"o"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L533-L540 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.andI | public static long[] andI(long[] v, long[] o) {
int i = 0;
for(; i < o.length; i++) {
v[i] &= o[i];
}
// Zero higher words
Arrays.fill(v, i, v.length, 0);
return v;
} | java | public static long[] andI(long[] v, long[] o) {
int i = 0;
for(; i < o.length; i++) {
v[i] &= o[i];
}
// Zero higher words
Arrays.fill(v, i, v.length, 0);
return v;
} | [
"public",
"static",
"long",
"[",
"]",
"andI",
"(",
"long",
"[",
"]",
"v",
",",
"long",
"[",
"]",
"o",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
";",
"i",
"<",
"o",
".",
"length",
";",
"i",
"++",
")",
"{",
"v",
"[",
"i",
"]",
"&="... | AND o onto v in-place, i.e. v &= o
@param v Primary object
@param o data to and
@return v | [
"AND",
"o",
"onto",
"v",
"in",
"-",
"place",
"i",
".",
"e",
".",
"v",
"&",
";",
"=",
"o"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L594-L602 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.nandI | public static long[] nandI(long[] v, long[] o) {
int i = 0;
for(; i < o.length; i++) {
v[i] &= ~o[i];
}
return v;
} | java | public static long[] nandI(long[] v, long[] o) {
int i = 0;
for(; i < o.length; i++) {
v[i] &= ~o[i];
}
return v;
} | [
"public",
"static",
"long",
"[",
"]",
"nandI",
"(",
"long",
"[",
"]",
"v",
",",
"long",
"[",
"]",
"o",
")",
"{",
"int",
"i",
"=",
"0",
";",
"for",
"(",
";",
"i",
"<",
"o",
".",
"length",
";",
"i",
"++",
")",
"{",
"v",
"[",
"i",
"]",
"&=... | NOTAND o onto v in-place, i.e. v &= ~o
@param v Primary object
@param o data to and
@return v | [
"NOTAND",
"o",
"onto",
"v",
"in",
"-",
"place",
"i",
".",
"e",
".",
"v",
"&",
";",
"=",
"~o"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L679-L685 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.invertI | public static long[] invertI(long[] v) {
for(int i = 0; i < v.length; i++) {
v[i] = ~v[i];
}
return v;
} | java | public static long[] invertI(long[] v) {
for(int i = 0; i < v.length; i++) {
v[i] = ~v[i];
}
return v;
} | [
"public",
"static",
"long",
"[",
"]",
"invertI",
"(",
"long",
"[",
"]",
"v",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"v",
".",
"length",
";",
"i",
"++",
")",
"{",
"v",
"[",
"i",
"]",
"=",
"~",
"v",
"[",
"i",
"]",
";",... | Invert v in-place.
@param v Object to invert
@return v | [
"Invert",
"v",
"in",
"-",
"place",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L693-L698 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.cycleLeftC | public static long cycleLeftC(long v, int shift, int len) {
return shift == 0 ? v : shift < 0 ? cycleRightC(v, -shift, len) : //
(((v) << (shift)) | ((v) >>> ((len) - (shift)))) & ((1 << len) - 1);
} | java | public static long cycleLeftC(long v, int shift, int len) {
return shift == 0 ? v : shift < 0 ? cycleRightC(v, -shift, len) : //
(((v) << (shift)) | ((v) >>> ((len) - (shift)))) & ((1 << len) - 1);
} | [
"public",
"static",
"long",
"cycleLeftC",
"(",
"long",
"v",
",",
"int",
"shift",
",",
"int",
"len",
")",
"{",
"return",
"shift",
"==",
"0",
"?",
"v",
":",
"shift",
"<",
"0",
"?",
"cycleRightC",
"(",
"v",
",",
"-",
"shift",
",",
"len",
")",
":",
... | Rotate a long to the left, cyclic with length len
@param v Bits
@param shift Shift value
@param len Length
@return cycled bit set | [
"Rotate",
"a",
"long",
"to",
"the",
"left",
"cyclic",
"with",
"length",
"len"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L839-L842 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.cycleLeftI | public static long[] cycleLeftI(long[] v, int shift, int len) {
long[] t = copy(v, len, shift);
return orI(shiftRightI(v, len - shift), truncateI(t, len));
} | java | public static long[] cycleLeftI(long[] v, int shift, int len) {
long[] t = copy(v, len, shift);
return orI(shiftRightI(v, len - shift), truncateI(t, len));
} | [
"public",
"static",
"long",
"[",
"]",
"cycleLeftI",
"(",
"long",
"[",
"]",
"v",
",",
"int",
"shift",
",",
"int",
"len",
")",
"{",
"long",
"[",
"]",
"t",
"=",
"copy",
"(",
"v",
",",
"len",
",",
"shift",
")",
";",
"return",
"orI",
"(",
"shiftRigh... | Cycle a bitstring to the right.
@param v Bit string
@param shift Number of steps to cycle
@param len Length | [
"Cycle",
"a",
"bitstring",
"to",
"the",
"right",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L851-L854 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.numberOfTrailingZerosSigned | public static int numberOfTrailingZerosSigned(long[] v) {
for(int p = 0;; p++) {
if(p == v.length) {
return -1;
}
if(v[p] != 0) {
return Long.numberOfTrailingZeros(v[p]) + p * Long.SIZE;
}
}
} | java | public static int numberOfTrailingZerosSigned(long[] v) {
for(int p = 0;; p++) {
if(p == v.length) {
return -1;
}
if(v[p] != 0) {
return Long.numberOfTrailingZeros(v[p]) + p * Long.SIZE;
}
}
} | [
"public",
"static",
"int",
"numberOfTrailingZerosSigned",
"(",
"long",
"[",
"]",
"v",
")",
"{",
"for",
"(",
"int",
"p",
"=",
"0",
";",
";",
"p",
"++",
")",
"{",
"if",
"(",
"p",
"==",
"v",
".",
"length",
")",
"{",
"return",
"-",
"1",
";",
"}",
... | Find the number of trailing zeros.
@param v Bitset
@return Position of first set bit, -1 if no set bit was found. | [
"Find",
"the",
"number",
"of",
"trailing",
"zeros",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1063-L1072 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.numberOfLeadingZerosSigned | public static int numberOfLeadingZerosSigned(long[] v) {
for(int p = 0, ip = v.length - 1; p < v.length; p++, ip--) {
if(v[ip] != 0) {
return Long.numberOfLeadingZeros(v[ip]) + p * Long.SIZE;
}
}
return -1;
} | java | public static int numberOfLeadingZerosSigned(long[] v) {
for(int p = 0, ip = v.length - 1; p < v.length; p++, ip--) {
if(v[ip] != 0) {
return Long.numberOfLeadingZeros(v[ip]) + p * Long.SIZE;
}
}
return -1;
} | [
"public",
"static",
"int",
"numberOfLeadingZerosSigned",
"(",
"long",
"[",
"]",
"v",
")",
"{",
"for",
"(",
"int",
"p",
"=",
"0",
",",
"ip",
"=",
"v",
".",
"length",
"-",
"1",
";",
"p",
"<",
"v",
".",
"length",
";",
"p",
"++",
",",
"ip",
"--",
... | Find the number of leading zeros.
@param v Bitset
@return Position of first set bit, -1 if no set bit was found. | [
"Find",
"the",
"number",
"of",
"leading",
"zeros",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1134-L1141 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.previousClearBit | public static int previousClearBit(long v, int start) {
if(start < 0) {
return -1;
}
start = start < Long.SIZE ? start : Long.SIZE - 1;
long cur = ~v & (LONG_ALL_BITS >>> -(start + 1));
return cur == 0 ? -1 : 63 - Long.numberOfLeadingZeros(cur);
} | java | public static int previousClearBit(long v, int start) {
if(start < 0) {
return -1;
}
start = start < Long.SIZE ? start : Long.SIZE - 1;
long cur = ~v & (LONG_ALL_BITS >>> -(start + 1));
return cur == 0 ? -1 : 63 - Long.numberOfLeadingZeros(cur);
} | [
"public",
"static",
"int",
"previousClearBit",
"(",
"long",
"v",
",",
"int",
"start",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"start",
"=",
"start",
"<",
"Long",
".",
"SIZE",
"?",
"start",
":",
"Long",
".",... | Find the previous clear bit.
@param v Values to process
@param start Start position (inclusive)
@return Position of previous clear bit, or -1. | [
"Find",
"the",
"previous",
"clear",
"bit",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1262-L1269 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.nextSetBit | public static int nextSetBit(long v, int start) {
if(start >= Long.SIZE) {
return -1;
}
start = start < 0 ? 0 : start;
long cur = v & (LONG_ALL_BITS << start);
return cur == 0 ? -1 : cur == LONG_ALL_BITS ? 0 : Long.numberOfTrailingZeros(cur);
} | java | public static int nextSetBit(long v, int start) {
if(start >= Long.SIZE) {
return -1;
}
start = start < 0 ? 0 : start;
long cur = v & (LONG_ALL_BITS << start);
return cur == 0 ? -1 : cur == LONG_ALL_BITS ? 0 : Long.numberOfTrailingZeros(cur);
} | [
"public",
"static",
"int",
"nextSetBit",
"(",
"long",
"v",
",",
"int",
"start",
")",
"{",
"if",
"(",
"start",
">=",
"Long",
".",
"SIZE",
")",
"{",
"return",
"-",
"1",
";",
"}",
"start",
"=",
"start",
"<",
"0",
"?",
"0",
":",
"start",
";",
"long... | Find the next set bit.
@param v Value to process
@param start Start position (inclusive)
@return Position of next set bit, or -1. | [
"Find",
"the",
"next",
"set",
"bit",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1307-L1314 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.intersect | public static boolean intersect(long[] x, long[] y) {
final int min = (x.length < y.length) ? x.length : y.length;
for(int i = 0; i < min; i++) {
if((x[i] & y[i]) != 0L) {
return true;
}
}
return false;
} | java | public static boolean intersect(long[] x, long[] y) {
final int min = (x.length < y.length) ? x.length : y.length;
for(int i = 0; i < min; i++) {
if((x[i] & y[i]) != 0L) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"intersect",
"(",
"long",
"[",
"]",
"x",
",",
"long",
"[",
"]",
"y",
")",
"{",
"final",
"int",
"min",
"=",
"(",
"x",
".",
"length",
"<",
"y",
".",
"length",
")",
"?",
"x",
".",
"length",
":",
"y",
".",
"length",
... | Test whether two Bitsets intersect.
@param x First bitset
@param y Second bitset
@return {@code true} when the bitsets intersect. | [
"Test",
"whether",
"two",
"Bitsets",
"intersect",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1434-L1442 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.intersectionSize | public static int intersectionSize(long[] x, long[] y) {
final int lx = x.length, ly = y.length;
final int min = (lx < ly) ? lx : ly;
int res = 0;
for(int i = 0; i < min; i++) {
res += Long.bitCount(x[i] & y[i]);
}
return res;
} | java | public static int intersectionSize(long[] x, long[] y) {
final int lx = x.length, ly = y.length;
final int min = (lx < ly) ? lx : ly;
int res = 0;
for(int i = 0; i < min; i++) {
res += Long.bitCount(x[i] & y[i]);
}
return res;
} | [
"public",
"static",
"int",
"intersectionSize",
"(",
"long",
"[",
"]",
"x",
",",
"long",
"[",
"]",
"y",
")",
"{",
"final",
"int",
"lx",
"=",
"x",
".",
"length",
",",
"ly",
"=",
"y",
".",
"length",
";",
"final",
"int",
"min",
"=",
"(",
"lx",
"<",... | Compute the intersection size of two Bitsets.
@param x First bitset
@param y Second bitset
@return Intersection size | [
"Compute",
"the",
"intersection",
"size",
"of",
"two",
"Bitsets",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1462-L1470 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.unionSize | public static int unionSize(long[] x, long[] y) {
final int lx = x.length, ly = y.length;
final int min = (lx < ly) ? lx : ly;
int i = 0, res = 0;
for(; i < min; i++) {
res += Long.bitCount(x[i] | y[i]);
}
for(; i < lx; i++) {
res += Long.bitCount(x[i]);
}
for(; i < ly; i++) {
res += Long.bitCount(y[i]);
}
return res;
} | java | public static int unionSize(long[] x, long[] y) {
final int lx = x.length, ly = y.length;
final int min = (lx < ly) ? lx : ly;
int i = 0, res = 0;
for(; i < min; i++) {
res += Long.bitCount(x[i] | y[i]);
}
for(; i < lx; i++) {
res += Long.bitCount(x[i]);
}
for(; i < ly; i++) {
res += Long.bitCount(y[i]);
}
return res;
} | [
"public",
"static",
"int",
"unionSize",
"(",
"long",
"[",
"]",
"x",
",",
"long",
"[",
"]",
"y",
")",
"{",
"final",
"int",
"lx",
"=",
"x",
".",
"length",
",",
"ly",
"=",
"y",
".",
"length",
";",
"final",
"int",
"min",
"=",
"(",
"lx",
"<",
"ly"... | Compute the union size of two Bitsets.
@param x First bitset
@param y Second bitset
@return Union size | [
"Compute",
"the",
"union",
"size",
"of",
"two",
"Bitsets",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1490-L1504 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.equal | public static boolean equal(long[] x, long[] y) {
if(x == null || y == null) {
return (x == null) && (y == null);
}
int p = Math.min(x.length, y.length) - 1;
for(int i = x.length - 1; i > p; i--) {
if(x[i] != 0L) {
return false;
}
}
for(int i = y.length - 1; i > p; i--) {
if(y[i] != 0L) {
return false;
}
}
for(; p >= 0; p--) {
if(x[p] != y[p]) {
return false;
}
}
return true;
} | java | public static boolean equal(long[] x, long[] y) {
if(x == null || y == null) {
return (x == null) && (y == null);
}
int p = Math.min(x.length, y.length) - 1;
for(int i = x.length - 1; i > p; i--) {
if(x[i] != 0L) {
return false;
}
}
for(int i = y.length - 1; i > p; i--) {
if(y[i] != 0L) {
return false;
}
}
for(; p >= 0; p--) {
if(x[p] != y[p]) {
return false;
}
}
return true;
} | [
"public",
"static",
"boolean",
"equal",
"(",
"long",
"[",
"]",
"x",
",",
"long",
"[",
"]",
"y",
")",
"{",
"if",
"(",
"x",
"==",
"null",
"||",
"y",
"==",
"null",
")",
"{",
"return",
"(",
"x",
"==",
"null",
")",
"&&",
"(",
"y",
"==",
"null",
... | Test two bitsets for equality
@param x First bitset
@param y Second bitset
@return {@code true} when the bitsets are equal | [
"Test",
"two",
"bitsets",
"for",
"equality"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1570-L1591 | train |
elki-project/elki | elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java | BitsUtil.compare | public static int compare(long[] x, long[] y) {
if(x == null) {
return (y == null) ? 0 : -1;
}
if(y == null) {
return +1;
}
int p = Math.min(x.length, y.length) - 1;
for(int i = x.length - 1; i > p; i--) {
if(x[i] != 0) {
return +1;
}
}
for(int i = y.length - 1; i > p; i--) {
if(y[i] != 0) {
return -1;
}
}
for(; p >= 0; p--) {
final long xp = x[p], yp = y[p];
if(xp != yp) {
return xp < 0 ? (yp < 0 && yp < xp) ? -1 : +1 : (yp < 0 || xp < yp) ? -1 : +1;
}
}
return 0;
} | java | public static int compare(long[] x, long[] y) {
if(x == null) {
return (y == null) ? 0 : -1;
}
if(y == null) {
return +1;
}
int p = Math.min(x.length, y.length) - 1;
for(int i = x.length - 1; i > p; i--) {
if(x[i] != 0) {
return +1;
}
}
for(int i = y.length - 1; i > p; i--) {
if(y[i] != 0) {
return -1;
}
}
for(; p >= 0; p--) {
final long xp = x[p], yp = y[p];
if(xp != yp) {
return xp < 0 ? (yp < 0 && yp < xp) ? -1 : +1 : (yp < 0 || xp < yp) ? -1 : +1;
}
}
return 0;
} | [
"public",
"static",
"int",
"compare",
"(",
"long",
"[",
"]",
"x",
",",
"long",
"[",
"]",
"y",
")",
"{",
"if",
"(",
"x",
"==",
"null",
")",
"{",
"return",
"(",
"y",
"==",
"null",
")",
"?",
"0",
":",
"-",
"1",
";",
"}",
"if",
"(",
"y",
"=="... | Compare two bitsets.
@param x First bitset
@param y Second bitset
@return Comparison result | [
"Compare",
"two",
"bitsets",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/BitsUtil.java#L1611-L1636 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/split/distribution/DistanceEntry.java | DistanceEntry.compareTo | @Override
public int compareTo(DistanceEntry<E> o) {
int comp = Double.compare(distance, o.distance);
return comp;
// return comp != 0 ? comp :
// entry.getEntryID().compareTo(o.entry.getEntryID());
} | java | @Override
public int compareTo(DistanceEntry<E> o) {
int comp = Double.compare(distance, o.distance);
return comp;
// return comp != 0 ? comp :
// entry.getEntryID().compareTo(o.entry.getEntryID());
} | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"DistanceEntry",
"<",
"E",
">",
"o",
")",
"{",
"int",
"comp",
"=",
"Double",
".",
"compare",
"(",
"distance",
",",
"o",
".",
"distance",
")",
";",
"return",
"comp",
";",
"// return comp != 0 ? comp :",
... | Compares this object with the specified object for order.
@param o the Object to be compared.
@return a negative integer, zero, or a positive integer as this object is
less than, equal to, or greater than the specified object.
@throws ClassCastException if the specified object's type prevents it from
being compared to this Object. | [
"Compares",
"this",
"object",
"with",
"the",
"specified",
"object",
"for",
"order",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/split/distribution/DistanceEntry.java#L85-L91 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mktab/MkTabTreeIndex.java | MkTabTreeIndex.knnDistances | private double[] knnDistances(O object) {
KNNList knns = knnq.getKNNForObject(object, getKmax() - 1);
double[] distances = new double[getKmax()];
int i = 0;
for(DoubleDBIDListIter iter = knns.iter(); iter.valid() && i < getKmax(); iter.advance(), i++) {
distances[i] = iter.doubleValue();
}
return distances;
} | java | private double[] knnDistances(O object) {
KNNList knns = knnq.getKNNForObject(object, getKmax() - 1);
double[] distances = new double[getKmax()];
int i = 0;
for(DoubleDBIDListIter iter = knns.iter(); iter.valid() && i < getKmax(); iter.advance(), i++) {
distances[i] = iter.doubleValue();
}
return distances;
} | [
"private",
"double",
"[",
"]",
"knnDistances",
"(",
"O",
"object",
")",
"{",
"KNNList",
"knns",
"=",
"knnq",
".",
"getKNNForObject",
"(",
"object",
",",
"getKmax",
"(",
")",
"-",
"1",
")",
";",
"double",
"[",
"]",
"distances",
"=",
"new",
"double",
"... | Returns the knn distance of the object with the specified id.
@param object the query object
@return the knn distance of the object with the specified id | [
"Returns",
"the",
"knn",
"distance",
"of",
"the",
"object",
"with",
"the",
"specified",
"id",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mktab/MkTabTreeIndex.java#L86-L94 | train |
elki-project/elki | elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/DoubleDynamicHistogram.java | DoubleDynamicHistogram.downsample | protected double downsample(double[] data, int start, int end, int size) {
double sum = 0;
for (int i = start; i < end; i++) {
sum += data[i];
}
return sum;
} | java | protected double downsample(double[] data, int start, int end, int size) {
double sum = 0;
for (int i = start; i < end; i++) {
sum += data[i];
}
return sum;
} | [
"protected",
"double",
"downsample",
"(",
"double",
"[",
"]",
"data",
",",
"int",
"start",
",",
"int",
"end",
",",
"int",
"size",
")",
"{",
"double",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"+... | Perform downsampling on a number of bins.
@param data Data array (needs cast!)
@param start Interval start
@param end Interval end (exclusive)
@param size Intended size - extra bins are assumed to be empty, should be a
power of two
@return New bin value | [
"Perform",
"downsampling",
"on",
"a",
"number",
"of",
"bins",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/histogram/DoubleDynamicHistogram.java#L242-L248 | train |
elki-project/elki | addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java | Simple1DOFCamera.setRotationZ | public void setRotationZ(double rotationZ) {
this.rotationZ = rotationZ;
this.cosZ = FastMath.cos(rotationZ);
this.sinZ = FastMath.sin(rotationZ);
fireCameraChangedEvent();
} | java | public void setRotationZ(double rotationZ) {
this.rotationZ = rotationZ;
this.cosZ = FastMath.cos(rotationZ);
this.sinZ = FastMath.sin(rotationZ);
fireCameraChangedEvent();
} | [
"public",
"void",
"setRotationZ",
"(",
"double",
"rotationZ",
")",
"{",
"this",
".",
"rotationZ",
"=",
"rotationZ",
";",
"this",
".",
"cosZ",
"=",
"FastMath",
".",
"cos",
"(",
"rotationZ",
")",
";",
"this",
".",
"sinZ",
"=",
"FastMath",
".",
"sin",
"("... | Set the z rotation angle in radians.
@param rotationZ Z rotation angle. | [
"Set",
"the",
"z",
"rotation",
"angle",
"in",
"radians",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java#L213-L219 | train |
elki-project/elki | addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java | Simple1DOFCamera.apply | public void apply(GL2 gl) {
// 3D projection
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
// Perspective.
glu.gluPerspective(35, ratio, 1, 1000);
glu.gluLookAt(distance * sinZ, distance * -cosZ, height, // pos
0, 0, .5, // center
0, 0, 1 // up
);
// Change back to model view matrix.
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
// Store the matrixes for reference.
gl.glGetIntegerv(GL.GL_VIEWPORT, viewp, 0);
gl.glGetDoublev(GLMatrixFunc.GL_MODELVIEW_MATRIX, modelview, 0);
gl.glGetDoublev(GLMatrixFunc.GL_PROJECTION_MATRIX, projection, 0);
} | java | public void apply(GL2 gl) {
// 3D projection
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
// Perspective.
glu.gluPerspective(35, ratio, 1, 1000);
glu.gluLookAt(distance * sinZ, distance * -cosZ, height, // pos
0, 0, .5, // center
0, 0, 1 // up
);
// Change back to model view matrix.
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
// Store the matrixes for reference.
gl.glGetIntegerv(GL.GL_VIEWPORT, viewp, 0);
gl.glGetDoublev(GLMatrixFunc.GL_MODELVIEW_MATRIX, modelview, 0);
gl.glGetDoublev(GLMatrixFunc.GL_PROJECTION_MATRIX, projection, 0);
} | [
"public",
"void",
"apply",
"(",
"GL2",
"gl",
")",
"{",
"// 3D projection",
"gl",
".",
"glMatrixMode",
"(",
"GL2",
".",
"GL_PROJECTION",
")",
";",
"gl",
".",
"glLoadIdentity",
"(",
")",
";",
"// Perspective.",
"glu",
".",
"gluPerspective",
"(",
"35",
",",
... | Apply the camera to a GL context.
@param gl GL context. | [
"Apply",
"the",
"camera",
"to",
"a",
"GL",
"context",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java#L226-L244 | train |
elki-project/elki | addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java | Simple1DOFCamera.project | public void project(double x, double y, double z, double[] out) {
glu.gluProject(x, y, z, modelview, 0, projection, 0, viewp, 0, out, 0);
} | java | public void project(double x, double y, double z, double[] out) {
glu.gluProject(x, y, z, modelview, 0, projection, 0, viewp, 0, out, 0);
} | [
"public",
"void",
"project",
"(",
"double",
"x",
",",
"double",
"y",
",",
"double",
"z",
",",
"double",
"[",
"]",
"out",
")",
"{",
"glu",
".",
"gluProject",
"(",
"x",
",",
"y",
",",
"z",
",",
"modelview",
",",
"0",
",",
"projection",
",",
"0",
... | Project a coordinate
@param x X
@param y Y
@param z Z
@param out output buffer | [
"Project",
"a",
"coordinate"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java#L280-L282 | train |
elki-project/elki | addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java | Simple1DOFCamera.addCameraListener | public void addCameraListener(CameraListener lis) {
if (listeners == null) {
listeners = new ArrayList<>(5);
}
listeners.add(lis);
} | java | public void addCameraListener(CameraListener lis) {
if (listeners == null) {
listeners = new ArrayList<>(5);
}
listeners.add(lis);
} | [
"public",
"void",
"addCameraListener",
"(",
"CameraListener",
"lis",
")",
"{",
"if",
"(",
"listeners",
"==",
"null",
")",
"{",
"listeners",
"=",
"new",
"ArrayList",
"<>",
"(",
"5",
")",
";",
"}",
"listeners",
".",
"add",
"(",
"lis",
")",
";",
"}"
] | Add a camera listener.
@param lis Listener | [
"Add",
"a",
"camera",
"listener",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/util/Simple1DOFCamera.java#L317-L322 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/projections/AffineProjection.java | AffineProjection.axisProjection | public static AffineTransformation axisProjection(int dim, int ax1, int ax2) {
// setup a projection to get the data into the interval -1:+1 in each
// dimension with the intended-to-see dimensions first.
AffineTransformation proj = AffineTransformation.reorderAxesTransformation(dim, ax1, ax2);
// Assuming that the data was normalized on [0:1], center it:
double[] trans = new double[dim];
for(int i = 0; i < dim; i++) {
trans[i] = -.5;
}
proj.addTranslation(trans);
// mirror on the y axis, since the SVG coordinate system is screen
// coordinates (y = down) and not mathematical coordinates (y = up)
proj.addAxisReflection(2);
// scale it up
proj.addScaling(SCALE);
return proj;
} | java | public static AffineTransformation axisProjection(int dim, int ax1, int ax2) {
// setup a projection to get the data into the interval -1:+1 in each
// dimension with the intended-to-see dimensions first.
AffineTransformation proj = AffineTransformation.reorderAxesTransformation(dim, ax1, ax2);
// Assuming that the data was normalized on [0:1], center it:
double[] trans = new double[dim];
for(int i = 0; i < dim; i++) {
trans[i] = -.5;
}
proj.addTranslation(trans);
// mirror on the y axis, since the SVG coordinate system is screen
// coordinates (y = down) and not mathematical coordinates (y = up)
proj.addAxisReflection(2);
// scale it up
proj.addScaling(SCALE);
return proj;
} | [
"public",
"static",
"AffineTransformation",
"axisProjection",
"(",
"int",
"dim",
",",
"int",
"ax1",
",",
"int",
"ax2",
")",
"{",
"// setup a projection to get the data into the interval -1:+1 in each",
"// dimension with the intended-to-see dimensions first.",
"AffineTransformation... | Compute an transformation matrix to show only axis ax1 and ax2.
@param dim Dimensionality
@param ax1 First axis
@param ax2 Second axis
@return transformation matrix | [
"Compute",
"an",
"transformation",
"matrix",
"to",
"show",
"only",
"axis",
"ax1",
"and",
"ax2",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/projections/AffineProjection.java#L147-L164 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTreeNode.java | MkCoPTreeNode.conservativeKnnDistanceApproximation | protected ApproximationLine conservativeKnnDistanceApproximation(int k_max) {
// determine k_0, y_1, y_kmax
int k_0 = k_max;
double y_1 = Double.NEGATIVE_INFINITY;
double y_kmax = Double.NEGATIVE_INFINITY;
for(int i = 0; i < getNumEntries(); i++) {
MkCoPEntry entry = getEntry(i);
ApproximationLine approx = entry.getConservativeKnnDistanceApproximation();
k_0 = Math.min(approx.getK_0(), k_0);
}
for(int i = 0; i < getNumEntries(); i++) {
MkCoPEntry entry = getEntry(i);
ApproximationLine approx = entry.getConservativeKnnDistanceApproximation();
double entry_y_1 = approx.getValueAt(k_0);
double entry_y_kmax = approx.getValueAt(k_max);
if(!Double.isInfinite(entry_y_1)) {
y_1 = Math.max(entry_y_1, y_1);
}
if(!Double.isInfinite(entry_y_kmax)) {
y_kmax = Math.max(entry_y_kmax, y_kmax);
}
}
// determine m and t
double m = (y_kmax - y_1) / (FastMath.log(k_max) - FastMath.log(k_0));
double t = y_1 - m * FastMath.log(k_0);
return new ApproximationLine(k_0, m, t);
} | java | protected ApproximationLine conservativeKnnDistanceApproximation(int k_max) {
// determine k_0, y_1, y_kmax
int k_0 = k_max;
double y_1 = Double.NEGATIVE_INFINITY;
double y_kmax = Double.NEGATIVE_INFINITY;
for(int i = 0; i < getNumEntries(); i++) {
MkCoPEntry entry = getEntry(i);
ApproximationLine approx = entry.getConservativeKnnDistanceApproximation();
k_0 = Math.min(approx.getK_0(), k_0);
}
for(int i = 0; i < getNumEntries(); i++) {
MkCoPEntry entry = getEntry(i);
ApproximationLine approx = entry.getConservativeKnnDistanceApproximation();
double entry_y_1 = approx.getValueAt(k_0);
double entry_y_kmax = approx.getValueAt(k_max);
if(!Double.isInfinite(entry_y_1)) {
y_1 = Math.max(entry_y_1, y_1);
}
if(!Double.isInfinite(entry_y_kmax)) {
y_kmax = Math.max(entry_y_kmax, y_kmax);
}
}
// determine m and t
double m = (y_kmax - y_1) / (FastMath.log(k_max) - FastMath.log(k_0));
double t = y_1 - m * FastMath.log(k_0);
return new ApproximationLine(k_0, m, t);
} | [
"protected",
"ApproximationLine",
"conservativeKnnDistanceApproximation",
"(",
"int",
"k_max",
")",
"{",
"// determine k_0, y_1, y_kmax",
"int",
"k_0",
"=",
"k_max",
";",
"double",
"y_1",
"=",
"Double",
".",
"NEGATIVE_INFINITY",
";",
"double",
"y_kmax",
"=",
"Double",... | Determines and returns the conservative approximation for the knn distances
of this node as the maximum of the conservative approximations of all
entries.
@param k_max the maximum k parameter
@return the conservative approximation for the knn distances | [
"Determines",
"and",
"returns",
"the",
"conservative",
"approximation",
"for",
"the",
"knn",
"distances",
"of",
"this",
"node",
"as",
"the",
"maximum",
"of",
"the",
"conservative",
"approximations",
"of",
"all",
"entries",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTreeNode.java#L70-L101 | train |
elki-project/elki | elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTreeNode.java | MkCoPTreeNode.progressiveKnnDistanceApproximation | protected ApproximationLine progressiveKnnDistanceApproximation(int k_max) {
if(!isLeaf()) {
throw new UnsupportedOperationException("Progressive KNN-distance approximation " + "is only vailable in leaf nodes!");
}
// determine k_0, y_1, y_kmax
int k_0 = 0;
double y_1 = Double.POSITIVE_INFINITY;
double y_kmax = Double.POSITIVE_INFINITY;
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
k_0 = Math.max(approx.getK_0(), k_0);
}
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
y_1 = Math.min(approx.getValueAt(k_0), y_1);
y_kmax = Math.min(approx.getValueAt(k_max), y_kmax);
}
// determine m and t
double m = (y_kmax - y_1) / (FastMath.log(k_max) - FastMath.log(k_0));
double t = y_1 - m * FastMath.log(k_0);
return new ApproximationLine(k_0, m, t);
} | java | protected ApproximationLine progressiveKnnDistanceApproximation(int k_max) {
if(!isLeaf()) {
throw new UnsupportedOperationException("Progressive KNN-distance approximation " + "is only vailable in leaf nodes!");
}
// determine k_0, y_1, y_kmax
int k_0 = 0;
double y_1 = Double.POSITIVE_INFINITY;
double y_kmax = Double.POSITIVE_INFINITY;
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
k_0 = Math.max(approx.getK_0(), k_0);
}
for(int i = 0; i < getNumEntries(); i++) {
MkCoPLeafEntry entry = (MkCoPLeafEntry) getEntry(i);
ApproximationLine approx = entry.getProgressiveKnnDistanceApproximation();
y_1 = Math.min(approx.getValueAt(k_0), y_1);
y_kmax = Math.min(approx.getValueAt(k_max), y_kmax);
}
// determine m and t
double m = (y_kmax - y_1) / (FastMath.log(k_max) - FastMath.log(k_0));
double t = y_1 - m * FastMath.log(k_0);
return new ApproximationLine(k_0, m, t);
} | [
"protected",
"ApproximationLine",
"progressiveKnnDistanceApproximation",
"(",
"int",
"k_max",
")",
"{",
"if",
"(",
"!",
"isLeaf",
"(",
")",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Progressive KNN-distance approximation \"",
"+",
"\"is only vaila... | Determines and returns the progressive approximation for the knn distances
of this node as the maximum of the progressive approximations of all
entries.
@param k_max the maximum k parameter
@return the conservative approximation for the knn distances | [
"Determines",
"and",
"returns",
"the",
"progressive",
"approximation",
"for",
"the",
"knn",
"distances",
"of",
"this",
"node",
"as",
"the",
"maximum",
"of",
"the",
"progressive",
"approximations",
"of",
"all",
"entries",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkcop/MkCoPTreeNode.java#L111-L139 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java | CSSClassManager.addClass | public CSSClass addClass(CSSClass clss) throws CSSNamingConflict {
CSSClass existing = store.get(clss.getName());
if (existing != null && existing.getOwner() != null && existing.getOwner() != clss.getOwner()) {
throw new CSSNamingConflict("CSS class naming conflict between "+clss.getOwner().toString()+" and "+existing.getOwner().toString());
}
return store.put(clss.getName(), clss);
} | java | public CSSClass addClass(CSSClass clss) throws CSSNamingConflict {
CSSClass existing = store.get(clss.getName());
if (existing != null && existing.getOwner() != null && existing.getOwner() != clss.getOwner()) {
throw new CSSNamingConflict("CSS class naming conflict between "+clss.getOwner().toString()+" and "+existing.getOwner().toString());
}
return store.put(clss.getName(), clss);
} | [
"public",
"CSSClass",
"addClass",
"(",
"CSSClass",
"clss",
")",
"throws",
"CSSNamingConflict",
"{",
"CSSClass",
"existing",
"=",
"store",
".",
"get",
"(",
"clss",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"existing",
"!=",
"null",
"&&",
"existing",
... | Add a single class to the map.
@param clss new CSS class
@return existing (old) class
@throws CSSNamingConflict when a class of the same name but different owner object exists. | [
"Add",
"a",
"single",
"class",
"to",
"the",
"map",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java#L54-L60 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java | CSSClassManager.removeClass | public synchronized void removeClass(CSSClass clss) {
CSSClass existing = store.get(clss.getName());
if (existing == clss) {
store.remove(existing.getName());
}
} | java | public synchronized void removeClass(CSSClass clss) {
CSSClass existing = store.get(clss.getName());
if (existing == clss) {
store.remove(existing.getName());
}
} | [
"public",
"synchronized",
"void",
"removeClass",
"(",
"CSSClass",
"clss",
")",
"{",
"CSSClass",
"existing",
"=",
"store",
".",
"get",
"(",
"clss",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"existing",
"==",
"clss",
")",
"{",
"store",
".",
"remove"... | Remove a single CSS class from the map.
Note that classes are removed by reference, not by name!
@param clss Class to remove | [
"Remove",
"a",
"single",
"CSS",
"class",
"from",
"the",
"map",
".",
"Note",
"that",
"classes",
"are",
"removed",
"by",
"reference",
"not",
"by",
"name!"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java#L68-L73 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java | CSSClassManager.getClass | public CSSClass getClass(String name, Object owner) throws CSSNamingConflict {
CSSClass existing = store.get(name);
// Not found.
if (existing == null) {
return null;
}
// Different owner
if (owner != null && existing.getOwner() != owner) {
throw new CSSNamingConflict("CSS class naming conflict between "+owner.toString()+" and "+existing.getOwner().toString());
}
return existing;
} | java | public CSSClass getClass(String name, Object owner) throws CSSNamingConflict {
CSSClass existing = store.get(name);
// Not found.
if (existing == null) {
return null;
}
// Different owner
if (owner != null && existing.getOwner() != owner) {
throw new CSSNamingConflict("CSS class naming conflict between "+owner.toString()+" and "+existing.getOwner().toString());
}
return existing;
} | [
"public",
"CSSClass",
"getClass",
"(",
"String",
"name",
",",
"Object",
"owner",
")",
"throws",
"CSSNamingConflict",
"{",
"CSSClass",
"existing",
"=",
"store",
".",
"get",
"(",
"name",
")",
";",
"// Not found.",
"if",
"(",
"existing",
"==",
"null",
")",
"{... | Retrieve a single class by name and owner
@param name Class name
@param owner Class owner
@return existing (old) class
@throws CSSNamingConflict if an owner was specified and doesn't match | [
"Retrieve",
"a",
"single",
"class",
"by",
"name",
"and",
"owner"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java#L83-L94 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java | CSSClassManager.serialize | public void serialize(StringBuilder buf) {
for (CSSClass clss : store.values()) {
clss.appendCSSDefinition(buf);
}
} | java | public void serialize(StringBuilder buf) {
for (CSSClass clss : store.values()) {
clss.appendCSSDefinition(buf);
}
} | [
"public",
"void",
"serialize",
"(",
"StringBuilder",
"buf",
")",
"{",
"for",
"(",
"CSSClass",
"clss",
":",
"store",
".",
"values",
"(",
")",
")",
"{",
"clss",
".",
"appendCSSDefinition",
"(",
"buf",
")",
";",
"}",
"}"
] | Serialize managed CSS classes to rule file.
@param buf String buffer | [
"Serialize",
"managed",
"CSS",
"classes",
"to",
"rule",
"file",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java#L121-L125 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java | CSSClassManager.mergeCSSFrom | public boolean mergeCSSFrom(CSSClassManager other) throws CSSNamingConflict {
for (CSSClass clss : other.getClasses()) {
this.addClass(clss);
}
return true;
} | java | public boolean mergeCSSFrom(CSSClassManager other) throws CSSNamingConflict {
for (CSSClass clss : other.getClasses()) {
this.addClass(clss);
}
return true;
} | [
"public",
"boolean",
"mergeCSSFrom",
"(",
"CSSClassManager",
"other",
")",
"throws",
"CSSNamingConflict",
"{",
"for",
"(",
"CSSClass",
"clss",
":",
"other",
".",
"getClasses",
"(",
")",
")",
"{",
"this",
".",
"addClass",
"(",
"clss",
")",
";",
"}",
"return... | Merge CSS classes, for example to merge two plots.
@param other Other class to merge with
@return success code
@throws CSSNamingConflict If there is a naming conflict. | [
"Merge",
"CSS",
"classes",
"for",
"example",
"to",
"merge",
"two",
"plots",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java#L160-L165 | train |
elki-project/elki | addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java | CSSClassManager.updateStyleElement | public void updateStyleElement(Document document, Element style) {
StringBuilder buf = new StringBuilder();
serialize(buf);
Text cont = document.createTextNode(buf.toString());
while (style.hasChildNodes()) {
style.removeChild(style.getFirstChild());
}
style.appendChild(cont);
} | java | public void updateStyleElement(Document document, Element style) {
StringBuilder buf = new StringBuilder();
serialize(buf);
Text cont = document.createTextNode(buf.toString());
while (style.hasChildNodes()) {
style.removeChild(style.getFirstChild());
}
style.appendChild(cont);
} | [
"public",
"void",
"updateStyleElement",
"(",
"Document",
"document",
",",
"Element",
"style",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"serialize",
"(",
"buf",
")",
";",
"Text",
"cont",
"=",
"document",
".",
"createTextNo... | Update the text contents of an existing style element.
@param document Document element (factory)
@param style Style element | [
"Update",
"the",
"text",
"contents",
"of",
"an",
"existing",
"style",
"element",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/css/CSSClassManager.java#L192-L200 | train |
elki-project/elki | elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/ALOCI.java | ALOCI.calculate_MDEF_norm | private static double calculate_MDEF_norm(Node sn, Node cg) {
// get the square sum of the counting neighborhoods box counts
long sq = sn.getSquareSum(cg.getLevel() - sn.getLevel());
/*
* if the square sum is equal to box count of the sampling Neighborhood then
* n_hat is equal one, and as cg needs to have at least one Element mdef
* would get zero or lower than zero. This is the case when all of the
* counting Neighborhoods contain one or zero Objects. Additionally, the
* cubic sum, square sum and sampling Neighborhood box count are all equal,
* which leads to sig_n_hat being zero and thus mdef_norm is either negative
* infinite or undefined. As the distribution of the Objects seem quite
* uniform, a mdef_norm value of zero ( = no outlier) is appropriate and
* circumvents the problem of undefined values.
*/
if(sq == sn.getCount()) {
return 0.0;
}
// calculation of mdef according to the paper and standardization as done in
// LOCI
long cb = sn.getCubicSum(cg.getLevel() - sn.getLevel());
double n_hat = (double) sq / sn.getCount();
double sig_n_hat = FastMath.sqrt(cb * sn.getCount() - (sq * sq)) / sn.getCount();
// Avoid NaN - correct result 0.0?
if(sig_n_hat < Double.MIN_NORMAL) {
return 0.0;
}
double mdef = n_hat - cg.getCount();
return mdef / sig_n_hat;
} | java | private static double calculate_MDEF_norm(Node sn, Node cg) {
// get the square sum of the counting neighborhoods box counts
long sq = sn.getSquareSum(cg.getLevel() - sn.getLevel());
/*
* if the square sum is equal to box count of the sampling Neighborhood then
* n_hat is equal one, and as cg needs to have at least one Element mdef
* would get zero or lower than zero. This is the case when all of the
* counting Neighborhoods contain one or zero Objects. Additionally, the
* cubic sum, square sum and sampling Neighborhood box count are all equal,
* which leads to sig_n_hat being zero and thus mdef_norm is either negative
* infinite or undefined. As the distribution of the Objects seem quite
* uniform, a mdef_norm value of zero ( = no outlier) is appropriate and
* circumvents the problem of undefined values.
*/
if(sq == sn.getCount()) {
return 0.0;
}
// calculation of mdef according to the paper and standardization as done in
// LOCI
long cb = sn.getCubicSum(cg.getLevel() - sn.getLevel());
double n_hat = (double) sq / sn.getCount();
double sig_n_hat = FastMath.sqrt(cb * sn.getCount() - (sq * sq)) / sn.getCount();
// Avoid NaN - correct result 0.0?
if(sig_n_hat < Double.MIN_NORMAL) {
return 0.0;
}
double mdef = n_hat - cg.getCount();
return mdef / sig_n_hat;
} | [
"private",
"static",
"double",
"calculate_MDEF_norm",
"(",
"Node",
"sn",
",",
"Node",
"cg",
")",
"{",
"// get the square sum of the counting neighborhoods box counts",
"long",
"sq",
"=",
"sn",
".",
"getSquareSum",
"(",
"cg",
".",
"getLevel",
"(",
")",
"-",
"sn",
... | Method for the MDEF calculation
@param sn Sampling Neighborhood
@param cg Counting Neighborhood
@return MDEF norm | [
"Method",
"for",
"the",
"MDEF",
"calculation"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/ALOCI.java#L259-L287 | train |
elki-project/elki | elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java | BundleWriter.writeBundleStream | public void writeBundleStream(BundleStreamSource source, WritableByteChannel output) throws IOException {
ByteBuffer buffer = ByteBuffer.allocateDirect(INITIAL_BUFFER);
DBIDVar var = DBIDUtil.newVar();
ByteBufferSerializer<?>[] serializers = null;
loop: while(true) {
BundleStreamSource.Event ev = source.nextEvent();
switch(ev){
case NEXT_OBJECT:
if(serializers == null) {
serializers = writeHeader(source, buffer, output);
}
if(serializers[0] != null) {
if(!source.assignDBID(var)) {
throw new AbortException("An object did not have an DBID assigned.");
}
DBID id = DBIDUtil.deref(var);
@SuppressWarnings("unchecked")
ByteBufferSerializer<DBID> ser = (ByteBufferSerializer<DBID>) serializers[0];
int size = ser.getByteSize(id);
buffer = ensureBuffer(size, buffer, output);
ser.toByteBuffer(buffer, id);
}
for(int i = 1, j = 0; i < serializers.length; ++i, ++j) {
@SuppressWarnings("unchecked")
ByteBufferSerializer<Object> ser = (ByteBufferSerializer<Object>) serializers[i];
int size = ser.getByteSize(source.data(j));
buffer = ensureBuffer(size, buffer, output);
ser.toByteBuffer(buffer, source.data(j));
}
break; // switch
case META_CHANGED:
if(serializers != null) {
throw new AbortException("Meta changes are not supported, once the block header has been written.");
}
break; // switch
case END_OF_STREAM:
break loop;
default:
LOG.warning("Unknown bundle stream event. API inconsistent? " + ev);
break; // switch
}
}
if(buffer.position() > 0) {
flushBuffer(buffer, output);
}
} | java | public void writeBundleStream(BundleStreamSource source, WritableByteChannel output) throws IOException {
ByteBuffer buffer = ByteBuffer.allocateDirect(INITIAL_BUFFER);
DBIDVar var = DBIDUtil.newVar();
ByteBufferSerializer<?>[] serializers = null;
loop: while(true) {
BundleStreamSource.Event ev = source.nextEvent();
switch(ev){
case NEXT_OBJECT:
if(serializers == null) {
serializers = writeHeader(source, buffer, output);
}
if(serializers[0] != null) {
if(!source.assignDBID(var)) {
throw new AbortException("An object did not have an DBID assigned.");
}
DBID id = DBIDUtil.deref(var);
@SuppressWarnings("unchecked")
ByteBufferSerializer<DBID> ser = (ByteBufferSerializer<DBID>) serializers[0];
int size = ser.getByteSize(id);
buffer = ensureBuffer(size, buffer, output);
ser.toByteBuffer(buffer, id);
}
for(int i = 1, j = 0; i < serializers.length; ++i, ++j) {
@SuppressWarnings("unchecked")
ByteBufferSerializer<Object> ser = (ByteBufferSerializer<Object>) serializers[i];
int size = ser.getByteSize(source.data(j));
buffer = ensureBuffer(size, buffer, output);
ser.toByteBuffer(buffer, source.data(j));
}
break; // switch
case META_CHANGED:
if(serializers != null) {
throw new AbortException("Meta changes are not supported, once the block header has been written.");
}
break; // switch
case END_OF_STREAM:
break loop;
default:
LOG.warning("Unknown bundle stream event. API inconsistent? " + ev);
break; // switch
}
}
if(buffer.position() > 0) {
flushBuffer(buffer, output);
}
} | [
"public",
"void",
"writeBundleStream",
"(",
"BundleStreamSource",
"source",
",",
"WritableByteChannel",
"output",
")",
"throws",
"IOException",
"{",
"ByteBuffer",
"buffer",
"=",
"ByteBuffer",
".",
"allocateDirect",
"(",
"INITIAL_BUFFER",
")",
";",
"DBIDVar",
"var",
... | Write a bundle stream to a file output channel.
@param source Data source
@param output Output channel
@throws IOException on IO errors | [
"Write",
"a",
"bundle",
"stream",
"to",
"a",
"file",
"output",
"channel",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java#L71-L117 | train |
elki-project/elki | elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java | BundleWriter.flushBuffer | private void flushBuffer(ByteBuffer buffer, WritableByteChannel output) throws IOException {
buffer.flip();
output.write(buffer);
buffer.flip();
buffer.limit(buffer.capacity());
} | java | private void flushBuffer(ByteBuffer buffer, WritableByteChannel output) throws IOException {
buffer.flip();
output.write(buffer);
buffer.flip();
buffer.limit(buffer.capacity());
} | [
"private",
"void",
"flushBuffer",
"(",
"ByteBuffer",
"buffer",
",",
"WritableByteChannel",
"output",
")",
"throws",
"IOException",
"{",
"buffer",
".",
"flip",
"(",
")",
";",
"output",
".",
"write",
"(",
"buffer",
")",
";",
"buffer",
".",
"flip",
"(",
")",
... | Flush the current write buffer to disk.
@param buffer Buffer to write
@param output Output channel
@throws IOException on IO errors | [
"Flush",
"the",
"current",
"write",
"buffer",
"to",
"disk",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java#L126-L131 | train |
elki-project/elki | elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java | BundleWriter.ensureBuffer | private ByteBuffer ensureBuffer(int size, ByteBuffer buffer, WritableByteChannel output) throws IOException {
if(buffer.remaining() >= size) {
return buffer;
}
flushBuffer(buffer, output);
if(buffer.remaining() >= size) {
return buffer;
}
// Aggressively grow the buffer
return ByteBuffer.allocateDirect(Math.max(buffer.capacity() << 1, buffer.capacity() + size));
} | java | private ByteBuffer ensureBuffer(int size, ByteBuffer buffer, WritableByteChannel output) throws IOException {
if(buffer.remaining() >= size) {
return buffer;
}
flushBuffer(buffer, output);
if(buffer.remaining() >= size) {
return buffer;
}
// Aggressively grow the buffer
return ByteBuffer.allocateDirect(Math.max(buffer.capacity() << 1, buffer.capacity() + size));
} | [
"private",
"ByteBuffer",
"ensureBuffer",
"(",
"int",
"size",
",",
"ByteBuffer",
"buffer",
",",
"WritableByteChannel",
"output",
")",
"throws",
"IOException",
"{",
"if",
"(",
"buffer",
".",
"remaining",
"(",
")",
">=",
"size",
")",
"{",
"return",
"buffer",
";... | Ensure the buffer is large enough.
@param size Required size to add
@param buffer Existing buffer
@param output Output channel
@return Buffer, eventually resized
@throws IOException on IO errors | [
"Ensure",
"the",
"buffer",
"is",
"large",
"enough",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java#L142-L152 | train |
elki-project/elki | elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java | BundleWriter.writeHeader | private ByteBufferSerializer<?>[] writeHeader(BundleStreamSource source, ByteBuffer buffer, WritableByteChannel output) throws IOException {
final BundleMeta meta = source.getMeta();
final int nummeta = meta.size();
@SuppressWarnings("rawtypes")
final ByteBufferSerializer[] serializers = new ByteBufferSerializer[1 + nummeta];
// Write our magic ID first.
assert (buffer.position() == 0) : "Buffer is supposed to be at 0.";
buffer.putInt(MAGIC);
// Write the number of metas next.
// For compatibility with earlier versions, treat DBIDs as extra type
if(source.hasDBIDs()) {
buffer.putInt(1 + nummeta);
ByteBufferSerializer<DBID> ser = DBIDFactory.FACTORY.getDBIDSerializer();
TypeInformationSerializer.STATIC.toByteBuffer(buffer, new SimpleTypeInformation<>(DBID.class, ser));
serializers[0] = ser;
}
else {
buffer.putInt(nummeta);
}
for(int i = 0; i < nummeta; i++) {
SimpleTypeInformation<?> type = meta.get(i);
ByteBufferSerializer<?> ser = type.getSerializer();
if(ser == null) {
throw new AbortException("Cannot serialize - no serializer found for type: " + type.toString());
}
TypeInformationSerializer.STATIC.toByteBuffer(buffer, type);
serializers[i + 1] = ser;
}
return serializers;
} | java | private ByteBufferSerializer<?>[] writeHeader(BundleStreamSource source, ByteBuffer buffer, WritableByteChannel output) throws IOException {
final BundleMeta meta = source.getMeta();
final int nummeta = meta.size();
@SuppressWarnings("rawtypes")
final ByteBufferSerializer[] serializers = new ByteBufferSerializer[1 + nummeta];
// Write our magic ID first.
assert (buffer.position() == 0) : "Buffer is supposed to be at 0.";
buffer.putInt(MAGIC);
// Write the number of metas next.
// For compatibility with earlier versions, treat DBIDs as extra type
if(source.hasDBIDs()) {
buffer.putInt(1 + nummeta);
ByteBufferSerializer<DBID> ser = DBIDFactory.FACTORY.getDBIDSerializer();
TypeInformationSerializer.STATIC.toByteBuffer(buffer, new SimpleTypeInformation<>(DBID.class, ser));
serializers[0] = ser;
}
else {
buffer.putInt(nummeta);
}
for(int i = 0; i < nummeta; i++) {
SimpleTypeInformation<?> type = meta.get(i);
ByteBufferSerializer<?> ser = type.getSerializer();
if(ser == null) {
throw new AbortException("Cannot serialize - no serializer found for type: " + type.toString());
}
TypeInformationSerializer.STATIC.toByteBuffer(buffer, type);
serializers[i + 1] = ser;
}
return serializers;
} | [
"private",
"ByteBufferSerializer",
"<",
"?",
">",
"[",
"]",
"writeHeader",
"(",
"BundleStreamSource",
"source",
",",
"ByteBuffer",
"buffer",
",",
"WritableByteChannel",
"output",
")",
"throws",
"IOException",
"{",
"final",
"BundleMeta",
"meta",
"=",
"source",
".",... | Write the header for the given stream to the stream.
@param source Bundle stream
@param buffer Buffer to use for writing
@param output Output channel
@return Array of serializers
@throws IOException on IO errors | [
"Write",
"the",
"header",
"for",
"the",
"given",
"stream",
"to",
"the",
"stream",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/BundleWriter.java#L163-L192 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java | DBSCAN.runDBSCAN | protected void runDBSCAN(Relation<O> relation, RangeQuery<O> rangeQuery) {
final int size = relation.size();
FiniteProgress objprog = LOG.isVerbose() ? new FiniteProgress("Processing objects", size, LOG) : null;
IndefiniteProgress clusprog = LOG.isVerbose() ? new IndefiniteProgress("Number of clusters", LOG) : null;
processedIDs = DBIDUtil.newHashSet(size);
ArrayModifiableDBIDs seeds = DBIDUtil.newArray();
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
if(!processedIDs.contains(iditer)) {
expandCluster(relation, rangeQuery, iditer, seeds, objprog, clusprog);
}
if(objprog != null && clusprog != null) {
objprog.setProcessed(processedIDs.size(), LOG);
clusprog.setProcessed(resultList.size(), LOG);
}
if(processedIDs.size() == size) {
break;
}
}
// Finish progress logging
LOG.ensureCompleted(objprog);
LOG.setCompleted(clusprog);
} | java | protected void runDBSCAN(Relation<O> relation, RangeQuery<O> rangeQuery) {
final int size = relation.size();
FiniteProgress objprog = LOG.isVerbose() ? new FiniteProgress("Processing objects", size, LOG) : null;
IndefiniteProgress clusprog = LOG.isVerbose() ? new IndefiniteProgress("Number of clusters", LOG) : null;
processedIDs = DBIDUtil.newHashSet(size);
ArrayModifiableDBIDs seeds = DBIDUtil.newArray();
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
if(!processedIDs.contains(iditer)) {
expandCluster(relation, rangeQuery, iditer, seeds, objprog, clusprog);
}
if(objprog != null && clusprog != null) {
objprog.setProcessed(processedIDs.size(), LOG);
clusprog.setProcessed(resultList.size(), LOG);
}
if(processedIDs.size() == size) {
break;
}
}
// Finish progress logging
LOG.ensureCompleted(objprog);
LOG.setCompleted(clusprog);
} | [
"protected",
"void",
"runDBSCAN",
"(",
"Relation",
"<",
"O",
">",
"relation",
",",
"RangeQuery",
"<",
"O",
">",
"rangeQuery",
")",
"{",
"final",
"int",
"size",
"=",
"relation",
".",
"size",
"(",
")",
";",
"FiniteProgress",
"objprog",
"=",
"LOG",
".",
"... | Run the DBSCAN algorithm
@param relation Data relation
@param rangeQuery Range query class | [
"Run",
"the",
"DBSCAN",
"algorithm"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java#L175-L197 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java | DBSCAN.expandCluster | protected void expandCluster(Relation<O> relation, RangeQuery<O> rangeQuery, DBIDRef startObjectID, ArrayModifiableDBIDs seeds, FiniteProgress objprog, IndefiniteProgress clusprog) {
DoubleDBIDList neighbors = rangeQuery.getRangeForDBID(startObjectID, epsilon);
ncounter += neighbors.size();
// startObject is no core-object
if(neighbors.size() < minpts) {
noise.add(startObjectID);
processedIDs.add(startObjectID);
if(objprog != null) {
objprog.incrementProcessed(LOG);
}
return;
}
ModifiableDBIDs currentCluster = DBIDUtil.newArray();
currentCluster.add(startObjectID);
processedIDs.add(startObjectID);
// try to expand the cluster
assert (seeds.size() == 0);
seeds.clear();
processNeighbors(neighbors.iter(), currentCluster, seeds);
DBIDVar o = DBIDUtil.newVar();
while(!seeds.isEmpty()) {
neighbors = rangeQuery.getRangeForDBID(seeds.pop(o), epsilon);
ncounter += neighbors.size();
if(neighbors.size() >= minpts) {
processNeighbors(neighbors.iter(), currentCluster, seeds);
}
if(objprog != null) {
objprog.incrementProcessed(LOG);
}
}
resultList.add(currentCluster);
if(clusprog != null) {
clusprog.setProcessed(resultList.size(), LOG);
}
} | java | protected void expandCluster(Relation<O> relation, RangeQuery<O> rangeQuery, DBIDRef startObjectID, ArrayModifiableDBIDs seeds, FiniteProgress objprog, IndefiniteProgress clusprog) {
DoubleDBIDList neighbors = rangeQuery.getRangeForDBID(startObjectID, epsilon);
ncounter += neighbors.size();
// startObject is no core-object
if(neighbors.size() < minpts) {
noise.add(startObjectID);
processedIDs.add(startObjectID);
if(objprog != null) {
objprog.incrementProcessed(LOG);
}
return;
}
ModifiableDBIDs currentCluster = DBIDUtil.newArray();
currentCluster.add(startObjectID);
processedIDs.add(startObjectID);
// try to expand the cluster
assert (seeds.size() == 0);
seeds.clear();
processNeighbors(neighbors.iter(), currentCluster, seeds);
DBIDVar o = DBIDUtil.newVar();
while(!seeds.isEmpty()) {
neighbors = rangeQuery.getRangeForDBID(seeds.pop(o), epsilon);
ncounter += neighbors.size();
if(neighbors.size() >= minpts) {
processNeighbors(neighbors.iter(), currentCluster, seeds);
}
if(objprog != null) {
objprog.incrementProcessed(LOG);
}
}
resultList.add(currentCluster);
if(clusprog != null) {
clusprog.setProcessed(resultList.size(), LOG);
}
} | [
"protected",
"void",
"expandCluster",
"(",
"Relation",
"<",
"O",
">",
"relation",
",",
"RangeQuery",
"<",
"O",
">",
"rangeQuery",
",",
"DBIDRef",
"startObjectID",
",",
"ArrayModifiableDBIDs",
"seeds",
",",
"FiniteProgress",
"objprog",
",",
"IndefiniteProgress",
"c... | DBSCAN-function expandCluster.
Border-Objects become members of the first possible cluster.
@param relation Database relation to run on
@param rangeQuery Range query to use
@param startObjectID potential seed of a new potential cluster
@param seeds Array to store the current seeds
@param objprog Number of objects processed (may be {@code null})
@param clusprog Number of clusters found (may be {@code null}) | [
"DBSCAN",
"-",
"function",
"expandCluster",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java#L211-L251 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java | DBSCAN.processNeighbors | private void processNeighbors(DoubleDBIDListIter neighbor, ModifiableDBIDs currentCluster, ArrayModifiableDBIDs seeds) {
final boolean ismetric = getDistanceFunction().isMetric();
for(; neighbor.valid(); neighbor.advance()) {
if(processedIDs.add(neighbor)) {
if(!ismetric || neighbor.doubleValue() > 0.) {
seeds.add(neighbor);
}
}
else if(!noise.remove(neighbor)) {
continue;
}
currentCluster.add(neighbor);
}
} | java | private void processNeighbors(DoubleDBIDListIter neighbor, ModifiableDBIDs currentCluster, ArrayModifiableDBIDs seeds) {
final boolean ismetric = getDistanceFunction().isMetric();
for(; neighbor.valid(); neighbor.advance()) {
if(processedIDs.add(neighbor)) {
if(!ismetric || neighbor.doubleValue() > 0.) {
seeds.add(neighbor);
}
}
else if(!noise.remove(neighbor)) {
continue;
}
currentCluster.add(neighbor);
}
} | [
"private",
"void",
"processNeighbors",
"(",
"DoubleDBIDListIter",
"neighbor",
",",
"ModifiableDBIDs",
"currentCluster",
",",
"ArrayModifiableDBIDs",
"seeds",
")",
"{",
"final",
"boolean",
"ismetric",
"=",
"getDistanceFunction",
"(",
")",
".",
"isMetric",
"(",
")",
"... | Process a single core point.
@param neighbor Iterator over neighbors
@param currentCluster Current cluster
@param seeds Seed set | [
"Process",
"a",
"single",
"core",
"point",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/DBSCAN.java#L260-L273 | train |
elki-project/elki | elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/GaussianUniformMixture.java | GaussianUniformMixture.loglikelihoodAnomalous | private double loglikelihoodAnomalous(DBIDs anomalousObjs) {
return anomalousObjs.isEmpty() ? 0 : anomalousObjs.size() * -FastMath.log(anomalousObjs.size());
} | java | private double loglikelihoodAnomalous(DBIDs anomalousObjs) {
return anomalousObjs.isEmpty() ? 0 : anomalousObjs.size() * -FastMath.log(anomalousObjs.size());
} | [
"private",
"double",
"loglikelihoodAnomalous",
"(",
"DBIDs",
"anomalousObjs",
")",
"{",
"return",
"anomalousObjs",
".",
"isEmpty",
"(",
")",
"?",
"0",
":",
"anomalousObjs",
".",
"size",
"(",
")",
"*",
"-",
"FastMath",
".",
"log",
"(",
"anomalousObjs",
".",
... | Loglikelihood anomalous objects. Uniform distribution.
@param anomalousObjs
@return loglikelihood for anomalous objects | [
"Loglikelihood",
"anomalous",
"objects",
".",
"Uniform",
"distribution",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/GaussianUniformMixture.java#L187-L189 | train |
elki-project/elki | elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/GaussianUniformMixture.java | GaussianUniformMixture.loglikelihoodNormal | private double loglikelihoodNormal(DBIDs objids, SetDBIDs anomalous, CovarianceMatrix builder, Relation<V> relation) {
double[] mean = builder.getMeanVector();
final LUDecomposition lu = new LUDecomposition(builder.makeSampleMatrix());
double[][] covInv = lu.inverse();
// for each object compute probability and sum
double prob = (objids.size() - anomalous.size()) * -FastMath.log(FastMath.sqrt(MathUtil.powi(MathUtil.TWOPI, RelationUtil.dimensionality(relation)) * lu.det()));
for(DBIDIter iter = objids.iter(); iter.valid(); iter.advance()) {
if(!anomalous.contains(iter)) {
double[] xcent = minusEquals(relation.get(iter).toArray(), mean);
prob -= .5 * transposeTimesTimes(xcent, covInv, xcent);
}
}
return prob;
} | java | private double loglikelihoodNormal(DBIDs objids, SetDBIDs anomalous, CovarianceMatrix builder, Relation<V> relation) {
double[] mean = builder.getMeanVector();
final LUDecomposition lu = new LUDecomposition(builder.makeSampleMatrix());
double[][] covInv = lu.inverse();
// for each object compute probability and sum
double prob = (objids.size() - anomalous.size()) * -FastMath.log(FastMath.sqrt(MathUtil.powi(MathUtil.TWOPI, RelationUtil.dimensionality(relation)) * lu.det()));
for(DBIDIter iter = objids.iter(); iter.valid(); iter.advance()) {
if(!anomalous.contains(iter)) {
double[] xcent = minusEquals(relation.get(iter).toArray(), mean);
prob -= .5 * transposeTimesTimes(xcent, covInv, xcent);
}
}
return prob;
} | [
"private",
"double",
"loglikelihoodNormal",
"(",
"DBIDs",
"objids",
",",
"SetDBIDs",
"anomalous",
",",
"CovarianceMatrix",
"builder",
",",
"Relation",
"<",
"V",
">",
"relation",
")",
"{",
"double",
"[",
"]",
"mean",
"=",
"builder",
".",
"getMeanVector",
"(",
... | Computes the loglikelihood of all normal objects. Gaussian model
@param objids Object IDs for 'normal' objects.
@param builder Covariance matrix builder
@param relation Database
@return loglikelihood for normal objects | [
"Computes",
"the",
"loglikelihood",
"of",
"all",
"normal",
"objects",
".",
"Gaussian",
"model"
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/GaussianUniformMixture.java#L199-L212 | train |
elki-project/elki | elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/DistanceStatisticsWithClasses.java | DistanceStatisticsWithClasses.exactMinMax | private DoubleMinMax exactMinMax(Relation<O> relation, DistanceQuery<O> distFunc) {
final FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("Exact fitting distance computations", relation.size(), LOG) : null;
DoubleMinMax minmax = new DoubleMinMax();
// find exact minimum and maximum first.
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
for(DBIDIter iditer2 = relation.iterDBIDs(); iditer2.valid(); iditer2.advance()) {
// skip the point itself.
if(DBIDUtil.equal(iditer, iditer2)) {
continue;
}
double d = distFunc.distance(iditer, iditer2);
minmax.put(d);
}
LOG.incrementProcessed(progress);
}
LOG.ensureCompleted(progress);
return minmax;
} | java | private DoubleMinMax exactMinMax(Relation<O> relation, DistanceQuery<O> distFunc) {
final FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("Exact fitting distance computations", relation.size(), LOG) : null;
DoubleMinMax minmax = new DoubleMinMax();
// find exact minimum and maximum first.
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
for(DBIDIter iditer2 = relation.iterDBIDs(); iditer2.valid(); iditer2.advance()) {
// skip the point itself.
if(DBIDUtil.equal(iditer, iditer2)) {
continue;
}
double d = distFunc.distance(iditer, iditer2);
minmax.put(d);
}
LOG.incrementProcessed(progress);
}
LOG.ensureCompleted(progress);
return minmax;
} | [
"private",
"DoubleMinMax",
"exactMinMax",
"(",
"Relation",
"<",
"O",
">",
"relation",
",",
"DistanceQuery",
"<",
"O",
">",
"distFunc",
")",
"{",
"final",
"FiniteProgress",
"progress",
"=",
"LOG",
".",
"isVerbose",
"(",
")",
"?",
"new",
"FiniteProgress",
"(",... | Compute the exact maximum and minimum.
@param relation Relation to process
@param distFunc Distance function
@return Exact maximum and minimum | [
"Compute",
"the",
"exact",
"maximum",
"and",
"minimum",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/DistanceStatisticsWithClasses.java#L357-L374 | train |
elki-project/elki | elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java | RdKNNTree.preInsert | @Override
protected void preInsert(RdKNNEntry entry) {
KNNHeap knns_o = DBIDUtil.newHeap(settings.k_max);
preInsert(entry, getRootEntry(), knns_o);
} | java | @Override
protected void preInsert(RdKNNEntry entry) {
KNNHeap knns_o = DBIDUtil.newHeap(settings.k_max);
preInsert(entry, getRootEntry(), knns_o);
} | [
"@",
"Override",
"protected",
"void",
"preInsert",
"(",
"RdKNNEntry",
"entry",
")",
"{",
"KNNHeap",
"knns_o",
"=",
"DBIDUtil",
".",
"newHeap",
"(",
"settings",
".",
"k_max",
")",
";",
"preInsert",
"(",
"entry",
",",
"getRootEntry",
"(",
")",
",",
"knns_o",... | Performs necessary operations before inserting the specified entry.
@param entry the entry to be inserted | [
"Performs",
"necessary",
"operations",
"before",
"inserting",
"the",
"specified",
"entry",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java#L123-L127 | train |
elki-project/elki | elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java | RdKNNTree.postDelete | @Override
protected void postDelete(RdKNNEntry entry) {
// reverse knn of o
ModifiableDoubleDBIDList rnns = DBIDUtil.newDistanceDBIDList();
doReverseKNN(getRoot(), ((RdKNNLeafEntry) entry).getDBID(), rnns);
// knn of rnn
ArrayModifiableDBIDs ids = DBIDUtil.newArray(rnns);
ids.sort();
List<? extends KNNList> knnLists = knnQuery.getKNNForBulkDBIDs(ids, settings.k_max);
// adjust knn distances
adjustKNNDistance(getRootEntry(), ids, knnLists);
} | java | @Override
protected void postDelete(RdKNNEntry entry) {
// reverse knn of o
ModifiableDoubleDBIDList rnns = DBIDUtil.newDistanceDBIDList();
doReverseKNN(getRoot(), ((RdKNNLeafEntry) entry).getDBID(), rnns);
// knn of rnn
ArrayModifiableDBIDs ids = DBIDUtil.newArray(rnns);
ids.sort();
List<? extends KNNList> knnLists = knnQuery.getKNNForBulkDBIDs(ids, settings.k_max);
// adjust knn distances
adjustKNNDistance(getRootEntry(), ids, knnLists);
} | [
"@",
"Override",
"protected",
"void",
"postDelete",
"(",
"RdKNNEntry",
"entry",
")",
"{",
"// reverse knn of o",
"ModifiableDoubleDBIDList",
"rnns",
"=",
"DBIDUtil",
".",
"newDistanceDBIDList",
"(",
")",
";",
"doReverseKNN",
"(",
"getRoot",
"(",
")",
",",
"(",
"... | Performs necessary operations after deleting the specified object. | [
"Performs",
"necessary",
"operations",
"after",
"deleting",
"the",
"specified",
"object",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java#L132-L145 | train |
elki-project/elki | elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java | RdKNNTree.doReverseKNN | private void doReverseKNN(RdKNNNode node, DBID oid, ModifiableDoubleDBIDList result) {
if(node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNLeafEntry entry = (RdKNNLeafEntry) node.getEntry(i);
double distance = distanceQuery.distance(entry.getDBID(), oid);
if(distance <= entry.getKnnDistance()) {
result.add(distance, entry.getDBID());
}
}
}
// node is a inner node
else {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNDirectoryEntry entry = (RdKNNDirectoryEntry) node.getEntry(i);
double minDist = distanceQuery.minDist(entry, oid);
if(minDist <= entry.getKnnDistance()) {
doReverseKNN(getNode(entry), oid, result);
}
}
}
} | java | private void doReverseKNN(RdKNNNode node, DBID oid, ModifiableDoubleDBIDList result) {
if(node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNLeafEntry entry = (RdKNNLeafEntry) node.getEntry(i);
double distance = distanceQuery.distance(entry.getDBID(), oid);
if(distance <= entry.getKnnDistance()) {
result.add(distance, entry.getDBID());
}
}
}
// node is a inner node
else {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNDirectoryEntry entry = (RdKNNDirectoryEntry) node.getEntry(i);
double minDist = distanceQuery.minDist(entry, oid);
if(minDist <= entry.getKnnDistance()) {
doReverseKNN(getNode(entry), oid, result);
}
}
}
} | [
"private",
"void",
"doReverseKNN",
"(",
"RdKNNNode",
"node",
",",
"DBID",
"oid",
",",
"ModifiableDoubleDBIDList",
"result",
")",
"{",
"if",
"(",
"node",
".",
"isLeaf",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"node",
".",
... | Performs a reverse knn query in the specified subtree.
@param node the root node of the current subtree
@param oid the id of the object for which the rknn query is performed
@param result the list containing the query results | [
"Performs",
"a",
"reverse",
"knn",
"query",
"in",
"the",
"specified",
"subtree",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java#L399-L419 | train |
elki-project/elki | elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java | RdKNNTree.doBulkReverseKNN | private void doBulkReverseKNN(RdKNNNode node, DBIDs ids, Map<DBID, ModifiableDoubleDBIDList> result) {
if(node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNLeafEntry entry = (RdKNNLeafEntry) node.getEntry(i);
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
DBID id = DBIDUtil.deref(iter);
double distance = distanceQuery.distance(entry.getDBID(), id);
if(distance <= entry.getKnnDistance()) {
result.get(id).add(distance, entry.getDBID());
}
}
}
}
// node is a inner node
else {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNDirectoryEntry entry = (RdKNNDirectoryEntry) node.getEntry(i);
ModifiableDBIDs candidates = DBIDUtil.newArray();
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
DBID id = DBIDUtil.deref(iter);
double minDist = distanceQuery.minDist(entry, id);
if(minDist <= entry.getKnnDistance()) {
candidates.add(id);
}
if(!candidates.isEmpty()) {
doBulkReverseKNN(getNode(entry), candidates, result);
}
}
}
}
} | java | private void doBulkReverseKNN(RdKNNNode node, DBIDs ids, Map<DBID, ModifiableDoubleDBIDList> result) {
if(node.isLeaf()) {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNLeafEntry entry = (RdKNNLeafEntry) node.getEntry(i);
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
DBID id = DBIDUtil.deref(iter);
double distance = distanceQuery.distance(entry.getDBID(), id);
if(distance <= entry.getKnnDistance()) {
result.get(id).add(distance, entry.getDBID());
}
}
}
}
// node is a inner node
else {
for(int i = 0; i < node.getNumEntries(); i++) {
RdKNNDirectoryEntry entry = (RdKNNDirectoryEntry) node.getEntry(i);
ModifiableDBIDs candidates = DBIDUtil.newArray();
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
DBID id = DBIDUtil.deref(iter);
double minDist = distanceQuery.minDist(entry, id);
if(minDist <= entry.getKnnDistance()) {
candidates.add(id);
}
if(!candidates.isEmpty()) {
doBulkReverseKNN(getNode(entry), candidates, result);
}
}
}
}
} | [
"private",
"void",
"doBulkReverseKNN",
"(",
"RdKNNNode",
"node",
",",
"DBIDs",
"ids",
",",
"Map",
"<",
"DBID",
",",
"ModifiableDoubleDBIDList",
">",
"result",
")",
"{",
"if",
"(",
"node",
".",
"isLeaf",
"(",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
... | Performs a bulk reverse knn query in the specified subtree.
@param node the root node of the current subtree
@param ids the object ids for which the rknn query is performed
@param result the map containing the query results for each object | [
"Performs",
"a",
"bulk",
"reverse",
"knn",
"query",
"in",
"the",
"specified",
"subtree",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java#L428-L458 | train |
elki-project/elki | elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java | RdKNNTree.checkDistanceFunction | private void checkDistanceFunction(SpatialPrimitiveDistanceFunction<? super O> distanceFunction) {
if(!settings.distanceFunction.equals(distanceFunction)) {
throw new IllegalArgumentException("Parameter distanceFunction must be an instance of " + this.distanceQuery.getClass() + ", but is " + distanceFunction.getClass());
}
} | java | private void checkDistanceFunction(SpatialPrimitiveDistanceFunction<? super O> distanceFunction) {
if(!settings.distanceFunction.equals(distanceFunction)) {
throw new IllegalArgumentException("Parameter distanceFunction must be an instance of " + this.distanceQuery.getClass() + ", but is " + distanceFunction.getClass());
}
} | [
"private",
"void",
"checkDistanceFunction",
"(",
"SpatialPrimitiveDistanceFunction",
"<",
"?",
"super",
"O",
">",
"distanceFunction",
")",
"{",
"if",
"(",
"!",
"settings",
".",
"distanceFunction",
".",
"equals",
"(",
"distanceFunction",
")",
")",
"{",
"throw",
"... | Throws an IllegalArgumentException if the specified distance function is
not an instance of the distance function used by this index.
@throws IllegalArgumentException
@param distanceFunction the distance function to be checked | [
"Throws",
"an",
"IllegalArgumentException",
"if",
"the",
"specified",
"distance",
"function",
"is",
"not",
"an",
"instance",
"of",
"the",
"distance",
"function",
"used",
"by",
"this",
"index",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java#L538-L542 | train |
elki-project/elki | elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java | RdKNNTree.insertAll | @Override
public final void insertAll(DBIDs ids) {
if(ids.isEmpty() || (ids.size() == 1)) {
return;
}
// Make an example leaf
if(canBulkLoad()) {
List<RdKNNEntry> leafs = new ArrayList<>(ids.size());
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
leafs.add(createNewLeafEntry(DBIDUtil.deref(iter)));
}
bulkLoad(leafs);
}
else {
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
insert(iter);
}
}
doExtraIntegrityChecks();
} | java | @Override
public final void insertAll(DBIDs ids) {
if(ids.isEmpty() || (ids.size() == 1)) {
return;
}
// Make an example leaf
if(canBulkLoad()) {
List<RdKNNEntry> leafs = new ArrayList<>(ids.size());
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
leafs.add(createNewLeafEntry(DBIDUtil.deref(iter)));
}
bulkLoad(leafs);
}
else {
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
insert(iter);
}
}
doExtraIntegrityChecks();
} | [
"@",
"Override",
"public",
"final",
"void",
"insertAll",
"(",
"DBIDs",
"ids",
")",
"{",
"if",
"(",
"ids",
".",
"isEmpty",
"(",
")",
"||",
"(",
"ids",
".",
"size",
"(",
")",
"==",
"1",
")",
")",
"{",
"return",
";",
"}",
"// Make an example leaf",
"i... | Inserts the specified objects into this index. If a bulk load mode is
implemented, the objects are inserted in one bulk.
@param ids the objects to be inserted | [
"Inserts",
"the",
"specified",
"objects",
"into",
"this",
"index",
".",
"If",
"a",
"bulk",
"load",
"mode",
"is",
"implemented",
"the",
"objects",
"are",
"inserted",
"in",
"one",
"bulk",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNTree.java#L570-L591 | train |
elki-project/elki | elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/HiCO.java | HiCO.correlationDistance | public int correlationDistance(PCAFilteredResult pca1, PCAFilteredResult pca2, int dimensionality) {
// TODO: Can we delay copying the matrixes?
// pca of rv1
double[][] v1t = copy(pca1.getEigenvectors());
double[][] v1t_strong = pca1.getStrongEigenvectors();
int lambda1 = pca1.getCorrelationDimension();
// pca of rv2
double[][] v2t = copy(pca2.getEigenvectors());
double[][] v2t_strong = pca2.getStrongEigenvectors();
int lambda2 = pca2.getCorrelationDimension();
// for all strong eigenvectors of rv2
double[][] m1_czech = pca1.dissimilarityMatrix();
for(int i = 0; i < v2t_strong.length; i++) {
double[] v2_i = v2t_strong[i];
// check, if distance of v2_i to the space of rv1 > delta
// (i.e., if v2_i spans up a new dimension)
double distsq = squareSum(v2_i) - transposeTimesTimes(v2_i, m1_czech, v2_i);
// if so, insert v2_i into v1 and adjust v1
// and compute m1_czech new, increase lambda1
if(lambda1 < dimensionality && distsq > deltasq) {
adjust(v1t, v2_i, lambda1++);
// TODO: make this incremental?
double[] e1_czech_d = new double[v1t.length];
Arrays.fill(e1_czech_d, 0, lambda1, 1);
m1_czech = transposeDiagonalTimes(v1t, e1_czech_d, v1t);
}
}
// for all strong eigenvectors of rv1
double[][] m2_czech = pca2.dissimilarityMatrix();
for(int i = 0; i < v1t_strong.length; i++) {
double[] v1_i = v1t_strong[i];
// check, if distance of v1_i to the space of rv2 > delta
// (i.e., if v1_i spans up a new dimension)
double distsq = squareSum(v1_i) - transposeTimesTimes(v1_i, m2_czech, v1_i);
// if so, insert v1_i into v2 and adjust v2
// and compute m2_czech new , increase lambda2
if(lambda2 < dimensionality && distsq > deltasq) {
adjust(v2t, v1_i, lambda2++);
// TODO: make this incremental?
double[] e2_czech_d = new double[v1t.length];
Arrays.fill(e2_czech_d, 0, lambda2, 1);
m2_czech = transposeDiagonalTimes(v2t, e2_czech_d, v2t);
}
}
return Math.max(lambda1, lambda2);
} | java | public int correlationDistance(PCAFilteredResult pca1, PCAFilteredResult pca2, int dimensionality) {
// TODO: Can we delay copying the matrixes?
// pca of rv1
double[][] v1t = copy(pca1.getEigenvectors());
double[][] v1t_strong = pca1.getStrongEigenvectors();
int lambda1 = pca1.getCorrelationDimension();
// pca of rv2
double[][] v2t = copy(pca2.getEigenvectors());
double[][] v2t_strong = pca2.getStrongEigenvectors();
int lambda2 = pca2.getCorrelationDimension();
// for all strong eigenvectors of rv2
double[][] m1_czech = pca1.dissimilarityMatrix();
for(int i = 0; i < v2t_strong.length; i++) {
double[] v2_i = v2t_strong[i];
// check, if distance of v2_i to the space of rv1 > delta
// (i.e., if v2_i spans up a new dimension)
double distsq = squareSum(v2_i) - transposeTimesTimes(v2_i, m1_czech, v2_i);
// if so, insert v2_i into v1 and adjust v1
// and compute m1_czech new, increase lambda1
if(lambda1 < dimensionality && distsq > deltasq) {
adjust(v1t, v2_i, lambda1++);
// TODO: make this incremental?
double[] e1_czech_d = new double[v1t.length];
Arrays.fill(e1_czech_d, 0, lambda1, 1);
m1_czech = transposeDiagonalTimes(v1t, e1_czech_d, v1t);
}
}
// for all strong eigenvectors of rv1
double[][] m2_czech = pca2.dissimilarityMatrix();
for(int i = 0; i < v1t_strong.length; i++) {
double[] v1_i = v1t_strong[i];
// check, if distance of v1_i to the space of rv2 > delta
// (i.e., if v1_i spans up a new dimension)
double distsq = squareSum(v1_i) - transposeTimesTimes(v1_i, m2_czech, v1_i);
// if so, insert v1_i into v2 and adjust v2
// and compute m2_czech new , increase lambda2
if(lambda2 < dimensionality && distsq > deltasq) {
adjust(v2t, v1_i, lambda2++);
// TODO: make this incremental?
double[] e2_czech_d = new double[v1t.length];
Arrays.fill(e2_czech_d, 0, lambda2, 1);
m2_czech = transposeDiagonalTimes(v2t, e2_czech_d, v2t);
}
}
return Math.max(lambda1, lambda2);
} | [
"public",
"int",
"correlationDistance",
"(",
"PCAFilteredResult",
"pca1",
",",
"PCAFilteredResult",
"pca2",
",",
"int",
"dimensionality",
")",
"{",
"// TODO: Can we delay copying the matrixes?",
"// pca of rv1",
"double",
"[",
"]",
"[",
"]",
"v1t",
"=",
"copy",
"(",
... | Computes the correlation distance between the two subspaces defined by the
specified PCAs.
@param pca1 first PCA
@param pca2 second PCA
@param dimensionality the dimensionality of the data space
@return the correlation distance between the two subspaces defined by the
specified PCAs | [
"Computes",
"the",
"correlation",
"distance",
"between",
"the",
"two",
"subspaces",
"defined",
"by",
"the",
"specified",
"PCAs",
"."
] | b54673327e76198ecd4c8a2a901021f1a9174498 | https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/HiCO.java#L302-L352 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.