Struct __mpz_struct

Source
#[repr(C)]
pub struct __mpz_struct { pub _mp_alloc: int_t, pub _mp_size: int_t, pub _mp_d: *mut mp_limb_t, }
Expand description

__mpz_struct

Fields§

§_mp_alloc: int_t

_mp_alloc

§_mp_size: int_t

_mp_size

§_mp_d: *mut mp_limb_t

_mp_d

Implementations§

Source§

impl __mpz_struct

impl mpz_s

Source

pub fn clear(&mut self)

clear

Source

pub fn init() -> Self

init create new instance

Source

pub fn init2(n: mp_bitcnt_t) -> Self

init2 with prec create new instance

Source

pub fn init_set(a: mpz_r<'_>) -> Self

init_set create new instance

Source

pub fn init_set_ui(u: ui_t) -> Self

init_set_ui create new instance

Source

pub fn init_set_si(s: si_t) -> Self

init_set_si create new instance

Source

pub fn init_set_d(d: double_t) -> Self

init_set_d create new instance

Source

pub fn init_set_str(s: &str, b: int_t) -> Self

init_set_str create new instance

Source

pub fn set(&mut self, a: mpz_r<'_>) -> &mut Self

set self = a

Source

pub fn set_ui(&mut self, u: ui_t) -> &mut Self

set_ui self = u

Source

pub fn set_si(&mut self, s: si_t) -> &mut Self

set_si self = s

Source

pub fn set_d(&mut self, d: double_t) -> &mut Self

set_d self = d

Source

pub fn set_str(&mut self, s: &str, b: int_t) -> &mut Self

set_str self from str

Source

pub fn fmtstr(&self, b: int_t) -> String

fmtstr

Source

pub fn binstr(&self) -> String

binstr

  • return “-111111” when bin is “1…11000001”
Source

pub fn hexstr(&self) -> String

hexstr

  • return “-3f” when hex is “f…c1”
Source

pub fn hexdump(&self) -> String

hexdump as String dump of limbs

Source

pub fn get_d(&self) -> double_t

get_d (loss of digits)

Source

pub fn get_ui(&self) -> ui_t

get_ui (loss of digits)

Source

pub fn get_si(&self) -> si_t

get_si (loss of digits)

Source

pub fn get_d_2exp(&self) -> (double_t, si_t)

get_d_2exp (loss of digits)

Source

pub fn swap(&mut self, b: mpz_t<'_>) -> &mut Self

swap

Source

pub fn realloc2(&mut self, n: mp_bitcnt_t) -> &mut Self

realloc2

Source

pub fn _realloc(&mut self, sz: mp_size_t) -> &mut Self

_realloc

Source

pub fn size(&self) -> mp_size_t

size

Source

pub fn limbs_read(&self) -> &[mp_limb_t]

limbs_read slice

Source

pub fn getlimbn(&self, n: mp_size_t) -> mp_limb_t

getlimbn (single element)

Source

pub fn limbs_write(&mut self, sz: mp_size_t) -> &mut [mp_limb_t]

limbs_write slice (must call limbs_finish)

Source

pub fn limbs_modify(&mut self, sz: mp_size_t) -> &mut [mp_limb_t]

limbs_modify slice (same as write)

Source

pub fn limbs_finish(&mut self, sz: mp_size_t) -> &mut Self

limbs_finish (used after write or modify to update internal size)

Source

pub fn roinit_n(&mut self, p: &[mp_limb_t], sz: mp_size_t) -> &mut Self

roinit_n (unsafe) slice single element

Source

pub fn cmp(&self, b: mpz_r<'_>) -> int_t

cmp

Source

pub fn cmp_d(&self, d: double_t) -> int_t

cmp_d

Source

pub fn cmp_ui(&self, u: ui_t) -> int_t

cmp_ui

Source

pub fn cmp_si(&self, s: si_t) -> int_t

cmp_si

Source

pub fn cmpabs(&self, b: mpz_r<'_>) -> int_t

cmpabs

Source

pub fn cmpabs_d(&self, d: double_t) -> int_t

cmpabs_d

Source

pub fn cmpabs_ui(&self, u: ui_t) -> int_t

cmpabs_ui

Source

pub fn sgn(&self) -> int_t

sgn

Source

pub fn root(&self, n: ui_t) -> (Self, bool)

root nth root of self create new instance

Source

pub fn rootrem(&self, n: ui_t) -> (Self, Self)

rootrem (nth root of self, self - root**n) create new instance

Source

pub fn sqrt(&self) -> Self

sqrt square root of self create new instance

Source

pub fn sqrtrem(&self) -> (Self, Self)

sqrtrem (square root of self, self - root**2) create new instance

Source

pub fn perfect_power_p(&self) -> bool

perfect_power_p

Source

pub fn perfect_square_p(&self) -> bool

perfect_square_p

Source

pub fn primorial_ui(n: ui_t) -> Self

primorial_ui c = 235711*…*p(prev)*p(<=n) create new instance

Source

pub fn fac_ui(n: ui_t) -> Self

fac_ui create new instance

Source

pub fn fac2_ui(n: ui_t) -> Self

fac2_ui create new instance

Source

pub fn mfac_uiui(n: ui_t, m: ui_t) -> Self

mfac_uiui create new instance

Source

pub fn remove(&self, f: mpz_r<'_>) -> (Self, mp_bitcnt_t)

remove create new instance

Source

pub fn fib_ui(n: ui_t) -> Self

fib_ui create new instance

Source

pub fn fib2_ui(n: ui_t) -> (Self, Self)

fib2_ui create new instance (f_n, f_nsub1)

Source

pub fn lucnum_ui(n: ui_t) -> Self

lucnum_ui create new instance

Source

pub fn lucnum2_ui(n: ui_t) -> (Self, Self)

lucnum2_ui create new instance (l_n, l_n_1)

Source

pub fn gcd(&self, b: mpz_r<'_>) -> Self

gcd create new instance

Source

pub fn gcd_ui(&self, u: ui_t) -> (Self, ui_t)

gcd_ui create new instance (gcd, gcd: ui_t) return 0 when gcd does not fit to ui_t

Source

pub fn gcdext(&self, b: mpz_r<'_>) -> (Self, Self, Self)

gcdext create new instance (gcd, s, t) s and t to coefficients satisfying as + bt == gcd

Source

pub fn lcm(&self, b: mpz_r<'_>) -> Self

lcm create new instance

Source

pub fn lcm_ui(&self, u: ui_t) -> Self

lcm_ui create new instance

Source

pub fn probab_prime_p(&self, r: int_t) -> int_t

probab_prime_p 2 or 1 or 0

Source

pub fn nextprime(&self) -> Self

nextprime create new instance

Source

pub fn invert(a: mpz_r<'_>, b: mpz_r<'_>) -> (Self, int_t)

invert create new instance c = inverse of a mod b ((c*a) mod b == 1) returns (undefined, 0) when not exist inverse

Source

pub fn jacobi(&self, n: mpz_r<'_>) -> int_t

jacobi 0 1 -1 (defined only for n odd)

Source

pub fn legendre(&self, p: mpz_r<'_>) -> int_t

legendre 0 1 -1 (defined only for p an odd positive prime)

Source

pub fn kronecker(&self, n: mpz_r<'_>) -> int_t

kronecker

Source

pub fn kronecker_ui(&self, u: ui_t) -> int_t

kronecker_ui

Source

pub fn kronecker_si(&self, s: si_t) -> int_t

kronecker_si

Source

pub fn ui_kronecker(&self, u: ui_t) -> int_t

ui_kronecker

Source

pub fn si_kronecker(&self, s: si_t) -> int_t

si_kronecker

Source

pub fn bin_ui(n: mpz_r<'_>, k: ui_t) -> Self

bin_ui nCk create new instance

Source

pub fn bin_uiui(n: ui_t, k: ui_t) -> Self

bin_uiui nCk create new instance

Source

pub fn abs(&self) -> Self

abs create new instance

Source

pub fn neg(&self) -> Self

neg create new instance

Source

pub fn sub(&mut self, b: mpz_r<'_>) -> &mut Self

sub self -= b

Source

pub fn sub_ui(&mut self, u: ui_t) -> &mut Self

sub_ui self -= u

Source

pub fn ui_sub(&mut self, u: ui_t) -> &mut Self

ui_sub self = u - self

Source

pub fn submul(&mut self, a: mpz_r<'_>, b: mpz_r<'_>) -> &mut Self

submul self -= a * b

Source

pub fn submul_ui(&mut self, a: mpz_r<'_>, u: ui_t) -> &mut Self

submul_ui self -= a * u

Source

pub fn add(&mut self, b: mpz_r<'_>) -> &mut Self

add self += b

Source

pub fn add_ui(&mut self, u: ui_t) -> &mut Self

add_ui self += u

Source

pub fn addmul(&mut self, a: mpz_r<'_>, b: mpz_r<'_>) -> &mut Self

addmul self += a * b

Source

pub fn addmul_ui(&mut self, a: mpz_r<'_>, u: ui_t) -> &mut Self

addmul_ui self += a * u

Source

pub fn mul(&mut self, b: mpz_r<'_>) -> &mut Self

mul self *= b

Source

pub fn mul_ui(&mut self, u: ui_t) -> &mut Self

mul_ui self *= u

Source

pub fn mul_si(&mut self, s: si_t) -> &mut Self

mul_si self *= s

Source

pub fn mul_2exp(&mut self, n: mp_bitcnt_t) -> &mut Self

mul_2exp self *= 2**n

Source

pub fn cdiv_q(&self, d: mpz_r<'_>) -> Self

cdiv_q create new instance

Source

pub fn cdiv_r(&self, d: mpz_r<'_>) -> Self

cdiv_r create new instance

Source

pub fn cdiv_qr(&self, d: mpz_r<'_>) -> (Self, Self)

cdiv_qr create new instance

Source

pub fn cdiv_q_ui(&self, d: ui_t) -> (Self, ui_t)

cdiv_q_ui create new instance

Source

pub fn cdiv_r_ui(&self, d: ui_t) -> (Self, ui_t)

cdiv_r_ui create new instance

Source

pub fn cdiv_qr_ui(&self, d: ui_t) -> (Self, Self, ui_t)

cdiv_qr_ui create new instance

Source

pub fn cdiv_ui(&self, d: ui_t) -> ui_t

cdiv_ui

Source

pub fn cdiv_q_2exp(&self, b: mp_bitcnt_t) -> Self

cdiv_q_2exp create new instance

Source

pub fn cdiv_r_2exp(&self, b: mp_bitcnt_t) -> Self

cdiv_r_2exp create new instance

Source

pub fn fdiv_q(&self, d: mpz_r<'_>) -> Self

fdiv_q create new instance

Source

pub fn fdiv_r(&self, d: mpz_r<'_>) -> Self

fdiv_r create new instance

Source

pub fn fdiv_qr(&self, d: mpz_r<'_>) -> (Self, Self)

fdiv_qr create new instance

Source

pub fn fdiv_q_ui(&self, d: ui_t) -> (Self, ui_t)

fdiv_q_ui create new instance

Source

pub fn fdiv_r_ui(&self, d: ui_t) -> (Self, ui_t)

fdiv_r_ui create new instance

Source

pub fn fdiv_qr_ui(&self, d: ui_t) -> (Self, Self, ui_t)

fdiv_qr_ui create new instance

Source

pub fn fdiv_ui(&self, d: ui_t) -> ui_t

fdiv_ui

Source

pub fn fdiv_q_2exp(&self, b: mp_bitcnt_t) -> Self

fdiv_q_2exp create new instance

Source

pub fn fdiv_r_2exp(&self, b: mp_bitcnt_t) -> Self

fdiv_r_2exp create new instance

Source

pub fn tdiv_q(&self, d: mpz_r<'_>) -> Self

tdiv_q create new instance

Source

pub fn tdiv_r(&self, d: mpz_r<'_>) -> Self

tdiv_r create new instance

Source

pub fn tdiv_qr(&self, d: mpz_r<'_>) -> (Self, Self)

tdiv_qr create new instance

Source

pub fn tdiv_q_ui(&self, d: ui_t) -> (Self, ui_t)

tdiv_q_ui create new instance

Source

pub fn tdiv_r_ui(&self, d: ui_t) -> (Self, ui_t)

tdiv_r_ui create new instance

Source

pub fn tdiv_qr_ui(&self, d: ui_t) -> (Self, Self, ui_t)

tdiv_qr_ui create new instance

Source

pub fn tdiv_ui(&self, d: ui_t) -> ui_t

tdiv_ui

Source

pub fn tdiv_q_2exp(&self, b: mp_bitcnt_t) -> Self

tdiv_q_2exp create new instance

Source

pub fn tdiv_r_2exp(&self, b: mp_bitcnt_t) -> Self

tdiv_r_2exp create new instance

Source

pub fn modulo(&self, d: mpz_r<'_>) -> Self

modulo create new instance

Source

pub fn mod_ui(&self, d: ui_t) -> (Self, ui_t)

mod_ui (the result is always non-negative) create new instance

Source

pub fn divexact(&self, d: mpz_r<'_>) -> Self

divexact create new instance

Source

pub fn divexact_ui(&self, d: ui_t) -> Self

divexact_ui create new instance

Source

pub fn divisible_p(&self, d: mpz_r<'_>) -> bool

divisible_p

Source

pub fn divisible_ui_p(&self, d: ui_t) -> bool

divisible_ui_p

Source

pub fn divisible_2exp_p(&self, b: mp_bitcnt_t) -> bool

divisible_2exp_p

Source

pub fn congruent_p(&self, c: mpz_r<'_>, d: mpz_r<'_>) -> bool

congruent_p

Source

pub fn congruent_ui_p(&self, c: ui_t, d: ui_t) -> bool

congruent_ui_p

Source

pub fn congruent_2exp_p(&self, c: mpz_r<'_>, b: mp_bitcnt_t) -> bool

congruent_2exp_p

Source

pub fn powm_sec(a: mpz_r<'_>, n: mpz_r<'_>, m: mpz_r<'_>) -> Self

powm_sec (a**n) mod m required n > 0 and m is odd create new instance

Source

pub fn powm(a: mpz_r<'_>, n: mpz_r<'_>, m: mpz_r<'_>) -> Self

powm (an) mod m n < 0 when exists inv a-1 mod m create new instance

Source

pub fn powm_ui(a: mpz_r<'_>, n: ui_t, m: mpz_r<'_>) -> Self

powm_ui (a**n) mod m create new instance

Source

pub fn pow_ui(a: mpz_r<'_>, n: ui_t) -> Self

pow_ui a**n create new instance

Source

pub fn ui_pow_ui(a: ui_t, n: ui_t) -> Self

ui_pow_ui a**n create new instance

Source

pub fn sizeinbase(&self, base: int_t) -> mp_size_t

sizeinbase

Source

pub fn even_p(&self) -> bool

even_p

Source

pub fn odd_p(&self) -> bool

odd_p

Source

pub fn fits_ulong_p(&self) -> bool

fits_ulong_p

Source

pub fn fits_slong_p(&self) -> bool

fits_slong_p

Source

pub fn fits_uint_p(&self) -> bool

fits_uint_p

Source

pub fn fits_sint_p(&self) -> bool

fits_sint_p

Source

pub fn fits_ushort_p(&self) -> bool

fits_ushort_p

Source

pub fn fits_sshort_p(&self) -> bool

fits_sshort_p

Source

pub fn urandomb(r: randstate_t<'_>, nbits: mp_bitcnt_t) -> Self

urandomb create new instance

Source

pub fn urandomm(r: randstate_t<'_>, n: mpz_r<'_>) -> Self

urandomm create new instance

Source

pub fn rrandomb(r: randstate_t<'_>, nbits: mp_bitcnt_t) -> Self

rrandomb create new instance

Source

pub fn random(max_size: mp_size_t) -> Self

random create new instance (obsoleted) urandomb or urandomm instead

Source

pub fn random2(max_size: mp_size_t) -> Self

random2 create new instance

Source

pub fn and(&self, b: mpz_r<'_>) -> Self

and create new instance

Source

pub fn ior(&self, b: mpz_r<'_>) -> Self

ior create new instance

Source

pub fn xor(&self, b: mpz_r<'_>) -> Self

xor create new instance

Source

pub fn com(&self) -> Self

com create new instance

Source

pub fn popcount(&self) -> mp_bitcnt_t

popcount

Source

pub fn hamdist(&self, b: mpz_r<'_>) -> mp_bitcnt_t

hamdist hamming distance between a and b (both sgn must be same)

Source

pub fn scan0(&self, s: mp_bitcnt_t) -> mp_bitcnt_t

scan0 to msb

Source

pub fn scan1(&self, s: mp_bitcnt_t) -> mp_bitcnt_t

scan1 to msb

Source

pub fn clrbit(&mut self, n: mp_bitcnt_t) -> &mut Self

clrbit

Source

pub fn setbit(&mut self, n: mp_bitcnt_t) -> &mut Self

setbit

Source

pub fn combit(&mut self, n: mp_bitcnt_t) -> &mut Self

combit

Source

pub fn tstbit(&self, n: mp_bitcnt_t) -> bool

tstbit

Source

pub fn fact(n: ui_t) -> Self

fact create new instance (slow without cache)

Source

pub fn fact_cached(n: ui_t, m: &mut HashMap<ui_t, mpz_s>) -> Self

fact cached

Trait Implementations§

Source§

impl Debug for __mpz_struct

impl Debug

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

fmt

Source§

impl Display for __mpz_struct

impl Display

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

fmt

Source§

impl Drop for __mpz_struct

impl Drop

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl SNew for __mpz_struct

impl SNew

Source§

fn new() -> Self

new

Source§

fn as_ptr(&self) -> mp_r

as_ptr
Source§

fn as_ptr_mut(&mut self) -> mp_t

as_ptr_mut

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.