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/ELKIServiceLoader.java
ELKIServiceLoader.parseLine
private static void parseLine(Class<?> parent, char[] line, int begin, int end) { while(begin < end && line[begin] == ' ') { begin++; } if(begin >= end || line[begin] == '#') { return; // Empty/comment lines are okay, continue } // Find end of class name: int cend = begin + 1; while(cend < end && line[cend] != ' ') { cend++; } // Class name: String cname = new String(line, begin, cend - begin); ELKIServiceRegistry.register(parent, cname); for(int abegin = cend + 1, aend = -1; abegin < end; abegin = aend + 1) { // Skip whitespace: while(abegin < end && line[abegin] == ' ') { abegin++; } // Find next whitespace: aend = abegin + 1; while(aend < end && line[aend] != ' ') { aend++; } ELKIServiceRegistry.registerAlias(parent, new String(line, abegin, aend - abegin), cname); } return; }
java
private static void parseLine(Class<?> parent, char[] line, int begin, int end) { while(begin < end && line[begin] == ' ') { begin++; } if(begin >= end || line[begin] == '#') { return; // Empty/comment lines are okay, continue } // Find end of class name: int cend = begin + 1; while(cend < end && line[cend] != ' ') { cend++; } // Class name: String cname = new String(line, begin, cend - begin); ELKIServiceRegistry.register(parent, cname); for(int abegin = cend + 1, aend = -1; abegin < end; abegin = aend + 1) { // Skip whitespace: while(abegin < end && line[abegin] == ' ') { abegin++; } // Find next whitespace: aend = abegin + 1; while(aend < end && line[aend] != ' ') { aend++; } ELKIServiceRegistry.registerAlias(parent, new String(line, abegin, aend - abegin), cname); } return; }
[ "private", "static", "void", "parseLine", "(", "Class", "<", "?", ">", "parent", ",", "char", "[", "]", "line", ",", "int", "begin", ",", "int", "end", ")", "{", "while", "(", "begin", "<", "end", "&&", "line", "[", "begin", "]", "==", "'", "'", ...
Parse a single line from a service registry file. @param parent Parent class @param line Line to read
[ "Parse", "a", "single", "line", "from", "a", "service", "registry", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/ELKIServiceLoader.java#L130-L158
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/rdknn/RdKNNLeafEntry.java
RdKNNLeafEntry.readExternal
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); this.knnDistance = in.readDouble(); }
java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); this.knnDistance = in.readDouble(); }
[ "@", "Override", "public", "void", "readExternal", "(", "ObjectInput", "in", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "super", ".", "readExternal", "(", "in", ")", ";", "this", ".", "knnDistance", "=", "in", ".", "readDouble", "(", "...
Calls the super method and reads the knn distance 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", "knn", "distance", "of", "this", "entry", "from", "the", "specified", "input", "stream", "." ]
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/RdKNNLeafEntry.java#L98-L102
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/OnlineLOF.java
OnlineLOF.getKNNAndRkNNQueries
private Pair<Pair<KNNQuery<O>, KNNQuery<O>>, Pair<RKNNQuery<O>, RKNNQuery<O>>> getKNNAndRkNNQueries(Database database, Relation<O> relation, StepProgress stepprog) { DistanceQuery<O> drefQ = database.getDistanceQuery(relation, referenceDistanceFunction); // Use "HEAVY" flag, since this is an online algorithm KNNQuery<O> kNNRefer = database.getKNNQuery(drefQ, krefer, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); RKNNQuery<O> rkNNRefer = database.getRKNNQuery(drefQ, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); // No optimized kNN query or RkNN query - use a preprocessor! if(kNNRefer == null || rkNNRefer == null) { if(stepprog != null) { stepprog.beginStep(1, "Materializing neighborhood w.r.t. reference neighborhood distance function.", LOG); } MaterializeKNNAndRKNNPreprocessor<O> preproc = new MaterializeKNNAndRKNNPreprocessor<>(relation, referenceDistanceFunction, krefer); kNNRefer = preproc.getKNNQuery(drefQ, krefer, DatabaseQuery.HINT_HEAVY_USE); rkNNRefer = preproc.getRKNNQuery(drefQ, krefer, DatabaseQuery.HINT_HEAVY_USE); // add as index database.getHierarchy().add(relation, preproc); } else { if(stepprog != null) { stepprog.beginStep(1, "Optimized neighborhood w.r.t. reference neighborhood distance function provided by database.", LOG); } } DistanceQuery<O> dreachQ = database.getDistanceQuery(relation, reachabilityDistanceFunction); KNNQuery<O> kNNReach = database.getKNNQuery(dreachQ, kreach, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); RKNNQuery<O> rkNNReach = database.getRKNNQuery(dreachQ, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); if(kNNReach == null || rkNNReach == null) { if(stepprog != null) { stepprog.beginStep(2, "Materializing neighborhood w.r.t. reachability distance function.", LOG); } ListParameterization config = new ListParameterization(); config.addParameter(AbstractMaterializeKNNPreprocessor.Factory.DISTANCE_FUNCTION_ID, reachabilityDistanceFunction); config.addParameter(AbstractMaterializeKNNPreprocessor.Factory.K_ID, kreach); MaterializeKNNAndRKNNPreprocessor<O> preproc = new MaterializeKNNAndRKNNPreprocessor<>(relation, reachabilityDistanceFunction, kreach); kNNReach = preproc.getKNNQuery(dreachQ, kreach, DatabaseQuery.HINT_HEAVY_USE); rkNNReach = preproc.getRKNNQuery(dreachQ, kreach, DatabaseQuery.HINT_HEAVY_USE); // add as index database.getHierarchy().add(relation, preproc); } Pair<KNNQuery<O>, KNNQuery<O>> kNNPair = new Pair<>(kNNRefer, kNNReach); Pair<RKNNQuery<O>, RKNNQuery<O>> rkNNPair = new Pair<>(rkNNRefer, rkNNReach); return new Pair<>(kNNPair, rkNNPair); }
java
private Pair<Pair<KNNQuery<O>, KNNQuery<O>>, Pair<RKNNQuery<O>, RKNNQuery<O>>> getKNNAndRkNNQueries(Database database, Relation<O> relation, StepProgress stepprog) { DistanceQuery<O> drefQ = database.getDistanceQuery(relation, referenceDistanceFunction); // Use "HEAVY" flag, since this is an online algorithm KNNQuery<O> kNNRefer = database.getKNNQuery(drefQ, krefer, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); RKNNQuery<O> rkNNRefer = database.getRKNNQuery(drefQ, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); // No optimized kNN query or RkNN query - use a preprocessor! if(kNNRefer == null || rkNNRefer == null) { if(stepprog != null) { stepprog.beginStep(1, "Materializing neighborhood w.r.t. reference neighborhood distance function.", LOG); } MaterializeKNNAndRKNNPreprocessor<O> preproc = new MaterializeKNNAndRKNNPreprocessor<>(relation, referenceDistanceFunction, krefer); kNNRefer = preproc.getKNNQuery(drefQ, krefer, DatabaseQuery.HINT_HEAVY_USE); rkNNRefer = preproc.getRKNNQuery(drefQ, krefer, DatabaseQuery.HINT_HEAVY_USE); // add as index database.getHierarchy().add(relation, preproc); } else { if(stepprog != null) { stepprog.beginStep(1, "Optimized neighborhood w.r.t. reference neighborhood distance function provided by database.", LOG); } } DistanceQuery<O> dreachQ = database.getDistanceQuery(relation, reachabilityDistanceFunction); KNNQuery<O> kNNReach = database.getKNNQuery(dreachQ, kreach, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); RKNNQuery<O> rkNNReach = database.getRKNNQuery(dreachQ, DatabaseQuery.HINT_HEAVY_USE, DatabaseQuery.HINT_OPTIMIZED_ONLY, DatabaseQuery.HINT_NO_CACHE); if(kNNReach == null || rkNNReach == null) { if(stepprog != null) { stepprog.beginStep(2, "Materializing neighborhood w.r.t. reachability distance function.", LOG); } ListParameterization config = new ListParameterization(); config.addParameter(AbstractMaterializeKNNPreprocessor.Factory.DISTANCE_FUNCTION_ID, reachabilityDistanceFunction); config.addParameter(AbstractMaterializeKNNPreprocessor.Factory.K_ID, kreach); MaterializeKNNAndRKNNPreprocessor<O> preproc = new MaterializeKNNAndRKNNPreprocessor<>(relation, reachabilityDistanceFunction, kreach); kNNReach = preproc.getKNNQuery(dreachQ, kreach, DatabaseQuery.HINT_HEAVY_USE); rkNNReach = preproc.getRKNNQuery(dreachQ, kreach, DatabaseQuery.HINT_HEAVY_USE); // add as index database.getHierarchy().add(relation, preproc); } Pair<KNNQuery<O>, KNNQuery<O>> kNNPair = new Pair<>(kNNRefer, kNNReach); Pair<RKNNQuery<O>, RKNNQuery<O>> rkNNPair = new Pair<>(rkNNRefer, rkNNReach); return new Pair<>(kNNPair, rkNNPair); }
[ "private", "Pair", "<", "Pair", "<", "KNNQuery", "<", "O", ">", ",", "KNNQuery", "<", "O", ">", ">", ",", "Pair", "<", "RKNNQuery", "<", "O", ">", ",", "RKNNQuery", "<", "O", ">", ">", ">", "getKNNAndRkNNQueries", "(", "Database", "database", ",", ...
Get the kNN and rkNN queries for the algorithm. @param relation Data @param stepprog Progress logger @return the kNN and rkNN queries
[ "Get", "the", "kNN", "and", "rkNN", "queries", "for", "the", "algorithm", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/algorithm/outlier/lof/OnlineLOF.java#L121-L165
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/COPACNeighborPredicate.java
COPACNeighborPredicate.instantiate
public COPACNeighborPredicate.Instance instantiate(Database database, Relation<V> relation) { DistanceQuery<V> dq = database.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = database.getKNNQuery(dq, settings.k); WritableDataStore<COPACModel> storage = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, COPACModel.class); Duration time = LOG.newDuration(this.getClass().getName() + ".preprocessing-time").begin(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress(this.getClass().getName(), relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { DoubleDBIDList ref = knnq.getKNNForDBID(iditer, settings.k); storage.put(iditer, computeLocalModel(iditer, ref, relation)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); LOG.statistics(time.end()); return new Instance(relation.getDBIDs(), storage); }
java
public COPACNeighborPredicate.Instance instantiate(Database database, Relation<V> relation) { DistanceQuery<V> dq = database.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = database.getKNNQuery(dq, settings.k); WritableDataStore<COPACModel> storage = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, COPACModel.class); Duration time = LOG.newDuration(this.getClass().getName() + ".preprocessing-time").begin(); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress(this.getClass().getName(), relation.size(), LOG) : null; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { DoubleDBIDList ref = knnq.getKNNForDBID(iditer, settings.k); storage.put(iditer, computeLocalModel(iditer, ref, relation)); LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); LOG.statistics(time.end()); return new Instance(relation.getDBIDs(), storage); }
[ "public", "COPACNeighborPredicate", ".", "Instance", "instantiate", "(", "Database", "database", ",", "Relation", "<", "V", ">", "relation", ")", "{", "DistanceQuery", "<", "V", ">", "dq", "=", "database", ".", "getDistanceQuery", "(", "relation", ",", "Euclid...
Full instantiation method. @param database Database @param relation Vector relation @return Instance
[ "Full", "instantiation", "method", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/COPACNeighborPredicate.java#L115-L131
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/COPACNeighborPredicate.java
COPACNeighborPredicate.computeLocalModel
protected COPACModel computeLocalModel(DBIDRef id, DoubleDBIDList knnneighbors, Relation<V> relation) { PCAResult epairs = settings.pca.processIds(knnneighbors, relation); int pdim = settings.filter.filter(epairs.getEigenvalues()); PCAFilteredResult pcares = new PCAFilteredResult(epairs.getEigenPairs(), pdim, 1., 0.); double[][] mat = pcares.similarityMatrix(); double[] vecP = relation.get(id).toArray(); if(pdim == vecP.length) { // Full dimensional - noise! return new COPACModel(pdim, DBIDUtil.EMPTYDBIDS); } // Check which neighbors survive HashSetModifiableDBIDs survivors = DBIDUtil.newHashSet(); for(DBIDIter neighbor = relation.iterDBIDs(); neighbor.valid(); neighbor.advance()) { double[] diff = minusEquals(relation.get(neighbor).toArray(), vecP); double cdistP = transposeTimesTimes(diff, mat, diff); if(cdistP <= epsilonsq) { survivors.add(neighbor); } } return new COPACModel(pdim, survivors); }
java
protected COPACModel computeLocalModel(DBIDRef id, DoubleDBIDList knnneighbors, Relation<V> relation) { PCAResult epairs = settings.pca.processIds(knnneighbors, relation); int pdim = settings.filter.filter(epairs.getEigenvalues()); PCAFilteredResult pcares = new PCAFilteredResult(epairs.getEigenPairs(), pdim, 1., 0.); double[][] mat = pcares.similarityMatrix(); double[] vecP = relation.get(id).toArray(); if(pdim == vecP.length) { // Full dimensional - noise! return new COPACModel(pdim, DBIDUtil.EMPTYDBIDS); } // Check which neighbors survive HashSetModifiableDBIDs survivors = DBIDUtil.newHashSet(); for(DBIDIter neighbor = relation.iterDBIDs(); neighbor.valid(); neighbor.advance()) { double[] diff = minusEquals(relation.get(neighbor).toArray(), vecP); double cdistP = transposeTimesTimes(diff, mat, diff); if(cdistP <= epsilonsq) { survivors.add(neighbor); } } return new COPACModel(pdim, survivors); }
[ "protected", "COPACModel", "computeLocalModel", "(", "DBIDRef", "id", ",", "DoubleDBIDList", "knnneighbors", ",", "Relation", "<", "V", ">", "relation", ")", "{", "PCAResult", "epairs", "=", "settings", ".", "pca", ".", "processIds", "(", "knnneighbors", ",", ...
COPAC model computation @param id Query object @param knnneighbors k nearest neighbors @param relation Data relation @return COPAC object model
[ "COPAC", "model", "computation" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/COPACNeighborPredicate.java#L141-L163
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTreeNode.java
AbstractRStarTreeNode.computeMBR
public ModifiableHyperBoundingBox computeMBR() { E firstEntry = getEntry(0); if(firstEntry == null) { return null; } // Note: we deliberately get a cloned copy here, since we will modify it. ModifiableHyperBoundingBox mbr = new ModifiableHyperBoundingBox(firstEntry); for(int i = 1; i < numEntries; i++) { mbr.extend(getEntry(i)); } return mbr; }
java
public ModifiableHyperBoundingBox computeMBR() { E firstEntry = getEntry(0); if(firstEntry == null) { return null; } // Note: we deliberately get a cloned copy here, since we will modify it. ModifiableHyperBoundingBox mbr = new ModifiableHyperBoundingBox(firstEntry); for(int i = 1; i < numEntries; i++) { mbr.extend(getEntry(i)); } return mbr; }
[ "public", "ModifiableHyperBoundingBox", "computeMBR", "(", ")", "{", "E", "firstEntry", "=", "getEntry", "(", "0", ")", ";", "if", "(", "firstEntry", "==", "null", ")", "{", "return", "null", ";", "}", "// Note: we deliberately get a cloned copy here, since we will ...
Recomputing the MBR is rather expensive. @return MBR
[ "Recomputing", "the", "MBR", "is", "rather", "expensive", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTreeNode.java#L72-L83
train
elki-project/elki
addons/joglvis/src/main/java/de/lmu/ifi/dbs/elki/joglvis/SimpleCamera3D.java
SimpleCamera3D.applyCamera
public void applyCamera(GL2 gl) { // Setup projection. gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45f, // fov, width / (float) height, // ratio 0.f, 10.f); // near, far clipping eye[0] = (float) Math.sin(theta) * 2.f; eye[1] = .5f; eye[2] = (float) Math.cos(theta) * 2.f; glu.gluLookAt(eye[0], eye[1], eye[2], // eye .0f, .0f, 0.f, // center 0.f, 1.f, 0.f); // up gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glViewport(0, 0, width, height); }
java
public void applyCamera(GL2 gl) { // Setup projection. gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45f, // fov, width / (float) height, // ratio 0.f, 10.f); // near, far clipping eye[0] = (float) Math.sin(theta) * 2.f; eye[1] = .5f; eye[2] = (float) Math.cos(theta) * 2.f; glu.gluLookAt(eye[0], eye[1], eye[2], // eye .0f, .0f, 0.f, // center 0.f, 1.f, 0.f); // up gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glViewport(0, 0, width, height); }
[ "public", "void", "applyCamera", "(", "GL2", "gl", ")", "{", "// Setup projection.", "gl", ".", "glMatrixMode", "(", "GL2", ".", "GL_PROJECTION", ")", ";", "gl", ".", "glLoadIdentity", "(", ")", ";", "glu", ".", "gluPerspective", "(", "45f", ",", "// fov,"...
Apply the camera settings. @param gl GL API.
[ "Apply", "the", "camera", "settings", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/joglvis/src/main/java/de/lmu/ifi/dbs/elki/joglvis/SimpleCamera3D.java#L66-L84
train
elki-project/elki
elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/knn/LinearScanDistanceKNNQuery.java
LinearScanDistanceKNNQuery.linearScanBatchKNN
private void linearScanBatchKNN(ArrayDBIDs ids, List<KNNHeap> heaps) { final DistanceQuery<O> dq = distanceQuery; // The distance is computed on database IDs for(DBIDIter iter = getRelation().getDBIDs().iter(); iter.valid(); iter.advance()) { int index = 0; for(DBIDIter iter2 = ids.iter(); iter2.valid(); iter2.advance(), index++) { KNNHeap heap = heaps.get(index); heap.insert(dq.distance(iter2, iter), iter); } } }
java
private void linearScanBatchKNN(ArrayDBIDs ids, List<KNNHeap> heaps) { final DistanceQuery<O> dq = distanceQuery; // The distance is computed on database IDs for(DBIDIter iter = getRelation().getDBIDs().iter(); iter.valid(); iter.advance()) { int index = 0; for(DBIDIter iter2 = ids.iter(); iter2.valid(); iter2.advance(), index++) { KNNHeap heap = heaps.get(index); heap.insert(dq.distance(iter2, iter), iter); } } }
[ "private", "void", "linearScanBatchKNN", "(", "ArrayDBIDs", "ids", ",", "List", "<", "KNNHeap", ">", "heaps", ")", "{", "final", "DistanceQuery", "<", "O", ">", "dq", "=", "distanceQuery", ";", "// The distance is computed on database IDs", "for", "(", "DBIDIter",...
Linear batch knn for arbitrary distance functions. @param ids DBIDs to process @param heaps Heaps to store the results in
[ "Linear", "batch", "knn", "for", "arbitrary", "distance", "functions", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-database/src/main/java/de/lmu/ifi/dbs/elki/database/query/knn/LinearScanDistanceKNNQuery.java#L103-L113
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/colorhistogram/RGBHistogramQuadraticDistanceFunction.java
RGBHistogramQuadraticDistanceFunction.computeWeightMatrix
public static double[][] computeWeightMatrix(int bpp) { final int dim = bpp * bpp * bpp; final double[][] m = new double[dim][dim]; // maximum occurring distance in manhattan between bins: final double max = 3. * (bpp - 1.); for(int x = 0; x < dim; x++) { final int rx = (x / bpp) / bpp; final int gx = (x / bpp) % bpp; final int bx = x % bpp; for(int y = x; y < dim; y++) { final int ry = (y / bpp) / bpp; final int gy = (y / bpp) % bpp; final int by = y % bpp; final double dr = Math.abs(rx - ry); final double dg = Math.abs(gx - gy); final double db = Math.abs(bx - by); final double val = 1 - (dr + dg + db) / max; m[x][y] = m[y][x] = val; } } return m; }
java
public static double[][] computeWeightMatrix(int bpp) { final int dim = bpp * bpp * bpp; final double[][] m = new double[dim][dim]; // maximum occurring distance in manhattan between bins: final double max = 3. * (bpp - 1.); for(int x = 0; x < dim; x++) { final int rx = (x / bpp) / bpp; final int gx = (x / bpp) % bpp; final int bx = x % bpp; for(int y = x; y < dim; y++) { final int ry = (y / bpp) / bpp; final int gy = (y / bpp) % bpp; final int by = y % bpp; final double dr = Math.abs(rx - ry); final double dg = Math.abs(gx - gy); final double db = Math.abs(bx - by); final double val = 1 - (dr + dg + db) / max; m[x][y] = m[y][x] = val; } } return m; }
[ "public", "static", "double", "[", "]", "[", "]", "computeWeightMatrix", "(", "int", "bpp", ")", "{", "final", "int", "dim", "=", "bpp", "*", "bpp", "*", "bpp", ";", "final", "double", "[", "]", "[", "]", "m", "=", "new", "double", "[", "dim", "]...
Compute weight matrix for a RGB color histogram @param bpp bins per plane @return Weight matrix
[ "Compute", "weight", "matrix", "for", "a", "RGB", "color", "histogram" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/colorhistogram/RGBHistogramQuadraticDistanceFunction.java#L64-L88
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/HopkinsStatisticClusteringTendency.java
HopkinsStatisticClusteringTendency.initializeDataExtends
protected void initializeDataExtends(Relation<NumberVector> relation, int dim, double[] min, double[] extend) { assert (min.length == dim && extend.length == dim); // if no parameter for min max compute min max values for each dimension // from dataset if(minima == null || maxima == null || minima.length == 0 || maxima.length == 0) { double[][] minmax = RelationUtil.computeMinMax(relation); final double[] dmin = minmax[0], dmax = minmax[1]; for(int d = 0; d < dim; d++) { min[d] = dmin[d]; extend[d] = dmax[d] - dmin[d]; } return; } if(minima.length == dim) { System.arraycopy(minima, 0, min, 0, dim); } else if(minima.length == 1) { Arrays.fill(min, minima[0]); } else { throw new AbortException("Invalid minima specified: expected " + dim + " got minima dimensionality: " + minima.length); } if(maxima.length == dim) { for(int d = 0; d < dim; d++) { extend[d] = maxima[d] - min[d]; } return; } else if(maxima.length == 1) { for(int d = 0; d < dim; d++) { extend[d] = maxima[0] - min[d]; } return; } else { throw new AbortException("Invalid maxima specified: expected " + dim + " got maxima dimensionality: " + maxima.length); } }
java
protected void initializeDataExtends(Relation<NumberVector> relation, int dim, double[] min, double[] extend) { assert (min.length == dim && extend.length == dim); // if no parameter for min max compute min max values for each dimension // from dataset if(minima == null || maxima == null || minima.length == 0 || maxima.length == 0) { double[][] minmax = RelationUtil.computeMinMax(relation); final double[] dmin = minmax[0], dmax = minmax[1]; for(int d = 0; d < dim; d++) { min[d] = dmin[d]; extend[d] = dmax[d] - dmin[d]; } return; } if(minima.length == dim) { System.arraycopy(minima, 0, min, 0, dim); } else if(minima.length == 1) { Arrays.fill(min, minima[0]); } else { throw new AbortException("Invalid minima specified: expected " + dim + " got minima dimensionality: " + minima.length); } if(maxima.length == dim) { for(int d = 0; d < dim; d++) { extend[d] = maxima[d] - min[d]; } return; } else if(maxima.length == 1) { for(int d = 0; d < dim; d++) { extend[d] = maxima[0] - min[d]; } return; } else { throw new AbortException("Invalid maxima specified: expected " + dim + " got maxima dimensionality: " + maxima.length); } }
[ "protected", "void", "initializeDataExtends", "(", "Relation", "<", "NumberVector", ">", "relation", ",", "int", "dim", ",", "double", "[", "]", "min", ",", "double", "[", "]", "extend", ")", "{", "assert", "(", "min", ".", "length", "==", "dim", "&&", ...
Initialize the uniform sampling area. @param relation Data relation @param dim Dimensionality @param min Minima output array (preallocated!) @param extend Data extend output array (preallocated!)
[ "Initialize", "the", "uniform", "sampling", "area", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/HopkinsStatisticClusteringTendency.java#L248-L285
train
elki-project/elki
elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/SharedNearestNeighborSimilarityFunction.java
SharedNearestNeighborSimilarityFunction.countSharedNeighbors
static protected int countSharedNeighbors(DBIDs neighbors1, DBIDs neighbors2) { int intersection = 0; DBIDIter iter1 = neighbors1.iter(); DBIDIter iter2 = neighbors2.iter(); while(iter1.valid() && iter2.valid()) { final int comp = DBIDUtil.compare(iter1, iter2); if(comp == 0) { intersection++; iter1.advance(); iter2.advance(); } else if(comp < 0) { iter1.advance(); } else // iter2 < iter1 { iter2.advance(); } } return intersection; }
java
static protected int countSharedNeighbors(DBIDs neighbors1, DBIDs neighbors2) { int intersection = 0; DBIDIter iter1 = neighbors1.iter(); DBIDIter iter2 = neighbors2.iter(); while(iter1.valid() && iter2.valid()) { final int comp = DBIDUtil.compare(iter1, iter2); if(comp == 0) { intersection++; iter1.advance(); iter2.advance(); } else if(comp < 0) { iter1.advance(); } else // iter2 < iter1 { iter2.advance(); } } return intersection; }
[ "static", "protected", "int", "countSharedNeighbors", "(", "DBIDs", "neighbors1", ",", "DBIDs", "neighbors2", ")", "{", "int", "intersection", "=", "0", ";", "DBIDIter", "iter1", "=", "neighbors1", ".", "iter", "(", ")", ";", "DBIDIter", "iter2", "=", "neigh...
Compute the intersection size @param neighbors1 SORTED neighbors of first @param neighbors2 SORTED neighbors of second @return Intersection size
[ "Compute", "the", "intersection", "size" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/SharedNearestNeighborSimilarityFunction.java#L61-L81
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/index/idistance/InMemoryIDistanceIndex.java
InMemoryIDistanceIndex.rankReferencePoints
protected static <O> DoubleIntPair[] rankReferencePoints(DistanceQuery<O> distanceQuery, O obj, ArrayDBIDs referencepoints) { DoubleIntPair[] priority = new DoubleIntPair[referencepoints.size()]; // Compute distances to reference points. for(DBIDArrayIter iter = referencepoints.iter(); iter.valid(); iter.advance()) { final int i = iter.getOffset(); final double dist = distanceQuery.distance(obj, iter); priority[i] = new DoubleIntPair(dist, i); } Arrays.sort(priority); return priority; }
java
protected static <O> DoubleIntPair[] rankReferencePoints(DistanceQuery<O> distanceQuery, O obj, ArrayDBIDs referencepoints) { DoubleIntPair[] priority = new DoubleIntPair[referencepoints.size()]; // Compute distances to reference points. for(DBIDArrayIter iter = referencepoints.iter(); iter.valid(); iter.advance()) { final int i = iter.getOffset(); final double dist = distanceQuery.distance(obj, iter); priority[i] = new DoubleIntPair(dist, i); } Arrays.sort(priority); return priority; }
[ "protected", "static", "<", "O", ">", "DoubleIntPair", "[", "]", "rankReferencePoints", "(", "DistanceQuery", "<", "O", ">", "distanceQuery", ",", "O", "obj", ",", "ArrayDBIDs", "referencepoints", ")", "{", "DoubleIntPair", "[", "]", "priority", "=", "new", ...
Sort the reference points by distance to the query object @param distanceQuery Distance query @param obj Query object @param referencepoints Iterator for reference points @return Sorted array.
[ "Sort", "the", "reference", "points", "by", "distance", "to", "the", "query", "object" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/index/idistance/InMemoryIDistanceIndex.java#L258-L268
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/index/idistance/InMemoryIDistanceIndex.java
InMemoryIDistanceIndex.binarySearch
protected static void binarySearch(ModifiableDoubleDBIDList index, DoubleDBIDListIter iter, double val) { // Binary search. TODO: move this into the DoubleDBIDList class. int left = 0, right = index.size(); while(left < right) { final int mid = (left + right) >>> 1; final double curd = iter.seek(mid).doubleValue(); if(val < curd) { right = mid; } else if(val > curd) { left = mid + 1; } else { left = mid; break; } } if(left >= index.size()) { --left; } iter.seek(left); }
java
protected static void binarySearch(ModifiableDoubleDBIDList index, DoubleDBIDListIter iter, double val) { // Binary search. TODO: move this into the DoubleDBIDList class. int left = 0, right = index.size(); while(left < right) { final int mid = (left + right) >>> 1; final double curd = iter.seek(mid).doubleValue(); if(val < curd) { right = mid; } else if(val > curd) { left = mid + 1; } else { left = mid; break; } } if(left >= index.size()) { --left; } iter.seek(left); }
[ "protected", "static", "void", "binarySearch", "(", "ModifiableDoubleDBIDList", "index", ",", "DoubleDBIDListIter", "iter", ",", "double", "val", ")", "{", "// Binary search. TODO: move this into the DoubleDBIDList class.", "int", "left", "=", "0", ",", "right", "=", "i...
Seek an iterator to the desired position, using binary search. @param index Index to search @param iter Iterator @param val Distance to search to
[ "Seek", "an", "iterator", "to", "the", "desired", "position", "using", "binary", "search", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/index/idistance/InMemoryIDistanceIndex.java#L277-L298
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/workflow/AlgorithmStep.java
AlgorithmStep.runAlgorithms
public Result runAlgorithms(Database database) { ResultHierarchy hier = database.getHierarchy(); if(LOG.isStatistics()) { boolean first = true; for(It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) { if(first) { LOG.statistics("Index statistics before running algorithms:"); first = false; } it.get().logStatistics(); } } stepresult = new BasicResult("Algorithm Step", "algorithm-step"); for(Algorithm algorithm : algorithms) { Thread.currentThread().setName(algorithm.toString()); Duration duration = LOG.isStatistics() ? LOG.newDuration(algorithm.getClass().getName() + ".runtime").begin() : null; Result res = algorithm.run(database); if(duration != null) { LOG.statistics(duration.end()); } if(LOG.isStatistics()) { boolean first = true; for(It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) { if(first) { LOG.statistics("Index statistics after running algorithm " + algorithm.toString() + ":"); first = false; } it.get().logStatistics(); } } if(res != null) { // Make sure the result is attached, but usually this is a noop: hier.add(database, res); } } return stepresult; }
java
public Result runAlgorithms(Database database) { ResultHierarchy hier = database.getHierarchy(); if(LOG.isStatistics()) { boolean first = true; for(It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) { if(first) { LOG.statistics("Index statistics before running algorithms:"); first = false; } it.get().logStatistics(); } } stepresult = new BasicResult("Algorithm Step", "algorithm-step"); for(Algorithm algorithm : algorithms) { Thread.currentThread().setName(algorithm.toString()); Duration duration = LOG.isStatistics() ? LOG.newDuration(algorithm.getClass().getName() + ".runtime").begin() : null; Result res = algorithm.run(database); if(duration != null) { LOG.statistics(duration.end()); } if(LOG.isStatistics()) { boolean first = true; for(It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) { if(first) { LOG.statistics("Index statistics after running algorithm " + algorithm.toString() + ":"); first = false; } it.get().logStatistics(); } } if(res != null) { // Make sure the result is attached, but usually this is a noop: hier.add(database, res); } } return stepresult; }
[ "public", "Result", "runAlgorithms", "(", "Database", "database", ")", "{", "ResultHierarchy", "hier", "=", "database", ".", "getHierarchy", "(", ")", ";", "if", "(", "LOG", ".", "isStatistics", "(", ")", ")", "{", "boolean", "first", "=", "true", ";", "...
Run algorithms. @param database Database @return Algorithm result
[ "Run", "algorithms", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/workflow/AlgorithmStep.java#L84-L120
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/DistanceQuantileSampler.java
DistanceQuantileSampler.run
public CollectionResult<double[]> run(Database database, Relation<O> rel) { DistanceQuery<O> dq = rel.getDistanceQuery(getDistanceFunction()); int size = rel.size(); long pairs = (size * (long) size) >> 1; final long ssize = sampling <= 1 ? (long) Math.ceil(sampling * pairs) : (long) sampling; if(ssize > Integer.MAX_VALUE) { throw new AbortException("Sampling size too large."); } final int qsize = quantile <= 0 ? 1 : (int) Math.ceil(quantile * ssize); DoubleMaxHeap heap = new DoubleMaxHeap(qsize); ArrayDBIDs ids = DBIDUtil.ensureArray(rel.getDBIDs()); DBIDArrayIter i1 = ids.iter(), i2 = ids.iter(); Random r = rand.getSingleThreadedRandom(); FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Sampling", (int) ssize, LOG) : null; for(long i = 0; i < ssize; i++) { int x = r.nextInt(size - 1) + 1, y = r.nextInt(x); double dist = dq.distance(i1.seek(x), i2.seek(y)); // Skip NaN, and/or zeros. if(dist != dist || (nozeros && dist < Double.MIN_NORMAL)) { continue; } heap.add(dist, qsize); LOG.incrementProcessed(prog); } LOG.statistics(new DoubleStatistic(PREFIX + ".quantile", quantile)); LOG.statistics(new LongStatistic(PREFIX + ".samplesize", ssize)); LOG.statistics(new DoubleStatistic(PREFIX + ".distance", heap.peek())); LOG.ensureCompleted(prog); Collection<String> header = Arrays.asList(new String[] { "Distance" }); Collection<double[]> data = Arrays.asList(new double[][] { new double[] { heap.peek() } }); return new CollectionResult<double[]>("Distances sample", "distance-sample", data, header); }
java
public CollectionResult<double[]> run(Database database, Relation<O> rel) { DistanceQuery<O> dq = rel.getDistanceQuery(getDistanceFunction()); int size = rel.size(); long pairs = (size * (long) size) >> 1; final long ssize = sampling <= 1 ? (long) Math.ceil(sampling * pairs) : (long) sampling; if(ssize > Integer.MAX_VALUE) { throw new AbortException("Sampling size too large."); } final int qsize = quantile <= 0 ? 1 : (int) Math.ceil(quantile * ssize); DoubleMaxHeap heap = new DoubleMaxHeap(qsize); ArrayDBIDs ids = DBIDUtil.ensureArray(rel.getDBIDs()); DBIDArrayIter i1 = ids.iter(), i2 = ids.iter(); Random r = rand.getSingleThreadedRandom(); FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Sampling", (int) ssize, LOG) : null; for(long i = 0; i < ssize; i++) { int x = r.nextInt(size - 1) + 1, y = r.nextInt(x); double dist = dq.distance(i1.seek(x), i2.seek(y)); // Skip NaN, and/or zeros. if(dist != dist || (nozeros && dist < Double.MIN_NORMAL)) { continue; } heap.add(dist, qsize); LOG.incrementProcessed(prog); } LOG.statistics(new DoubleStatistic(PREFIX + ".quantile", quantile)); LOG.statistics(new LongStatistic(PREFIX + ".samplesize", ssize)); LOG.statistics(new DoubleStatistic(PREFIX + ".distance", heap.peek())); LOG.ensureCompleted(prog); Collection<String> header = Arrays.asList(new String[] { "Distance" }); Collection<double[]> data = Arrays.asList(new double[][] { new double[] { heap.peek() } }); return new CollectionResult<double[]>("Distances sample", "distance-sample", data, header); }
[ "public", "CollectionResult", "<", "double", "[", "]", ">", "run", "(", "Database", "database", ",", "Relation", "<", "O", ">", "rel", ")", "{", "DistanceQuery", "<", "O", ">", "dq", "=", "rel", ".", "getDistanceQuery", "(", "getDistanceFunction", "(", "...
Run the distance quantile sampler. @param database @param rel @return Distances sample
[ "Run", "the", "distance", "quantile", "sampler", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/statistics/DistanceQuantileSampler.java#L119-L155
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/parser/NumberVectorLabelParser.java
NumberVectorLabelParser.parseLineInternal
protected boolean parseLineInternal() { // Split into numerical attributes and labels int i = 0; for(/* initialized by nextLineExceptComents()! */; tokenizer.valid(); tokenizer.advance(), i++) { if(!isLabelColumn(i) && !tokenizer.isQuoted()) { try { attributes.add(tokenizer.getDouble()); continue; } catch(NumberFormatException e) { if(!warnedPrecision && (e == ParseUtil.PRECISION_OVERFLOW || e == ParseUtil.EXPONENT_OVERFLOW)) { getLogger().warning("Too many digits in what looked like a double number - treating as string: " + tokenizer.getSubstring()); warnedPrecision = true; } // Ignore attempt, add to labels below. } } // Else: labels. String lbl = tokenizer.getStrippedSubstring(); if(lbl.length() > 0) { haslabels = true; lbl = unique.addOrGet(lbl); labels.add(lbl); } } // Maybe a label row? if(curvec == null && attributes.size == 0) { columnnames = new ArrayList<>(labels); haslabels = false; curvec = null; curlbl = null; labels.clear(); return false; } // Pass outside via class variables curvec = createVector(); curlbl = LabelList.make(labels); attributes.clear(); labels.clear(); return true; }
java
protected boolean parseLineInternal() { // Split into numerical attributes and labels int i = 0; for(/* initialized by nextLineExceptComents()! */; tokenizer.valid(); tokenizer.advance(), i++) { if(!isLabelColumn(i) && !tokenizer.isQuoted()) { try { attributes.add(tokenizer.getDouble()); continue; } catch(NumberFormatException e) { if(!warnedPrecision && (e == ParseUtil.PRECISION_OVERFLOW || e == ParseUtil.EXPONENT_OVERFLOW)) { getLogger().warning("Too many digits in what looked like a double number - treating as string: " + tokenizer.getSubstring()); warnedPrecision = true; } // Ignore attempt, add to labels below. } } // Else: labels. String lbl = tokenizer.getStrippedSubstring(); if(lbl.length() > 0) { haslabels = true; lbl = unique.addOrGet(lbl); labels.add(lbl); } } // Maybe a label row? if(curvec == null && attributes.size == 0) { columnnames = new ArrayList<>(labels); haslabels = false; curvec = null; curlbl = null; labels.clear(); return false; } // Pass outside via class variables curvec = createVector(); curlbl = LabelList.make(labels); attributes.clear(); labels.clear(); return true; }
[ "protected", "boolean", "parseLineInternal", "(", ")", "{", "// Split into numerical attributes and labels", "int", "i", "=", "0", ";", "for", "(", "/* initialized by nextLineExceptComents()! */", ";", "tokenizer", ".", "valid", "(", ")", ";", "tokenizer", ".", "advan...
Internal method for parsing a single line. Used by both line based parsing as well as block parsing. This saves the building of meta data for each line. @return {@code true} when a valid line was read, {@code false} on a label row.
[ "Internal", "method", "for", "parsing", "a", "single", "line", ".", "Used", "by", "both", "line", "based", "parsing", "as", "well", "as", "block", "parsing", ".", "This", "saves", "the", "building", "of", "meta", "data", "for", "each", "line", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/parser/NumberVectorLabelParser.java#L276-L316
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/parser/NumberVectorLabelParser.java
NumberVectorLabelParser.getTypeInformation
SimpleTypeInformation<V> getTypeInformation(int mindim, int maxdim) { if(mindim > maxdim) { throw new AbortException("No vectors were read from the input file - cannot determine vector data type."); } if(mindim == maxdim) { String[] colnames = null; if(columnnames != null && mindim <= columnnames.size()) { colnames = new String[mindim]; int j = 0; for(int i = 0; i < mindim; i++) { if(isLabelColumn(i)) { continue; } colnames[j] = columnnames.get(i); j++; } if(j != mindim) { colnames = null; // Did not work } } return new VectorFieldTypeInformation<>(factory, mindim, colnames); } // Variable dimensionality - return non-vector field type return new VectorTypeInformation<>(factory, factory.getDefaultSerializer(), mindim, maxdim); }
java
SimpleTypeInformation<V> getTypeInformation(int mindim, int maxdim) { if(mindim > maxdim) { throw new AbortException("No vectors were read from the input file - cannot determine vector data type."); } if(mindim == maxdim) { String[] colnames = null; if(columnnames != null && mindim <= columnnames.size()) { colnames = new String[mindim]; int j = 0; for(int i = 0; i < mindim; i++) { if(isLabelColumn(i)) { continue; } colnames[j] = columnnames.get(i); j++; } if(j != mindim) { colnames = null; // Did not work } } return new VectorFieldTypeInformation<>(factory, mindim, colnames); } // Variable dimensionality - return non-vector field type return new VectorTypeInformation<>(factory, factory.getDefaultSerializer(), mindim, maxdim); }
[ "SimpleTypeInformation", "<", "V", ">", "getTypeInformation", "(", "int", "mindim", ",", "int", "maxdim", ")", "{", "if", "(", "mindim", ">", "maxdim", ")", "{", "throw", "new", "AbortException", "(", "\"No vectors were read from the input file - cannot determine vect...
Get a prototype object for the given dimensionality. @param mindim Minimum dimensionality @param maxdim Maximum dimensionality @return Prototype object
[ "Get", "a", "prototype", "object", "for", "the", "given", "dimensionality", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/parser/NumberVectorLabelParser.java#L334-L358
train
elki-project/elki
elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/MaterializeKNNAndRKNNPreprocessor.java
MaterializeKNNAndRKNNPreprocessor.materializeKNNAndRKNNs
private void materializeKNNAndRKNNs(ArrayDBIDs ids, FiniteProgress progress) { // add an empty list to each rknn for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { if(materialized_RkNN.get(iter) == null) { materialized_RkNN.put(iter, new TreeSet<DoubleDBIDPair>()); } } // knn query List<? extends KNNList> kNNList = knnQuery.getKNNForBulkDBIDs(ids, k); for(DBIDArrayIter id = ids.iter(); id.valid(); id.advance()) { KNNList kNNs = kNNList.get(id.getOffset()); storage.put(id, kNNs); for(DoubleDBIDListIter iter = kNNs.iter(); iter.valid(); iter.advance()) { materialized_RkNN.get(iter).add(DBIDUtil.newPair(iter.doubleValue(), id)); } LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); }
java
private void materializeKNNAndRKNNs(ArrayDBIDs ids, FiniteProgress progress) { // add an empty list to each rknn for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { if(materialized_RkNN.get(iter) == null) { materialized_RkNN.put(iter, new TreeSet<DoubleDBIDPair>()); } } // knn query List<? extends KNNList> kNNList = knnQuery.getKNNForBulkDBIDs(ids, k); for(DBIDArrayIter id = ids.iter(); id.valid(); id.advance()) { KNNList kNNs = kNNList.get(id.getOffset()); storage.put(id, kNNs); for(DoubleDBIDListIter iter = kNNs.iter(); iter.valid(); iter.advance()) { materialized_RkNN.get(iter).add(DBIDUtil.newPair(iter.doubleValue(), id)); } LOG.incrementProcessed(progress); } LOG.ensureCompleted(progress); }
[ "private", "void", "materializeKNNAndRKNNs", "(", "ArrayDBIDs", "ids", ",", "FiniteProgress", "progress", ")", "{", "// add an empty list to each rknn", "for", "(", "DBIDIter", "iter", "=", "ids", ".", "iter", "(", ")", ";", "iter", ".", "valid", "(", ")", ";"...
Materializes the kNNs and RkNNs of the specified object IDs. @param ids the IDs of the objects
[ "Materializes", "the", "kNNs", "and", "RkNNs", "of", "the", "specified", "object", "IDs", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/MaterializeKNNAndRKNNPreprocessor.java#L95-L115
train
elki-project/elki
elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/MaterializeKNNAndRKNNPreprocessor.java
MaterializeKNNAndRKNNPreprocessor.getRKNN
public DoubleDBIDList getRKNN(DBIDRef id) { TreeSet<DoubleDBIDPair> rKNN = materialized_RkNN.get(id); if(rKNN == null) { return null; } ModifiableDoubleDBIDList ret = DBIDUtil.newDistanceDBIDList(rKNN.size()); for(DoubleDBIDPair pair : rKNN) { ret.add(pair); } ret.sort(); return ret; }
java
public DoubleDBIDList getRKNN(DBIDRef id) { TreeSet<DoubleDBIDPair> rKNN = materialized_RkNN.get(id); if(rKNN == null) { return null; } ModifiableDoubleDBIDList ret = DBIDUtil.newDistanceDBIDList(rKNN.size()); for(DoubleDBIDPair pair : rKNN) { ret.add(pair); } ret.sort(); return ret; }
[ "public", "DoubleDBIDList", "getRKNN", "(", "DBIDRef", "id", ")", "{", "TreeSet", "<", "DoubleDBIDPair", ">", "rKNN", "=", "materialized_RkNN", ".", "get", "(", "id", ")", ";", "if", "(", "rKNN", "==", "null", ")", "{", "return", "null", ";", "}", "Mod...
Returns the materialized RkNNs of the specified id. @param id the query id @return the RkNNs
[ "Returns", "the", "materialized", "RkNNs", "of", "the", "specified", "id", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-preprocessed/src/main/java/de/lmu/ifi/dbs/elki/index/preprocessed/knn/MaterializeKNNAndRKNNPreprocessor.java#L335-L346
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java
CFTree.insert
public void insert(NumberVector nv) { final int dim = nv.getDimensionality(); // No root created yet: if(root == null) { ClusteringFeature leaf = new ClusteringFeature(dim); leaf.addToStatistics(nv); root = new TreeNode(dim, capacity); root.children[0] = leaf; root.addToStatistics(nv); ++leaves; return; } TreeNode other = insert(root, nv); // Handle root overflow: if(other != null) { TreeNode newnode = new TreeNode(dim, capacity); newnode.addToStatistics(newnode.children[0] = root); newnode.addToStatistics(newnode.children[1] = other); root = newnode; } }
java
public void insert(NumberVector nv) { final int dim = nv.getDimensionality(); // No root created yet: if(root == null) { ClusteringFeature leaf = new ClusteringFeature(dim); leaf.addToStatistics(nv); root = new TreeNode(dim, capacity); root.children[0] = leaf; root.addToStatistics(nv); ++leaves; return; } TreeNode other = insert(root, nv); // Handle root overflow: if(other != null) { TreeNode newnode = new TreeNode(dim, capacity); newnode.addToStatistics(newnode.children[0] = root); newnode.addToStatistics(newnode.children[1] = other); root = newnode; } }
[ "public", "void", "insert", "(", "NumberVector", "nv", ")", "{", "final", "int", "dim", "=", "nv", ".", "getDimensionality", "(", ")", ";", "// No root created yet:", "if", "(", "root", "==", "null", ")", "{", "ClusteringFeature", "leaf", "=", "new", "Clus...
Insert a data point into the tree. @param nv Object data
[ "Insert", "a", "data", "point", "into", "the", "tree", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java#L143-L163
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java
CFTree.rebuildTree
protected void rebuildTree() { final int dim = root.getDimensionality(); double t = estimateThreshold(root) / leaves; t *= t; // Never decrease the threshold. thresholdsq = t > thresholdsq ? t : thresholdsq; LOG.debug("New squared threshold: " + thresholdsq); LeafIterator iter = new LeafIterator(root); // Will keep the old root. assert (iter.valid()); ClusteringFeature first = iter.get(); leaves = 0; // Make a new root node: root = new TreeNode(dim, capacity); root.children[0] = first; root.addToStatistics(first); ++leaves; for(iter.advance(); iter.valid(); iter.advance()) { TreeNode other = insert(root, iter.get()); // Handle root overflow: if(other != null) { TreeNode newnode = new TreeNode(dim, capacity); newnode.addToStatistics(newnode.children[0] = root); newnode.addToStatistics(newnode.children[1] = other); root = newnode; } } }
java
protected void rebuildTree() { final int dim = root.getDimensionality(); double t = estimateThreshold(root) / leaves; t *= t; // Never decrease the threshold. thresholdsq = t > thresholdsq ? t : thresholdsq; LOG.debug("New squared threshold: " + thresholdsq); LeafIterator iter = new LeafIterator(root); // Will keep the old root. assert (iter.valid()); ClusteringFeature first = iter.get(); leaves = 0; // Make a new root node: root = new TreeNode(dim, capacity); root.children[0] = first; root.addToStatistics(first); ++leaves; for(iter.advance(); iter.valid(); iter.advance()) { TreeNode other = insert(root, iter.get()); // Handle root overflow: if(other != null) { TreeNode newnode = new TreeNode(dim, capacity); newnode.addToStatistics(newnode.children[0] = root); newnode.addToStatistics(newnode.children[1] = other); root = newnode; } } }
[ "protected", "void", "rebuildTree", "(", ")", "{", "final", "int", "dim", "=", "root", ".", "getDimensionality", "(", ")", ";", "double", "t", "=", "estimateThreshold", "(", "root", ")", "/", "leaves", ";", "t", "*=", "t", ";", "// Never decrease the thres...
Rebuild the CFTree to condense it to approximately half the size.
[ "Rebuild", "the", "CFTree", "to", "condense", "it", "to", "approximately", "half", "the", "size", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java#L168-L196
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java
CFTree.insert
private TreeNode insert(TreeNode node, NumberVector nv) { // Find closest child: ClusteringFeature[] cfs = node.children; assert (cfs[0] != null) : "Unexpected empty node!"; // Find the best child: ClusteringFeature best = cfs[0]; double bestd = distance.squaredDistance(nv, best); for(int i = 1; i < cfs.length; i++) { ClusteringFeature cf = cfs[i]; if(cf == null) { break; } double d2 = distance.squaredDistance(nv, cf); if(d2 < bestd) { best = cf; bestd = d2; } } // Leaf node: if(!(best instanceof TreeNode)) { // Threshold constraint satisfied? if(absorption.squaredCriterion(best, nv) <= thresholdsq) { best.addToStatistics(nv); node.addToStatistics(nv); return null; } best = new ClusteringFeature(nv.getDimensionality()); best.addToStatistics(nv); ++leaves; if(add(node.children, best)) { node.addToStatistics(nv); // Update statistics return null; } return split(node, best); } assert (best instanceof TreeNode) : "Node is neither child nor inner?"; TreeNode newchild = insert((TreeNode) best, nv); if(newchild == null || add(node.children, newchild)) { node.addToStatistics(nv); // Update statistics return null; } return split(node, newchild); }
java
private TreeNode insert(TreeNode node, NumberVector nv) { // Find closest child: ClusteringFeature[] cfs = node.children; assert (cfs[0] != null) : "Unexpected empty node!"; // Find the best child: ClusteringFeature best = cfs[0]; double bestd = distance.squaredDistance(nv, best); for(int i = 1; i < cfs.length; i++) { ClusteringFeature cf = cfs[i]; if(cf == null) { break; } double d2 = distance.squaredDistance(nv, cf); if(d2 < bestd) { best = cf; bestd = d2; } } // Leaf node: if(!(best instanceof TreeNode)) { // Threshold constraint satisfied? if(absorption.squaredCriterion(best, nv) <= thresholdsq) { best.addToStatistics(nv); node.addToStatistics(nv); return null; } best = new ClusteringFeature(nv.getDimensionality()); best.addToStatistics(nv); ++leaves; if(add(node.children, best)) { node.addToStatistics(nv); // Update statistics return null; } return split(node, best); } assert (best instanceof TreeNode) : "Node is neither child nor inner?"; TreeNode newchild = insert((TreeNode) best, nv); if(newchild == null || add(node.children, newchild)) { node.addToStatistics(nv); // Update statistics return null; } return split(node, newchild); }
[ "private", "TreeNode", "insert", "(", "TreeNode", "node", ",", "NumberVector", "nv", ")", "{", "// Find closest child:", "ClusteringFeature", "[", "]", "cfs", "=", "node", ".", "children", ";", "assert", "(", "cfs", "[", "0", "]", "!=", "null", ")", ":", ...
Recursive insertion. @param node Current node @param nv Object data @return New sibling, if the node was split.
[ "Recursive", "insertion", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java#L253-L297
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java
CFTree.add
private boolean add(ClusteringFeature[] children, ClusteringFeature child) { for(int i = 0; i < children.length; i++) { if(children[i] == null) { children[i] = child; return true; } } return false; }
java
private boolean add(ClusteringFeature[] children, ClusteringFeature child) { for(int i = 0; i < children.length; i++) { if(children[i] == null) { children[i] = child; return true; } } return false; }
[ "private", "boolean", "add", "(", "ClusteringFeature", "[", "]", "children", ",", "ClusteringFeature", "child", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "children", ".", "length", ";", "i", "++", ")", "{", "if", "(", "children", "["...
Add a node to the first unused slot. @param children Children list @param child Child to add @return {@code false} if node is full
[ "Add", "a", "node", "to", "the", "first", "unused", "slot", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java#L472-L480
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java
CFTree.printDebug
protected StringBuilder printDebug(StringBuilder buf, ClusteringFeature n, int d) { FormatUtil.appendSpace(buf, d).append(n.n); for(int i = 0; i < n.getDimensionality(); i++) { buf.append(' ').append(n.centroid(i)); } buf.append(" - ").append(n.n).append('\n'); if(n instanceof TreeNode) { ClusteringFeature[] children = ((TreeNode) n).children; for(int i = 0; i < children.length; i++) { ClusteringFeature c = children[i]; if(c != null) { printDebug(buf, c, d + 1); } } } return buf; }
java
protected StringBuilder printDebug(StringBuilder buf, ClusteringFeature n, int d) { FormatUtil.appendSpace(buf, d).append(n.n); for(int i = 0; i < n.getDimensionality(); i++) { buf.append(' ').append(n.centroid(i)); } buf.append(" - ").append(n.n).append('\n'); if(n instanceof TreeNode) { ClusteringFeature[] children = ((TreeNode) n).children; for(int i = 0; i < children.length; i++) { ClusteringFeature c = children[i]; if(c != null) { printDebug(buf, c, d + 1); } } } return buf; }
[ "protected", "StringBuilder", "printDebug", "(", "StringBuilder", "buf", ",", "ClusteringFeature", "n", ",", "int", "d", ")", "{", "FormatUtil", ".", "appendSpace", "(", "buf", ",", "d", ")", ".", "append", "(", "n", ".", "n", ")", ";", "for", "(", "in...
Utility function for debugging. @param buf Output buffer @param n Current node @param d Depth @return Output buffer
[ "Utility", "function", "for", "debugging", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/birch/CFTree.java#L577-L593
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/StudentsTDistribution.java
StudentsTDistribution.cdf
public static double cdf(double val, int v) { double x = v / (val * val + v); return 1 - (0.5 * BetaDistribution.regularizedIncBeta(x, v * .5, 0.5)); }
java
public static double cdf(double val, int v) { double x = v / (val * val + v); return 1 - (0.5 * BetaDistribution.regularizedIncBeta(x, v * .5, 0.5)); }
[ "public", "static", "double", "cdf", "(", "double", "val", ",", "int", "v", ")", "{", "double", "x", "=", "v", "/", "(", "val", "*", "val", "+", "v", ")", ";", "return", "1", "-", "(", "0.5", "*", "BetaDistribution", ".", "regularizedIncBeta", "(",...
Static version of the CDF of the t-distribution for t &gt; 0 @param val value to evaluate @param v degrees of freedom @return F(val, v)
[ "Static", "version", "of", "the", "CDF", "of", "the", "t", "-", "distribution", "for", "t", "&gt", ";", "0" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/StudentsTDistribution.java#L136-L139
train
elki-project/elki
elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/ChangePoints.java
ChangePoints.add
public void add(DBIDRef iter, int column, double score) { changepoints.add(new ChangePoint(iter, column, score)); }
java
public void add(DBIDRef iter, int column, double score) { changepoints.add(new ChangePoint(iter, column, score)); }
[ "public", "void", "add", "(", "DBIDRef", "iter", ",", "int", "column", ",", "double", "score", ")", "{", "changepoints", ".", "add", "(", "new", "ChangePoint", "(", "iter", ",", "column", ",", "score", ")", ")", ";", "}" ]
Add a change point to the result. @param iter Time reference @param column Column @param score Score
[ "Add", "a", "change", "point", "to", "the", "result", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-timeseries/src/main/java/de/lmu/ifi/dbs/elki/algorithm/timeseries/ChangePoints.java#L75-L77
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/PolygonsObject.java
PolygonsObject.appendToBuffer
public void appendToBuffer(StringBuilder buf) { Iterator<Polygon> iter = polygons.iterator(); while(iter.hasNext()) { Polygon poly = iter.next(); poly.appendToBuffer(buf); if(iter.hasNext()) { buf.append(" -- "); } } }
java
public void appendToBuffer(StringBuilder buf) { Iterator<Polygon> iter = polygons.iterator(); while(iter.hasNext()) { Polygon poly = iter.next(); poly.appendToBuffer(buf); if(iter.hasNext()) { buf.append(" -- "); } } }
[ "public", "void", "appendToBuffer", "(", "StringBuilder", "buf", ")", "{", "Iterator", "<", "Polygon", ">", "iter", "=", "polygons", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "Polygon", "poly", "=", "iter...
Append polygons to the buffer. @param buf Buffer to append to
[ "Append", "polygons", "to", "the", "buffer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/spatial/PolygonsObject.java#L80-L89
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/Tokenizer.java
Tokenizer.initialize
public void initialize(CharSequence input, int begin, int end) { this.input = input; this.send = end; this.matcher.reset(input).region(begin, end); this.index = begin; advance(); }
java
public void initialize(CharSequence input, int begin, int end) { this.input = input; this.send = end; this.matcher.reset(input).region(begin, end); this.index = begin; advance(); }
[ "public", "void", "initialize", "(", "CharSequence", "input", ",", "int", "begin", ",", "int", "end", ")", "{", "this", ".", "input", "=", "input", ";", "this", ".", "send", "=", "end", ";", "this", ".", "matcher", ".", "reset", "(", "input", ")", ...
Initialize parser with a new string. @param input New string to parse. @param begin Begin @param end End
[ "Initialize", "parser", "with", "a", "new", "string", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/Tokenizer.java#L96-L102
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/Tokenizer.java
Tokenizer.getStrippedSubstring
public String getStrippedSubstring() { // TODO: detect Java <6 and make sure we only return the substring? // With java 7, String.substring will arraycopy the characters. int sstart = start, send = end; while(sstart < send) { char c = input.charAt(sstart); if(c != ' ' || c != '\n' || c != '\r' || c != '\t') { break; } ++sstart; } while(--send >= sstart) { char c = input.charAt(send); if(c != ' ' || c != '\n' || c != '\r' || c != '\t') { break; } } ++send; return (sstart < send) ? input.subSequence(sstart, send).toString() : ""; }
java
public String getStrippedSubstring() { // TODO: detect Java <6 and make sure we only return the substring? // With java 7, String.substring will arraycopy the characters. int sstart = start, send = end; while(sstart < send) { char c = input.charAt(sstart); if(c != ' ' || c != '\n' || c != '\r' || c != '\t') { break; } ++sstart; } while(--send >= sstart) { char c = input.charAt(send); if(c != ' ' || c != '\n' || c != '\r' || c != '\t') { break; } } ++send; return (sstart < send) ? input.subSequence(sstart, send).toString() : ""; }
[ "public", "String", "getStrippedSubstring", "(", ")", "{", "// TODO: detect Java <6 and make sure we only return the substring?", "// With java 7, String.substring will arraycopy the characters.", "int", "sstart", "=", "start", ",", "send", "=", "end", ";", "while", "(", "sstar...
Get the current part as substring @return Current value as substring.
[ "Get", "the", "current", "part", "as", "substring" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/Tokenizer.java#L168-L187
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/Tokenizer.java
Tokenizer.isQuote
private char isQuote(int index) { if(index >= input.length()) { return 0; } char c = input.charAt(index); for(int i = 0; i < quoteChars.length; i++) { if(c == quoteChars[i]) { return c; } } return 0; }
java
private char isQuote(int index) { if(index >= input.length()) { return 0; } char c = input.charAt(index); for(int i = 0; i < quoteChars.length; i++) { if(c == quoteChars[i]) { return c; } } return 0; }
[ "private", "char", "isQuote", "(", "int", "index", ")", "{", "if", "(", "index", ">=", "input", ".", "length", "(", ")", ")", "{", "return", "0", ";", "}", "char", "c", "=", "input", ".", "charAt", "(", "index", ")", ";", "for", "(", "int", "i"...
Detect quote characters. TODO: support more than one quote character, make sure opening and closing quotes match then. @param index Position @return {@code 1} when a quote character, {@code 0} otherwise.
[ "Detect", "quote", "characters", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/Tokenizer.java#L237-L248
train
elki-project/elki
elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/datastore/DataStoreUtil.java
DataStoreUtil.makeRecordStorage
public static WritableRecordStore makeRecordStorage(DBIDs ids, int hints, Class<?>... dataclasses) { return DataStoreFactory.FACTORY.makeRecordStorage(ids, hints, dataclasses); }
java
public static WritableRecordStore makeRecordStorage(DBIDs ids, int hints, Class<?>... dataclasses) { return DataStoreFactory.FACTORY.makeRecordStorage(ids, hints, dataclasses); }
[ "public", "static", "WritableRecordStore", "makeRecordStorage", "(", "DBIDs", "ids", ",", "int", "hints", ",", "Class", "<", "?", ">", "...", "dataclasses", ")", "{", "return", "DataStoreFactory", ".", "FACTORY", ".", "makeRecordStorage", "(", "ids", ",", "hin...
Make a new record storage, to associate the given ids with an object of class dataclass. @param ids DBIDs to store data for @param hints Hints for the storage manager @param dataclasses classes to store @return new record store
[ "Make", "a", "new", "record", "storage", "to", "associate", "the", "given", "ids", "with", "an", "object", "of", "class", "dataclass", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/datastore/DataStoreUtil.java#L138-L140
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/projection/random/RandomSubsetProjectionFamily.java
RandomSubsetProjectionFamily.randomPermutation
public static int[] randomPermutation(final int[] out, Random random) { for(int i = out.length - 1; i > 0; i--) { // Swap with random preceeding element. int ri = random.nextInt(i + 1); int tmp = out[ri]; out[ri] = out[i]; out[i] = tmp; } return out; }
java
public static int[] randomPermutation(final int[] out, Random random) { for(int i = out.length - 1; i > 0; i--) { // Swap with random preceeding element. int ri = random.nextInt(i + 1); int tmp = out[ri]; out[ri] = out[i]; out[i] = tmp; } return out; }
[ "public", "static", "int", "[", "]", "randomPermutation", "(", "final", "int", "[", "]", "out", ",", "Random", "random", ")", "{", "for", "(", "int", "i", "=", "out", ".", "length", "-", "1", ";", "i", ">", "0", ";", "i", "--", ")", "{", "// Sw...
Perform a random permutation of the array, in-place. Knuth / Fisher-Yates style shuffle TODO: move to shared code. @param out Existing output array @param random Random generator. @return Same array.
[ "Perform", "a", "random", "permutation", "of", "the", "array", "in", "-", "place", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/projection/random/RandomSubsetProjectionFamily.java#L95-L104
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGUpdateSynchronizer.java
JSVGUpdateSynchronizer.makeRunnerIfNeeded
protected void makeRunnerIfNeeded() { // We don't need to make a SVG runner when there are no pending updates. boolean stop = true; for(WeakReference<UpdateRunner> wur : updaterunner) { UpdateRunner ur = wur.get(); if(ur == null) { updaterunner.remove(wur); } else if(!ur.isEmpty()) { stop = false; } } if(stop) { return; } // We only need a new runner when we don't have one in the queue yet! if(pending.get() != null) { return; } // We need a component JSVGComponent component = this.cref.get(); if(component == null) { return; } // Synchronize with all layers: synchronized(this) { synchronized(component) { UpdateManager um = component.getUpdateManager(); if(um != null) { synchronized(um) { if(um.isRunning()) { // Create and insert a runner. Runnable newrunner = new Runnable() { @Override public void run() { if(pending.compareAndSet(this, null)) { // Wake up all runners for(WeakReference<UpdateRunner> wur : updaterunner) { UpdateRunner ur = wur.get(); if(ur == null || ur.isEmpty()) { continue; } ur.runQueue(); } } } }; pending.set(newrunner); um.getUpdateRunnableQueue().invokeLater(newrunner); return; } } } } } }
java
protected void makeRunnerIfNeeded() { // We don't need to make a SVG runner when there are no pending updates. boolean stop = true; for(WeakReference<UpdateRunner> wur : updaterunner) { UpdateRunner ur = wur.get(); if(ur == null) { updaterunner.remove(wur); } else if(!ur.isEmpty()) { stop = false; } } if(stop) { return; } // We only need a new runner when we don't have one in the queue yet! if(pending.get() != null) { return; } // We need a component JSVGComponent component = this.cref.get(); if(component == null) { return; } // Synchronize with all layers: synchronized(this) { synchronized(component) { UpdateManager um = component.getUpdateManager(); if(um != null) { synchronized(um) { if(um.isRunning()) { // Create and insert a runner. Runnable newrunner = new Runnable() { @Override public void run() { if(pending.compareAndSet(this, null)) { // Wake up all runners for(WeakReference<UpdateRunner> wur : updaterunner) { UpdateRunner ur = wur.get(); if(ur == null || ur.isEmpty()) { continue; } ur.runQueue(); } } } }; pending.set(newrunner); um.getUpdateRunnableQueue().invokeLater(newrunner); return; } } } } } }
[ "protected", "void", "makeRunnerIfNeeded", "(", ")", "{", "// We don't need to make a SVG runner when there are no pending updates.", "boolean", "stop", "=", "true", ";", "for", "(", "WeakReference", "<", "UpdateRunner", ">", "wur", ":", "updaterunner", ")", "{", "Updat...
Join the runnable queue of a component.
[ "Join", "the", "runnable", "queue", "of", "a", "component", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/JSVGUpdateSynchronizer.java#L87-L142
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/thumbs/ThumbnailVisualization.java
ThumbnailVisualization.fullRedraw
@Override public void fullRedraw() { if(!(getWidth() > 0 && getHeight() > 0)) { LoggingUtil.warning("Thumbnail of zero size requested: " + visFactory); return; } if(thumbid < 0) { // LoggingUtil.warning("Generating new thumbnail " + this); layer.appendChild(SVGUtil.svgWaitIcon(plot.getDocument(), 0, 0, getWidth(), getHeight())); if(pendingThumbnail == null) { pendingThumbnail = ThumbnailThread.queue(this); } return; } // LoggingUtil.warning("Injecting Thumbnail " + this); Element i = plot.svgElement(SVGConstants.SVG_IMAGE_TAG); SVGUtil.setAtt(i, SVGConstants.SVG_X_ATTRIBUTE, 0); SVGUtil.setAtt(i, SVGConstants.SVG_Y_ATTRIBUTE, 0); SVGUtil.setAtt(i, SVGConstants.SVG_WIDTH_ATTRIBUTE, getWidth()); SVGUtil.setAtt(i, SVGConstants.SVG_HEIGHT_ATTRIBUTE, getHeight()); i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_QNAME, ThumbnailRegistryEntry.INTERNAL_PROTOCOL + ":" + thumbid); layer.appendChild(i); }
java
@Override public void fullRedraw() { if(!(getWidth() > 0 && getHeight() > 0)) { LoggingUtil.warning("Thumbnail of zero size requested: " + visFactory); return; } if(thumbid < 0) { // LoggingUtil.warning("Generating new thumbnail " + this); layer.appendChild(SVGUtil.svgWaitIcon(plot.getDocument(), 0, 0, getWidth(), getHeight())); if(pendingThumbnail == null) { pendingThumbnail = ThumbnailThread.queue(this); } return; } // LoggingUtil.warning("Injecting Thumbnail " + this); Element i = plot.svgElement(SVGConstants.SVG_IMAGE_TAG); SVGUtil.setAtt(i, SVGConstants.SVG_X_ATTRIBUTE, 0); SVGUtil.setAtt(i, SVGConstants.SVG_Y_ATTRIBUTE, 0); SVGUtil.setAtt(i, SVGConstants.SVG_WIDTH_ATTRIBUTE, getWidth()); SVGUtil.setAtt(i, SVGConstants.SVG_HEIGHT_ATTRIBUTE, getHeight()); i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_QNAME, ThumbnailRegistryEntry.INTERNAL_PROTOCOL + ":" + thumbid); layer.appendChild(i); }
[ "@", "Override", "public", "void", "fullRedraw", "(", ")", "{", "if", "(", "!", "(", "getWidth", "(", ")", ">", "0", "&&", "getHeight", "(", ")", ">", "0", ")", ")", "{", "LoggingUtil", ".", "warning", "(", "\"Thumbnail of zero size requested: \"", "+", ...
Perform a full redraw.
[ "Perform", "a", "full", "redraw", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/thumbs/ThumbnailVisualization.java#L137-L159
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/Centroid.java
Centroid.make
public static Centroid make(Relation<? extends NumberVector> relation, DBIDs ids) { final int dim = RelationUtil.dimensionality(relation); Centroid c = new Centroid(dim); double[] elems = c.elements; int count = 0; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { NumberVector v = relation.get(iter); for(int i = 0; i < dim; i++) { elems[i] += v.doubleValue(i); } count += 1; } if(count == 0) { return c; } for(int i = 0; i < dim; i++) { elems[i] /= count; } c.wsum = count; return c; }
java
public static Centroid make(Relation<? extends NumberVector> relation, DBIDs ids) { final int dim = RelationUtil.dimensionality(relation); Centroid c = new Centroid(dim); double[] elems = c.elements; int count = 0; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { NumberVector v = relation.get(iter); for(int i = 0; i < dim; i++) { elems[i] += v.doubleValue(i); } count += 1; } if(count == 0) { return c; } for(int i = 0; i < dim; i++) { elems[i] /= count; } c.wsum = count; return c; }
[ "public", "static", "Centroid", "make", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "relation", ",", "DBIDs", "ids", ")", "{", "final", "int", "dim", "=", "RelationUtil", ".", "dimensionality", "(", "relation", ")", ";", "Centroid", "c", "="...
Static constructor from an existing relation. @param relation Relation to use @param ids IDs to use @return Centroid
[ "Static", "constructor", "from", "an", "existing", "relation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/Centroid.java#L155-L175
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/timeseries/DTWDistanceFunction.java
DTWDistanceFunction.firstRow
protected void firstRow(double[] buf, int band, NumberVector v1, NumberVector v2, int dim2) { // First cell: final double val1 = v1.doubleValue(0); buf[0] = delta(val1, v2.doubleValue(0)); // Width of valid area: final int w = (band >= dim2) ? dim2 - 1 : band; // Fill remaining part of buffer: for(int j = 1; j <= w; j++) { buf[j] = buf[j - 1] + delta(val1, v2.doubleValue(j)); } }
java
protected void firstRow(double[] buf, int band, NumberVector v1, NumberVector v2, int dim2) { // First cell: final double val1 = v1.doubleValue(0); buf[0] = delta(val1, v2.doubleValue(0)); // Width of valid area: final int w = (band >= dim2) ? dim2 - 1 : band; // Fill remaining part of buffer: for(int j = 1; j <= w; j++) { buf[j] = buf[j - 1] + delta(val1, v2.doubleValue(j)); } }
[ "protected", "void", "firstRow", "(", "double", "[", "]", "buf", ",", "int", "band", ",", "NumberVector", "v1", ",", "NumberVector", "v2", ",", "int", "dim2", ")", "{", "// First cell:", "final", "double", "val1", "=", "v1", ".", "doubleValue", "(", "0",...
Fill the first row. @param buf Buffer @param band Bandwidth @param v1 First vector @param v2 Second vector @param dim2 Dimensionality of second
[ "Fill", "the", "first", "row", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/timeseries/DTWDistanceFunction.java#L137-L148
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/weightfunctions/GaussStddevWeight.java
GaussStddevWeight.getWeight
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } double normdistance = distance / stddev; return scaling * FastMath.exp(-.5 * normdistance * normdistance) / stddev; }
java
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } double normdistance = distance / stddev; return scaling * FastMath.exp(-.5 * normdistance * normdistance) / stddev; }
[ "@", "Override", "public", "double", "getWeight", "(", "double", "distance", ",", "double", "max", ",", "double", "stddev", ")", "{", "if", "(", "stddev", "<=", "0", ")", "{", "return", "1", ";", "}", "double", "normdistance", "=", "distance", "/", "st...
Get Gaussian Weight using standard deviation for scaling. max is ignored.
[ "Get", "Gaussian", "Weight", "using", "standard", "deviation", "for", "scaling", ".", "max", "is", "ignored", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/weightfunctions/GaussStddevWeight.java#L44-L51
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/TokenizedReader.java
TokenizedReader.nextLineExceptComments
public boolean nextLineExceptComments() throws IOException { while(nextLine()) { if(comment == null || !comment.reset(buf).matches()) { tokenizer.initialize(buf, 0, buf.length()); return true; } } return false; }
java
public boolean nextLineExceptComments() throws IOException { while(nextLine()) { if(comment == null || !comment.reset(buf).matches()) { tokenizer.initialize(buf, 0, buf.length()); return true; } } return false; }
[ "public", "boolean", "nextLineExceptComments", "(", ")", "throws", "IOException", "{", "while", "(", "nextLine", "(", ")", ")", "{", "if", "(", "comment", "==", "null", "||", "!", "comment", ".", "reset", "(", "buf", ")", ".", "matches", "(", ")", ")",...
Read the next line into the tokenizer. @return The next line, or {@code null}.
[ "Read", "the", "next", "line", "into", "the", "tokenizer", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/TokenizedReader.java#L64-L72
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGArrow.java
SVGArrow.makeArrow
public static Element makeArrow(SVGPlot svgp, Direction dir, double x, double y, double size) { final double hs = size / 2.; switch(dir){ case LEFT: return new SVGPath().drawTo(x + hs, y + hs).drawTo(x - hs, y).drawTo(x + hs, y - hs).drawTo(x + hs, y + hs).close().makeElement(svgp); case DOWN: return new SVGPath().drawTo(x - hs, y - hs).drawTo(x + hs, y - hs).drawTo(x, y + hs).drawTo(x - hs, y - hs).close().makeElement(svgp); case RIGHT: return new SVGPath().drawTo(x - hs, y - hs).drawTo(x + hs, y).drawTo(x - hs, y + hs).drawTo(x - hs, y - hs).close().makeElement(svgp); case UP: return new SVGPath().drawTo(x - hs, y + hs).drawTo(x, y - hs).drawTo(x + hs, y + hs).drawTo(x - hs, y + hs).close().makeElement(svgp); default: throw new IllegalArgumentException("Unexpected direction: " + dir); } }
java
public static Element makeArrow(SVGPlot svgp, Direction dir, double x, double y, double size) { final double hs = size / 2.; switch(dir){ case LEFT: return new SVGPath().drawTo(x + hs, y + hs).drawTo(x - hs, y).drawTo(x + hs, y - hs).drawTo(x + hs, y + hs).close().makeElement(svgp); case DOWN: return new SVGPath().drawTo(x - hs, y - hs).drawTo(x + hs, y - hs).drawTo(x, y + hs).drawTo(x - hs, y - hs).close().makeElement(svgp); case RIGHT: return new SVGPath().drawTo(x - hs, y - hs).drawTo(x + hs, y).drawTo(x - hs, y + hs).drawTo(x - hs, y - hs).close().makeElement(svgp); case UP: return new SVGPath().drawTo(x - hs, y + hs).drawTo(x, y - hs).drawTo(x + hs, y + hs).drawTo(x - hs, y + hs).close().makeElement(svgp); default: throw new IllegalArgumentException("Unexpected direction: " + dir); } }
[ "public", "static", "Element", "makeArrow", "(", "SVGPlot", "svgp", ",", "Direction", "dir", ",", "double", "x", ",", "double", "y", ",", "double", "size", ")", "{", "final", "double", "hs", "=", "size", "/", "2.", ";", "switch", "(", "dir", ")", "{"...
Draw an arrow at the given position. Note: the arrow is an unstyled svg path. You need to apply style afterwards. @param svgp Plot to draw to @param dir Direction to draw @param x Center x coordinate @param y Center y coordinate @param size Arrow size @return SVG Element
[ "Draw", "an", "arrow", "at", "the", "given", "position", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGArrow.java#L66-L81
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/set/HammingDistanceFunction.java
HammingDistanceFunction.hammingDistanceNumberVector
private double hammingDistanceNumberVector(NumberVector o1, NumberVector o2) { final int d1 = o1.getDimensionality(), d2 = o2.getDimensionality(); int differences = 0; int d = 0; for(; d < d1 && d < d2; d++) { double v1 = o1.doubleValue(d), v2 = o2.doubleValue(d); if(v1 != v1 || v2 != v2) { /* NaN */ continue; } if(v1 != v2) { ++differences; } } for(; d < d1; d++) { double v1 = o1.doubleValue(d); if(v1 != 0. && v1 == v1 /* not NaN */) { ++differences; } } for(; d < d2; d++) { double v2 = o2.doubleValue(d); if(v2 != 0. && v2 == v2 /* not NaN */) { ++differences; } } return differences; }
java
private double hammingDistanceNumberVector(NumberVector o1, NumberVector o2) { final int d1 = o1.getDimensionality(), d2 = o2.getDimensionality(); int differences = 0; int d = 0; for(; d < d1 && d < d2; d++) { double v1 = o1.doubleValue(d), v2 = o2.doubleValue(d); if(v1 != v1 || v2 != v2) { /* NaN */ continue; } if(v1 != v2) { ++differences; } } for(; d < d1; d++) { double v1 = o1.doubleValue(d); if(v1 != 0. && v1 == v1 /* not NaN */) { ++differences; } } for(; d < d2; d++) { double v2 = o2.doubleValue(d); if(v2 != 0. && v2 == v2 /* not NaN */) { ++differences; } } return differences; }
[ "private", "double", "hammingDistanceNumberVector", "(", "NumberVector", "o1", ",", "NumberVector", "o2", ")", "{", "final", "int", "d1", "=", "o1", ".", "getDimensionality", "(", ")", ",", "d2", "=", "o2", ".", "getDimensionality", "(", ")", ";", "int", "...
Version for number vectors. @param o1 First vector @param o2 Second vector @return hamming distance
[ "Version", "for", "number", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/distancefunction/set/HammingDistanceFunction.java#L126-L152
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/spacefillingcurves/HilbertSpatialSorter.java
HilbertSpatialSorter.interleaveBits
public static long[] interleaveBits(long[] coords, int iter) { final int numdim = coords.length; final long[] bitset = BitsUtil.zero(numdim); // convert longValues into zValues final long mask = 1L << 63 - iter; for(int dim = 0; dim < numdim; dim++) { if((coords[dim] & mask) != 0) { BitsUtil.setI(bitset, dim); } } return bitset; }
java
public static long[] interleaveBits(long[] coords, int iter) { final int numdim = coords.length; final long[] bitset = BitsUtil.zero(numdim); // convert longValues into zValues final long mask = 1L << 63 - iter; for(int dim = 0; dim < numdim; dim++) { if((coords[dim] & mask) != 0) { BitsUtil.setI(bitset, dim); } } return bitset; }
[ "public", "static", "long", "[", "]", "interleaveBits", "(", "long", "[", "]", "coords", ",", "int", "iter", ")", "{", "final", "int", "numdim", "=", "coords", ".", "length", ";", "final", "long", "[", "]", "bitset", "=", "BitsUtil", ".", "zero", "("...
Select the "iter" highest bit from each dimension. @param coords Input coordinates @param iter Bit position (from highest position) @return One bit per dimension
[ "Select", "the", "iter", "highest", "bit", "from", "each", "dimension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/spacefillingcurves/HilbertSpatialSorter.java#L290-L301
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizationTree.java
VisualizationTree.visChanged
public void visChanged(VisualizationItem item) { for(int i = vlistenerList.size(); --i >= 0;) { final VisualizationListener listener = vlistenerList.get(i); if(listener != null) { listener.visualizationChanged(item); } } }
java
public void visChanged(VisualizationItem item) { for(int i = vlistenerList.size(); --i >= 0;) { final VisualizationListener listener = vlistenerList.get(i); if(listener != null) { listener.visualizationChanged(item); } } }
[ "public", "void", "visChanged", "(", "VisualizationItem", "item", ")", "{", "for", "(", "int", "i", "=", "vlistenerList", ".", "size", "(", ")", ";", "--", "i", ">=", "0", ";", ")", "{", "final", "VisualizationListener", "listener", "=", "vlistenerList", ...
A visualization item has changed. @param item Item that has changed
[ "A", "visualization", "item", "has", "changed", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizationTree.java#L85-L92
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizationTree.java
VisualizationTree.setVisible
public static void setVisible(VisualizerContext context, VisualizationTask task, boolean visibility) { // Hide other tools if(visibility && task.isTool()) { Hierarchy<Object> vistree = context.getVisHierarchy(); for(It<VisualizationTask> iter2 = vistree.iterAll().filter(VisualizationTask.class); iter2.valid(); iter2.advance()) { VisualizationTask other = iter2.get(); if(other != task && other.isTool() && other.isVisible()) { context.visChanged(other.visibility(false)); } } } context.visChanged(task.visibility(visibility)); }
java
public static void setVisible(VisualizerContext context, VisualizationTask task, boolean visibility) { // Hide other tools if(visibility && task.isTool()) { Hierarchy<Object> vistree = context.getVisHierarchy(); for(It<VisualizationTask> iter2 = vistree.iterAll().filter(VisualizationTask.class); iter2.valid(); iter2.advance()) { VisualizationTask other = iter2.get(); if(other != task && other.isTool() && other.isVisible()) { context.visChanged(other.visibility(false)); } } } context.visChanged(task.visibility(visibility)); }
[ "public", "static", "void", "setVisible", "(", "VisualizerContext", "context", ",", "VisualizationTask", "task", ",", "boolean", "visibility", ")", "{", "// Hide other tools", "if", "(", "visibility", "&&", "task", ".", "isTool", "(", ")", ")", "{", "Hierarchy",...
Utility function to change Visualizer visibility. @param context Visualization context @param task Visualization task @param visibility Visibility value
[ "Utility", "function", "to", "change", "Visualizer", "visibility", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/VisualizationTree.java#L221-L233
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/AGNES.java
AGNES.findMerge
protected int findMerge(int end, MatrixParadigm mat, PointerHierarchyRepresentationBuilder builder) { assert (end > 0); final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] matrix = mat.matrix; double mindist = Double.POSITIVE_INFINITY; int x = -1, y = -1; // Find minimum: for(int ox = 0, xbase = 0; ox < end; xbase += ox++) { // Skip if object has already joined a cluster: if(builder.isLinked(ix.seek(ox))) { continue; } assert (xbase == MatrixParadigm.triangleSize(ox)); for(int oy = 0; oy < ox; oy++) { // Skip if object has already joined a cluster: if(builder.isLinked(iy.seek(oy))) { continue; } final double dist = matrix[xbase + oy]; if(dist <= mindist) { // Prefer later on ==, to truncate more often. mindist = dist; x = ox; y = oy; } } } assert (x >= 0 && y >= 0); assert (y < x); // We could swap otherwise, but this shouldn't arise. merge(end, mat, builder, mindist, x, y); return x; }
java
protected int findMerge(int end, MatrixParadigm mat, PointerHierarchyRepresentationBuilder builder) { assert (end > 0); final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] matrix = mat.matrix; double mindist = Double.POSITIVE_INFINITY; int x = -1, y = -1; // Find minimum: for(int ox = 0, xbase = 0; ox < end; xbase += ox++) { // Skip if object has already joined a cluster: if(builder.isLinked(ix.seek(ox))) { continue; } assert (xbase == MatrixParadigm.triangleSize(ox)); for(int oy = 0; oy < ox; oy++) { // Skip if object has already joined a cluster: if(builder.isLinked(iy.seek(oy))) { continue; } final double dist = matrix[xbase + oy]; if(dist <= mindist) { // Prefer later on ==, to truncate more often. mindist = dist; x = ox; y = oy; } } } assert (x >= 0 && y >= 0); assert (y < x); // We could swap otherwise, but this shouldn't arise. merge(end, mat, builder, mindist, x, y); return x; }
[ "protected", "int", "findMerge", "(", "int", "end", ",", "MatrixParadigm", "mat", ",", "PointerHierarchyRepresentationBuilder", "builder", ")", "{", "assert", "(", "end", ">", "0", ")", ";", "final", "DBIDArrayIter", "ix", "=", "mat", ".", "ix", ",", "iy", ...
Perform the next merge step in AGNES. @param end Active set size @param mat Matrix storage @param builder Pointer representation builder @return the index that has disappeared, for shrinking the working set
[ "Perform", "the", "next", "merge", "step", "in", "AGNES", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/AGNES.java#L224-L254
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/em/TextbookMultivariateGaussianModel.java
TextbookMultivariateGaussianModel.updateCholesky
private void updateCholesky() { // TODO: further improve handling of degenerated cases? CholeskyDecomposition chol = new CholeskyDecomposition(covariance); if(!chol.isSPD()) { // Add a small value to the diagonal, to reduce some rounding problems. double s = 0.; for(int i = 0; i < covariance.length; i++) { s += covariance[i][i]; } s *= SINGULARITY_CHEAT / covariance.length; for(int i = 0; i < covariance.length; i++) { covariance[i][i] += s; } chol = new CholeskyDecomposition(covariance); } if(!chol.isSPD()) { LOG.warning("A cluster has degenerated, likely due to lack of variance in a subset of the data or too extreme magnitude differences.\n" + // "The algorithm will likely stop without converging, and fail to produce a good fit."); chol = this.chol != null ? this.chol : chol; // Prefer previous } this.chol = chol; logNormDet = FastMath.log(weight) - .5 * logNorm - getHalfLogDeterminant(this.chol); }
java
private void updateCholesky() { // TODO: further improve handling of degenerated cases? CholeskyDecomposition chol = new CholeskyDecomposition(covariance); if(!chol.isSPD()) { // Add a small value to the diagonal, to reduce some rounding problems. double s = 0.; for(int i = 0; i < covariance.length; i++) { s += covariance[i][i]; } s *= SINGULARITY_CHEAT / covariance.length; for(int i = 0; i < covariance.length; i++) { covariance[i][i] += s; } chol = new CholeskyDecomposition(covariance); } if(!chol.isSPD()) { LOG.warning("A cluster has degenerated, likely due to lack of variance in a subset of the data or too extreme magnitude differences.\n" + // "The algorithm will likely stop without converging, and fail to produce a good fit."); chol = this.chol != null ? this.chol : chol; // Prefer previous } this.chol = chol; logNormDet = FastMath.log(weight) - .5 * logNorm - getHalfLogDeterminant(this.chol); }
[ "private", "void", "updateCholesky", "(", ")", "{", "// TODO: further improve handling of degenerated cases?", "CholeskyDecomposition", "chol", "=", "new", "CholeskyDecomposition", "(", "covariance", ")", ";", "if", "(", "!", "chol", ".", "isSPD", "(", ")", ")", "{"...
Update the cholesky decomposition.
[ "Update", "the", "cholesky", "decomposition", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/em/TextbookMultivariateGaussianModel.java#L203-L225
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassParameter.java
ClassParameter.validate
@Override public boolean validate(Class<? extends C> obj) throws ParameterException { if(obj == null) { throw new UnspecifiedParameterException(this); } if(!restrictionClass.isAssignableFrom(obj)) { throw new WrongParameterValueException(this, obj.getName(), "Given class not a subclass / implementation of " + restrictionClass.getName()); } return super.validate(obj); }
java
@Override public boolean validate(Class<? extends C> obj) throws ParameterException { if(obj == null) { throw new UnspecifiedParameterException(this); } if(!restrictionClass.isAssignableFrom(obj)) { throw new WrongParameterValueException(this, obj.getName(), "Given class not a subclass / implementation of " + restrictionClass.getName()); } return super.validate(obj); }
[ "@", "Override", "public", "boolean", "validate", "(", "Class", "<", "?", "extends", "C", ">", "obj", ")", "throws", "ParameterException", "{", "if", "(", "obj", "==", "null", ")", "{", "throw", "new", "UnspecifiedParameterException", "(", "this", ")", ";"...
Checks if the given parameter value is valid for this ClassParameter. If not a parameter exception is thrown.
[ "Checks", "if", "the", "given", "parameter", "value", "is", "valid", "for", "this", "ClassParameter", ".", "If", "not", "a", "parameter", "exception", "is", "thrown", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/ClassParameter.java#L139-L148
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/AbstractVisualization.java
AbstractVisualization.addListeners
protected void addListeners() { // Listen for result changes, including the one we monitor context.addResultListener(this); context.addVisualizationListener(this); // Listen for database events only when needed. if(task.has(UpdateFlag.ON_DATA)) { context.addDataStoreListener(this); } }
java
protected void addListeners() { // Listen for result changes, including the one we monitor context.addResultListener(this); context.addVisualizationListener(this); // Listen for database events only when needed. if(task.has(UpdateFlag.ON_DATA)) { context.addDataStoreListener(this); } }
[ "protected", "void", "addListeners", "(", ")", "{", "// Listen for result changes, including the one we monitor", "context", ".", "addResultListener", "(", "this", ")", ";", "context", ".", "addVisualizationListener", "(", "this", ")", ";", "// Listen for database events on...
Add the listeners according to the mask.
[ "Add", "the", "listeners", "according", "to", "the", "mask", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/AbstractVisualization.java#L102-L110
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java
GeneratorSingleCluster.addGenerator
public void addGenerator(Distribution gen) { if(trans != null) { throw new AbortException("Generators may no longer be added when transformations have been applied."); } axes.add(gen); dim++; }
java
public void addGenerator(Distribution gen) { if(trans != null) { throw new AbortException("Generators may no longer be added when transformations have been applied."); } axes.add(gen); dim++; }
[ "public", "void", "addGenerator", "(", "Distribution", "gen", ")", "{", "if", "(", "trans", "!=", "null", ")", "{", "throw", "new", "AbortException", "(", "\"Generators may no longer be added when transformations have been applied.\"", ")", ";", "}", "axes", ".", "a...
Add a new generator to the cluster. No transformations must have been added so far! @param gen Distribution generator
[ "Add", "a", "new", "generator", "to", "the", "cluster", ".", "No", "transformations", "must", "have", "been", "added", "so", "far!" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java#L119-L125
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java
GeneratorSingleCluster.addRotation
public void addRotation(int axis1, int axis2, double angle) { if(trans == null) { trans = new AffineTransformation(dim); } trans.addRotation(axis1, axis2, angle); }
java
public void addRotation(int axis1, int axis2, double angle) { if(trans == null) { trans = new AffineTransformation(dim); } trans.addRotation(axis1, axis2, angle); }
[ "public", "void", "addRotation", "(", "int", "axis1", ",", "int", "axis2", ",", "double", "angle", ")", "{", "if", "(", "trans", "==", "null", ")", "{", "trans", "=", "new", "AffineTransformation", "(", "dim", ")", ";", "}", "trans", ".", "addRotation"...
Apply a rotation to the generator @param axis1 First axis (0 &lt;= axis1 &lt; dim) @param axis2 Second axis (0 &lt;= axis2 &lt; dim) @param angle Angle in Radians
[ "Apply", "a", "rotation", "to", "the", "generator" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java#L134-L139
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java
GeneratorSingleCluster.addTranslation
public void addTranslation(double[] v) { if(trans == null) { trans = new AffineTransformation(dim); } trans.addTranslation(v); }
java
public void addTranslation(double[] v) { if(trans == null) { trans = new AffineTransformation(dim); } trans.addTranslation(v); }
[ "public", "void", "addTranslation", "(", "double", "[", "]", "v", ")", "{", "if", "(", "trans", "==", "null", ")", "{", "trans", "=", "new", "AffineTransformation", "(", "dim", ")", ";", "}", "trans", ".", "addTranslation", "(", "v", ")", ";", "}" ]
Add a translation to the generator @param v translation double[]
[ "Add", "a", "translation", "to", "the", "generator" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java#L146-L151
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java
GeneratorSingleCluster.generate
@Override public List<double[]> generate(int count) { ArrayList<double[]> result = new ArrayList<>(count); while(result.size() < count) { double[] d = new double[dim]; for(int i = 0; i < dim; i++) { d[i] = axes.get(i).nextRandom(); } if(trans != null) { d = trans.apply(d); } if(testClipping(d)) { if(--retries < 0) { throw new AbortException("Maximum retry count in generator exceeded."); } continue; } result.add(d); } return result; }
java
@Override public List<double[]> generate(int count) { ArrayList<double[]> result = new ArrayList<>(count); while(result.size() < count) { double[] d = new double[dim]; for(int i = 0; i < dim; i++) { d[i] = axes.get(i).nextRandom(); } if(trans != null) { d = trans.apply(d); } if(testClipping(d)) { if(--retries < 0) { throw new AbortException("Maximum retry count in generator exceeded."); } continue; } result.add(d); } return result; }
[ "@", "Override", "public", "List", "<", "double", "[", "]", ">", "generate", "(", "int", "count", ")", "{", "ArrayList", "<", "double", "[", "]", ">", "result", "=", "new", "ArrayList", "<>", "(", "count", ")", ";", "while", "(", "result", ".", "si...
Generate the given number of additional points. @see de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorInterface#generate(int)
[ "Generate", "the", "given", "number", "of", "additional", "points", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/data/synthetic/bymodel/GeneratorSingleCluster.java#L221-L241
train
elki-project/elki
addons/tutorial/src/main/java/tutorial/clustering/SameSizeKMeansAlgorithm.java
SameSizeKMeansAlgorithm.run
@Override public Clustering<MeanModel> run(Database database, Relation<V> relation) { // Database objects to process final DBIDs ids = relation.getDBIDs(); // Choose initial means double[][] means = initializer.chooseInitialMeans(database, relation, k, getDistanceFunction()); // Setup cluster assignment store List<ModifiableDBIDs> clusters = new ArrayList<>(); for(int i = 0; i < k; i++) { clusters.add(DBIDUtil.newHashSet(relation.size() / k + 2)); } // Meta data storage final WritableDataStore<Meta> metas = initializeMeta(relation, means); // Perform the initial assignment ArrayModifiableDBIDs tids = initialAssignment(clusters, metas, ids); // Recompute the means after the initial assignment means = means(clusters, means, relation); // Refine the result via k-means like iterations means = refineResult(relation, means, clusters, metas, tids); // Wrap result Clustering<MeanModel> result = new Clustering<>("k-Means Samesize Clustering", "kmeans-samesize-clustering"); for(int i = 0; i < clusters.size(); i++) { result.addToplevelCluster(new Cluster<>(clusters.get(i), new MeanModel(means[i]))); } return result; }
java
@Override public Clustering<MeanModel> run(Database database, Relation<V> relation) { // Database objects to process final DBIDs ids = relation.getDBIDs(); // Choose initial means double[][] means = initializer.chooseInitialMeans(database, relation, k, getDistanceFunction()); // Setup cluster assignment store List<ModifiableDBIDs> clusters = new ArrayList<>(); for(int i = 0; i < k; i++) { clusters.add(DBIDUtil.newHashSet(relation.size() / k + 2)); } // Meta data storage final WritableDataStore<Meta> metas = initializeMeta(relation, means); // Perform the initial assignment ArrayModifiableDBIDs tids = initialAssignment(clusters, metas, ids); // Recompute the means after the initial assignment means = means(clusters, means, relation); // Refine the result via k-means like iterations means = refineResult(relation, means, clusters, metas, tids); // Wrap result Clustering<MeanModel> result = new Clustering<>("k-Means Samesize Clustering", "kmeans-samesize-clustering"); for(int i = 0; i < clusters.size(); i++) { result.addToplevelCluster(new Cluster<>(clusters.get(i), new MeanModel(means[i]))); } return result; }
[ "@", "Override", "public", "Clustering", "<", "MeanModel", ">", "run", "(", "Database", "database", ",", "Relation", "<", "V", ">", "relation", ")", "{", "// Database objects to process", "final", "DBIDs", "ids", "=", "relation", ".", "getDBIDs", "(", ")", "...
Run k-means with cluster size constraints. @param database Database @param relation relation to use @return result
[ "Run", "k", "-", "means", "with", "cluster", "size", "constraints", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/tutorial/src/main/java/tutorial/clustering/SameSizeKMeansAlgorithm.java#L108-L135
train
elki-project/elki
addons/tutorial/src/main/java/tutorial/clustering/SameSizeKMeansAlgorithm.java
SameSizeKMeansAlgorithm.initializeMeta
protected WritableDataStore<Meta> initializeMeta(Relation<V> relation, double[][] means) { NumberVectorDistanceFunction<? super V> df = getDistanceFunction(); // The actual storage final WritableDataStore<Meta> metas = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, Meta.class); // Build the metadata, track the two nearest cluster centers. for(DBIDIter id = relation.iterDBIDs(); id.valid(); id.advance()) { Meta c = new Meta(k); V fv = relation.get(id); for(int i = 0; i < k; i++) { final double d = c.dists[i] = df.distance(fv, DoubleVector.wrap(means[i])); if(i > 0) { if(d < c.dists[c.primary]) { c.primary = i; } else if(d > c.dists[c.secondary]) { c.secondary = i; } } } metas.put(id, c); } return metas; }
java
protected WritableDataStore<Meta> initializeMeta(Relation<V> relation, double[][] means) { NumberVectorDistanceFunction<? super V> df = getDistanceFunction(); // The actual storage final WritableDataStore<Meta> metas = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, Meta.class); // Build the metadata, track the two nearest cluster centers. for(DBIDIter id = relation.iterDBIDs(); id.valid(); id.advance()) { Meta c = new Meta(k); V fv = relation.get(id); for(int i = 0; i < k; i++) { final double d = c.dists[i] = df.distance(fv, DoubleVector.wrap(means[i])); if(i > 0) { if(d < c.dists[c.primary]) { c.primary = i; } else if(d > c.dists[c.secondary]) { c.secondary = i; } } } metas.put(id, c); } return metas; }
[ "protected", "WritableDataStore", "<", "Meta", ">", "initializeMeta", "(", "Relation", "<", "V", ">", "relation", ",", "double", "[", "]", "[", "]", "means", ")", "{", "NumberVectorDistanceFunction", "<", "?", "super", "V", ">", "df", "=", "getDistanceFuncti...
Initialize the metadata storage. @param relation Relation to process @param means Mean vectors @return Initialized storage
[ "Initialize", "the", "metadata", "storage", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/tutorial/src/main/java/tutorial/clustering/SameSizeKMeansAlgorithm.java#L144-L166
train
elki-project/elki
addons/tutorial/src/main/java/tutorial/clustering/SameSizeKMeansAlgorithm.java
SameSizeKMeansAlgorithm.transfer
protected void transfer(final WritableDataStore<Meta> metas, Meta meta, ModifiableDBIDs src, ModifiableDBIDs dst, DBIDRef id, int dstnum) { src.remove(id); dst.add(id); meta.primary = dstnum; metas.put(id, meta); // Make sure the storage is up to date. }
java
protected void transfer(final WritableDataStore<Meta> metas, Meta meta, ModifiableDBIDs src, ModifiableDBIDs dst, DBIDRef id, int dstnum) { src.remove(id); dst.add(id); meta.primary = dstnum; metas.put(id, meta); // Make sure the storage is up to date. }
[ "protected", "void", "transfer", "(", "final", "WritableDataStore", "<", "Meta", ">", "metas", ",", "Meta", "meta", ",", "ModifiableDBIDs", "src", ",", "ModifiableDBIDs", "dst", ",", "DBIDRef", "id", ",", "int", "dstnum", ")", "{", "src", ".", "remove", "(...
Transfer a single element from one cluster to another. @param metas Meta storage @param meta Meta of current object @param src Source cluster @param dst Destination cluster @param id Object ID @param dstnum Destination cluster number
[ "Transfer", "a", "single", "element", "from", "one", "cluster", "to", "another", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/tutorial/src/main/java/tutorial/clustering/SameSizeKMeansAlgorithm.java#L357-L362
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HoeffdingsDDependenceMeasure.java
HoeffdingsDDependenceMeasure.toPValue
public double toPValue(double d, int n) { double b = d / 30 + 1. / (36 * n); double z = .5 * MathUtil.PISQUARE * MathUtil.PISQUARE * n * b; // Exponential approximation if(z < 1.1 || z > 8.5) { double e = FastMath.exp(0.3885037 - 1.164879 * z); return (e > 1) ? 1 : (e < 0) ? 0 : e; } // Tabular approximation for(int i = 0; i < 86; i++) { if(TABPOS[i] >= z) { // Exact table value if(TABPOS[i] == z) { return TABVAL[i]; } // Linear interpolation double x1 = TABPOS[i], x0 = TABPOS[i - 1]; double y1 = TABVAL[i], y0 = TABVAL[i - 1]; return y0 + (y1 - y0) * (z - x0) / (x1 - x0); } } return -1; }
java
public double toPValue(double d, int n) { double b = d / 30 + 1. / (36 * n); double z = .5 * MathUtil.PISQUARE * MathUtil.PISQUARE * n * b; // Exponential approximation if(z < 1.1 || z > 8.5) { double e = FastMath.exp(0.3885037 - 1.164879 * z); return (e > 1) ? 1 : (e < 0) ? 0 : e; } // Tabular approximation for(int i = 0; i < 86; i++) { if(TABPOS[i] >= z) { // Exact table value if(TABPOS[i] == z) { return TABVAL[i]; } // Linear interpolation double x1 = TABPOS[i], x0 = TABPOS[i - 1]; double y1 = TABVAL[i], y0 = TABVAL[i - 1]; return y0 + (y1 - y0) * (z - x0) / (x1 - x0); } } return -1; }
[ "public", "double", "toPValue", "(", "double", "d", ",", "int", "n", ")", "{", "double", "b", "=", "d", "/", "30", "+", "1.", "/", "(", "36", "*", "n", ")", ";", "double", "z", "=", ".5", "*", "MathUtil", ".", "PISQUARE", "*", "MathUtil", ".", ...
Convert Hoeffding D value to a p-value. @param d D value @param n Data set size @return p-value
[ "Convert", "Hoeffding", "D", "value", "to", "a", "p", "-", "value", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HoeffdingsDDependenceMeasure.java#L170-L193
train
elki-project/elki
elki-core-parallel/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelExecutor.java
ParallelExecutor.run
public static void run(DBIDs ids, Processor... procs) { ParallelCore core = ParallelCore.getCore(); core.connect(); try { // TODO: try different strategies anyway! ArrayDBIDs aids = DBIDUtil.ensureArray(ids); final int size = aids.size(); int numparts = core.getParallelism(); // TODO: are there better heuristics for choosing this? numparts = (size > numparts * numparts * 16) ? numparts * Math.max(1, numparts - 1) : numparts; final int blocksize = (size + (numparts - 1)) / numparts; List<Future<ArrayDBIDs>> parts = new ArrayList<>(numparts); for(int i = 0; i < numparts; i++) { final int start = i * blocksize; final int end = Math.min(start + blocksize, size); Callable<ArrayDBIDs> run = new BlockArrayRunner(aids, start, end, procs); parts.add(core.submit(run)); } for(Future<ArrayDBIDs> fut : parts) { fut.get(); } } catch(ExecutionException e) { throw new RuntimeException("Processor execution failed.", e); } catch(InterruptedException e) { throw new RuntimeException("Parallel execution interrupted."); } finally { core.disconnect(); } }
java
public static void run(DBIDs ids, Processor... procs) { ParallelCore core = ParallelCore.getCore(); core.connect(); try { // TODO: try different strategies anyway! ArrayDBIDs aids = DBIDUtil.ensureArray(ids); final int size = aids.size(); int numparts = core.getParallelism(); // TODO: are there better heuristics for choosing this? numparts = (size > numparts * numparts * 16) ? numparts * Math.max(1, numparts - 1) : numparts; final int blocksize = (size + (numparts - 1)) / numparts; List<Future<ArrayDBIDs>> parts = new ArrayList<>(numparts); for(int i = 0; i < numparts; i++) { final int start = i * blocksize; final int end = Math.min(start + blocksize, size); Callable<ArrayDBIDs> run = new BlockArrayRunner(aids, start, end, procs); parts.add(core.submit(run)); } for(Future<ArrayDBIDs> fut : parts) { fut.get(); } } catch(ExecutionException e) { throw new RuntimeException("Processor execution failed.", e); } catch(InterruptedException e) { throw new RuntimeException("Parallel execution interrupted."); } finally { core.disconnect(); } }
[ "public", "static", "void", "run", "(", "DBIDs", "ids", ",", "Processor", "...", "procs", ")", "{", "ParallelCore", "core", "=", "ParallelCore", ".", "getCore", "(", ")", ";", "core", ".", "connect", "(", ")", ";", "try", "{", "// TODO: try different strat...
Run a task on all available CPUs. @param ids IDs to process @param procs Processors to run
[ "Run", "a", "task", "on", "all", "available", "CPUs", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-parallel/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelExecutor.java#L63-L96
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java
OPTICSPlot.replot
public void replot() { width = co.size(); height = (int) Math.ceil(width * .2); ratio = width / (double) height; height = height < MIN_HEIGHT ? MIN_HEIGHT : height > MAX_HEIGHT ? MAX_HEIGHT : height; if(scale == null) { scale = computeScale(co); } BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); int x = 0; for(DBIDIter it = co.iter(); it.valid(); it.advance()) { double reach = co.getReachability(it); final int y = scaleToPixel(reach); try { int col = colors.getColorForDBID(it); for(int y2 = height - 1; y2 >= y; y2--) { img.setRGB(x, y2, col); } } catch(ArrayIndexOutOfBoundsException e) { LOG.error("Plotting out of range: " + x + "," + y + " >= " + width + "x" + height); } x++; } plot = img; }
java
public void replot() { width = co.size(); height = (int) Math.ceil(width * .2); ratio = width / (double) height; height = height < MIN_HEIGHT ? MIN_HEIGHT : height > MAX_HEIGHT ? MAX_HEIGHT : height; if(scale == null) { scale = computeScale(co); } BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); int x = 0; for(DBIDIter it = co.iter(); it.valid(); it.advance()) { double reach = co.getReachability(it); final int y = scaleToPixel(reach); try { int col = colors.getColorForDBID(it); for(int y2 = height - 1; y2 >= y; y2--) { img.setRGB(x, y2, col); } } catch(ArrayIndexOutOfBoundsException e) { LOG.error("Plotting out of range: " + x + "," + y + " >= " + width + "x" + height); } x++; } plot = img; }
[ "public", "void", "replot", "(", ")", "{", "width", "=", "co", ".", "size", "(", ")", ";", "height", "=", "(", "int", ")", "Math", ".", "ceil", "(", "width", "*", ".2", ")", ";", "ratio", "=", "width", "/", "(", "double", ")", "height", ";", ...
Trigger a redraw of the OPTICS plot
[ "Trigger", "a", "redraw", "of", "the", "OPTICS", "plot" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java#L111-L139
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java
OPTICSPlot.scaleToPixel
public int scaleToPixel(double reach) { return (Double.isInfinite(reach) || Double.isNaN(reach)) ? 0 : // (int) Math.round(scale.getScaled(reach, height - .5, .5)); }
java
public int scaleToPixel(double reach) { return (Double.isInfinite(reach) || Double.isNaN(reach)) ? 0 : // (int) Math.round(scale.getScaled(reach, height - .5, .5)); }
[ "public", "int", "scaleToPixel", "(", "double", "reach", ")", "{", "return", "(", "Double", ".", "isInfinite", "(", "reach", ")", "||", "Double", ".", "isNaN", "(", "reach", ")", ")", "?", "0", ":", "//", "(", "int", ")", "Math", ".", "round", "(",...
Scale a reachability distance to a pixel value. @param reach Reachability @return Pixel value.
[ "Scale", "a", "reachability", "distance", "to", "a", "pixel", "value", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java#L147-L150
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java
OPTICSPlot.getSVGPlotURI
public String getSVGPlotURI() { if(plotnum < 0) { plotnum = ThumbnailRegistryEntry.registerImage(plot); } return ThumbnailRegistryEntry.INTERNAL_PREFIX + plotnum; }
java
public String getSVGPlotURI() { if(plotnum < 0) { plotnum = ThumbnailRegistryEntry.registerImage(plot); } return ThumbnailRegistryEntry.INTERNAL_PREFIX + plotnum; }
[ "public", "String", "getSVGPlotURI", "(", ")", "{", "if", "(", "plotnum", "<", "0", ")", "{", "plotnum", "=", "ThumbnailRegistryEntry", ".", "registerImage", "(", "plot", ")", ";", "}", "return", "ThumbnailRegistryEntry", ".", "INTERNAL_PREFIX", "+", "plotnum"...
Get the SVG registered plot number @return Plot URI
[ "Get", "the", "SVG", "registered", "plot", "number" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java#L252-L257
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java
OPTICSPlot.plotForClusterOrder
public static OPTICSPlot plotForClusterOrder(ClusterOrder co, VisualizerContext context) { // Check for an existing plot // ArrayList<OPTICSPlot<D>> plots = ResultUtil.filterResults(co, // OPTICSPlot.class); // if (plots.size() > 0) { // return plots.get(0); // } final StylingPolicy policy = context.getStylingPolicy(); OPTICSPlot opticsplot = new OPTICSPlot(co, policy); // co.addChildResult(opticsplot); return opticsplot; }
java
public static OPTICSPlot plotForClusterOrder(ClusterOrder co, VisualizerContext context) { // Check for an existing plot // ArrayList<OPTICSPlot<D>> plots = ResultUtil.filterResults(co, // OPTICSPlot.class); // if (plots.size() > 0) { // return plots.get(0); // } final StylingPolicy policy = context.getStylingPolicy(); OPTICSPlot opticsplot = new OPTICSPlot(co, policy); // co.addChildResult(opticsplot); return opticsplot; }
[ "public", "static", "OPTICSPlot", "plotForClusterOrder", "(", "ClusterOrder", "co", ",", "VisualizerContext", "context", ")", "{", "// Check for an existing plot", "// ArrayList<OPTICSPlot<D>> plots = ResultUtil.filterResults(co,", "// OPTICSPlot.class);", "// if (plots.size() > 0) {",...
Static method to find an optics plot for a result, or to create a new one using the given context. @param co Cluster order @param context Context (for colors and reference clustering) @return New or existing optics plot
[ "Static", "method", "to", "find", "an", "optics", "plot", "for", "a", "result", "or", "to", "create", "a", "new", "one", "using", "the", "given", "context", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/opticsplot/OPTICSPlot.java#L278-L289
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/LUDecomposition.java
LUDecomposition.inverse
public double[][] inverse() { // Build permuted identity matrix efficiently: double[][] b = new double[piv.length][m]; for(int i = 0; i < piv.length; i++) { b[piv[i]][i] = 1.; } return solveInplace(b); }
java
public double[][] inverse() { // Build permuted identity matrix efficiently: double[][] b = new double[piv.length][m]; for(int i = 0; i < piv.length; i++) { b[piv[i]][i] = 1.; } return solveInplace(b); }
[ "public", "double", "[", "]", "[", "]", "inverse", "(", ")", "{", "// Build permuted identity matrix efficiently:", "double", "[", "]", "[", "]", "b", "=", "new", "double", "[", "piv", ".", "length", "]", "[", "m", "]", ";", "for", "(", "int", "i", "...
Find the inverse matrix. @return Inverse matrix @throws ArithmeticException Matrix is rank deficient.
[ "Find", "the", "inverse", "matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/LUDecomposition.java#L330-L337
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/parser/SimplePolygonParser.java
SimplePolygonParser.parseLine
private boolean parseLine() { cureid = null; curpoly = null; curlbl = null; polys.clear(); coords.clear(); labels.clear(); Matcher m = COORD.matcher(reader.getBuffer()); for(/* initialized by nextLineExceptComments */; tokenizer.valid(); tokenizer.advance()) { m.region(tokenizer.getStart(), tokenizer.getEnd()); if(m.find()) { try { double c1 = ParseUtil.parseDouble(m.group(1)); double c2 = ParseUtil.parseDouble(m.group(2)); if(m.group(3) != null) { double c3 = ParseUtil.parseDouble(m.group(3)); coords.add(new double[] { c1, c2, c3 }); } else { coords.add(new double[] { c1, c2 }); } continue; } catch(NumberFormatException e) { LOG.warning("Looked like a coordinate pair but didn't parse: " + tokenizer.getSubstring()); } } // Match polygon separator: // FIXME: Avoid unnecessary subSequence call. final int len = tokenizer.getEnd() - tokenizer.getStart(); if(POLYGON_SEPARATOR.length() == len && // reader.getBuffer().subSequence(tokenizer.getStart(), tokenizer.getEnd()).equals(POLYGON_SEPARATOR)) { if(!coords.isEmpty()) { polys.add(new Polygon(new ArrayList<>(coords))); } continue; } String cur = tokenizer.getSubstring(); // First label will become the External ID if(cureid == null) { cureid = new ExternalID(cur); } else { labels.add(cur); } } // Complete polygon if(!coords.isEmpty()) { polys.add(new Polygon(coords)); } curpoly = new PolygonsObject(polys); curlbl = (haslabels || !labels.isEmpty()) ? LabelList.make(labels) : null; return true; }
java
private boolean parseLine() { cureid = null; curpoly = null; curlbl = null; polys.clear(); coords.clear(); labels.clear(); Matcher m = COORD.matcher(reader.getBuffer()); for(/* initialized by nextLineExceptComments */; tokenizer.valid(); tokenizer.advance()) { m.region(tokenizer.getStart(), tokenizer.getEnd()); if(m.find()) { try { double c1 = ParseUtil.parseDouble(m.group(1)); double c2 = ParseUtil.parseDouble(m.group(2)); if(m.group(3) != null) { double c3 = ParseUtil.parseDouble(m.group(3)); coords.add(new double[] { c1, c2, c3 }); } else { coords.add(new double[] { c1, c2 }); } continue; } catch(NumberFormatException e) { LOG.warning("Looked like a coordinate pair but didn't parse: " + tokenizer.getSubstring()); } } // Match polygon separator: // FIXME: Avoid unnecessary subSequence call. final int len = tokenizer.getEnd() - tokenizer.getStart(); if(POLYGON_SEPARATOR.length() == len && // reader.getBuffer().subSequence(tokenizer.getStart(), tokenizer.getEnd()).equals(POLYGON_SEPARATOR)) { if(!coords.isEmpty()) { polys.add(new Polygon(new ArrayList<>(coords))); } continue; } String cur = tokenizer.getSubstring(); // First label will become the External ID if(cureid == null) { cureid = new ExternalID(cur); } else { labels.add(cur); } } // Complete polygon if(!coords.isEmpty()) { polys.add(new Polygon(coords)); } curpoly = new PolygonsObject(polys); curlbl = (haslabels || !labels.isEmpty()) ? LabelList.make(labels) : null; return true; }
[ "private", "boolean", "parseLine", "(", ")", "{", "cureid", "=", "null", ";", "curpoly", "=", "null", ";", "curlbl", "=", "null", ";", "polys", ".", "clear", "(", ")", ";", "coords", ".", "clear", "(", ")", ";", "labels", ".", "clear", "(", ")", ...
Parse a single line. @return {@code true} if the line was read successful.
[ "Parse", "a", "single", "line", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/parser/SimplePolygonParser.java#L181-L235
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/workflow/OutputStep.java
OutputStep.runResultHandlers
public void runResultHandlers(ResultHierarchy hier, Database db) { // Run result handlers for(ResultHandler resulthandler : resulthandlers) { Thread.currentThread().setName(resulthandler.toString()); resulthandler.processNewResult(hier, db); } }
java
public void runResultHandlers(ResultHierarchy hier, Database db) { // Run result handlers for(ResultHandler resulthandler : resulthandlers) { Thread.currentThread().setName(resulthandler.toString()); resulthandler.processNewResult(hier, db); } }
[ "public", "void", "runResultHandlers", "(", "ResultHierarchy", "hier", ",", "Database", "db", ")", "{", "// Run result handlers", "for", "(", "ResultHandler", "resulthandler", ":", "resulthandlers", ")", "{", "Thread", ".", "currentThread", "(", ")", ".", "setName...
Run the result handlers. @param hier Result to run on @param db Database
[ "Run", "the", "result", "handlers", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/workflow/OutputStep.java#L66-L72
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/workflow/OutputStep.java
OutputStep.setDefaultHandlerVisualizer
@SuppressWarnings("unchecked") public static void setDefaultHandlerVisualizer() { defaultHandlers = new ArrayList<>(1); Class<? extends ResultHandler> clz; try { clz = (Class<? extends ResultHandler>) Thread.currentThread().getContextClassLoader().loadClass(// "de.lmu.ifi.dbs.elki.result.AutomaticVisualization"); } catch(ClassNotFoundException e) { clz = ResultWriter.class; } defaultHandlers.add(clz); }
java
@SuppressWarnings("unchecked") public static void setDefaultHandlerVisualizer() { defaultHandlers = new ArrayList<>(1); Class<? extends ResultHandler> clz; try { clz = (Class<? extends ResultHandler>) Thread.currentThread().getContextClassLoader().loadClass(// "de.lmu.ifi.dbs.elki.result.AutomaticVisualization"); } catch(ClassNotFoundException e) { clz = ResultWriter.class; } defaultHandlers.add(clz); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "void", "setDefaultHandlerVisualizer", "(", ")", "{", "defaultHandlers", "=", "new", "ArrayList", "<>", "(", "1", ")", ";", "Class", "<", "?", "extends", "ResultHandler", ">", "clz", ";", ...
Set the default handler to the Batik addon visualizer, if available.
[ "Set", "the", "default", "handler", "to", "the", "Batik", "addon", "visualizer", "if", "available", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/workflow/OutputStep.java#L85-L97
train
elki-project/elki
elki-core-parallel/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelCore.java
ParallelCore.connect
public synchronized void connect() { if(executor == null) { executor = new ThreadPoolExecutor(0, processors, 10L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); executor.allowCoreThreadTimeOut(true); } if(++connected == 1) { executor.allowCoreThreadTimeOut(false); executor.setCorePoolSize(executor.getMaximumPoolSize()); } }
java
public synchronized void connect() { if(executor == null) { executor = new ThreadPoolExecutor(0, processors, 10L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); executor.allowCoreThreadTimeOut(true); } if(++connected == 1) { executor.allowCoreThreadTimeOut(false); executor.setCorePoolSize(executor.getMaximumPoolSize()); } }
[ "public", "synchronized", "void", "connect", "(", ")", "{", "if", "(", "executor", "==", "null", ")", "{", "executor", "=", "new", "ThreadPoolExecutor", "(", "0", ",", "processors", ",", "10L", ",", "TimeUnit", ".", "MILLISECONDS", ",", "new", "LinkedBlock...
Connect to the executor.
[ "Connect", "to", "the", "executor", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-parallel/src/main/java/de/lmu/ifi/dbs/elki/parallel/ParallelCore.java#L99-L108
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/XYCurve.java
XYCurve.add
public void add(double x, double y) { data.add(x); data.add(y); minx = Math.min(minx, x); maxx = Math.max(maxx, x); miny = Math.min(miny, y); maxy = Math.max(maxy, y); }
java
public void add(double x, double y) { data.add(x); data.add(y); minx = Math.min(minx, x); maxx = Math.max(maxx, x); miny = Math.min(miny, y); maxy = Math.max(maxy, y); }
[ "public", "void", "add", "(", "double", "x", ",", "double", "y", ")", "{", "data", ".", "add", "(", "x", ")", ";", "data", ".", "add", "(", "y", ")", ";", "minx", "=", "Math", ".", "min", "(", "minx", ",", "x", ")", ";", "maxx", "=", "Math"...
Add a coordinate pair, but don't simplify @param x X coordinate @param y Y coordinate
[ "Add", "a", "coordinate", "pair", "but", "don", "t", "simplify" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/XYCurve.java#L134-L141
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/XYCurve.java
XYCurve.addAndSimplify
public void addAndSimplify(double x, double y) { // simplify curve when possible: final int len = data.size(); if (len >= 4) { // Look at the previous 2 points final double l1x = data.get(len - 4); final double l1y = data.get(len - 3); final double l2x = data.get(len - 2); final double l2y = data.get(len - 1); // Differences: final double ldx = l2x - l1x; final double ldy = l2y - l1y; final double cdx = x - l2x; final double cdy = y - l2y; // X simplification if ((ldx == 0) && (cdx == 0)) { data.remove(len - 2, 2); } // horizontal simplification else if ((ldy == 0) && (cdy == 0)) { data.remove(len - 2, 2); } // diagonal simplification else if (ldy > 0 && cdy > 0) { if (Math.abs((ldx / ldy) - (cdx / cdy)) < THRESHOLD) { data.remove(len - 2, 2); } } } add(x, y); }
java
public void addAndSimplify(double x, double y) { // simplify curve when possible: final int len = data.size(); if (len >= 4) { // Look at the previous 2 points final double l1x = data.get(len - 4); final double l1y = data.get(len - 3); final double l2x = data.get(len - 2); final double l2y = data.get(len - 1); // Differences: final double ldx = l2x - l1x; final double ldy = l2y - l1y; final double cdx = x - l2x; final double cdy = y - l2y; // X simplification if ((ldx == 0) && (cdx == 0)) { data.remove(len - 2, 2); } // horizontal simplification else if ((ldy == 0) && (cdy == 0)) { data.remove(len - 2, 2); } // diagonal simplification else if (ldy > 0 && cdy > 0) { if (Math.abs((ldx / ldy) - (cdx / cdy)) < THRESHOLD) { data.remove(len - 2, 2); } } } add(x, y); }
[ "public", "void", "addAndSimplify", "(", "double", "x", ",", "double", "y", ")", "{", "// simplify curve when possible:", "final", "int", "len", "=", "data", ".", "size", "(", ")", ";", "if", "(", "len", ">=", "4", ")", "{", "// Look at the previous 2 points...
Add a coordinate pair, performing curve simplification if possible. @param x X coordinate @param y Y coordinate
[ "Add", "a", "coordinate", "pair", "performing", "curve", "simplification", "if", "possible", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/XYCurve.java#L149-L179
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/XYCurve.java
XYCurve.rescale
public void rescale(double sx, double sy) { for (int i = 0; i < data.size(); i += 2) { data.set(i, sx * data.get(i)); data.set(i + 1, sy * data.get(i + 1)); } maxx *= sx; maxy *= sy; }
java
public void rescale(double sx, double sy) { for (int i = 0; i < data.size(); i += 2) { data.set(i, sx * data.get(i)); data.set(i + 1, sy * data.get(i + 1)); } maxx *= sx; maxy *= sy; }
[ "public", "void", "rescale", "(", "double", "sx", ",", "double", "sy", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "data", ".", "size", "(", ")", ";", "i", "+=", "2", ")", "{", "data", ".", "set", "(", "i", ",", "sx", "*", ...
Rescale the graph. @param sx Scaling factor for X axis @param sy Scaling factor for Y axis
[ "Rescale", "the", "graph", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/XYCurve.java#L261-L268
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/insert/MinimumEnlargementInsert.java
MinimumEnlargementInsert.choosePath
private IndexTreePath<E> choosePath(AbstractMTree<?, N, E, ?> tree, E object, IndexTreePath<E> subtree) { N node = tree.getNode(subtree.getEntry()); // leaf if(node.isLeaf()) { return subtree; } // Initialize from first: int bestIdx = 0; E bestEntry = node.getEntry(0); double bestDistance = tree.distance(object.getRoutingObjectID(), bestEntry.getRoutingObjectID()); // Iterate over remaining for(int i = 1; i < node.getNumEntries(); i++) { E entry = node.getEntry(i); double distance = tree.distance(object.getRoutingObjectID(), entry.getRoutingObjectID()); if(distance < bestDistance) { bestIdx = i; bestEntry = entry; bestDistance = distance; } } return choosePath(tree, object, new IndexTreePath<>(subtree, bestEntry, bestIdx)); }
java
private IndexTreePath<E> choosePath(AbstractMTree<?, N, E, ?> tree, E object, IndexTreePath<E> subtree) { N node = tree.getNode(subtree.getEntry()); // leaf if(node.isLeaf()) { return subtree; } // Initialize from first: int bestIdx = 0; E bestEntry = node.getEntry(0); double bestDistance = tree.distance(object.getRoutingObjectID(), bestEntry.getRoutingObjectID()); // Iterate over remaining for(int i = 1; i < node.getNumEntries(); i++) { E entry = node.getEntry(i); double distance = tree.distance(object.getRoutingObjectID(), entry.getRoutingObjectID()); if(distance < bestDistance) { bestIdx = i; bestEntry = entry; bestDistance = distance; } } return choosePath(tree, object, new IndexTreePath<>(subtree, bestEntry, bestIdx)); }
[ "private", "IndexTreePath", "<", "E", ">", "choosePath", "(", "AbstractMTree", "<", "?", ",", "N", ",", "E", ",", "?", ">", "tree", ",", "E", "object", ",", "IndexTreePath", "<", "E", ">", "subtree", ")", "{", "N", "node", "=", "tree", ".", "getNod...
Chooses the best path of the specified subtree for insertion of the given object. @param tree the tree to insert into @param object the entry to search @param subtree the subtree to be tested for insertion @return the path of the appropriate subtree to insert the given object
[ "Chooses", "the", "best", "path", "of", "the", "specified", "subtree", "for", "insertion", "of", "the", "given", "object", "." ]
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/insert/MinimumEnlargementInsert.java#L61-L86
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/MergedParameterization.java
MergedParameterization.rewind
public void rewind() { synchronized(used) { for(ParameterPair pair : used) { current.addParameter(pair); } used.clear(); } }
java
public void rewind() { synchronized(used) { for(ParameterPair pair : used) { current.addParameter(pair); } used.clear(); } }
[ "public", "void", "rewind", "(", ")", "{", "synchronized", "(", "used", ")", "{", "for", "(", "ParameterPair", "pair", ":", "used", ")", "{", "current", ".", "addParameter", "(", "pair", ")", ";", "}", "used", ".", "clear", "(", ")", ";", "}", "}" ...
Rewind the configuration to the initial situation
[ "Rewind", "the", "configuration", "to", "the", "initial", "situation" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameterization/MergedParameterization.java#L86-L93
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/estimator/UniformEnhancedMinMaxEstimator.java
UniformEnhancedMinMaxEstimator.estimate
public UniformDistribution estimate(double min, double max, final int count) { double grow = (count > 1) ? 0.5 * (max - min) / (count - 1) : 0.; return new UniformDistribution(Math.max(min - grow, -Double.MAX_VALUE), Math.min(max + grow, Double.MAX_VALUE)); }
java
public UniformDistribution estimate(double min, double max, final int count) { double grow = (count > 1) ? 0.5 * (max - min) / (count - 1) : 0.; return new UniformDistribution(Math.max(min - grow, -Double.MAX_VALUE), Math.min(max + grow, Double.MAX_VALUE)); }
[ "public", "UniformDistribution", "estimate", "(", "double", "min", ",", "double", "max", ",", "final", "int", "count", ")", "{", "double", "grow", "=", "(", "count", ">", "1", ")", "?", "0.5", "*", "(", "max", "-", "min", ")", "/", "(", "count", "-...
Estimate from simple characteristics. @param min Minimum @param max Maximum @param count Number of observations @return Distribution
[ "Estimate", "from", "simple", "characteristics", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/estimator/UniformEnhancedMinMaxEstimator.java#L71-L74
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/WeibullDistribution.java
WeibullDistribution.cdf
public static double cdf(double val, double k, double lambda, double theta) { return (val > theta) ? // (1.0 - FastMath.exp(-FastMath.pow((val - theta) / lambda, k))) // : val == val ? 0.0 : Double.NaN; }
java
public static double cdf(double val, double k, double lambda, double theta) { return (val > theta) ? // (1.0 - FastMath.exp(-FastMath.pow((val - theta) / lambda, k))) // : val == val ? 0.0 : Double.NaN; }
[ "public", "static", "double", "cdf", "(", "double", "val", ",", "double", "k", ",", "double", "lambda", ",", "double", "theta", ")", "{", "return", "(", "val", ">", "theta", ")", "?", "//", "(", "1.0", "-", "FastMath", ".", "exp", "(", "-", "FastMa...
CDF of Weibull distribution @param val Value @param k Shape parameter @param lambda Scale parameter @param theta Shift offset parameter @return CDF at position x.
[ "CDF", "of", "Weibull", "distribution" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/WeibullDistribution.java#L195-L199
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/WeibullDistribution.java
WeibullDistribution.quantile
public static double quantile(double val, double k, double lambda, double theta) { if(val < 0.0 || val > 1.0) { return Double.NaN; } else if(val == 0) { return 0.0; } else if(val == 1) { return Double.POSITIVE_INFINITY; } else { return theta + lambda * FastMath.pow(-FastMath.log(1.0 - val), 1.0 / k); } }
java
public static double quantile(double val, double k, double lambda, double theta) { if(val < 0.0 || val > 1.0) { return Double.NaN; } else if(val == 0) { return 0.0; } else if(val == 1) { return Double.POSITIVE_INFINITY; } else { return theta + lambda * FastMath.pow(-FastMath.log(1.0 - val), 1.0 / k); } }
[ "public", "static", "double", "quantile", "(", "double", "val", ",", "double", "k", ",", "double", "lambda", ",", "double", "theta", ")", "{", "if", "(", "val", "<", "0.0", "||", "val", ">", "1.0", ")", "{", "return", "Double", ".", "NaN", ";", "}"...
Quantile function of Weibull distribution @param val Value @param k Shape parameter @param lambda Scale parameter @param theta Shift offset parameter @return Quantile function at position x.
[ "Quantile", "function", "of", "Weibull", "distribution" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/WeibullDistribution.java#L215-L228
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/PCARunner.java
PCARunner.processIds
public PCAResult processIds(DBIDs ids, Relation<? extends NumberVector> database) { return processCovarMatrix(covarianceMatrixBuilder.processIds(ids, database)); }
java
public PCAResult processIds(DBIDs ids, Relation<? extends NumberVector> database) { return processCovarMatrix(covarianceMatrixBuilder.processIds(ids, database)); }
[ "public", "PCAResult", "processIds", "(", "DBIDs", "ids", ",", "Relation", "<", "?", "extends", "NumberVector", ">", "database", ")", "{", "return", "processCovarMatrix", "(", "covarianceMatrixBuilder", ".", "processIds", "(", "ids", ",", "database", ")", ")", ...
Run PCA on a collection of database IDs. @param ids a collection of ids @param database the database used @return PCA result
[ "Run", "PCA", "on", "a", "collection", "of", "database", "IDs", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/PCARunner.java#L73-L75
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/PCARunner.java
PCARunner.processQueryResult
public PCAResult processQueryResult(DoubleDBIDList results, Relation<? extends NumberVector> database) { return processCovarMatrix(covarianceMatrixBuilder.processQueryResults(results, database)); }
java
public PCAResult processQueryResult(DoubleDBIDList results, Relation<? extends NumberVector> database) { return processCovarMatrix(covarianceMatrixBuilder.processQueryResults(results, database)); }
[ "public", "PCAResult", "processQueryResult", "(", "DoubleDBIDList", "results", ",", "Relation", "<", "?", "extends", "NumberVector", ">", "database", ")", "{", "return", "processCovarMatrix", "(", "covarianceMatrixBuilder", ".", "processQueryResults", "(", "results", ...
Run PCA on a QueryResult Collection. @param results a collection of QueryResults @param database the database used @return PCA result
[ "Run", "PCA", "on", "a", "QueryResult", "Collection", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/PCARunner.java#L84-L86
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/QRDecomposition.java
QRDecomposition.isFullRank
public boolean isFullRank() { // Find maximum: double t = 0.; for(int j = 0; j < n; j++) { double v = Rdiag[j]; if(v == 0) { return false; } v = Math.abs(v); t = v > t ? v : t; } t *= 1e-15; // Numerical precision threshold. for(int j = 1; j < n; j++) { if(Math.abs(Rdiag[j]) < t) { return false; } } return true; }
java
public boolean isFullRank() { // Find maximum: double t = 0.; for(int j = 0; j < n; j++) { double v = Rdiag[j]; if(v == 0) { return false; } v = Math.abs(v); t = v > t ? v : t; } t *= 1e-15; // Numerical precision threshold. for(int j = 1; j < n; j++) { if(Math.abs(Rdiag[j]) < t) { return false; } } return true; }
[ "public", "boolean", "isFullRank", "(", ")", "{", "// Find maximum:", "double", "t", "=", "0.", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "n", ";", "j", "++", ")", "{", "double", "v", "=", "Rdiag", "[", "j", "]", ";", "if", "(", "...
Is the matrix full rank? @return true if R, and hence A, has full rank.
[ "Is", "the", "matrix", "full", "rank?" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/QRDecomposition.java#L143-L161
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/QRDecomposition.java
QRDecomposition.rank
public int rank(double t) { int rank = n; for(int j = 0; j < n; j++) { if(Math.abs(Rdiag[j]) <= t) { --rank; } } return rank; }
java
public int rank(double t) { int rank = n; for(int j = 0; j < n; j++) { if(Math.abs(Rdiag[j]) <= t) { --rank; } } return rank; }
[ "public", "int", "rank", "(", "double", "t", ")", "{", "int", "rank", "=", "n", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "n", ";", "j", "++", ")", "{", "if", "(", "Math", ".", "abs", "(", "Rdiag", "[", "j", "]", ")", "<=", ...
Get the matrix rank? @param t Tolerance threshold @return Rank of R
[ "Get", "the", "matrix", "rank?" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/QRDecomposition.java#L169-L177
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/XYPlotVisualization.java
XYPlotVisualization.setupCSS
private void setupCSS(VisualizerContext context, SVGPlot svgp, XYPlot plot) { StyleLibrary style = context.getStyleLibrary(); for(XYPlot.Curve curve : plot) { CSSClass csscls = new CSSClass(this, SERIESID + curve.getColor()); // csscls.setStatement(SVGConstants.SVG_STROKE_WIDTH_ATTRIBUTE, "0.2%"); csscls.setStatement(SVGConstants.SVG_FILL_ATTRIBUTE, SVGConstants.SVG_NONE_VALUE); style.lines().formatCSSClass(csscls, curve.getColor(), style.getLineWidth(StyleLibrary.XYCURVE)); svgp.addCSSClassOrLogError(csscls); } // Axis label CSSClass label = new CSSClass(this, CSS_AXIS_LABEL); label.setStatement(SVGConstants.CSS_FILL_PROPERTY, style.getTextColor(StyleLibrary.XYCURVE)); label.setStatement(SVGConstants.CSS_FONT_FAMILY_PROPERTY, style.getFontFamily(StyleLibrary.XYCURVE)); label.setStatement(SVGConstants.CSS_FONT_SIZE_PROPERTY, style.getTextSize(StyleLibrary.XYCURVE)); label.setStatement(SVGConstants.CSS_TEXT_ANCHOR_PROPERTY, SVGConstants.CSS_MIDDLE_VALUE); svgp.addCSSClassOrLogError(label); svgp.updateStyleElement(); }
java
private void setupCSS(VisualizerContext context, SVGPlot svgp, XYPlot plot) { StyleLibrary style = context.getStyleLibrary(); for(XYPlot.Curve curve : plot) { CSSClass csscls = new CSSClass(this, SERIESID + curve.getColor()); // csscls.setStatement(SVGConstants.SVG_STROKE_WIDTH_ATTRIBUTE, "0.2%"); csscls.setStatement(SVGConstants.SVG_FILL_ATTRIBUTE, SVGConstants.SVG_NONE_VALUE); style.lines().formatCSSClass(csscls, curve.getColor(), style.getLineWidth(StyleLibrary.XYCURVE)); svgp.addCSSClassOrLogError(csscls); } // Axis label CSSClass label = new CSSClass(this, CSS_AXIS_LABEL); label.setStatement(SVGConstants.CSS_FILL_PROPERTY, style.getTextColor(StyleLibrary.XYCURVE)); label.setStatement(SVGConstants.CSS_FONT_FAMILY_PROPERTY, style.getFontFamily(StyleLibrary.XYCURVE)); label.setStatement(SVGConstants.CSS_FONT_SIZE_PROPERTY, style.getTextSize(StyleLibrary.XYCURVE)); label.setStatement(SVGConstants.CSS_TEXT_ANCHOR_PROPERTY, SVGConstants.CSS_MIDDLE_VALUE); svgp.addCSSClassOrLogError(label); svgp.updateStyleElement(); }
[ "private", "void", "setupCSS", "(", "VisualizerContext", "context", ",", "SVGPlot", "svgp", ",", "XYPlot", "plot", ")", "{", "StyleLibrary", "style", "=", "context", ".", "getStyleLibrary", "(", ")", ";", "for", "(", "XYPlot", ".", "Curve", "curve", ":", "...
Setup the CSS classes for the plot. @param svgp Plot @param plot Plot to render
[ "Setup", "the", "CSS", "classes", "for", "the", "plot", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/visunproj/XYPlotVisualization.java#L135-L152
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/EigenPair.java
EigenPair.compareTo
@Override public int compareTo(EigenPair o) { if(this.eigenvalue < o.eigenvalue) { return -1; } if(this.eigenvalue > o.eigenvalue) { return +1; } return 0; }
java
@Override public int compareTo(EigenPair o) { if(this.eigenvalue < o.eigenvalue) { return -1; } if(this.eigenvalue > o.eigenvalue) { return +1; } return 0; }
[ "@", "Override", "public", "int", "compareTo", "(", "EigenPair", "o", ")", "{", "if", "(", "this", ".", "eigenvalue", "<", "o", ".", "eigenvalue", ")", "{", "return", "-", "1", ";", "}", "if", "(", "this", ".", "eigenvalue", ">", "o", ".", "eigenva...
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object's eigenvalue is greater than, equal to, or less than the specified object's eigenvalue. @param o the Eigenvector to be compared. @return a negative integer, zero, or a positive integer as this object's eigenvalue is greater than, equal to, or less than the specified object's eigenvalue.
[ "Compares", "this", "object", "with", "the", "specified", "object", "for", "order", ".", "Returns", "a", "negative", "integer", "zero", "or", "a", "positive", "integer", "as", "this", "object", "s", "eigenvalue", "is", "greater", "than", "equal", "to", "or",...
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/EigenPair.java#L66-L75
train
elki-project/elki
elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/utilities/scaling/outlier/MixtureModelOutlierScaling.java
MixtureModelOutlierScaling.calcPosterior
protected static double calcPosterior(double f, double alpha, double mu, double sigma, double lambda) { final double pi = calcP_i(f, mu, sigma); final double qi = calcQ_i(f, lambda); return (alpha * pi) / (alpha * pi + (1.0 - alpha) * qi); }
java
protected static double calcPosterior(double f, double alpha, double mu, double sigma, double lambda) { final double pi = calcP_i(f, mu, sigma); final double qi = calcQ_i(f, lambda); return (alpha * pi) / (alpha * pi + (1.0 - alpha) * qi); }
[ "protected", "static", "double", "calcPosterior", "(", "double", "f", ",", "double", "alpha", ",", "double", "mu", ",", "double", "sigma", ",", "double", "lambda", ")", "{", "final", "double", "pi", "=", "calcP_i", "(", "f", ",", "mu", ",", "sigma", ")...
Compute the a posterior probability for the given parameters. @param f value @param alpha Alpha (mixing) parameter @param mu Mu (for gaussian) @param sigma Sigma (for gaussian) @param lambda Lambda (for exponential) @return Probability
[ "Compute", "the", "a", "posterior", "probability", "for", "the", "given", "parameters", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-outlier/src/main/java/de/lmu/ifi/dbs/elki/utilities/scaling/outlier/MixtureModelOutlierScaling.java#L129-L133
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/cash/CASHInterval.java
CASHInterval.split
public void split() { if(hasChildren()) { return; } final boolean issplit = (maxSplitDimension >= (getDimensionality() - 1)); final int childLevel = issplit ? level + 1 : level; final int splitDim = issplit ? 0 : maxSplitDimension + 1; final double splitPoint = getMin(splitDim) + (getMax(splitDim) - getMin(splitDim)) * .5; // left and right child for(int i = 0; i < 2; i++) { double[] min = SpatialUtil.getMin(this); // clone double[] max = SpatialUtil.getMax(this); // clone // right child if(i == 0) { min[splitDim] = splitPoint; } // left child else { max[splitDim] = splitPoint; } ModifiableDBIDs childIDs = split.determineIDs(getIDs(), new HyperBoundingBox(min, max), d_min, d_max); if(childIDs != null) { // right child if(i == 0) { rightChild = new CASHInterval(min, max, split, childIDs, splitDim, childLevel, d_min, d_max); } // left child else { leftChild = new CASHInterval(min, max, split, childIDs, splitDim, childLevel, d_min, d_max); } } } if(LOG.isDebuggingFine()) { StringBuilder msg = new StringBuilder(); msg.append("Child level ").append(childLevel).append(", split Dim ").append(splitDim); if(leftChild != null) { msg.append("\nleft ").append(leftChild); } if(rightChild != null) { msg.append("\nright ").append(rightChild); } LOG.fine(msg.toString()); } }
java
public void split() { if(hasChildren()) { return; } final boolean issplit = (maxSplitDimension >= (getDimensionality() - 1)); final int childLevel = issplit ? level + 1 : level; final int splitDim = issplit ? 0 : maxSplitDimension + 1; final double splitPoint = getMin(splitDim) + (getMax(splitDim) - getMin(splitDim)) * .5; // left and right child for(int i = 0; i < 2; i++) { double[] min = SpatialUtil.getMin(this); // clone double[] max = SpatialUtil.getMax(this); // clone // right child if(i == 0) { min[splitDim] = splitPoint; } // left child else { max[splitDim] = splitPoint; } ModifiableDBIDs childIDs = split.determineIDs(getIDs(), new HyperBoundingBox(min, max), d_min, d_max); if(childIDs != null) { // right child if(i == 0) { rightChild = new CASHInterval(min, max, split, childIDs, splitDim, childLevel, d_min, d_max); } // left child else { leftChild = new CASHInterval(min, max, split, childIDs, splitDim, childLevel, d_min, d_max); } } } if(LOG.isDebuggingFine()) { StringBuilder msg = new StringBuilder(); msg.append("Child level ").append(childLevel).append(", split Dim ").append(splitDim); if(leftChild != null) { msg.append("\nleft ").append(leftChild); } if(rightChild != null) { msg.append("\nright ").append(rightChild); } LOG.fine(msg.toString()); } }
[ "public", "void", "split", "(", ")", "{", "if", "(", "hasChildren", "(", ")", ")", "{", "return", ";", "}", "final", "boolean", "issplit", "=", "(", "maxSplitDimension", ">=", "(", "getDimensionality", "(", ")", "-", "1", ")", ")", ";", "final", "int...
Splits this interval into 2 children.
[ "Splits", "this", "interval", "into", "2", "children", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/cash/CASHInterval.java#L263-L311
train
elki-project/elki
elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/application/GeneratorXMLSpec.java
GeneratorXMLSpec.run
@Override public void run() { MultipleObjectsBundle data = generator.loadData(); if(LOG.isVerbose()) { LOG.verbose("Writing output ..."); } try { if(outputFile.exists() && LOG.isVerbose()) { LOG.verbose("The file " + outputFile + " already exists, " + "the generator result will be APPENDED."); } try (OutputStreamWriter outStream = new FileWriter(outputFile, true)) { writeClusters(outStream, data); } } catch(IOException e) { throw new AbortException("IO Error in data generator.", e); } if(LOG.isVerbose()) { LOG.verbose("Done."); } }
java
@Override public void run() { MultipleObjectsBundle data = generator.loadData(); if(LOG.isVerbose()) { LOG.verbose("Writing output ..."); } try { if(outputFile.exists() && LOG.isVerbose()) { LOG.verbose("The file " + outputFile + " already exists, " + "the generator result will be APPENDED."); } try (OutputStreamWriter outStream = new FileWriter(outputFile, true)) { writeClusters(outStream, data); } } catch(IOException e) { throw new AbortException("IO Error in data generator.", e); } if(LOG.isVerbose()) { LOG.verbose("Done."); } }
[ "@", "Override", "public", "void", "run", "(", ")", "{", "MultipleObjectsBundle", "data", "=", "generator", ".", "loadData", "(", ")", ";", "if", "(", "LOG", ".", "isVerbose", "(", ")", ")", "{", "LOG", ".", "verbose", "(", "\"Writing output ...\"", ")",...
Runs the wrapper with the specified arguments.
[ "Runs", "the", "wrapper", "with", "the", "specified", "arguments", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-data-generator/src/main/java/de/lmu/ifi/dbs/elki/application/GeneratorXMLSpec.java#L89-L110
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/random/RandomFactory.java
RandomFactory.getGlobalSeed
private static long getGlobalSeed() { String sseed = System.getProperty("elki.seed"); return (sseed != null) ? Long.parseLong(sseed) : System.nanoTime(); }
java
private static long getGlobalSeed() { String sseed = System.getProperty("elki.seed"); return (sseed != null) ? Long.parseLong(sseed) : System.nanoTime(); }
[ "private", "static", "long", "getGlobalSeed", "(", ")", "{", "String", "sseed", "=", "System", ".", "getProperty", "(", "\"elki.seed\"", ")", ";", "return", "(", "sseed", "!=", "null", ")", "?", "Long", ".", "parseLong", "(", "sseed", ")", ":", "System",...
Initialize the default random. @return seed for the random generator factory.
[ "Initialize", "the", "default", "random", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/random/RandomFactory.java#L57-L60
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/split/distribution/Assignments.java
Assignments.computeFirstCover
public double computeFirstCover(boolean leaf) { double max = 0.; for(DistanceEntry<E> e : firstAssignments) { double cover = leaf ? e.getDistance() : (e.getEntry().getCoveringRadius() + e.getDistance()); max = cover > max ? cover : max; } return max; }
java
public double computeFirstCover(boolean leaf) { double max = 0.; for(DistanceEntry<E> e : firstAssignments) { double cover = leaf ? e.getDistance() : (e.getEntry().getCoveringRadius() + e.getDistance()); max = cover > max ? cover : max; } return max; }
[ "public", "double", "computeFirstCover", "(", "boolean", "leaf", ")", "{", "double", "max", "=", "0.", ";", "for", "(", "DistanceEntry", "<", "E", ">", "e", ":", "firstAssignments", ")", "{", "double", "cover", "=", "leaf", "?", "e", ".", "getDistance", ...
Compute the covering radius of the first assignment. @param leaf {@code true} if in leaf mode. @return Covering radius.
[ "Compute", "the", "covering", "radius", "of", "the", "first", "assignment", "." ]
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/Assignments.java#L90-L97
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/strategies/split/distribution/Assignments.java
Assignments.computeSecondCover
public double computeSecondCover(boolean leaf) { double max = 0.; for(DistanceEntry<E> e : secondAssignments) { double cover = leaf ? e.getDistance() : (e.getEntry().getCoveringRadius() + e.getDistance()); max = cover > max ? cover : max; } return max; }
java
public double computeSecondCover(boolean leaf) { double max = 0.; for(DistanceEntry<E> e : secondAssignments) { double cover = leaf ? e.getDistance() : (e.getEntry().getCoveringRadius() + e.getDistance()); max = cover > max ? cover : max; } return max; }
[ "public", "double", "computeSecondCover", "(", "boolean", "leaf", ")", "{", "double", "max", "=", "0.", ";", "for", "(", "DistanceEntry", "<", "E", ">", "e", ":", "secondAssignments", ")", "{", "double", "cover", "=", "leaf", "?", "e", ".", "getDistance"...
Compute the covering radius of the second assignment. @param leaf {@code true} if in leaf mode. @return Covering radius.
[ "Compute", "the", "covering", "radius", "of", "the", "second", "assignment", "." ]
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/Assignments.java#L105-L112
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/UpdatableHeap.java
UpdatableHeap.offerAt
protected void offerAt(final int pos, O e) { if(pos == NO_VALUE) { // resize when needed if(size + 1 > queue.length) { resize(size + 1); } index.put(e, size); size++; heapifyUp(size - 1, e); heapModified(); return; } assert (pos >= 0) : "Unexpected negative position."; assert (queue[pos].equals(e)); // Did the value improve? if(comparator.compare(e, queue[pos]) >= 0) { return; } heapifyUp(pos, e); heapModified(); return; }
java
protected void offerAt(final int pos, O e) { if(pos == NO_VALUE) { // resize when needed if(size + 1 > queue.length) { resize(size + 1); } index.put(e, size); size++; heapifyUp(size - 1, e); heapModified(); return; } assert (pos >= 0) : "Unexpected negative position."; assert (queue[pos].equals(e)); // Did the value improve? if(comparator.compare(e, queue[pos]) >= 0) { return; } heapifyUp(pos, e); heapModified(); return; }
[ "protected", "void", "offerAt", "(", "final", "int", "pos", ",", "O", "e", ")", "{", "if", "(", "pos", "==", "NO_VALUE", ")", "{", "// resize when needed", "if", "(", "size", "+", "1", ">", "queue", ".", "length", ")", "{", "resize", "(", "size", "...
Offer element at the given position. @param pos Position @param e Element
[ "Offer", "element", "at", "the", "given", "position", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/UpdatableHeap.java#L111-L132
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/UpdatableHeap.java
UpdatableHeap.removeObject
public O removeObject(O e) { int pos = index.getInt(e); return (pos >= 0) ? removeAt(pos) : null; }
java
public O removeObject(O e) { int pos = index.getInt(e); return (pos >= 0) ? removeAt(pos) : null; }
[ "public", "O", "removeObject", "(", "O", "e", ")", "{", "int", "pos", "=", "index", ".", "getInt", "(", "e", ")", ";", "return", "(", "pos", ">=", "0", ")", "?", "removeAt", "(", "pos", ")", ":", "null", ";", "}" ]
Remove the given object from the queue. @param e Object to remove @return Existing entry
[ "Remove", "the", "given", "object", "from", "the", "queue", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/datastructures/heap/UpdatableHeap.java#L164-L167
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java
HSMDependenceMeasure.sumMatrix
private long sumMatrix(int[][] mat) { long ret = 0; for(int i = 0; i < mat.length; i++) { final int[] row = mat[i]; for(int j = 0; j < row.length; j++) { ret += row[j]; } } return ret; }
java
private long sumMatrix(int[][] mat) { long ret = 0; for(int i = 0; i < mat.length; i++) { final int[] row = mat[i]; for(int j = 0; j < row.length; j++) { ret += row[j]; } } return ret; }
[ "private", "long", "sumMatrix", "(", "int", "[", "]", "[", "]", "mat", ")", "{", "long", "ret", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mat", ".", "length", ";", "i", "++", ")", "{", "final", "int", "[", "]", "row",...
Compute the sum of a matrix. @param mat Matrix @return Sum of all elements
[ "Compute", "the", "sum", "of", "a", "matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java#L129-L138
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java
HSMDependenceMeasure.countAboveThreshold
private int countAboveThreshold(int[][] mat, double threshold) { int ret = 0; for(int i = 0; i < mat.length; i++) { int[] row = mat[i]; for(int j = 0; j < row.length; j++) { if(row[j] >= threshold) { ret++; } } } return ret; }
java
private int countAboveThreshold(int[][] mat, double threshold) { int ret = 0; for(int i = 0; i < mat.length; i++) { int[] row = mat[i]; for(int j = 0; j < row.length; j++) { if(row[j] >= threshold) { ret++; } } } return ret; }
[ "private", "int", "countAboveThreshold", "(", "int", "[", "]", "[", "]", "mat", ",", "double", "threshold", ")", "{", "int", "ret", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mat", ".", "length", ";", "i", "++", ")", "{", ...
Count the number of cells above the threshold. @param mat Matrix @param threshold Threshold @return Number of elements above the threshold.
[ "Count", "the", "number", "of", "cells", "above", "the", "threshold", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java#L147-L158
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java
HSMDependenceMeasure.houghTransformation
private int[][] houghTransformation(boolean[][] mat) { final int xres = mat.length, yres = mat[0].length; final double tscale = STEPS * .66 / (xres + yres); final int[][] ret = new int[STEPS][STEPS]; for(int x = 0; x < mat.length; x++) { final boolean[] row = mat[x]; for(int y = 0; y < mat[0].length; y++) { if(row[y]) { for(int i = 0; i < STEPS; i++) { final int d = (STEPS >> 1) + (int) (tscale * (x * table.cos(i) + y * table.sin(i))); if(d > 0 && d < STEPS) { ret[d][i]++; } } } } } return ret; }
java
private int[][] houghTransformation(boolean[][] mat) { final int xres = mat.length, yres = mat[0].length; final double tscale = STEPS * .66 / (xres + yres); final int[][] ret = new int[STEPS][STEPS]; for(int x = 0; x < mat.length; x++) { final boolean[] row = mat[x]; for(int y = 0; y < mat[0].length; y++) { if(row[y]) { for(int i = 0; i < STEPS; i++) { final int d = (STEPS >> 1) + (int) (tscale * (x * table.cos(i) + y * table.sin(i))); if(d > 0 && d < STEPS) { ret[d][i]++; } } } } } return ret; }
[ "private", "int", "[", "]", "[", "]", "houghTransformation", "(", "boolean", "[", "]", "[", "]", "mat", ")", "{", "final", "int", "xres", "=", "mat", ".", "length", ",", "yres", "=", "mat", "[", "0", "]", ".", "length", ";", "final", "double", "t...
Perform a hough transformation on the binary image in "mat". @param mat Binary image @return Hough transformation of image.
[ "Perform", "a", "hough", "transformation", "on", "the", "binary", "image", "in", "mat", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java#L166-L186
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java
HSMDependenceMeasure.drawLine
private static void drawLine(int x0, int y0, int x1, int y1, boolean[][] pic) { final int xres = pic.length, yres = pic[0].length; // Ensure bounds y0 = (y0 < 0) ? 0 : (y0 >= yres) ? (yres - 1) : y0; y1 = (y1 < 0) ? 0 : (y1 >= yres) ? (yres - 1) : y1; x0 = (x0 < 0) ? 0 : (x0 >= xres) ? (xres - 1) : x0; x1 = (x1 < 0) ? 0 : (x1 >= xres) ? (xres - 1) : x1; // Default slope final int dx = +Math.abs(x1 - x0), sx = x0 < x1 ? 1 : -1; final int dy = -Math.abs(y1 - y0), sy = y0 < y1 ? 1 : -1; // Error counter int err = dx + dy; for(;;) { pic[x0][y0] = true; if(x0 == x1 && y0 == y1) { break; } final int e2 = err << 1; if(e2 > dy) { err += dy; x0 += sx; } if(e2 < dx) { err += dx; y0 += sy; } } }
java
private static void drawLine(int x0, int y0, int x1, int y1, boolean[][] pic) { final int xres = pic.length, yres = pic[0].length; // Ensure bounds y0 = (y0 < 0) ? 0 : (y0 >= yres) ? (yres - 1) : y0; y1 = (y1 < 0) ? 0 : (y1 >= yres) ? (yres - 1) : y1; x0 = (x0 < 0) ? 0 : (x0 >= xres) ? (xres - 1) : x0; x1 = (x1 < 0) ? 0 : (x1 >= xres) ? (xres - 1) : x1; // Default slope final int dx = +Math.abs(x1 - x0), sx = x0 < x1 ? 1 : -1; final int dy = -Math.abs(y1 - y0), sy = y0 < y1 ? 1 : -1; // Error counter int err = dx + dy; for(;;) { pic[x0][y0] = true; if(x0 == x1 && y0 == y1) { break; } final int e2 = err << 1; if(e2 > dy) { err += dy; x0 += sx; } if(e2 < dx) { err += dx; y0 += sy; } } }
[ "private", "static", "void", "drawLine", "(", "int", "x0", ",", "int", "y0", ",", "int", "x1", ",", "int", "y1", ",", "boolean", "[", "]", "[", "]", "pic", ")", "{", "final", "int", "xres", "=", "pic", ".", "length", ",", "yres", "=", "pic", "[...
Draw a line onto the array, using the classic Bresenham algorithm. @param x0 Start X @param y0 Start Y @param x1 End X @param y1 End Y @param pic Picture array
[ "Draw", "a", "line", "onto", "the", "array", "using", "the", "classic", "Bresenham", "algorithm", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/HSMDependenceMeasure.java#L197-L226
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java
EnumParameter.getPossibleValues
public Collection<String> getPossibleValues() { // Convert to string array final E[] enums = enumClass.getEnumConstants(); ArrayList<String> values = new ArrayList<>(enums.length); for(E t : enums) { values.add(t.name()); } return values; }
java
public Collection<String> getPossibleValues() { // Convert to string array final E[] enums = enumClass.getEnumConstants(); ArrayList<String> values = new ArrayList<>(enums.length); for(E t : enums) { values.add(t.name()); } return values; }
[ "public", "Collection", "<", "String", ">", "getPossibleValues", "(", ")", "{", "// Convert to string array", "final", "E", "[", "]", "enums", "=", "enumClass", ".", "getEnumConstants", "(", ")", ";", "ArrayList", "<", "String", ">", "values", "=", "new", "A...
Get a list of possible values for this enum parameter. @return list of strings representing possible enum values.
[ "Get", "a", "list", "of", "possible", "values", "for", "this", "enum", "parameter", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java#L149-L157
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java
EnumParameter.joinEnumNames
private String joinEnumNames(String separator) { E[] enumTypes = enumClass.getEnumConstants(); StringBuilder sb = new StringBuilder(); for(int i = 0; i < enumTypes.length; ++i) { if(i > 0) { sb.append(separator); } sb.append(enumTypes[i].name()); } return sb.toString(); }
java
private String joinEnumNames(String separator) { E[] enumTypes = enumClass.getEnumConstants(); StringBuilder sb = new StringBuilder(); for(int i = 0; i < enumTypes.length; ++i) { if(i > 0) { sb.append(separator); } sb.append(enumTypes[i].name()); } return sb.toString(); }
[ "private", "String", "joinEnumNames", "(", "String", "separator", ")", "{", "E", "[", "]", "enumTypes", "=", "enumClass", ".", "getEnumConstants", "(", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "...
Utility method for merging possible values into a string for informational messages. @param separator char sequence to use as a separator for enum values. @return <code>{VAL1}{separator}{VAL2}{separator}...</code>
[ "Utility", "method", "for", "merging", "possible", "values", "into", "a", "string", "for", "informational", "messages", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/parameters/EnumParameter.java#L166-L176
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/mktrees/mkmax/MkMaxTree.java
MkMaxTree.preInsert
@Override protected void preInsert(MkMaxEntry entry) { KNNHeap knns_o = DBIDUtil.newHeap(getKmax()); preInsert(entry, getRootEntry(), knns_o); }
java
@Override protected void preInsert(MkMaxEntry entry) { KNNHeap knns_o = DBIDUtil.newHeap(getKmax()); preInsert(entry, getRootEntry(), knns_o); }
[ "@", "Override", "protected", "void", "preInsert", "(", "MkMaxEntry", "entry", ")", "{", "KNNHeap", "knns_o", "=", "DBIDUtil", ".", "newHeap", "(", "getKmax", "(", ")", ")", ";", "preInsert", "(", "entry", ",", "getRootEntry", "(", ")", ",", "knns_o", ")...
Adapts the knn distances before insertion of the specified entry.
[ "Adapts", "the", "knn", "distances", "before", "insertion", "of", "the", "specified", "entry", "." ]
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/mkmax/MkMaxTree.java#L128-L132
train
elki-project/elki
addons/xtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/xtree/util/SplitHistory.java
SplitHistory.getCommonDimensions
public static IntIterator getCommonDimensions(Collection<SplitHistory> splitHistories) { Iterator<SplitHistory> it = splitHistories.iterator(); long[] checkSet = BitsUtil.copy(it.next().dimBits); while(it.hasNext()) { SplitHistory sh = it.next(); BitsUtil.andI(checkSet, sh.dimBits); } return new BitsetIterator(checkSet); }
java
public static IntIterator getCommonDimensions(Collection<SplitHistory> splitHistories) { Iterator<SplitHistory> it = splitHistories.iterator(); long[] checkSet = BitsUtil.copy(it.next().dimBits); while(it.hasNext()) { SplitHistory sh = it.next(); BitsUtil.andI(checkSet, sh.dimBits); } return new BitsetIterator(checkSet); }
[ "public", "static", "IntIterator", "getCommonDimensions", "(", "Collection", "<", "SplitHistory", ">", "splitHistories", ")", "{", "Iterator", "<", "SplitHistory", ">", "it", "=", "splitHistories", ".", "iterator", "(", ")", ";", "long", "[", "]", "checkSet", ...
Get the common split dimensions from a list of split histories. @param splitHistories @return list of split dimensions
[ "Get", "the", "common", "split", "dimensions", "from", "a", "list", "of", "split", "histories", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/xtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/xtree/util/SplitHistory.java#L85-L93
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/ThumbnailRegistryEntry.java
ThumbnailRegistryEntry.handleURL
public static Filter handleURL(ParsedURL url) { if(LOG.isDebuggingFiner()) { LOG.debugFiner("handleURL " + url.toString()); } if(!isCompatibleURLStatic(url)) { return null; } int id; try { id = ParseUtil.parseIntBase10(url.getPath()); } catch(NumberFormatException e) { return null; } SoftReference<RenderedImage> ref = images.get(id); if(ref != null) { RenderedImage ri = ref.get(); if(ri == null) { LOG.warning("Referenced image has expired from the cache!"); } else { return new RedRable(GraphicsUtil.wrap(ri)); } } // Image not found in registry. return null; }
java
public static Filter handleURL(ParsedURL url) { if(LOG.isDebuggingFiner()) { LOG.debugFiner("handleURL " + url.toString()); } if(!isCompatibleURLStatic(url)) { return null; } int id; try { id = ParseUtil.parseIntBase10(url.getPath()); } catch(NumberFormatException e) { return null; } SoftReference<RenderedImage> ref = images.get(id); if(ref != null) { RenderedImage ri = ref.get(); if(ri == null) { LOG.warning("Referenced image has expired from the cache!"); } else { return new RedRable(GraphicsUtil.wrap(ri)); } } // Image not found in registry. return null; }
[ "public", "static", "Filter", "handleURL", "(", "ParsedURL", "url", ")", "{", "if", "(", "LOG", ".", "isDebuggingFiner", "(", ")", ")", "{", "LOG", ".", "debugFiner", "(", "\"handleURL \"", "+", "url", ".", "toString", "(", ")", ")", ";", "}", "if", ...
Statically handle the URL access. @param url URL to access @return Image, or null
[ "Statically", "handle", "the", "URL", "access", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/ThumbnailRegistryEntry.java#L161-L187
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateVarianceRatioCriteria.java
EvaluateVarianceRatioCriteria.globalCentroid
public static int globalCentroid(Centroid overallCentroid, Relation<? extends NumberVector> rel, List<? extends Cluster<?>> clusters, NumberVector[] centroids, NoiseHandling noiseOption) { int clustercount = 0; Iterator<? extends Cluster<?>> ci = clusters.iterator(); for(int i = 0; ci.hasNext(); i++) { Cluster<?> cluster = ci.next(); if(cluster.size() <= 1 || cluster.isNoise()) { switch(noiseOption){ case IGNORE_NOISE: continue; // Ignore completely case TREAT_NOISE_AS_SINGLETONS: clustercount += cluster.size(); // Update global centroid: for(DBIDIter it = cluster.getIDs().iter(); it.valid(); it.advance()) { overallCentroid.put(rel.get(it)); } continue; // With NEXT cluster. case MERGE_NOISE: break; // Treat as cluster below: } } // Update centroid: assert (centroids[i] != null); overallCentroid.put(centroids[i], cluster.size()); ++clustercount; } return clustercount; }
java
public static int globalCentroid(Centroid overallCentroid, Relation<? extends NumberVector> rel, List<? extends Cluster<?>> clusters, NumberVector[] centroids, NoiseHandling noiseOption) { int clustercount = 0; Iterator<? extends Cluster<?>> ci = clusters.iterator(); for(int i = 0; ci.hasNext(); i++) { Cluster<?> cluster = ci.next(); if(cluster.size() <= 1 || cluster.isNoise()) { switch(noiseOption){ case IGNORE_NOISE: continue; // Ignore completely case TREAT_NOISE_AS_SINGLETONS: clustercount += cluster.size(); // Update global centroid: for(DBIDIter it = cluster.getIDs().iter(); it.valid(); it.advance()) { overallCentroid.put(rel.get(it)); } continue; // With NEXT cluster. case MERGE_NOISE: break; // Treat as cluster below: } } // Update centroid: assert (centroids[i] != null); overallCentroid.put(centroids[i], cluster.size()); ++clustercount; } return clustercount; }
[ "public", "static", "int", "globalCentroid", "(", "Centroid", "overallCentroid", ",", "Relation", "<", "?", "extends", "NumberVector", ">", "rel", ",", "List", "<", "?", "extends", "Cluster", "<", "?", ">", ">", "clusters", ",", "NumberVector", "[", "]", "...
Update the global centroid. @param overallCentroid Centroid to udpate @param rel Data relation @param clusters Clusters @param centroids Cluster centroids @return Number of clusters
[ "Update", "the", "global", "centroid", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateVarianceRatioCriteria.java#L190-L216
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerPrototypeHierarchyRepresentationResult.java
PointerPrototypeHierarchyRepresentationResult.findPrototype
public DBID findPrototype(DBIDs members) { // Find the last merge within the cluster. // The object with maximum priority will merge outside of the cluster, // So we need the second largest priority. DBIDIter it = members.iter(); DBIDVar proto = DBIDUtil.newVar(it), last = DBIDUtil.newVar(it); int maxprio = Integer.MIN_VALUE, secprio = Integer.MIN_VALUE; for(; it.valid(); it.advance()) { int prio = mergeOrder.intValue(it); if(prio > maxprio) { secprio = maxprio; proto.set(last); maxprio = prio; last.set(it); } else if(prio > secprio) { secprio = prio; proto.set(it); } } return DBIDUtil.deref(prototypes.assignVar(proto, proto)); }
java
public DBID findPrototype(DBIDs members) { // Find the last merge within the cluster. // The object with maximum priority will merge outside of the cluster, // So we need the second largest priority. DBIDIter it = members.iter(); DBIDVar proto = DBIDUtil.newVar(it), last = DBIDUtil.newVar(it); int maxprio = Integer.MIN_VALUE, secprio = Integer.MIN_VALUE; for(; it.valid(); it.advance()) { int prio = mergeOrder.intValue(it); if(prio > maxprio) { secprio = maxprio; proto.set(last); maxprio = prio; last.set(it); } else if(prio > secprio) { secprio = prio; proto.set(it); } } return DBIDUtil.deref(prototypes.assignVar(proto, proto)); }
[ "public", "DBID", "findPrototype", "(", "DBIDs", "members", ")", "{", "// Find the last merge within the cluster.", "// The object with maximum priority will merge outside of the cluster,", "// So we need the second largest priority.", "DBIDIter", "it", "=", "members", ".", "iter", ...
Extract the prototype of a given cluster. When the argument is not a valid cluster of this Pointer Hierarchy, the return value is unspecified. @param members Cluster members @return The prototype of the cluster
[ "Extract", "the", "prototype", "of", "a", "given", "cluster", ".", "When", "the", "argument", "is", "not", "a", "valid", "cluster", "of", "this", "Pointer", "Hierarchy", "the", "return", "value", "is", "unspecified", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/PointerPrototypeHierarchyRepresentationResult.java#L86-L107
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/SimplifiedCoverTree.java
SimplifiedCoverTree.bulkLoad
public void bulkLoad(DBIDs ids) { if(ids.size() == 0) { return; } assert (root == null) : "Tree already initialized."; DBIDIter it = ids.iter(); DBID first = DBIDUtil.deref(it); // Compute distances to all neighbors: ModifiableDoubleDBIDList candidates = DBIDUtil.newDistanceDBIDList(ids.size() - 1); for(it.advance(); it.valid(); it.advance()) { candidates.add(distance(first, it), it); } root = bulkConstruct(first, Integer.MAX_VALUE, candidates); }
java
public void bulkLoad(DBIDs ids) { if(ids.size() == 0) { return; } assert (root == null) : "Tree already initialized."; DBIDIter it = ids.iter(); DBID first = DBIDUtil.deref(it); // Compute distances to all neighbors: ModifiableDoubleDBIDList candidates = DBIDUtil.newDistanceDBIDList(ids.size() - 1); for(it.advance(); it.valid(); it.advance()) { candidates.add(distance(first, it), it); } root = bulkConstruct(first, Integer.MAX_VALUE, candidates); }
[ "public", "void", "bulkLoad", "(", "DBIDs", "ids", ")", "{", "if", "(", "ids", ".", "size", "(", ")", "==", "0", ")", "{", "return", ";", "}", "assert", "(", "root", "==", "null", ")", ":", "\"Tree already initialized.\"", ";", "DBIDIter", "it", "=",...
Bulk-load the index. @param ids IDs to load
[ "Bulk", "-", "load", "the", "index", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/SimplifiedCoverTree.java#L179-L192
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/SimplifiedCoverTree.java
SimplifiedCoverTree.checkCoverTree
private void checkCoverTree(Node cur, int[] counts, int depth) { counts[0] += 1; // Node count counts[1] += depth; // Sum of depth counts[2] = depth > counts[2] ? depth : counts[2]; // Max depth counts[3] += cur.singletons.size() - 1; counts[4] += cur.singletons.size() - (cur.children == null ? 0 : 1); if(cur.children != null) { ++depth; for(Node chi : cur.children) { checkCoverTree(chi, counts, depth); } assert (!cur.children.isEmpty()) : "Empty childs list."; } }
java
private void checkCoverTree(Node cur, int[] counts, int depth) { counts[0] += 1; // Node count counts[1] += depth; // Sum of depth counts[2] = depth > counts[2] ? depth : counts[2]; // Max depth counts[3] += cur.singletons.size() - 1; counts[4] += cur.singletons.size() - (cur.children == null ? 0 : 1); if(cur.children != null) { ++depth; for(Node chi : cur.children) { checkCoverTree(chi, counts, depth); } assert (!cur.children.isEmpty()) : "Empty childs list."; } }
[ "private", "void", "checkCoverTree", "(", "Node", "cur", ",", "int", "[", "]", "counts", ",", "int", "depth", ")", "{", "counts", "[", "0", "]", "+=", "1", ";", "// Node count", "counts", "[", "1", "]", "+=", "depth", ";", "// Sum of depth", "counts", ...
Collect some statistics on the tree. @param cur Current node @param counts Counter set @param depth Current depth
[ "Collect", "some", "statistics", "on", "the", "tree", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/SimplifiedCoverTree.java#L269-L282
train