gmp :: NativeMPZ :: defaultinit
gmp :: NativeMPZ :: probab_prime_p
core :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Pointer :: defaultinit
gmp :: NativeMPZ :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).gmp :: NativeMPZ :: probab_prime_p
# Multi precision Integer
extern class NativeMPZ `{mpz_ptr`}
# Initializing
new `{
mpz_ptr self = (mpz_ptr)malloc(sizeof(mpz_t));
mpz_init(self);
return self;
`}
# Arithmetic Functions
fun add(res, op: NativeMPZ) `{
mpz_add(res, self, op);
`}
fun add_ui(res: NativeMPZ, op: UInt64) `{
mpz_add_ui(res, self, *op);
`}
fun sub(res, op: NativeMPZ) `{
mpz_sub(res, self, op);
`}
fun sub_ui(res: NativeMPZ, op: UInt64) `{
mpz_sub_ui(res, self, *op);
`}
fun mul(res, op: NativeMPZ) `{
mpz_mul(res, self, op);
`}
fun mul_si(res: NativeMPZ, op: Int) `{
mpz_mul_si(res, self, op);
`}
fun neg(res: NativeMPZ) `{
mpz_neg(res, self);
`}
fun abs(res: NativeMPZ) `{
mpz_abs(res, self);
`}
fun tdiv_q(res, op: NativeMPZ) `{
mpz_tdiv_q(res, self, op);
`}
fun tdiv_q_ui(res: NativeMPZ, op: UInt64) `{
mpz_tdiv_q_ui(res, self, *op);
`}
fun mod(res, op: NativeMPZ) `{
mpz_mod(res, self, op);
`}
fun mod_ui(res: NativeMPZ, op: UInt64) `{
mpz_mod_ui(res, self, *op);
`}
fun pow_ui(res: NativeMPZ, op: UInt64) `{
mpz_pow_ui(res, self, *op);
`}
#Number Theoretic Functions
fun probab_prime_p(reps: Int32): Int `{
return mpz_probab_prime_p(self, reps);
`}
fun nextprime(res: NativeMPZ) `{
mpz_nextprime(res, self);
`}
fun gcd(res, op: NativeMPZ) `{
mpz_gcd(res, self, op);
`}
fun gcd_ui(res: NativeMPZ, op: UInt64) `{
mpz_gcd_ui(res, self, *op);
`}
# Comparison Functions
fun cmp(op: NativeMPZ): Int `{
return mpz_cmp(self, op);
`}
fun cmp_si(op: Int): Int `{
return mpz_cmp_si(self, op);
`}
# Assignment
fun set(op: NativeMPZ) `{ mpz_set(self, op); `}
fun set_si(op: Int) `{ mpz_set_si(self, op); `}
fun set_d(op: Float) `{ mpz_set_d(self, op); `}
fun set_q(op: NativeMPQ) `{ mpz_set_q(self, op); `}
fun set_str(str: CString, base: Int32) `{
mpz_set_str(self, str, base);
`}
fun swap(op: NativeMPZ) `{ mpz_swap(self, op); `}
# Conversion Functions
fun get_si: Int `{ return mpz_get_si(self); `}
fun get_d: Float `{ return mpz_get_d(self); `}
fun get_str(base: Int32): CString `{
return mpz_get_str(NULL, base, self);
`}
# Delete this NativeMPZ
fun finalize `{
mpz_clear(self);
free(self);
`}
end
lib/gmp/native_gmp.nit:22,1--146,3