padic 0.1.4

P-adic numbers in Rust
Documentation

P-adic numbers

crate documentation minimum rustc 1.31

A collection of tools for p-adic numbers in Rust.

This includes a p-adic type and a rational type.

Status

This library is currently in development. It is not yet ready for use.

Usage

Add this to your Cargo.toml:

[dependencies]

padic = "0.1.4"

use padic::Ratio;
let ratio = Ratio::new(1, 3);
let padic = r.to_padic(5, 6);
assert_eq!(padic.valuation, 0);
assert_eq!(padic.expansion, vec![3, 1, 3, 1, 3, 2]);
assert_eq!(padic.to_string(), "...3 1 3 1 3 2");

Helpers functions

  • Prime factors with multiplicity (a: i64 / b: i64) -> Vec<(prime: u64, exp: u64)>
  • Greatest common divisor (Stein's algorithm)
  • Modular multiplicative inverse

Resources

TODOs

Ratio

  • Extract sign information to transform ratio into a tuple of unsigned integer variables
  • Reduce ratio to lowest terms using GCD (Stein's algorithm)
  • Basic arithmetic operations for rational numbers

P-adic

  • Prime decomposition returning vector of (prime, exponent) tuples.
  • P-adic valuation of rational number
  • P-adic norm of rational number
  • P-adic expansion of rational number with given precision
  • P-adic string representation with given precision and given valuation
  • Cyclic detection in p-adic expansion
  • Convert p-adic expansion into rational number
  • Basic operations for p-adic numbers

Bugs

  • 5-adic expansion of 25/3 is not correct
  • 5-adic expansion of 1/75 is not correct

License

MIT