code
stringlengths
73
34.1k
label
stringclasses
1 value
public static int lengthWithoutLinefeed(CharSequence line) { int length = line.length(); while(length > 0) { char last = line.charAt(length - 1); if(last != '\n' && last != '\r') { break; } --length; } return length; }
java
public synchronized void logAndClearReportedErrors() { for(ParameterException e : getErrors()) { if(LOG.isDebugging()) { LOG.warning(e.getMessage(), e); } else { LOG.warning(e.getMessage()); } } clearErrors(); }
java
public void addParameter(Object owner, Parameter<?> param, TrackParameters track) { this.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED)); ParameterConfigurator cfg = null; { // Find Object cur = owner; while(cur != null) { cfg = childconfig.get(cur); if(cfg != null) { ...
java
protected static <E extends MTreeEntry, N extends AbstractMTreeNode<?, N, E>> double[][] computeDistanceMatrix(AbstractMTree<?, N, E, ?> tree, N node) { final int n = node.getNumEntries(); double[][] distancematrix = new double[n][n]; // Build distance matrix for(int i = 0; i < n; i++) { E ei = no...
java
protected static double sparsity(final int setsize, final int dbsize, final int k, final double phi) { // calculate sparsity c final double fK = MathUtil.powi(1. / phi, k); return (setsize - (dbsize * fK)) / FastMath.sqrt(dbsize * fK * (1 - fK)); }
java
protected DBIDs computeSubspace(int[] subspace, ArrayList<ArrayList<DBIDs>> ranges) { HashSetModifiableDBIDs ids = DBIDUtil.newHashSet(ranges.get(subspace[0]).get(subspace[1])); // intersect all selected dimensions for(int i = 2, e = subspace.length - 1; i < e; i += 2) { DBIDs current = ranges.get(sub...
java
protected DBIDs computeSubspaceForGene(short[] gene, ArrayList<ArrayList<DBIDs>> ranges) { HashSetModifiableDBIDs m = null; // intersect all present restrictions for(int i = 0; i < gene.length; i++) { if(gene[i] != DONT_CARE) { DBIDs current = ranges.get(i).get(gene[i] - GENE_OFFSET); ...
java
private static void updateFilterSDASet(double mib, List<SteepDownArea> sdaset, double ixi) { Iterator<SteepDownArea> iter = sdaset.iterator(); while(iter.hasNext()) { SteepDownArea sda = iter.next(); if(sda.getMaximum() * ixi <= mib) { iter.remove(); } else { // Update ...
java
private static void sort5(double[] keys, int[] vals, final int m1, final int m2, final int m3, final int m4, final int m5) { if(keys[m1] > keys[m2]) { swap(keys, vals, m1, m2); } if(keys[m3] > keys[m4]) { swap(keys, vals, m3, m4); } // Merge 1+2 and 3+4 if(keys[m2] > keys[m4]) { ...
java
private static void swap(double[] keys, int[] vals, int j, int i) { double td = keys[j]; keys[j] = keys[i]; keys[i] = td; int ti = vals[j]; vals[j] = vals[i]; vals[i] = ti; }
java
public EvaluationResult.MeasurementGroup newGroup(String string) { EvaluationResult.MeasurementGroup g = new MeasurementGroup(string); groups.add(g); return g; }
java
public EvaluationResult.MeasurementGroup findOrCreateGroup(String label) { for(EvaluationResult.MeasurementGroup g : groups) { if(label.equals(g.getName())) { return g; } } return newGroup(label); }
java
public int numLines() { int r = header.size(); for(MeasurementGroup m : groups) { r += 1 + m.measurements.size(); } return r; }
java
public static EvaluationResult findOrCreate(ResultHierarchy hierarchy, Result parent, String name, String shortname) { ArrayList<EvaluationResult> ers = ResultUtil.filterResults(hierarchy, parent, EvaluationResult.class); EvaluationResult ev = null; for(EvaluationResult e : ers) { if(shortname.equals(...
java
public Document cloneDocument(DOMImplementation domImpl, Document document) { Element root = document.getDocumentElement(); // New document Document result = domImpl.createDocument(root.getNamespaceURI(), root.getNodeName(), null); Element rroot = result.getDocumentElement(); // Cloning the document...
java
public Node cloneNode(Document doc, Node eold) { return doc.importNode(eold, true); }
java
public void copyAttributes(Document doc, Element eold, Element enew) { if(eold.hasAttributes()) { NamedNodeMap attr = eold.getAttributes(); int len = attr.getLength(); for(int i = 0; i < len; i++) { enew.setAttributeNode((Attr) doc.importNode(attr.item(i), true)); } } }
java
protected String getFilename(Object result, String filenamepre) { if(filenamepre == null || filenamepre.length() == 0) { filenamepre = "result"; } for(int i = 0;; i++) { String filename = i > 0 ? filenamepre + "-" + i : filenamepre; Object existing = filenames.get(filename); if(exist...
java
@SuppressWarnings("unchecked") public void output(Database db, Result r, StreamFactory streamOpener, Pattern filter) throws IOException { List<Relation<?>> ra = new LinkedList<>(); List<OrderingResult> ro = new LinkedList<>(); List<Clustering<?>> rc = new LinkedList<>(); List<IterableResult<?>> ri = n...
java
@Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); out.writeObject(approximation); }
java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); approximation = (PolynomialApproximation) in.readObject(); }
java
private WritableIntegerDataStore computeSubtreeSizes(DBIDs order) { WritableIntegerDataStore siz = DataStoreUtil.makeIntegerStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, 1); DBIDVar v1 = DBIDUtil.newVar(); for(DBIDIter it = order.iter(); it.valid(); it.advance()) { if(DBIDUtil.e...
java
private WritableDoubleDataStore computeMaxHeight() { WritableDoubleDataStore maxheight = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_HOT | DataStoreFactory.HINT_TEMP, 0.); DBIDVar v1 = DBIDUtil.newVar(); for(DBIDIter it = ids.iter(); it.valid(); it.advance()) { double d = parentDistance...
java
public ArrayDBIDs topologicalSort() { ArrayModifiableDBIDs ids = DBIDUtil.newArray(this.ids); if(mergeOrder != null) { ids.sort(new DataStoreUtil.AscendingByIntegerDataStore(mergeOrder)); WritableDoubleDataStore maxheight = computeMaxHeight(); ids.sort(new Sorter(maxheight)); maxheight.d...
java
public static int[] range(int start, int end) { int[] out = new int[end - start]; for(int i = 0, j = start; j < end; i++, j++) { out[i] = j; } return out; }
java
private void doReverseKNNQuery(int k, DBIDRef q, ModifiableDoubleDBIDList result, ModifiableDBIDs candidates) { final ComparableMinHeap<MTreeSearchCandidate> pq = new ComparableMinHeap<>(); // push root pq.add(new MTreeSearchCandidate(0., getRootID(), null, Double.NaN)); // search in tree while(!p...
java
protected void expirePage(P page) { if(LOG.isDebuggingFine()) { LOG.debugFine("Write to backing:" + page.getPageID()); } if (page.isDirty()) { file.writePage(page); } }
java
public void setCacheSize(int cacheSize) { this.cacheSize = cacheSize; long toDelete = map.size() - this.cacheSize; if(toDelete <= 0) { return; } List<Integer> keys = new ArrayList<>(map.keySet()); Collections.reverse(keys); for(Integer id : keys) { P page = map.remove(id); ...
java
public static String getFilenameExtension(String name) { if(name == null) { return null; } int index = name.lastIndexOf('.'); return index < 0 ? null : name.substring(index + 1).toLowerCase(); }
java
public static InputStream tryGzipInput(InputStream in) throws IOException { // try autodetecting gzip compression. if(!in.markSupported()) { PushbackInputStream pb = new PushbackInputStream(in, 16); // read a magic from the file header, and push it back byte[] magic = { 0, 0 }; int r = p...
java
public static File locateFile(String name, String basedir) { // Try exact match first. File f = new File(name); if(f.exists()) { return f; } // Try with base directory if(basedir != null) { if((f = new File(basedir, name)).exists()) { return f; } } // try stripp...
java
protected void addInternal(double dist, int id) { if(size == dists.length) { grow(); } dists[size] = dist; ids[size] = id; ++size; }
java
protected void grow() { if(dists == EMPTY_DISTS) { dists = new double[INITIAL_SIZE]; ids = new int[INITIAL_SIZE]; return; } final int len = dists.length; final int newlength = len + (len >> 1) + 1; double[] odists = dists; dists = new double[newlength]; System.arraycopy(odi...
java
protected void reverse() { for(int i = 0, j = size - 1; i < j; i++, j--) { double tmpd = dists[j]; dists[j] = dists[i]; dists[i] = tmpd; int tmpi = ids[j]; ids[j] = ids[i]; ids[i] = tmpi; } }
java
public void truncate(int newsize) { if(newsize < size) { double[] odists = dists; dists = new double[newsize]; System.arraycopy(odists, 0, dists, 0, newsize); int[] oids = ids; ids = new int[newsize]; System.arraycopy(oids, 0, ids, 0, newsize); size = newsize; } }
java
private RectangleArranger<PlotItem> arrangeVisualizations(double width, double height) { if(!(width > 0. && height > 0.)) { LOG.warning("No size information during arrange()", new Throwable()); return new RectangleArranger<>(1., 1.); } RectangleArranger<PlotItem> plotmap = new RectangleArranger<...
java
public void initialize(double ratio) { if(!(ratio > 0 && ratio < Double.POSITIVE_INFINITY)) { LOG.warning("Invalid ratio: " + ratio, new Throwable()); ratio = 1.4; } this.ratio = ratio; if(plot != null) { LOG.warning("Already initialized."); lazyRefresh(); return; } ...
java
private void initializePlot() { plot = new VisualizationPlot(); { // Add a background element: CSSClass cls = new CSSClass(this, "background"); final String bgcol = context.getStyleLibrary().getBackgroundColor(StyleLibrary.PAGE); cls.setStatement(SVGConstants.CSS_FILL_PROPERTY, bgcol); p...
java
private Visualization embedOrThumbnail(final int thumbsize, PlotItem it, VisualizationTask task, Element parent) { final Visualization vis; if(!single) { vis = task.getFactory().makeVisualizationOrThumbnail(context, task, plot, it.w, it.h, it.proj, thumbsize); } else { vis = task.getFactory(...
java
protected boolean visibleInOverview(VisualizationTask task) { return task.isVisible() && !task.has(single ? RenderFlag.NO_EMBED : RenderFlag.NO_THUMBNAIL); }
java
private void recalcViewbox() { final Element root = plot.getRoot(); // Reset plot attributes SVGUtil.setAtt(root, SVGConstants.SVG_WIDTH_ATTRIBUTE, "20cm"); SVGUtil.setAtt(root, SVGConstants.SVG_HEIGHT_ATTRIBUTE, SVGUtil.fmt(20 * plotmap.getHeight() / plotmap.getWidth()) + "cm"); String vb = "0 0 " ...
java
protected void triggerSubplotSelectEvent(PlotItem it) { // forward event to all listeners. for(ActionListener actionListener : actionListeners) { actionListener.actionPerformed(new DetailViewSelectedEvent(this, ActionEvent.ACTION_PERFORMED, null, 0, it)); } }
java
public static double cdf(double val, double mu, double sigma, double xi) { val = (val - mu) / sigma; // Check support: if(val < 0) { return 0.; } if(xi < 0 && val > -1. / xi) { return 1.; } return 1 - FastMath.pow(1 + xi * val, -1. / xi); }
java
public static double quantile(double val, double mu, double sigma, double xi) { if(val < 0.0 || val > 1.0) { return Double.NaN; } if(xi == 0.) { return mu - sigma * FastMath.log(1 - val); } return mu - sigma / xi * (1 - FastMath.pow(1 - val, -xi)); }
java
public Result run(Database database, Relation<O> relation, Relation<NumberVector> radrel) { if(queries != null) { throw new AbortException("This 'run' method will not use the given query set!"); } // Get a distance and kNN query instance. DistanceQuery<O> distQuery = database.getDistanceQuery(rela...
java
public static long[] random(int card, int capacity, Random random) { if(card < 0 || card > capacity) { throw new IllegalArgumentException("Cannot set " + card + " out of " + capacity + " bits."); } // FIXME: Avoid recomputing the cardinality. if(card < capacity >>> 1) { long[] bitset = BitsU...
java
public static long[] copy(long[] v, int mincap) { int words = ((mincap - 1) >>> LONG_LOG2_SIZE) + 1; if(v.length == words) { return Arrays.copyOf(v, v.length); } long[] ret = new long[words]; System.arraycopy(v, 0, ret, 0, Math.min(v.length, words)); return ret; }
java
public static boolean isZero(long[] v) { for(int i = 0; i < v.length; i++) { if(v[i] != 0) { return false; } } return true; }
java
public static long[] setI(long[] v, long[] o) { assert (o.length <= v.length) : "Bit set sizes do not agree."; final int max = Math.min(v.length, o.length); for(int i = 0; i < max; i++) { v[i] = o[i]; } return v; }
java
public static void onesI(long[] v, int bits) { final int fillWords = bits >>> LONG_LOG2_SIZE; final int fillBits = bits & LONG_LOG2_MASK; Arrays.fill(v, 0, fillWords, LONG_ALL_BITS); if(fillBits > 0) { v[fillWords] = (1L << fillBits) - 1; } if(fillWords + 1 < v.length) { Arrays.fill(...
java
public static long[] xorI(long[] v, long[] o) { assert (o.length <= v.length) : "Bit set sizes do not agree."; for(int i = 0; i < o.length; i++) { v[i] ^= o[i]; } return v; }
java
public static long[] orI(long[] v, long[] o) { assert (o.length <= v.length) : "Bit set sizes do not agree."; final int max = Math.min(v.length, o.length); for(int i = 0; i < max; i++) { v[i] |= o[i]; } return v; }
java
public static long[] andI(long[] v, long[] o) { int i = 0; for(; i < o.length; i++) { v[i] &= o[i]; } // Zero higher words Arrays.fill(v, i, v.length, 0); return v; }
java
public static long[] nandI(long[] v, long[] o) { int i = 0; for(; i < o.length; i++) { v[i] &= ~o[i]; } return v; }
java
public static long[] invertI(long[] v) { for(int i = 0; i < v.length; i++) { v[i] = ~v[i]; } return v; }
java
public static long cycleLeftC(long v, int shift, int len) { return shift == 0 ? v : shift < 0 ? cycleRightC(v, -shift, len) : // (((v) << (shift)) | ((v) >>> ((len) - (shift)))) & ((1 << len) - 1); }
java
public static long[] cycleLeftI(long[] v, int shift, int len) { long[] t = copy(v, len, shift); return orI(shiftRightI(v, len - shift), truncateI(t, len)); }
java
public static int numberOfTrailingZerosSigned(long[] v) { for(int p = 0;; p++) { if(p == v.length) { return -1; } if(v[p] != 0) { return Long.numberOfTrailingZeros(v[p]) + p * Long.SIZE; } } }
java
public static int numberOfLeadingZerosSigned(long[] v) { for(int p = 0, ip = v.length - 1; p < v.length; p++, ip--) { if(v[ip] != 0) { return Long.numberOfLeadingZeros(v[ip]) + p * Long.SIZE; } } return -1; }
java
public static int previousClearBit(long v, int start) { if(start < 0) { return -1; } start = start < Long.SIZE ? start : Long.SIZE - 1; long cur = ~v & (LONG_ALL_BITS >>> -(start + 1)); return cur == 0 ? -1 : 63 - Long.numberOfLeadingZeros(cur); }
java
public static int nextSetBit(long v, int start) { if(start >= Long.SIZE) { return -1; } start = start < 0 ? 0 : start; long cur = v & (LONG_ALL_BITS << start); return cur == 0 ? -1 : cur == LONG_ALL_BITS ? 0 : Long.numberOfTrailingZeros(cur); }
java
public static boolean intersect(long[] x, long[] y) { final int min = (x.length < y.length) ? x.length : y.length; for(int i = 0; i < min; i++) { if((x[i] & y[i]) != 0L) { return true; } } return false; }
java
public static int intersectionSize(long[] x, long[] y) { final int lx = x.length, ly = y.length; final int min = (lx < ly) ? lx : ly; int res = 0; for(int i = 0; i < min; i++) { res += Long.bitCount(x[i] & y[i]); } return res; }
java
public static int unionSize(long[] x, long[] y) { final int lx = x.length, ly = y.length; final int min = (lx < ly) ? lx : ly; int i = 0, res = 0; for(; i < min; i++) { res += Long.bitCount(x[i] | y[i]); } for(; i < lx; i++) { res += Long.bitCount(x[i]); } for(; i < ly; i++) ...
java
public static boolean equal(long[] x, long[] y) { if(x == null || y == null) { return (x == null) && (y == null); } int p = Math.min(x.length, y.length) - 1; for(int i = x.length - 1; i > p; i--) { if(x[i] != 0L) { return false; } } for(int i = y.length - 1; i > p; i--)...
java
public static int compare(long[] x, long[] y) { if(x == null) { return (y == null) ? 0 : -1; } if(y == null) { return +1; } int p = Math.min(x.length, y.length) - 1; for(int i = x.length - 1; i > p; i--) { if(x[i] != 0) { return +1; } } for(int i = y.lengt...
java
@Override public int compareTo(DistanceEntry<E> o) { int comp = Double.compare(distance, o.distance); return comp; // return comp != 0 ? comp : // entry.getEntryID().compareTo(o.entry.getEntryID()); }
java
private double[] knnDistances(O object) { KNNList knns = knnq.getKNNForObject(object, getKmax() - 1); double[] distances = new double[getKmax()]; int i = 0; for(DoubleDBIDListIter iter = knns.iter(); iter.valid() && i < getKmax(); iter.advance(), i++) { distances[i] = iter.doubleValue(); } ...
java
protected double downsample(double[] data, int start, int end, int size) { double sum = 0; for (int i = start; i < end; i++) { sum += data[i]; } return sum; }
java
public void setRotationZ(double rotationZ) { this.rotationZ = rotationZ; this.cosZ = FastMath.cos(rotationZ); this.sinZ = FastMath.sin(rotationZ); fireCameraChangedEvent(); }
java
public void apply(GL2 gl) { // 3D projection gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); // Perspective. glu.gluPerspective(35, ratio, 1, 1000); glu.gluLookAt(distance * sinZ, distance * -cosZ, height, // pos 0, 0, .5, // center 0, 0, 1 // up ); // Change bac...
java
public void project(double x, double y, double z, double[] out) { glu.gluProject(x, y, z, modelview, 0, projection, 0, viewp, 0, out, 0); }
java
public void addCameraListener(CameraListener lis) { if (listeners == null) { listeners = new ArrayList<>(5); } listeners.add(lis); }
java
public static AffineTransformation axisProjection(int dim, int ax1, int ax2) { // setup a projection to get the data into the interval -1:+1 in each // dimension with the intended-to-see dimensions first. AffineTransformation proj = AffineTransformation.reorderAxesTransformation(dim, ax1, ax2); // Assum...
java
protected ApproximationLine conservativeKnnDistanceApproximation(int k_max) { // determine k_0, y_1, y_kmax int k_0 = k_max; double y_1 = Double.NEGATIVE_INFINITY; double y_kmax = Double.NEGATIVE_INFINITY; for(int i = 0; i < getNumEntries(); i++) { MkCoPEntry entry = getEntry(i); Approx...
java
protected ApproximationLine progressiveKnnDistanceApproximation(int k_max) { if(!isLeaf()) { throw new UnsupportedOperationException("Progressive KNN-distance approximation " + "is only vailable in leaf nodes!"); } // determine k_0, y_1, y_kmax int k_0 = 0; double y_1 = Double.POSITIVE_INFINI...
java
public CSSClass addClass(CSSClass clss) throws CSSNamingConflict { CSSClass existing = store.get(clss.getName()); if (existing != null && existing.getOwner() != null && existing.getOwner() != clss.getOwner()) { throw new CSSNamingConflict("CSS class naming conflict between "+clss.getOwner().toString()+" a...
java
public synchronized void removeClass(CSSClass clss) { CSSClass existing = store.get(clss.getName()); if (existing == clss) { store.remove(existing.getName()); } }
java
public CSSClass getClass(String name, Object owner) throws CSSNamingConflict { CSSClass existing = store.get(name); // Not found. if (existing == null) { return null; } // Different owner if (owner != null && existing.getOwner() != owner) { throw new CSSNamingConflict("CSS class nami...
java
public void serialize(StringBuilder buf) { for (CSSClass clss : store.values()) { clss.appendCSSDefinition(buf); } }
java
public boolean mergeCSSFrom(CSSClassManager other) throws CSSNamingConflict { for (CSSClass clss : other.getClasses()) { this.addClass(clss); } return true; }
java
public void updateStyleElement(Document document, Element style) { StringBuilder buf = new StringBuilder(); serialize(buf); Text cont = document.createTextNode(buf.toString()); while (style.hasChildNodes()) { style.removeChild(style.getFirstChild()); } style.appendChild(cont); }
java
private static double calculate_MDEF_norm(Node sn, Node cg) { // get the square sum of the counting neighborhoods box counts long sq = sn.getSquareSum(cg.getLevel() - sn.getLevel()); /* * if the square sum is equal to box count of the sampling Neighborhood then * n_hat is equal one, and as cg need...
java
public void writeBundleStream(BundleStreamSource source, WritableByteChannel output) throws IOException { ByteBuffer buffer = ByteBuffer.allocateDirect(INITIAL_BUFFER); DBIDVar var = DBIDUtil.newVar(); ByteBufferSerializer<?>[] serializers = null; loop: while(true) { BundleStreamSource.Event ev =...
java
private void flushBuffer(ByteBuffer buffer, WritableByteChannel output) throws IOException { buffer.flip(); output.write(buffer); buffer.flip(); buffer.limit(buffer.capacity()); }
java
private ByteBuffer ensureBuffer(int size, ByteBuffer buffer, WritableByteChannel output) throws IOException { if(buffer.remaining() >= size) { return buffer; } flushBuffer(buffer, output); if(buffer.remaining() >= size) { return buffer; } // Aggressively grow the buffer return By...
java
private ByteBufferSerializer<?>[] writeHeader(BundleStreamSource source, ByteBuffer buffer, WritableByteChannel output) throws IOException { final BundleMeta meta = source.getMeta(); final int nummeta = meta.size(); @SuppressWarnings("rawtypes") final ByteBufferSerializer[] serializers = new ByteBufferS...
java
protected void runDBSCAN(Relation<O> relation, RangeQuery<O> rangeQuery) { final int size = relation.size(); FiniteProgress objprog = LOG.isVerbose() ? new FiniteProgress("Processing objects", size, LOG) : null; IndefiniteProgress clusprog = LOG.isVerbose() ? new IndefiniteProgress("Number of clusters", LOG...
java
protected void expandCluster(Relation<O> relation, RangeQuery<O> rangeQuery, DBIDRef startObjectID, ArrayModifiableDBIDs seeds, FiniteProgress objprog, IndefiniteProgress clusprog) { DoubleDBIDList neighbors = rangeQuery.getRangeForDBID(startObjectID, epsilon); ncounter += neighbors.size(); // startObject ...
java
private void processNeighbors(DoubleDBIDListIter neighbor, ModifiableDBIDs currentCluster, ArrayModifiableDBIDs seeds) { final boolean ismetric = getDistanceFunction().isMetric(); for(; neighbor.valid(); neighbor.advance()) { if(processedIDs.add(neighbor)) { if(!ismetric || neighbor.doubleValue() ...
java
private double loglikelihoodAnomalous(DBIDs anomalousObjs) { return anomalousObjs.isEmpty() ? 0 : anomalousObjs.size() * -FastMath.log(anomalousObjs.size()); }
java
private double loglikelihoodNormal(DBIDs objids, SetDBIDs anomalous, CovarianceMatrix builder, Relation<V> relation) { double[] mean = builder.getMeanVector(); final LUDecomposition lu = new LUDecomposition(builder.makeSampleMatrix()); double[][] covInv = lu.inverse(); // for each object compute probabi...
java
private DoubleMinMax exactMinMax(Relation<O> relation, DistanceQuery<O> distFunc) { final FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("Exact fitting distance computations", relation.size(), LOG) : null; DoubleMinMax minmax = new DoubleMinMax(); // find exact minimum and maximum first. ...
java
@Override protected void preInsert(RdKNNEntry entry) { KNNHeap knns_o = DBIDUtil.newHeap(settings.k_max); preInsert(entry, getRootEntry(), knns_o); }
java
@Override protected void postDelete(RdKNNEntry entry) { // reverse knn of o ModifiableDoubleDBIDList rnns = DBIDUtil.newDistanceDBIDList(); doReverseKNN(getRoot(), ((RdKNNLeafEntry) entry).getDBID(), rnns); // knn of rnn ArrayModifiableDBIDs ids = DBIDUtil.newArray(rnns); ids.sort(); List...
java
private void doReverseKNN(RdKNNNode node, DBID oid, ModifiableDoubleDBIDList result) { if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { RdKNNLeafEntry entry = (RdKNNLeafEntry) node.getEntry(i); double distance = distanceQuery.distance(entry.getDBID(), oid); if(distan...
java
private void doBulkReverseKNN(RdKNNNode node, DBIDs ids, Map<DBID, ModifiableDoubleDBIDList> result) { if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { RdKNNLeafEntry entry = (RdKNNLeafEntry) node.getEntry(i); for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { ...
java
private void checkDistanceFunction(SpatialPrimitiveDistanceFunction<? super O> distanceFunction) { if(!settings.distanceFunction.equals(distanceFunction)) { throw new IllegalArgumentException("Parameter distanceFunction must be an instance of " + this.distanceQuery.getClass() + ", but is " + distanceFunction....
java
@Override public final void insertAll(DBIDs ids) { if(ids.isEmpty() || (ids.size() == 1)) { return; } // Make an example leaf if(canBulkLoad()) { List<RdKNNEntry> leafs = new ArrayList<>(ids.size()); for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { leafs.add(c...
java
public int correlationDistance(PCAFilteredResult pca1, PCAFilteredResult pca2, int dimensionality) { // TODO: Can we delay copying the matrixes? // pca of rv1 double[][] v1t = copy(pca1.getEigenvectors()); double[][] v1t_strong = pca1.getStrongEigenvectors(); int lambda1 = pca1.getCorrelationDimensi...
java