Numworks Epsilon  1.4.1
Graphing Calculator Operating System
mpz.c File Reference
#include <string.h>
#include <assert.h>
#include "py/mpz.h"

Go to the source code of this file.

Macros

#define DIG_SIZE   (MPZ_DIG_SIZE)
 
#define DIG_MASK   ((MPZ_LONG_1 << DIG_SIZE) - 1)
 
#define DIG_MSB   (MPZ_LONG_1 << (DIG_SIZE - 1))
 
#define DIG_BASE   (MPZ_LONG_1 << DIG_SIZE)
 
#define MIN_ALLOC   (2)
 

Functions

STATIC size_t mpn_remove_trailing_zeros (mpz_dig_t *oidig, mpz_dig_t *idig)
 
STATIC int mpn_cmp (const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen)
 
STATIC size_t mpn_shl (mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n)
 
STATIC size_t mpn_shr (mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mp_uint_t n)
 
STATIC size_t mpn_add (mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen)
 
STATIC size_t mpn_sub (mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen)
 
STATIC size_t mpn_and_neg (mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk)
 
STATIC size_t mpn_or_neg (mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk)
 
STATIC size_t mpn_xor_neg (mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen, mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk)
 
STATIC size_t mpn_mul_dig_add_dig (mpz_dig_t *idig, size_t ilen, mpz_dig_t dmul, mpz_dig_t dadd)
 
STATIC size_t mpn_mul (mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *kdig, size_t klen)
 
STATIC void mpn_div (mpz_dig_t *num_dig, size_t *num_len, const mpz_dig_t *den_dig, size_t den_len, mpz_dig_t *quo_dig, size_t *quo_len)
 
void mpz_init_zero (mpz_t *z)
 
void mpz_init_from_int (mpz_t *z, mp_int_t val)
 
void mpz_init_fixed_from_int (mpz_t *z, mpz_dig_t *dig, size_t alloc, mp_int_t val)
 
void mpz_deinit (mpz_t *z)
 
STATIC void mpz_free (mpz_t *z)
 
STATIC void mpz_need_dig (mpz_t *z, size_t need)
 
STATIC mpz_tmpz_clone (const mpz_t *src)
 
void mpz_set (mpz_t *dest, const mpz_t *src)
 
void mpz_set_from_int (mpz_t *z, mp_int_t val)
 
void mpz_set_from_ll (mpz_t *z, long long val, bool is_signed)
 
size_t mpz_set_from_str (mpz_t *z, const char *str, size_t len, bool neg, unsigned int base)
 
void mpz_set_from_bytes (mpz_t *z, bool big_endian, size_t len, const byte *buf)
 
int mpz_cmp (const mpz_t *z1, const mpz_t *z2)
 
void mpz_abs_inpl (mpz_t *dest, const mpz_t *z)
 
void mpz_neg_inpl (mpz_t *dest, const mpz_t *z)
 
void mpz_not_inpl (mpz_t *dest, const mpz_t *z)
 
void mpz_shl_inpl (mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs)
 
void mpz_shr_inpl (mpz_t *dest, const mpz_t *lhs, mp_uint_t rhs)
 
void mpz_add_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
 
void mpz_sub_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
 
void mpz_and_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
 
void mpz_or_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
 
void mpz_xor_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
 
void mpz_mul_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
 
void mpz_pow_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs)
 
void mpz_pow3_inpl (mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs, const mpz_t *mod)
 
void mpz_divmod_inpl (mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs)
 
mp_int_t mpz_hash (const mpz_t *z)
 
bool mpz_as_int_checked (const mpz_t *i, mp_int_t *value)
 
bool mpz_as_uint_checked (const mpz_t *i, mp_uint_t *value)
 
void mpz_as_bytes (const mpz_t *z, bool big_endian, size_t len, byte *buf)
 
size_t mpz_as_str_inpl (const mpz_t *i, unsigned int base, const char *prefix, char base_char, char comma, char *str)
 

Macro Definition Documentation

◆ DIG_BASE

#define DIG_BASE   (MPZ_LONG_1 << DIG_SIZE)

Definition at line 37 of file mpz.c.

◆ DIG_MASK

#define DIG_MASK   ((MPZ_LONG_1 << DIG_SIZE) - 1)

Definition at line 35 of file mpz.c.

◆ DIG_MSB

#define DIG_MSB   (MPZ_LONG_1 << (DIG_SIZE - 1))

Definition at line 36 of file mpz.c.

◆ DIG_SIZE

#define DIG_SIZE   (MPZ_DIG_SIZE)

Definition at line 34 of file mpz.c.

◆ MIN_ALLOC

#define MIN_ALLOC   (2)

Definition at line 646 of file mpz.c.

Function Documentation

◆ mpn_add()

STATIC size_t mpn_add ( mpz_dig_t idig,
const mpz_dig_t jdig,
size_t  jlen,
const mpz_dig_t kdig,
size_t  klen 
)

Definition at line 151 of file mpz.c.

◆ mpn_and_neg()

STATIC size_t mpn_and_neg ( mpz_dig_t idig,
const mpz_dig_t jdig,
size_t  jlen,
const mpz_dig_t kdig,
size_t  klen,
mpz_dbl_dig_t  carryi,
mpz_dbl_dig_t  carryj,
mpz_dbl_dig_t  carryk 
)

Definition at line 230 of file mpz.c.

◆ mpn_cmp()

STATIC int mpn_cmp ( const mpz_dig_t idig,
size_t  ilen,
const mpz_dig_t jdig,
size_t  jlen 
)

Definition at line 62 of file mpz.c.

◆ mpn_div()

STATIC void mpn_div ( mpz_dig_t num_dig,
size_t num_len,
const mpz_dig_t den_dig,
size_t  den_len,
mpz_dig_t quo_dig,
size_t quo_len 
)

Definition at line 458 of file mpz.c.

◆ mpn_mul()

STATIC size_t mpn_mul ( mpz_dig_t idig,
mpz_dig_t jdig,
size_t  jlen,
mpz_dig_t kdig,
size_t  klen 
)

Definition at line 427 of file mpz.c.

◆ mpn_mul_dig_add_dig()

STATIC size_t mpn_mul_dig_add_dig ( mpz_dig_t idig,
size_t  ilen,
mpz_dig_t  dmul,
mpz_dig_t  dadd 
)

Definition at line 405 of file mpz.c.

◆ mpn_or_neg()

STATIC size_t mpn_or_neg ( mpz_dig_t idig,
const mpz_dig_t jdig,
size_t  jlen,
const mpz_dig_t kdig,
size_t  klen,
mpz_dbl_dig_t  carryi,
mpz_dbl_dig_t  carryj,
mpz_dbl_dig_t  carryk 
)

Definition at line 321 of file mpz.c.

◆ mpn_remove_trailing_zeros()

STATIC size_t mpn_remove_trailing_zeros ( mpz_dig_t oidig,
mpz_dig_t idig 
)

Definition at line 52 of file mpz.c.

◆ mpn_shl()

STATIC size_t mpn_shl ( mpz_dig_t idig,
mpz_dig_t jdig,
size_t  jlen,
mp_uint_t  n 
)

Definition at line 80 of file mpz.c.

◆ mpn_shr()

STATIC size_t mpn_shr ( mpz_dig_t idig,
mpz_dig_t jdig,
size_t  jlen,
mp_uint_t  n 
)

Definition at line 119 of file mpz.c.

◆ mpn_sub()

STATIC size_t mpn_sub ( mpz_dig_t idig,
const mpz_dig_t jdig,
size_t  jlen,
const mpz_dig_t kdig,
size_t  klen 
)

Definition at line 181 of file mpz.c.

◆ mpn_xor_neg()

STATIC size_t mpn_xor_neg ( mpz_dig_t idig,
const mpz_dig_t jdig,
size_t  jlen,
const mpz_dig_t kdig,
size_t  klen,
mpz_dbl_dig_t  carryi,
mpz_dbl_dig_t  carryj,
mpz_dbl_dig_t  carryk 
)

Definition at line 380 of file mpz.c.

◆ mpz_abs_inpl()

void mpz_abs_inpl ( mpz_t dest,
const mpz_t z 
)

Definition at line 1076 of file mpz.c.

◆ mpz_add_inpl()

void mpz_add_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1171 of file mpz.c.

◆ mpz_and_inpl()

void mpz_and_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1220 of file mpz.c.

◆ mpz_as_bytes()

void mpz_as_bytes ( const mpz_t z,
bool  big_endian,
size_t  len,
byte buf 
)

Definition at line 1618 of file mpz.c.

◆ mpz_as_int_checked()

bool mpz_as_int_checked ( const mpz_t i,
mp_int_t value 
)

Definition at line 1576 of file mpz.c.

◆ mpz_as_str_inpl()

size_t mpz_as_str_inpl ( const mpz_t i,
unsigned int  base,
const char *  prefix,
char  base_char,
char  comma,
char *  str 
)

Definition at line 1679 of file mpz.c.

◆ mpz_as_uint_checked()

bool mpz_as_uint_checked ( const mpz_t i,
mp_uint_t value 
)

Definition at line 1596 of file mpz.c.

◆ mpz_clone()

STATIC mpz_t* mpz_clone ( const mpz_t src)

Definition at line 733 of file mpz.c.

◆ mpz_cmp()

int mpz_cmp ( const mpz_t z1,
const mpz_t z2 
)

Definition at line 958 of file mpz.c.

◆ mpz_deinit()

void mpz_deinit ( mpz_t z)

Definition at line 670 of file mpz.c.

◆ mpz_divmod_inpl()

void mpz_divmod_inpl ( mpz_t dest_quo,
mpz_t dest_rem,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1513 of file mpz.c.

◆ mpz_free()

STATIC void mpz_free ( mpz_t z)

Definition at line 712 of file mpz.c.

◆ mpz_hash()

mp_int_t mpz_hash ( const mpz_t z)

Definition at line 1561 of file mpz.c.

◆ mpz_init_fixed_from_int()

void mpz_init_fixed_from_int ( mpz_t z,
mpz_dig_t dig,
size_t  alloc,
mp_int_t  val 
)

Definition at line 661 of file mpz.c.

◆ mpz_init_from_int()

void mpz_init_from_int ( mpz_t z,
mp_int_t  val 
)

Definition at line 656 of file mpz.c.

◆ mpz_init_zero()

void mpz_init_zero ( mpz_t z)

Definition at line 648 of file mpz.c.

◆ mpz_mul_inpl()

void mpz_mul_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1326 of file mpz.c.

◆ mpz_need_dig()

STATIC void mpz_need_dig ( mpz_t z,
size_t  need 
)

Definition at line 719 of file mpz.c.

◆ mpz_neg_inpl()

void mpz_neg_inpl ( mpz_t dest,
const mpz_t z 
)

Definition at line 1086 of file mpz.c.

◆ mpz_not_inpl()

void mpz_not_inpl ( mpz_t dest,
const mpz_t z 
)

Definition at line 1096 of file mpz.c.

◆ mpz_or_inpl()

void mpz_or_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1254 of file mpz.c.

◆ mpz_pow3_inpl()

void mpz_pow3_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs,
const mpz_t mod 
)

Definition at line 1392 of file mpz.c.

◆ mpz_pow_inpl()

void mpz_pow_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1358 of file mpz.c.

◆ mpz_set()

void mpz_set ( mpz_t dest,
const mpz_t src 
)

Definition at line 751 of file mpz.c.

◆ mpz_set_from_bytes()

void mpz_set_from_bytes ( mpz_t z,
bool  big_endian,
size_t  len,
const byte buf 
)

Definition at line 909 of file mpz.c.

◆ mpz_set_from_int()

void mpz_set_from_int ( mpz_t z,
mp_int_t  val 
)

Definition at line 758 of file mpz.c.

◆ mpz_set_from_ll()

void mpz_set_from_ll ( mpz_t z,
long long  val,
bool  is_signed 
)

Definition at line 782 of file mpz.c.

◆ mpz_set_from_str()

size_t mpz_set_from_str ( mpz_t z,
const char *  str,
size_t  len,
bool  neg,
unsigned int  base 
)

Definition at line 873 of file mpz.c.

◆ mpz_shl_inpl()

void mpz_shl_inpl ( mpz_t dest,
const mpz_t lhs,
mp_uint_t  rhs 
)

Definition at line 1120 of file mpz.c.

◆ mpz_shr_inpl()

void mpz_shr_inpl ( mpz_t dest,
const mpz_t lhs,
mp_uint_t  rhs 
)

Definition at line 1133 of file mpz.c.

◆ mpz_sub_inpl()

void mpz_sub_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1192 of file mpz.c.

◆ mpz_xor_inpl()

void mpz_xor_inpl ( mpz_t dest,
const mpz_t lhs,
const mpz_t rhs 
)

Definition at line 1288 of file mpz.c.