code
stringlengths
73
34.1k
label
stringclasses
1 value
private static void parseLine(Class<?> parent, char[] line, int begin, int end) { while(begin < end && line[begin] == ' ') { begin++; } if(begin >= end || line[begin] == '#') { return; // Empty/comment lines are okay, continue } // Find end of class name: int cend = begin + 1; wh...
java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { super.readExternal(in); this.knnDistance = in.readDouble(); }
java
private Pair<Pair<KNNQuery<O>, KNNQuery<O>>, Pair<RKNNQuery<O>, RKNNQuery<O>>> getKNNAndRkNNQueries(Database database, Relation<O> relation, StepProgress stepprog) { DistanceQuery<O> drefQ = database.getDistanceQuery(relation, referenceDistanceFunction); // Use "HEAVY" flag, since this is an online algorithm ...
java
public COPACNeighborPredicate.Instance instantiate(Database database, Relation<V> relation) { DistanceQuery<V> dq = database.getDistanceQuery(relation, EuclideanDistanceFunction.STATIC); KNNQuery<V> knnq = database.getKNNQuery(dq, settings.k); WritableDataStore<COPACModel> storage = DataStoreUtil.makeStora...
java
protected COPACModel computeLocalModel(DBIDRef id, DoubleDBIDList knnneighbors, Relation<V> relation) { PCAResult epairs = settings.pca.processIds(knnneighbors, relation); int pdim = settings.filter.filter(epairs.getEigenvalues()); PCAFilteredResult pcares = new PCAFilteredResult(epairs.getEigenPairs(), pdi...
java
public ModifiableHyperBoundingBox computeMBR() { E firstEntry = getEntry(0); if(firstEntry == null) { return null; } // Note: we deliberately get a cloned copy here, since we will modify it. ModifiableHyperBoundingBox mbr = new ModifiableHyperBoundingBox(firstEntry); for(int i = 1; i < num...
java
public void applyCamera(GL2 gl) { // Setup projection. gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45f, // fov, width / (float) height, // ratio 0.f, 10.f); // near, far clipping eye[0] = (float) Math.sin(theta) * 2.f; eye[1] = .5f; eye[2] = (f...
java
private void linearScanBatchKNN(ArrayDBIDs ids, List<KNNHeap> heaps) { final DistanceQuery<O> dq = distanceQuery; // The distance is computed on database IDs for(DBIDIter iter = getRelation().getDBIDs().iter(); iter.valid(); iter.advance()) { int index = 0; for(DBIDIter iter2 = ids.iter(); iter2...
java
public static double[][] computeWeightMatrix(int bpp) { final int dim = bpp * bpp * bpp; final double[][] m = new double[dim][dim]; // maximum occurring distance in manhattan between bins: final double max = 3. * (bpp - 1.); for(int x = 0; x < dim; x++) { final int rx = (x / bpp) / bpp; ...
java
protected void initializeDataExtends(Relation<NumberVector> relation, int dim, double[] min, double[] extend) { assert (min.length == dim && extend.length == dim); // if no parameter for min max compute min max values for each dimension // from dataset if(minima == null || maxima == null || minima.lengt...
java
static protected int countSharedNeighbors(DBIDs neighbors1, DBIDs neighbors2) { int intersection = 0; DBIDIter iter1 = neighbors1.iter(); DBIDIter iter2 = neighbors2.iter(); while(iter1.valid() && iter2.valid()) { final int comp = DBIDUtil.compare(iter1, iter2); if(comp == 0) { inter...
java
protected static <O> DoubleIntPair[] rankReferencePoints(DistanceQuery<O> distanceQuery, O obj, ArrayDBIDs referencepoints) { DoubleIntPair[] priority = new DoubleIntPair[referencepoints.size()]; // Compute distances to reference points. for(DBIDArrayIter iter = referencepoints.iter(); iter.valid(); iter.ad...
java
protected static void binarySearch(ModifiableDoubleDBIDList index, DoubleDBIDListIter iter, double val) { // Binary search. TODO: move this into the DoubleDBIDList class. int left = 0, right = index.size(); while(left < right) { final int mid = (left + right) >>> 1; final double curd = iter.seek...
java
public Result runAlgorithms(Database database) { ResultHierarchy hier = database.getHierarchy(); if(LOG.isStatistics()) { boolean first = true; for(It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) { if(first) { LOG.statistics("Index stati...
java
public CollectionResult<double[]> run(Database database, Relation<O> rel) { DistanceQuery<O> dq = rel.getDistanceQuery(getDistanceFunction()); int size = rel.size(); long pairs = (size * (long) size) >> 1; final long ssize = sampling <= 1 ? (long) Math.ceil(sampling * pairs) : (long) sampling; if(s...
java
protected boolean parseLineInternal() { // Split into numerical attributes and labels int i = 0; for(/* initialized by nextLineExceptComents()! */; tokenizer.valid(); tokenizer.advance(), i++) { if(!isLabelColumn(i) && !tokenizer.isQuoted()) { try { attributes.add(tokenizer.getDouble...
java
SimpleTypeInformation<V> getTypeInformation(int mindim, int maxdim) { if(mindim > maxdim) { throw new AbortException("No vectors were read from the input file - cannot determine vector data type."); } if(mindim == maxdim) { String[] colnames = null; if(columnnames != null && mindim <= colu...
java
private void materializeKNNAndRKNNs(ArrayDBIDs ids, FiniteProgress progress) { // add an empty list to each rknn for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { if(materialized_RkNN.get(iter) == null) { materialized_RkNN.put(iter, new TreeSet<DoubleDBIDPair>()); } } ...
java
public DoubleDBIDList getRKNN(DBIDRef id) { TreeSet<DoubleDBIDPair> rKNN = materialized_RkNN.get(id); if(rKNN == null) { return null; } ModifiableDoubleDBIDList ret = DBIDUtil.newDistanceDBIDList(rKNN.size()); for(DoubleDBIDPair pair : rKNN) { ret.add(pair); } ret.sort(); ret...
java
public void insert(NumberVector nv) { final int dim = nv.getDimensionality(); // No root created yet: if(root == null) { ClusteringFeature leaf = new ClusteringFeature(dim); leaf.addToStatistics(nv); root = new TreeNode(dim, capacity); root.children[0] = leaf; root.addToStatist...
java
protected void rebuildTree() { final int dim = root.getDimensionality(); double t = estimateThreshold(root) / leaves; t *= t; // Never decrease the threshold. thresholdsq = t > thresholdsq ? t : thresholdsq; LOG.debug("New squared threshold: " + thresholdsq); LeafIterator iter = new LeafIte...
java
private TreeNode insert(TreeNode node, NumberVector nv) { // Find closest child: ClusteringFeature[] cfs = node.children; assert (cfs[0] != null) : "Unexpected empty node!"; // Find the best child: ClusteringFeature best = cfs[0]; double bestd = distance.squaredDistance(nv, best); for(int i...
java
private boolean add(ClusteringFeature[] children, ClusteringFeature child) { for(int i = 0; i < children.length; i++) { if(children[i] == null) { children[i] = child; return true; } } return false; }
java
protected StringBuilder printDebug(StringBuilder buf, ClusteringFeature n, int d) { FormatUtil.appendSpace(buf, d).append(n.n); for(int i = 0; i < n.getDimensionality(); i++) { buf.append(' ').append(n.centroid(i)); } buf.append(" - ").append(n.n).append('\n'); if(n instanceof TreeNode) { ...
java
public static double cdf(double val, int v) { double x = v / (val * val + v); return 1 - (0.5 * BetaDistribution.regularizedIncBeta(x, v * .5, 0.5)); }
java
public void add(DBIDRef iter, int column, double score) { changepoints.add(new ChangePoint(iter, column, score)); }
java
public void appendToBuffer(StringBuilder buf) { Iterator<Polygon> iter = polygons.iterator(); while(iter.hasNext()) { Polygon poly = iter.next(); poly.appendToBuffer(buf); if(iter.hasNext()) { buf.append(" -- "); } } }
java
public void initialize(CharSequence input, int begin, int end) { this.input = input; this.send = end; this.matcher.reset(input).region(begin, end); this.index = begin; advance(); }
java
public String getStrippedSubstring() { // TODO: detect Java <6 and make sure we only return the substring? // With java 7, String.substring will arraycopy the characters. int sstart = start, send = end; while(sstart < send) { char c = input.charAt(sstart); if(c != ' ' || c != '\n' || c != '\...
java
private char isQuote(int index) { if(index >= input.length()) { return 0; } char c = input.charAt(index); for(int i = 0; i < quoteChars.length; i++) { if(c == quoteChars[i]) { return c; } } return 0; }
java
public static WritableRecordStore makeRecordStorage(DBIDs ids, int hints, Class<?>... dataclasses) { return DataStoreFactory.FACTORY.makeRecordStorage(ids, hints, dataclasses); }
java
public static int[] randomPermutation(final int[] out, Random random) { for(int i = out.length - 1; i > 0; i--) { // Swap with random preceeding element. int ri = random.nextInt(i + 1); int tmp = out[ri]; out[ri] = out[i]; out[i] = tmp; } return out; }
java
protected void makeRunnerIfNeeded() { // We don't need to make a SVG runner when there are no pending updates. boolean stop = true; for(WeakReference<UpdateRunner> wur : updaterunner) { UpdateRunner ur = wur.get(); if(ur == null) { updaterunner.remove(wur); } else if(!ur.isEm...
java
@Override public void fullRedraw() { if(!(getWidth() > 0 && getHeight() > 0)) { LoggingUtil.warning("Thumbnail of zero size requested: " + visFactory); return; } if(thumbid < 0) { // LoggingUtil.warning("Generating new thumbnail " + this); layer.appendChild(SVGUtil.svgWaitIcon(plot...
java
public static Centroid make(Relation<? extends NumberVector> relation, DBIDs ids) { final int dim = RelationUtil.dimensionality(relation); Centroid c = new Centroid(dim); double[] elems = c.elements; int count = 0; for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { NumberVector v ...
java
protected void firstRow(double[] buf, int band, NumberVector v1, NumberVector v2, int dim2) { // First cell: final double val1 = v1.doubleValue(0); buf[0] = delta(val1, v2.doubleValue(0)); // Width of valid area: final int w = (band >= dim2) ? dim2 - 1 : band; // Fill remaining part of buffer: ...
java
@Override public double getWeight(double distance, double max, double stddev) { if(stddev <= 0) { return 1; } double normdistance = distance / stddev; return scaling * FastMath.exp(-.5 * normdistance * normdistance) / stddev; }
java
public boolean nextLineExceptComments() throws IOException { while(nextLine()) { if(comment == null || !comment.reset(buf).matches()) { tokenizer.initialize(buf, 0, buf.length()); return true; } } return false; }
java
public static Element makeArrow(SVGPlot svgp, Direction dir, double x, double y, double size) { final double hs = size / 2.; switch(dir){ case LEFT: return new SVGPath().drawTo(x + hs, y + hs).drawTo(x - hs, y).drawTo(x + hs, y - hs).drawTo(x + hs, y + hs).close().makeElement(svgp); case DOWN: ...
java
private double hammingDistanceNumberVector(NumberVector o1, NumberVector o2) { final int d1 = o1.getDimensionality(), d2 = o2.getDimensionality(); int differences = 0; int d = 0; for(; d < d1 && d < d2; d++) { double v1 = o1.doubleValue(d), v2 = o2.doubleValue(d); if(v1 != v1 || v2 != v2) { ...
java
public static long[] interleaveBits(long[] coords, int iter) { final int numdim = coords.length; final long[] bitset = BitsUtil.zero(numdim); // convert longValues into zValues final long mask = 1L << 63 - iter; for(int dim = 0; dim < numdim; dim++) { if((coords[dim] & mask) != 0) { Bi...
java
public void visChanged(VisualizationItem item) { for(int i = vlistenerList.size(); --i >= 0;) { final VisualizationListener listener = vlistenerList.get(i); if(listener != null) { listener.visualizationChanged(item); } } }
java
public static void setVisible(VisualizerContext context, VisualizationTask task, boolean visibility) { // Hide other tools if(visibility && task.isTool()) { Hierarchy<Object> vistree = context.getVisHierarchy(); for(It<VisualizationTask> iter2 = vistree.iterAll().filter(VisualizationTask.class); ite...
java
protected int findMerge(int end, MatrixParadigm mat, PointerHierarchyRepresentationBuilder builder) { assert (end > 0); final DBIDArrayIter ix = mat.ix, iy = mat.iy; final double[] matrix = mat.matrix; double mindist = Double.POSITIVE_INFINITY; int x = -1, y = -1; // Find minimum: for(int ox...
java
private void updateCholesky() { // TODO: further improve handling of degenerated cases? CholeskyDecomposition chol = new CholeskyDecomposition(covariance); if(!chol.isSPD()) { // Add a small value to the diagonal, to reduce some rounding problems. double s = 0.; for(int i = 0; i < covarian...
java
@Override public boolean validate(Class<? extends C> obj) throws ParameterException { if(obj == null) { throw new UnspecifiedParameterException(this); } if(!restrictionClass.isAssignableFrom(obj)) { throw new WrongParameterValueException(this, obj.getName(), "Given class not a subclass / imple...
java
protected void addListeners() { // Listen for result changes, including the one we monitor context.addResultListener(this); context.addVisualizationListener(this); // Listen for database events only when needed. if(task.has(UpdateFlag.ON_DATA)) { context.addDataStoreListener(this); } }
java
public void addGenerator(Distribution gen) { if(trans != null) { throw new AbortException("Generators may no longer be added when transformations have been applied."); } axes.add(gen); dim++; }
java
public void addRotation(int axis1, int axis2, double angle) { if(trans == null) { trans = new AffineTransformation(dim); } trans.addRotation(axis1, axis2, angle); }
java
public void addTranslation(double[] v) { if(trans == null) { trans = new AffineTransformation(dim); } trans.addTranslation(v); }
java
@Override public List<double[]> generate(int count) { ArrayList<double[]> result = new ArrayList<>(count); while(result.size() < count) { double[] d = new double[dim]; for(int i = 0; i < dim; i++) { d[i] = axes.get(i).nextRandom(); } if(trans != null) { d = trans.apply(...
java
@Override public Clustering<MeanModel> run(Database database, Relation<V> relation) { // Database objects to process final DBIDs ids = relation.getDBIDs(); // Choose initial means double[][] means = initializer.chooseInitialMeans(database, relation, k, getDistanceFunction()); // Setup cluster assi...
java
protected WritableDataStore<Meta> initializeMeta(Relation<V> relation, double[][] means) { NumberVectorDistanceFunction<? super V> df = getDistanceFunction(); // The actual storage final WritableDataStore<Meta> metas = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_HOT | DataStoreFacto...
java
protected void transfer(final WritableDataStore<Meta> metas, Meta meta, ModifiableDBIDs src, ModifiableDBIDs dst, DBIDRef id, int dstnum) { src.remove(id); dst.add(id); meta.primary = dstnum; metas.put(id, meta); // Make sure the storage is up to date. }
java
public double toPValue(double d, int n) { double b = d / 30 + 1. / (36 * n); double z = .5 * MathUtil.PISQUARE * MathUtil.PISQUARE * n * b; // Exponential approximation if(z < 1.1 || z > 8.5) { double e = FastMath.exp(0.3885037 - 1.164879 * z); return (e > 1) ? 1 : (e < 0) ? 0 : e; } ...
java
public static void run(DBIDs ids, Processor... procs) { ParallelCore core = ParallelCore.getCore(); core.connect(); try { // TODO: try different strategies anyway! ArrayDBIDs aids = DBIDUtil.ensureArray(ids); final int size = aids.size(); int numparts = core.getParallelism(); /...
java
public void replot() { width = co.size(); height = (int) Math.ceil(width * .2); ratio = width / (double) height; height = height < MIN_HEIGHT ? MIN_HEIGHT : height > MAX_HEIGHT ? MAX_HEIGHT : height; if(scale == null) { scale = computeScale(co); } BufferedImage img = new BufferedImage...
java
public int scaleToPixel(double reach) { return (Double.isInfinite(reach) || Double.isNaN(reach)) ? 0 : // (int) Math.round(scale.getScaled(reach, height - .5, .5)); }
java
public String getSVGPlotURI() { if(plotnum < 0) { plotnum = ThumbnailRegistryEntry.registerImage(plot); } return ThumbnailRegistryEntry.INTERNAL_PREFIX + plotnum; }
java
public static OPTICSPlot plotForClusterOrder(ClusterOrder co, VisualizerContext context) { // Check for an existing plot // ArrayList<OPTICSPlot<D>> plots = ResultUtil.filterResults(co, // OPTICSPlot.class); // if (plots.size() > 0) { // return plots.get(0); // } final StylingPolicy policy =...
java
public double[][] inverse() { // Build permuted identity matrix efficiently: double[][] b = new double[piv.length][m]; for(int i = 0; i < piv.length; i++) { b[piv[i]][i] = 1.; } return solveInplace(b); }
java
private boolean parseLine() { cureid = null; curpoly = null; curlbl = null; polys.clear(); coords.clear(); labels.clear(); Matcher m = COORD.matcher(reader.getBuffer()); for(/* initialized by nextLineExceptComments */; tokenizer.valid(); tokenizer.advance()) { m.region(tokenizer.g...
java
public void runResultHandlers(ResultHierarchy hier, Database db) { // Run result handlers for(ResultHandler resulthandler : resulthandlers) { Thread.currentThread().setName(resulthandler.toString()); resulthandler.processNewResult(hier, db); } }
java
@SuppressWarnings("unchecked") public static void setDefaultHandlerVisualizer() { defaultHandlers = new ArrayList<>(1); Class<? extends ResultHandler> clz; try { clz = (Class<? extends ResultHandler>) Thread.currentThread().getContextClassLoader().loadClass(// "de.lmu.ifi.dbs.elki.result.A...
java
public synchronized void connect() { if(executor == null) { executor = new ThreadPoolExecutor(0, processors, 10L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); executor.allowCoreThreadTimeOut(true); } if(++connected == 1) { executor.allowCoreThreadTimeOut(false); execu...
java
public void add(double x, double y) { data.add(x); data.add(y); minx = Math.min(minx, x); maxx = Math.max(maxx, x); miny = Math.min(miny, y); maxy = Math.max(maxy, y); }
java
public void addAndSimplify(double x, double y) { // simplify curve when possible: final int len = data.size(); if (len >= 4) { // Look at the previous 2 points final double l1x = data.get(len - 4); final double l1y = data.get(len - 3); final double l2x = data.get(len - 2); fina...
java
public void rescale(double sx, double sy) { for (int i = 0; i < data.size(); i += 2) { data.set(i, sx * data.get(i)); data.set(i + 1, sy * data.get(i + 1)); } maxx *= sx; maxy *= sy; }
java
private IndexTreePath<E> choosePath(AbstractMTree<?, N, E, ?> tree, E object, IndexTreePath<E> subtree) { N node = tree.getNode(subtree.getEntry()); // leaf if(node.isLeaf()) { return subtree; } // Initialize from first: int bestIdx = 0; E bestEntry = node.getEntry(0); double bes...
java
public void rewind() { synchronized(used) { for(ParameterPair pair : used) { current.addParameter(pair); } used.clear(); } }
java
public UniformDistribution estimate(double min, double max, final int count) { double grow = (count > 1) ? 0.5 * (max - min) / (count - 1) : 0.; return new UniformDistribution(Math.max(min - grow, -Double.MAX_VALUE), Math.min(max + grow, Double.MAX_VALUE)); }
java
public static double cdf(double val, double k, double lambda, double theta) { return (val > theta) ? // (1.0 - FastMath.exp(-FastMath.pow((val - theta) / lambda, k))) // : val == val ? 0.0 : Double.NaN; }
java
public static double quantile(double val, double k, double lambda, double theta) { if(val < 0.0 || val > 1.0) { return Double.NaN; } else if(val == 0) { return 0.0; } else if(val == 1) { return Double.POSITIVE_INFINITY; } else { return theta + lambda * FastMath.pow(-F...
java
public PCAResult processIds(DBIDs ids, Relation<? extends NumberVector> database) { return processCovarMatrix(covarianceMatrixBuilder.processIds(ids, database)); }
java
public PCAResult processQueryResult(DoubleDBIDList results, Relation<? extends NumberVector> database) { return processCovarMatrix(covarianceMatrixBuilder.processQueryResults(results, database)); }
java
public boolean isFullRank() { // Find maximum: double t = 0.; for(int j = 0; j < n; j++) { double v = Rdiag[j]; if(v == 0) { return false; } v = Math.abs(v); t = v > t ? v : t; } t *= 1e-15; // Numerical precision threshold. for(int j = 1; j < n; j++) { ...
java
public int rank(double t) { int rank = n; for(int j = 0; j < n; j++) { if(Math.abs(Rdiag[j]) <= t) { --rank; } } return rank; }
java
private void setupCSS(VisualizerContext context, SVGPlot svgp, XYPlot plot) { StyleLibrary style = context.getStyleLibrary(); for(XYPlot.Curve curve : plot) { CSSClass csscls = new CSSClass(this, SERIESID + curve.getColor()); // csscls.setStatement(SVGConstants.SVG_STROKE_WIDTH_ATTRIBUTE, "0.2%"); ...
java
@Override public int compareTo(EigenPair o) { if(this.eigenvalue < o.eigenvalue) { return -1; } if(this.eigenvalue > o.eigenvalue) { return +1; } return 0; }
java
protected static double calcPosterior(double f, double alpha, double mu, double sigma, double lambda) { final double pi = calcP_i(f, mu, sigma); final double qi = calcQ_i(f, lambda); return (alpha * pi) / (alpha * pi + (1.0 - alpha) * qi); }
java
public void split() { if(hasChildren()) { return; } final boolean issplit = (maxSplitDimension >= (getDimensionality() - 1)); final int childLevel = issplit ? level + 1 : level; final int splitDim = issplit ? 0 : maxSplitDimension + 1; final double splitPoint = getMin(splitDim) + (getMax(...
java
@Override public void run() { MultipleObjectsBundle data = generator.loadData(); if(LOG.isVerbose()) { LOG.verbose("Writing output ..."); } try { if(outputFile.exists() && LOG.isVerbose()) { LOG.verbose("The file " + outputFile + " already exists, " + "the generator result will be ...
java
private static long getGlobalSeed() { String sseed = System.getProperty("elki.seed"); return (sseed != null) ? Long.parseLong(sseed) : System.nanoTime(); }
java
public double computeFirstCover(boolean leaf) { double max = 0.; for(DistanceEntry<E> e : firstAssignments) { double cover = leaf ? e.getDistance() : (e.getEntry().getCoveringRadius() + e.getDistance()); max = cover > max ? cover : max; } return max; }
java
public double computeSecondCover(boolean leaf) { double max = 0.; for(DistanceEntry<E> e : secondAssignments) { double cover = leaf ? e.getDistance() : (e.getEntry().getCoveringRadius() + e.getDistance()); max = cover > max ? cover : max; } return max; }
java
protected void offerAt(final int pos, O e) { if(pos == NO_VALUE) { // resize when needed if(size + 1 > queue.length) { resize(size + 1); } index.put(e, size); size++; heapifyUp(size - 1, e); heapModified(); return; } assert (pos >= 0) : "Unexpected neg...
java
public O removeObject(O e) { int pos = index.getInt(e); return (pos >= 0) ? removeAt(pos) : null; }
java
private long sumMatrix(int[][] mat) { long ret = 0; for(int i = 0; i < mat.length; i++) { final int[] row = mat[i]; for(int j = 0; j < row.length; j++) { ret += row[j]; } } return ret; }
java
private int countAboveThreshold(int[][] mat, double threshold) { int ret = 0; for(int i = 0; i < mat.length; i++) { int[] row = mat[i]; for(int j = 0; j < row.length; j++) { if(row[j] >= threshold) { ret++; } } } return ret; }
java
private int[][] houghTransformation(boolean[][] mat) { final int xres = mat.length, yres = mat[0].length; final double tscale = STEPS * .66 / (xres + yres); final int[][] ret = new int[STEPS][STEPS]; for(int x = 0; x < mat.length; x++) { final boolean[] row = mat[x]; for(int y = 0; y < mat[...
java
private static void drawLine(int x0, int y0, int x1, int y1, boolean[][] pic) { final int xres = pic.length, yres = pic[0].length; // Ensure bounds y0 = (y0 < 0) ? 0 : (y0 >= yres) ? (yres - 1) : y0; y1 = (y1 < 0) ? 0 : (y1 >= yres) ? (yres - 1) : y1; x0 = (x0 < 0) ? 0 : (x0 >= xres) ? (xres - 1) : ...
java
public Collection<String> getPossibleValues() { // Convert to string array final E[] enums = enumClass.getEnumConstants(); ArrayList<String> values = new ArrayList<>(enums.length); for(E t : enums) { values.add(t.name()); } return values; }
java
private String joinEnumNames(String separator) { E[] enumTypes = enumClass.getEnumConstants(); StringBuilder sb = new StringBuilder(); for(int i = 0; i < enumTypes.length; ++i) { if(i > 0) { sb.append(separator); } sb.append(enumTypes[i].name()); } return sb.toString(); }
java
@Override protected void preInsert(MkMaxEntry entry) { KNNHeap knns_o = DBIDUtil.newHeap(getKmax()); preInsert(entry, getRootEntry(), knns_o); }
java
public static IntIterator getCommonDimensions(Collection<SplitHistory> splitHistories) { Iterator<SplitHistory> it = splitHistories.iterator(); long[] checkSet = BitsUtil.copy(it.next().dimBits); while(it.hasNext()) { SplitHistory sh = it.next(); BitsUtil.andI(checkSet, sh.dimBits); } re...
java
public static Filter handleURL(ParsedURL url) { if(LOG.isDebuggingFiner()) { LOG.debugFiner("handleURL " + url.toString()); } if(!isCompatibleURLStatic(url)) { return null; } int id; try { id = ParseUtil.parseIntBase10(url.getPath()); } catch(NumberFormatException e) { ...
java
public static int globalCentroid(Centroid overallCentroid, Relation<? extends NumberVector> rel, List<? extends Cluster<?>> clusters, NumberVector[] centroids, NoiseHandling noiseOption) { int clustercount = 0; Iterator<? extends Cluster<?>> ci = clusters.iterator(); for(int i = 0; ci.hasNext(); i++) { ...
java
public DBID findPrototype(DBIDs members) { // Find the last merge within the cluster. // The object with maximum priority will merge outside of the cluster, // So we need the second largest priority. DBIDIter it = members.iter(); DBIDVar proto = DBIDUtil.newVar(it), last = DBIDUtil.newVar(it); i...
java
public void bulkLoad(DBIDs ids) { if(ids.size() == 0) { return; } assert (root == null) : "Tree already initialized."; DBIDIter it = ids.iter(); DBID first = DBIDUtil.deref(it); // Compute distances to all neighbors: ModifiableDoubleDBIDList candidates = DBIDUtil.newDistanceDBIDList(id...
java
private void checkCoverTree(Node cur, int[] counts, int depth) { counts[0] += 1; // Node count counts[1] += depth; // Sum of depth counts[2] = depth > counts[2] ? depth : counts[2]; // Max depth counts[3] += cur.singletons.size() - 1; counts[4] += cur.singletons.size() - (cur.children == null ? 0 : ...
java