OpenScop  0.9.0
Data Structures | Typedefs | Functions
int.h File Reference

Go to the source code of this file.

Data Structures

union  osl_int
 

Typedefs

typedef union osl_int osl_int_t
 
typedef union osl_intosl_int_p
 
typedef union osl_int const osl_const_int_t
 
typedef union osl_int *const osl_int_const_p
 
typedef union osl_int const * osl_const_int_p
 
typedef union osl_int const *const osl_const_int_const_p
 

Functions

int osl_int_is_precision_supported (int)
 
void osl_int_dump_precision (FILE *, int)
 
void osl_int_init (int, osl_int_const_p)
 Initialize the osl int. More...
 
osl_int_p osl_int_malloc (int)
 Initialize the osl int. More...
 
void osl_int_assign (int, osl_int_const_p, osl_const_int_t)
 variable = value More...
 
void osl_int_set_si (int, osl_int_const_p, int)
 variable = i More...
 
int osl_int_get_si (int, osl_const_int_t)
 Get the value in a int. More...
 
double osl_int_get_d (int, osl_const_int_t)
 Get the value in a double. More...
 
void osl_int_init_set (int, osl_int_const_p, osl_const_int_t)
 variable = i // including initialization for GMP More...
 
void osl_int_init_set_si (int, osl_int_const_p, int)
 variable = i // including initialization for GMP More...
 
void osl_int_swap (int, osl_int_const_p, osl_int_const_p)
 Swap the osl ints. More...
 
void osl_int_clear (int, osl_int_const_p)
 variable = 0 // including cleaning for GMP More...
 
void osl_int_free (int, osl_int_const_p)
 Free thr osl int. More...
 
void osl_int_print (FILE *, int, osl_const_int_t)
 
void osl_int_sprint (char *, int, osl_const_int_t)
 
void osl_int_sprint_txt (char *, int, osl_const_int_t)
 
int osl_int_sscanf (char *, int, osl_int_const_p)
 sscanf for osl int More...
 
void osl_int_sread (char **, int, osl_int_const_p)
 sread for osl int More...
 
void osl_int_increment (int, osl_int_const_p, osl_const_int_t)
 variable = value + 1 More...
 
void osl_int_decrement (int, osl_int_const_p, osl_const_int_t)
 variable = value - 1 More...
 
void osl_int_add (int, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 variable = val1 + val2 More...
 
void osl_int_add_si (int, osl_int_const_p, osl_const_int_t, int)
 variable = val1 + i More...
 
void osl_int_sub (int, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 variable = val1 - val2 More...
 
void osl_int_mul (int, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 variable = val1 * val2 More...
 
void osl_int_mul_si (int, osl_int_const_p, osl_const_int_t, int)
 variable = val1 * i More...
 
void osl_int_div_exact (int const, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 q = a / b More...
 
void osl_int_floor_div_q (int const, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 q = floor(a / b) More...
 
void osl_int_floor_div_r (int const, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 r = a - b * (a / b) More...
 
void osl_int_floor_div_q_r (int const, osl_int_const_p, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 Compute (q, r) such that a = b * q + r. More...
 
void osl_int_mod (int const, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 mod = a % b More...
 
void osl_int_gcd (int const, osl_int_const_p, osl_const_int_t, osl_const_int_t)
 Compute the gcd (greatest common divisor) of a and b. More...
 
void osl_int_oppose (int, osl_int_const_p, osl_const_int_t)
 variable = - value More...
 
void osl_int_abs (int, osl_int_const_p, osl_const_int_t)
 variable = | value | More...
 
size_t osl_int_size_in_base_2 (int const, osl_const_int_t)
 Get the size in base 2. More...
 
size_t osl_int_size_in_base_10 (int const, osl_const_int_t)
 Get the size in base 10. More...
 
int osl_int_eq (int, osl_const_int_t, osl_const_int_t)
 val1 == val2 More...
 
int osl_int_ne (int, osl_const_int_t, osl_const_int_t)
 val1 != val2 More...
 
int osl_int_pos (int, osl_const_int_t)
 value > 0 More...
 
int osl_int_neg (int, osl_const_int_t)
 value < 0 More...
 
int osl_int_zero (int, osl_const_int_t)
 value == 0 More...
 
int osl_int_one (int, osl_const_int_t)
 value == 1 More...
 
int osl_int_mone (int, osl_const_int_t)
 value == -1 More...
 
int osl_int_divisible (int, osl_const_int_t, osl_const_int_t)
 (val1 % val2) == 0 More...
 
void osl_int_set_precision (int const, int const, osl_int_p)
 Change the precision of the osl_int. More...
 

Typedef Documentation

typedef union osl_int const* const osl_const_int_const_p

Definition at line 93 of file int.h.

typedef union osl_int const* osl_const_int_p

Definition at line 92 of file int.h.

typedef union osl_int const osl_const_int_t

Definition at line 90 of file int.h.

typedef union osl_int* const osl_int_const_p

Definition at line 91 of file int.h.

typedef union osl_int* osl_int_p

Definition at line 89 of file int.h.

typedef union osl_int osl_int_t

Definition at line 88 of file int.h.

Function Documentation

void osl_int_abs ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  value 
)

variable = | value |

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to get the absolute value
[in]valueValue in a osl int

Definition at line 1010 of file int.c.

void osl_int_add ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  val1,
osl_const_int_t  val2 
)

variable = val1 + val2

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to save the result
[in]val1Value of first osl int
[in]val2Value of second osl int

Definition at line 581 of file int.c.

References osl_int_neg(), and osl_int_pos().

Referenced by osl_int_sub(), osl_relation_add_vector(), and osl_vector_add().

void osl_int_add_si ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  value,
int  i 
)

variable = val1 + i

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to save the result
[in]valueValue of first int in a osl int
[in]iValue of second int in a int

Definition at line 631 of file int.c.

References osl_int_neg(), and osl_int_pos().

Referenced by osl_int_decrement(), osl_int_increment(), and osl_vector_add_scalar().

void osl_int_assign ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  value 
)
void osl_int_clear ( int  precision,
osl_int_const_p  variable 
)

variable = 0 // including cleaning for GMP

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to clear

Definition at line 382 of file int.c.

Referenced by osl_int_free(), osl_int_set_precision(), osl_relation_free_inside(), and osl_vector_free().

void osl_int_decrement ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  value 
)

variable = value - 1

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to save the result
[in]valueValue in a osl int

Definition at line 568 of file int.c.

References osl_int_add_si().

void osl_int_div_exact ( int const  precision,
osl_int_const_p  q,
osl_const_int_t  a,
osl_const_int_t  b 
)

q = a / b

Precondition
b divides a (without remainder)
Parameters
[in]precisionPrecision of the osl int
[in]qQuotient in a osl int
[in]aValue of first osl int
[in]bValue of second osl int

Definition at line 797 of file int.c.

int osl_int_divisible ( int  precision,
osl_const_int_t  val1,
osl_const_int_t  val2 
)

(val1 % val2) == 0

Parameters
[in]precisionPrecision of the osl int
[in]val1Value of first osl int
[in]val2Value of second osl int
Returns
1 if val2 divises val1 without remainder, false otherwise

Definition at line 1275 of file int.c.

Referenced by osl_relation_get_array_id().

void osl_int_dump_precision ( FILE *  file,
int  precision 
)

osl_int_dump_precision function: this function prints in a human readable fashion the precision corresponding to the "precision" parameter.

Parameters
[in]fileThe file where to print the precision.
[in]precisionThe precision to print.

Definition at line 113 of file int.c.

Referenced by osl_relation_idump(), and osl_vector_idump().

int osl_int_eq ( int  precision,
osl_const_int_t  val1,
osl_const_int_t  val2 
)

val1 == val2

Parameters
[in]precisionPrecision of the osl int
[in]val1Value of first osl int
[in]val2Value of second osl int
Returns
1 if values are equal, false otherwise

Definition at line 1112 of file int.c.

Referenced by osl_int_ne().

void osl_int_floor_div_q ( int const  precision,
osl_int_const_p  q,
osl_const_int_t  a,
osl_const_int_t  b 
)

q = floor(a / b)

Parameters
[in]precisionPrecision of the osl int
[in]qQuotient in a osl int
[in]aValue of first osl int
[in]bValue of second osl int

Definition at line 821 of file int.c.

References osl_int_neg(), and osl_int_pos().

Referenced by osl_int_floor_div_q_r(), and osl_int_floor_div_r().

void osl_int_floor_div_q_r ( int const  precision,
osl_int_const_p  q,
osl_int_const_p  r,
osl_const_int_t  a,
osl_const_int_t  b 
)

Compute (q, r) such that a = b * q + r.

Parameters
[in]precisionPrecision of the osl int
[in]qQuotient in a osl int
[in]rRemainder in a osl int
[in]aValue of first osl int
[in]bValue of second osl int

Definition at line 894 of file int.c.

References osl_int_floor_div_q().

void osl_int_floor_div_r ( int const  precision,
osl_int_const_p  r,
osl_const_int_t  a,
osl_const_int_t  b 
)

r = a - b * (a / b)

Parameters
[in]precisionPrecision of the osl int
[in]rRemainder in a osl int
[in]aValue of first osl int
[in]bValue of second osl int

Definition at line 863 of file int.c.

References osl_int_floor_div_q().

void osl_int_free ( int  precision,
osl_int_const_p  variable 
)

Free thr osl int.

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to free

Definition at line 410 of file int.c.

References osl_int_clear().

void osl_int_gcd ( int const  precision,
osl_int_const_p  gcd,
osl_const_int_t  a,
osl_const_int_t  b 
)

Compute the gcd (greatest common divisor) of a and b.

Parameters
[in]precisionPrecision of the osl int
[in]gcdGreatest common divisor in a osl int
[in]aValue of first osl int
[in]bValue of second osl int

Definition at line 959 of file int.c.

References llgcd().

double osl_int_get_d ( int  precision,
osl_const_int_t  i 
)

Get the value in a double.

Parameters
[in]precisionPrecision of the osl int
[in]iValue in a osl int
Returns
the value in a double

Definition at line 277 of file int.c.

int osl_int_get_si ( int  precision,
osl_const_int_t  value 
)

Get the value in a int.

Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
the value in a int

Definition at line 236 of file int.c.

Referenced by osl_int_set_precision(), osl_relation_add_vector(), osl_relation_get_array_id(), and osl_relation_sub_vector().

void osl_int_increment ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  value 
)

variable = value + 1

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to save the result
[in]valueValue in a osl int

Definition at line 556 of file int.c.

References osl_int_add_si().

void osl_int_init ( int  precision,
osl_int_const_p  variable 
)

Initialize the osl int.

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to initialize

Definition at line 137 of file int.c.

Referenced by osl_int_init_set(), osl_int_malloc(), and osl_int_sub().

void osl_int_init_set ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  i 
)

variable = i // including initialization for GMP

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to initialize
[in]iValue in a osl int

Definition at line 302 of file int.c.

References osl_int_assign(), and osl_int_init().

void osl_int_init_set_si ( int  precision,
osl_int_const_p  variable,
int  i 
)

variable = i // including initialization for GMP

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to initialize
[in]iValue in a osl int

Definition at line 314 of file int.c.

Referenced by osl_int_set_precision(), osl_relation_pmalloc(), and osl_vector_pmalloc().

int osl_int_is_precision_supported ( int  precision)

osl_int_is_precision_supported function: this function returns 1 if the precision provided as parameter is supported by the library and 0 otherwise. Possible values for the precision parameter are OSL_PRECISION_SP for 32 bits (single) precision, OSL_PRECISION_DP for 64 bits (double) precision and OSL_PRECISION_MP for multiple precision.

Parameters
[in]precisionThe precision to check for.
Returns
1 if the precision is supported, 0 otherwise.

Definition at line 90 of file int.c.

osl_int_p osl_int_malloc ( int  precision)

Initialize the osl int.

Parameters
[in]precisionPrecision of the osl int

Definition at line 164 of file int.c.

References osl_int_init().

void osl_int_mod ( int const  precision,
osl_int_const_p  mod,
osl_const_int_t  a,
osl_const_int_t  b 
)

mod = a % b

Precondition
mod is always positive
Parameters
[in]precisionPrecision of the osl int
[in]modModulo in a osl int
[in]aValue of first osl int
[in]bValue of second osl int

Definition at line 925 of file int.c.

int osl_int_mone ( int  precision,
osl_const_int_t  value 
)

value == -1

Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
1 if value equal to -1, false otherwise

Definition at line 1249 of file int.c.

Referenced by osl_relation_expression_element(), osl_relation_is_simple_output(), and osl_scop_check_compatible_scoplib().

void osl_int_mul ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  val1,
osl_const_int_t  val2 
)

variable = val1 * val2

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to save the result
[in]val1Value of first osl int
[in]val2Value of second osl int

Definition at line 708 of file int.c.

References osl_int_zero().

void osl_int_mul_si ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  value,
int  i 
)

variable = val1 * i

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to save the result
[in]valueValue of first int in a osl int
[in]iValue of second int in a int

Definition at line 752 of file int.c.

References osl_int_zero().

Referenced by osl_vector_mul_scalar().

int osl_int_ne ( int  precision,
osl_const_int_t  val1,
osl_const_int_t  val2 
)

val1 != val2

Parameters
[in]precisionPrecision of the osl int
[in]val1Value of first osl int
[in]val2Value of second osl int
Returns
1 if values are not equal, false otherwise

Definition at line 1138 of file int.c.

References osl_int_eq().

Referenced by osl_relation_part_equal(), and osl_vector_equal().

int osl_int_neg ( int  precision,
osl_const_int_t  value 
)

value < 0

Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
1 if value < 0, false otherwise

Definition at line 1174 of file int.c.

Referenced by osl_int_add(), osl_int_add_si(), osl_int_floor_div_q(), and osl_relation_expression_element().

int osl_int_one ( int  precision,
osl_const_int_t  value 
)

value == 1

Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
1 if value equal to 1, false otherwise

Definition at line 1224 of file int.c.

Referenced by osl_relation_expression_element(), osl_relation_integrity_check(), and osl_relation_is_simple_output().

void osl_int_oppose ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  value 
)

variable = - value

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to get the oppose
[in]valueValue in a osl int

Definition at line 981 of file int.c.

Referenced by osl_int_sub(), and osl_relation_subexpression().

int osl_int_pos ( int  precision,
osl_const_int_t  value 
)

value > 0

Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
1 if value is > 0, false otherwise

Definition at line 1149 of file int.c.

Referenced by osl_int_add(), osl_int_add_si(), osl_int_floor_div_q(), and osl_relation_expression_element().

void osl_int_print ( FILE *  file,
int  precision,
osl_const_int_t  value 
)

osl_int_print function: this function displays an integer value into a file (file, possibly stdout).

Parameters
fileThe file where the integer has to be printed.
precisionThe precision of the integer.
valueThe integer element to print.

Definition at line 423 of file int.c.

References osl_int_sprint().

Referenced by osl_relation_idump(), and osl_vector_idump().

void osl_int_set_precision ( int const  precision,
int const  new_precision,
osl_int_p  i 
)

Change the precision of the osl_int.

Parameters
[in]precisionPrecision of the osl int
[in]new_precisionPrecision wanted for the osl int
[in,out]iA osl int to change the precision

Definition at line 1306 of file int.c.

References osl_int_clear(), osl_int_get_si(), and osl_int_init_set_si().

Referenced by osl_relation_set_precision().

void osl_int_set_si ( int  precision,
osl_int_const_p  variable,
int  i 
)

variable = i

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to assign
[in]iValue in a int

Definition at line 208 of file int.c.

Referenced by osl_relation_extend_output(), osl_vector_tag_equality(), and osl_vector_tag_inequality().

size_t osl_int_size_in_base_10 ( int const  precision,
osl_const_int_t const  value 
)

Get the size in base 10.

Warning
warning mpz_sizeinbase may not return the same result with same integer in different precisions
Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
the size in base 10

Definition at line 1084 of file int.c.

References lllog10().

size_t osl_int_size_in_base_2 ( int const  precision,
osl_const_int_t const  value 
)

Get the size in base 2.

Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
the size in base 2

Definition at line 1050 of file int.c.

References lllog2().

void osl_int_sprint ( char *  string,
int  precision,
osl_const_int_t  value 
)

osl_int_sprint function: this function prints an integer value into a string, it uses the OpenScop Library formats OSL_FMT_* to format the printing.

Parameters
stringThe string where the integer has to be printed.
precisionThe precision of the integer.
valueThe integer element to print.

Definition at line 439 of file int.c.

Referenced by osl_int_print(), osl_relation_spprint_polylib(), and osl_relation_spprint_polylib_scoplib().

void osl_int_sprint_txt ( char *  string,
int  precision,
osl_const_int_t  value 
)

osl_int_sprint_txt function: this function is similar to osl_int_sprintf but it prints the value using OSL_TMT_TXT_* formats.

See Also
osl_int_sprintf

Definition at line 471 of file int.c.

Referenced by osl_relation_expression_element().

void osl_int_sread ( char **  string,
int  precision,
osl_int_const_p  i 
)

sread for osl int

Parameters
[in]stringInteger in a char**
[in]precisionPrecision of the osl int
[in]iA osl int to save integer

Definition at line 539 of file int.c.

References osl_int_sscanf().

Referenced by osl_relation_pread(), and osl_relation_psread_polylib().

int osl_int_sscanf ( char *  string,
int  precision,
osl_int_const_p  i 
)

sscanf for osl int

Parameters
[in]stringInteger in a char*
[in]precisionPrecision of the osl int
[in]iA osl int to save integer
Returns
the number of char readed

Definition at line 504 of file int.c.

Referenced by osl_int_sread().

void osl_int_sub ( int  precision,
osl_int_const_p  variable,
osl_const_int_t  val1,
osl_const_int_t  val2 
)

variable = val1 - val2

Parameters
[in]precisionPrecision of the osl int
[in]variableA osl int to save the result
[in]val1Value of first osl int
[in]val2Value of second osl int

Definition at line 685 of file int.c.

References osl_int_add(), osl_int_init(), and osl_int_oppose().

Referenced by osl_relation_sub_vector(), and osl_vector_sub().

void osl_int_swap ( int  precision,
osl_int_const_p  var1,
osl_int_const_p  var2 
)

Swap the osl ints.

Parameters
[in]precisionPrecision of the osl ints
[in]var1First osl int to swap
[in]var2Second osl int to swap

Definition at line 343 of file int.c.

Referenced by osl_relation_swap_constraints().

int osl_int_zero ( int  precision,
osl_const_int_t  value 
)

value == 0

Parameters
[in]precisionPrecision of the osl int
[in]valueValue in a osl int
Returns
1 if value equal to 0, false otherwise

Definition at line 1199 of file int.c.

Referenced by osl_int_mul(), osl_int_mul_si(), osl_relation_expression_element(), osl_relation_get_array_id(), osl_relation_integrity_check(), osl_relation_is_simple_output(), osl_relation_sprint_comment(), osl_scop_check_compatible_scoplib(), and osl_vector_is_scalar().