[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

Module pkint

This module is defined by the file `polka_num.h', included from `polka.h'. It defines generic operations on integers. The naming scheme and the semantics of these operations comes from the GMP library. They assume in particular that all integer objects are initialized before being used.

datatype: pkint_t
 
typedef struct pkint_t {
  ACTUALTYPE rep;
} pkint_t;
The generic type of coefficients in vectors and matrices. The actual type is defined by the configure command.

Function: void pkint_init (pkint_t integer)
Initialize integer and set its value to 0.
Function: void pkint_clear (pkint_t integer)
Free the space possibly used by integer. Make sure to call this function for all pkint_t variables when you are done with them.

Function: void pkint_set (pkint_t rop, pkint_t op)
Function: void pkint_set_ui (pkint_t rop, unsigned int op)
Function: void pkint_set_si (pkint_t rop, signed int op)
Set the value of rop from op.

Function: void pkint_init_set (pkint_t rop, pkint_t op)
Function: void pkint_init_set_ui (pkint_t rop, unsigned int op)
Function: void pkint_init_set_si (pkint_t rop, signed int op)
Initialize rop and set its value from op.

Function: void pkint_add (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to op1 + op2.
Function: void pkint_sub (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to op1 - op2.
Function: void pkint_neg (pkint_t rop, pkint_t op)
Set rop to -op.
Function: void pkint_mul (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to op1 * op2.
Function: void pkint_addmul (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to rop + op1 * op2.
Function: void pkint_submul (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to rop - op1 * op2.
Function: void pkint_div (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to op1 / op2.
Function: void pkint_mod (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to op1 modulo op2.
Function: void pkint_abs (pkint_t rop, pkint_t op)
Set rop to the absolute value of op.
Function: int pkint_sgn (pkint_t integer)
Return the sign of integer: 0 if null, > 0 if positive, < 0 if negative.

Function: void pkint_gcd (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to Greatest Common Divisor of op1 and op2.
Function: void pkint_divexact (pkint_t rop, pkint_t op1, pkint_t op2)
Set rop to op1 / op2, assuming that op2 is a divisor of op1.

Function: int pkint_cmp (pkint_t op1, pkint_t op2)
Function: int pkint_cmp_ui (pkint_t op1, unsigned long int op2)
Function: int pkint_cmp_si (pkint_t op1, signed long int op2)
Compare op1 and op2. Return a positive value if op1 > op2, zero if op1 = op2, and a negative value if op1 < op2.

Function: unsigned long int pkint_get_ui (pkint_t integer)
Return the least significant part from integer.

Function: signed long int pkint_get_si (pkint_t integer)
If integer fits into a signed long int return the value of integer. Otherwise return the least significant part of integer, with the same sign as integer.

If integer is too large to fit in a signed long int, the returned result is probably not very useful. To find out if the value will fit, use the function pkint_fits_slong_p.

Function: void pkint_set_str10 (pkint_t integer, char* str)
Put in integer the string representation in base 10 str of an integer. Behavior unspecified if str is not a correct representation.

Function: void pkint_sizeinbase10 (pkint_t integer)
Return the size of integer measured in number of digits in base 10. The sign of integer is ignored. The result may be too big than the exact value.

This function is useful in order to allocate the right amount of space before converting OP to a string. The right amount of allocation is normally two more than the value returned by pkint_sizeinbase10.

Function: void pkint_get_str10 (char* str, pkint_t integer)
Convert integer to a string of digits in base 10.

If str is NULL, the result string is allocated using malloc. The block will be strlen(str)+1 bytes, that being exactly enough for the string and null-terminator.

If str is not NULL, it should point to a block of storage large enough for the result, that being pkint_sizeinbase10(integer) + 2. The two extra bytes are for a possible minus sign, and the null-terminator.

A pointer to the result string is returned, being either the allocated block, or the given str.

Function: void pkint_print (pkint_t integer)
Prints integer on the standard output.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on October, 27 2006 using texi2html