33 releases (stable)

5.4.0 May 7, 2023
5.0.2 Dec 6, 2022
5.0.1 Nov 29, 2022
4.1.0 Oct 18, 2022
0.9.0 Nov 2, 2021

#128 in Algorithms

Download history 25/week @ 2023-01-25 40/week @ 2023-02-01 39/week @ 2023-02-08 120/week @ 2023-02-15 29/week @ 2023-02-22 7/week @ 2023-03-01 6/week @ 2023-03-08 7/week @ 2023-03-15 70/week @ 2023-03-29 32/week @ 2023-04-05 59/week @ 2023-04-12 40/week @ 2023-04-19 42/week @ 2023-04-26 58/week @ 2023-05-03 43/week @ 2023-05-10

183 downloads per month
Used in 7 crates

MIT license

93KB
3K SLoC

Opis

Opis is a library for rational number and matrix arithmetic.

Author

Roy R. O. Okello

Email

Github

Twitter

Features

  • Arbitrary Precision Integer Representation and Arithmetic
  • Fractions

Usage

Cargo.toml

[dependencies]
opis = "5.4.0"

Module.rs

use opis::{ Bit, Integer, Fraction, Matrix };

API

Bit

Add a + b

And a & b

Eq a == a

Not !a

Or a | b

Xor a ^ b

Integer

Addition a + b, a += b

And a & b

Base2 Integer::from_bin("1010101"), a.to_bin()

Base10 Integer::from_dec("674755"), a.to_dec()

Base16 Integer::from_hex("00ABC012"), a.to_hex()

Bytes Integer::from(&bytes), a.into()

Comparision a < b, a <= b, a > b, a >= b

Division a / b?

Equality a == b

Extended Euclidean Algorithm a.ext_gcd(&b)

Extended Bits a.to_ext_bits(256)

Extended Bytes a.to_ext_bytes(32)

Linear Feedback Shift Register a.lfsr(1)?

Modulo: a.modulo(&m)

Modular Exponentiation: base.mod_pow(&exponent, &modulus)

Multiply a * b, a *= b

Negate a.negate()

Not !a

Or a | b

Exponentiation a.pow(e)

Remainder: a % b?

Shifts a << 1, a <<= 1, a >> 1, a >>= 1

Subtraction a - b, a -= b

Type Conversion 2_u8.into()

Fraction

Addition a + b, a += b

Comparison a < b, a <= b, a > b, a >= b

Division a / b?

Equality a == b

Multiplication a * b, a *= b

Reciprocal a.reciprocal()

Reduce a.reduce()

String Conversion Fraction::try_from("1/2")

Subtraction a - b, a -= b

Type Conversion 2_u8.into()

Matrix

Addition a + b

Cofactors a.cofactors(neg_one, one)

Determinant a.determinant()

Dimensions a.dimensions()

Equality a == b

Identity Matrix::identity(size, zero, one)

Inverse a.inverse(zero, one)

Minors a.minors()

Multiplication a * b

Subtraction a - b

Trace a.trace()

Transpose a.transpose()

License

Disclaimer

12023-05-07

No runtime deps