@Override @Deprecated public long[] getSelectedDimensions() { long[] bs = BitsUtil.zero(dim); BitsUtil.setI(bs, dim); return bs; }
@Override public <T extends SpatialComparable> void sort(List<T> objs, int start, int end, double[] minmax, int[] dims) { peanoSort(objs, start, end, minmax, dims, 0, BitsUtil.zero(minmax.length >> 1), false); }
@Override public long[] getItems() { long[] bits = BitsUtil.zero(indices[indices.length - 1]); for(int item : indices) { BitsUtil.setI(bits, item); } return bits; }
/** * Creates a new one-dimensional subspace of the original data space. * * @param dimension the dimension building this subspace */ public Subspace(int dimension) { dimensions = BitsUtil.zero(dimension + 1); BitsUtil.setI(dimensions, dimension); dimensionality = 1; }
@Override public long[] getItems() { long[] bits = BitsUtil.zero(item); BitsUtil.setI(bits, item); return bits; }
/** * Select the "iter" highest bit from each dimension. * * @param coords Input coordinates * @param iter Bit position (from highest position) * @return One bit per dimension */ public static long[] interleaveBits(int[] coords, int iter) { final int numdim = coords.length; final long[] bitset = BitsUtil.zero(numdim); // convert longValues into zValues final long mask = 1L << 31 - iter; for (int dim = 0; dim < numdim; dim++) { if ((coords[dim] & mask) != 0) { BitsUtil.setI(bitset, dim); } } return bitset; }
/** * Select the "iter" highest bit from each dimension. * * @param coords Input coordinates * @param iter Bit position (from highest position) * @return One bit per dimension */ public static long[] interleaveBits(long[] coords, int iter) { final int numdim = coords.length; final long[] bitset = BitsUtil.zero(numdim); // convert longValues into zValues final long mask = 1L << 63 - iter; for (int dim = 0; dim < numdim; dim++) { if ((coords[dim] & mask) != 0) { BitsUtil.setI(bitset, dim); } } return bitset; }
/** * Select the "iter" highest bit from each dimension. * * @param coords Input coordinates * @param iter Bit position (from highest position) * @return One bit per dimension */ public static long[] interleaveBits(short[] coords, int iter) { final int numdim = coords.length; final long[] bitset = BitsUtil.zero(numdim); // convert longValues into zValues final long mask = 1L << 15 - iter; for (int dim = 0; dim < numdim; dim++) { if ((coords[dim] & mask) != 0) { BitsUtil.setI(bitset, dim); } } return bitset; }
/** * Constructor. * * @param rows Row dimensionality. * @param cols Column dimensionality. */ protected BiclusterCandidate(int rows, int cols) { super(); this.rows = BitsUtil.ones(rows); this.irow = BitsUtil.zero(rows); this.rowcard = rows; this.rowM = new double[rows]; this.cols = BitsUtil.ones(cols); this.colcard = cols; this.colM = new double[cols]; }
@Override public long[] getVisibleDimensions2D() { final int dim = proj.getDimensionality(); long[] actDim = BitsUtil.zero(dim); double[] vScale = new double[dim]; for(int d = 0; d < dim; d++) { Arrays.fill(vScale, 0); vScale[d] = 1; double[] vRender = fastProjectScaledToRenderSpace(vScale); // TODO: Can't we do this by inspecting the projection matrix directly? if(vRender[0] > 0.0 || vRender[0] < 0.0 || vRender[1] != 0) { BitsUtil.setI(actDim, d); } } return actDim; } }
@Override public <A> BitVector newFeatureVector(A array, ArrayAdapter<? extends Number, A> adapter) { int dim = adapter.size(array); long[] bits = BitsUtil.zero(dim); for(int i = 0; i < dim; i++) { if(adapter.get(array, i).doubleValue() >= 0.5) { BitsUtil.setI(bits, i); } } return new BitVector(bits, dim); }
/** * Constructor. * * @param clusterCore Signature */ public ClusterCandidate(Signature clusterCore) { this.dimensions = BitsUtil.zero(clusterCore.spec.length >> 1); for(int i = 0; i < clusterCore.spec.length; i += 2) { BitsUtil.setI(this.dimensions, i >> 1); } this.ids = DBIDUtil.newArray(clusterCore.ids.size()); } }
/** * Filled hypercube. * * @param svgp SVG Plot * @param cls CSS class to use. * @param proj Visualization projection * @param min First corner * @param max Opposite corner * @return group element */ public static Element drawFilled(SVGPlot svgp, String cls, Projection2D proj, double[] min, double[] max) { Element group = svgp.svgElement(SVGConstants.SVG_G_TAG); ArrayList<double[]> edges = getVisibleEdges(proj, min, max); double[] rv_min = proj.fastProjectDataToRenderSpace(min); recDrawSides(svgp, group, cls, rv_min[0], rv_min[1], edges, 0, BitsUtil.zero(edges.size())); return group; }
/** * Filled hypercube. * * @param svgp SVG Plot * @param cls CSS class to use. * @param proj Visualization projection * @param min First corner * @param max Opposite corner * @return group element */ public static Element drawFilled(SVGPlot svgp, String cls, Projection2D proj, NumberVector min, NumberVector max) { Element group = svgp.svgElement(SVGConstants.SVG_G_TAG); ArrayList<double[]> edges = getVisibleEdges(proj, min, max); double[] rv_min = proj.fastProjectDataToRenderSpace(min); recDrawSides(svgp, group, cls, rv_min[0], rv_min[1], edges, 0, BitsUtil.zero(edges.size())); return group; }
@Override public <A> BitVector newNumberVector(A array, NumberArrayAdapter<?, ? super A> adapter) { int dim = adapter.size(array); long[] bits = BitsUtil.zero(dim); for(int i = 0; i < dim; i++) { if(adapter.getDouble(array, i) >= 0.5) { BitsUtil.setI(bits, i); } } return new BitVector(bits, dim); }
/** * Wireframe hypercube. * * @param svgp SVG Plot * @param proj Visualization projection * @param min First corner * @param max Opposite corner * @return path element */ public static Element drawFrame(SVGPlot svgp, Projection2D proj, double[] min, double[] max) { SVGPath path = new SVGPath(); ArrayList<double[]> edges = getVisibleEdges(proj, min, max); double[] rv_min = proj.fastProjectDataToRenderSpace(min); recDrawEdges(path, rv_min[0], rv_min[1], edges, 0, BitsUtil.zero(edges.size())); return path.makeElement(svgp); }
/** * Wireframe hypercube. * * @param svgp SVG Plot * @param proj Visualization projection * @param min First corner * @param max Opposite corner * @return path element */ public static Element drawFrame(SVGPlot svgp, Projection2D proj, NumberVector min, NumberVector max) { SVGPath path = new SVGPath(); ArrayList<double[]> edges = getVisibleEdges(proj, min, max); double[] rv_min = proj.fastProjectDataToRenderSpace(min); recDrawEdges(path, rv_min[0], rv_min[1], edges, 0, BitsUtil.zero(edges.size())); return path.makeElement(svgp); }
@Override public <E extends SpatialComparable, A> long[] split(A entries, ArrayAdapter<E, A> getter, int minEntries) { Split<A, E> split = new Split<>(entries, getter); split.chooseSplitAxis(minEntries); split.chooseSplitPoint(minEntries); assert (split.splitPoint < split.size) : "Invalid split produced. Size: " + getter.size(entries) + " minEntries: " + minEntries + " split.size: " + split.size; long[] assignment = BitsUtil.zero(split.size); for(int i = split.splitPoint; i < split.size; i++) { BitsUtil.setI(assignment, split.bestSorting[i].second); } return assignment; }
/** * Filled hypercube. * * @param svgp SVG Plot * @param cls CSS class to use. * @param proj Visualization projection * @param box Bounding box * @return group element */ public static Element drawFilled(SVGPlot svgp, String cls, Projection2D proj, SpatialComparable box) { Element group = svgp.svgElement(SVGConstants.SVG_G_TAG); ArrayList<double[]> edges = getVisibleEdges(proj, box); final int dim = box.getDimensionality(); double[] min = new double[dim]; for(int i = 0; i < dim; i++) { min[i] = box.getMin(i); } double[] rv_min = proj.fastProjectDataToRenderSpace(min); recDrawSides(svgp, group, cls, rv_min[0], rv_min[1], edges, 0, BitsUtil.zero(edges.size())); return group; }
@Override public BitVector newNumberVector(TIntDoubleMap values, int maxdim) { long[] bits = BitsUtil.zero(maxdim); // Import and sort the indexes for(TIntDoubleIterator iter = values.iterator(); iter.hasNext();) { iter.advance(); if(iter.value() != 0.) { BitsUtil.setI(bits, iter.key()); } } return new BitVector(bits, maxdim); }