primal-0.3.2/.cargo_vcs_info.json0000644000000001360000000000100123220ustar { "git": { "sha1": "fd09436cecf81fac48d7514bd50deb7818fd7bc1" }, "path_in_vcs": "" }primal-0.3.2/.github/workflows/ci.yml000064400000000000000000000015161046102023000156300ustar 00000000000000name: Continuous integration on: push: branches: - staging - trying env: CARGO_TERM_COLOR: always CARGO_INCREMENTAL: 0 jobs: tests: runs-on: ubuntu-latest strategy: matrix: include: - rust: 1.36.0 # MSRV - rust: stable - rust: beta - rust: nightly - rust: nightly-i686-unknown-linux-gnu - rust: stable target: mips64-unknown-linux-gnuabi64 steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - name: Install packages if: matrix.rust == 'nightly-i686-unknown-linux-gnu' run: sudo apt-get install -y gcc-multilib - name: Tests env: TARGET: ${{ matrix.target }} run: ./ci/script.sh primal-0.3.2/.github/workflows/pr.yml000064400000000000000000000006201046102023000156510ustar 00000000000000name: Pull Request on: pull_request: env: CARGO_TERM_COLOR: always CARGO_INCREMENTAL: 0 jobs: tests: runs-on: ubuntu-latest strategy: matrix: include: - rust: stable steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - name: Tests run: ./ci/script.sh primal-0.3.2/.gitignore000064400000000000000000000001021046102023000130730ustar 00000000000000Cargo.lock target perf.data* /papers *.prof *.callgrind examples_ primal-0.3.2/Cargo.lock0000644000000761700000000000100103100ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hermit-abi 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bstr" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bumpalo" version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cast" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc_version 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cast" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" version = "2.33.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "criterion" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "cast 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.4 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "plotters 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", "serde_cbor 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "criterion-plot" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cast 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-channel" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-deque" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-epoch" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-utils" version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "csv" version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "csv-core" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "either" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "half" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hamming" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hermit-abi" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hermit-abi" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itertools" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "either 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itoa" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memoffset" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-integer" version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num_cpus" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hermit-abi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "once_cell" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "oorandom" version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "plotters" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "plotters-backend 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "plotters-svg 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", "web-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "plotters-backend" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "plotters-svg" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "plotters-backend 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal" version = "0.3.2" dependencies = [ "criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "primal-check 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "primal-estimate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "primal-sieve 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "primal-slowsieve 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal-bit" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal-check" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.45 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal-estimate" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "primal-sieve" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "primal-bit 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "primal-estimate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal-slowsieve" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "primal-bit 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "primal-estimate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "proc-macro2" version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-ident 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon-core" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-channel 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "regex-syntax 0.6.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex-syntax" version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ryu" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "semver" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_cbor" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "smallvec" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-ident 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-width 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tinytemplate" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "unicode-ident" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "walkdir" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 3.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro-support 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "web-sys" version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "js-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-util" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" "checksum bumpalo 3.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" "checksum cast 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" "checksum cast 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" "checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" "checksum clap 2.33.4 (registry+https://github.com/rust-lang/crates.io-index)" = "826bf7bc84f9435630275cb8e802a4a0ec792b615969934bd16d42ffed10f207" "checksum criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" "checksum criterion-plot 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" "checksum crossbeam-channel 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" "checksum crossbeam-deque 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" "checksum crossbeam-epoch 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)" = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" "checksum crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)" = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" "checksum csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" "checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" "checksum either 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" "checksum half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" "checksum hermit-abi 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" "checksum hermit-abi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" "checksum itertools 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" "checksum itoa 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" "checksum itoa 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" "checksum js-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)" = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)" = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" "checksum log 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" "checksum memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" "checksum memoffset 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" "checksum num-integer 0.1.45 (registry+https://github.com/rust-lang/crates.io-index)" = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" "checksum num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" "checksum num_cpus 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" "checksum once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" "checksum oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" "checksum plotters 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" "checksum plotters-backend 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" "checksum plotters-svg 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" "checksum primal-bit 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce4fe11b2a87850ca3bd5dc9c7cb9f66e32a09edab221be406ac5ff677f2241" "checksum primal-check 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9df7f93fd637f083201473dab4fee2db4c429d32e55e3299980ab3957ab916a0" "checksum primal-estimate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7374f14c76f23e1271e6be806981ac5dd9e52b59132b0a2f10bcc412495f9159" "checksum primal-sieve 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2a14766f8c543620824b5b2cec356abf2681b76966a7ac4b4ed2c0011e696a" "checksum primal-slowsieve 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "220c9c15c7f69d6ba93fa11687435e3fc48092939959b0c0315443609bbf46d3" "checksum proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)" = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" "checksum quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" "checksum rayon 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" "checksum rayon-core 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" "checksum regex 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" "checksum regex-automata 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" "checksum regex-syntax 0.6.28 (registry+https://github.com/rust-lang/crates.io-index)" = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" "checksum rustc_version 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" "checksum ryu 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" "checksum semver 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" "checksum serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)" = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" "checksum serde_cbor 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" "checksum serde_derive 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)" = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" "checksum serde_json 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" "checksum smallvec 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" "checksum syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" "checksum unicode-ident 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" "checksum unicode-width 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" "checksum walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" "checksum wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" "checksum wasm-bindgen-backend 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" "checksum wasm-bindgen-macro 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" "checksum wasm-bindgen-macro-support 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" "checksum wasm-bindgen-shared 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" "checksum web-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)" = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" "checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" primal-0.3.2/Cargo.toml0000644000000030570000000000100103250ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2018" name = "primal" version = "0.3.2" authors = ["Huon Wilson "] description = """ `primal` puts raw power into prime numbers. This crates includes: optimised prime sieves, checking for primality, enumerating primes, factorising numbers, and state-of-the-art estimation of upper and lower bounds for π(n) (the number of primes below n) and p_k (the k-th prime). """ homepage = "https://github.com/huonw/primal" documentation = "http://docs.rs/primal/" readme = "README.md" keywords = [ "math", "mathematics", "primes", "number-theory", ] license = "MIT OR Apache-2.0" repository = "https://github.com/huonw/primal" [package.metadata.release] sign-tag = true tag-name = "{{crate_name}}-{{version}}" [[bench]] name = "bench" harness = false [dependencies.primal-check] version = "0.3" [dependencies.primal-estimate] version = "0.3" [dependencies.primal-sieve] version = "0.3" [dev-dependencies.criterion] version = "0.3.4" features = ["html_reports"] [dev-dependencies.primal-slowsieve] version = "0.3" [features] unstable = ["primal-sieve/unstable"] primal-0.3.2/Cargo.toml.orig000064400000000000000000000026051046102023000140040ustar 00000000000000[package] name = "primal" version = "0.3.2" authors = ["Huon Wilson "] edition = "2018" homepage = "https://github.com/huonw/primal" repository = "https://github.com/huonw/primal" documentation = "http://docs.rs/primal/" license = "MIT OR Apache-2.0" keywords = ["math", "mathematics", "primes", "number-theory"] readme = "README.md" description = """ `primal` puts raw power into prime numbers. This crates includes: optimised prime sieves, checking for primality, enumerating primes, factorising numbers, and state-of-the-art estimation of upper and lower bounds for π(n) (the number of primes below n) and p_k (the k-th prime). """ [dependencies] primal-check = { path = "primal-check", version = "0.3" } primal-estimate = { path = "primal-estimate", version = "0.3" } primal-sieve = { path = "primal-sieve", version = "0.3" } [dev-dependencies] primal-slowsieve = { path = "primal-slowsieve", version = "0.3" } criterion = { version = "0.3.4", features = ["html_reports"] } [[bench]] name = "bench" harness = false [features] unstable = ["primal-sieve/unstable"] [workspace] members = [ "primal-bit", "primal-check", "primal-estimate", "primal-sieve", "primal-slowsieve", "generators", ] [workspace.metadata.release] sign-tag = true tag-name = "{{crate_name}}-{{version}}" [package.metadata.release] sign-tag = true tag-name = "{{crate_name}}-{{version}}" primal-0.3.2/LICENSE-APACHE000064400000000000000000000251371046102023000130460ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. primal-0.3.2/LICENSE-MIT000064400000000000000000000020361046102023000125470ustar 00000000000000Copyright (c) 2014 Huon Wilson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.primal-0.3.2/README.md000064400000000000000000000017421046102023000123750ustar 00000000000000# primal [![crates.io](https://img.shields.io/crates/v/primal.svg)](https://crates.io/crates/primal) [![documentation](https://docs.rs/primal/badge.svg)](https://docs.rs/primal) ![minimum rustc 1.36](https://img.shields.io/badge/rustc-1.36+-red.svg) `primal` puts raw power into prime numbers. This crates includes - optimised prime sieves - checking for primality - enumerating primes - factorising numbers - estimating upper and lower bounds for π(*n*) (the number of primes below *n*) and *pk* (the kth prime) This uses a state-of-the-art cache-friendly Sieve of Eratosthenes to enumerate the primes up to some fixed bound (in a memory efficient manner), and then allows this cached information to be used for things like enumerating and counting primes. `primal` takes around 2.8 seconds and less than 3MB of RAM to count the exact number of primes below 1010 (455052511) on the author's laptop (i7-3517U). [**Documentation**](http://docs.rs/primal/) primal-0.3.2/benches/bench.rs000064400000000000000000000016101046102023000141440ustar 00000000000000#[macro_use] extern crate criterion; use criterion::Criterion; const N: usize = 1_000_000; const STEP: usize = 101; fn is_prime(c: &mut Criterion) { let mut group = c.benchmark_group("is_prime"); group.bench_function("is_prime", |b| { b.iter(|| { (1..N) .step_by(STEP) .filter(|&n| primal::is_prime(n as u64)) .count() }) }); group.bench_function("Sieve::is_prime", |b| { let sieve = primal::Sieve::new(N); b.iter(|| (1..N).step_by(STEP).filter(|&n| sieve.is_prime(n)).count()) }); group.bench_function("Sieve::is_prime with init", |b| { b.iter(|| { let sieve = primal::Sieve::new(N); (1..N).step_by(STEP).filter(|&n| sieve.is_prime(n)).count() }) }); group.finish(); } criterion_group!(benches, is_prime); criterion_main!(benches); primal-0.3.2/bors.toml000064400000000000000000000002731046102023000127560ustar 00000000000000status = [ "tests (1.36.0)", "tests (stable)", "tests (beta)", "tests (nightly)", "tests (nightly-i686-unknown-linux-gnu)", "tests (stable, mips64-unknown-linux-gnuabi64)", ] primal-0.3.2/ci/codecov.yml000064400000000000000000000001161046102023000136500ustar 00000000000000coverage: status: project: default: paths: "!generators/" primal-0.3.2/ci/compat-Cargo.lock000064400000000000000000000737301046102023000147050ustar 00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hermit-abi 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bstr" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "regex-automata 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "bumpalo" version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cast" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rustc_version 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cast" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" version = "2.33.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "criterion" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "cast 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.4 (registry+https://github.com/rust-lang/crates.io-index)", "criterion-plot 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "plotters 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", "serde_cbor 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "criterion-plot" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cast 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-channel" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-deque" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-epoch 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-epoch" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "crossbeam-utils" version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "csv" version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "csv-core" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "either" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "generators" version = "0.3.0" dependencies = [ "primal-check 0.3.3", "primal-slowsieve 0.3.1", ] [[package]] name = "half" version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hamming" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hermit-abi" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "hermit-abi" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itertools" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "either 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "itoa" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "itoa" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "js-sys" version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "log" version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memchr" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memoffset" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-integer" version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num_cpus" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hermit-abi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "once_cell" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "oorandom" version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "plotters" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "plotters-backend 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "plotters-svg 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", "web-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "plotters-backend" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "plotters-svg" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "plotters-backend 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal" version = "0.3.2" dependencies = [ "criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "primal-check 0.3.3", "primal-estimate 0.3.2", "primal-sieve 0.3.6", "primal-slowsieve 0.3.1", ] [[package]] name = "primal-bit" version = "0.3.1" dependencies = [ "hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal-check" version = "0.3.3" dependencies = [ "num-integer 0.1.45 (registry+https://github.com/rust-lang/crates.io-index)", "primal 0.3.2", ] [[package]] name = "primal-estimate" version = "0.3.2" dependencies = [ "primal 0.3.2", ] [[package]] name = "primal-sieve" version = "0.3.6" dependencies = [ "criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "primal 0.3.2", "primal-bit 0.3.1", "primal-estimate 0.3.2", "primal-slowsieve 0.3.1", "smallvec 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "primal-slowsieve" version = "0.3.1" dependencies = [ "criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "primal-bit 0.3.1", "primal-estimate 0.3.2", ] [[package]] name = "proc-macro2" version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-ident 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "quote" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "either 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon-core 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rayon-core" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-channel 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-deque 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "regex-syntax 0.6.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-automata" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex-syntax" version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "semver 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ryu" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "semver" version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde_cbor" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive" version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "ryu 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "smallvec" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "syn" version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-ident 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-width 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tinytemplate" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "unicode-ident" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "unicode-width" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "walkdir" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bumpalo 3.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)", "once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro-support 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-backend 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-shared 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "web-sys" version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "js-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi-util" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum bstr 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" "checksum bumpalo 3.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" "checksum cast 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" "checksum cast 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" "checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" "checksum clap 2.33.4 (registry+https://github.com/rust-lang/crates.io-index)" = "826bf7bc84f9435630275cb8e802a4a0ec792b615969934bd16d42ffed10f207" "checksum criterion 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" "checksum criterion-plot 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2673cc8207403546f45f5fd319a974b1e6983ad1a3ee7e6041650013be041876" "checksum crossbeam-channel 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" "checksum crossbeam-deque 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" "checksum crossbeam-epoch 0.9.9 (registry+https://github.com/rust-lang/crates.io-index)" = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" "checksum crossbeam-utils 0.8.10 (registry+https://github.com/rust-lang/crates.io-index)" = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" "checksum csv 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" "checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" "checksum either 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" "checksum half 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" "checksum hermit-abi 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" "checksum hermit-abi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" "checksum itertools 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" "checksum itoa 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" "checksum itoa 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" "checksum js-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)" = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)" = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" "checksum log 0.4.17 (registry+https://github.com/rust-lang/crates.io-index)" = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" "checksum memchr 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" "checksum memoffset 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" "checksum num-integer 0.1.45 (registry+https://github.com/rust-lang/crates.io-index)" = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" "checksum num-traits 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" "checksum num_cpus 1.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" "checksum once_cell 1.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f7254b99e31cad77da24b08ebf628882739a608578bb1bcdfc1f9c21260d7c0" "checksum oorandom 11.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" "checksum plotters 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" "checksum plotters-backend 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" "checksum plotters-svg 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a81d2759aae1dae668f783c308bc5c8ebd191ff4184aaa1b37f65a6ae5a56f" "checksum proc-macro2 1.0.49 (registry+https://github.com/rust-lang/crates.io-index)" = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" "checksum quote 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" "checksum rayon 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" "checksum rayon-core 1.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" "checksum regex 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" "checksum regex-automata 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" "checksum regex-syntax 0.6.28 (registry+https://github.com/rust-lang/crates.io-index)" = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" "checksum rustc_version 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" "checksum ryu 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" "checksum semver 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" "checksum serde 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)" = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" "checksum serde_cbor 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" "checksum serde_derive 1.0.152 (registry+https://github.com/rust-lang/crates.io-index)" = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" "checksum serde_json 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)" = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" "checksum smallvec 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" "checksum syn 1.0.107 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" "checksum tinytemplate 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" "checksum unicode-ident 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" "checksum unicode-width 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" "checksum walkdir 2.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" "checksum wasm-bindgen 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" "checksum wasm-bindgen-backend 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" "checksum wasm-bindgen-macro 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" "checksum wasm-bindgen-macro-support 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" "checksum wasm-bindgen-shared 0.2.83 (registry+https://github.com/rust-lang/crates.io-index)" = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" "checksum web-sys 0.3.60 (registry+https://github.com/rust-lang/crates.io-index)" = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" "checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" primal-0.3.2/ci/script.sh000075500000000000000000000027121046102023000133520ustar 00000000000000#!/usr/bin/env bash set -ex cargo=cargo target_param="" features=" " if rustc -V | grep -qF 'nightly' ; then features+=" unstable" fi if rustc -V | grep -qF 'rustc 1.36' ; then cp ./ci/compat-Cargo.lock ./Cargo.lock fi if [ ! -z "$TARGET" ]; then rustup target add "$TARGET" cargo install -v cross --force cargo="cross" target_param="--target $TARGET" fi $cargo build -v --all $target_param --features "$features" $cargo test -v --all $target_param --features "$features" $cargo bench -v --all $target_param --features "$features" -- --test # don't actually record numbers $cargo doc -v --all $target_param --features "$features" $cargo test -v -p primal-sieve --features "$features primal-sieve/safe" $cargo test -v --all --release --features "$features primal-sieve/slow_tests primal-slowsieve/slow_tests" if [ ! -z "$COVERAGE" ]; then if [ ! -z "$TARGET" ]; then echo "cannot record coverage while cross compiling" exit 1 fi # Rust 1.41 changed the default lock format, which cargo-travis doesn't understand. # https://github.com/roblabla/cargo-travis/issues/66 rustup install --profile minimal 1.40.0 cargo +1.40.0 generate-lockfile cargo install -v cargo-travis || echo "cargo-travis already installed" cargo coverage -v --all -m coverage-reports --kcov-build-location "$PWD/target" --features "$features" bash <(curl -s https://codecov.io/bash) -c -X gcov -X coveragepy -s coverage-reports fi primal-0.3.2/examples/binary-search-is-prime.rs000064400000000000000000000007551046102023000175570ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let zeros = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as u32)) .unwrap_or(10); let step = 1 << (zeros + 1); let start = Instant::now(); let mut it = step + 1; while !primal::is_prime(it) { it += step; } let p = it; let time = start.elapsed(); println!("{} is the first prime with {} zeros, in {:?}", p, zeros, time); } primal-0.3.2/examples/binary-search-iterator.rs000064400000000000000000000006751046102023000176640ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let zeros = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as u32)) .unwrap_or(10); let start = Instant::now(); let p = primal::Primes::all().find(|p| (p / 2).trailing_zeros() >= zeros).unwrap(); let time = start.elapsed(); println!("{} is the first prime with {} zeros, in {:?}", p, zeros, time); } primal-0.3.2/examples/binary-search-sieve.rs000064400000000000000000000012561046102023000171420ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let zeros = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as u32)) .unwrap_or(10); let start = Instant::now(); let mut low = 1 << (zeros + 1); let p = loop { println!("searching {}--{}", low, low * 2); let sieve = primal::Sieve::new(low * 2); match sieve.primes_from(low).find(|p| (p / 2).trailing_zeros() >= zeros) { Some(p) => break p, None => {} } low *= 2; }; let time = start.elapsed(); println!("{} is the first prime with {} zeros, in {:?}", p, zeros, time); } primal-0.3.2/examples/count-iterator.rs000075500000000000000000000007301046102023000162600ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let max = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as usize)) .unwrap_or(1_000_000); let start = Instant::now(); let count = primal::Primes::all().take_while(|x| *x <= max).count(); let time = start.elapsed(); println!("{} primes below {} in {:?} (est: {:?})", count, max, time, primal::estimate_prime_pi(max as u64)); } primal-0.3.2/examples/count-sieve.rs000064400000000000000000000012131046102023000155340ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let max = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as usize)) .unwrap_or(1_000_000); let start = Instant::now(); let sieve = primal::Sieve::new(max); let time_sieve = start.elapsed(); let start = Instant::now(); let count = sieve.prime_pi(max); let time_prime_pi = start.elapsed(); println!("{} primes below {} (est: {:?})\nsieve {:?}, prime_pi {:?}, total: {:?}", count, max, primal::estimate_prime_pi(max as u64), time_sieve, time_prime_pi, time_sieve + time_prime_pi); } primal-0.3.2/examples/count-slowsieve.rs000075500000000000000000000007251046102023000164530ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let max = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as usize)) .unwrap_or(1_000_000); let start = Instant::now(); let count = primal_slowsieve::Primes::sieve(max).count_upto(max); let time = start.elapsed(); println!("{} primes below {} in {:?} (est: {:?})", count, max, time, primal::estimate_prime_pi(max as u64)); } primal-0.3.2/examples/count-streaming.rs000075500000000000000000000007061046102023000164230ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let max = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as usize)) .unwrap_or(1_000_000); let start = Instant::now(); let count = primal::StreamingSieve::prime_pi(max); let time = start.elapsed(); println!("{} primes below {} in {:?} (est: {:?})", count, max, time, primal::estimate_prime_pi(max as u64)); } primal-0.3.2/examples/nth-prime-iterator.rs000064400000000000000000000007101046102023000170260ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let n = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as usize)) .unwrap_or(1_000_000); let start = Instant::now(); let prime = primal::Primes::all().nth(n - 1).unwrap(); let time = start.elapsed(); println!("{}th prime is {} (est: {:?})\ntotal: {:?}", n, prime, primal::estimate_nth_prime(n as u64), time); } primal-0.3.2/examples/nth-prime-sieve.rs000064400000000000000000000013071046102023000163130ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let n = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as usize)) .unwrap_or(1_000_000); let start = Instant::now(); let (_, hi) = primal::estimate_nth_prime(n as u64); let sieve = primal::Sieve::new(hi as usize); let time_sieve = start.elapsed(); let start = Instant::now(); let prime = sieve.nth_prime(n); let time_nth_prime = start.elapsed(); println!("{}th prime is {} (est: {:?})\nsieve {:?}, nth-prime {:?}, total: {:?}", n, prime, primal::estimate_nth_prime(n as u64), time_sieve, time_nth_prime, time_sieve + time_nth_prime); } primal-0.3.2/examples/nth-prime-streaming.rs000064400000000000000000000007031046102023000171700ustar 00000000000000use std::env; use std::time::Instant; fn main() { let mut args = env::args(); let n = args .nth(1).and_then(|s| s.parse::().ok().map(|x| x as usize)) .unwrap_or(1_000_000); let start = Instant::now(); let prime = primal::StreamingSieve::nth_prime(n); let time = start.elapsed(); println!("{}th prime is {} (est: {:?})\ntotal: {:?}", n, prime, primal::estimate_nth_prime(n as u64), time); } primal-0.3.2/examples/prime-sum-sieve-overestimate.rs000064400000000000000000000005731046102023000210370ustar 00000000000000fn main() { let ns = (1..100 + 1).map(|x| x * 100_000).collect::>(); // find the primes up to this upper bound let sieve = primal::Sieve::new(1_000_000_000); // now we can efficiently sum them up let sum = ns.iter() .map(|n| sieve.nth_prime(*n)) .fold(0u64, |a, b| a + b as u64); println!("the sum is {}", sum); } primal-0.3.2/examples/prime-sum-sieve.rs000064400000000000000000000007221046102023000163260ustar 00000000000000fn main() { let ns = (1..100 + 1).map(|x| x * 100_000).collect::>(); // find our upper bound let (_lo, hi) = primal::estimate_nth_prime(10_000_000); // find the primes up to this upper bound let sieve = primal::Sieve::new(hi as usize); // now we can efficiently sum them up let sum = ns.iter() .map(|n| sieve.nth_prime(*n)) .fold(0u64, |a, b| a + b as u64); println!("the sum is {}", sum); } primal-0.3.2/examples/prime-sum-streaming.rs000064400000000000000000000004531046102023000172050ustar 00000000000000fn main() { let ns = (1..100 + 1).map(|x| x * 100_000).collect::>(); // now we can efficiently sum them up let sum = ns.iter() .map(|n| primal::StreamingSieve::nth_prime(*n)) .fold(0u64, |a, b| a + b as u64); println!("the sum is {}", sum); } primal-0.3.2/examples/small_prime_props.rs000075500000000000000000000047551046102023000170430ustar 00000000000000use std::cmp; // prints two Rust statics: // // - `SMALL_PRIME_PI` such that `SMALL_PRIME_PI[n] == π(n)`. // - `SMALL_PRIMES` listing the primes below some small bound static LINE_LIMIT: usize = 90; static LARGEST_PI: u64 = 255; static LARGEST_PRIME: u64 = 255; fn u_type(max: u64) -> String { format!("u{}", match () { _ if max < 1 << 8 => 8, _ if max < 1 << 16 => 16, _ if max < 1 << 32 => 32, _ => 64 }) } fn main() { let (_, hi) = primal::estimate_nth_prime(LARGEST_PI + 1); // we know `hi` is definitely above one prime we're interested in, // so just make sure we're above the other one. let sieve = primal::Sieve::new(cmp::max(hi, LARGEST_PRIME) as usize); let stop_at = sieve.primes_from(0).nth(LARGEST_PI as usize).unwrap(); println!("// created with small_prime_props.rs"); print!("pub const SMALL_PRIME_PI: [{}; {}] = [", u_type(LARGEST_PI), stop_at); let mut width = LINE_LIMIT; macro_rules! check_width { ($next_len: expr) => { if width + $next_len >= LINE_LIMIT { print!("\n "); width = 4; false } else { true } } } let mut last = 0; for (pi, p) in sieve.primes_from(0).enumerate() { let text = format!("{},", pi); let len = text.len(); let mut new_prime = true; for _ in last..p { if check_width!(1 + len) && !new_prime { print!(" "); width += 1 } print!("{}", text); width += len; new_prime = false; } last = p; if pi as u64 >= LARGEST_PI { break } let p_text = format!("/*{}*/", p); if check_width!(1 + p_text.len()) { print!(" "); width += 1; } print!("{}", p_text); width += p_text.len(); } println!("];"); let count = sieve.primes_from(0).take_while(|p| *p as u64 <= LARGEST_PRIME).count(); println!("pub const SMALL_PRIME_LIMIT: usize = {};", LARGEST_PRIME); print!("pub const SMALL_PRIMES: [{}, .. {}] = [", u_type(LARGEST_PRIME), count); width = LINE_LIMIT; for p in sieve.primes_from(0).take_while(|p| *p as u64 <= LARGEST_PRIME) { let text = format!("{},", p); if check_width!(1 + text.len()) { print!(" "); width += 1; } print!("{}", text); width += text.len(); } println!("];") } primal-0.3.2/src/lib.rs000064400000000000000000000217721046102023000130260ustar 00000000000000//! `primal` puts raw power into prime numbers. //! //! This crates includes //! //! - optimised prime sieves //! - checking for primality //! - enumerating primes //! - factorising numbers //! - estimating upper and lower bounds for π(*n*) (the number of primes //! below *n*) and *pk* (the kth prime) //! //! This uses a state-of-the-art cache-friendly Sieve of Eratosthenes //! to enumerate the primes up to some fixed bound (in a memory //! efficient manner), and then allows this cached information to be //! used for things like enumerating and counting primes. //! //! `primal` takes around 2.8 seconds and less than 3MB of RAM to //! count the exact number of primes below 1010 (455052511) //! on my laptop (i7-3517U). //! //! [*Source*](http://github.com/huonw/primal) //! //! # Using this library //! //! Just add the following to your [`Cargo.toml`](http://crates.io/): //! //! ```toml //! [dependencies] //! primal = "0.2" //! ``` //! //! # Examples //! //! ## "Indexing" Primes //! //! Let's find the 10001st prime. The easiest way is to enumerate the //! primes, and find the 10001st: //! //! ```rust //! // (.nth is zero indexed.) //! let p = primal::Primes::all().nth(10001 - 1).unwrap(); //! println!("The 10001st prime is {}", p); // 104743 //! # assert_eq!(p, 104743); //! ``` //! //! This takes around 400 microseconds on my computer, which seems //! nice and quick, but, `Primes` is flexible at the cost of //! performance: we can make it faster. The `StreamingSieve` type //! offers a specialised `nth_prime` function: //! //! ```rust //! let p = primal::StreamingSieve::nth_prime(10001); //! println!("The 10001st prime is {}", p); // 104743 //! # assert_eq!(p, 104743); //! ``` //! //! This runs in only 10 microseconds! `StreamingSieve` is extremely //! efficient and uses very little memory. It is the best way to solve //! this task with `primal`. //! //! Since that was so easy, let's now make the problem bigger and //! harder: find the sum of the 100,000th, 200,000th, 300,000th, ..., //! 10,000,000th primes (100 in total). //! //! We could call `StreamingSieve::nth_prime` repeatedly: //! //! ```rust,no_run //! // the primes we want to find //! let ns = (1..100 + 1).map(|x| x * 100_000).collect::>(); //! //! // search and sum them up //! let sum = ns.iter() //! .map(|n| primal::StreamingSieve::nth_prime(*n)) //! .fold(0, |a, b| a + b); //! println!("the sum is {}", sum); //! ``` //! //! This takes around 1.6s seconds to print `the sum is 8795091674`; //! not so speedy. Each call to `nth_prime` is individually fast (400 //! microseconds for 100,000 to 40 milliseconds for 10,000,000) but //! they add up to something bad. Every one is starting from the start //! and redoing work that previous calls have done... wouldn't it be //! nice if we could just do the computation for 10,000,000 and reuse //! that for the smaller ones? //! //! The `Sieve` type is a wrapper around `StreamingSieve` that //! caches information, allowing repeated queries to be answered //! efficiently. //! //! There's one hitch: `Sieve` requires a limit to know how far to //! sieve: we need some way to find an upper bound to be guaranteed to //! be at least as large as all our primes. We could guess that, say, //! 1010 will be large enough and use that, but that's a //! huge overestimate (spoilers: the 10,000,000th prime is around //! 2×108). We could also try filtering with //! exponentially larger upper bounds until we find one that works //! (e.g. doubling each time), or, we could just take a shortcut and //! use deeper mathematics via //! [`estimate_nth_prime`](fn.estimate_nth_prime.html). //! //! ```rust //! // the primes we want to find //! let ns = (1..100 + 1).map(|x| x * 100_000).collect::>(); //! //! // find our upper bound //! let (_lo, hi) = primal::estimate_nth_prime(10_000_000); //! //! // find the primes up to this upper bound //! let sieve = primal::Sieve::new(hi as usize); //! //! // now we can efficiently sum them up //! let sum = ns.iter() //! .map(|n| sieve.nth_prime(*n)) //! .fold(0u64, |a, b| a + b as u64); //! println!("the sum is {}", sum); //! # assert_eq!(sum, 8_795_091_674); //! ``` //! //! This takes around 40 milliseconds, and gives the same output: much //! better! //! //! (By the way, the version using 1010 as the bound //! instead of the more accurate estimate still only takes ~3 //! seconds.) //! //! ## Counting Primes //! //! Another problem: count the number of primes below 1 million. This //! is evaluating the [prime-counting function //! π](https://en.wikipedia.org/wiki/Prime-counting_function), //! i.e. π(106). //! //! As above, there's a few ways to attack this: the iterator, and the //! sieves. //! //! ```rust //! const LIMIT: usize = 1_000_000; //! //! // iterator //! let count = primal::Primes::all().take_while(|p| *p < LIMIT).count(); //! println!("there are {} primes below 1 million", count); // 78498 //! # assert_eq!(count, 78498); //! //! // sieves //! let sieve = primal::Sieve::new(LIMIT); //! let count = sieve.prime_pi(LIMIT); //! println!("there are {} primes below 1 million", count); //! # assert_eq!(count, 78498); //! //! let count = primal::StreamingSieve::prime_pi(LIMIT); //! println!("there are {} primes below 1 million", count); //! # assert_eq!(count, 78498); //! ``` //! //! `StreamingSieve` is fastest (380 microseconds) followed by `Sieve` //! (400) with `Primes` bringing up the rear at 1300 microseconds. Of //! course, repeated queries will be faster with `Sieve` than with //! `StreamingSieve`, but that flexibility comes at the cost of extra //! memory use. //! //! If an approximation is all that is required, `estimate_prime_pi` //! provides close upper and lower bounds: //! //! ```rust //! let (lo, hi) = primal::estimate_prime_pi(1_000_000); //! println!("there are between {} and {} primes below 1 million", lo, hi); //! // 78380, 78573 //! # assert_eq!(lo, 78380); //! # assert_eq!(hi, 78573); //! ``` //! //! ## Searching Primes //! //! Now for something where `Primes` might be useful: find the first //! prime where the binary expansion (not including trailing zeros) //! ends like `00..001` with at least 27 zeros. This condition is //! checked by: //! //! ```rust //! fn check(p: usize) -> bool { //! p > 1 && (p / 2).trailing_zeros() >= 27 //! } //! ``` //! //! I have no idea how large the prime might be: I know it's //! guaranteed to be at *least* 227 + 1 + 1, but not an //! upper limit. //! //! The `Primes` iterator works perfectly for this: //! //! ```rust //! # fn check(p: usize) -> bool { p > 1 && (p / 2).trailing_zeros() >= 5 } // 27 is too slow //! let p = primal::Primes::all().find(|p| check(*p)).unwrap(); //! println!("the prime is {}", p); //! # assert_eq!(p, 193); //! ``` //! //! It takes about 3.1 seconds for my computer to spit out 3,221,225,473. //! //! Using a sieve is a little trickier: one approach is to start with //! some estimated upper bound (like double the absolute lower bound), //! look for a valid prime. If one isn't found, double the upper bound //! and start again. The `primes_from` method allows for saving a //! little bit of work: we can start iterating from an arbitrary point //! in the sequence, such as the lower bound. //! //! ```rust //! # fn check(p: usize) -> bool { p > 1 && (p / 2).trailing_zeros() >= 5 } // 27 is too slow //! let p; //! let mut lower_bound = 1 << (27 + 1); //! # let mut lower_bound = 1 << (5 + 1); //! loop { //! // our upper bound is double the lower bound //! let sieve = primal::Sieve::new(lower_bound * 2); //! if let Some(p_) = sieve.primes_from(lower_bound).find(|p| check(*p)) { //! p = p_; //! break //! } //! lower_bound *= 2; //! } //! println!("the prime is {}", p); //! # assert_eq!(p, 193); //! ``` //! //! This takes around 3.5 seconds to print the same number. Slower //! than the iterator! //! //! I was just using this silly condition as an example of something //! that doesn't have an obvious upper bound, rather than a problem //! that is hard to do fast. There's a much faster way to tackle it, //! by inverting the problem: construct numbers that satisfy `check`, //! and check the primality of those. //! //! The numbers that satisfy `check` are `k * (1 << (27 + 1)) + 1` for //! `k >= 1`, so the only hard bit is testing primality. Fortunately, //! `primal` offers the `is_prime` function which is an efficient way //! to do primality tests, even of very large numbers. //! //! ```rust //! let mut p = 0; //! for k in 1.. { //! p = k * (1 << (27 + 1)) + 1; //! if primal::is_prime(p) { break } //! } //! println!("the prime is {}", p); //! # assert_eq!(p, 3_221_225_473); //! ``` //! //! This takes 6 microseconds: more than 500,000× //! faster than the iterator! pub use primal_estimate::prime_pi as estimate_prime_pi; pub use primal_estimate::nth_prime as estimate_nth_prime; pub use primal_check::miller_rabin as is_prime; pub use primal_check::{as_perfect_power, as_prime_power}; pub use primal_sieve::{StreamingSieve, Sieve, SievePrimes, Primes};