Package java.util

Examples of java.util.BitSet.cardinality()


    gotcha.set(1);
    assertThat(gotcha.cardinality(), is(3));
    gotcha.set(3);
    assertThat(gotcha.cardinality(), is(4));
    gotcha.set(4);
    assertThat(gotcha.cardinality(), is(5));

    gotcha = new BitSet(5);
    int val;
    while (gotcha.cardinality() < 4) {
      val = Direction.rand().get();
View Full Code Here


    gotcha.set(4);
    assertThat(gotcha.cardinality(), is(5));

    gotcha = new BitSet(5);
    int val;
    while (gotcha.cardinality() < 4) {
      val = Direction.rand().get();
      gotcha.set(val);
    }

    assertFalse(gotcha.get(0));
View Full Code Here

        doIterate(a_andn,b_andn, mode);

        assertEquals(a_and.cardinality(), b_and.cardinality());
        assertEquals(a_or.cardinality(), b_or.cardinality());
        assertEquals(a_xor.cardinality(), b_xor.cardinality());
        assertEquals(a_andn.cardinality(), b_andn.cardinality());

        // test non-mutating popcounts
        assertEquals(b_and.cardinality(), OpenBitSet.intersectionCount(b,b0));
        assertEquals(b_or.cardinality(), OpenBitSet.unionCount(b,b0));
        assertEquals(b_xor.cardinality(), OpenBitSet.xorCount(b,b0));
View Full Code Here

            double logLikelihood = logLikelihood(a, b, c, d);
            if (logLikelihood > 3.841)
                validFeatures.set(co);
        }
        if (LOGGER.isLoggable(Level.FINE))
            LOGGER.fine(term + " had " + validFeatures.cardinality()
                        + " features");
        return validFeatures;
    }

    /**
 
View Full Code Here

                            for (Integer linkIndex : linkPartition) {
                                Edge link = edgeList.get(linkIndex);
                                nodesInPartition.set(link.from);
                                nodesInPartition.set(link.to);
                            }
                            int numNodes = nodesInPartition.cardinality();
                            // This reflects the density of this particular
                            // cluster
                            double partitionDensity =
                                (numLinks - (numNodes - 1d))
                                / (((numNodes * (numNodes - 1d)) / 2d)
View Full Code Here

            for (Integer linkIndex : linkPartition) {
                Edge link = edgeList.get(linkIndex);
                nodesInPartition.set(link.from);
                nodesInPartition.set(link.to);
            }
            int numNodes = nodesInPartition.cardinality();
            // This reflects the density of this particular cluster within the
            // total partitioning
            double partitionDensity = (numLinks - (numNodes - 1d))
                / (((numNodes * (numNodes - 1d)) / 2d) - (numLinks - 1));               
            partitionDensitySum += partitionDensity;
View Full Code Here

    @Test public void testRandomDistributionUnderHalfSet() {
        for (int size = 10; size < 100; ++size) {
            for (int set = 1; set < size / 2; ++set) {
                BitSet b = Statistics.randomDistribution(set, size);
                assertEquals(set, b.cardinality());
            }
        }       
    }

    @Test public void testRandomDistributionOverHalfSet() {
View Full Code Here

    @Test public void testRandomDistributionOverHalfSet() {
        for (int size = 10; size < 100; ++size) {
            for (int set = size / 2; set < ((3 * size) / 4); ++set) {
                BitSet b = Statistics.randomDistribution(set, size);
                assertEquals(set, b.cardinality());
            }
        }       
    }

    @Test(expected=IllegalArgumentException.class)
View Full Code Here

            union.set(i);
        }
       
        // get the intersection
        c.and(d);
        return ((double)(c.cardinality())) / union.cardinality();
    }

    /**
     * Computes the <a href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard
     * index</a> comparing the similarity both {@code DoubleVector}s when viewed
View Full Code Here

     * {@inheritDoc}
     */
    public int disconnect(int v) {
        BitSet b = edges.remove(v);
        if (b != null) {
            int edges = b.cardinality();
            size -= edges;
            return edges;
        }
        return 0;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.