Skip to content

v0.12.0

Choose a tag to compare

@mhogrefe mhogrefe released this 20 Sep 06:06
· 213 commits to master since this release

This release adds every trigonometric and inverse trigonometric function, correctly rounded, to Float. It also adds two new complex types, GaussianInteger and GaussianRational.

Highlights

  • Trigonometry for Float: sin, cos, tan, sec, csc, cot, and sin_cos, with their inverses asin, acos, atan, atan2, asec, acsc, and acot. Each of the fourteen comes in six forms: a Float or a Rational angle, measured in radians, in uths of a turn (_with_period), or in half-turns (_pi), and each also has a correctly rounded f32/f64 counterpart. This goes past MPFR, which has no secu, cscu, or cotu to match its sinu and cosu, no pi scalings of the reciprocal trio, and no asec, acsc, or acot at all. Also new: the Dottie number, the fixed point of the cosine, to any precision.
  • Gaussian integers and rationals: GaussianInteger in malachite-nz and GaussianRational in malachite-q, each a pair of public real and imaginary fields. Arithmetic follows FLINT's fmpzi algorithms (Karatsuba and double-word multiplication, exact division, Euclidean div_rem with nearest-quotient rounding, GCD, powers, and exact square and nth roots) alongside canonicalization under the units ±1 and ±i, the full equality, ordering, and absolute-value comparison matrices against the real types, and a complete conversion matrix.
  • Float is now in the malachite crate by default. The floats feature is on by default, so Float and the float module are re-exported at the crate root. This costs nothing extra to compile: malachite-float was already built by every default build.
  • Performance: sin, cos, and sin_cos use the equivalent of MPFR's asymptotically fast binary-splitting tier at high precision, and multiplying any bignum by itself through aliased references (&x * &x) routes to the squaring algorithm.
  • New traits in malachite-base for complex arithmetic: AbsSquared, Conjugate, MulI, DivI, MulIPow, IsGaussianInteger, IsReal, IsUnit, CanonicalizeUnit, CanonicalUnitIPow, the I and NegativeI constants, and ImaginaryFrom/ImaginaryInto, plus ContentAndPrimitivePart, Content, and PrimitivePart.

Breaking and behavioral changes

  • PrimitiveInt and PrimitiveFloat have gained supertraits, so a type outside Malachite implementing either must now implement those too. Code that uses them only as bounds is unaffected, and gains the new methods on every primitive type.
  • The malachite crate enables floats by default, so a glob import of malachite alongside another Float is now ambiguous.
  • The malachite crate's std, random, enable_serde, and 32_bit_limbs features no longer drag the optional sub-crates into the build; each now configures whichever of naturals_and_integers, rationals, and floats is enabled, and those three build on one another. --no-default-features plus only a modifier feature now gets malachite-base alone.

See the full changelog for details.