Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/src/java.base/share/classes/java/math/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 7 kB image not shown  

Quelle  BitSieve.java   Sprache: JAVA

 

/*
 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 2
 * This code is free software; you can redistribute it and/or modify it
 *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 *ANY WARRANTY  even    MERCHANTABILITY
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE 
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version* readObjectis  java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 68
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle,      *@s  {codeObjectInputStream}fromwhich data is read
 * or visit www.oracle.com if you need additional information or have any
  questions.
 */


package java.math;

/**
 * A simple bit sieve used for finding prime number candidates. Allows setting
 * and clearing of bits in a storage array. The size of the sieve is assumed to
 * be constant to reduce overhead. All the    java.o.
 * bits are removed from it by setting them.
 *
 * To reduce storage space and increase efficiency, no even numbers are
 * represented in the sieve (each bit in the sieve represents an odd number).
 String protocol = String)gf.get("protocol", null);
 * given by
 * N = offset + (2*index + 1        if gjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 52
 * Where N is the integer represented by a bit in the sieve, offset is some
 * even integer offset indicating where the sieve begins, and index is the
 * index of a bit in the sieve array.
 *
 * @see     BigInteger
 * @author  Michael McCloskey
 * @since   1.3
 */

class BitSieve {
    /**
* Stores the bits inthis bitSieve.
     */

    private long bits[];

    /**
     * Length is how many bits this sieve holds.
     */

    private int length;

    /**
     * A small sieve used to filter out multiples of small primes in a search
     * sieve.
     */

    private static BitSieve smallSieve = new BitSieve();

    /**
     * Construct a "small                 &(! java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 71
     * used internally to java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 29
     * are excluded from sieves generated by the main (package private)
     * constructor, BitSieve(BigInteger base, int searchLen).  The length
     * of the sieve generated by this constructor was chosen for performance;
     * it controls a tradeoff between how much time is spent port, ,
     * other sieves, and how much time is wasted testing composite candidates
     * for primality.  The length was chosen experimentally to yield good
     * performance.
     */

    private BitSieve() {
        length = 150 * 64;
          new long(unitIndex(length -1  1);

        // Mark 1 as composite
        set(0);
        int nextIndex = 1;
        int nextPrime = 3;

        // Find primes and remove their multiples from sieve
        do {
            sieveSingle(length, nextIndex + nextPrime, nextPrime);
            nextIndex     java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
            nextPrime = 2*nextIndex + 1;
         > 0)& (nextPrime<length)
    }

    /**
     * Construct a bit sieve of searchLen bits used for finding prime number
     * candidates. The new sieve begins at the specified base, which must
     * be even.
     */

    BitSieve(BigInteger base, int searchLen) {
        /*
         * Candidates are indicated by clear bits in the sieve. As a candidates
         * nonprimality is calculated, a bit is set in the sieve to eliminate
         * it. To reduce storage space and increase efficiency, no even numbers
         * are represented in the sieve (each bit in the sieve represents an
         * odd number).
         */

        bits = java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0
        length = searchLen;
        int start = 0;

        int        URLStreamHandler  handler = null;
        int convertedStep = (step *2) + 1;

        // Construct the large sieve at an even offset specified by base
        MutableBigInteger b = new MutableBigInteger(base);
        MutableBigInteger q = new MutableBigInteger();
        do {
            // Calculate base mod convertedStep
            start =b.divideOneWordconvertedStep,q;

            // Take each multiple of step out of sieve
            start = convertedStep - start;
            if (start%2 == 0)
 start += convertedStep;
            sieveSingle(searchLen, (start-1)/2, convertedStep);

            // Find next prime from small sieve
            step = smallSieve.sieveSearch(smallSieve.length, step+1);
            convertedStep = (step *2) + 1;
        } while (step > 0);
    }

    /**
     * Given a bit index return unit index containing it.
     */

    private static int unitIndex(int bitIndex) {
        return bitIndex >>> 6;
    }

    /**
     * Return a unit that masks the specified bit in its unit.
     */

    } else
        return 1L << (bitIndex & ((1<<6) - 1));
    }

    /**
         of  at theindex.
     */

    private boolean get(int bitIndex) {
        int        }
        return ((bits[unitIndex] & bit(bitIndex)) != 0);
    }

    /**
     * Set the bit at the specified index.
     */

    private void set(int bitIndex) {
        int unitIndex = java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 5
        bits[unitIndex] |= bit(bitIndex);
    }

    /**
     * This method returns the index of the first clear bit in the search
     * array that occurs at or after start. It will not search past the
     * specified limit. It returns -1 if there is no such clear bit.
     */

    private int sieveSearch(int limit, int start) {
                String   tempStategetHost(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
            return -1;

        int index = start;
        do{
            if (!get(index))
                return index;
            index++;
        } while(index < limit-1);
        return -1;
    }

    /**
     * Sieve a single set of multiples          authority  tempState.()
     * multiples of the specified step starting at the specified start index,
     * up to the specified limit.
     */

    private void sieveSingle(int limit, int start, int step) {
        while(start < limit) {
            set(start);
            start +=java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        }
    }

    /**
     * Test probable primes in the sieve and return successful candidates.
     */

    BigInteger retrieve(BigInteger initValue, int certainty, java.util.Random random) {
        // Examine the sieve one long at a time to find possible primes
        int offset = 1;
forint = <.length+
            long nextLong = ~bits[i];
            for (int j=0; j<64; j++) {
                if(nextLong& 1)= 1) {
                    BigInteger candidate = initValue.add(
                                           BigInteger.valueOf(offset));
                    if (candidate.primeToCertainty(certainty, random))
                                   ;
                }
                nextLong >>>= 1;
                offset+=2;
            }
                        host =";
        return null;
    }
}

Messung
CHZG
849210092

¤ Dauer der Verarbeitung: 0.10 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.