gcdn 0.2.0

An algorithmically faster implementation of variadic GCD.
Documentation
  • Coverage
  • 100%
    25 out of 25 items documented0 out of 23 items with examples
  • Size
  • Source code size: 31.01 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.43 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • atlv24/gcdn
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • atlv24

gcdn

gcdn is an algorithmically faster implementation of variadic GCD. It outperforms chaining implementations such as gcd(gcd(a,b), c) by over 40% in some workloads.

This is a novel algorithm that I wrote in 2017 as part of some experiments in C# and ported to Rust in 2021, but have continually delayed releasing out of hopes of writing a paper about it someday.

The main idea is to sort, and then do some binary-euclidean-algorithm tricks that use knowledge of all arguments to accelerate evaluation.

Please consult the documentation for more information.

Add it to your Cargo.toml:

[dependencies]

gcdn = "0.1"

Example

assert_eq!(gcd4(15, 120, 30, 25), 5u32);

// needs mutable access because it runs the algorithm in-place to avoid allocation
assert_eq!(gcdn(&mut [15, 120, 30, 25]), 5u32);

License

gcdn is dual-licensed under either:

at your option.

Your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.