Crates.io | malachite-q |
lib.rs | malachite-q |
version | |
source | src |
created_at | 2022-06-04 23:23:10.423562 |
updated_at | 2025-02-03 03:56:04.191633 |
description | The arbitrary-precision type Rational, with efficient algorithms partially derived from GMP and FLINT. |
homepage | https://malachite.rs/ |
repository | https://github.com/mhogrefe/malachite |
max_upload_size | |
id | 599954 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Rather than using this crate directly, use the
malachite
meta-crate. It re-exports all of this crate's
public members.
In malachite-q
's doctests you will frequently see import paths beginning with
malachite_q::
. When using the malachite
crate, replace this part of the paths with
malachite::
.
The import path of the Rational
type is shortened to malachite::Rational
.
This crate defines
Rational
s. The name of
this crate refers to the mathematical symbol for rational numbers, ℚ.
Rational
s. These include
Rational
s are stored as
Natural
s, so
Rational
s with small
numerators and denominators can be stored entirely on the stack.Rational
s requires
(automatically) reducing the numerator and denominator. This is done very efficiently by using
the high performance GCD and exact division algorithms implemented by
Natural
s.This crate comes with a bin
target that can be used for running demos and benchmarks.
Rational
addition, you
can use the following command:
cargo run --features bin_build --release -- -l 10000 -m exhaustive -d demo_rational_add
This command uses the exhaustive
mode, which generates every possible input, generally
starting with the simplest input and progressing to more complex ones. Another mode is
random
. The -l
flag specifies how many inputs should be generated.cargo run --features bin_build --release -- -l 1000000 -m random -b \
benchmark_rational_add_algorithms -o gcd-bench.gp
or GCD implementations of other libraries:
cargo run --features bin_build --release -- -l 1000000 -m random -b \
benchmark_rational_add_assign_library_comparison -o gcd-bench.gp
This creates a file called gcd-bench.gp. You can use gnuplot to create an SVG from it like
so:
gnuplot -e "set terminal svg; l \"gcd-bench.gp\"" > gcd-bench.svg
The list of available demos and benchmarks is not documented anywhere; you must find them by
browsing through
bin_util/demo_and_bench
.
32_bit_limbs
: Sets the type of Limb
to
u32
instead of the default,
u64
.random
: This feature provides some functions for randomly generating values. It is off by
default to avoid pulling in some extra dependencies.enable_serde
: Enables serialization and deserialization using serde.test_build
: A large proportion of the code in this crate is only used for testing. For a
typical user, building this code would result in an unnecessarily long compilation time and
an unnecessarily large binary. My solution is to only build this code when the test_build
feature is enabled. If you want to run unit tests, you must enable test_build
. However,
doctests don't require it, since they only test the public interface. Enabling this feature also
enables random
.bin_build
: This feature is used to build the code for demos and benchmarks, which also
takes a long time to build. Enabling this feature also enables test_build
and random
.Malachite is developed by Mikhail Hogrefe. Thanks to b4D8, florian1345, konstin, Rowan Hart, YunWon Jeong, Park Joon-Kyu, Antonio Mamić, OliverNChalk, shekohex, and skycloudd for additional contributions.
Copyright © 2025 Mikhail Hogrefe