@Override protected AnderbergHierarchicalClustering<O> makeInstance() { return new AnderbergHierarchicalClustering<>(distanceFunction, linkage); } }
/** * Update the cache. * * @param size Working set size * @param scratch Scratch matrix * @param bestd Best distance * @param besti Best index * @param x First cluster * @param y Second cluster, {@code y < x} * @param j Updated value d(y, j) * @param d New distance */ private void updateCache(int size, double[] scratch, double[] bestd, int[] besti, int x, int y, int j, double d) { // New best if(d <= bestd[j]) { bestd[j] = d; besti[j] = y; return; } // Needs slow upate. if(besti[j] == x || besti[j] == y) { findBest(size, scratch, bestd, besti, j); } }
merge(size, mat, bestd, besti, builder, mindist, x, y); return x;
LOG.verbose("Notice: SLINK is a much faster algorithm for single-linkage clustering!"); DistanceQuery<O> dq = db.getDistanceQuery(relation, getDistanceFunction()); final DBIDs ids = relation.getDBIDs(); MatrixParadigm mat = new MatrixParadigm(ids); initializeNNCache(mat.matrix, bestd, besti); for(int i = 1, end = size; i < size; i++) { findMerge(end, mat, bestd, besti, builder)); LOG.incrementProcessed(prog);
builder.add(ix, linkage.restore(mindist, getDistanceFunction().isSquared()), iy); updateMatrix(size, mat.matrix, iy, bestd, besti, builder, mindist, x, y, sizex, sizey); if(besti[y] == x) { findBest(size, mat.matrix, bestd, besti, y);
updateMatrix(size, scratch, iy, bestd, besti, builder, mindist, x, y, sizex, sizey); if(besti[y] == x) { findBest(size, scratch, bestd, besti, y);
@Override public TypeInformation[] getInputTypeRestriction() { // The input relation must match our distance function: return TypeUtil.array(getDistanceFunction().getInputTypeRestriction()); }
final int yb = ybase + j; final double d = scratch[yb] = linkage.combine(sizex, scratch[xbase + j], sizey, scratch[yb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d); final int jb = jbase + y; final double d = scratch[jb] = linkage.combine(sizex, scratch[xbase + j], sizey, scratch[jb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d); final int jb = jbase + y; final double d = scratch[jb] = linkage.combine(sizex, scratch[jbase + x], sizey, scratch[jb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d);
LOG.verbose("Notice: SLINK is a much faster algorithm for single-linkage clustering!"); DistanceQuery<O> dq = db.getDistanceQuery(relation, getDistanceFunction()); final DBIDs ids = relation.getDBIDs(); MatrixParadigm mat = new MatrixParadigm(ids); initializeNNCache(mat.matrix, bestd, besti); for(int i = 1, end = size; i < size; i++) { findMerge(end, mat, bestd, besti, builder)); LOG.incrementProcessed(prog);
builder.add(ix, linkage.restore(mindist, getDistanceFunction().isSquared()), iy); updateMatrix(size, mat.matrix, iy, bestd, besti, builder, mindist, x, y, sizex, sizey); if(besti[y] == x) { findBest(size, mat.matrix, bestd, besti, y);
@Override public TypeInformation[] getInputTypeRestriction() { // The input relation must match our distance function: return TypeUtil.array(getDistanceFunction().getInputTypeRestriction()); }
final int yb = ybase + j; final double d = scratch[yb] = linkage.combine(sizex, scratch[xbase + j], sizey, scratch[yb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d); final int jb = jbase + y; final double d = scratch[jb] = linkage.combine(sizex, scratch[xbase + j], sizey, scratch[jb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d); updateCache(size, scratch, bestd, besti, x, y, j, d);
DistanceQuery<O> dq = db.getDistanceQuery(relation, getDistanceFunction()); ArrayDBIDs ids = DBIDUtil.ensureArray(relation.getDBIDs()); final int size = ids.size(); initializeNNCache(scratch, bestd, besti); int wsize = size; for(int i = 1; i < size; i++) { int x = findMerge(wsize, scratch, ix, iy, bestd, besti, builder); if(x == wsize - 1) { --wsize;
@Override protected AnderbergHierarchicalClustering<O> makeInstance() { return new AnderbergHierarchicalClustering<>(distanceFunction, linkage); } }
@Override public TypeInformation[] getInputTypeRestriction() { // The input relation must match our distance function: return TypeUtil.array(getDistanceFunction().getInputTypeRestriction()); }
/** * Update the cache. * * @param size Working set size * @param scratch Scratch matrix * @param bestd Best distance * @param besti Best index * @param x First cluster * @param y Second cluster, {@code y < x} * @param j Updated value d(y, j) * @param d New distance */ private void updateCache(int size, double[] scratch, double[] bestd, int[] besti, int x, int y, int j, double d) { // New best if(d <= bestd[j]) { bestd[j] = d; besti[j] = y; return; } // Needs slow update. if(besti[j] == x || besti[j] == y) { findBest(size, scratch, bestd, besti, j); } }
merge(size, scratch, ix, iy, bestd, besti, builder, mindist, x < y ? y : x, x < y ? x : y); return x;
final int yb = ybase + j; final double d = scratch[yb] = linkage.combine(sizex, scratch[xbase + j], sizey, scratch[yb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d); final int jb = jbase + y; final double d = scratch[jb] = linkage.combine(sizex, scratch[xbase + j], sizey, scratch[jb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d); final int jb = jbase + y; final double d = scratch[jb] = linkage.combine(sizex, scratch[jbase + x], sizey, scratch[jb], sizej, mindist); updateCache(size, scratch, bestd, besti, x, y, j, d);
@Override protected AnderbergHierarchicalClustering<O> makeInstance() { return new AnderbergHierarchicalClustering<>(distanceFunction, linkage); } }
/** * Update the cache. * * @param size Working set size * @param scratch Scratch matrix * @param bestd Best distance * @param besti Best index * @param x First cluster * @param y Second cluster, {@code y < x} * @param j Updated value d(y, j) * @param d New distance */ private void updateCache(int size, double[] scratch, double[] bestd, int[] besti, int x, int y, int j, double d) { // New best if(d <= bestd[j]) { bestd[j] = d; besti[j] = y; return; } // Needs slow update. if(besti[j] == x || besti[j] == y) { findBest(size, scratch, bestd, besti, j); } }