#include <stdio.h>#include <limits.h>#include "boolean.h"#include "arithmetic_errors.h"Go to the source code of this file.
Data Structures | |
| struct | frac |
| struct | col |
Defines | |
| #define | LINEAR_VALUE_STRING "int" |
| # #### # # #### # #### # # #### # # # ## # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # ### # # # # # # # ### # # # # ## # # # # # # ## # # ###### #### # # #### ###### #### # # #### | |
| #define | VALUE_FMT "%d" |
| #define | VALUE_CONST(val) (val) |
| #define | VALUE_NAN INT_MIN |
| #define | VALUE_MIN (INT_MIN+1) |
| #define | VALUE_MAX INT_MAX |
| #define | VALUE_ZERO 0 |
| #define | VALUE_ONE 1 |
| #define | VALUE_MONE -1 |
| #define | VALUE_TO_LONG(val) ((long)(val)) |
| #define | VALUE_TO_INT(val) ((int)(val)) |
| #define | VALUE_TO_FLOAT(val) ((float)(val)) |
| #define | VALUE_TO_DOUBLE(val) ((double)(val)) |
| #define | int_to_value(i) ((Value)(i)) |
| end LINEAR_VALUE_IS_INT | |
| #define | long_to_value(l) ((Value)(l)) |
| #define | float_to_value(f) ((Value)(f)) |
| #define | double_to_value(d) ((Value)(d)) |
| #define | value_eq(v1, v2) ((v1)==(v2)) |
| boolean operators on values | |
| #define | value_ne(v1, v2) ((v1)!=(v2)) |
| #define | value_gt(v1, v2) ((v1)>(v2)) |
| #define | value_ge(v1, v2) ((v1)>=(v2)) |
| #define | value_lt(v1, v2) ((v1)<(v2)) |
| #define | value_le(v1, v2) ((v1)<=(v2)) |
| #define | value_sign(v) (value_eq(v,VALUE_ZERO)?0:value_lt(v,VALUE_ZERO)?-1:1) |
| trian operators on values | |
| #define | value_compare(v1, v2) (value_eq(v1,v2)?0:value_lt(v1,v2)?-1:1) |
| #define | value_plus(v1, v2) ((v1)+(v2)) |
| binary operators on values | |
| #define | value_div(v1, v2) ((v1)/(v2)) |
| #define | value_mod(v1, v2) ((v1)%(v2)) |
| #define | value_direct_multiply(v1, v2) ((v1)*(v2)) |
| #define | value_minus(v1, v2) ((v1)-(v2)) |
| #define | value_pdiv(v1, v2) (divide(v1,v2)) |
| #define | value_pmod(v1, v2) (modulo(v1,v2)) |
| #define | value_min(v1, v2) (value_le(v1,v2)? (v1): (v2)) |
| #define | value_max(v1, v2) (value_ge(v1,v2)? (v1): (v2)) |
| #define | value_or(v1, v2) ((v1)|(v2)) |
| #define | value_and(v1, v2) ((v1)&(v2)) |
| #define | value_lshift(v1, v2) ((v1)<<(v2)) |
| #define | value_rshift(v1, v2) ((v1)>>(v2)) |
| #define | value_assign(ref, val) (ref=(val)) |
| assigments | |
| #define | value_addto(ref, val) (ref+=(val)) |
| #define | value_increment(ref) (ref++) |
| #define | value_direct_product(ref, val) (ref*=(val)) |
| #define | value_multiply(ref, val) value_assign(ref,value_mult(ref,val)) |
| #define | value_substract(ref, val) (ref-=(val)) |
| #define | value_decrement(ref) (ref--) |
| #define | value_division(ref, val) (ref/=(val)) |
| #define | value_modulus(ref, val) (ref%=(val)) |
| #define | value_pdivision(ref, val) value_assign(ref,value_pdiv(ref,val)) |
| #define | value_oppose(ref) value_assign(ref,value_uminus(ref)) |
| #define | value_absolute(ref) value_assign(ref,value_abs(ref)) |
| #define | value_minimum(ref, val) value_assign(ref,value_min(ref,val)) |
| #define | value_maximum(ref, val) value_assign(ref,value_max(ref,val)) |
| #define | value_orto(ref, val) (ref |= (val)) |
| #define | value_andto(ref, val) (ref &= (val)) |
| #define | value_uminus(val) (-(val)) |
| unary operators on values | |
| #define | value_not(val) (~(val)) |
| #define | value_abs(val) |
| #define | value_pos_p(val) value_gt(val,VALUE_ZERO) |
| #define | value_neg_p(val) value_lt(val,VALUE_ZERO) |
| #define | value_posz_p(val) value_ge(val,VALUE_ZERO) |
| #define | value_negz_p(val) value_le(val,VALUE_ZERO) |
| #define | value_zero_p(val) value_eq(val,VALUE_ZERO) |
| #define | value_notzero_p(val) value_ne(val,VALUE_ZERO) |
| #define | value_one_p(val) value_eq(val,VALUE_ONE) |
| #define | value_notone_p(val) value_ne(val,VALUE_ONE) |
| #define | value_mone_p(val) value_eq(val,VALUE_MONE) |
| #define | value_notmone_p(val) value_ne(val,VALUE_MONE) |
| #define | value_min_p(val) value_eq(val,VALUE_MIN) |
| #define | value_max_p(val) value_eq(val,VALUE_MAX) |
| #define | value_notmin_p(val) value_ne(val,VALUE_MIN) |
| #define | value_notmax_p(val) value_ne(val,VALUE_MAX) |
| #define | value_protected_hard_idiv_multiply(v, w, throw) |
| (|v| < MAX / |w|) => v*w is okay I could check ((v*w)/w)==v but a tmp would be useful | |
| #define | value_protected_multiply(v, w, throw) value_protected_hard_idiv_multiply(v,w,throw) |
| is a software idiv is assumed, quick check performed first | |
| #define | value_protected_mult(v, w) value_protected_multiply(v,w,THROW(overflow_error)) |
| protected versions | |
| #define | value_protected_product(v, w) v=value_protected_mult(v,w) |
| #define | value_mult(v, w) |
| whether the default is protected or not this define makes no sense any more. | |
| #define | value_product(v, w) v=value_mult(v,w) |
| #define | SIGN(x) (((x)>0)? 1 : ((x)==0? 0 : -1)) |
| was: define value_mult(v,w) value_direct_multiply(v,w) define value_product(v,w) value_direct_product(v,w) could be: protected versions. | |
| #define | DIVIDE(x, y) |
| division avec reste toujours positif basee sur les equations: a/(-b) = - (a/b) (-a)/b = - ((a+b-1)/b) ou a et b sont des entiers positifs | |
| #define | POSITIVE_DIVIDE(x, y) ((x)>0 ? (x)/(y) : - (-(x)+(y)-1)/(y)) |
| division avec reste toujours positif quand y est positif: assert(y>=0) | |
| #define | MODULO(x, y) ((y)>0 ? POSITIVE_MODULO(x,y) : POSITIVE_MODULO(-x,-y)) |
| modulo a resultat toujours positif | |
| #define | POSITIVE_MODULO(x, y) |
| modulo par rapport a un nombre positif: assert(y>=0) | |
| #define | pgcd(a, b) pgcd_slow(a,b) |
| Pour la recherche de performance, selection d'une implementation particuliere des fonctions. | |
| #define | divide(a, b) DIVIDE(a,b) |
| #define | modulo(a, b) MODULO(a,b) |
Typedefs | |
| typedef int | Value |
| typedef struct col | tableau |
Enumerations | |
| enum | linear_exception_t { overflow_error = 1, simplex_arithmetic_error = 2, user_exception_error = 4, parser_exception_error = 8, timeout_error = 16, any_exception_error = ~0, overflow_error = 1, simplex_arithmetic_error = 2, user_exception_error = 4, parser_exception_error = 8, timeout_error = 16, any_exception_error = ~0 } |
Warning! Do not modify this file that is automatically generated! More... | |
Functions | |
| Value | abs_ofl_ctrl (Value, int) |
| end of arithmetique-local.h | |
| Value | absval_ofl (Value) |
| int absval_ofl(int i): absolute value of i (SUN version) | |
| Value | absval (Value) |
| int absval(int i): absolute value of i (SUN version) | |
| Value | divide_fast (Value, Value) |
| divide.c | |
| Value | divide_slow (Value, Value) |
| Value | exponentiate (Value, int) |
| exp.c | |
| Value | modulo_fast (Value, Value) |
| modulo.c | |
| Value | pgcd_slow (Value, Value) |
| pgcd.c | |
| Value | pgcd_fast (Value, Value) |
| int pgcd_fast(int a, int b): calcul iteratif du pgcd de deux entiers; le pgcd retourne est toujours positif; il n'est pas defini si a et b sont nuls (abort); | |
| Value | pgcd_interne (Value, Value) |
| int pgcd_interne(int a, int b): calcul iteratif du pgcd de deux entiers strictement positifs tels que a > b; le pgcd retourne est toujours positif; | |
| Value | gcd_subtract (Value, Value) |
| int gcd_subtract(int a, int b): find the gcd (pgcd) of two integers | |
| Value | vecteur_bezout (Value[], Value[], int) |
| int vecteur_bezout(int u[], int v[], int l): calcul du vecteur v qui verifie le theoreme de bezout pour le vecteur u; les vecteurs u et v sont de dimension l | |
| Value | bezout (Value, Value, Value *, Value *) |
| int bezout(int a, int b, int *x, int *y): calcule x et y, les deux nombres qui verifient le theoreme de Bezout pour a et b; le pgcd de a et b est retourne par valeur | |
| Value | bezout_grl (Value, Value, Value *, Value *) |
| int bezout_grl(int a, int b, int *x, int *y): calcule x et y, les deux entiers quelconcs qui verifient le theoreme de Bezout pour a et b; le pgcd de a et b est retourne par valeur | |
| Value | ppcm (Value, Value) |
| ppcm.c | |
| void | print_Value (Value) |
| io.c | |
| void | fprint_Value (FILE *, Value) |
| void | fprint_string_Value (FILE *, char *, Value) |
| void | sprint_Value (char *, Value) |
| int | fscan_Value (FILE *, Value *) |
| int | scan_Value (Value *) |
| int | sscan_Value (char *, Value *) |
| char * | Value_to_string (Value) |
| char const * | get_exception_name (const linear_exception_t) |
| errors.c | |
| void | set_exception_callbacks (exception_callback_t, exception_callback_t) |
| void | dump_exception_stack_to_file (FILE *) |
| void | dump_exception_stack (void) |
| jmp_buf * | push_exception_on_stack (const int, const char *, const char *, const int) |
| void | pop_exception_from_stack (const int, const char *, const char *, const int) |
| void | throw_exception (const int, const char *, const char *, const int) |
| void | linear_initialize_exception_stack (unsigned int, exception_callback_t, exception_callback_t) |
Variables | |
| linear_exception_t | the_last_just_thrown_exception |
| int | linear_number_of_exception_thrown |
Definition at line 514 of file arithmetique.h.
| #define DIVIDE | ( | x, | |||
| y | ) |
((y)>0? POSITIVE_DIVIDE(x,y) : \ -POSITIVE_DIVIDE((x),(-(y))))
division avec reste toujours positif basee sur les equations: a/(-b) = - (a/b) (-a)/b = - ((a+b-1)/b) ou a et b sont des entiers positifs
Definition at line 490 of file arithmetique.h.
| #define double_to_value | ( | d | ) | ((Value)(d)) |
Definition at line 263 of file arithmetique.h.
Definition at line 262 of file arithmetique.h.
| #define LINEAR_VALUE_STRING "int" |
# #### # # #### # #### # # #### # # # ## # # # # # # ## # # # # # # # # # # # # # # # # # # # # # # # # ### # # # # # # # ### # # # # ## # # # # # # ## # # ###### #### # # #### ###### #### # # ####
put there because I cannot have these constants with ansi options.default: LINEAR_VALUE_IS_INT
Definition at line 238 of file arithmetique.h.
| #define long_to_value | ( | l | ) | ((Value)(l)) |
Definition at line 261 of file arithmetique.h.
Definition at line 516 of file arithmetique.h.
modulo a resultat toujours positif
Definition at line 497 of file arithmetique.h.
Pour la recherche de performance, selection d'une implementation particuliere des fonctions.
Definition at line 512 of file arithmetique.h.
division avec reste toujours positif quand y est positif: assert(y>=0)
Definition at line 494 of file arithmetique.h.
| #define POSITIVE_MODULO | ( | x, | |||
| y | ) |
modulo par rapport a un nombre positif: assert(y>=0)
Ce n'est pas la macro la plus efficace que j'aie jamais ecrite: il faut faire, dans le pire des cas, deux appels a la routine .rem, qui n'est surement pas plus cablee que la division ou la multiplication
Definition at line 505 of file arithmetique.h.
was: define value_mult(v,w) value_direct_multiply(v,w) define value_product(v,w) value_direct_product(v,w) could be: protected versions.
..LINEAR_VALUE_IS_CHARS is used for type checking. some operations are not allowed on (char*), thus they are switched to some other operation here...valeur absolueminimum et maximum if they are defined somewhere else, they are very likely to be defined the same way. Thus the previous def is not overwritten.signe d'un entier: -1, 0 ou 1
Definition at line 482 of file arithmetique.h.
| #define value_abs | ( | val | ) |
(value_posz_p(val)? \ (val) : \ (value_ne((val), VALUE_NAN) ? \ value_uminus(val) : \ (THROW (overflow_error), VALUE_NAN )))
Definition at line 318 of file arithmetique.h.
Definition at line 308 of file arithmetique.h.
Definition at line 298 of file arithmetique.h.
| #define value_and | ( | v1, | |||
| v2 | ) | ((v1)&(v2)) |
Definition at line 291 of file arithmetique.h.
Definition at line 312 of file arithmetique.h.
assigments
Definition at line 297 of file arithmetique.h.
| #define value_compare | ( | v1, | |||
| v2 | ) | (value_eq(v1,v2)?0:value_lt(v1,v2)?-1:1) |
Definition at line 277 of file arithmetique.h.
| #define VALUE_CONST | ( | val | ) | (val) |
Definition at line 241 of file arithmetique.h.
Definition at line 303 of file arithmetique.h.
| #define value_direct_multiply | ( | v1, | |||
| v2 | ) | ((v1)*(v2)) |
Definition at line 284 of file arithmetique.h.
Definition at line 300 of file arithmetique.h.
| #define value_div | ( | v1, | |||
| v2 | ) | ((v1)/(v2)) |
Definition at line 282 of file arithmetique.h.
Definition at line 304 of file arithmetique.h.
| #define value_eq | ( | v1, | |||
| v2 | ) | ((v1)==(v2)) |
boolean operators on values
Definition at line 267 of file arithmetique.h.
| #define VALUE_FMT "%d" |
Definition at line 240 of file arithmetique.h.
| #define value_ge | ( | v1, | |||
| v2 | ) | ((v1)>=(v2)) |
Definition at line 270 of file arithmetique.h.
| #define value_gt | ( | v1, | |||
| v2 | ) | ((v1)>(v2)) |
Definition at line 269 of file arithmetique.h.
Definition at line 299 of file arithmetique.h.
| #define value_le | ( | v1, | |||
| v2 | ) | ((v1)<=(v2)) |
Definition at line 272 of file arithmetique.h.
| #define value_lshift | ( | v1, | |||
| v2 | ) | ((v1)<<(v2)) |
Definition at line 292 of file arithmetique.h.
| #define value_lt | ( | v1, | |||
| v2 | ) | ((v1)<(v2)) |
Definition at line 271 of file arithmetique.h.
| #define value_max | ( | v1, | |||
| v2 | ) | (value_ge(v1,v2)? (v1): (v2)) |
Definition at line 289 of file arithmetique.h.
| #define VALUE_MAX INT_MAX |
Definition at line 244 of file arithmetique.h.
| #define value_max_p | ( | val | ) | value_eq(val,VALUE_MAX) |
Definition at line 335 of file arithmetique.h.
Definition at line 310 of file arithmetique.h.
| #define value_min | ( | v1, | |||
| v2 | ) | (value_le(v1,v2)? (v1): (v2)) |
Definition at line 288 of file arithmetique.h.
| #define VALUE_MIN (INT_MIN+1) |
Definition at line 243 of file arithmetique.h.
| #define value_min_p | ( | val | ) | value_eq(val,VALUE_MIN) |
Definition at line 334 of file arithmetique.h.
Definition at line 309 of file arithmetique.h.
| #define value_minus | ( | v1, | |||
| v2 | ) | ((v1)-(v2)) |
Definition at line 285 of file arithmetique.h.
| #define value_mod | ( | v1, | |||
| v2 | ) | ((v1)%(v2)) |
Definition at line 283 of file arithmetique.h.
Definition at line 305 of file arithmetique.h.
| #define VALUE_MONE -1 |
Definition at line 247 of file arithmetique.h.
| #define value_mone_p | ( | val | ) | value_eq(val,VALUE_MONE) |
Definition at line 332 of file arithmetique.h.
| #define value_mult | ( | v, | |||
| w | ) |
value_protected_multiply(v,w, \ (fprintf(stderr,"[value_mult] value overflow!\n"),THROW(overflow_error)))
whether the default is protected or not this define makes no sense any more.
.. well, doesn't matter. FC.I do enforce the protection whatever requested:-) prints out a message and throws the exception, hoping that some valid CATCH waits for it upwards.
Definition at line 382 of file arithmetique.h.
Definition at line 301 of file arithmetique.h.
| #define VALUE_NAN INT_MIN |
Definition at line 242 of file arithmetique.h.
| #define value_ne | ( | v1, | |||
| v2 | ) | ((v1)!=(v2)) |
Definition at line 268 of file arithmetique.h.
| #define value_neg_p | ( | val | ) | value_lt(val,VALUE_ZERO) |
Definition at line 325 of file arithmetique.h.
| #define value_negz_p | ( | val | ) | value_le(val,VALUE_ZERO) |
Definition at line 327 of file arithmetique.h.
| #define value_not | ( | val | ) | (~(val)) |
Definition at line 317 of file arithmetique.h.
| #define value_notmax_p | ( | val | ) | value_ne(val,VALUE_MAX) |
Definition at line 337 of file arithmetique.h.
| #define value_notmin_p | ( | val | ) | value_ne(val,VALUE_MIN) |
Definition at line 336 of file arithmetique.h.
| #define value_notmone_p | ( | val | ) | value_ne(val,VALUE_MONE) |
Definition at line 333 of file arithmetique.h.
| #define value_notone_p | ( | val | ) | value_ne(val,VALUE_ONE) |
Definition at line 331 of file arithmetique.h.
| #define value_notzero_p | ( | val | ) | value_ne(val,VALUE_ZERO) |
Definition at line 329 of file arithmetique.h.
| #define VALUE_ONE 1 |
Definition at line 246 of file arithmetique.h.
| #define value_one_p | ( | val | ) | value_eq(val,VALUE_ONE) |
Definition at line 330 of file arithmetique.h.
Definition at line 307 of file arithmetique.h.
| #define value_or | ( | v1, | |||
| v2 | ) | ((v1)|(v2)) |
Definition at line 290 of file arithmetique.h.
Definition at line 311 of file arithmetique.h.
| #define value_pdiv | ( | v1, | |||
| v2 | ) | (divide(v1,v2)) |
Definition at line 286 of file arithmetique.h.
Definition at line 306 of file arithmetique.h.
| #define value_plus | ( | v1, | |||
| v2 | ) | ((v1)+(v2)) |
binary operators on values
Definition at line 281 of file arithmetique.h.
| #define value_pmod | ( | v1, | |||
| v2 | ) | (modulo(v1,v2)) |
Definition at line 287 of file arithmetique.h.
| #define value_pos_p | ( | val | ) | value_gt(val,VALUE_ZERO) |
Definition at line 324 of file arithmetique.h.
| #define value_posz_p | ( | val | ) | value_ge(val,VALUE_ZERO) |
Definition at line 326 of file arithmetique.h.
Definition at line 385 of file arithmetique.h.
| #define value_protected_hard_idiv_multiply | ( | v, | |||
| w, | |||||
| throw | ) |
((value_zero_p(w) || value_zero_p(v))? VALUE_ZERO: \ value_lt(value_abs(v),value_div(VALUE_MAX,value_abs(w)))? \ value_direct_multiply(v,w): (throw, VALUE_NAN))
(|v| < MAX / |w|) => v*w is okay I could check ((v*w)/w)==v but a tmp would be useful
Definition at line 346 of file arithmetique.h.
protected versions
Definition at line 365 of file arithmetique.h.
is a software idiv is assumed, quick check performed first
Definition at line 359 of file arithmetique.h.
Definition at line 367 of file arithmetique.h.
| #define value_rshift | ( | v1, | |||
| v2 | ) | ((v1)>>(v2)) |
Definition at line 293 of file arithmetique.h.
trian operators on values
Definition at line 276 of file arithmetique.h.
Definition at line 302 of file arithmetique.h.
| #define VALUE_TO_DOUBLE | ( | val | ) | ((double)(val)) |
Definition at line 251 of file arithmetique.h.
| #define VALUE_TO_FLOAT | ( | val | ) | ((float)(val)) |
Definition at line 250 of file arithmetique.h.
| #define VALUE_TO_INT | ( | val | ) | ((int)(val)) |
Definition at line 249 of file arithmetique.h.
| #define VALUE_TO_LONG | ( | val | ) | ((long)(val)) |
Definition at line 248 of file arithmetique.h.
| #define value_uminus | ( | val | ) | (-(val)) |
unary operators on values
Definition at line 316 of file arithmetique.h.
| #define VALUE_ZERO 0 |
Definition at line 245 of file arithmetique.h.
| #define value_zero_p | ( | val | ) | value_eq(val,VALUE_ZERO) |
Definition at line 328 of file arithmetique.h.
| typedef int Value |
Definition at line 239 of file arithmetique.h.
| enum linear_exception_t |
Warning! Do not modify this file that is automatically generated!
Modify src/Libs/arithmetique/arithmetique-local.h instead, to add your own modifications. header file built by cprotopackage arithmetique Francois Irigoin, mai 1989
Modifications
Indeed, we cannot switch easily to bignums that need constructors dans destructors... That would lead to too many modifications... C++ would make things easier and cleaner...
Fabien COELHOfor FILE *to be included for _MIN and _MAX: include <limits.h>Global constants to designate exceptions. To be used in the type field.
Definition at line 66 of file arithmetique.h.
00066 { 00067 overflow_error = 1, 00068 simplex_arithmetic_error = 2, 00069 user_exception_error = 4, 00070 parser_exception_error = 8, 00071 timeout_error = 16, 00072 /* catch all */ 00073 any_exception_error = ~0 00074 } linear_exception_t;
end of arithmetique-local.h
end of arithmetique-local.h
.. FC.
| ofl_ctrl | fl_ctrl |
Definition at line 35 of file abs.c.
References assert, overflow_error, THROW, value_eq, VALUE_MIN, value_ne, value_pos_p, and value_uminus.
Referenced by absval(), and absval_ofl().
00036 { 00037 00038 if ((ofl_ctrl == 1) && value_eq(i,VALUE_MIN)) 00039 THROW(overflow_error); 00040 00041 assert(value_ne(i,VALUE_MIN)); 00042 return value_pos_p(i)? i: value_uminus(i); 00043 }
int absval(int i): absolute value of i (SUN version)
Definition at line 55 of file abs.c.
References abs_ofl_ctrl().
00056 { 00057 return abs_ofl_ctrl(i, 0); 00058 }
int absval_ofl(int i): absolute value of i (SUN version)
Definition at line 47 of file abs.c.
References abs_ofl_ctrl().
00048 { 00049 return abs_ofl_ctrl(i, 1); 00050 }
int bezout(int a, int b, int *x, int *y): calcule x et y, les deux nombres qui verifient le theoreme de Bezout pour a et b; le pgcd de a et b est retourne par valeur
a * x + b * y = gcd(a,b) return gcd(a,b)
Definition at line 262 of file pgcd.c.
References c, v, value_div, value_ge, value_minus, value_mod, value_mult, value_notzero_p, VALUE_ONE, VALUE_ZERO, and value_zero_p.
Referenced by vecteur_bezout().
00263 { 00264 Value u0=VALUE_ONE,u1=VALUE_ZERO,v0=VALUE_ZERO,v1=VALUE_ONE; 00265 Value a0,a1,u,v,r,q,c; 00266 00267 if (value_ge(a,b)) 00268 { 00269 a0 = a; 00270 a1 = b; 00271 c = VALUE_ZERO; 00272 } 00273 else 00274 { 00275 a0 = b; 00276 a1 = a; 00277 c = VALUE_ONE; 00278 } 00279 00280 r = value_mod(a0,a1); 00281 while (value_notzero_p(r)) 00282 { 00283 q = value_div(a0,a1); 00284 u = value_mult(u1,q); 00285 u = value_minus(u0,u); 00286 00287 v = value_mult(v1,q); 00288 v = value_minus(v0,v); 00289 a0 = a1; a1 = r; 00290 u0 = u1; u1 = u; 00291 v0 = v1; v1 = v; 00292 00293 r = value_mod(a0,a1); 00294 } 00295 00296 if (value_zero_p(c)) { 00297 *x = u1; 00298 *y = v1; 00299 } 00300 else { 00301 *x = v1; 00302 *y = u1; 00303 } 00304 00305 return(a1); 00306 }
int bezout_grl(int a, int b, int *x, int *y): calcule x et y, les deux entiers quelconcs qui verifient le theoreme de Bezout pour a et b; le pgcd de a et b est retourne par valeur
a * x + b * y = gcd(a,b) return gcd(a,b) gcd () >=0 le pre et le post conditions de pgcd sont comme la fonction gcd_subtract(). les situations speciaux sont donnes ci_dessous: si (a==0 et b==0) x=y=0; gcd()=0, si (a==0)(ou b==0) x=1(ou -1) y=0 (ou x=0 y=1(ou -1)) et gcd()=a(ou -a) (ou gcd()=b(ou -b))
les signes de a et b
Definition at line 321 of file pgcd.c.
References c, v, value_div, value_ge, value_minus, value_mod, VALUE_MONE, value_mult, value_neg_p, value_notzero_p, VALUE_ONE, value_uminus, VALUE_ZERO, and value_zero_p.
Referenced by base_G_h1_unnull().
00322 { 00323 Value u0=VALUE_ONE,u1=VALUE_ZERO,v0=VALUE_ZERO,v1=VALUE_ONE; 00324 Value a0,a1,u,v,r,q,c; 00325 Value sa,sb; /* les signes de a et b */ 00326 00327 sa = sb = VALUE_ONE; 00328 if (value_neg_p(a)){ 00329 sa = VALUE_MONE; 00330 a = value_uminus(a); 00331 } 00332 if (value_neg_p(b)){ 00333 sb = VALUE_MONE; 00334 b = value_uminus(b); 00335 } 00336 if (value_zero_p(a) && value_zero_p(b)){ 00337 *x = VALUE_ONE; 00338 *y = VALUE_ONE; 00339 return VALUE_ZERO; 00340 } 00341 else if(value_zero_p(a) || value_zero_p(b)){ 00342 if (value_zero_p(a)){ 00343 *x = VALUE_ZERO; 00344 *y = sb; 00345 return(b); 00346 } 00347 else{ 00348 *x = sa; 00349 *y = VALUE_ZERO; 00350 return(a); 00351 } 00352 } 00353 else{ 00354 00355 if (value_ge(a,b)) 00356 { 00357 a0 = a; 00358 a1 = b; 00359 c = VALUE_ZERO; 00360 } 00361 else 00362 { 00363 a0 = b; 00364 a1 = a; 00365 c = VALUE_ONE; 00366 } 00367 00368 r = value_mod(a0,a1); 00369 while (value_notzero_p(r)) 00370 { 00371 q = value_div(a0,a1); 00372 u = value_mult(u1,q); 00373 u = value_minus(u0,u); 00374 00375 v = value_mult(v1,q); 00376 v = value_minus(v0,v); 00377 a0 = a1; a1 = r; 00378 u0 = u1; u1 = u; 00379 v0 = v1; v1 = v; 00380 00381 r = value_mod(a0,a1); 00382 } 00383 00384 if (value_zero_p(c)) { 00385 *x = value_mult(sa,u1); 00386 *y = value_mult(sb,v1); 00387 } 00388 else { 00389 *x = value_mult(sa,v1); 00390 *y = value_mult(sb,u1); 00391 } 00392 00393 return a1; 00394 } 00395 }
INTLIBRARYint divide(int a, int b): calcul du divide de a par b; le reste (qui n'est pas retourne) est toujours positif; il est fourni par la fonction modulo() Il y a quatre configuration de signe a traiter: 1. a>0 && b>0: a / b 2. a<0 && b>0: (a-b+1) / b 3. a>0 && b<0: cf. 1. apres changement de signe de b, puis changement de signe du resultat 4. a<0 && b<0: cf. 2. apres changement de signe de b, puis changement de signe du resultat 5. a==0: 0
definition d'une look-up table pour les valeurs de a appartenant a [-DIVIDE_MAX_A..DIVIDE_MAX_A] et pour les valeurs de b appartenant a [1..DIVIDE_MAX_B] (en fait [-DIVIDE_MAX_B..DIVIDE_MAX_B] a cause du changement de signe)
Serait-il utile d'ajouter une test b==1 pour supprimer une colonne?
Serait-il utile de tester b > a pour renvoyer 0 ou -1 tout de suite?
b == 1 2 3 4 5 6 7 8
a == - 7
a == - 6
a == - 5
a == - 4
a == - 3
a == - 2
a == - 1
a == 0
a == 1
a == 2
a == 3
a == 4
a == 5
a == 6
a == 7
translation de a pour acces a la look-up table par indice positif: la == a + DIVIDE_MAX_A >= 0
valeur du quotient C
serait-il utile d'optimiser la division de a=0 par b? Ou bien cette routine n'est-elle jamais appelee avec a=0 par le package vecteur?
direct table look up
shift a for the table
this is just divide_slow
Definition at line 49 of file divide.c.
References assert, DIVIDE_MAX_A, DIVIDE_MAX_B, int_to_value, value_ge, value_le, value_notzero_p, value_pdiv, VALUE_TO_INT, and value_uminus.
00050 { 00051 /* definition d'une look-up table pour les valeurs de a appartenant 00052 a [-DIVIDE_MAX_A..DIVIDE_MAX_A] et pour les valeurs de b 00053 appartenant a [1..DIVIDE_MAX_B] (en fait [-DIVIDE_MAX_B..DIVIDE_MAX_B] 00054 a cause du changement de signe) 00055 00056 Serait-il utile d'ajouter une test b==1 pour supprimer une colonne? 00057 00058 Serait-il utile de tester b > a pour renvoyer 0 ou -1 tout de suite? 00059 */ 00060 00061 #define DIVIDE_MAX_A 7 00062 #define DIVIDE_MAX_B 8 00063 00064 static Value 00065 divide_look_up[2*DIVIDE_MAX_A+1][DIVIDE_MAX_B]={ 00066 /* b == 1 2 3 4 5 6 7 8 */ 00067 {/* a == - 7 */ -7, -4, -3, -2, -2, -2, -1, -1}, 00068 {/* a == - 6 */ -6, -3, -2, -2, -2, -1, -1, -1}, 00069 {/* a == - 5 */ -5, -3, -2, -2, -1, -1, -1, -1}, 00070 {/* a == - 4 */ -4, -2, -2, -2, -1, -1, -1, -1}, 00071 {/* a == - 3 */ -3, -2, -1, -1, -1, -1, -1, -1}, 00072 {/* a == - 2 */ -2, -1, -1, -1, -1, -1, -1, -1}, 00073 {/* a == - 1 */ -1, -1, -1, -1, -1, -1, -1, -1}, 00074 {/* a == 0 */ 0, 0, 0, 0, 0, 0, 0, 0}, 00075 {/* a == 1 */ 1, 0, 0, 0, 0, 0, 0, 0}, 00076 {/* a == 2 */ 2, 1, 0, 0, 0, 0, 0, 0}, 00077 {/* a == 3 */ 3, 1, 1, 0, 0, 0, 0, 0}, 00078 {/* a == 4 */ 4, 2, 1, 1, 0, 0, 0, 0}, 00079 {/* a == 5 */ 5, 2, 1, 1, 1, 0, 0, 0}, 00080 {/* a == 6 */ 6, 3, 2, 1, 1, 1, 0, 0}, 00081 {/* a == 7 */ 7, 3, 2, 1, 1, 1, 1, 0} 00082 }; 00083 /* translation de a pour acces a la look-up table par indice positif: 00084 la == a + DIVIDE_MAX_A >= 0 */ 00085 00086 Value quotient; /* valeur du quotient C */ 00087 00088 assert(value_notzero_p(b)); 00089 00090 /* serait-il utile d'optimiser la division de a=0 par b? Ou bien 00091 cette routine n'est-elle jamais appelee avec a=0 par le package vecteur? 00092 */ 00093 00094 if (value_le(a, int_to_value(DIVIDE_MAX_A)) && 00095 value_ge(a, int_to_value(-DIVIDE_MAX_A)) && 00096 value_le(b, int_to_value(DIVIDE_MAX_B)) && 00097 value_ge(b, int_to_value(-DIVIDE_MAX_B))) 00098 { 00099 /* direct table look up */ 00100 int bint = VALUE_TO_INT(b), 00101 la = VALUE_TO_INT(a)+DIVIDE_MAX_A; /* shift a for the table */ 00102 quotient = (bint>0)? 00103 divide_look_up[la][bint-1]: 00104 value_uminus(divide_look_up[la][(-bint)-1]); 00105 } 00106 else 00107 quotient = value_pdiv(a,b); /* this is just divide_slow */ 00108 00109 return quotient; 00110 }
Definition at line 112 of file divide.c.
References value_pdiv.
00113 { 00114 return value_pdiv(a, b); 00115 }
| void dump_exception_stack | ( | void | ) |
| void dump_exception_stack_to_file | ( | FILE * | ) |
INTLIBRARYno overflow is checked int exponentiate(x,n): raise x to the power n Precondition: n => 0
validation - n is positive
FI: la complexite pourrait etre reduite de O(n) a O(log n)
Definition at line 42 of file exp.c.
References assert, VALUE_ONE, and value_product.
00043 { 00044 Value y; 00045 00046 /* validation - n is positive 00047 */ 00048 assert(n >= 0); 00049 if (n == 0) return VALUE_ONE; 00050 00051 /* FI: la complexite pourrait etre reduite de O(n) a O(log n) 00052 */ 00053 for(y=VALUE_ONE; n>0; n--) 00054 value_product(y,x); 00055 00056 return y; 00057 }
| void fprint_string_Value | ( | FILE * | , | |
| char * | , | |||
| Value | ||||
| ) |
Definition at line 44 of file linear/src/arithmetique/io.c.
References fprint_Value(), and fprintf().
Referenced by build_sc_machine(), calculate_delay(), evaluate_var_to_complexity(), make_movements_loop_body_wp65(), print_dependence_cone(), print_vect_in_vertice_val(), region_translation_init(), and TestDiVariables().
00045 { 00046 fprintf(f, blah); 00047 fprint_Value(f, v); 00048 }
| void fprint_Value | ( | FILE * | , | |
| Value | ||||
| ) |
Definition at line 39 of file linear/src/arithmetique/io.c.
References fprintf(), and VALUE_FMT.
Referenced by adg_contrainte_fprint(), build1(), choose(), computebounds(), contrainte_fprint(), coupe(), evaluate_var_to_complexity(), fast(), fastplus(), findandmod(), fourier1(), fprint_contrainte_vecteur(), fprint_string_Value(), gcdtest(), igvoir3(), inequaldivision(), ipivotage2(), iprimal(), iprimalplus(), is2(), lowbound(), majlowbounds(), majuu(), matrice_fprint(), matrix_fprint(), matrix_pr_quot(), pr_quot(), pu_contrainte_fprint(), pu_vect_fprint(), sc_minmax_of_variable2(), sommet_fprint(), sommet_fprint_as_dense(), splitpb(), tableau_janus(), term(), upperbound(), vect_fprint(), vect_fprint_as_dense(), vect_gen_write(), voirbornes(), vzcut(), and wvoir().
| int fscan_Value | ( | FILE * | , | |
| Value * | ||||
| ) |
Definition at line 55 of file linear/src/arithmetique/io.c.
References VALUE_FMT.
Referenced by matrice_fscan(), and matrix_fscan().
int gcd_subtract(int a, int b): find the gcd (pgcd) of two integers
There is no precondition on the input. Negative input is handled in the same way as positive ones. If one input is zero the output is equal to the other input - thus an input of two zeros is the only way an output of zero is created.
Postcondition: gcd(a,b) > 0 ; gcd(a,b)==0 iff a==0 and b==0 whereas it should be undefined (F. Irigoin)
Exception: gcd(0,0) aborts
Implementation: by subtractions
Note: the signs of a and b do not matter because they can be exactly divided by the gcd
b == 0
Definition at line 186 of file pgcd.c.
References assert, value_abs, value_ge, value_minus, value_notzero_p, and value_zero_p.
00187 { 00188 a = value_abs(a); 00189 b = value_abs(b); 00190 00191 while (value_notzero_p(a) && value_notzero_p(b)) { 00192 if (value_ge(a,b)) 00193 a = value_minus(a,b); 00194 else 00195 b = value_minus(b,a); 00196 } 00197 00198 if (value_zero_p(a)) { 00199 assert(value_notzero_p(b)); 00200 return b; 00201 } 00202 else { 00203 /* b == 0 */ 00204 assert(value_notzero_p(a)); 00205 return a; 00206 } 00207 }
| linear_exception_t | xception |
| void linear_initialize_exception_stack | ( | unsigned | int, | |
| exception_callback_t | , | |||
| exception_callback_t | ||||
| ) |
| int | erbose_exceptions |
INTLIBRARYint modulo_fast(int a, int b): calcul du modulo de a par b; le modulo retourne est toujours positif Il y a quatre configuration de signe a traiter: 1. a>0 && b>0: a % b 2. a<0 && b>0: a % b == 0 ? 0 : b - (-a)b 3. a>0 && b<0: cf. 1. apres changement de signe de b 4. a<0 && b<0: cf. 2. apres changement de signe de b
definition d'une look-up table pour les valeurs de a appartenant a [-MODULO_MAX_A..MODULO_MAX_A] et pour les valeurs de b appartenant a [1..MODULO_MAX_B] (en fait [-MODULO_MAX_B..MODULO_MAX_B] a cause du changement de signe)
Serait-il utile d'ajouter une test b==1 pour supprimer une colonne?
should be generated automatically
b == 1 2 3 4 5
a == - 5
a == - 4
a == - 3
a == - 2
a == - 1
a == 0
a == 1
a == 2
a == 3
a == 4
a == 5
translation de a pour acces a la look-up table
valeur du modulo C
premier changement de signe, ne changeant pas le resultat
traitement des cas particuliers
supprime pour cause de look-up table if(a==1 || a== 0) return(a);
if(b==1) return(0);
acceleration par une look-up table
calcul effectif du modulo: attention, portabilite douteuse
Definition at line 45 of file modulo.c.
References assert, int_to_value, MODULO_MAX_A, MODULO_MAX_B, value_abs, value_ge, value_le, value_minus, value_mod, value_neg_p, value_notzero_p, and VALUE_TO_INT.
00046 { 00047 /* definition d'une look-up table pour les valeurs de a appartenant 00048 a [-MODULO_MAX_A..MODULO_MAX_A] et pour les valeurs de b 00049 appartenant a [1..MODULO_MAX_B] (en fait [-MODULO_MAX_B..MODULO_MAX_B] 00050 a cause du changement de signe) 00051 00052 Serait-il utile d'ajouter une test b==1 pour supprimer une colonne? 00053 */ 00054 #define MODULO_MAX_A 5 00055 #define MODULO_MAX_B 5 00056 static Value /* should be generated automatically */ 00057 modulo_look_up[2*MODULO_MAX_A+1][MODULO_MAX_B]= { 00058 /* b == 1 2 3 4 5 */ 00059 {/* a == - 5 */ 0, 1, 1, 3, 0}, 00060 {/* a == - 4 */ 0, 0, 2, 0, 1}, 00061 {/* a == - 3 */ 0, 1, 0, 1, 2}, 00062 {/* a == - 2 */ 0, 0, 1, 2, 3}, 00063 {/* a == - 1 */ 0, 1, 2, 3, 4}, 00064 {/* a == 0 */ 0, 0, 0, 0, 0}, 00065 {/* a == 1 */ 0, 1, 1, 1, 1}, 00066 {/* a == 2 */ 0, 0, 2, 2, 2}, 00067 {/* a == 3 */ 0, 1, 0, 3, 3}, 00068 {/* a == 4 */ 0, 0, 1, 0, 4}, 00069 {/* a == 5 */ 0, 1, 2, 1, 0} 00070 }; 00071 /* translation de a pour acces a la look-up table */ 00072 00073 Value mod; /* valeur du modulo C */ 00074 assert(value_notzero_p(b)); 00075 00076 /* premier changement de signe, ne changeant pas le resultat */ 00077 b = value_abs(b); 00078 00079 /* traitement des cas particuliers */ 00080 /* supprime pour cause de look-up table 00081 * if(a==1 || a== 0) 00082 * return(a); 00083 * 00084 * if(b==1) 00085 * return(0); 00086 */ 00087 00088 if (value_le(a, int_to_value( MODULO_MAX_A)) && 00089 value_ge(a, int_to_value(-MODULO_MAX_A)) && 00090 value_le(b, int_to_value( MODULO_MAX_B))) 00091 { 00092 /* acceleration par une look-up table 00093 */ 00094 mod = modulo_look_up[VALUE_TO_INT(a)+MODULO_MAX_A][VALUE_TO_INT(b)-1]; 00095 } 00096 else { 00097 /* calcul effectif du modulo: attention, portabilite douteuse */ 00098 mod = value_mod(a,b); 00099 mod = value_neg_p(mod)? value_minus(b,mod): mod; 00100 } 00101 00102 return mod; 00103 }
int pgcd_fast(int a, int b): calcul iteratif du pgcd de deux entiers; le pgcd retourne est toujours positif; il n'est pas defini si a et b sont nuls (abort);
si cette routine n'est JAMAIS appelee avec des arguments nuls, il faudrait supprimer les deux tests d'egalite a 0; ca devrait etre le cas avec les vecteurs creux
Definition at line 79 of file pgcd.c.
References assert, pgcd_interne(), value_abs, value_gt, value_notzero_p, and value_zero_p.
00080 { 00081 Value gcd; 00082 00083 assert(value_notzero_p(b)||value_notzero_p(a)); 00084 00085 a = value_abs(a); 00086 b = value_abs(b); 00087 00088 /* si cette routine n'est JAMAIS appelee avec des arguments nuls, 00089 il faudrait supprimer les deux tests d'egalite a 0; ca devrait 00090 etre le cas avec les vecteurs creux */ 00091 if(value_gt(a,b)) 00092 gcd = value_zero_p(b)? a : pgcd_interne(a,b); 00093 else 00094 gcd = value_zero_p(a)? b : pgcd_interne(b,a); 00095 00096 return gcd; 00097 }
int pgcd_interne(int a, int b): calcul iteratif du pgcd de deux entiers strictement positifs tels que a > b; le pgcd retourne est toujours positif;
Definition d'une look-up table pour les valeurs de a appartenant a [0..GCD_MAX_A] (en fait [-GCD_MAX_A..GCD_MAX_A]) et pour les valeurs de b appartenant a [1..GCD_MAX_B] (en fait [-GCD_MAX_B..GCD_MAX_B] a cause du changement de signe)
Serait-il utile d'ajouter une test b==1 pour supprimer une colonne?
la commutativite du pgcd n'est pas utilisee pour reduire la taille de la table
b == 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
a == 0
a == 1
a == 2
a == 3
a == 4
a == 5
a == 6
a == 7
a == 8
a == 9
a == 10
a == 11
a == 12
a == 13
a == 14
a == 15
on pourrait aussi utiliser une table des nombres premiers pour diminuer le nombre de boucles
on utilise la valeur particuliere -1 pour iterer
compute modulo(a,b) en utilisant la routine C puisque a et b sont strictement positifs (vaudrait-il mieux utiliser la soustraction?)
Definition at line 103 of file pgcd.c.
References assert, GCD_MAX_A, GCD_MAX_B, int_to_value, value_gt, value_le, value_mod, VALUE_MONE, value_neg_p, value_pos_p, VALUE_TO_INT, and value_zero_p.
Referenced by pgcd_fast().
00104 { 00105 /* Definition d'une look-up table pour les valeurs de a appartenant 00106 a [0..GCD_MAX_A] (en fait [-GCD_MAX_A..GCD_MAX_A]) 00107 et pour les valeurs de b appartenant a [1..GCD_MAX_B] 00108 (en fait [-GCD_MAX_B..GCD_MAX_B] a cause du changement de signe) 00109 00110 Serait-il utile d'ajouter une test b==1 pour supprimer une colonne? 00111 */ 00112 #define GCD_MAX_A 15 00113 #define GCD_MAX_B 15 00114 /* la commutativite du pgcd n'est pas utilisee pour reduire la 00115 taille de la table */ 00116 static Value 00117 gcd_look_up[GCD_MAX_A+1][GCD_MAX_B+1]= { 00118 /* b == 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ 00119 {/* a == 0 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15}, 00120 {/* a == 1 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 00121 {/* a == 2 */ 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1}, 00122 {/* a == 3 */ 3, 1, 1, 3, 1, 1, 3, 1, 1, 3, 1, 1, 3, 1, 1, 3}, 00123 {/* a == 4 */ 4, 1, 2, 1, 4, 1, 2, 1, 4, 1, 2, 1, 4, 1, 2, 1}, 00124 {/* a == 5 */ 5, 1, 1, 1, 1, 5, 1, 1, 1, 1, 5, 1, 1, 1, 1, 5}, 00125 {/* a == 6 */ 6, 1, 2, 3, 2, 1, 6, 1, 2, 3, 2, 1, 6, 1, 2, 3}, 00126 {/* a == 7 */ 7, 1, 1, 1, 1, 1, 1, 7, 1, 1, 1, 1, 1, 1, 7, 1}, 00127 {/* a == 8 */ 8, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1}, 00128 {/* a == 9 */ 9, 1, 1, 3, 1, 1, 3, 1, 1, 9, 1, 1, 3, 1, 1, 3}, 00129 {/* a == 10 */10, 1, 2, 1, 2, 5, 2, 1, 2, 1,10, 1, 2, 1, 2, 5}, 00130 {/* a == 11 */11, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,11, 1, 1, 1, 1}, 00131 {/* a == 12 */12, 1, 2, 3, 4, 1, 6, 1, 4, 3, 2, 1,12, 1, 2, 3}, 00132 {/* a == 13 */13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,13, 1, 1}, 00133 {/* a == 14 */14, 1, 2, 1, 2, 1, 2, 7, 2, 1, 2, 1, 2, 1,14, 1}, 00134 {/* a == 15 */15, 1, 1, 3, 1, 5, 3, 1, 1, 3, 5, 1, 3, 1, 1, 15} 00135 }; 00136 /* on pourrait aussi utiliser une table des nombres premiers 00137 pour diminuer le nombre de boucles */ 00138 00139 /* on utilise la valeur particuliere -1 pour iterer */ 00140 Value gcd = VALUE_MONE; 00141 Value mod; 00142 00143 assert(value_gt(a,b) && value_pos_p(b)); 00144 00145 do{ 00146 if(value_le(b,int_to_value(GCD_MAX_B)) && 00147 value_le(a,int_to_value(GCD_MAX_A))) { 00148 gcd = gcd_look_up[VALUE_TO_INT(a)][VALUE_TO_INT(b)]; 00149 break; 00150 } 00151 else { 00152 /* compute modulo(a,b) en utilisant la routine C puisque a et b 00153 sont strictement positifs (vaudrait-il mieux utiliser la 00154 soustraction?) */ 00155 mod = value_mod(a,b); 00156 if(value_zero_p(mod)) { 00157 gcd = b; 00158 } 00159 else { 00160 a = b; 00161 b = mod; 00162 } 00163 } 00164 } while(value_neg_p(gcd)); 00165 00166 return gcd; 00167 }
INTLIBRARYValue pgcd_slow(Value a, Value b) computation of the gcd of a and b. the result is always positive. standard algorithm in log(max(a,b)). pgcd_slow(0,0)==1 (maybe should we abort?). I changed from a recursive for a simple iterative version, FC 07/96.
a==0, b==0
a==0, b!=0
a!=0, b==0
a==b
swap
on entry in this loop, a > b > 0 is insured
Definition at line 41 of file pgcd.c.
References value_abs, value_absolute, value_eq, value_gt, value_mod, value_notzero_p, VALUE_ONE, and value_zero_p.
Referenced by matrice_determinant(), matrice_diagonale_inversion(), matrice_triangulaire_inversion(), matrix_determinant(), and substitute_var_with_vec().
00042 { 00043 Value m; 00044 00045 if (value_zero_p(a)) 00046 { 00047 if (value_zero_p(b)) 00048 return VALUE_ONE; /* a==0, b==0 */ 00049 else 00050 return value_abs(b); /* a==0, b!=0 */ 00051 } 00052 else 00053 if (value_zero_p(b)) 00054 return value_abs(a); /* a!=0, b==0 */ 00055 00056 value_absolute(a); 00057 value_absolute(b); 00058 00059 if (value_eq(a,b)) /* a==b */ 00060 return a; 00061 00062 if (value_gt(b,a)) 00063 m = a, a = b, b = m; /* swap */ 00064 00065 /* on entry in this loop, a > b > 0 is insured */ 00066 do { 00067 m = value_mod(a,b); 00068 a = b; 00069 b = m; 00070 } while(value_notzero_p(b)); 00071 00072 return a; 00073 }
| int | hat | |
| int | ine |
INTLIBRARYint ppcm(int i, int j): plus petit entier positif divisible par i et j Ancien nom et ancien type: void lcm(int i, int j, int *pk)
Definition at line 39 of file ppcm.c.
References pgcd, value_div, value_mult, value_neg_p, value_uminus, VALUE_ZERO, and value_zero_p.
Referenced by bounds_equal_p(), build_contraction_matrices(), compose_vvs(), include_trans_on_LC_in_ref(), matrice_diagonale_inversion(), matrice_substract(), matrix_add(), matrix_diagonal_inversion(), matrix_substract(), my_matrices_to_constraints_with_sym_cst(), my_matrices_to_constraints_with_sym_cst_2(), simplify_dimension(), simplify_predicate(), and vvs_on_vvs().
00040 { 00041 if (value_neg_p(i)) i = value_uminus(i); 00042 if (value_neg_p(j)) j = value_uminus(j); 00043 00044 if (value_zero_p(i) || value_zero_p(j)) 00045 return VALUE_ZERO; 00046 else { 00047 Value d = pgcd(i,j); 00048 d = value_div(i,d); 00049 return value_mult(d,j); 00050 } 00051 }
| void print_Value | ( | Value | v | ) |
IO on a Value
Definition at line 34 of file linear/src/arithmetique/io.c.
References printf(), and VALUE_FMT.
Referenced by add_var_sup(), eq_in_ineq(), lignes_entrant(), printfrac(), and var_ecart_sup().
| int | hat | |
| int | ine |
| int scan_Value | ( | Value * | ) |
Definition at line 60 of file linear/src/arithmetique/io.c.
References VALUE_FMT.
Referenced by fonct_read(), and vect_read().
00061 { 00062 return scanf(VALUE_FMT, pv); 00063 }
| void set_exception_callbacks | ( | exception_callback_t | , | |
| exception_callback_t | ||||
| ) |
Referenced by __attribute__(), atinit(), gpips_main(), pips_main(), tpips_main(), and wpips_main().
| void sprint_Value | ( | char * | , | |
| Value | ||||
| ) |
Definition at line 50 of file linear/src/arithmetique/io.c.
References VALUE_FMT.
Referenced by heuristique_1(), heuristique_3(), and vect_sprint_as_monome().
| int sscan_Value | ( | char * | , | |
| Value * | ||||
| ) |
Definition at line 65 of file linear/src/arithmetique/io.c.
References VALUE_FMT.
Referenced by slx_parse(), and vect_gen_read().
| int | hat | |
| int | ine |
| char* Value_to_string | ( | Value | ) |
Definition at line 73 of file linear/src/arithmetique/io.c.
References buf, BUFFER_SIZE, and VALUE_FMT.
Referenced by add_Value_to_current_line().
00074 { 00075 static char buf[BUFFER_SIZE]; 00076 sprintf(buf, VALUE_FMT, v); 00077 return buf; 00078 }
int vecteur_bezout(int u[], int v[], int l): calcul du vecteur v qui verifie le theoreme de bezout pour le vecteur u; les vecteurs u et v sont de dimension l
-> -> -> < u . v > = gcd(u ) i
printf("gcd = %d \n",gcd);
sum u * v = gcd(u ) k<l k k k<l k
a1 = gcd (u ) k<l-1 k
printf("gcd = %d\n",gcd);
Definition at line 217 of file pgcd.c.
References assert, bezout(), i, VALUE_ONE, value_product, and x.
00218 { 00219 Value gcd, a1, x; 00220 Value *p1, *p2; 00221 int i, j; 00222 00223 assert(l>0); 00224 00225 if (l==1) { 00226 v[0] = VALUE_ONE; 00227 gcd = u[0]; 00228 } 00229 else { 00230 p1 = &v[0]; p2 = &v[1]; 00231 a1 = u[0]; gcd = u[1]; 00232 gcd = bezout(a1,gcd,p1,p2); 00233 00234 /* printf("gcd = %d \n",gcd); */ 00235 00236 for (i=2;i<l;i++){ 00237 /* sum u * v = gcd(u ) 00238 * k<l k k k<l k 00239 * 00240 * a1 = gcd (u ) 00241 * k<l-1 k 00242 */ 00243 a1 = u[i]; 00244 p1 = &v[i]; 00245 gcd = bezout(a1,gcd,p1,&x); 00246 /* printf("gcd = %d\n",gcd); */ 00247 for (j=0;j<i;j++) 00248 value_product(v[j],x); 00249 } 00250 } 00251 00252 return gcd; 00253 }
Referenced by build_sc_nredund_1pass_ofl_ctrl(), efficient_sc_check_inequality_feasibility(), internal_sc_feasibility(), sc_cute_convex_hull(), sc_feasibility_ofl_ctrl(), sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl(), sc_janus_feasibility_ofl_ctrl_timeout_ctrl(), and sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl().
1.6.2-20100208