Skip to content

v0.5.0

Compare
Choose a tag to compare
@JSorngard JSorngard released this 10 May 12:54
· 357 commits to main since this release
a1c8506

This version focuses on adding support for generating primes and sieving numbers in arbitrary ranges, instead of always having to start from 0. It also shortens and clarifies some function names.

What's Changed

Breaking changes

  • Rename are_prime to sieve.
  • Rename are_prime_below to sieve_lt.
  • Change function signature of sieve_lt.
  • Rename largest_prime_leq to previous_prime.
  • Rename smallest_prime_lt to next_prime.
  • Rename prime_counts to count_primes.
  • Remove moebius, as it is out of scope of this crate. If you want the source code for that function it can be found on Rosettacode, or in older versions of this crate.

New features

  • Add primes_geq, primes_lt, and sieve_geq functions to work with arbitrary ranges. They take in two const generics, the number of values to return and the size of the sieve used during evaluation.
  • Add primes_segment! and sieve_segment! macros to simplify usage of the above functions. These macros compute the size of the sieve that the above functions need. Due to restrictions on const arithmetic this can not be done inside the functions.
  • Add isqrt function. This can be useful if you wish to compute the size of the sieve yourself.

Minor changes

  • Speed up PRIMES::count_primes_leq by using a binary instead of linear search.
  • Various documentation improvements.