/** * Test if the current column is marked as label column. * * @param col Column number * @return {@code true} when a label column. */ protected boolean isLabelColumn(int col) { return labelIndices != null && BitsUtil.get(labelIndices, col); }
@Override public long longValue(int dimension) { return BitsUtil.get(bits, dimension) ? 1L : 0L; }
/** * Get the value of a single bit. * * @param dimension Bit number to get * @return {@code true} when set */ public boolean booleanValue(int dimension) { return BitsUtil.get(bits, dimension); }
@Override public double doubleValue(int dimension) { return BitsUtil.get(bits, dimension) ? 1. : 0.; }
/** * Returns a string representation of the specified bit set. * * @param bitSet the bitSet * @param dim the overall dimensionality of the bit set * @param sep the separator * @return a string representation of the specified bit set. */ public static String format(long[] bitSet, int dim, String sep) { StringBuilder msg = new StringBuilder(); msg.append(BitsUtil.get(bitSet, 0) ? '1' : '0'); for(int d = 1; d < dim; d++) { msg.append(sep); msg.append(BitsUtil.get(bitSet, d) ? '1' : '0'); } return msg.toString(); }
/** * Returns a String representation of this BitVector. The representation is * suitable to be parsed by * {@link de.lmu.ifi.dbs.elki.datasource.parser.BitVectorLabelParser * BitVectorLabelParser}. * * {@inheritDoc} */ @Override public String toString() { StringBuilder representation = new StringBuilder(); for(int i = 0; i < dimensionality; i++) { if(i > 0) { representation.append(ATTRIBUTE_SEPARATOR); } representation.append(BitsUtil.get(bits, i) ? '1' : '0'); } return representation.toString(); }
/** * Returns a Vector representing in one column and * <code>getDimensionality()</code> rows the values of this BitVector as * double values. * * @return a Matrix representing in one column and * <code>getDimensionality()</code> rows the values of this BitVector * as double values * * @see de.lmu.ifi.dbs.elki.data.NumberVector#getColumnVector() */ @Override public Vector getColumnVector() { double[] values = new double[dimensionality]; for(int i = 0; i < dimensionality; i++) { values[i] = BitsUtil.get(bits, i) ? 1 : 0; } return new Vector(values); }
@Override public void toByteBuffer(ByteBuffer buffer, BitVector vec) throws IOException { final int len = getByteSize(vec); assert (vec.getDimensionality() <= Short.MAX_VALUE); final short dim = (short) vec.getDimensionality(); if(buffer.remaining() < len) { throw new IOException("Not enough space for the bit vector!"); } // write size buffer.putShort(dim); // write values // Next byte to write: byte b = 0; for(int i = 0; i < dim; i++) { final byte mask = (byte) (1 << (i & 7)); if(BitsUtil.get(vec.bits, i)) { b |= mask; } else { b &= ~mask; } // Write when appropriate if((i & 7) == 7 || i == dim - 1) { buffer.put(b); b = 0; } } }
/** * Returns true if this subspace is a subspace of the specified subspace, i.e. * if the set of dimensions building this subspace are contained in the set of * dimensions building the specified subspace. * * @param subspace the subspace to test * @return true if this subspace is a subspace of the specified subspace, * false otherwise */ public boolean isSubspace(Subspace subspace) { if(this.dimensionality > subspace.dimensionality) { return false; } // FIXME: use bit operations. for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) { if(!BitsUtil.get(subspace.dimensions, d)) { return false; } } return true; }
/** * Remove entries according to the given mask. * * @param mask Mask to remove */ public void removeMask(long[] mask) { int dest = BitsUtil.nextSetBit(mask, 0); if(dest < 0) { return; } int src = BitsUtil.nextSetBit(mask, dest); while(src < numEntries) { if(!BitsUtil.get(mask, src)) { entries[dest] = entries[src]; dest++; } src++; } int rm = src - dest; while(dest < numEntries) { entries[dest] = null; dest++; } numEntries -= rm; }
/** * Adds the specified dense unit to this subspace. * * @param unit the unit to be added. */ public void addDenseUnit(CLIQUEUnit<V> unit) { Collection<CLIQUEInterval> intervals = unit.getIntervals(); for(CLIQUEInterval interval : intervals) { if(!BitsUtil.get(getDimensions(), interval.getDimension())) { throw new IllegalArgumentException("Unit " + unit + "cannot be added to this subspace, because of wrong dimensions!"); } } getDenseUnits().add(unit); coverage += unit.numberOfFeatureVectors(); }
public List<Polygon> compute() { // Compute delaunay triangulation: delaunay = (new SweepHullDelaunay2D(points)).getDelaunay(); List<Polygon> polys = new ArrayList<>(); // Working data long[] used = BitsUtil.zero(delaunay.size()); List<Vector> cur = new ArrayList<>(); for(int i = 0 /* = used.nextClearBit(0) */; i < delaunay.size() && i >= 0; i = BitsUtil.nextClearBit(used, i + 1)) { if(!BitsUtil.get(used, i)) { BitsUtil.setI(used, i); SweepHullDelaunay2D.Triangle tri = delaunay.get(i); if(tri.r2 <= alpha2) { // Check neighbors processNeighbor(cur, used, i, tri.ab, tri.b); processNeighbor(cur, used, i, tri.bc, tri.c); processNeighbor(cur, used, i, tri.ca, tri.a); } if(cur.size() > 0) { polys.add(new Polygon(cur)); cur = new ArrayList<>(); } } } return polys; }
private void processNeighbor(List<Vector> cur, long[] used, int i, int ab, int b) { if(ab >= 0) { if(BitsUtil.get(used, ab)) { return; } BitsUtil.setI(used, ab); final SweepHullDelaunay2D.Triangle next = delaunay.get(ab); if(next.r2 < alpha2) { // Continue where we left off... if(next.ab == i) { processNeighbor(cur, used, ab, next.bc, next.c); processNeighbor(cur, used, ab, next.ca, next.a); } else if(next.bc == i) { processNeighbor(cur, used, ab, next.ca, next.a); processNeighbor(cur, used, ab, next.ab, next.b); } else if(next.ca == i) { processNeighbor(cur, used, ab, next.ab, next.b); processNeighbor(cur, used, ab, next.bc, next.c); } return; } } cur.add(points.get(b)); } }
if(BitsUtil.get(b, i)) { continue;
/** * Assigns the first object of the specified list to the first assignment that * it is not yet assigned to the second assignment. * * @param assign Output assignment * @param assigned Bitset of assigned objects * @param dis Distances * @param idx Indexes * @param pos Current position * @param second Assign to second, not first, set. * @return the new index */ private int assignBest(Assignments<E> assign, long[] assigned, N node, double[] dis, int[] idx, int pos, boolean second) { int i = idx[pos]; // Skip already assigned objects: while(BitsUtil.get(assigned, i)) { i = idx[++pos]; } if(second) { assign.addToSecond(node.getEntry(i), dis[pos], i); } else { assign.addToFirst(node.getEntry(i), dis[pos], i); } BitsUtil.setI(assigned, i); return ++pos; }
for(int i = 0; i < parts.length; i++) { if(BitsUtil.get(marked, i)) { continue;
@Override public <N extends AbstractRStarTreeNode<N, E>, E extends SpatialEntry> boolean handleOverflow(AbstractRStarTree<N, E, ?> tree, N node, IndexTreePath<E> path) { final int depthm1 = path.getPathCount() - 1; // No reinsertions at root level if(depthm1 == 0) { return false; } // Earlier reinsertions at the same level if(BitsUtil.capacity(reinsertions) < depthm1) { reinsertions = BitsUtil.copy(reinsertions, depthm1); } if(BitsUtil.get(reinsertions, depthm1)) { return false; } BitsUtil.setI(reinsertions, depthm1); final E entry = path.getEntry(); assert (!entry.isLeafEntry()) : "Unexpected leaf entry"; int[] cands = reinsertStrategy.computeReinserts(node, NodeArrayAdapter.STATIC, entry); if(cands == null || cands.length == 0) { return false; } tree.reInsert(node, path, cands); return true; }
for(int i = 0; i < getter.size(entries); i++) { E e = getter.get(entries, i); if(BitsUtil.get(assign, i)) { if(mbr1 == null) { mbr1 = new ModifiableHyperBoundingBox(e);
if (!BitsUtil.get(bits, 0)) { BitsUtil.flipI(refl, (nextrot - 1 + numdim) % numdim);
if (!BitsUtil.get(bits, 0)) { BitsUtil.flipI(refl, (nextrot - 1 + numdim) % numdim);