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-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/MultipleObjectsBundle.java
MultipleObjectsBundle.getRow
public Object[] getRow(int row) { Object[] ret = new Object[columns.size()]; for(int c = 0; c < columns.size(); c++) { ret[c] = data(row, c); } return ret; }
java
public Object[] getRow(int row) { Object[] ret = new Object[columns.size()]; for(int c = 0; c < columns.size(); c++) { ret[c] = data(row, c); } return ret; }
[ "public", "Object", "[", "]", "getRow", "(", "int", "row", ")", "{", "Object", "[", "]", "ret", "=", "new", "Object", "[", "columns", ".", "size", "(", ")", "]", ";", "for", "(", "int", "c", "=", "0", ";", "c", "<", "columns", ".", "size", "(...
Get an object row. @param row Row number @return Array of values
[ "Get", "an", "object", "row", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/datasource/bundle/MultipleObjectsBundle.java#L294-L300
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeKNNQuery.java
RStarTreeKNNQuery.batchNN
protected void batchNN(AbstractRStarTreeNode<?, ?> node, Map<DBID, KNNHeap> knnLists) { if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { SpatialEntry p = node.getEntry(i); for(Entry<DBID, KNNHeap> ent : knnLists.entrySet()) { final DBID q = ent.getKey(); final KNNHeap knns_q = ent.getValue(); double knn_q_maxDist = knns_q.getKNNDistance(); DBID pid = ((LeafEntry) p).getDBID(); // FIXME: objects are NOT accessible by DBID in a plain R-tree // context! double dist_pq = distanceFunction.distance(relation.get(pid), relation.get(q)); tree.statistics.countDistanceCalculation(); if(dist_pq <= knn_q_maxDist) { knns_q.insert(dist_pq, pid); } } } } else { ModifiableDBIDs ids = DBIDUtil.newArray(knnLists.size()); for(DBID id : knnLists.keySet()) { ids.add(id); } List<DoubleDistanceEntry> entries = getSortedEntries(node, ids); for(DoubleDistanceEntry distEntry : entries) { double minDist = distEntry.distance; for(Entry<DBID, KNNHeap> ent : knnLists.entrySet()) { final KNNHeap knns_q = ent.getValue(); double knn_q_maxDist = knns_q.getKNNDistance(); if(minDist <= knn_q_maxDist) { SpatialEntry entry = distEntry.entry; AbstractRStarTreeNode<?, ?> child = tree.getNode(((DirectoryEntry) entry).getPageID()); batchNN(child, knnLists); break; } } } } }
java
protected void batchNN(AbstractRStarTreeNode<?, ?> node, Map<DBID, KNNHeap> knnLists) { if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { SpatialEntry p = node.getEntry(i); for(Entry<DBID, KNNHeap> ent : knnLists.entrySet()) { final DBID q = ent.getKey(); final KNNHeap knns_q = ent.getValue(); double knn_q_maxDist = knns_q.getKNNDistance(); DBID pid = ((LeafEntry) p).getDBID(); // FIXME: objects are NOT accessible by DBID in a plain R-tree // context! double dist_pq = distanceFunction.distance(relation.get(pid), relation.get(q)); tree.statistics.countDistanceCalculation(); if(dist_pq <= knn_q_maxDist) { knns_q.insert(dist_pq, pid); } } } } else { ModifiableDBIDs ids = DBIDUtil.newArray(knnLists.size()); for(DBID id : knnLists.keySet()) { ids.add(id); } List<DoubleDistanceEntry> entries = getSortedEntries(node, ids); for(DoubleDistanceEntry distEntry : entries) { double minDist = distEntry.distance; for(Entry<DBID, KNNHeap> ent : knnLists.entrySet()) { final KNNHeap knns_q = ent.getValue(); double knn_q_maxDist = knns_q.getKNNDistance(); if(minDist <= knn_q_maxDist) { SpatialEntry entry = distEntry.entry; AbstractRStarTreeNode<?, ?> child = tree.getNode(((DirectoryEntry) entry).getPageID()); batchNN(child, knnLists); break; } } } } }
[ "protected", "void", "batchNN", "(", "AbstractRStarTreeNode", "<", "?", ",", "?", ">", "node", ",", "Map", "<", "DBID", ",", "KNNHeap", ">", "knnLists", ")", "{", "if", "(", "node", ".", "isLeaf", "(", ")", ")", "{", "for", "(", "int", "i", "=", ...
Performs a batch knn query. @param node the node for which the query should be performed @param knnLists a map containing the knn lists for each query objects
[ "Performs", "a", "batch", "knn", "query", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeKNNQuery.java#L163-L204
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeKNNQuery.java
RStarTreeKNNQuery.getSortedEntries
protected List<DoubleDistanceEntry> getSortedEntries(AbstractRStarTreeNode<?, ?> node, DBIDs ids) { List<DoubleDistanceEntry> result = new ArrayList<>(); for(int i = 0; i < node.getNumEntries(); i++) { SpatialEntry entry = node.getEntry(i); double minMinDist = Double.MAX_VALUE; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double minDist = distanceFunction.minDist(entry, relation.get(iter)); tree.statistics.countDistanceCalculation(); minMinDist = Math.min(minDist, minMinDist); } result.add(new DoubleDistanceEntry(entry, minMinDist)); } Collections.sort(result); return result; }
java
protected List<DoubleDistanceEntry> getSortedEntries(AbstractRStarTreeNode<?, ?> node, DBIDs ids) { List<DoubleDistanceEntry> result = new ArrayList<>(); for(int i = 0; i < node.getNumEntries(); i++) { SpatialEntry entry = node.getEntry(i); double minMinDist = Double.MAX_VALUE; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { double minDist = distanceFunction.minDist(entry, relation.get(iter)); tree.statistics.countDistanceCalculation(); minMinDist = Math.min(minDist, minMinDist); } result.add(new DoubleDistanceEntry(entry, minMinDist)); } Collections.sort(result); return result; }
[ "protected", "List", "<", "DoubleDistanceEntry", ">", "getSortedEntries", "(", "AbstractRStarTreeNode", "<", "?", ",", "?", ">", "node", ",", "DBIDs", "ids", ")", "{", "List", "<", "DoubleDistanceEntry", ">", "result", "=", "new", "ArrayList", "<>", "(", ")"...
Sorts the entries of the specified node according to their minimum distance to the specified objects. @param node the node @param ids the id of the objects @return a list of the sorted entries
[ "Sorts", "the", "entries", "of", "the", "specified", "node", "according", "to", "their", "minimum", "distance", "to", "the", "specified", "objects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/query/RStarTreeKNNQuery.java#L214-L230
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/FilteredConvexHull2D.java
FilteredConvexHull2D.checkCandidateUpdate
private boolean checkCandidateUpdate(double[] point) { final double x = point[0], y = point[1]; if(points.isEmpty()) { leftx = rightx = x; topy = bottomy = y; topleft = topright = bottomleft = bottomright = point; return true; } // A non-regular diamond spanned by left, top, right, and bottom. if(x <= leftx || x >= rightx || y <= bottomy || y >= topy) { double xpy = x + y, xmy = x - y; // Update bounds: boolean changed = false; if(xpy < bottomleft[0] + bottomleft[1]) { bottomleft = point; changed = true; } else if(xpy > topright[0] + topright[1]) { topright = point; changed = true; } if(xmy < topleft[0] - topleft[1]) { topleft = point; changed = true; } else if(xmy > bottomright[0] - bottomright[1]) { bottomright = point; changed = true; } if(changed) { leftx = Math.max(bottomleft[0], topleft[0]); rightx = Math.min(bottomright[0], topright[0]); topy = Math.min(topleft[1], topright[1]); bottomy = Math.max(bottomleft[1], bottomright[1]); } return true; } return false; }
java
private boolean checkCandidateUpdate(double[] point) { final double x = point[0], y = point[1]; if(points.isEmpty()) { leftx = rightx = x; topy = bottomy = y; topleft = topright = bottomleft = bottomright = point; return true; } // A non-regular diamond spanned by left, top, right, and bottom. if(x <= leftx || x >= rightx || y <= bottomy || y >= topy) { double xpy = x + y, xmy = x - y; // Update bounds: boolean changed = false; if(xpy < bottomleft[0] + bottomleft[1]) { bottomleft = point; changed = true; } else if(xpy > topright[0] + topright[1]) { topright = point; changed = true; } if(xmy < topleft[0] - topleft[1]) { topleft = point; changed = true; } else if(xmy > bottomright[0] - bottomright[1]) { bottomright = point; changed = true; } if(changed) { leftx = Math.max(bottomleft[0], topleft[0]); rightx = Math.min(bottomright[0], topright[0]); topy = Math.min(topleft[1], topright[1]); bottomy = Math.max(bottomleft[1], bottomright[1]); } return true; } return false; }
[ "private", "boolean", "checkCandidateUpdate", "(", "double", "[", "]", "point", ")", "{", "final", "double", "x", "=", "point", "[", "0", "]", ",", "y", "=", "point", "[", "1", "]", ";", "if", "(", "points", ".", "isEmpty", "(", ")", ")", "{", "l...
Check whether a point is inside the current bounds, and update the bounds @param point New point @return {@code true} if the point is potentially on the hull
[ "Check", "whether", "a", "point", "is", "inside", "the", "current", "bounds", "and", "update", "the", "bounds" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/geometry/FilteredConvexHull2D.java#L116-L154
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/CLARA.java
CLARA.randomSample
static DBIDs randomSample(DBIDs ids, int samplesize, Random rnd, DBIDs previous) { if(previous == null) { return DBIDUtil.randomSample(ids, samplesize, rnd); } ModifiableDBIDs sample = DBIDUtil.newHashSet(samplesize); sample.addDBIDs(previous); sample.addDBIDs(DBIDUtil.randomSample(ids, samplesize - previous.size(), rnd)); // If these two were not disjoint, we can be short of the desired size! if(sample.size() < samplesize) { // Draw a large enough sample to make sure to be able to fill it now. // This can be less random though, because the iterator may impose an // order; but this is a rare code path. for(DBIDIter it = DBIDUtil.randomSample(ids, samplesize, rnd).iter(); sample.size() < samplesize && it.valid(); it.advance()) { sample.add(it); } } return sample; }
java
static DBIDs randomSample(DBIDs ids, int samplesize, Random rnd, DBIDs previous) { if(previous == null) { return DBIDUtil.randomSample(ids, samplesize, rnd); } ModifiableDBIDs sample = DBIDUtil.newHashSet(samplesize); sample.addDBIDs(previous); sample.addDBIDs(DBIDUtil.randomSample(ids, samplesize - previous.size(), rnd)); // If these two were not disjoint, we can be short of the desired size! if(sample.size() < samplesize) { // Draw a large enough sample to make sure to be able to fill it now. // This can be less random though, because the iterator may impose an // order; but this is a rare code path. for(DBIDIter it = DBIDUtil.randomSample(ids, samplesize, rnd).iter(); sample.size() < samplesize && it.valid(); it.advance()) { sample.add(it); } } return sample; }
[ "static", "DBIDs", "randomSample", "(", "DBIDs", "ids", ",", "int", "samplesize", ",", "Random", "rnd", ",", "DBIDs", "previous", ")", "{", "if", "(", "previous", "==", "null", ")", "{", "return", "DBIDUtil", ".", "randomSample", "(", "ids", ",", "sample...
Draw a random sample of the desired size. @param ids IDs to sample from @param samplesize Sample size @param rnd Random generator @param previous Previous medoids to always include in the sample. @return Sample
[ "Draw", "a", "random", "sample", "of", "the", "desired", "size", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/CLARA.java#L205-L222
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/configurator/FileParameterConfigurator.java
FileParameterConfigurator.actionPerformed
@Override public void actionPerformed(ActionEvent e) { // Use a new JFileChooser. Inconsistent behaviour otherwise! final JFileChooser fc = new JFileChooser(new File(".")); if(param.isDefined()) { fc.setSelectedFile(param.getValue()); } if(e.getSource() == button) { int returnVal = fc.showOpenDialog(button); if(returnVal == JFileChooser.APPROVE_OPTION) { textfield.setText(fc.getSelectedFile().getPath()); fireValueChanged(); } // else: do nothing on cancel. } else if(e.getSource() == textfield) { fireValueChanged(); } else { LoggingUtil.warning("actionPerformed triggered by unknown source: " + e.getSource()); } }
java
@Override public void actionPerformed(ActionEvent e) { // Use a new JFileChooser. Inconsistent behaviour otherwise! final JFileChooser fc = new JFileChooser(new File(".")); if(param.isDefined()) { fc.setSelectedFile(param.getValue()); } if(e.getSource() == button) { int returnVal = fc.showOpenDialog(button); if(returnVal == JFileChooser.APPROVE_OPTION) { textfield.setText(fc.getSelectedFile().getPath()); fireValueChanged(); } // else: do nothing on cancel. } else if(e.getSource() == textfield) { fireValueChanged(); } else { LoggingUtil.warning("actionPerformed triggered by unknown source: " + e.getSource()); } }
[ "@", "Override", "public", "void", "actionPerformed", "(", "ActionEvent", "e", ")", "{", "// Use a new JFileChooser. Inconsistent behaviour otherwise!", "final", "JFileChooser", "fc", "=", "new", "JFileChooser", "(", "new", "File", "(", "\".\"", ")", ")", ";", "if",...
Button callback to show the file selector
[ "Button", "callback", "to", "show", "the", "file", "selector" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/configurator/FileParameterConfigurator.java#L97-L119
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/CloneInlineImages.java
CloneInlineImages.inlineThumbnail
protected Node inlineThumbnail(Document doc, ParsedURL urldata, Node eold) { RenderableImage img = ThumbnailRegistryEntry.handleURL(urldata); if(img == null) { LoggingUtil.warning("Image not found in registry: " + urldata.toString()); return null; } ByteArrayOutputStream os = new ByteArrayOutputStream(); try { os.write(SVGSyntax.DATA_PROTOCOL_PNG_PREFIX.getBytes()); Base64EncoderStream encoder = new Base64EncoderStream(os); ImageIO.write(img.createDefaultRendering(), "png", encoder); encoder.close(); } catch(IOException e) { LoggingUtil.exception("Exception serializing image to png", e); return null; } Element i = (Element) super.cloneNode(doc, eold); i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE, os.toString().replaceAll("\\s*[\\r\\n]+\\s*", "")); return i; }
java
protected Node inlineThumbnail(Document doc, ParsedURL urldata, Node eold) { RenderableImage img = ThumbnailRegistryEntry.handleURL(urldata); if(img == null) { LoggingUtil.warning("Image not found in registry: " + urldata.toString()); return null; } ByteArrayOutputStream os = new ByteArrayOutputStream(); try { os.write(SVGSyntax.DATA_PROTOCOL_PNG_PREFIX.getBytes()); Base64EncoderStream encoder = new Base64EncoderStream(os); ImageIO.write(img.createDefaultRendering(), "png", encoder); encoder.close(); } catch(IOException e) { LoggingUtil.exception("Exception serializing image to png", e); return null; } Element i = (Element) super.cloneNode(doc, eold); i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE, os.toString().replaceAll("\\s*[\\r\\n]+\\s*", "")); return i; }
[ "protected", "Node", "inlineThumbnail", "(", "Document", "doc", ",", "ParsedURL", "urldata", ",", "Node", "eold", ")", "{", "RenderableImage", "img", "=", "ThumbnailRegistryEntry", ".", "handleURL", "(", "urldata", ")", ";", "if", "(", "img", "==", "null", "...
Inline a referenced thumbnail. @param doc Document (element factory) @param urldata URL @param eold Existing node @return Replacement node, or {@code null}
[ "Inline", "a", "referenced", "thumbnail", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/batikutil/CloneInlineImages.java#L81-L101
train
elki-project/elki
elki-precomputed/src/main/java/de/lmu/ifi/dbs/elki/application/cache/PrecomputeDistancesAsciiApplication.java
PrecomputeDistancesAsciiApplication.openStream
private static PrintStream openStream(File out) throws IOException { OutputStream os = new FileOutputStream(out); os = out.getName().endsWith(GZIP_POSTFIX) ? new GZIPOutputStream(os) : os; return new PrintStream(os); }
java
private static PrintStream openStream(File out) throws IOException { OutputStream os = new FileOutputStream(out); os = out.getName().endsWith(GZIP_POSTFIX) ? new GZIPOutputStream(os) : os; return new PrintStream(os); }
[ "private", "static", "PrintStream", "openStream", "(", "File", "out", ")", "throws", "IOException", "{", "OutputStream", "os", "=", "new", "FileOutputStream", "(", "out", ")", ";", "os", "=", "out", ".", "getName", "(", ")", ".", "endsWith", "(", "GZIP_POS...
Open the output stream, using gzip if necessary. @param out Output file name. @return Output stream @throws IOException
[ "Open", "the", "output", "stream", "using", "gzip", "if", "necessary", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-precomputed/src/main/java/de/lmu/ifi/dbs/elki/application/cache/PrecomputeDistancesAsciiApplication.java#L152-L156
train
elki-project/elki
elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/SparseShortVector.java
SparseShortVector.setDimensionality
@Override public void setDimensionality(int dimensionality) throws IllegalArgumentException { final int maxdim = getMaxDim(); if(maxdim > dimensionality) { throw new IllegalArgumentException("Given dimensionality " + dimensionality + " is too small w.r.t. the given values (occurring maximum: " + maxdim + ")."); } this.dimensionality = dimensionality; }
java
@Override public void setDimensionality(int dimensionality) throws IllegalArgumentException { final int maxdim = getMaxDim(); if(maxdim > dimensionality) { throw new IllegalArgumentException("Given dimensionality " + dimensionality + " is too small w.r.t. the given values (occurring maximum: " + maxdim + ")."); } this.dimensionality = dimensionality; }
[ "@", "Override", "public", "void", "setDimensionality", "(", "int", "dimensionality", ")", "throws", "IllegalArgumentException", "{", "final", "int", "maxdim", "=", "getMaxDim", "(", ")", ";", "if", "(", "maxdim", ">", "dimensionality", ")", "{", "throw", "new...
Sets the dimensionality to the new value. @param dimensionality the new dimensionality @throws IllegalArgumentException if the given dimensionality is too small to cover the given values (i.e., the maximum index of any value not zero is bigger than the given dimensionality)
[ "Sets", "the", "dimensionality", "to", "the", "new", "value", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-data/src/main/java/de/lmu/ifi/dbs/elki/data/SparseShortVector.java#L189-L196
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.findPathToObject
protected IndexTreePath<E> findPathToObject(IndexTreePath<E> subtree, SpatialComparable mbr, DBIDRef id) { N node = getNode(subtree.getEntry()); if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { if(DBIDUtil.equal(((LeafEntry) node.getEntry(i)).getDBID(), id)) { return new IndexTreePath<>(subtree, node.getEntry(i), i); } } } // directory node else { for(int i = 0; i < node.getNumEntries(); i++) { if(SpatialUtil.intersects(node.getEntry(i), mbr)) { IndexTreePath<E> childSubtree = new IndexTreePath<>(subtree, node.getEntry(i), i); IndexTreePath<E> path = findPathToObject(childSubtree, mbr, id); if(path != null) { return path; } } } } return null; }
java
protected IndexTreePath<E> findPathToObject(IndexTreePath<E> subtree, SpatialComparable mbr, DBIDRef id) { N node = getNode(subtree.getEntry()); if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { if(DBIDUtil.equal(((LeafEntry) node.getEntry(i)).getDBID(), id)) { return new IndexTreePath<>(subtree, node.getEntry(i), i); } } } // directory node else { for(int i = 0; i < node.getNumEntries(); i++) { if(SpatialUtil.intersects(node.getEntry(i), mbr)) { IndexTreePath<E> childSubtree = new IndexTreePath<>(subtree, node.getEntry(i), i); IndexTreePath<E> path = findPathToObject(childSubtree, mbr, id); if(path != null) { return path; } } } } return null; }
[ "protected", "IndexTreePath", "<", "E", ">", "findPathToObject", "(", "IndexTreePath", "<", "E", ">", "subtree", ",", "SpatialComparable", "mbr", ",", "DBIDRef", "id", ")", "{", "N", "node", "=", "getNode", "(", "subtree", ".", "getEntry", "(", ")", ")", ...
Returns the path to the leaf entry in the specified subtree that represents the data object with the specified mbr and id. @param subtree the subtree to be tested @param mbr the mbr to look for @param id the id to look for @return the path to the leaf entry of the specified subtree that represents the data object with the specified mbr and id
[ "Returns", "the", "path", "to", "the", "leaf", "entry", "in", "the", "specified", "subtree", "that", "represents", "the", "data", "object", "with", "the", "specified", "mbr", "and", "id", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L116-L138
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.deletePath
protected void deletePath(IndexTreePath<E> deletionPath) { N leaf = getNode(deletionPath.getParentPath().getEntry()); int index = deletionPath.getIndex(); // delete o E entry = leaf.getEntry(index); leaf.deleteEntry(index); writeNode(leaf); // condense the tree Stack<N> stack = new Stack<>(); condenseTree(deletionPath.getParentPath(), stack); // reinsert underflow nodes while(!stack.empty()) { N node = stack.pop(); if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { settings.getOverflowTreatment().reinitialize(); // Intended? this.insertLeafEntry(node.getEntry(i)); } } else { for(int i = 0; i < node.getNumEntries(); i++) { stack.push(getNode(node.getEntry(i))); } } deleteNode(node); } postDelete(entry); doExtraIntegrityChecks(); }
java
protected void deletePath(IndexTreePath<E> deletionPath) { N leaf = getNode(deletionPath.getParentPath().getEntry()); int index = deletionPath.getIndex(); // delete o E entry = leaf.getEntry(index); leaf.deleteEntry(index); writeNode(leaf); // condense the tree Stack<N> stack = new Stack<>(); condenseTree(deletionPath.getParentPath(), stack); // reinsert underflow nodes while(!stack.empty()) { N node = stack.pop(); if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { settings.getOverflowTreatment().reinitialize(); // Intended? this.insertLeafEntry(node.getEntry(i)); } } else { for(int i = 0; i < node.getNumEntries(); i++) { stack.push(getNode(node.getEntry(i))); } } deleteNode(node); } postDelete(entry); doExtraIntegrityChecks(); }
[ "protected", "void", "deletePath", "(", "IndexTreePath", "<", "E", ">", "deletionPath", ")", "{", "N", "leaf", "=", "getNode", "(", "deletionPath", ".", "getParentPath", "(", ")", ".", "getEntry", "(", ")", ")", ";", "int", "index", "=", "deletionPath", ...
Delete a leaf at a given path - deletions for non-leaves are not supported! @param deletionPath Path to delete
[ "Delete", "a", "leaf", "at", "a", "given", "path", "-", "deletions", "for", "non", "-", "leaves", "are", "not", "supported!" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L203-L235
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.createBulkLeafNodes
protected List<E> createBulkLeafNodes(List<E> objects) { int minEntries = leafMinimum; int maxEntries = leafCapacity; ArrayList<E> result = new ArrayList<>(); List<List<E>> partitions = settings.bulkSplitter.partition(objects, minEntries, maxEntries); for(List<E> partition : partitions) { // create leaf node N leafNode = createNewLeafNode(); // insert data for(E o : partition) { leafNode.addLeafEntry(o); } // write to file writeNode(leafNode); result.add(createNewDirectoryEntry(leafNode)); if(getLogger().isDebugging()) { getLogger().debugFine("Created leaf page " + leafNode.getPageID()); } } if(getLogger().isDebugging()) { getLogger().debugFine("numDataPages = " + result.size()); } return result; }
java
protected List<E> createBulkLeafNodes(List<E> objects) { int minEntries = leafMinimum; int maxEntries = leafCapacity; ArrayList<E> result = new ArrayList<>(); List<List<E>> partitions = settings.bulkSplitter.partition(objects, minEntries, maxEntries); for(List<E> partition : partitions) { // create leaf node N leafNode = createNewLeafNode(); // insert data for(E o : partition) { leafNode.addLeafEntry(o); } // write to file writeNode(leafNode); result.add(createNewDirectoryEntry(leafNode)); if(getLogger().isDebugging()) { getLogger().debugFine("Created leaf page " + leafNode.getPageID()); } } if(getLogger().isDebugging()) { getLogger().debugFine("numDataPages = " + result.size()); } return result; }
[ "protected", "List", "<", "E", ">", "createBulkLeafNodes", "(", "List", "<", "E", ">", "objects", ")", "{", "int", "minEntries", "=", "leafMinimum", ";", "int", "maxEntries", "=", "leafCapacity", ";", "ArrayList", "<", "E", ">", "result", "=", "new", "Ar...
Creates and returns the leaf nodes for bulk load. @param objects the objects to be inserted @return the array of leaf nodes containing the objects
[ "Creates", "and", "returns", "the", "leaf", "nodes", "for", "bulk", "load", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L337-L366
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.choosePath
protected IndexTreePath<E> choosePath(IndexTreePath<E> subtree, SpatialComparable mbr, int depth, int cur) { if(getLogger().isDebuggingFiner()) { getLogger().debugFiner("node " + subtree + ", depth " + depth); } N node = getNode(subtree.getEntry()); if(node == null) { throw new RuntimeException("Page file did not return node for node id: " + getPageID(subtree.getEntry())); } if(node.isLeaf()) { return subtree; } // first test on containment IndexTreePath<E> newSubtree = containedTest(subtree, node, mbr); if(newSubtree != null) { return (++cur == depth) ? newSubtree : choosePath(newSubtree, mbr, depth, cur); } N childNode = getNode(node.getEntry(0)); int num = settings.insertionStrategy.choose(node, NodeArrayAdapter.STATIC, mbr, height, cur); newSubtree = new IndexTreePath<>(subtree, node.getEntry(num), num); ++cur; if(cur == depth) { return newSubtree; } // children are leafs if(childNode.isLeaf()) { assert cur == newSubtree.getPathCount(); // Check for programming errors throw new IllegalArgumentException("childNode is leaf, but currentDepth != depth: " + cur + " != " + depth); } // children are directory nodes return choosePath(newSubtree, mbr, depth, cur); }
java
protected IndexTreePath<E> choosePath(IndexTreePath<E> subtree, SpatialComparable mbr, int depth, int cur) { if(getLogger().isDebuggingFiner()) { getLogger().debugFiner("node " + subtree + ", depth " + depth); } N node = getNode(subtree.getEntry()); if(node == null) { throw new RuntimeException("Page file did not return node for node id: " + getPageID(subtree.getEntry())); } if(node.isLeaf()) { return subtree; } // first test on containment IndexTreePath<E> newSubtree = containedTest(subtree, node, mbr); if(newSubtree != null) { return (++cur == depth) ? newSubtree : choosePath(newSubtree, mbr, depth, cur); } N childNode = getNode(node.getEntry(0)); int num = settings.insertionStrategy.choose(node, NodeArrayAdapter.STATIC, mbr, height, cur); newSubtree = new IndexTreePath<>(subtree, node.getEntry(num), num); ++cur; if(cur == depth) { return newSubtree; } // children are leafs if(childNode.isLeaf()) { assert cur == newSubtree.getPathCount(); // Check for programming errors throw new IllegalArgumentException("childNode is leaf, but currentDepth != depth: " + cur + " != " + depth); } // children are directory nodes return choosePath(newSubtree, mbr, depth, cur); }
[ "protected", "IndexTreePath", "<", "E", ">", "choosePath", "(", "IndexTreePath", "<", "E", ">", "subtree", ",", "SpatialComparable", "mbr", ",", "int", "depth", ",", "int", "cur", ")", "{", "if", "(", "getLogger", "(", ")", ".", "isDebuggingFiner", "(", ...
Chooses the best path of the specified subtree for insertion of the given mbr at the specified level. @param subtree the subtree to be tested for insertion @param mbr the mbr to be inserted @param depth Reinsertion depth, 1 indicates root level @param cur Current depth @return the path of the appropriate subtree to insert the given mbr
[ "Chooses", "the", "best", "path", "of", "the", "specified", "subtree", "for", "insertion", "of", "the", "given", "mbr", "at", "the", "specified", "level", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L512-L544
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.split
private N split(N node) { // choose the split dimension and the split point int minimum = node.isLeaf() ? leafMinimum : dirMinimum; long[] split = settings.nodeSplitter.split(node, NodeArrayAdapter.STATIC, minimum); // New node final N newNode = node.isLeaf() ? createNewLeafNode() : createNewDirectoryNode(); // do the split node.splitByMask(newNode, split); // write changes to file writeNode(node); writeNode(newNode); return newNode; }
java
private N split(N node) { // choose the split dimension and the split point int minimum = node.isLeaf() ? leafMinimum : dirMinimum; long[] split = settings.nodeSplitter.split(node, NodeArrayAdapter.STATIC, minimum); // New node final N newNode = node.isLeaf() ? createNewLeafNode() : createNewDirectoryNode(); // do the split node.splitByMask(newNode, split); // write changes to file writeNode(node); writeNode(newNode); return newNode; }
[ "private", "N", "split", "(", "N", "node", ")", "{", "// choose the split dimension and the split point", "int", "minimum", "=", "node", ".", "isLeaf", "(", ")", "?", "leafMinimum", ":", "dirMinimum", ";", "long", "[", "]", "split", "=", "settings", ".", "no...
Splits the specified node and returns the newly created split node. @param node the node to be split @return the newly created split node
[ "Splits", "the", "specified", "node", "and", "returns", "the", "newly", "created", "split", "node", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L570-L585
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.reInsert
public void reInsert(N node, IndexTreePath<E> path, int[] offs) { final int depth = path.getPathCount(); long[] remove = BitsUtil.zero(node.getCapacity()); List<E> reInsertEntries = new ArrayList<>(offs.length); for(int i = 0; i < offs.length; i++) { reInsertEntries.add(node.getEntry(offs[i])); BitsUtil.setI(remove, offs[i]); } // Remove the entries we reinsert node.removeMask(remove); writeNode(node); // and adapt the mbrs IndexTreePath<E> childPath = path; N child = node; while(childPath.getParentPath() != null) { N parent = getNode(childPath.getParentPath().getEntry()); int indexOfChild = childPath.getIndex(); if(child.adjustEntry(parent.getEntry(indexOfChild))) { writeNode(parent); childPath = childPath.getParentPath(); child = parent; } else { break; // TODO: stop writing when MBR didn't change! } } // reinsert the first entries final Logging log = getLogger(); for(E entry : reInsertEntries) { if(node.isLeaf()) { if(log.isDebugging()) { log.debug("reinsert " + entry); } insertLeafEntry(entry); } else { if(log.isDebugging()) { log.debug("reinsert " + entry + " at " + depth); } insertDirectoryEntry(entry, depth); } } }
java
public void reInsert(N node, IndexTreePath<E> path, int[] offs) { final int depth = path.getPathCount(); long[] remove = BitsUtil.zero(node.getCapacity()); List<E> reInsertEntries = new ArrayList<>(offs.length); for(int i = 0; i < offs.length; i++) { reInsertEntries.add(node.getEntry(offs[i])); BitsUtil.setI(remove, offs[i]); } // Remove the entries we reinsert node.removeMask(remove); writeNode(node); // and adapt the mbrs IndexTreePath<E> childPath = path; N child = node; while(childPath.getParentPath() != null) { N parent = getNode(childPath.getParentPath().getEntry()); int indexOfChild = childPath.getIndex(); if(child.adjustEntry(parent.getEntry(indexOfChild))) { writeNode(parent); childPath = childPath.getParentPath(); child = parent; } else { break; // TODO: stop writing when MBR didn't change! } } // reinsert the first entries final Logging log = getLogger(); for(E entry : reInsertEntries) { if(node.isLeaf()) { if(log.isDebugging()) { log.debug("reinsert " + entry); } insertLeafEntry(entry); } else { if(log.isDebugging()) { log.debug("reinsert " + entry + " at " + depth); } insertDirectoryEntry(entry, depth); } } }
[ "public", "void", "reInsert", "(", "N", "node", ",", "IndexTreePath", "<", "E", ">", "path", ",", "int", "[", "]", "offs", ")", "{", "final", "int", "depth", "=", "path", ".", "getPathCount", "(", ")", ";", "long", "[", "]", "remove", "=", "BitsUti...
Reinserts the specified node at the specified level. @param node the node to be reinserted @param path the path to the node @param offs the nodes indexes to reinsert
[ "Reinserts", "the", "specified", "node", "at", "the", "specified", "level", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L594-L640
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.condenseTree
private void condenseTree(IndexTreePath<E> subtree, Stack<N> stack) { N node = getNode(subtree.getEntry()); // node is not root if(!isRoot(node)) { N parent = getNode(subtree.getParentPath().getEntry()); int index = subtree.getIndex(); if(hasUnderflow(node)) { if(parent.deleteEntry(index)) { stack.push(node); } else { node.adjustEntry(parent.getEntry(index)); } } else { node.adjustEntry(parent.getEntry(index)); } writeNode(parent); // get subtree to parent condenseTree(subtree.getParentPath(), stack); } // node is root else { if(hasUnderflow(node) && node.getNumEntries() == 1 && !node.isLeaf()) { N child = getNode(node.getEntry(0)); final N newRoot; if(child.isLeaf()) { newRoot = createNewLeafNode(); newRoot.setPageID(getRootID()); for(int i = 0; i < child.getNumEntries(); i++) { newRoot.addLeafEntry(child.getEntry(i)); } } else { newRoot = createNewDirectoryNode(); newRoot.setPageID(getRootID()); for(int i = 0; i < child.getNumEntries(); i++) { newRoot.addDirectoryEntry(child.getEntry(i)); } } writeNode(newRoot); height--; } } }
java
private void condenseTree(IndexTreePath<E> subtree, Stack<N> stack) { N node = getNode(subtree.getEntry()); // node is not root if(!isRoot(node)) { N parent = getNode(subtree.getParentPath().getEntry()); int index = subtree.getIndex(); if(hasUnderflow(node)) { if(parent.deleteEntry(index)) { stack.push(node); } else { node.adjustEntry(parent.getEntry(index)); } } else { node.adjustEntry(parent.getEntry(index)); } writeNode(parent); // get subtree to parent condenseTree(subtree.getParentPath(), stack); } // node is root else { if(hasUnderflow(node) && node.getNumEntries() == 1 && !node.isLeaf()) { N child = getNode(node.getEntry(0)); final N newRoot; if(child.isLeaf()) { newRoot = createNewLeafNode(); newRoot.setPageID(getRootID()); for(int i = 0; i < child.getNumEntries(); i++) { newRoot.addLeafEntry(child.getEntry(i)); } } else { newRoot = createNewDirectoryNode(); newRoot.setPageID(getRootID()); for(int i = 0; i < child.getNumEntries(); i++) { newRoot.addDirectoryEntry(child.getEntry(i)); } } writeNode(newRoot); height--; } } }
[ "private", "void", "condenseTree", "(", "IndexTreePath", "<", "E", ">", "subtree", ",", "Stack", "<", "N", ">", "stack", ")", "{", "N", "node", "=", "getNode", "(", "subtree", ".", "getEntry", "(", ")", ")", ";", "// node is not root", "if", "(", "!", ...
Condenses the tree after deletion of some nodes. @param subtree the subtree to be condensed @param stack the stack holding the nodes to be reinserted after the tree has been condensed
[ "Condenses", "the", "tree", "after", "deletion", "of", "some", "nodes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L720-L765
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java
AbstractRStarTree.getLeafNodes
private void getLeafNodes(N node, List<E> result, int currentLevel) { // Level 1 are the leaf nodes, Level 2 is the one atop! if(currentLevel == 2) { for(int i = 0; i < node.getNumEntries(); i++) { result.add(node.getEntry(i)); } } else { for(int i = 0; i < node.getNumEntries(); i++) { getLeafNodes(getNode(node.getEntry(i)), result, (currentLevel - 1)); } } }
java
private void getLeafNodes(N node, List<E> result, int currentLevel) { // Level 1 are the leaf nodes, Level 2 is the one atop! if(currentLevel == 2) { for(int i = 0; i < node.getNumEntries(); i++) { result.add(node.getEntry(i)); } } else { for(int i = 0; i < node.getNumEntries(); i++) { getLeafNodes(getNode(node.getEntry(i)), result, (currentLevel - 1)); } } }
[ "private", "void", "getLeafNodes", "(", "N", "node", ",", "List", "<", "E", ">", "result", ",", "int", "currentLevel", ")", "{", "// Level 1 are the leaf nodes, Level 2 is the one atop!", "if", "(", "currentLevel", "==", "2", ")", "{", "for", "(", "int", "i", ...
Determines the entries pointing to the leaf nodes of the specified subtree. @param node the subtree @param result the result to store the ids in @param currentLevel the level of the node in the R-Tree
[ "Determines", "the", "entries", "pointing", "to", "the", "leaf", "nodes", "of", "the", "specified", "subtree", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java#L786-L798
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.angleDense
public static double angleDense(NumberVector v1, NumberVector v2) { final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // v1.transposeTimes(v2) / (v1.euclideanLength() * v2.euclideanLength()); // We can just compute all three in parallel. double cross = 0, l1 = 0, l2 = 0; for(int k = 0; k < mindim; k++) { final double r1 = v1.doubleValue(k); final double r2 = v2.doubleValue(k); cross += r1 * r2; l1 += r1 * r1; l2 += r2 * r2; } for(int k = mindim; k < dim1; k++) { final double r1 = v1.doubleValue(k); l1 += r1 * r1; } for(int k = mindim; k < dim2; k++) { final double r2 = v2.doubleValue(k); l2 += r2 * r2; } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
java
public static double angleDense(NumberVector v1, NumberVector v2) { final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // v1.transposeTimes(v2) / (v1.euclideanLength() * v2.euclideanLength()); // We can just compute all three in parallel. double cross = 0, l1 = 0, l2 = 0; for(int k = 0; k < mindim; k++) { final double r1 = v1.doubleValue(k); final double r2 = v2.doubleValue(k); cross += r1 * r2; l1 += r1 * r1; l2 += r2 * r2; } for(int k = mindim; k < dim1; k++) { final double r1 = v1.doubleValue(k); l1 += r1 * r1; } for(int k = mindim; k < dim2; k++) { final double r2 = v2.doubleValue(k); l2 += r2 * r2; } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
[ "public", "static", "double", "angleDense", "(", "NumberVector", "v1", ",", "NumberVector", "v2", ")", "{", "final", "int", "dim1", "=", "v1", ".", "getDimensionality", "(", ")", ",", "dim2", "=", "v2", ".", "getDimensionality", "(", ")", ";", "final", "...
Compute the absolute cosine of the angle between two dense vectors. To convert it to radians, use <code>Math.acos(angle)</code>! @param v1 first vector @param v2 second vector @return Angle
[ "Compute", "the", "absolute", "cosine", "of", "the", "angle", "between", "two", "dense", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L95-L121
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.angleSparse
public static double angleSparse(SparseNumberVector v1, SparseNumberVector v2) { // TODO: exploit precomputed length, when available? double l1 = 0., l2 = 0., cross = 0.; int i1 = v1.iter(), i2 = v2.iter(); while(v1.iterValid(i1) && v2.iterValid(i2)) { final int d1 = v1.iterDim(i1), d2 = v2.iterDim(i2); if(d1 < d2) { final double val = v1.iterDoubleValue(i1); l1 += val * val; i1 = v1.iterAdvance(i1); } else if(d2 < d1) { final double val = v2.iterDoubleValue(i2); l2 += val * val; i2 = v2.iterAdvance(i2); } else { // d1 == d2 final double val1 = v1.iterDoubleValue(i1); final double val2 = v2.iterDoubleValue(i2); l1 += val1 * val1; l2 += val2 * val2; cross += val1 * val2; i1 = v1.iterAdvance(i1); i2 = v2.iterAdvance(i2); } } while(v1.iterValid(i1)) { final double val = v1.iterDoubleValue(i1); l1 += val * val; i1 = v1.iterAdvance(i1); } while(v2.iterValid(i2)) { final double val = v2.iterDoubleValue(i2); l2 += val * val; i2 = v2.iterAdvance(i2); } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
java
public static double angleSparse(SparseNumberVector v1, SparseNumberVector v2) { // TODO: exploit precomputed length, when available? double l1 = 0., l2 = 0., cross = 0.; int i1 = v1.iter(), i2 = v2.iter(); while(v1.iterValid(i1) && v2.iterValid(i2)) { final int d1 = v1.iterDim(i1), d2 = v2.iterDim(i2); if(d1 < d2) { final double val = v1.iterDoubleValue(i1); l1 += val * val; i1 = v1.iterAdvance(i1); } else if(d2 < d1) { final double val = v2.iterDoubleValue(i2); l2 += val * val; i2 = v2.iterAdvance(i2); } else { // d1 == d2 final double val1 = v1.iterDoubleValue(i1); final double val2 = v2.iterDoubleValue(i2); l1 += val1 * val1; l2 += val2 * val2; cross += val1 * val2; i1 = v1.iterAdvance(i1); i2 = v2.iterAdvance(i2); } } while(v1.iterValid(i1)) { final double val = v1.iterDoubleValue(i1); l1 += val * val; i1 = v1.iterAdvance(i1); } while(v2.iterValid(i2)) { final double val = v2.iterDoubleValue(i2); l2 += val * val; i2 = v2.iterAdvance(i2); } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
[ "public", "static", "double", "angleSparse", "(", "SparseNumberVector", "v1", ",", "SparseNumberVector", "v2", ")", "{", "// TODO: exploit precomputed length, when available?", "double", "l1", "=", "0.", ",", "l2", "=", "0.", ",", "cross", "=", "0.", ";", "int", ...
Compute the angle for sparse vectors. @param v1 First vector @param v2 Second vector @return angle
[ "Compute", "the", "angle", "for", "sparse", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L130-L170
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.angleSparseDense
public static double angleSparseDense(SparseNumberVector v1, NumberVector v2) { // TODO: exploit precomputed length, when available. final int dim2 = v2.getDimensionality(); double l1 = 0., l2 = 0., cross = 0.; int i1 = v1.iter(), d2 = 0; while(v1.iterValid(i1)) { final int d1 = v1.iterDim(i1); while(d2 < d1 && d2 < dim2) { final double val = v2.doubleValue(d2); l2 += val * val; ++d2; } if(d2 < dim2) { assert (d1 == d2) : "Dimensions not ordered"; final double val1 = v1.iterDoubleValue(i1); final double val2 = v2.doubleValue(d2); l1 += val1 * val1; l2 += val2 * val2; cross += val1 * val2; i1 = v1.iterAdvance(i1); ++d2; } else { final double val = v1.iterDoubleValue(i1); l1 += val * val; i1 = v1.iterAdvance(i1); } } while(d2 < dim2) { final double val = v2.doubleValue(d2); l2 += val * val; ++d2; } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
java
public static double angleSparseDense(SparseNumberVector v1, NumberVector v2) { // TODO: exploit precomputed length, when available. final int dim2 = v2.getDimensionality(); double l1 = 0., l2 = 0., cross = 0.; int i1 = v1.iter(), d2 = 0; while(v1.iterValid(i1)) { final int d1 = v1.iterDim(i1); while(d2 < d1 && d2 < dim2) { final double val = v2.doubleValue(d2); l2 += val * val; ++d2; } if(d2 < dim2) { assert (d1 == d2) : "Dimensions not ordered"; final double val1 = v1.iterDoubleValue(i1); final double val2 = v2.doubleValue(d2); l1 += val1 * val1; l2 += val2 * val2; cross += val1 * val2; i1 = v1.iterAdvance(i1); ++d2; } else { final double val = v1.iterDoubleValue(i1); l1 += val * val; i1 = v1.iterAdvance(i1); } } while(d2 < dim2) { final double val = v2.doubleValue(d2); l2 += val * val; ++d2; } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
[ "public", "static", "double", "angleSparseDense", "(", "SparseNumberVector", "v1", ",", "NumberVector", "v2", ")", "{", "// TODO: exploit precomputed length, when available.", "final", "int", "dim2", "=", "v2", ".", "getDimensionality", "(", ")", ";", "double", "l1", ...
Compute the angle for a sparse and a dense vector. @param v1 Sparse first vector @param v2 Dense second vector @return angle
[ "Compute", "the", "angle", "for", "a", "sparse", "and", "a", "dense", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L179-L216
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.cosAngle
public static double cosAngle(NumberVector v1, NumberVector v2) { // Java Hotspot appears to optimize these better than if-then-else: return v1 instanceof SparseNumberVector ? // v2 instanceof SparseNumberVector ? // angleSparse((SparseNumberVector) v1, (SparseNumberVector) v2) : // angleSparseDense((SparseNumberVector) v1, v2) : // v2 instanceof SparseNumberVector ? // angleSparseDense((SparseNumberVector) v2, v1) : // angleDense(v1, v2); }
java
public static double cosAngle(NumberVector v1, NumberVector v2) { // Java Hotspot appears to optimize these better than if-then-else: return v1 instanceof SparseNumberVector ? // v2 instanceof SparseNumberVector ? // angleSparse((SparseNumberVector) v1, (SparseNumberVector) v2) : // angleSparseDense((SparseNumberVector) v1, v2) : // v2 instanceof SparseNumberVector ? // angleSparseDense((SparseNumberVector) v2, v1) : // angleDense(v1, v2); }
[ "public", "static", "double", "cosAngle", "(", "NumberVector", "v1", ",", "NumberVector", "v2", ")", "{", "// Java Hotspot appears to optimize these better than if-then-else:", "return", "v1", "instanceof", "SparseNumberVector", "?", "//", "v2", "instanceof", "SparseNumberV...
Compute the absolute cosine of the angle between two vectors. To convert it to radians, use <code>Math.acos(angle)</code>! @param v1 first vector @param v2 second vector @return Angle
[ "Compute", "the", "absolute", "cosine", "of", "the", "angle", "between", "two", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L227-L236
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.minCosAngle
public static double minCosAngle(SpatialComparable v1, SpatialComparable v2) { if(v1 instanceof NumberVector && v2 instanceof NumberVector) { return cosAngle((NumberVector) v1, (NumberVector) v2); } final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // absmax(v1.transposeTimes(v2))/(min(v1.euclideanLength())*min(v2.euclideanLength())); // We can just compute all three in parallel. double s1 = 0, s2 = 0, l1 = 0, l2 = 0; for(int k = 0; k < mindim; k++) { final double min1 = v1.getMin(k), max1 = v1.getMax(k); final double min2 = v2.getMin(k), max2 = v2.getMax(k); final double p1 = min1 * min2, p2 = min1 * max2; final double p3 = max1 * min2, p4 = max1 * max2; s1 += Math.max(Math.max(p1, p2), Math.max(p3, p4)); s2 += Math.min(Math.min(p1, p2), Math.min(p3, p4)); if(max1 < 0) { l1 += max1 * max1; } else if(min1 > 0) { l1 += min1 * min1; } // else: 0 if(max2 < 0) { l2 += max2 * max2; } else if(min2 > 0) { l2 += min2 * min2; } // else: 0 } for(int k = mindim; k < dim1; k++) { final double min1 = v1.getMin(k), max1 = v1.getMax(k); if(max1 < 0.) { l1 += max1 * max1; } else if(min1 > 0.) { l1 += min1 * min1; } // else: 0 } for(int k = mindim; k < dim2; k++) { final double min2 = v2.getMin(k), max2 = v2.getMax(k); if(max2 < 0.) { l2 += max2 * max2; } else if(min2 > 0.) { l2 += min2 * min2; } // else: 0 } final double cross = Math.max(Math.abs(s1), Math.abs(s2)); final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
java
public static double minCosAngle(SpatialComparable v1, SpatialComparable v2) { if(v1 instanceof NumberVector && v2 instanceof NumberVector) { return cosAngle((NumberVector) v1, (NumberVector) v2); } final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // absmax(v1.transposeTimes(v2))/(min(v1.euclideanLength())*min(v2.euclideanLength())); // We can just compute all three in parallel. double s1 = 0, s2 = 0, l1 = 0, l2 = 0; for(int k = 0; k < mindim; k++) { final double min1 = v1.getMin(k), max1 = v1.getMax(k); final double min2 = v2.getMin(k), max2 = v2.getMax(k); final double p1 = min1 * min2, p2 = min1 * max2; final double p3 = max1 * min2, p4 = max1 * max2; s1 += Math.max(Math.max(p1, p2), Math.max(p3, p4)); s2 += Math.min(Math.min(p1, p2), Math.min(p3, p4)); if(max1 < 0) { l1 += max1 * max1; } else if(min1 > 0) { l1 += min1 * min1; } // else: 0 if(max2 < 0) { l2 += max2 * max2; } else if(min2 > 0) { l2 += min2 * min2; } // else: 0 } for(int k = mindim; k < dim1; k++) { final double min1 = v1.getMin(k), max1 = v1.getMax(k); if(max1 < 0.) { l1 += max1 * max1; } else if(min1 > 0.) { l1 += min1 * min1; } // else: 0 } for(int k = mindim; k < dim2; k++) { final double min2 = v2.getMin(k), max2 = v2.getMax(k); if(max2 < 0.) { l2 += max2 * max2; } else if(min2 > 0.) { l2 += min2 * min2; } // else: 0 } final double cross = Math.max(Math.abs(s1), Math.abs(s2)); final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
[ "public", "static", "double", "minCosAngle", "(", "SpatialComparable", "v1", ",", "SpatialComparable", "v2", ")", "{", "if", "(", "v1", "instanceof", "NumberVector", "&&", "v2", "instanceof", "NumberVector", ")", "{", "return", "cosAngle", "(", "(", "NumberVecto...
Compute the minimum angle between two rectangles. @param v1 first rectangle @param v2 second rectangle @return Angle
[ "Compute", "the", "minimum", "angle", "between", "two", "rectangles", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L245-L298
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.angle
public static double angle(NumberVector v1, NumberVector v2, NumberVector o) { final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(), dimo = o.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // v1' = v1 - o, v2' = v2 - o // v1'.transposeTimes(v2') / (v1'.euclideanLength()*v2'.euclideanLength()); // We can just compute all three in parallel. double cross = 0, l1 = 0, l2 = 0; for(int k = 0; k < mindim; k++) { final double ok = k < dimo ? o.doubleValue(k) : 0.; final double r1 = v1.doubleValue(k) - ok; final double r2 = v2.doubleValue(k) - ok; cross += r1 * r2; l1 += r1 * r1; l2 += r2 * r2; } for(int k = mindim; k < dim1; k++) { final double ok = k < dimo ? o.doubleValue(k) : 0.; final double r1 = v1.doubleValue(k) - ok; l1 += r1 * r1; } for(int k = mindim; k < dim2; k++) { final double ok = k < dimo ? o.doubleValue(k) : 0.; final double r2 = v2.doubleValue(k) - ok; l2 += r2 * r2; } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
java
public static double angle(NumberVector v1, NumberVector v2, NumberVector o) { final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(), dimo = o.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // v1' = v1 - o, v2' = v2 - o // v1'.transposeTimes(v2') / (v1'.euclideanLength()*v2'.euclideanLength()); // We can just compute all three in parallel. double cross = 0, l1 = 0, l2 = 0; for(int k = 0; k < mindim; k++) { final double ok = k < dimo ? o.doubleValue(k) : 0.; final double r1 = v1.doubleValue(k) - ok; final double r2 = v2.doubleValue(k) - ok; cross += r1 * r2; l1 += r1 * r1; l2 += r2 * r2; } for(int k = mindim; k < dim1; k++) { final double ok = k < dimo ? o.doubleValue(k) : 0.; final double r1 = v1.doubleValue(k) - ok; l1 += r1 * r1; } for(int k = mindim; k < dim2; k++) { final double ok = k < dimo ? o.doubleValue(k) : 0.; final double r2 = v2.doubleValue(k) - ok; l2 += r2 * r2; } final double a = (cross == 0.) ? 0. : // (l1 == 0. || l2 == 0.) ? 1. : // FastMath.sqrt((cross / l1) * (cross / l2)); return (a < 1.) ? a : 1.; }
[ "public", "static", "double", "angle", "(", "NumberVector", "v1", ",", "NumberVector", "v2", ",", "NumberVector", "o", ")", "{", "final", "int", "dim1", "=", "v1", ".", "getDimensionality", "(", ")", ",", "dim2", "=", "v2", ".", "getDimensionality", "(", ...
Compute the angle between two vectors with respect to a reference point. @param v1 first vector @param v2 second vector @param o Origin @return Angle
[ "Compute", "the", "angle", "between", "two", "vectors", "with", "respect", "to", "a", "reference", "point", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L308-L339
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.dotDense
public static double dotDense(NumberVector v1, NumberVector v2) { final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; double dot = 0; for(int k = 0; k < mindim; k++) { dot += v1.doubleValue(k) * v2.doubleValue(k); } return dot; }
java
public static double dotDense(NumberVector v1, NumberVector v2) { final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; double dot = 0; for(int k = 0; k < mindim; k++) { dot += v1.doubleValue(k) * v2.doubleValue(k); } return dot; }
[ "public", "static", "double", "dotDense", "(", "NumberVector", "v1", ",", "NumberVector", "v2", ")", "{", "final", "int", "dim1", "=", "v1", ".", "getDimensionality", "(", ")", ",", "dim2", "=", "v2", ".", "getDimensionality", "(", ")", ";", "final", "in...
Compute the dot product of two dense vectors. @param v1 first vector @param v2 second vector @return dot product
[ "Compute", "the", "dot", "product", "of", "two", "dense", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L348-L356
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.dotSparse
public static double dotSparse(SparseNumberVector v1, SparseNumberVector v2) { double dot = 0.; int i1 = v1.iter(), i2 = v2.iter(); while(v1.iterValid(i1) && v2.iterValid(i2)) { final int d1 = v1.iterDim(i1), d2 = v2.iterDim(i2); if(d1 < d2) { i1 = v1.iterAdvance(i1); } else if(d2 < d1) { i2 = v2.iterAdvance(i2); } else { // d1 == d2 dot += v1.iterDoubleValue(i1) * v2.iterDoubleValue(i2); i1 = v1.iterAdvance(i1); i2 = v2.iterAdvance(i2); } } return dot; }
java
public static double dotSparse(SparseNumberVector v1, SparseNumberVector v2) { double dot = 0.; int i1 = v1.iter(), i2 = v2.iter(); while(v1.iterValid(i1) && v2.iterValid(i2)) { final int d1 = v1.iterDim(i1), d2 = v2.iterDim(i2); if(d1 < d2) { i1 = v1.iterAdvance(i1); } else if(d2 < d1) { i2 = v2.iterAdvance(i2); } else { // d1 == d2 dot += v1.iterDoubleValue(i1) * v2.iterDoubleValue(i2); i1 = v1.iterAdvance(i1); i2 = v2.iterAdvance(i2); } } return dot; }
[ "public", "static", "double", "dotSparse", "(", "SparseNumberVector", "v1", ",", "SparseNumberVector", "v2", ")", "{", "double", "dot", "=", "0.", ";", "int", "i1", "=", "v1", ".", "iter", "(", ")", ",", "i2", "=", "v2", ".", "iter", "(", ")", ";", ...
Compute the dot product for two sparse vectors. @param v1 First vector @param v2 Second vector @return dot product
[ "Compute", "the", "dot", "product", "for", "two", "sparse", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L365-L383
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.dotSparseDense
public static double dotSparseDense(SparseNumberVector v1, NumberVector v2) { final int dim2 = v2.getDimensionality(); double dot = 0.; for(int i1 = v1.iter(); v1.iterValid(i1);) { final int d1 = v1.iterDim(i1); if(d1 >= dim2) { break; } dot += v1.iterDoubleValue(i1) * v2.doubleValue(d1); i1 = v1.iterAdvance(i1); } return dot; }
java
public static double dotSparseDense(SparseNumberVector v1, NumberVector v2) { final int dim2 = v2.getDimensionality(); double dot = 0.; for(int i1 = v1.iter(); v1.iterValid(i1);) { final int d1 = v1.iterDim(i1); if(d1 >= dim2) { break; } dot += v1.iterDoubleValue(i1) * v2.doubleValue(d1); i1 = v1.iterAdvance(i1); } return dot; }
[ "public", "static", "double", "dotSparseDense", "(", "SparseNumberVector", "v1", ",", "NumberVector", "v2", ")", "{", "final", "int", "dim2", "=", "v2", ".", "getDimensionality", "(", ")", ";", "double", "dot", "=", "0.", ";", "for", "(", "int", "i1", "=...
Compute the dot product for a sparse and a dense vector. @param v1 Sparse first vector @param v2 Dense second vector @return dot product
[ "Compute", "the", "dot", "product", "for", "a", "sparse", "and", "a", "dense", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L392-L404
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.dot
public static double dot(NumberVector v1, NumberVector v2) { // Java Hotspot appears to optimize these better than if-then-else: return v1 instanceof SparseNumberVector ? // v2 instanceof SparseNumberVector ? // dotSparse((SparseNumberVector) v1, (SparseNumberVector) v2) : // dotSparseDense((SparseNumberVector) v1, v2) : // v2 instanceof SparseNumberVector ? // dotSparseDense((SparseNumberVector) v2, v1) : // dotDense(v1, v2); }
java
public static double dot(NumberVector v1, NumberVector v2) { // Java Hotspot appears to optimize these better than if-then-else: return v1 instanceof SparseNumberVector ? // v2 instanceof SparseNumberVector ? // dotSparse((SparseNumberVector) v1, (SparseNumberVector) v2) : // dotSparseDense((SparseNumberVector) v1, v2) : // v2 instanceof SparseNumberVector ? // dotSparseDense((SparseNumberVector) v2, v1) : // dotDense(v1, v2); }
[ "public", "static", "double", "dot", "(", "NumberVector", "v1", ",", "NumberVector", "v2", ")", "{", "// Java Hotspot appears to optimize these better than if-then-else:", "return", "v1", "instanceof", "SparseNumberVector", "?", "//", "v2", "instanceof", "SparseNumberVector...
Compute the dot product of the angle between two vectors. @param v1 first vector @param v2 second vector @return Dot product
[ "Compute", "the", "dot", "product", "of", "the", "angle", "between", "two", "vectors", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L413-L422
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.minDot
public static double minDot(SpatialComparable v1, SpatialComparable v2) { if(v1 instanceof NumberVector && v2 instanceof NumberVector) { return dot((NumberVector) v1, (NumberVector) v2); } final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // absmax(v1.transposeTimes(v2)); double s1 = 0, s2 = 0; for(int k = 0; k < mindim; k++) { final double min1 = v1.getMin(k), max1 = v1.getMax(k); final double min2 = v2.getMin(k), max2 = v2.getMax(k); final double p1 = min1 * min2, p2 = min1 * max2; final double p3 = max1 * min2, p4 = max1 * max2; s1 += Math.max(Math.max(p1, p2), Math.max(p3, p4)); s2 += Math.min(Math.min(p1, p2), Math.min(p3, p4)); } return Math.max(Math.abs(s1), Math.abs(s2)); }
java
public static double minDot(SpatialComparable v1, SpatialComparable v2) { if(v1 instanceof NumberVector && v2 instanceof NumberVector) { return dot((NumberVector) v1, (NumberVector) v2); } final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(); final int mindim = (dim1 <= dim2) ? dim1 : dim2; // Essentially, we want to compute this: // absmax(v1.transposeTimes(v2)); double s1 = 0, s2 = 0; for(int k = 0; k < mindim; k++) { final double min1 = v1.getMin(k), max1 = v1.getMax(k); final double min2 = v2.getMin(k), max2 = v2.getMax(k); final double p1 = min1 * min2, p2 = min1 * max2; final double p3 = max1 * min2, p4 = max1 * max2; s1 += Math.max(Math.max(p1, p2), Math.max(p3, p4)); s2 += Math.min(Math.min(p1, p2), Math.min(p3, p4)); } return Math.max(Math.abs(s1), Math.abs(s2)); }
[ "public", "static", "double", "minDot", "(", "SpatialComparable", "v1", ",", "SpatialComparable", "v2", ")", "{", "if", "(", "v1", "instanceof", "NumberVector", "&&", "v2", "instanceof", "NumberVector", ")", "{", "return", "dot", "(", "(", "NumberVector", ")",...
Compute the minimum angle between two rectangles, assuming unit length vectors @param v1 first rectangle @param v2 second rectangle @return Angle
[ "Compute", "the", "minimum", "angle", "between", "two", "rectangles", "assuming", "unit", "length", "vectors" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L432-L450
train
elki-project/elki
elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java
VectorUtil.project
public static <V extends NumberVector> V project(V v, long[] selectedAttributes, NumberVector.Factory<V> factory) { int card = BitsUtil.cardinality(selectedAttributes); if(factory instanceof SparseNumberVector.Factory) { final SparseNumberVector.Factory<?> sfactory = (SparseNumberVector.Factory<?>) factory; Int2DoubleOpenHashMap values = new Int2DoubleOpenHashMap(card, .8f); for(int d = BitsUtil.nextSetBit(selectedAttributes, 0); d >= 0; d = BitsUtil.nextSetBit(selectedAttributes, d + 1)) { if(v.doubleValue(d) != 0.0) { values.put(d, v.doubleValue(d)); } } // We can't avoid this cast, because Java doesn't know that V is a // SparseNumberVector: @SuppressWarnings("unchecked") V projectedVector = (V) sfactory.newNumberVector(values, card); return projectedVector; } else { double[] newAttributes = new double[card]; int i = 0; for(int d = BitsUtil.nextSetBit(selectedAttributes, 0); d >= 0; d = BitsUtil.nextSetBit(selectedAttributes, d + 1)) { newAttributes[i] = v.doubleValue(d); i++; } return factory.newNumberVector(newAttributes); } }
java
public static <V extends NumberVector> V project(V v, long[] selectedAttributes, NumberVector.Factory<V> factory) { int card = BitsUtil.cardinality(selectedAttributes); if(factory instanceof SparseNumberVector.Factory) { final SparseNumberVector.Factory<?> sfactory = (SparseNumberVector.Factory<?>) factory; Int2DoubleOpenHashMap values = new Int2DoubleOpenHashMap(card, .8f); for(int d = BitsUtil.nextSetBit(selectedAttributes, 0); d >= 0; d = BitsUtil.nextSetBit(selectedAttributes, d + 1)) { if(v.doubleValue(d) != 0.0) { values.put(d, v.doubleValue(d)); } } // We can't avoid this cast, because Java doesn't know that V is a // SparseNumberVector: @SuppressWarnings("unchecked") V projectedVector = (V) sfactory.newNumberVector(values, card); return projectedVector; } else { double[] newAttributes = new double[card]; int i = 0; for(int d = BitsUtil.nextSetBit(selectedAttributes, 0); d >= 0; d = BitsUtil.nextSetBit(selectedAttributes, d + 1)) { newAttributes[i] = v.doubleValue(d); i++; } return factory.newNumberVector(newAttributes); } }
[ "public", "static", "<", "V", "extends", "NumberVector", ">", "V", "project", "(", "V", "v", ",", "long", "[", "]", "selectedAttributes", ",", "NumberVector", ".", "Factory", "<", "V", ">", "factory", ")", "{", "int", "card", "=", "BitsUtil", ".", "car...
Project a number vector to the specified attributes. @param v a NumberVector to project @param selectedAttributes the attributes selected for projection @param factory Vector factory @param <V> Vector type @return a new NumberVector as a projection on the specified attributes
[ "Project", "a", "number", "vector", "to", "the", "specified", "attributes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-api/src/main/java/de/lmu/ifi/dbs/elki/data/VectorUtil.java#L579-L604
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/util/Core.java
Core.mergeWith
public void mergeWith(Core o) { o.num = this.num = (num < o.num ? num : o.num); }
java
public void mergeWith(Core o) { o.num = this.num = (num < o.num ? num : o.num); }
[ "public", "void", "mergeWith", "(", "Core", "o", ")", "{", "o", ".", "num", "=", "this", ".", "num", "=", "(", "num", "<", "o", ".", "num", "?", "num", ":", "o", ".", "num", ")", ";", "}" ]
Merge two cores. @param o Other core
[ "Merge", "two", "cores", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/gdbscan/util/Core.java#L49-L51
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java
ByLabelClustering.run
public Clustering<Model> run(Relation<?> relation) { HashMap<String, DBIDs> labelMap = multiple ? multipleAssignment(relation) : singleAssignment(relation); ModifiableDBIDs noiseids = DBIDUtil.newArray(); Clustering<Model> result = new Clustering<>("By Label Clustering", "bylabel-clustering"); for(Entry<String, DBIDs> entry : labelMap.entrySet()) { DBIDs ids = entry.getValue(); if(ids.size() <= 1) { noiseids.addDBIDs(ids); continue; } // Build a cluster Cluster<Model> c = new Cluster<Model>(entry.getKey(), ids, ClusterModel.CLUSTER); if(noisepattern != null && noisepattern.matcher(entry.getKey()).find()) { c.setNoise(true); } result.addToplevelCluster(c); } // Collected noise IDs. if(noiseids.size() > 0) { Cluster<Model> c = new Cluster<Model>("Noise", noiseids, ClusterModel.CLUSTER); c.setNoise(true); result.addToplevelCluster(c); } return result; }
java
public Clustering<Model> run(Relation<?> relation) { HashMap<String, DBIDs> labelMap = multiple ? multipleAssignment(relation) : singleAssignment(relation); ModifiableDBIDs noiseids = DBIDUtil.newArray(); Clustering<Model> result = new Clustering<>("By Label Clustering", "bylabel-clustering"); for(Entry<String, DBIDs> entry : labelMap.entrySet()) { DBIDs ids = entry.getValue(); if(ids.size() <= 1) { noiseids.addDBIDs(ids); continue; } // Build a cluster Cluster<Model> c = new Cluster<Model>(entry.getKey(), ids, ClusterModel.CLUSTER); if(noisepattern != null && noisepattern.matcher(entry.getKey()).find()) { c.setNoise(true); } result.addToplevelCluster(c); } // Collected noise IDs. if(noiseids.size() > 0) { Cluster<Model> c = new Cluster<Model>("Noise", noiseids, ClusterModel.CLUSTER); c.setNoise(true); result.addToplevelCluster(c); } return result; }
[ "public", "Clustering", "<", "Model", ">", "run", "(", "Relation", "<", "?", ">", "relation", ")", "{", "HashMap", "<", "String", ",", "DBIDs", ">", "labelMap", "=", "multiple", "?", "multipleAssignment", "(", "relation", ")", ":", "singleAssignment", "(",...
Run the actual clustering algorithm. @param relation The data input we use
[ "Run", "the", "actual", "clustering", "algorithm", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java#L133-L158
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java
ByLabelClustering.singleAssignment
private HashMap<String, DBIDs> singleAssignment(Relation<?> data) { HashMap<String, DBIDs> labelMap = new HashMap<>(); for(DBIDIter iditer = data.iterDBIDs(); iditer.valid(); iditer.advance()) { final Object val = data.get(iditer); String label = (val != null) ? val.toString() : null; assign(labelMap, label, iditer); } return labelMap; }
java
private HashMap<String, DBIDs> singleAssignment(Relation<?> data) { HashMap<String, DBIDs> labelMap = new HashMap<>(); for(DBIDIter iditer = data.iterDBIDs(); iditer.valid(); iditer.advance()) { final Object val = data.get(iditer); String label = (val != null) ? val.toString() : null; assign(labelMap, label, iditer); } return labelMap; }
[ "private", "HashMap", "<", "String", ",", "DBIDs", ">", "singleAssignment", "(", "Relation", "<", "?", ">", "data", ")", "{", "HashMap", "<", "String", ",", "DBIDs", ">", "labelMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "DBIDIter", ...
Assigns the objects of the database to single clusters according to their labels. @param data the database storing the objects @return a mapping of labels to ids
[ "Assigns", "the", "objects", "of", "the", "database", "to", "single", "clusters", "according", "to", "their", "labels", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java#L167-L176
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java
ByLabelClustering.multipleAssignment
private HashMap<String, DBIDs> multipleAssignment(Relation<?> data) { HashMap<String, DBIDs> labelMap = new HashMap<>(); for(DBIDIter iditer = data.iterDBIDs(); iditer.valid(); iditer.advance()) { String[] labels = data.get(iditer).toString().split(" "); for(String label : labels) { assign(labelMap, label, iditer); } } return labelMap; }
java
private HashMap<String, DBIDs> multipleAssignment(Relation<?> data) { HashMap<String, DBIDs> labelMap = new HashMap<>(); for(DBIDIter iditer = data.iterDBIDs(); iditer.valid(); iditer.advance()) { String[] labels = data.get(iditer).toString().split(" "); for(String label : labels) { assign(labelMap, label, iditer); } } return labelMap; }
[ "private", "HashMap", "<", "String", ",", "DBIDs", ">", "multipleAssignment", "(", "Relation", "<", "?", ">", "data", ")", "{", "HashMap", "<", "String", ",", "DBIDs", ">", "labelMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "DBIDIter",...
Assigns the objects of the database to multiple clusters according to their labels. @param data the database storing the objects @return a mapping of labels to ids
[ "Assigns", "the", "objects", "of", "the", "database", "to", "multiple", "clusters", "according", "to", "their", "labels", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java#L185-L195
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java
ByLabelClustering.assign
private void assign(HashMap<String, DBIDs> labelMap, String label, DBIDRef id) { if(labelMap.containsKey(label)) { DBIDs exist = labelMap.get(label); if(exist instanceof DBID) { ModifiableDBIDs n = DBIDUtil.newHashSet(); n.add((DBID) exist); n.add(id); labelMap.put(label, n); } else { assert (exist instanceof HashSetModifiableDBIDs); assert (exist.size() > 1); ((ModifiableDBIDs) exist).add(id); } } else { labelMap.put(label, DBIDUtil.deref(id)); } }
java
private void assign(HashMap<String, DBIDs> labelMap, String label, DBIDRef id) { if(labelMap.containsKey(label)) { DBIDs exist = labelMap.get(label); if(exist instanceof DBID) { ModifiableDBIDs n = DBIDUtil.newHashSet(); n.add((DBID) exist); n.add(id); labelMap.put(label, n); } else { assert (exist instanceof HashSetModifiableDBIDs); assert (exist.size() > 1); ((ModifiableDBIDs) exist).add(id); } } else { labelMap.put(label, DBIDUtil.deref(id)); } }
[ "private", "void", "assign", "(", "HashMap", "<", "String", ",", "DBIDs", ">", "labelMap", ",", "String", "label", ",", "DBIDRef", "id", ")", "{", "if", "(", "labelMap", ".", "containsKey", "(", "label", ")", ")", "{", "DBIDs", "exist", "=", "labelMap"...
Assigns the specified id to the labelMap according to its label @param labelMap the mapping of label to ids @param label the label of the object to be assigned @param id the id of the object to be assigned
[ "Assigns", "the", "specified", "id", "to", "the", "labelMap", "according", "to", "its", "label" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/trivial/ByLabelClustering.java#L204-L222
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/DoubleMinMax.java
DoubleMinMax.put
public void put(double val) { min = val < min ? val : min; max = val > max ? val : max; }
java
public void put(double val) { min = val < min ? val : min; max = val > max ? val : max; }
[ "public", "void", "put", "(", "double", "val", ")", "{", "min", "=", "val", "<", "min", "?", "val", ":", "min", ";", "max", "=", "val", ">", "max", "?", "val", ":", "max", ";", "}" ]
Process a single double value. If the new value is smaller than the current minimum, it will become the new minimum. If the new value is larger than the current maximum, it will become the new maximum. @param val New value
[ "Process", "a", "single", "double", "value", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/DoubleMinMax.java#L73-L76
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGEffects.java
SVGEffects.addShadowFilter
public static void addShadowFilter(SVGPlot svgp) { Element shadow = svgp.getIdElement(SHADOW_ID); if(shadow == null) { shadow = svgp.svgElement(SVGConstants.SVG_FILTER_TAG); shadow.setAttribute(SVGConstants.SVG_ID_ATTRIBUTE, SHADOW_ID); shadow.setAttribute(SVGConstants.SVG_WIDTH_ATTRIBUTE, "140%"); shadow.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "140%"); Element offset = svgp.svgElement(SVGConstants.SVG_FE_OFFSET_TAG); offset.setAttribute(SVGConstants.SVG_IN_ATTRIBUTE, SVGConstants.SVG_SOURCE_ALPHA_VALUE); offset.setAttribute(SVGConstants.SVG_RESULT_ATTRIBUTE, "off"); offset.setAttribute(SVGConstants.SVG_DX_ATTRIBUTE, "0.1"); offset.setAttribute(SVGConstants.SVG_DY_ATTRIBUTE, "0.1"); shadow.appendChild(offset); Element gauss = svgp.svgElement(SVGConstants.SVG_FE_GAUSSIAN_BLUR_TAG); gauss.setAttribute(SVGConstants.SVG_IN_ATTRIBUTE, "off"); gauss.setAttribute(SVGConstants.SVG_RESULT_ATTRIBUTE, "blur"); gauss.setAttribute(SVGConstants.SVG_STD_DEVIATION_ATTRIBUTE, "0.1"); shadow.appendChild(gauss); Element blend = svgp.svgElement(SVGConstants.SVG_FE_BLEND_TAG); blend.setAttribute(SVGConstants.SVG_IN_ATTRIBUTE, SVGConstants.SVG_SOURCE_GRAPHIC_VALUE); blend.setAttribute(SVGConstants.SVG_IN2_ATTRIBUTE, "blur"); blend.setAttribute(SVGConstants.SVG_MODE_ATTRIBUTE, SVGConstants.SVG_NORMAL_VALUE); shadow.appendChild(blend); svgp.getDefs().appendChild(shadow); svgp.putIdElement(SHADOW_ID, shadow); } }
java
public static void addShadowFilter(SVGPlot svgp) { Element shadow = svgp.getIdElement(SHADOW_ID); if(shadow == null) { shadow = svgp.svgElement(SVGConstants.SVG_FILTER_TAG); shadow.setAttribute(SVGConstants.SVG_ID_ATTRIBUTE, SHADOW_ID); shadow.setAttribute(SVGConstants.SVG_WIDTH_ATTRIBUTE, "140%"); shadow.setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, "140%"); Element offset = svgp.svgElement(SVGConstants.SVG_FE_OFFSET_TAG); offset.setAttribute(SVGConstants.SVG_IN_ATTRIBUTE, SVGConstants.SVG_SOURCE_ALPHA_VALUE); offset.setAttribute(SVGConstants.SVG_RESULT_ATTRIBUTE, "off"); offset.setAttribute(SVGConstants.SVG_DX_ATTRIBUTE, "0.1"); offset.setAttribute(SVGConstants.SVG_DY_ATTRIBUTE, "0.1"); shadow.appendChild(offset); Element gauss = svgp.svgElement(SVGConstants.SVG_FE_GAUSSIAN_BLUR_TAG); gauss.setAttribute(SVGConstants.SVG_IN_ATTRIBUTE, "off"); gauss.setAttribute(SVGConstants.SVG_RESULT_ATTRIBUTE, "blur"); gauss.setAttribute(SVGConstants.SVG_STD_DEVIATION_ATTRIBUTE, "0.1"); shadow.appendChild(gauss); Element blend = svgp.svgElement(SVGConstants.SVG_FE_BLEND_TAG); blend.setAttribute(SVGConstants.SVG_IN_ATTRIBUTE, SVGConstants.SVG_SOURCE_GRAPHIC_VALUE); blend.setAttribute(SVGConstants.SVG_IN2_ATTRIBUTE, "blur"); blend.setAttribute(SVGConstants.SVG_MODE_ATTRIBUTE, SVGConstants.SVG_NORMAL_VALUE); shadow.appendChild(blend); svgp.getDefs().appendChild(shadow); svgp.putIdElement(SHADOW_ID, shadow); } }
[ "public", "static", "void", "addShadowFilter", "(", "SVGPlot", "svgp", ")", "{", "Element", "shadow", "=", "svgp", ".", "getIdElement", "(", "SHADOW_ID", ")", ";", "if", "(", "shadow", "==", "null", ")", "{", "shadow", "=", "svgp", ".", "svgElement", "("...
Static method to prepare a SVG document for drop shadow effects. Invoke this from an appropriate update thread! @param svgp Plot to prepare
[ "Static", "method", "to", "prepare", "a", "SVG", "document", "for", "drop", "shadow", "effects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGEffects.java#L57-L87
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGEffects.java
SVGEffects.addLightGradient
public static void addLightGradient(SVGPlot svgp) { Element gradient = svgp.getIdElement(LIGHT_GRADIENT_ID); if(gradient == null) { gradient = svgp.svgElement(SVGConstants.SVG_LINEAR_GRADIENT_TAG); gradient.setAttribute(SVGConstants.SVG_ID_ATTRIBUTE, LIGHT_GRADIENT_ID); gradient.setAttribute(SVGConstants.SVG_X1_ATTRIBUTE, "0"); gradient.setAttribute(SVGConstants.SVG_Y1_ATTRIBUTE, "0"); gradient.setAttribute(SVGConstants.SVG_X2_ATTRIBUTE, "0"); gradient.setAttribute(SVGConstants.SVG_Y2_ATTRIBUTE, "1"); Element stop0 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop0.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "white"); stop0.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, "1"); stop0.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, "0"); gradient.appendChild(stop0); Element stop04 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop04.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "white"); stop04.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, "0"); stop04.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, ".4"); gradient.appendChild(stop04); Element stop06 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop06.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "black"); stop06.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, "0"); stop06.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, ".6"); gradient.appendChild(stop06); Element stop1 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop1.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "black"); stop1.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, ".5"); stop1.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, "1"); gradient.appendChild(stop1); svgp.getDefs().appendChild(gradient); svgp.putIdElement(LIGHT_GRADIENT_ID, gradient); } }
java
public static void addLightGradient(SVGPlot svgp) { Element gradient = svgp.getIdElement(LIGHT_GRADIENT_ID); if(gradient == null) { gradient = svgp.svgElement(SVGConstants.SVG_LINEAR_GRADIENT_TAG); gradient.setAttribute(SVGConstants.SVG_ID_ATTRIBUTE, LIGHT_GRADIENT_ID); gradient.setAttribute(SVGConstants.SVG_X1_ATTRIBUTE, "0"); gradient.setAttribute(SVGConstants.SVG_Y1_ATTRIBUTE, "0"); gradient.setAttribute(SVGConstants.SVG_X2_ATTRIBUTE, "0"); gradient.setAttribute(SVGConstants.SVG_Y2_ATTRIBUTE, "1"); Element stop0 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop0.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "white"); stop0.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, "1"); stop0.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, "0"); gradient.appendChild(stop0); Element stop04 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop04.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "white"); stop04.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, "0"); stop04.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, ".4"); gradient.appendChild(stop04); Element stop06 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop06.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "black"); stop06.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, "0"); stop06.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, ".6"); gradient.appendChild(stop06); Element stop1 = svgp.svgElement(SVGConstants.SVG_STOP_TAG); stop1.setAttribute(SVGConstants.SVG_STOP_COLOR_ATTRIBUTE, "black"); stop1.setAttribute(SVGConstants.SVG_STOP_OPACITY_ATTRIBUTE, ".5"); stop1.setAttribute(SVGConstants.SVG_OFFSET_ATTRIBUTE, "1"); gradient.appendChild(stop1); svgp.getDefs().appendChild(gradient); svgp.putIdElement(LIGHT_GRADIENT_ID, gradient); } }
[ "public", "static", "void", "addLightGradient", "(", "SVGPlot", "svgp", ")", "{", "Element", "gradient", "=", "svgp", ".", "getIdElement", "(", "LIGHT_GRADIENT_ID", ")", ";", "if", "(", "gradient", "==", "null", ")", "{", "gradient", "=", "svgp", ".", "svg...
Static method to prepare a SVG document for light gradient effects. Invoke this from an appropriate update thread! @param svgp Plot to prepare
[ "Static", "method", "to", "prepare", "a", "SVG", "document", "for", "light", "gradient", "effects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGEffects.java#L96-L133
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGEffects.java
SVGEffects.makeCheckmark
public static Element makeCheckmark(SVGPlot svgp) { Element checkmark = svgp.svgElement(SVGConstants.SVG_PATH_TAG); checkmark.setAttribute(SVGConstants.SVG_D_ATTRIBUTE, SVG_CHECKMARK_PATH); checkmark.setAttribute(SVGConstants.SVG_FILL_ATTRIBUTE, SVGConstants.CSS_BLACK_VALUE); checkmark.setAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE, SVGConstants.CSS_NONE_VALUE); return checkmark; }
java
public static Element makeCheckmark(SVGPlot svgp) { Element checkmark = svgp.svgElement(SVGConstants.SVG_PATH_TAG); checkmark.setAttribute(SVGConstants.SVG_D_ATTRIBUTE, SVG_CHECKMARK_PATH); checkmark.setAttribute(SVGConstants.SVG_FILL_ATTRIBUTE, SVGConstants.CSS_BLACK_VALUE); checkmark.setAttribute(SVGConstants.SVG_STROKE_ATTRIBUTE, SVGConstants.CSS_NONE_VALUE); return checkmark; }
[ "public", "static", "Element", "makeCheckmark", "(", "SVGPlot", "svgp", ")", "{", "Element", "checkmark", "=", "svgp", ".", "svgElement", "(", "SVGConstants", ".", "SVG_PATH_TAG", ")", ";", "checkmark", ".", "setAttribute", "(", "SVGConstants", ".", "SVG_D_ATTRI...
Creates a 15x15 big checkmark @param svgp Plot to create the element for @return Element
[ "Creates", "a", "15x15", "big", "checkmark" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/svg/SVGEffects.java#L146-L152
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/projections/CanvasSize.java
CanvasSize.continueToMargin
public double continueToMargin(double[] origin, double[] delta) { assert (delta.length == 2 && origin.length == 2); double factor = Double.POSITIVE_INFINITY; if(delta[0] > 0) { factor = Math.min(factor, (maxx - origin[0]) / delta[0]); } else if(delta[0] < 0) { factor = Math.min(factor, (origin[0] - minx) / -delta[0]); } if(delta[1] > 0) { factor = Math.min(factor, (maxy - origin[1]) / delta[1]); } else if(delta[1] < 0) { factor = Math.min(factor, (origin[1] - miny) / -delta[1]); } return factor; }
java
public double continueToMargin(double[] origin, double[] delta) { assert (delta.length == 2 && origin.length == 2); double factor = Double.POSITIVE_INFINITY; if(delta[0] > 0) { factor = Math.min(factor, (maxx - origin[0]) / delta[0]); } else if(delta[0] < 0) { factor = Math.min(factor, (origin[0] - minx) / -delta[0]); } if(delta[1] > 0) { factor = Math.min(factor, (maxy - origin[1]) / delta[1]); } else if(delta[1] < 0) { factor = Math.min(factor, (origin[1] - miny) / -delta[1]); } return factor; }
[ "public", "double", "continueToMargin", "(", "double", "[", "]", "origin", ",", "double", "[", "]", "delta", ")", "{", "assert", "(", "delta", ".", "length", "==", "2", "&&", "origin", ".", "length", "==", "2", ")", ";", "double", "factor", "=", "Dou...
Continue a line along a given direction to the margin. @param origin Origin point @param delta Direction vector @return scaling factor for delta vector
[ "Continue", "a", "line", "along", "a", "given", "direction", "to", "the", "margin", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/projections/CanvasSize.java#L116-L132
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/PersistentPageFile.java
PersistentPageFile.clear
@Override public void clear() { try { file.setLength(header.size()); } catch(IOException e) { throw new RuntimeException(e); } }
java
@Override public void clear() { try { file.setLength(header.size()); } catch(IOException e) { throw new RuntimeException(e); } }
[ "@", "Override", "public", "void", "clear", "(", ")", "{", "try", "{", "file", ".", "setLength", "(", "header", ".", "size", "(", ")", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";"...
Clears this PageFile.
[ "Clears", "this", "PageFile", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/persistent/PersistentPageFile.java#L195-L203
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/LMCLUS.java
LMCLUS.deviation
private double deviation(double[] delta, double[][] beta) { final double a = squareSum(delta); final double b = squareSum(transposeTimes(beta, delta)); return (a > b) ? FastMath.sqrt(a - b) : 0.; }
java
private double deviation(double[] delta, double[][] beta) { final double a = squareSum(delta); final double b = squareSum(transposeTimes(beta, delta)); return (a > b) ? FastMath.sqrt(a - b) : 0.; }
[ "private", "double", "deviation", "(", "double", "[", "]", "delta", ",", "double", "[", "]", "[", "]", "beta", ")", "{", "final", "double", "a", "=", "squareSum", "(", "delta", ")", ";", "final", "double", "b", "=", "squareSum", "(", "transposeTimes", ...
Deviation from a manifold described by beta. @param delta Delta from origin vector @param beta Manifold @return Deviation score
[ "Deviation", "from", "a", "manifold", "described", "by", "beta", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/LMCLUS.java#L247-L252
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/LMCLUS.java
LMCLUS.findSeparation
private Separation findSeparation(Relation<NumberVector> relation, DBIDs currentids, int dimension, Random r) { Separation separation = new Separation(); // determine the number of samples needed, to secure that with a specific // probability // in at least on sample every sampled point is from the same cluster. int samples = (int) Math.min(LOG_NOT_FROM_ONE_CLUSTER_PROBABILITY / (FastMath.log1p(-FastMath.powFast(samplingLevel, -dimension))), (double) currentids.size()); // System.out.println("Number of samples: " + samples); int remaining_retries = 100; for(int i = 1; i <= samples; i++) { DBIDs sample = DBIDUtil.randomSample(currentids, dimension + 1, r); final DBIDIter iter = sample.iter(); // Use first as origin double[] originV = relation.get(iter).toArray(); iter.advance(); // Build orthogonal basis from remainder double[][] basis; { List<double[]> vectors = new ArrayList<>(sample.size() - 1); for(; iter.valid(); iter.advance()) { double[] vec = relation.get(iter).toArray(); vectors.add(minusEquals(vec, originV)); } // generate orthogonal basis basis = generateOrthonormalBasis(vectors); if(basis == null) { // new sample has to be taken. i--; if(--remaining_retries < 0) { throw new TooManyRetriesException("Too many retries in sampling, and always a linear dependant data set."); } continue; } } // Generate and fill a histogram. DoubleDynamicHistogram histogram = new DoubleDynamicHistogram(BINS); double w = 1.0 / currentids.size(); for(DBIDIter iter2 = currentids.iter(); iter2.valid(); iter2.advance()) { // Skip sampled points if(sample.contains(iter2)) { continue; } double[] vec = minusEquals(relation.get(iter2).toArray(), originV); final double distance = deviation(vec, basis); histogram.increment(distance, w); } double[] th = findAndEvaluateThreshold(histogram); // evaluate threshold if(th[1] > separation.goodness) { separation.goodness = th[1]; separation.threshold = th[0]; separation.originV = originV; separation.basis = basis; } } return separation; }
java
private Separation findSeparation(Relation<NumberVector> relation, DBIDs currentids, int dimension, Random r) { Separation separation = new Separation(); // determine the number of samples needed, to secure that with a specific // probability // in at least on sample every sampled point is from the same cluster. int samples = (int) Math.min(LOG_NOT_FROM_ONE_CLUSTER_PROBABILITY / (FastMath.log1p(-FastMath.powFast(samplingLevel, -dimension))), (double) currentids.size()); // System.out.println("Number of samples: " + samples); int remaining_retries = 100; for(int i = 1; i <= samples; i++) { DBIDs sample = DBIDUtil.randomSample(currentids, dimension + 1, r); final DBIDIter iter = sample.iter(); // Use first as origin double[] originV = relation.get(iter).toArray(); iter.advance(); // Build orthogonal basis from remainder double[][] basis; { List<double[]> vectors = new ArrayList<>(sample.size() - 1); for(; iter.valid(); iter.advance()) { double[] vec = relation.get(iter).toArray(); vectors.add(minusEquals(vec, originV)); } // generate orthogonal basis basis = generateOrthonormalBasis(vectors); if(basis == null) { // new sample has to be taken. i--; if(--remaining_retries < 0) { throw new TooManyRetriesException("Too many retries in sampling, and always a linear dependant data set."); } continue; } } // Generate and fill a histogram. DoubleDynamicHistogram histogram = new DoubleDynamicHistogram(BINS); double w = 1.0 / currentids.size(); for(DBIDIter iter2 = currentids.iter(); iter2.valid(); iter2.advance()) { // Skip sampled points if(sample.contains(iter2)) { continue; } double[] vec = minusEquals(relation.get(iter2).toArray(), originV); final double distance = deviation(vec, basis); histogram.increment(distance, w); } double[] th = findAndEvaluateThreshold(histogram); // evaluate threshold if(th[1] > separation.goodness) { separation.goodness = th[1]; separation.threshold = th[0]; separation.originV = originV; separation.basis = basis; } } return separation; }
[ "private", "Separation", "findSeparation", "(", "Relation", "<", "NumberVector", ">", "relation", ",", "DBIDs", "currentids", ",", "int", "dimension", ",", "Random", "r", ")", "{", "Separation", "separation", "=", "new", "Separation", "(", ")", ";", "// determ...
This method samples a number of linear manifolds an tries to determine which the one with the best cluster is. <PRE> A number of sample points according to the dimension of the linear manifold are taken. The basis (B) and the origin(o) of the manifold are calculated. A distance histogram using the distance function ||x-o|| -||B^t*(x-o)|| is generated. The best threshold is searched using the elevate threshold function. The overall goodness of the threshold is determined. The process is redone until a specific number of samples is taken. </PRE> @param relation The vector relation @param currentids Current DBIDs @param dimension the dimension of the linear manifold to sample. @param r Random generator @return the overall goodness of the separation. The values origin basis and threshold are returned indirectly over class variables.
[ "This", "method", "samples", "a", "number", "of", "linear", "manifolds", "an", "tries", "to", "determine", "which", "the", "one", "with", "the", "best", "cluster", "is", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/correlation/LMCLUS.java#L274-L328
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java
KernelMatrix.getDistance
public double getDistance(final DBIDRef o1, final DBIDRef o2) { return FastMath.sqrt(getSquaredDistance(o1, o2)); }
java
public double getDistance(final DBIDRef o1, final DBIDRef o2) { return FastMath.sqrt(getSquaredDistance(o1, o2)); }
[ "public", "double", "getDistance", "(", "final", "DBIDRef", "o1", ",", "final", "DBIDRef", "o2", ")", "{", "return", "FastMath", ".", "sqrt", "(", "getSquaredDistance", "(", "o1", ",", "o2", ")", ")", ";", "}" ]
Returns the kernel distance between the two specified objects. @param o1 first ObjectID @param o2 second ObjectID @return the distance between the two objects
[ "Returns", "the", "kernel", "distance", "between", "the", "two", "specified", "objects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java#L209-L211
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java
KernelMatrix.getSquaredDistance
public double getSquaredDistance(final DBIDRef id1, final DBIDRef id2) { final int o1 = idmap.getOffset(id1), o2 = idmap.getOffset(id2); return kernel[o1][o1] + kernel[o2][o2] - 2 * kernel[o1][o2]; }
java
public double getSquaredDistance(final DBIDRef id1, final DBIDRef id2) { final int o1 = idmap.getOffset(id1), o2 = idmap.getOffset(id2); return kernel[o1][o1] + kernel[o2][o2] - 2 * kernel[o1][o2]; }
[ "public", "double", "getSquaredDistance", "(", "final", "DBIDRef", "id1", ",", "final", "DBIDRef", "id2", ")", "{", "final", "int", "o1", "=", "idmap", ".", "getOffset", "(", "id1", ")", ",", "o2", "=", "idmap", ".", "getOffset", "(", "id2", ")", ";", ...
Returns the squared kernel distance between the two specified objects. @param id1 first ObjectID @param id2 second ObjectID @return the distance between the two objects
[ "Returns", "the", "squared", "kernel", "distance", "between", "the", "two", "specified", "objects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java#L229-L232
train
elki-project/elki
elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java
KernelMatrix.getSimilarity
public double getSimilarity(DBIDRef id1, DBIDRef id2) { return kernel[idmap.getOffset(id1)][idmap.getOffset(id2)]; }
java
public double getSimilarity(DBIDRef id1, DBIDRef id2) { return kernel[idmap.getOffset(id1)][idmap.getOffset(id2)]; }
[ "public", "double", "getSimilarity", "(", "DBIDRef", "id1", ",", "DBIDRef", "id2", ")", "{", "return", "kernel", "[", "idmap", ".", "getOffset", "(", "id1", ")", "]", "[", "idmap", ".", "getOffset", "(", "id2", ")", "]", ";", "}" ]
Get the kernel similarity for the given objects. @param id1 First object @param id2 Second object @return Similarity.
[ "Get", "the", "kernel", "similarity", "for", "the", "given", "objects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-distance/src/main/java/de/lmu/ifi/dbs/elki/distance/similarityfunction/kernel/KernelMatrix.java#L272-L274
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java
AbstractKMeans.initialMeans
protected double[][] initialMeans(Database database, Relation<V> relation) { Duration inittime = getLogger().newDuration(initializer.getClass() + ".time").begin(); double[][] means = initializer.chooseInitialMeans(database, relation, k, getDistanceFunction()); getLogger().statistics(inittime.end()); return means; }
java
protected double[][] initialMeans(Database database, Relation<V> relation) { Duration inittime = getLogger().newDuration(initializer.getClass() + ".time").begin(); double[][] means = initializer.chooseInitialMeans(database, relation, k, getDistanceFunction()); getLogger().statistics(inittime.end()); return means; }
[ "protected", "double", "[", "]", "[", "]", "initialMeans", "(", "Database", "database", ",", "Relation", "<", "V", ">", "relation", ")", "{", "Duration", "inittime", "=", "getLogger", "(", ")", ".", "newDuration", "(", "initializer", ".", "getClass", "(", ...
Choose the initial means. @param database Database @param relation Relation @return Means
[ "Choose", "the", "initial", "means", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java#L122-L127
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java
AbstractKMeans.plusEquals
public static void plusEquals(double[] sum, NumberVector vec) { for(int d = 0; d < sum.length; d++) { sum[d] += vec.doubleValue(d); } }
java
public static void plusEquals(double[] sum, NumberVector vec) { for(int d = 0; d < sum.length; d++) { sum[d] += vec.doubleValue(d); } }
[ "public", "static", "void", "plusEquals", "(", "double", "[", "]", "sum", ",", "NumberVector", "vec", ")", "{", "for", "(", "int", "d", "=", "0", ";", "d", "<", "sum", ".", "length", ";", "d", "++", ")", "{", "sum", "[", "d", "]", "+=", "vec", ...
Similar to VMath.plusEquals, but accepts a number vector. @param sum Aggregation array @param vec Vector to add
[ "Similar", "to", "VMath", ".", "plusEquals", "but", "accepts", "a", "number", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java#L183-L187
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java
AbstractKMeans.minusEquals
public static void minusEquals(double[] sum, NumberVector vec) { for(int d = 0; d < sum.length; d++) { sum[d] -= vec.doubleValue(d); } }
java
public static void minusEquals(double[] sum, NumberVector vec) { for(int d = 0; d < sum.length; d++) { sum[d] -= vec.doubleValue(d); } }
[ "public", "static", "void", "minusEquals", "(", "double", "[", "]", "sum", ",", "NumberVector", "vec", ")", "{", "for", "(", "int", "d", "=", "0", ";", "d", "<", "sum", ".", "length", ";", "d", "++", ")", "{", "sum", "[", "d", "]", "-=", "vec",...
Similar to VMath.minusEquals, but accepts a number vector. @param sum Aggregation array @param vec Vector to subtract
[ "Similar", "to", "VMath", ".", "minusEquals", "but", "accepts", "a", "number", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java#L195-L199
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java
AbstractKMeans.plusMinusEquals
public static void plusMinusEquals(double[] add, double[] sub, NumberVector vec) { for(int d = 0; d < add.length; d++) { final double v = vec.doubleValue(d); add[d] += v; sub[d] -= v; } }
java
public static void plusMinusEquals(double[] add, double[] sub, NumberVector vec) { for(int d = 0; d < add.length; d++) { final double v = vec.doubleValue(d); add[d] += v; sub[d] -= v; } }
[ "public", "static", "void", "plusMinusEquals", "(", "double", "[", "]", "add", ",", "double", "[", "]", "sub", ",", "NumberVector", "vec", ")", "{", "for", "(", "int", "d", "=", "0", ";", "d", "<", "add", ".", "length", ";", "d", "++", ")", "{", ...
Add to one, remove from another. @param add Array to add to @param sub Array to remove from @param vec Vector to subtract
[ "Add", "to", "one", "remove", "from", "another", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java#L208-L214
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java
AbstractKMeans.incrementalUpdateMean
protected static void incrementalUpdateMean(double[] mean, NumberVector vec, int newsize, double op) { if(newsize == 0) { return; // Keep old mean } // Note: numerically stabilized version: VMath.plusTimesEquals(mean, VMath.minusEquals(vec.toArray(), mean), op / newsize); }
java
protected static void incrementalUpdateMean(double[] mean, NumberVector vec, int newsize, double op) { if(newsize == 0) { return; // Keep old mean } // Note: numerically stabilized version: VMath.plusTimesEquals(mean, VMath.minusEquals(vec.toArray(), mean), op / newsize); }
[ "protected", "static", "void", "incrementalUpdateMean", "(", "double", "[", "]", "mean", ",", "NumberVector", "vec", ",", "int", "newsize", ",", "double", "op", ")", "{", "if", "(", "newsize", "==", "0", ")", "{", "return", ";", "// Keep old mean", "}", ...
Compute an incremental update for the mean. @param mean Mean to update @param vec Object vector @param newsize (New) size of cluster @param op Cluster size change / Weight change
[ "Compute", "an", "incremental", "update", "for", "the", "mean", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/AbstractKMeans.java#L278-L284
train
elki-project/elki
elki-index-lsh/src/main/java/de/lmu/ifi/dbs/elki/index/lsh/hashfunctions/MultipleProjectionsLocalitySensitiveHashFunction.java
MultipleProjectionsLocalitySensitiveHashFunction.fastModPrime
public static int fastModPrime(long data) { // Mix high and low 32 bit: int high = (int) (data >>> 32); // Use fast multiplication with 5 for high: int alpha = ((int) data) + (high << 2 + high); // Note that in Java, PRIME will be negative. if(alpha < 0 && alpha > -5) { alpha = alpha + 5; } return alpha; }
java
public static int fastModPrime(long data) { // Mix high and low 32 bit: int high = (int) (data >>> 32); // Use fast multiplication with 5 for high: int alpha = ((int) data) + (high << 2 + high); // Note that in Java, PRIME will be negative. if(alpha < 0 && alpha > -5) { alpha = alpha + 5; } return alpha; }
[ "public", "static", "int", "fastModPrime", "(", "long", "data", ")", "{", "// Mix high and low 32 bit:", "int", "high", "=", "(", "int", ")", "(", "data", ">>>", "32", ")", ";", "// Use fast multiplication with 5 for high:", "int", "alpha", "=", "(", "(", "int...
Fast modulo operation for the largest unsigned integer prime. @param data Long input @return {@code data % (2^32 - 5)}.
[ "Fast", "modulo", "operation", "for", "the", "largest", "unsigned", "integer", "prime", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-lsh/src/main/java/de/lmu/ifi/dbs/elki/index/lsh/hashfunctions/MultipleProjectionsLocalitySensitiveHashFunction.java#L127-L137
train
elki-project/elki
elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/query/MTreeRangeQuery.java
MTreeRangeQuery.doRangeQuery
private void doRangeQuery(DBID o_p, AbstractMTreeNode<O, ?, ?> node, O q, double r_q, ModifiableDoubleDBIDList result) { double d1 = 0.; if(o_p != null) { d1 = distanceQuery.distance(o_p, q); index.statistics.countDistanceCalculation(); } if(!node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { MTreeEntry entry = node.getEntry(i); DBID o_r = entry.getRoutingObjectID(); double r_or = entry.getCoveringRadius(); double d2 = o_p != null ? entry.getParentDistance() : 0.; double diff = Math.abs(d1 - d2); double sum = r_q + r_or; if(diff <= sum) { double d3 = distanceQuery.distance(o_r, q); index.statistics.countDistanceCalculation(); if(d3 <= sum) { AbstractMTreeNode<O, ?, ?> child = index.getNode(((DirectoryEntry) entry).getPageID()); doRangeQuery(o_r, child, q, r_q, result); } } } } else { for(int i = 0; i < node.getNumEntries(); i++) { MTreeEntry entry = node.getEntry(i); DBID o_j = entry.getRoutingObjectID(); double d2 = o_p != null ? entry.getParentDistance() : 0.; double diff = Math.abs(d1 - d2); if(diff <= r_q) { double d3 = distanceQuery.distance(o_j, q); index.statistics.countDistanceCalculation(); if(d3 <= r_q) { result.add(d3, o_j); } } } } }
java
private void doRangeQuery(DBID o_p, AbstractMTreeNode<O, ?, ?> node, O q, double r_q, ModifiableDoubleDBIDList result) { double d1 = 0.; if(o_p != null) { d1 = distanceQuery.distance(o_p, q); index.statistics.countDistanceCalculation(); } if(!node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { MTreeEntry entry = node.getEntry(i); DBID o_r = entry.getRoutingObjectID(); double r_or = entry.getCoveringRadius(); double d2 = o_p != null ? entry.getParentDistance() : 0.; double diff = Math.abs(d1 - d2); double sum = r_q + r_or; if(diff <= sum) { double d3 = distanceQuery.distance(o_r, q); index.statistics.countDistanceCalculation(); if(d3 <= sum) { AbstractMTreeNode<O, ?, ?> child = index.getNode(((DirectoryEntry) entry).getPageID()); doRangeQuery(o_r, child, q, r_q, result); } } } } else { for(int i = 0; i < node.getNumEntries(); i++) { MTreeEntry entry = node.getEntry(i); DBID o_j = entry.getRoutingObjectID(); double d2 = o_p != null ? entry.getParentDistance() : 0.; double diff = Math.abs(d1 - d2); if(diff <= r_q) { double d3 = distanceQuery.distance(o_j, q); index.statistics.countDistanceCalculation(); if(d3 <= r_q) { result.add(d3, o_j); } } } } }
[ "private", "void", "doRangeQuery", "(", "DBID", "o_p", ",", "AbstractMTreeNode", "<", "O", ",", "?", ",", "?", ">", "node", ",", "O", "q", ",", "double", "r_q", ",", "ModifiableDoubleDBIDList", "result", ")", "{", "double", "d1", "=", "0.", ";", "if", ...
Performs a range query on the specified subtree. It recursively traverses all paths from the specified node, which cannot be excluded from leading to qualifying objects. @param o_p the routing object of the specified node @param node the root of the subtree to be traversed @param q the query object @param r_q the query range @param result the list holding the query results
[ "Performs", "a", "range", "query", "on", "the", "specified", "subtree", ".", "It", "recursively", "traverses", "all", "paths", "from", "the", "specified", "node", "which", "cannot", "be", "excluded", "from", "leading", "to", "qualifying", "objects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-mtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/mtreevariants/query/MTreeRangeQuery.java#L70-L115
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java
GumbelDistribution.pdf
public static double pdf(double x, double mu, double beta) { final double z = (x - mu) / beta; if(x == Double.NEGATIVE_INFINITY) { return 0.; } return FastMath.exp(-z - FastMath.exp(-z)) / beta; }
java
public static double pdf(double x, double mu, double beta) { final double z = (x - mu) / beta; if(x == Double.NEGATIVE_INFINITY) { return 0.; } return FastMath.exp(-z - FastMath.exp(-z)) / beta; }
[ "public", "static", "double", "pdf", "(", "double", "x", ",", "double", "mu", ",", "double", "beta", ")", "{", "final", "double", "z", "=", "(", "x", "-", "mu", ")", "/", "beta", ";", "if", "(", "x", "==", "Double", ".", "NEGATIVE_INFINITY", ")", ...
PDF of Gumbel distribution @param x Value @param mu Mode @param beta Shape @return PDF at position x.
[ "PDF", "of", "Gumbel", "distribution" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java#L109-L115
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java
GumbelDistribution.logpdf
public static double logpdf(double x, double mu, double beta) { if(x == Double.NEGATIVE_INFINITY) { return Double.NEGATIVE_INFINITY; } final double z = (x - mu) / beta; return -z - FastMath.exp(-z) - FastMath.log(beta); }
java
public static double logpdf(double x, double mu, double beta) { if(x == Double.NEGATIVE_INFINITY) { return Double.NEGATIVE_INFINITY; } final double z = (x - mu) / beta; return -z - FastMath.exp(-z) - FastMath.log(beta); }
[ "public", "static", "double", "logpdf", "(", "double", "x", ",", "double", "mu", ",", "double", "beta", ")", "{", "if", "(", "x", "==", "Double", ".", "NEGATIVE_INFINITY", ")", "{", "return", "Double", ".", "NEGATIVE_INFINITY", ";", "}", "final", "double...
log PDF of Gumbel distribution @param x Value @param mu Mode @param beta Shape @return PDF at position x.
[ "log", "PDF", "of", "Gumbel", "distribution" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java#L130-L136
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java
GumbelDistribution.cdf
public static double cdf(double val, double mu, double beta) { return FastMath.exp(-FastMath.exp(-(val - mu) / beta)); }
java
public static double cdf(double val, double mu, double beta) { return FastMath.exp(-FastMath.exp(-(val - mu) / beta)); }
[ "public", "static", "double", "cdf", "(", "double", "val", ",", "double", "mu", ",", "double", "beta", ")", "{", "return", "FastMath", ".", "exp", "(", "-", "FastMath", ".", "exp", "(", "-", "(", "val", "-", "mu", ")", "/", "beta", ")", ")", ";",...
CDF of Gumbel distribution @param val Value @param mu Mode @param beta Shape @return CDF at position x.
[ "CDF", "of", "Gumbel", "distribution" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java#L151-L153
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java
GumbelDistribution.quantile
public static double quantile(double val, double mu, double beta) { return mu - beta * FastMath.log(-FastMath.log(val)); }
java
public static double quantile(double val, double mu, double beta) { return mu - beta * FastMath.log(-FastMath.log(val)); }
[ "public", "static", "double", "quantile", "(", "double", "val", ",", "double", "mu", ",", "double", "beta", ")", "{", "return", "mu", "-", "beta", "*", "FastMath", ".", "log", "(", "-", "FastMath", ".", "log", "(", "val", ")", ")", ";", "}" ]
Quantile function of Gumbel distribution @param val Value @param mu Mode @param beta Shape @return Quantile function at position x.
[ "Quantile", "function", "of", "Gumbel", "distribution" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GumbelDistribution.java#L168-L170
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VAFile.java
VAFile.setPartitions
public void setPartitions(Relation<V> relation) throws IllegalArgumentException { if((FastMath.log(partitions) / FastMath.log(2)) != (int) (FastMath.log(partitions) / FastMath.log(2))) { throw new IllegalArgumentException("Number of partitions must be a power of 2!"); } final int dimensions = RelationUtil.dimensionality(relation); final int size = relation.size(); splitPositions = new double[dimensions][partitions + 1]; for(int d = 0; d < dimensions; d++) { double[] tempdata = new double[size]; int j = 0; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { tempdata[j] = relation.get(iditer).doubleValue(d); j += 1; } Arrays.sort(tempdata); for(int b = 0; b < partitions; b++) { int start = (int) (b * size / (double) partitions); splitPositions[d][b] = tempdata[start]; } // make sure that last object will be included splitPositions[d][partitions] = tempdata[size - 1] + 0.000001; } }
java
public void setPartitions(Relation<V> relation) throws IllegalArgumentException { if((FastMath.log(partitions) / FastMath.log(2)) != (int) (FastMath.log(partitions) / FastMath.log(2))) { throw new IllegalArgumentException("Number of partitions must be a power of 2!"); } final int dimensions = RelationUtil.dimensionality(relation); final int size = relation.size(); splitPositions = new double[dimensions][partitions + 1]; for(int d = 0; d < dimensions; d++) { double[] tempdata = new double[size]; int j = 0; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) { tempdata[j] = relation.get(iditer).doubleValue(d); j += 1; } Arrays.sort(tempdata); for(int b = 0; b < partitions; b++) { int start = (int) (b * size / (double) partitions); splitPositions[d][b] = tempdata[start]; } // make sure that last object will be included splitPositions[d][partitions] = tempdata[size - 1] + 0.000001; } }
[ "public", "void", "setPartitions", "(", "Relation", "<", "V", ">", "relation", ")", "throws", "IllegalArgumentException", "{", "if", "(", "(", "FastMath", ".", "log", "(", "partitions", ")", "/", "FastMath", ".", "log", "(", "2", ")", ")", "!=", "(", "...
Initialize the data set grid by computing quantiles. @param relation Data relation @throws IllegalArgumentException
[ "Initialize", "the", "data", "set", "grid", "by", "computing", "quantiles", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VAFile.java#L144-L169
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VAFile.java
VAFile.getScannedPages
public long getScannedPages() { int vacapacity = pageSize / VectorApproximation.byteOnDisk(splitPositions.length, partitions); long vasize = (long) Math.ceil((vectorApprox.size()) / (1.0 * vacapacity)); return vasize * scans; }
java
public long getScannedPages() { int vacapacity = pageSize / VectorApproximation.byteOnDisk(splitPositions.length, partitions); long vasize = (long) Math.ceil((vectorApprox.size()) / (1.0 * vacapacity)); return vasize * scans; }
[ "public", "long", "getScannedPages", "(", ")", "{", "int", "vacapacity", "=", "pageSize", "/", "VectorApproximation", ".", "byteOnDisk", "(", "splitPositions", ".", "length", ",", "partitions", ")", ";", "long", "vasize", "=", "(", "long", ")", "Math", ".", ...
Get the number of scanned bytes. @return Number of scanned bytes.
[ "Get", "the", "number", "of", "scanned", "bytes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/vafile/VAFile.java#L212-L216
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/EigenvalueDecomposition.java
EigenvalueDecomposition.hqr2BackTransformation
private void hqr2BackTransformation(int nn, int low, int high) { for(int j = nn - 1; j >= low; j--) { final int last = j < high ? j : high; for(int i = low; i <= high; i++) { final double[] Vi = V[i]; double sum = 0.; for(int k = low; k <= last; k++) { sum += Vi[k] * H[k][j]; } Vi[j] = sum; } } }
java
private void hqr2BackTransformation(int nn, int low, int high) { for(int j = nn - 1; j >= low; j--) { final int last = j < high ? j : high; for(int i = low; i <= high; i++) { final double[] Vi = V[i]; double sum = 0.; for(int k = low; k <= last; k++) { sum += Vi[k] * H[k][j]; } Vi[j] = sum; } } }
[ "private", "void", "hqr2BackTransformation", "(", "int", "nn", ",", "int", "low", ",", "int", "high", ")", "{", "for", "(", "int", "j", "=", "nn", "-", "1", ";", "j", ">=", "low", ";", "j", "--", ")", "{", "final", "int", "last", "=", "j", "<",...
Back transformation to get eigenvectors of original matrix.
[ "Back", "transformation", "to", "get", "eigenvectors", "of", "original", "matrix", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/EigenvalueDecomposition.java#L807-L819
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GammaDistribution.java
GammaDistribution.gammaQuantileNewtonRefinement
protected static double gammaQuantileNewtonRefinement(final double logpt, final double k, final double theta, final int maxit, double x) { final double EPS_N = 1e-15; // Precision threshold // 0 is not possible, try MIN_NORMAL instead if(x <= 0) { x = Double.MIN_NORMAL; } // Current estimation double logpc = logcdf(x, k, theta); if(x == Double.MIN_NORMAL && logpc > logpt * (1. + 1e-7)) { return 0.; } if(logpc == Double.NEGATIVE_INFINITY) { return 0.; } // Refine by newton iterations for(int i = 0; i < maxit; i++) { // Error of current approximation final double logpe = logpc - logpt; if(Math.abs(logpe) < Math.abs(EPS_N * logpt)) { break; } // Step size is controlled by PDF: final double g = logpdf(x, k, theta); if(g == Double.NEGATIVE_INFINITY) { break; } final double newx = x - logpe * FastMath.exp(logpc - g); // New estimate: logpc = logcdf(newx, k, theta); if(Math.abs(logpc - logpt) > Math.abs(logpe) || (i > 0 && Math.abs(logpc - logpt) == Math.abs(logpe))) { // no further improvement break; } x = newx; } return x; }
java
protected static double gammaQuantileNewtonRefinement(final double logpt, final double k, final double theta, final int maxit, double x) { final double EPS_N = 1e-15; // Precision threshold // 0 is not possible, try MIN_NORMAL instead if(x <= 0) { x = Double.MIN_NORMAL; } // Current estimation double logpc = logcdf(x, k, theta); if(x == Double.MIN_NORMAL && logpc > logpt * (1. + 1e-7)) { return 0.; } if(logpc == Double.NEGATIVE_INFINITY) { return 0.; } // Refine by newton iterations for(int i = 0; i < maxit; i++) { // Error of current approximation final double logpe = logpc - logpt; if(Math.abs(logpe) < Math.abs(EPS_N * logpt)) { break; } // Step size is controlled by PDF: final double g = logpdf(x, k, theta); if(g == Double.NEGATIVE_INFINITY) { break; } final double newx = x - logpe * FastMath.exp(logpc - g); // New estimate: logpc = logcdf(newx, k, theta); if(Math.abs(logpc - logpt) > Math.abs(logpe) || (i > 0 && Math.abs(logpc - logpt) == Math.abs(logpe))) { // no further improvement break; } x = newx; } return x; }
[ "protected", "static", "double", "gammaQuantileNewtonRefinement", "(", "final", "double", "logpt", ",", "final", "double", "k", ",", "final", "double", "theta", ",", "final", "int", "maxit", ",", "double", "x", ")", "{", "final", "double", "EPS_N", "=", "1e-...
Refinement of ChiSquared probit using Newton iterations. A trick used by GNU R to improve precision. @param logpt Target value of log p @param k Alpha @param theta Theta = 1 / Beta @param maxit Maximum number of iterations to do @param x Initial estimate @return Refined value
[ "Refinement", "of", "ChiSquared", "probit", "using", "Newton", "iterations", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/GammaDistribution.java#L840-L876
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/style/marker/CircleMarkers.java
CircleMarkers.useMarker
@Override public Element useMarker(SVGPlot plot, Element parent, double x, double y, int stylenr, double size) { Element marker = plot.svgCircle(x, y, size * .5); final String col; if(stylenr == -1) { col = dotcolor; } else if(stylenr == -2) { col = greycolor; } else { col = colors.getColor(stylenr); } SVGUtil.setStyle(marker, SVGConstants.CSS_FILL_PROPERTY + ":" + col); parent.appendChild(marker); return marker; }
java
@Override public Element useMarker(SVGPlot plot, Element parent, double x, double y, int stylenr, double size) { Element marker = plot.svgCircle(x, y, size * .5); final String col; if(stylenr == -1) { col = dotcolor; } else if(stylenr == -2) { col = greycolor; } else { col = colors.getColor(stylenr); } SVGUtil.setStyle(marker, SVGConstants.CSS_FILL_PROPERTY + ":" + col); parent.appendChild(marker); return marker; }
[ "@", "Override", "public", "Element", "useMarker", "(", "SVGPlot", "plot", ",", "Element", "parent", ",", "double", "x", ",", "double", "y", ",", "int", "stylenr", ",", "double", "size", ")", "{", "Element", "marker", "=", "plot", ".", "svgCircle", "(", ...
Use a given marker on the document.
[ "Use", "a", "given", "marker", "on", "the", "document", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/style/marker/CircleMarkers.java#L71-L87
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/extraction/HDBSCANHierarchyExtraction.java
HDBSCANHierarchyExtraction.run
public Clustering<DendrogramModel> run(PointerHierarchyRepresentationResult pointerresult) { Clustering<DendrogramModel> result = new Instance(pointerresult).run(); result.addChildResult(pointerresult); return result; }
java
public Clustering<DendrogramModel> run(PointerHierarchyRepresentationResult pointerresult) { Clustering<DendrogramModel> result = new Instance(pointerresult).run(); result.addChildResult(pointerresult); return result; }
[ "public", "Clustering", "<", "DendrogramModel", ">", "run", "(", "PointerHierarchyRepresentationResult", "pointerresult", ")", "{", "Clustering", "<", "DendrogramModel", ">", "result", "=", "new", "Instance", "(", "pointerresult", ")", ".", "run", "(", ")", ";", ...
Process an existing result. @param pointerresult Existing result in pointer representation. @return Clustering
[ "Process", "an", "existing", "result", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/hierarchical/extraction/HDBSCANHierarchyExtraction.java#L128-L132
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/NormalDistribution.java
NormalDistribution.erf
public static double erf(double x) { final double w = x < 0 ? -x : x; double y; if(w < 2.2) { double t = w * w; int k = (int) t; t -= k; k *= 13; y = ((((((((((((ERF_COEFF1[k] * t + ERF_COEFF1[k + 1]) * t + // ERF_COEFF1[k + 2]) * t + ERF_COEFF1[k + 3]) * t + ERF_COEFF1[k + 4]) * t + // ERF_COEFF1[k + 5]) * t + ERF_COEFF1[k + 6]) * t + ERF_COEFF1[k + 7]) * t + // ERF_COEFF1[k + 8]) * t + ERF_COEFF1[k + 9]) * t + ERF_COEFF1[k + 10]) * t + // ERF_COEFF1[k + 11]) * t + ERF_COEFF1[k + 12]) * w; } else if(w < 6.9) { int k = (int) w; double t = w - k; k = 13 * (k - 2); y = (((((((((((ERF_COEFF2[k] * t + ERF_COEFF2[k + 1]) * t + // ERF_COEFF2[k + 2]) * t + ERF_COEFF2[k + 3]) * t + ERF_COEFF2[k + 4]) * t + // ERF_COEFF2[k + 5]) * t + ERF_COEFF2[k + 6]) * t + ERF_COEFF2[k + 7]) * t + // ERF_COEFF2[k + 8]) * t + ERF_COEFF2[k + 9]) * t + ERF_COEFF2[k + 10]) * t + // ERF_COEFF2[k + 11]) * t + ERF_COEFF2[k + 12]; y *= y; y *= y; y *= y; y = 1 - y * y; } else if(w == w) { y = 1; } else { return Double.NaN; } return x < 0 ? -y : y; }
java
public static double erf(double x) { final double w = x < 0 ? -x : x; double y; if(w < 2.2) { double t = w * w; int k = (int) t; t -= k; k *= 13; y = ((((((((((((ERF_COEFF1[k] * t + ERF_COEFF1[k + 1]) * t + // ERF_COEFF1[k + 2]) * t + ERF_COEFF1[k + 3]) * t + ERF_COEFF1[k + 4]) * t + // ERF_COEFF1[k + 5]) * t + ERF_COEFF1[k + 6]) * t + ERF_COEFF1[k + 7]) * t + // ERF_COEFF1[k + 8]) * t + ERF_COEFF1[k + 9]) * t + ERF_COEFF1[k + 10]) * t + // ERF_COEFF1[k + 11]) * t + ERF_COEFF1[k + 12]) * w; } else if(w < 6.9) { int k = (int) w; double t = w - k; k = 13 * (k - 2); y = (((((((((((ERF_COEFF2[k] * t + ERF_COEFF2[k + 1]) * t + // ERF_COEFF2[k + 2]) * t + ERF_COEFF2[k + 3]) * t + ERF_COEFF2[k + 4]) * t + // ERF_COEFF2[k + 5]) * t + ERF_COEFF2[k + 6]) * t + ERF_COEFF2[k + 7]) * t + // ERF_COEFF2[k + 8]) * t + ERF_COEFF2[k + 9]) * t + ERF_COEFF2[k + 10]) * t + // ERF_COEFF2[k + 11]) * t + ERF_COEFF2[k + 12]; y *= y; y *= y; y *= y; y = 1 - y * y; } else if(w == w) { y = 1; } else { return Double.NaN; } return x < 0 ? -y : y; }
[ "public", "static", "double", "erf", "(", "double", "x", ")", "{", "final", "double", "w", "=", "x", "<", "0", "?", "-", "x", ":", "x", ";", "double", "y", ";", "if", "(", "w", "<", "2.2", ")", "{", "double", "t", "=", "w", "*", "w", ";", ...
Error function for Gaussian distributions = Normal distributions. @param x parameter value @return erf(x)
[ "Error", "function", "for", "Gaussian", "distributions", "=", "Normal", "distributions", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/NormalDistribution.java#L292-L327
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/NormalDistribution.java
NormalDistribution.standardNormalQuantile
public static double standardNormalQuantile(double d) { return (d == 0) ? Double.NEGATIVE_INFINITY : // (d == 1) ? Double.POSITIVE_INFINITY : // (Double.isNaN(d) || d < 0 || d > 1) ? Double.NaN // : MathUtil.SQRT2 * -erfcinv(2 * d); }
java
public static double standardNormalQuantile(double d) { return (d == 0) ? Double.NEGATIVE_INFINITY : // (d == 1) ? Double.POSITIVE_INFINITY : // (Double.isNaN(d) || d < 0 || d > 1) ? Double.NaN // : MathUtil.SQRT2 * -erfcinv(2 * d); }
[ "public", "static", "double", "standardNormalQuantile", "(", "double", "d", ")", "{", "return", "(", "d", "==", "0", ")", "?", "Double", ".", "NEGATIVE_INFINITY", ":", "//", "(", "d", "==", "1", ")", "?", "Double", ".", "POSITIVE_INFINITY", ":", "//", ...
Approximate the inverse error function for normal distributions. @param d Quantile. Must be in [0:1], obviously. @return Inverse erf.
[ "Approximate", "the", "inverse", "error", "function", "for", "normal", "distributions", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/NormalDistribution.java#L533-L538
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/MaxExtensionBulkSplit.java
MaxExtensionBulkSplit.partition
@Override public <N extends SpatialComparable> List<List<N>> partition(List<N> spatialObjects, int minEntries, int maxEntries) { List<List<N>> partitions = new ArrayList<>(); List<N> objects = new ArrayList<>(spatialObjects); while (!objects.isEmpty()) { StringBuilder msg = new StringBuilder(); // get the split axis and split point int splitAxis = chooseMaximalExtendedSplitAxis(objects); int splitPoint = chooseBulkSplitPoint(objects.size(), minEntries, maxEntries); if (LOG.isDebugging()) { msg.append("\nsplitAxis ").append(splitAxis); msg.append("\nsplitPoint ").append(splitPoint); } // sort in the right dimension Collections.sort(objects, new SpatialSingleMinComparator(splitAxis)); // insert into partition List<N> partition1 = new ArrayList<>(); for (int i = 0; i < splitPoint; i++) { N o = objects.remove(0); partition1.add(o); } partitions.add(partition1); // copy array if (LOG.isDebugging()) { msg.append("\ncurrent partition ").append(partition1); msg.append("\nremaining objects # ").append(objects.size()); LOG.debugFine(msg.toString()); } } if (LOG.isDebugging()) { LOG.debugFine("partitions " + partitions); } return partitions; }
java
@Override public <N extends SpatialComparable> List<List<N>> partition(List<N> spatialObjects, int minEntries, int maxEntries) { List<List<N>> partitions = new ArrayList<>(); List<N> objects = new ArrayList<>(spatialObjects); while (!objects.isEmpty()) { StringBuilder msg = new StringBuilder(); // get the split axis and split point int splitAxis = chooseMaximalExtendedSplitAxis(objects); int splitPoint = chooseBulkSplitPoint(objects.size(), minEntries, maxEntries); if (LOG.isDebugging()) { msg.append("\nsplitAxis ").append(splitAxis); msg.append("\nsplitPoint ").append(splitPoint); } // sort in the right dimension Collections.sort(objects, new SpatialSingleMinComparator(splitAxis)); // insert into partition List<N> partition1 = new ArrayList<>(); for (int i = 0; i < splitPoint; i++) { N o = objects.remove(0); partition1.add(o); } partitions.add(partition1); // copy array if (LOG.isDebugging()) { msg.append("\ncurrent partition ").append(partition1); msg.append("\nremaining objects # ").append(objects.size()); LOG.debugFine(msg.toString()); } } if (LOG.isDebugging()) { LOG.debugFine("partitions " + partitions); } return partitions; }
[ "@", "Override", "public", "<", "N", "extends", "SpatialComparable", ">", "List", "<", "List", "<", "N", ">", ">", "partition", "(", "List", "<", "N", ">", "spatialObjects", ",", "int", "minEntries", ",", "int", "maxEntries", ")", "{", "List", "<", "Li...
Partitions the specified feature vectors where the split axes are the dimensions with maximum extension. @param spatialObjects the spatial objects to be partitioned @param minEntries the minimum number of entries in a partition @param maxEntries the maximum number of entries in a partition @return the partition of the specified spatial objects
[ "Partitions", "the", "specified", "feature", "vectors", "where", "the", "split", "axes", "are", "the", "dimensions", "with", "maximum", "extension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/MaxExtensionBulkSplit.java#L71-L110
train
elki-project/elki
elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/MaxExtensionBulkSplit.java
MaxExtensionBulkSplit.chooseMaximalExtendedSplitAxis
private int chooseMaximalExtendedSplitAxis(List<? extends SpatialComparable> objects) { // maximum and minimum value for the extension int dimension = objects.get(0).getDimensionality(); double[] maxExtension = new double[dimension]; double[] minExtension = new double[dimension]; Arrays.fill(minExtension, Double.MAX_VALUE); // compute min and max value in each dimension for (SpatialComparable object : objects) { for (int d = 0; d < dimension; d++) { double min, max; min = object.getMin(d); max = object.getMax(d); if (maxExtension[d] < max) { maxExtension[d] = max; } if (minExtension[d] > min) { minExtension[d] = min; } } } // set split axis to dim with maximal extension int splitAxis = -1; double max = 0; for (int d = 0; d < dimension; d++) { double currentExtension = maxExtension[d] - minExtension[d]; if (max < currentExtension) { max = currentExtension; splitAxis = d; } } return splitAxis; }
java
private int chooseMaximalExtendedSplitAxis(List<? extends SpatialComparable> objects) { // maximum and minimum value for the extension int dimension = objects.get(0).getDimensionality(); double[] maxExtension = new double[dimension]; double[] minExtension = new double[dimension]; Arrays.fill(minExtension, Double.MAX_VALUE); // compute min and max value in each dimension for (SpatialComparable object : objects) { for (int d = 0; d < dimension; d++) { double min, max; min = object.getMin(d); max = object.getMax(d); if (maxExtension[d] < max) { maxExtension[d] = max; } if (minExtension[d] > min) { minExtension[d] = min; } } } // set split axis to dim with maximal extension int splitAxis = -1; double max = 0; for (int d = 0; d < dimension; d++) { double currentExtension = maxExtension[d] - minExtension[d]; if (max < currentExtension) { max = currentExtension; splitAxis = d; } } return splitAxis; }
[ "private", "int", "chooseMaximalExtendedSplitAxis", "(", "List", "<", "?", "extends", "SpatialComparable", ">", "objects", ")", "{", "// maximum and minimum value for the extension", "int", "dimension", "=", "objects", ".", "get", "(", "0", ")", ".", "getDimensionalit...
Computes and returns the best split axis. The best split axis is the split axes with the maximal extension. @param objects the spatial objects to be split @return the best split axis
[ "Computes", "and", "returns", "the", "best", "split", "axis", ".", "The", "best", "split", "axis", "is", "the", "split", "axes", "with", "the", "maximal", "extension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-rtree/src/main/java/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/strategies/bulk/MaxExtensionBulkSplit.java#L119-L154
train
elki-project/elki
elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/MutableProgress.java
MutableProgress.setTotal
public void setTotal(int total) throws IllegalArgumentException { if(getProcessed() > total) { throw new IllegalArgumentException(getProcessed() + " exceeds total: " + total); } this.total = total; }
java
public void setTotal(int total) throws IllegalArgumentException { if(getProcessed() > total) { throw new IllegalArgumentException(getProcessed() + " exceeds total: " + total); } this.total = total; }
[ "public", "void", "setTotal", "(", "int", "total", ")", "throws", "IllegalArgumentException", "{", "if", "(", "getProcessed", "(", ")", ">", "total", ")", "{", "throw", "new", "IllegalArgumentException", "(", "getProcessed", "(", ")", "+", "\" exceeds total: \""...
Modify the total value. @param total @throws IllegalArgumentException
[ "Modify", "the", "total", "value", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-logging/src/main/java/de/lmu/ifi/dbs/elki/logging/progress/MutableProgress.java#L70-L75
train
elki-project/elki
elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/datastore/memory/MapRecordStore.java
MapRecordStore.get
@SuppressWarnings("unchecked") protected <T> T get(DBIDRef id, int index) { Object[] d = data.get(DBIDUtil.deref(id)); if(d == null) { return null; } return (T) d[index]; }
java
@SuppressWarnings("unchecked") protected <T> T get(DBIDRef id, int index) { Object[] d = data.get(DBIDUtil.deref(id)); if(d == null) { return null; } return (T) d[index]; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "<", "T", ">", "T", "get", "(", "DBIDRef", "id", ",", "int", "index", ")", "{", "Object", "[", "]", "d", "=", "data", ".", "get", "(", "DBIDUtil", ".", "deref", "(", "id", ")", ")", ...
Actual getter. @param id Database ID @param index column index @param <T> type @return current value
[ "Actual", "getter", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/datastore/memory/MapRecordStore.java#L88-L95
train
elki-project/elki
elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/datastore/memory/MapRecordStore.java
MapRecordStore.set
@SuppressWarnings("unchecked") protected <T> T set(DBIDRef id, int index, T value) { Object[] d = data.get(DBIDUtil.deref(id)); if(d == null) { d = new Object[rlen]; data.put(DBIDUtil.deref(id), d); } T ret = (T) d[index]; d[index] = value; return ret; }
java
@SuppressWarnings("unchecked") protected <T> T set(DBIDRef id, int index, T value) { Object[] d = data.get(DBIDUtil.deref(id)); if(d == null) { d = new Object[rlen]; data.put(DBIDUtil.deref(id), d); } T ret = (T) d[index]; d[index] = value; return ret; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "<", "T", ">", "T", "set", "(", "DBIDRef", "id", ",", "int", "index", ",", "T", "value", ")", "{", "Object", "[", "]", "d", "=", "data", ".", "get", "(", "DBIDUtil", ".", "deref", "("...
Actual setter. @param id Database ID @param index column index @param value new value @param <T> type @return previous value
[ "Actual", "setter", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-dbids/src/main/java/de/lmu/ifi/dbs/elki/database/datastore/memory/MapRecordStore.java#L106-L116
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/estimator/UniformMinMaxEstimator.java
UniformMinMaxEstimator.estimate
public UniformDistribution estimate(DoubleMinMax mm) { return new UniformDistribution(Math.max(mm.getMin(), -Double.MAX_VALUE), Math.min(mm.getMax(), Double.MAX_VALUE)); }
java
public UniformDistribution estimate(DoubleMinMax mm) { return new UniformDistribution(Math.max(mm.getMin(), -Double.MAX_VALUE), Math.min(mm.getMax(), Double.MAX_VALUE)); }
[ "public", "UniformDistribution", "estimate", "(", "DoubleMinMax", "mm", ")", "{", "return", "new", "UniformDistribution", "(", "Math", ".", "max", "(", "mm", ".", "getMin", "(", ")", ",", "-", "Double", ".", "MAX_VALUE", ")", ",", "Math", ".", "min", "("...
Estimate parameters from minimum and maximum observed. @param mm Minimum and Maximum @return Estimation
[ "Estimate", "parameters", "from", "minimum", "and", "maximum", "observed", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/estimator/UniformMinMaxEstimator.java#L69-L71
train
elki-project/elki
addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/scatterplot/index/TreeSphereVisualization.java
TreeSphereVisualization.canVisualize
public static boolean canVisualize(Relation<?> rel, AbstractMTree<?, ?, ?, ?> tree) { if(!TypeUtil.NUMBER_VECTOR_FIELD.isAssignableFromType(rel.getDataTypeInformation())) { return false; } return getLPNormP(tree) > 0; }
java
public static boolean canVisualize(Relation<?> rel, AbstractMTree<?, ?, ?, ?> tree) { if(!TypeUtil.NUMBER_VECTOR_FIELD.isAssignableFromType(rel.getDataTypeInformation())) { return false; } return getLPNormP(tree) > 0; }
[ "public", "static", "boolean", "canVisualize", "(", "Relation", "<", "?", ">", "rel", ",", "AbstractMTree", "<", "?", ",", "?", ",", "?", ",", "?", ">", "tree", ")", "{", "if", "(", "!", "TypeUtil", ".", "NUMBER_VECTOR_FIELD", ".", "isAssignableFromType"...
Test for a visualizable index in the context's database. @param rel Vector relation @param tree Tree to visualize @return whether the tree is visualizable
[ "Test", "for", "a", "visualizable", "index", "in", "the", "context", "s", "database", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/batikvis/src/main/java/de/lmu/ifi/dbs/elki/visualization/visualizers/scatterplot/index/TreeSphereVisualization.java#L146-L151
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/transform/NumberVectorRandomFeatureSelectionFilter.java
NumberVectorRandomFeatureSelectionFilter.initializeRandomAttributes
void initializeRandomAttributes(SimpleTypeInformation<V> in) { int d = ((VectorFieldTypeInformation<V>) in).getDimensionality(); selectedAttributes = BitsUtil.random(k, d, rnd.getSingleThreadedRandom()); }
java
void initializeRandomAttributes(SimpleTypeInformation<V> in) { int d = ((VectorFieldTypeInformation<V>) in).getDimensionality(); selectedAttributes = BitsUtil.random(k, d, rnd.getSingleThreadedRandom()); }
[ "void", "initializeRandomAttributes", "(", "SimpleTypeInformation", "<", "V", ">", "in", ")", "{", "int", "d", "=", "(", "(", "VectorFieldTypeInformation", "<", "V", ">", ")", "in", ")", ".", "getDimensionality", "(", ")", ";", "selectedAttributes", "=", "Bi...
Initialize random attributes. Invoke this from {@link #convertedType}! @param in Type information.
[ "Initialize", "random", "attributes", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/transform/NumberVectorRandomFeatureSelectionFilter.java#L103-L106
train
elki-project/elki
elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/GreedyEnsembleExperiment.java
GreedyEnsembleExperiment.singleEnsemble
protected void singleEnsemble(final double[] ensemble, final NumberVector vec) { double[] buf = new double[1]; for(int i = 0; i < ensemble.length; i++) { buf[0] = vec.doubleValue(i); ensemble[i] = voting.combine(buf, 1); if(Double.isNaN(ensemble[i])) { LOG.warning("NaN after combining: " + FormatUtil.format(buf) + " " + voting.toString()); } } applyScaling(ensemble, scaling); }
java
protected void singleEnsemble(final double[] ensemble, final NumberVector vec) { double[] buf = new double[1]; for(int i = 0; i < ensemble.length; i++) { buf[0] = vec.doubleValue(i); ensemble[i] = voting.combine(buf, 1); if(Double.isNaN(ensemble[i])) { LOG.warning("NaN after combining: " + FormatUtil.format(buf) + " " + voting.toString()); } } applyScaling(ensemble, scaling); }
[ "protected", "void", "singleEnsemble", "(", "final", "double", "[", "]", "ensemble", ",", "final", "NumberVector", "vec", ")", "{", "double", "[", "]", "buf", "=", "new", "double", "[", "1", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<"...
Build a single-element "ensemble". @param ensemble @param vec
[ "Build", "a", "single", "-", "element", "ensemble", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki/src/main/java/de/lmu/ifi/dbs/elki/application/greedyensemble/GreedyEnsembleExperiment.java#L489-L499
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/OptionUtil.java
OptionUtil.getFullDescription
public static String getFullDescription(Parameter<?> param) { StringBuilder description = new StringBuilder(1000) // .append(param.getShortDescription()).append(FormatUtil.NEWLINE); param.describeValues(description); if(!FormatUtil.endsWith(description, FormatUtil.NEWLINE)) { description.append(FormatUtil.NEWLINE); } if(param.hasDefaultValue()) { description.append("Default: ").append(param.getDefaultValueAsString()).append(FormatUtil.NEWLINE); } List<? extends ParameterConstraint<?>> constraints = param.getConstraints(); if(constraints != null && !constraints.isEmpty()) { description.append((constraints.size() == 1) ? "Constraint: " : "Constraints: ") // .append(constraints.get(0).getDescription(param.getOptionID().getName())); for(int i = 1; i < constraints.size(); i++) { description.append(", ").append(constraints.get(i).getDescription(param.getOptionID().getName())); } description.append(FormatUtil.NEWLINE); } return description.toString(); }
java
public static String getFullDescription(Parameter<?> param) { StringBuilder description = new StringBuilder(1000) // .append(param.getShortDescription()).append(FormatUtil.NEWLINE); param.describeValues(description); if(!FormatUtil.endsWith(description, FormatUtil.NEWLINE)) { description.append(FormatUtil.NEWLINE); } if(param.hasDefaultValue()) { description.append("Default: ").append(param.getDefaultValueAsString()).append(FormatUtil.NEWLINE); } List<? extends ParameterConstraint<?>> constraints = param.getConstraints(); if(constraints != null && !constraints.isEmpty()) { description.append((constraints.size() == 1) ? "Constraint: " : "Constraints: ") // .append(constraints.get(0).getDescription(param.getOptionID().getName())); for(int i = 1; i < constraints.size(); i++) { description.append(", ").append(constraints.get(i).getDescription(param.getOptionID().getName())); } description.append(FormatUtil.NEWLINE); } return description.toString(); }
[ "public", "static", "String", "getFullDescription", "(", "Parameter", "<", "?", ">", "param", ")", "{", "StringBuilder", "description", "=", "new", "StringBuilder", "(", "1000", ")", "//", ".", "append", "(", "param", ".", "getShortDescription", "(", ")", ")...
Format a parameter description. @param param Parameter @return Parameter description
[ "Format", "a", "parameter", "description", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/OptionUtil.java#L78-L98
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/OptionUtil.java
OptionUtil.println
private static void println(StringBuilder buf, int width, String data) { for(String line : FormatUtil.splitAtLastBlank(data, width)) { buf.append(line); if(!line.endsWith(FormatUtil.NEWLINE)) { buf.append(FormatUtil.NEWLINE); } } }
java
private static void println(StringBuilder buf, int width, String data) { for(String line : FormatUtil.splitAtLastBlank(data, width)) { buf.append(line); if(!line.endsWith(FormatUtil.NEWLINE)) { buf.append(FormatUtil.NEWLINE); } } }
[ "private", "static", "void", "println", "(", "StringBuilder", "buf", ",", "int", "width", ",", "String", "data", ")", "{", "for", "(", "String", "line", ":", "FormatUtil", ".", "splitAtLastBlank", "(", "data", ",", "width", ")", ")", "{", "buf", ".", "...
Simple writing helper with no indentation. @param buf Buffer to write to @param width Width to use for linewraps @param data Data to write.
[ "Simple", "writing", "helper", "with", "no", "indentation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/optionhandling/OptionUtil.java#L107-L114
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateSimplifiedSilhouette.java
EvaluateSimplifiedSilhouette.centroids
public static int centroids(Relation<? extends NumberVector> rel, List<? extends Cluster<?>> clusters, NumberVector[] centroids, NoiseHandling noiseOption) { assert (centroids.length == clusters.size()); int ignorednoise = 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: ignorednoise += cluster.size(); case TREAT_NOISE_AS_SINGLETONS: centroids[i] = null; continue; case MERGE_NOISE: break; // Treat as cluster below } } centroids[i] = ModelUtil.getPrototypeOrCentroid(cluster.getModel(), rel, cluster.getIDs()); } return ignorednoise; }
java
public static int centroids(Relation<? extends NumberVector> rel, List<? extends Cluster<?>> clusters, NumberVector[] centroids, NoiseHandling noiseOption) { assert (centroids.length == clusters.size()); int ignorednoise = 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: ignorednoise += cluster.size(); case TREAT_NOISE_AS_SINGLETONS: centroids[i] = null; continue; case MERGE_NOISE: break; // Treat as cluster below } } centroids[i] = ModelUtil.getPrototypeOrCentroid(cluster.getModel(), rel, cluster.getIDs()); } return ignorednoise; }
[ "public", "static", "int", "centroids", "(", "Relation", "<", "?", "extends", "NumberVector", ">", "rel", ",", "List", "<", "?", "extends", "Cluster", "<", "?", ">", ">", "clusters", ",", "NumberVector", "[", "]", "centroids", ",", "NoiseHandling", "noiseO...
Compute centroids. @param rel Data relation @param clusters Clusters @param centroids Output array for centroids @return Number of ignored noise elements.
[ "Compute", "centroids", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/evaluation/clustering/internal/EvaluateSimplifiedSilhouette.java#L216-L236
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/LaplaceDistribution.java
LaplaceDistribution.cdf
public static double cdf(double val, double rate) { final double v = .5 * FastMath.exp(-rate * Math.abs(val)); return (v == Double.POSITIVE_INFINITY) ? ((val <= 0) ? 0 : 1) : // (val < 0) ? v : 1 - v; }
java
public static double cdf(double val, double rate) { final double v = .5 * FastMath.exp(-rate * Math.abs(val)); return (v == Double.POSITIVE_INFINITY) ? ((val <= 0) ? 0 : 1) : // (val < 0) ? v : 1 - v; }
[ "public", "static", "double", "cdf", "(", "double", "val", ",", "double", "rate", ")", "{", "final", "double", "v", "=", ".5", "*", "FastMath", ".", "exp", "(", "-", "rate", "*", "Math", ".", "abs", "(", "val", ")", ")", ";", "return", "(", "v", ...
Cumulative density, static version @param val Value to compute CDF at @param rate Rate parameter (1/scale) @return cumulative density
[ "Cumulative", "density", "static", "version" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/distribution/LaplaceDistribution.java#L167-L171
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/AbstractCoverTree.java
AbstractCoverTree.maxDistance
protected double maxDistance(DoubleDBIDList elems) { double max = 0; for(DoubleDBIDListIter it = elems.iter(); it.valid(); it.advance()) { final double v = it.doubleValue(); max = max > v ? max : v; } return max; }
java
protected double maxDistance(DoubleDBIDList elems) { double max = 0; for(DoubleDBIDListIter it = elems.iter(); it.valid(); it.advance()) { final double v = it.doubleValue(); max = max > v ? max : v; } return max; }
[ "protected", "double", "maxDistance", "(", "DoubleDBIDList", "elems", ")", "{", "double", "max", "=", "0", ";", "for", "(", "DoubleDBIDListIter", "it", "=", "elems", ".", "iter", "(", ")", ";", "it", ".", "valid", "(", ")", ";", "it", ".", "advance", ...
Find maximum in a list via scanning. @param elems Elements @return Maximum distance
[ "Find", "maximum", "in", "a", "list", "via", "scanning", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/AbstractCoverTree.java#L133-L140
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/AbstractCoverTree.java
AbstractCoverTree.excludeNotCovered
protected void excludeNotCovered(ModifiableDoubleDBIDList candidates, double fmax, ModifiableDoubleDBIDList collect) { for(DoubleDBIDListIter it = candidates.iter(); it.valid();) { if(it.doubleValue() > fmax) { collect.add(it.doubleValue(), it); candidates.removeSwap(it.getOffset()); } else { it.advance(); // Keep in candidates } } }
java
protected void excludeNotCovered(ModifiableDoubleDBIDList candidates, double fmax, ModifiableDoubleDBIDList collect) { for(DoubleDBIDListIter it = candidates.iter(); it.valid();) { if(it.doubleValue() > fmax) { collect.add(it.doubleValue(), it); candidates.removeSwap(it.getOffset()); } else { it.advance(); // Keep in candidates } } }
[ "protected", "void", "excludeNotCovered", "(", "ModifiableDoubleDBIDList", "candidates", ",", "double", "fmax", ",", "ModifiableDoubleDBIDList", "collect", ")", "{", "for", "(", "DoubleDBIDListIter", "it", "=", "candidates", ".", "iter", "(", ")", ";", "it", ".", ...
Retain all elements within the current cover. @param candidates Candidates @param fmax Maximum distance @param collect Far neighbors
[ "Retain", "all", "elements", "within", "the", "current", "cover", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/AbstractCoverTree.java#L173-L183
train
elki-project/elki
elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/AbstractCoverTree.java
AbstractCoverTree.collectByCover
protected void collectByCover(DBIDRef cur, ModifiableDoubleDBIDList candidates, double fmax, ModifiableDoubleDBIDList collect) { assert (collect.size() == 0) : "Not empty"; DoubleDBIDListIter it = candidates.iter().advance(); // Except first = cur! while(it.valid()) { assert (!DBIDUtil.equal(cur, it)); final double dist = distance(cur, it); if(dist <= fmax) { // Collect collect.add(dist, it); candidates.removeSwap(it.getOffset()); } else { it.advance(); // Keep in candidates, outside cover radius. } } }
java
protected void collectByCover(DBIDRef cur, ModifiableDoubleDBIDList candidates, double fmax, ModifiableDoubleDBIDList collect) { assert (collect.size() == 0) : "Not empty"; DoubleDBIDListIter it = candidates.iter().advance(); // Except first = cur! while(it.valid()) { assert (!DBIDUtil.equal(cur, it)); final double dist = distance(cur, it); if(dist <= fmax) { // Collect collect.add(dist, it); candidates.removeSwap(it.getOffset()); } else { it.advance(); // Keep in candidates, outside cover radius. } } }
[ "protected", "void", "collectByCover", "(", "DBIDRef", "cur", ",", "ModifiableDoubleDBIDList", "candidates", ",", "double", "fmax", ",", "ModifiableDoubleDBIDList", "collect", ")", "{", "assert", "(", "collect", ".", "size", "(", ")", "==", "0", ")", ":", "\"N...
Collect all elements with respect to a new routing object. @param cur Routing object @param candidates Candidate list @param fmax Maximum distance @param collect Output list
[ "Collect", "all", "elements", "with", "respect", "to", "a", "new", "routing", "object", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index-various/src/main/java/de/lmu/ifi/dbs/elki/index/tree/metrical/covertree/AbstractCoverTree.java#L193-L207
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/KernelDensityEstimator.java
KernelDensityEstimator.process
private void process(double[] data, double min, double max, KernelDensityFunction kernel, int window, double epsilon) { dens = new double[data.length]; var = new double[data.length]; // This is the desired bandwidth of the kernel. double halfwidth = ((max - min) / window) * .5; for (int current = 0; current < data.length; current++) { double value = 0.0; for (int i = current; i >= 0; i--) { double delta = Math.abs(data[i] - data[current]) / halfwidth; final double contrib = kernel.density(delta); value += contrib; if (contrib < epsilon) { break; } } for (int i = current + 1; i < data.length; i++) { double delta = Math.abs(data[i] - data[current]) / halfwidth; final double contrib = kernel.density(delta); value += contrib; if (contrib < epsilon) { break; } } double realwidth = (Math.min(data[current] + halfwidth, max) - Math.max(min, data[current] - halfwidth)); double weight = realwidth / (2 * halfwidth); dens[current] = value / (data.length * realwidth * .5); var[current] = 1 / weight; } }
java
private void process(double[] data, double min, double max, KernelDensityFunction kernel, int window, double epsilon) { dens = new double[data.length]; var = new double[data.length]; // This is the desired bandwidth of the kernel. double halfwidth = ((max - min) / window) * .5; for (int current = 0; current < data.length; current++) { double value = 0.0; for (int i = current; i >= 0; i--) { double delta = Math.abs(data[i] - data[current]) / halfwidth; final double contrib = kernel.density(delta); value += contrib; if (contrib < epsilon) { break; } } for (int i = current + 1; i < data.length; i++) { double delta = Math.abs(data[i] - data[current]) / halfwidth; final double contrib = kernel.density(delta); value += contrib; if (contrib < epsilon) { break; } } double realwidth = (Math.min(data[current] + halfwidth, max) - Math.max(min, data[current] - halfwidth)); double weight = realwidth / (2 * halfwidth); dens[current] = value / (data.length * realwidth * .5); var[current] = 1 / weight; } }
[ "private", "void", "process", "(", "double", "[", "]", "data", ",", "double", "min", ",", "double", "max", ",", "KernelDensityFunction", "kernel", ",", "int", "window", ",", "double", "epsilon", ")", "{", "dens", "=", "new", "double", "[", "data", ".", ...
Process a new array @param data data to use (must be sorted!) @param min minimum value @param max maximum value @param kernel Kernel function to use @param window window size @param epsilon Precision threshold
[ "Process", "a", "new", "array" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/KernelDensityEstimator.java#L73-L103
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java
AbstractLayout3DPC.computeSimilarityMatrix
public static double[] computeSimilarityMatrix(DependenceMeasure sim, Relation<? extends NumberVector> rel) { final int dim = RelationUtil.dimensionality(rel); // TODO: we could use less memory (no copy), but this would likely be // slower. Maybe as a fallback option? double[][] data = new double[dim][rel.size()]; int r = 0; for(DBIDIter it = rel.iterDBIDs(); it.valid(); it.advance(), r++) { NumberVector v = rel.get(it); for(int d = 0; d < dim; d++) { data[d][r] = v.doubleValue(d); } } return sim.dependence(DoubleArrayAdapter.STATIC, Arrays.asList(data)); }
java
public static double[] computeSimilarityMatrix(DependenceMeasure sim, Relation<? extends NumberVector> rel) { final int dim = RelationUtil.dimensionality(rel); // TODO: we could use less memory (no copy), but this would likely be // slower. Maybe as a fallback option? double[][] data = new double[dim][rel.size()]; int r = 0; for(DBIDIter it = rel.iterDBIDs(); it.valid(); it.advance(), r++) { NumberVector v = rel.get(it); for(int d = 0; d < dim; d++) { data[d][r] = v.doubleValue(d); } } return sim.dependence(DoubleArrayAdapter.STATIC, Arrays.asList(data)); }
[ "public", "static", "double", "[", "]", "computeSimilarityMatrix", "(", "DependenceMeasure", "sim", ",", "Relation", "<", "?", "extends", "NumberVector", ">", "rel", ")", "{", "final", "int", "dim", "=", "RelationUtil", ".", "dimensionality", "(", "rel", ")", ...
Compute a column-wise dependency matrix for the given relation. @param sim Dependence measure @param rel Vector relation @return Similarity matrix (lower triangular form)
[ "Compute", "a", "column", "-", "wise", "dependency", "matrix", "for", "the", "given", "relation", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java#L80-L93
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java
AbstractLayout3DPC.buildSpanningTree
protected N buildSpanningTree(int dim, double[] mat, Layout layout) { assert (layout.edges == null || layout.edges.size() == 0); int[] iedges = PrimsMinimumSpanningTree.processDense(mat, new LowerTriangularAdapter(dim)); int root = findOptimalRoot(iedges); // Convert edges: ArrayList<Edge> edges = new ArrayList<>(iedges.length >> 1); for(int i = 1; i < iedges.length; i += 2) { edges.add(new Edge(iedges[i - 1], iedges[i])); } layout.edges = edges; // Prefill nodes array with nulls. ArrayList<N> nodes = new ArrayList<>(dim); for(int i = 0; i < dim; i++) { nodes.add(null); } layout.nodes = nodes; N rootnode = buildTree(iedges, root, -1, nodes); return rootnode; }
java
protected N buildSpanningTree(int dim, double[] mat, Layout layout) { assert (layout.edges == null || layout.edges.size() == 0); int[] iedges = PrimsMinimumSpanningTree.processDense(mat, new LowerTriangularAdapter(dim)); int root = findOptimalRoot(iedges); // Convert edges: ArrayList<Edge> edges = new ArrayList<>(iedges.length >> 1); for(int i = 1; i < iedges.length; i += 2) { edges.add(new Edge(iedges[i - 1], iedges[i])); } layout.edges = edges; // Prefill nodes array with nulls. ArrayList<N> nodes = new ArrayList<>(dim); for(int i = 0; i < dim; i++) { nodes.add(null); } layout.nodes = nodes; N rootnode = buildTree(iedges, root, -1, nodes); return rootnode; }
[ "protected", "N", "buildSpanningTree", "(", "int", "dim", ",", "double", "[", "]", "mat", ",", "Layout", "layout", ")", "{", "assert", "(", "layout", ".", "edges", "==", "null", "||", "layout", ".", "edges", ".", "size", "(", ")", "==", "0", ")", "...
Build the minimum spanning tree. @param mat Similarity matrix @param layout Layout to write to @return Root node id
[ "Build", "the", "minimum", "spanning", "tree", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java#L133-L154
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java
AbstractLayout3DPC.buildTree
protected N buildTree(int[] msg, int cur, int parent, ArrayList<N> nodes) { // Count the number of children: int c = 0; for(int i = 1; i < msg.length; i += 2) { if((msg[i - 1] == cur && msg[i] != parent) || (msg[i] == cur && msg[i - 1] != parent)) { c++; } } // Build children: List<N> children = Collections.emptyList(); if(c > 0) { children = new ArrayList<>(c); for(int i = 1; i < msg.length; i += 2) { if(msg[i - 1] == cur && msg[i] != parent) { children.add(buildTree(msg, msg[i], cur, nodes)); } else if(msg[i] == cur && msg[i - 1] != parent) { children.add(buildTree(msg, msg[i - 1], cur, nodes)); } } } N node = makeNode(cur, children); nodes.set(cur, node); return node; }
java
protected N buildTree(int[] msg, int cur, int parent, ArrayList<N> nodes) { // Count the number of children: int c = 0; for(int i = 1; i < msg.length; i += 2) { if((msg[i - 1] == cur && msg[i] != parent) || (msg[i] == cur && msg[i - 1] != parent)) { c++; } } // Build children: List<N> children = Collections.emptyList(); if(c > 0) { children = new ArrayList<>(c); for(int i = 1; i < msg.length; i += 2) { if(msg[i - 1] == cur && msg[i] != parent) { children.add(buildTree(msg, msg[i], cur, nodes)); } else if(msg[i] == cur && msg[i - 1] != parent) { children.add(buildTree(msg, msg[i - 1], cur, nodes)); } } } N node = makeNode(cur, children); nodes.set(cur, node); return node; }
[ "protected", "N", "buildTree", "(", "int", "[", "]", "msg", ",", "int", "cur", ",", "int", "parent", ",", "ArrayList", "<", "N", ">", "nodes", ")", "{", "// Count the number of children:", "int", "c", "=", "0", ";", "for", "(", "int", "i", "=", "1", ...
Recursive tree build method. @param msg Minimum spanning graph @param cur Current node @param parent Parent node @param nodes Nodes array to fill - must be preinitialized with nulls! @return Tree of nodes
[ "Recursive", "tree", "build", "method", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java#L167-L191
train
elki-project/elki
addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java
AbstractLayout3DPC.maxDepth
protected int maxDepth(Layout.Node node) { int depth = 0; for(int i = 0; i < node.numChildren(); i++) { depth = Math.max(depth, maxDepth(node.getChild(i))); } return depth + 1; }
java
protected int maxDepth(Layout.Node node) { int depth = 0; for(int i = 0; i < node.numChildren(); i++) { depth = Math.max(depth, maxDepth(node.getChild(i))); } return depth + 1; }
[ "protected", "int", "maxDepth", "(", "Layout", ".", "Node", "node", ")", "{", "int", "depth", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "node", ".", "numChildren", "(", ")", ";", "i", "++", ")", "{", "depth", "=", "Math", ...
Compute the depth of the graph. @param node Current node @return Depth
[ "Compute", "the", "depth", "of", "the", "graph", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/addons/3dpc/src/main/java/de/lmu/ifi/dbs/elki/visualization/parallel3d/layout/AbstractLayout3DPC.java#L199-L205
train
elki-project/elki
elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java
IndexTree.initialize
@Override public void initialize() { TreeIndexHeader header = createHeader(); if(this.file.initialize(header)) { initializeFromFile(header, file); } rootEntry = createRootEntry(); }
java
@Override public void initialize() { TreeIndexHeader header = createHeader(); if(this.file.initialize(header)) { initializeFromFile(header, file); } rootEntry = createRootEntry(); }
[ "@", "Override", "public", "void", "initialize", "(", ")", "{", "TreeIndexHeader", "header", "=", "createHeader", "(", ")", ";", "if", "(", "this", ".", "file", ".", "initialize", "(", "header", ")", ")", "{", "initializeFromFile", "(", "header", ",", "f...
Initialize the tree if the page file already existed.
[ "Initialize", "the", "tree", "if", "the", "page", "file", "already", "existed", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java#L93-L100
train
elki-project/elki
elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java
IndexTree.getNode
public N getNode(int nodeID) { if(nodeID == getPageID(rootEntry)) { return getRoot(); } else { return file.readPage(nodeID); } }
java
public N getNode(int nodeID) { if(nodeID == getPageID(rootEntry)) { return getRoot(); } else { return file.readPage(nodeID); } }
[ "public", "N", "getNode", "(", "int", "nodeID", ")", "{", "if", "(", "nodeID", "==", "getPageID", "(", "rootEntry", ")", ")", "{", "return", "getRoot", "(", ")", ";", "}", "else", "{", "return", "file", ".", "readPage", "(", "nodeID", ")", ";", "}"...
Returns the node with the specified id. @param nodeID the page id of the node to be returned @return the node with the specified id
[ "Returns", "the", "node", "with", "the", "specified", "id", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java#L165-L172
train
elki-project/elki
elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java
IndexTree.initializeFromFile
public void initializeFromFile(TreeIndexHeader header, PageFile<N> file) { this.dirCapacity = header.getDirCapacity(); this.leafCapacity = header.getLeafCapacity(); this.dirMinimum = header.getDirMinimum(); this.leafMinimum = header.getLeafMinimum(); if(getLogger().isDebugging()) { StringBuilder msg = new StringBuilder(); msg.append(getClass()); msg.append("\n file = ").append(file.getClass()); getLogger().debugFine(msg.toString()); } this.initialized = true; }
java
public void initializeFromFile(TreeIndexHeader header, PageFile<N> file) { this.dirCapacity = header.getDirCapacity(); this.leafCapacity = header.getLeafCapacity(); this.dirMinimum = header.getDirMinimum(); this.leafMinimum = header.getLeafMinimum(); if(getLogger().isDebugging()) { StringBuilder msg = new StringBuilder(); msg.append(getClass()); msg.append("\n file = ").append(file.getClass()); getLogger().debugFine(msg.toString()); } this.initialized = true; }
[ "public", "void", "initializeFromFile", "(", "TreeIndexHeader", "header", ",", "PageFile", "<", "N", ">", "file", ")", "{", "this", ".", "dirCapacity", "=", "header", ".", "getDirCapacity", "(", ")", ";", "this", ".", "leafCapacity", "=", "header", ".", "g...
Initializes this index from an existing persistent file. @param header File header @param file Page file
[ "Initializes", "this", "index", "from", "an", "existing", "persistent", "file", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java#L219-L233
train
elki-project/elki
elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java
IndexTree.initialize
protected final void initialize(E exampleLeaf) { initializeCapacities(exampleLeaf); // create empty root createEmptyRoot(exampleLeaf); final Logging log = getLogger(); if(log.isStatistics()) { String cls = this.getClass().getName(); log.statistics(new LongStatistic(cls + ".directory.capacity", dirCapacity)); log.statistics(new LongStatistic(cls + ".directory.minfill", dirMinimum)); log.statistics(new LongStatistic(cls + ".leaf.capacity", leafCapacity)); log.statistics(new LongStatistic(cls + ".leaf.minfill", leafMinimum)); } initialized = true; }
java
protected final void initialize(E exampleLeaf) { initializeCapacities(exampleLeaf); // create empty root createEmptyRoot(exampleLeaf); final Logging log = getLogger(); if(log.isStatistics()) { String cls = this.getClass().getName(); log.statistics(new LongStatistic(cls + ".directory.capacity", dirCapacity)); log.statistics(new LongStatistic(cls + ".directory.minfill", dirMinimum)); log.statistics(new LongStatistic(cls + ".leaf.capacity", leafCapacity)); log.statistics(new LongStatistic(cls + ".leaf.minfill", leafMinimum)); } initialized = true; }
[ "protected", "final", "void", "initialize", "(", "E", "exampleLeaf", ")", "{", "initializeCapacities", "(", "exampleLeaf", ")", ";", "// create empty root", "createEmptyRoot", "(", "exampleLeaf", ")", ";", "final", "Logging", "log", "=", "getLogger", "(", ")", "...
Initializes the index. @param exampleLeaf an object that will be stored in the index
[ "Initializes", "the", "index", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-index/src/main/java/de/lmu/ifi/dbs/elki/index/tree/IndexTree.java#L240-L256
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/MeanVarianceMinMax.java
MeanVarianceMinMax.newArray
public static MeanVarianceMinMax[] newArray(int dimensionality) { MeanVarianceMinMax[] arr = new MeanVarianceMinMax[dimensionality]; for(int i = 0; i < dimensionality; i++) { arr[i] = new MeanVarianceMinMax(); } return arr; }
java
public static MeanVarianceMinMax[] newArray(int dimensionality) { MeanVarianceMinMax[] arr = new MeanVarianceMinMax[dimensionality]; for(int i = 0; i < dimensionality; i++) { arr[i] = new MeanVarianceMinMax(); } return arr; }
[ "public", "static", "MeanVarianceMinMax", "[", "]", "newArray", "(", "int", "dimensionality", ")", "{", "MeanVarianceMinMax", "[", "]", "arr", "=", "new", "MeanVarianceMinMax", "[", "dimensionality", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<...
Create and initialize a new array of MeanVarianceMinMax @param dimensionality Dimensionality @return New and initialized Array
[ "Create", "and", "initialize", "a", "new", "array", "of", "MeanVarianceMinMax" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/MeanVarianceMinMax.java#L187-L193
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/weightfunctions/ExponentialStddevWeight.java
ExponentialStddevWeight.getWeight
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } double scaleddistance = distance / stddev; return stddev * FastMath.exp(-.5 * scaleddistance); }
java
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } double scaleddistance = distance / stddev; return stddev * FastMath.exp(-.5 * scaleddistance); }
[ "@", "Override", "public", "double", "getWeight", "(", "double", "distance", ",", "double", "max", ",", "double", "stddev", ")", "{", "if", "(", "stddev", "<=", "0", ")", "{", "return", "1", ";", "}", "double", "scaleddistance", "=", "distance", "/", "...
Get exponential weight, max is ignored.
[ "Get", "exponential", "weight", "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/ExponentialStddevWeight.java#L41-L48
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/AbstractDependenceMeasure.java
AbstractDependenceMeasure.sortedIndex
protected static <A> int[] sortedIndex(final NumberArrayAdapter<?, A> adapter, final A data, int len) { int[] s1 = MathUtil.sequence(0, len); IntegerArrayQuickSort.sort(s1, (x, y) -> Double.compare(adapter.getDouble(data, x), adapter.getDouble(data, y))); return s1; }
java
protected static <A> int[] sortedIndex(final NumberArrayAdapter<?, A> adapter, final A data, int len) { int[] s1 = MathUtil.sequence(0, len); IntegerArrayQuickSort.sort(s1, (x, y) -> Double.compare(adapter.getDouble(data, x), adapter.getDouble(data, y))); return s1; }
[ "protected", "static", "<", "A", ">", "int", "[", "]", "sortedIndex", "(", "final", "NumberArrayAdapter", "<", "?", ",", "A", ">", "adapter", ",", "final", "A", "data", ",", "int", "len", ")", "{", "int", "[", "]", "s1", "=", "MathUtil", ".", "sequ...
Build a sorted index of objects. @param adapter Data adapter @param data Data array @param len Length of data @return Sorted index
[ "Build", "a", "sorted", "index", "of", "objects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/AbstractDependenceMeasure.java#L128-L132
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/AbstractDependenceMeasure.java
AbstractDependenceMeasure.discretize
protected static <A> int[] discretize(NumberArrayAdapter<?, A> adapter, A data, final int len, final int bins) { double min = adapter.getDouble(data, 0), max = min; for(int i = 1; i < len; i++) { double v = adapter.getDouble(data, i); if(v < min) { min = v; } else if(v > max) { max = v; } } final double scale = (max > min) ? bins / (max - min) : 1; int[] discData = new int[len]; for(int i = 0; i < len; i++) { int bin = (int) Math.floor((adapter.getDouble(data, i) - min) * scale); discData[i] = bin < 0 ? 0 : bin >= bins ? bins - 1 : bin; } return discData; }
java
protected static <A> int[] discretize(NumberArrayAdapter<?, A> adapter, A data, final int len, final int bins) { double min = adapter.getDouble(data, 0), max = min; for(int i = 1; i < len; i++) { double v = adapter.getDouble(data, i); if(v < min) { min = v; } else if(v > max) { max = v; } } final double scale = (max > min) ? bins / (max - min) : 1; int[] discData = new int[len]; for(int i = 0; i < len; i++) { int bin = (int) Math.floor((adapter.getDouble(data, i) - min) * scale); discData[i] = bin < 0 ? 0 : bin >= bins ? bins - 1 : bin; } return discData; }
[ "protected", "static", "<", "A", ">", "int", "[", "]", "discretize", "(", "NumberArrayAdapter", "<", "?", ",", "A", ">", "adapter", ",", "A", "data", ",", "final", "int", "len", ",", "final", "int", "bins", ")", "{", "double", "min", "=", "adapter", ...
Discretize a data set into equi-width bin numbers. @param adapter Data adapter @param data Data array @param len Length of data @param bins Number of bins @return Array of bin numbers [0;bin[
[ "Discretize", "a", "data", "set", "into", "equi", "-", "width", "bin", "numbers", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/statistics/dependence/AbstractDependenceMeasure.java#L143-L161
train
elki-project/elki
elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/configurator/AbstractParameterConfigurator.java
AbstractParameterConfigurator.finishGridRow
protected void finishGridRow() { GridBagConstraints constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 0; final JLabel icon; if(param.isOptional()) { if(param.isDefined() && param.tookDefaultValue() && !(param instanceof Flag)) { // TODO: better icon for default value? icon = new JLabel(StockIcon.getStockIcon(StockIcon.DIALOG_INFORMATION)); icon.setToolTipText("Default value: "+param.getDefaultValueAsString()); } else { icon = new JLabel(); icon.setMinimumSize(new Dimension(16, 16)); } } else { if(!param.isDefined()) { icon = new JLabel(StockIcon.getStockIcon(StockIcon.DIALOG_ERROR)); icon.setToolTipText("Missing value."); } else { icon = new JLabel(); icon.setMinimumSize(new Dimension(16, 16)); } } parent.add(icon, constraints); }
java
protected void finishGridRow() { GridBagConstraints constraints = new GridBagConstraints(); constraints.gridwidth = GridBagConstraints.REMAINDER; constraints.weightx = 0; final JLabel icon; if(param.isOptional()) { if(param.isDefined() && param.tookDefaultValue() && !(param instanceof Flag)) { // TODO: better icon for default value? icon = new JLabel(StockIcon.getStockIcon(StockIcon.DIALOG_INFORMATION)); icon.setToolTipText("Default value: "+param.getDefaultValueAsString()); } else { icon = new JLabel(); icon.setMinimumSize(new Dimension(16, 16)); } } else { if(!param.isDefined()) { icon = new JLabel(StockIcon.getStockIcon(StockIcon.DIALOG_ERROR)); icon.setToolTipText("Missing value."); } else { icon = new JLabel(); icon.setMinimumSize(new Dimension(16, 16)); } } parent.add(icon, constraints); }
[ "protected", "void", "finishGridRow", "(", ")", "{", "GridBagConstraints", "constraints", "=", "new", "GridBagConstraints", "(", ")", ";", "constraints", ".", "gridwidth", "=", "GridBagConstraints", ".", "REMAINDER", ";", "constraints", ".", "weightx", "=", "0", ...
Complete the current grid row, adding the icon at the end
[ "Complete", "the", "current", "grid", "row", "adding", "the", "icon", "at", "the", "end" ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-gui-minigui/src/main/java/de/lmu/ifi/dbs/elki/gui/configurator/AbstractParameterConfigurator.java#L80-L107
train
elki-project/elki
elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/normalization/columnwise/AttributeWiseVarianceNormalization.java
AttributeWiseVarianceNormalization.normalize
private double normalize(int d, double val) { d = (mean.length == 1) ? 0 : d; return (val - mean[d]) / stddev[d]; }
java
private double normalize(int d, double val) { d = (mean.length == 1) ? 0 : d; return (val - mean[d]) / stddev[d]; }
[ "private", "double", "normalize", "(", "int", "d", ",", "double", "val", ")", "{", "d", "=", "(", "mean", ".", "length", "==", "1", ")", "?", "0", ":", "d", ";", "return", "(", "val", "-", "mean", "[", "d", "]", ")", "/", "stddev", "[", "d", ...
Normalize a single dimension. @param d Dimension @param val Value @return Normalized value
[ "Normalize", "a", "single", "dimension", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-input/src/main/java/de/lmu/ifi/dbs/elki/datasource/filter/normalization/columnwise/AttributeWiseVarianceNormalization.java#L170-L173
train
elki-project/elki
elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/PCAResult.java
PCAResult.processDecomposition
private static EigenPair[] processDecomposition(EigenvalueDecomposition evd) { double[] eigenvalues = evd.getRealEigenvalues(); double[][] eigenvectors = evd.getV(); EigenPair[] eigenPairs = new EigenPair[eigenvalues.length]; for(int i = 0; i < eigenvalues.length; i++) { double e = Math.abs(eigenvalues[i]); double[] v = VMath.getCol(eigenvectors, i); eigenPairs[i] = new EigenPair(v, e); } Arrays.sort(eigenPairs, Comparator.reverseOrder()); return eigenPairs; }
java
private static EigenPair[] processDecomposition(EigenvalueDecomposition evd) { double[] eigenvalues = evd.getRealEigenvalues(); double[][] eigenvectors = evd.getV(); EigenPair[] eigenPairs = new EigenPair[eigenvalues.length]; for(int i = 0; i < eigenvalues.length; i++) { double e = Math.abs(eigenvalues[i]); double[] v = VMath.getCol(eigenvectors, i); eigenPairs[i] = new EigenPair(v, e); } Arrays.sort(eigenPairs, Comparator.reverseOrder()); return eigenPairs; }
[ "private", "static", "EigenPair", "[", "]", "processDecomposition", "(", "EigenvalueDecomposition", "evd", ")", "{", "double", "[", "]", "eigenvalues", "=", "evd", ".", "getRealEigenvalues", "(", ")", ";", "double", "[", "]", "[", "]", "eigenvectors", "=", "...
Convert an eigenvalue decomposition into EigenPair objects. @param evd Eigenvalue decomposition @return Eigenpairs
[ "Convert", "an", "eigenvalue", "decomposition", "into", "EigenPair", "objects", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-math/src/main/java/de/lmu/ifi/dbs/elki/math/linearalgebra/pca/PCAResult.java#L85-L97
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/parallel/KMeansProcessor.java
KMeansProcessor.nextIteration
public void nextIteration(double[][] means) { this.means = means; changed = false; final int k = means.length; final int dim = means[0].length; centroids = new double[k][dim]; sizes = new int[k]; Arrays.fill(varsum, 0.); }
java
public void nextIteration(double[][] means) { this.means = means; changed = false; final int k = means.length; final int dim = means[0].length; centroids = new double[k][dim]; sizes = new int[k]; Arrays.fill(varsum, 0.); }
[ "public", "void", "nextIteration", "(", "double", "[", "]", "[", "]", "means", ")", "{", "this", ".", "means", "=", "means", ";", "changed", "=", "false", ";", "final", "int", "k", "=", "means", ".", "length", ";", "final", "int", "dim", "=", "mean...
Initialize for a new iteration. @param means New means.
[ "Initialize", "for", "a", "new", "iteration", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/parallel/KMeansProcessor.java#L118-L126
train
elki-project/elki
elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/parallel/KMeansProcessor.java
KMeansProcessor.getMeans
public double[][] getMeans() { double[][] newmeans = new double[centroids.length][]; for(int i = 0; i < centroids.length; i++) { if(sizes[i] == 0) { newmeans[i] = means[i]; // Keep old mean. continue; } newmeans[i] = centroids[i]; } return newmeans; }
java
public double[][] getMeans() { double[][] newmeans = new double[centroids.length][]; for(int i = 0; i < centroids.length; i++) { if(sizes[i] == 0) { newmeans[i] = means[i]; // Keep old mean. continue; } newmeans[i] = centroids[i]; } return newmeans; }
[ "public", "double", "[", "]", "[", "]", "getMeans", "(", ")", "{", "double", "[", "]", "[", "]", "newmeans", "=", "new", "double", "[", "centroids", ".", "length", "]", "[", "", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cent...
Get the new means. @return New means
[ "Get", "the", "new", "means", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-clustering/src/main/java/de/lmu/ifi/dbs/elki/algorithm/clustering/kmeans/parallel/KMeansProcessor.java#L162-L172
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.format
public static String format(double[] v, int w, int d) { DecimalFormat format = new DecimalFormat(); format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); format.setMinimumIntegerDigits(1); format.setMaximumFractionDigits(d); format.setMinimumFractionDigits(d); format.setGroupingUsed(false); int width = w + 1; StringBuilder msg = new StringBuilder() // .append('\n'); // start on new line. for(int i = 0; i < v.length; i++) { String s = format.format(v[i]); // format the number // At _least_ 1 whitespace is added whitespace(msg, Math.max(1, width - s.length())).append(s); } return msg.toString(); }
java
public static String format(double[] v, int w, int d) { DecimalFormat format = new DecimalFormat(); format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US)); format.setMinimumIntegerDigits(1); format.setMaximumFractionDigits(d); format.setMinimumFractionDigits(d); format.setGroupingUsed(false); int width = w + 1; StringBuilder msg = new StringBuilder() // .append('\n'); // start on new line. for(int i = 0; i < v.length; i++) { String s = format.format(v[i]); // format the number // At _least_ 1 whitespace is added whitespace(msg, Math.max(1, width - s.length())).append(s); } return msg.toString(); }
[ "public", "static", "String", "format", "(", "double", "[", "]", "v", ",", "int", "w", ",", "int", "d", ")", "{", "DecimalFormat", "format", "=", "new", "DecimalFormat", "(", ")", ";", "format", ".", "setDecimalFormatSymbols", "(", "new", "DecimalFormatSym...
Returns a string representation of this vector. @param w column width @param d number of digits after the decimal @return a string representation of this matrix
[ "Returns", "a", "string", "representation", "of", "this", "vector", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L240-L257
train
elki-project/elki
elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java
FormatUtil.formatTo
public static StringBuilder formatTo(StringBuilder buf, double[] d, String sep) { if(d == null) { return buf.append("null"); } if(d.length == 0) { return buf; } buf.append(d[0]); for(int i = 1; i < d.length; i++) { buf.append(sep).append(d[i]); } return buf; }
java
public static StringBuilder formatTo(StringBuilder buf, double[] d, String sep) { if(d == null) { return buf.append("null"); } if(d.length == 0) { return buf; } buf.append(d[0]); for(int i = 1; i < d.length; i++) { buf.append(sep).append(d[i]); } return buf; }
[ "public", "static", "StringBuilder", "formatTo", "(", "StringBuilder", "buf", ",", "double", "[", "]", "d", ",", "String", "sep", ")", "{", "if", "(", "d", "==", "null", ")", "{", "return", "buf", ".", "append", "(", "\"null\"", ")", ";", "}", "if", ...
Formats the double array d with the default number format. @param buf String builder to append to @param d the double array to be formatted @param sep separator between the single values of the array, e.g. ',' @return Output buffer buf
[ "Formats", "the", "double", "array", "d", "with", "the", "default", "number", "format", "." ]
b54673327e76198ecd4c8a2a901021f1a9174498
https://github.com/elki-project/elki/blob/b54673327e76198ecd4c8a2a901021f1a9174498/elki-core-util/src/main/java/de/lmu/ifi/dbs/elki/utilities/io/FormatUtil.java#L267-L279
train