PIPS
base.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "linear_assert.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
+ Include dependency graph for base.c:

Go to the source code of this file.

Functions

Pbase vect_add_variable (Pbase b, Variable v)
 package vecteur - routines sur les bases More...
 
Pbase base_add_variable (Pbase b, Variable var)
 Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end of the base list; if variable v is already in basis b, do nothing; this is not clean but convenient to avoid a test;. More...
 
Pbase make_base_from_vect (Pvecteur pv)
 
Pbase base_remove_variable (Pbase b, Variable v)
 Pbase base_remove_variable(b, v): remove basis vector relative to v from b; abort if v is not in b;. More...
 
bool base_contains_variable_p (Pbase b, Variable v)
 bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements; More...
 
Variable base_find_variable (Pbase b, Variable v)
 Variable base_find_variable(Pbase b, Variable v): returns variable v if variable v is one of b's elements (returns a pointer to the copy of v that's pointed to by basis b); else returns VARIABLE_UNDEFINED. More...
 
Variable base_find_variable_name (Pbase b, Variable v, char *(*variable_name)(Variable))
 Variable base_find_variable_name(Pbase b, Variable v, char * (*variable_name)()): returns the variable (i.e. More...
 
int base_find_variable_rank (Pbase b, Variable v, char *(*variable_name)(Variable))
 int base_find_variable_rank(Pbase b, Variable v, char * (*variable_name)()): returns variable v's rank if it is in basis b, else -1 More...
 
Pbase base_reversal (Pbase b_in)
 Pbase base_reversal(Pbase b_in): produces a basis b_out, having the same basis vectors as b_in, but in reverse order. More...
 
Pvecteur vect_rename (Pvecteur v, Pbase b, char *(*variable_name)(Variable))
 Pvecteur vect_rename(Pvecteur v, Pbase b, char * (*variable_name)()): modify vector v so that its coordinates are relative to basis b; each basis vector is defined by a pointer of type Variable, but different pointers can point to the same basis vector wrt variable_name; these pointers are unified with respect to b and variable_name to let us perform eq-type comparison in the library. More...
 
Pvecteur vect_rename_variables (Pvecteur v, bool(*renamed_p)(Variable), Variable(*new_variable)(Variable))
 Pvecteur vect_rename_variables(v, renamed_p, new_variable) Pvecteur v; bool (*renamed_p)(Variable); Variable (*new_variable)(Variable);. More...
 
Pvecteur vect_translate (Pvecteur v, Pbase b, char *(*variable_name)(Variable))
 Pvecteur vect_translate(Pvecteur v, Pbase b, char * (*variable_name)()): modify vector v so that its coordinates are relative to basis b; each basis vector is defined by a pointer of type Variable, but different pointers can point to the same basis vector wrt variable_name; these pointers are unified with respect to b and variable_name to let us perform eq-type comparison in the library. More...
 
bool vect_in_basis_p (Pvecteur v, Pbase b)
 Pvecteur vect_in_basis_p(Pvecteur v, Pbase b): check that all coordinates in v are in b, i.e. More...
 
Pvecteur vect_variable_rename (Pvecteur v, Variable v_old, Variable v_new)
 Pvecteur vect_variable_rename(Pvecteur v, Variable v_old, Variable v_new): rename the potential coordinate v_old in v as v_new. More...
 
void base_append (Pbase *pb1, Pbase b2)
 appends b2 to b1. More...
 
Pbase base_union (Pbase b1, Pbase b2)
 Pbase base_union(Pbase b1, Pbase b2): compute a new basis containing all elements of b1 and all elements of b2, in an unkown order. More...
 
Pbase base_intersection (Pbase b1, Pbase b2)
 Return variables/dimensions present in bases b1 and b2. More...
 
int rank_of_variable (Pbase base, Variable var)
 this function returns the rank of the variable var in the base 0 encodes TCST, but I do not know why, TCST may be in base, sometimes -1 encodes an error More...
 
Variable variable_of_rank (Pbase base, int rank)
 Variable variable_of_rank(): this function returns the variable of rank "rank". More...
 
int search_higher_rank (Pvecteur vect, Pbase base)
 int search_higher_rank(): this fonction returns the rank of the variable of higher rank in the vecteur More...
 
Variable search_var_of_higher_rank (Pvecteur pvect, Pbase base, Variable var)
 this function returns the variable of higher rank, after the variable var, in the vecteur pvect More...
 
Pvecteur search_i_element (Pbase b, int i)
 Pvecteur search_i_element(): recherche du i-ieme couple (var,val) dans la Pbase b. More...
 
Pbase base_normalize (Pbase b)
 
bool base_normalized_p (Pbase b)
 
Pbase base_difference (Pbase b1, Pbase b2)
 Pbase base_difference(Pbase b1, Pbase b2): allocate b; b = b1 - b2 – with the set meaning return b;. More...
 
bool base_included_p (Pbase b1, Pbase b2)
 Pbase base_included_p(Pbase b1, Pbase b2): include_p = b1 is included in b2 – with the set meaning return b;. More...
 
bool bases_strictly_equal_p (Pbase b1, Pbase b2)
 Make sure that each dimension of b1 is the same dimension in b2. More...
 

Function Documentation

◆ base_add_variable()

Pbase base_add_variable ( Pbase  b,
Variable  var 
)

Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end of the base list; if variable v is already in basis b, do nothing; this is not clean but convenient to avoid a test;.

Note that basis b contains a pointer towards variable v and not a copy of it. So some sharing is introduced.

A routine to check variable equality, variable_equal(), is used.

Parameters
varar

Definition at line 88 of file base.c.

91 {
92  Pbase b1 = b;
93  Pbase result = b;
94 
95 
96  if (!VECTEUR_NUL_P(b1)) {
97  for(; !VECTEUR_NUL_P(b1) && !variable_equal(vecteur_var(b1), var);
98  b1 = b1->succ);
99  if (VECTEUR_NUL_P(b1)) {
100  for (b1 = b; !VECTEUR_NUL_P(b1->succ); b1=b1->succ);
101  b1->succ = vect_new(var, VALUE_ONE);
102  }
103  }
104  else { result = vect_new(var, VALUE_ONE);
105  }
106  return(result);
107 }
#define VALUE_ONE
bool variable_equal(Variable v1, Variable v2)
package vecteur - routines sur les variables
Definition: variable.c:62
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define vecteur_var(v)
#define VECTEUR_NUL_P(v)
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110

References b1, VALUE_ONE, variable_equal(), vect_new(), VECTEUR_NUL_P, and vecteur_var.

Referenced by add_constraint_on_x(), base_intersection(), build_and_test_dependence_context(), copy_write_statement_with_cumulated_regions(), generic_minmax_to_transformer(), include_parameters_in_sc(), local_tile_constraints(), main(), make_base_from_vect(), make_base_phi_variables(), new_system_with_only_live_variable(), region_to_com_nest(), region_to_loop_nest(), sc_safe_append(), TestDependence(), transformer_add_loop_index_incrementation(), transformer_add_sign_information(), transformer_add_value_update(), transformer_add_variable_update(), transformer_derivative_fix_point(), transformer_list_generic_transitive_closure(), and vect_change_base().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_append()

void base_append ( Pbase pb1,
Pbase  b2 
)

appends b2 to b1.

modifies b1. b2 is not modified.

Parameters
pb1b1
b22

Definition at line 384 of file base.c.

385 {
386  if (BASE_NULLE_P(*pb1))
387  *pb1 = base_copy(b2);
388  else
389  {
390  Pvecteur v;
392  for (v=*pb1; v; v=v->succ)
393  {
394  Variable var = var_of(v);
395  if (var!=TCST) linear_hashtable_put_once(seen, var, var);
396  }
397 
398  for (v=b2; v; v=v->succ)
399  {
400  Variable var = var_of(v);
401  if (var!=TCST && !linear_hashtable_isin(seen, var))
402  {
403  linear_hashtable_put_once(seen, var, var);
404  *pb1 = vect_chain(*pb1, var, VALUE_ONE);
405  }
406  }
407 
409  }
410 }
static hash_table seen
static function to store whether a module has been seen during the recursive generation of the daVinc...
Definition: graph.c:85
bool linear_hashtable_isin(linear_hashtable_pt h, void *k)
Definition: hashpointer.c:273
void linear_hashtable_put_once(linear_hashtable_pt h, void *k, void *v)
Definition: hashpointer.c:268
linear_hashtable_pt linear_hashtable_make(void)
constructor.
Definition: hashpointer.c:165
void linear_hashtable_free(linear_hashtable_pt h)
destructor
Definition: hashpointer.c:189
Pvecteur vect_chain(Pvecteur v_in, Variable var, Value coeff)
package vecteur routines internes au package
Definition: private.c:69
Value b2
Definition: sc_gram.c:105
struct Svecteur * succ
Definition: vecteur-local.h:92
hidden structure to store the hashtable.
Definition: hashpointer.c:66
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
#define var_of(varval)
#define BASE_NULLE_P(b)
Pbase base_copy(Pbase b)
Direct duplication.
Definition: alloc.c:300

References b2, base_copy(), BASE_NULLE_P, linear_hashtable_free(), linear_hashtable_isin(), linear_hashtable_make(), linear_hashtable_put_once(), seen, Svecteur::succ, TCST, VALUE_ONE, var_of, and vect_chain().

Referenced by sc_append().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_contains_variable_p()

bool base_contains_variable_p ( Pbase  b,
Variable  v 
)

bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements;

Based on variable_equal()

Definition at line 136 of file base.c.

139 {
140  bool in_base;
141 
142  for(; !VECTEUR_NUL_P(b) && !variable_equal(vecteur_var(b), v); b = b->succ)
143  ;
144 
145  in_base = !VECTEUR_NUL_P(b);
146  return(in_base);
147 }

References variable_equal(), VECTEUR_NUL_P, and vecteur_var.

Referenced by add_bounding_box_constraints(), add_type_information(), base_difference(), base_intersection(), base_remove_variable(), build_transfer_equations(), cell_reference_sc_exact_projection_along_variable(), fortran_user_call_to_transformer(), include_trans_on_LC_in_ref(), my_system_remove_variables(), new_ident(), new_system_with_only_live_variable(), partial_eval_reference(), precondition_intra_to_inter(), region_exact_projection_along_parameters(), region_exact_projection_along_variable(), safe_transformer_projection(), sc_minmax_of_variable2(), sc_multiply_constant_terms(), sc_projection_ofl_along_list_of_variables(), separate_variables(), separate_variables_2(), simplify_dimension(), simplify_predicate(), sub_basis_p(), system_contains_var(), transform_in_ineq(), transformer_add_value_update(), transformer_add_variable_update(), transformer_argument_general_consistency_p(), transformer_arguments_projection(), transformer_combine(), transformer_convex_hulls(), transformer_filter(), transformer_projection_with_redundancy_elimination_and_check(), transformer_range(), transformer_to_1D_lattice(), transformer_to_domain(), transformer_value_substitutable_p(), transformer_value_substitute(), translate_global_value(), translate_to_module_frame(), vect_in_basis_p(), and vect_read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_difference()

Pbase base_difference ( Pbase  b1,
Pbase  b2 
)

Pbase base_difference(Pbase b1, Pbase b2): allocate b; b = b1 - b2 – with the set meaning return b;.

Parameters
b11
b22

Definition at line 621 of file base.c.

622 {
623  Pbase b = BASE_NULLE;
624  Pbase eb = BASE_UNDEFINED;
625 
626  for(eb = b1; !BASE_NULLE_P(eb); eb = eb->succ) {
627  Variable v = vecteur_var(eb);
628 
630  b = vect_add_variable(b, v);
631  }
632 
633  return b;
634 }
bool base_contains_variable_p(Pbase b, Variable v)
bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements...
Definition: base.c:136
Pbase vect_add_variable(Pbase b, Variable v)
package vecteur - routines sur les bases
Definition: base.c:61
#define BASE_UNDEFINED
#define BASE_NULLE
MACROS SUR LES BASES.

References b1, b2, base_contains_variable_p(), BASE_NULLE, BASE_NULLE_P, BASE_UNDEFINED, Svecteur::succ, vect_add_variable(), and vecteur_var.

Referenced by algorithm_row_echelon_generic(), build_transfer_equations(), get_other_constraints(), sc_consistent_p(), and set_sort_context().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_find_variable()

Variable base_find_variable ( Pbase  b,
Variable  v 
)

Variable base_find_variable(Pbase b, Variable v): returns variable v if variable v is one of b's elements (returns a pointer to the copy of v that's pointed to by basis b); else returns VARIABLE_UNDEFINED.

Based on variable_equal()

Definition at line 155 of file base.c.

158 {
159  for(; !VECTEUR_NUL_P(b) && !variable_equal(vecteur_var(b), v); b = b->succ)
160  ;
161 
163 }
#define VARIABLE_UNDEFINED
Definition: vecteur-local.h:64

References variable_equal(), VARIABLE_UNDEFINED, VECTEUR_NUL_P, and vecteur_var.

Referenced by matrice_index_sys(), rec_ident(), and vect_read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_find_variable_name()

Variable base_find_variable_name ( Pbase  b,
Variable  v,
char * (*)(Variable variable_name 
)

Variable base_find_variable_name(Pbase b, Variable v, char * (*variable_name)()): returns the variable (i.e.

coord) in b that has the same name as v; else returns VARIABLE_UNDEFINED

Definition at line 170 of file base.c.

174 {
175  char * nv;
176  char * nb;
177  bool equal;
178 
179  for(; !VECTEUR_NUL_P(b); b = b->succ) {
180  nv = variable_name(v);
181  nb = variable_name(vecteur_var(b));
182  equal = !strcmp(nv, nb);
183  if(equal)
184  break;
185  }
186 
188 }
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73

References variable_name(), VARIABLE_UNDEFINED, VECTEUR_NUL_P, and vecteur_var.

Referenced by sc_variables_rename(), vect_rename(), and vect_translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_find_variable_rank()

int base_find_variable_rank ( Pbase  b,
Variable  v,
char * (*)(Variable variable_name 
)

int base_find_variable_rank(Pbase b, Variable v, char * (*variable_name)()): returns variable v's rank if it is in basis b, else -1

Definition at line 194 of file base.c.

198 {
199  char * nv;
200  char * nb;
201  bool equal;
202  int rank;
203 
204  for(rank=1; !VECTEUR_NUL_P(b); b = b->succ, rank++) {
205  nv = variable_name(v);
206  nb = variable_name(vecteur_var(b));
207  equal = !strcmp(nv, nb);
208  if(equal)
209  break;
210  }
211 
212  return VECTEUR_NUL_P(b)? -1 : rank;
213 }
static entity rank

References rank, variable_name(), VECTEUR_NUL_P, and vecteur_var.

Referenced by egalites_to_matrice(), make_bound_expression(), and vect_change_base().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_included_p()

bool base_included_p ( Pbase  b1,
Pbase  b2 
)

Pbase base_included_p(Pbase b1, Pbase b2): include_p = b1 is included in b2 – with the set meaning return b;.

Parameters
b11
b22

Definition at line 640 of file base.c.

641 {
642  Pbase b;
643  bool included_p = true;
645 
646  for (b=b2; b; b=b->succ)
647  if (var_of(b)!=TCST)
649 
650  for (b=b1; b && included_p; b=b->succ)
651  if (var_of(b)!=TCST && !linear_hashtable_isin(seen, var_of(b)))
652  included_p = false;
653 
655 
656  return included_p;
657 }

References b1, b2, linear_hashtable_free(), linear_hashtable_isin(), linear_hashtable_make(), linear_hashtable_put_once(), seen, Svecteur::succ, TCST, and var_of.

Referenced by sc_weak_consistent_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_intersection()

Pbase base_intersection ( Pbase  b1,
Pbase  b2 
)

Return variables/dimensions present in bases b1 and b2.

Order is not preserved.

Parameters
b11
b22

Definition at line 473 of file base.c.

474 {
475  Pbase b = BASE_NULLE;
476  bool
477  bn1 = BASE_NULLE_P(b1),
478  bn2 = BASE_NULLE_P(b2);
479 
480  if(!bn1 && !bn2) {
481  Pbase bc;
482  for(bc=b1; !BASE_UNDEFINED_P(bc); bc = vecteur_succ(bc)) {
483  Variable var = vecteur_var(bc);
484  if(base_contains_variable_p(b2, var)) {
485  b = base_add_variable(b, var);
486  }
487  }
488  }
489 
490  return b;
491 }
Pbase base_add_variable(Pbase b, Variable var)
Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end...
Definition: base.c:88
#define BASE_UNDEFINED_P(b)
#define vecteur_succ(v)

References b1, b2, base_add_variable(), base_contains_variable_p(), BASE_NULLE, BASE_NULLE_P, BASE_UNDEFINED_P, vecteur_succ, and vecteur_var.

Referenced by sc_projection_optim_along_vecteur_ofl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_normalize()

Pbase base_normalize ( Pbase  b)

Definition at line 594 of file base.c.

596 {
597  Pbase eb;
598 
599  for (eb = b ; !BASE_NULLE_P(eb) ; eb=eb->succ)
600  vecteur_val(eb) = VALUE_ONE;
601  return b;
602 }
#define vecteur_val(v)

References BASE_NULLE_P, Svecteur::succ, VALUE_ONE, and vecteur_val.

Referenced by pip_solve(), pip_solve_min_with_big(), set_sort_context(), and vars_read_and_written().

+ Here is the caller graph for this function:

◆ base_normalized_p()

bool base_normalized_p ( Pbase  b)

Definition at line 604 of file base.c.

606 {
607  Pbase eb;
608 
609  for (eb = b ;
610  !BASE_NULLE_P(eb) && value_one_p(vecteur_val(eb));
611  eb=eb->succ)
612  ;
613  return BASE_NULLE_P(eb) && vect_check((Pvecteur) b);
614 }
#define value_one_p(val)
bool vect_check(Pvecteur cv)
bool vect_check(Pvecteur v): renvoie true si le vecteur v est coherent avec les specifications du pac...
Definition: reductions.c:529

References BASE_NULLE_P, Svecteur::succ, value_one_p, vect_check(), and vecteur_val.

Referenced by sc_consistent_p(), and sc_weak_consistent_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_remove_variable()

Pbase base_remove_variable ( Pbase  b,
Variable  v 
)

Pbase base_remove_variable(b, v): remove basis vector relative to v from b; abort if v is not in b;.

Definition at line 122 of file base.c.

125 {
127  vect_erase_var(&b, v);
128  return b;
129 }
#define assert(ex)
Definition: newgen_assert.h:41
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106

References assert, base_contains_variable_p(), and vect_erase_var().

Referenced by main(), sc_base_remove_variable(), transformer_derivative_fix_point(), and transformer_list_generic_transitive_closure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_reversal()

Pbase base_reversal ( Pbase  b_in)

Pbase base_reversal(Pbase b_in): produces a basis b_out, having the same basis vectors as b_in, but in reverse order.

Basis b_in is not touched.

Example: b_in = { e1, e2, e3 } -> b_out = { e3, e2, e1}

Parameters
b_in_in

Definition at line 221 of file base.c.

223 {
224  Pbase b_out = VECTEUR_NUL;
225 
226  for( ; !VECTEUR_NUL_P(b_in); b_in = b_in->succ)
227  vect_add_elem(&b_out, vecteur_var(b_in), vecteur_val(b_in));
228 
229  return b_out;
230 }
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References vect_add_elem(), VECTEUR_NUL, VECTEUR_NUL_P, vecteur_val, and vecteur_var.

Referenced by adg_sc_dup(), algorithm_row_echelon_generic(), build_image_base(), code_generation(), compute_iteration_domain(), create_tile_basis(), derive_new_basis(), list_to_base(), loop_nest_to_wp65_code(), matrices_to_loop_sc(), matrices_to_sc(), parallel_tiling(), sc_projection_concat_proj_on_variables(), set_sort_context(), and tiling_transformation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ base_union()

Pbase base_union ( Pbase  b1,
Pbase  b2 
)

Pbase base_union(Pbase b1, Pbase b2): compute a new basis containing all elements of b1 and all elements of b2, in an unkown order.

b := b1 u b2; return b;

Bases b1 and b2 are not modified. Basis vectors are compared for equality using variable_equal()

Modifications:

  • Pbase b = (Pbase)vect_add((Pvecteur) b1, (Pvecteur) b2); This is the definition of b at the beginning. This ignored one case that when addition of two values is zero, vect_add will call vect_add_elem, where there is vect_erase_var. We'll miss the variable Lei Zhou. 15/07/91
Parameters
b11
b22

Definition at line 428 of file base.c.

429 {
430  Pbase b = BASE_NULLE;
431  bool
432  bn1 = BASE_NULLE_P(b1),
433  bn2 = BASE_NULLE_P(b2);
434 
435  if (!bn1 && bn2)
436  b = base_copy(b1);
437  else if (bn1 && !bn2)
438  b = base_copy(b2);
439  else if (!bn1 && !bn2)
440  {
442  Pvecteur v;
443  Variable var;
444 
445  for (v = b1; v; v=v->succ)
446  {
447  var = var_of(v);
448  if (var!=TCST)
449  {
450  linear_hashtable_put_once(seen, var, var);
451  b = vect_chain(b, var, VALUE_ONE);
452  }
453  }
454 
455  for (v = b2; v; v=v->succ)
456  {
457  var = var_of(v);
458  if (var!=TCST)
459  if (!linear_hashtable_isin(seen, var))
460  {
461  linear_hashtable_put_once(seen, var, var);
462  b = vect_chain(b, var, VALUE_ONE);
463  }
464  }
465 
467  }
468 
469  return b;
470 }

References b1, b2, base_copy(), BASE_NULLE, BASE_NULLE_P, linear_hashtable_free(), linear_hashtable_isin(), linear_hashtable_make(), linear_hashtable_put_once(), seen, Svecteur::succ, TCST, VALUE_ONE, var_of, and vect_chain().

Referenced by actual_convex_union(), elementary_convex_union(), gcd_and_constant_dependence_test(), is_inferior_monome(), matrices_to_constraints_with_sym_cst(), matrices_to_contraintes_with_sym_cst(), pip_solve(), pip_solve_min_with_big(), polynome_used_var(), regions_must_convex_hull(), sc_constraint_add(), sc_cute_convex_hull(), sc_elim_redund_with_first_ofl_ctrl(), sg_union(), simplify_float_constraint_system(), sl_fprint_tab(), transformer_add_loop_index_initialization(), transformer_convex_hulls(), and transformer_list_generic_transitive_closure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bases_strictly_equal_p()

bool bases_strictly_equal_p ( Pbase  b1,
Pbase  b2 
)

Make sure that each dimension of b1 is the same dimension in b2.

Parameters
b11
b22

Definition at line 660 of file base.c.

661 {
662  int s1 = base_dimension(b1);
663  int s2 = base_dimension(b2);
664  bool strictly_equal_p = true;
665 
666  if(s1==s2) {
667  int i;
668  for(i=1; i<= s1 && strictly_equal_p; i++) {
669  Variable d1 = variable_of_rank(b1, i);
670  Variable d2 = variable_of_rank(b2, i);
671  strictly_equal_p = (d1==d2);
672  }
673  }
674  else
675  strictly_equal_p = false;
676 
677  return strictly_equal_p;
678 }
Variable variable_of_rank(Pbase base, int rank)
Variable variable_of_rank(): this function returns the variable of rank "rank".
Definition: base.c:520
s1
Definition: set.c:247
#define base_dimension(b)

References b1, b2, base_dimension, s1, and variable_of_rank().

Referenced by sc_union().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_base_from_vect()

Pbase make_base_from_vect ( Pvecteur  pv)
Parameters
pvv

Definition at line 109 of file base.c.

110 {
111  Pbase b = (Pbase) NULL;
112  for(;!VECTEUR_NUL_P(pv);pv=pv->succ)
113  if (pv->var != TCST)
114  b = base_add_variable(b,pv->var);
115  return(b);
116 }
Variable var
Definition: vecteur-local.h:90
struct Svecteur * Pbase

References base_add_variable(), Svecteur::succ, TCST, Svecteur::var, and VECTEUR_NUL_P.

Referenced by efficient_sc_check_inequality_feasibility(), sc_normalize2(), and transformer_add_loop_index_initialization().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rank_of_variable()

int rank_of_variable ( Pbase  base,
Variable  var 
)

this function returns the rank of the variable var in the base 0 encodes TCST, but I do not know why, TCST may be in base, sometimes -1 encodes an error

not found

Parameters
basease
varar

Definition at line 497 of file base.c.

500 {
501  int rank=1;
502  register Pvecteur pv;
503 
504  if (var!=TCST)
505  {
506  for(pv=base;
507  !VECTEUR_NUL_P(pv) && !(vecteur_var(pv) ==var);
508  pv=pv->succ, rank++);
509  if (VECTEUR_NUL_P(pv)) rank = -1; /* not found */
510  }
511  else
512  rank = 0;
513 
514  return(rank);
515 }
bdt base
Current expression.
Definition: bdt_read_paf.c:100

References base, rank, Svecteur::succ, TCST, VECTEUR_NUL_P, and vecteur_var.

Referenced by bound_generation(), build_transfer_matrix(), compare_variables_in_base(), constraint_distribution(), constraint_integer_combination(), contrainte_extract(), reference_conversion_computation(), reference_conversion_expression(), reference_translation(), sc_elim_triang_integer_redund_constraint_p(), sc_integer_projection_information(), sc_normalize2(), search_higher_rank(), search_var_of_higher_rank(), and transformer_to_1D_lattice().

+ Here is the caller graph for this function:

◆ search_higher_rank()

int search_higher_rank ( Pvecteur  vect,
Pbase  base 
)

int search_higher_rank(): this fonction returns the rank of the variable of higher rank in the vecteur

Parameters
vectect
basease

Definition at line 541 of file base.c.

544 {
545  int rank_pv = 0;
546  int rv=0;
547  register Pvecteur pv;
548 
549  for (pv=vect;!VECTEUR_NUL_P(pv);pv=pv->succ){
550  if ((rv =rank_of_variable(base,vecteur_var(pv))) > rank_pv)
551  rank_pv = rv;
552  }
553  return(rank_pv);
554 }
int rank_of_variable(Pbase base, Variable var)
this function returns the rank of the variable var in the base 0 encodes TCST, but I do not know why,...
Definition: base.c:497

References base, rank_of_variable(), Svecteur::succ, VECTEUR_NUL_P, and vecteur_var.

Referenced by bound_distribution(), build_integer_sc_nredund(), constraint_distribution(), contrainte_extract(), egalite_distribution(), elim_redund_sc_with_sc(), lower_bound_generation(), sc_integer_projection_information(), test_bound_generation(), and upper_bound_generation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search_i_element()

Pvecteur search_i_element ( Pbase  b,
int  i 
)

Pvecteur search_i_element(): recherche du i-ieme couple (var,val) dans la Pbase b.

Definition at line 583 of file base.c.

586 {
587  Pbase b1;
588  int j;
589 
590  for (b1=b, j=1; j<i; b1=b1->succ,j++);
591  return(b1);
592 }

References b1.

◆ search_var_of_higher_rank()

Variable search_var_of_higher_rank ( Pvecteur  pvect,
Pbase  base,
Variable  var 
)

this function returns the variable of higher rank, after the variable var, in the vecteur pvect

Parameters
pvectvect
basease
varar

Definition at line 561 of file base.c.

565 {
566  int rv,rank_pv = 0;
567  Variable higher_var=TCST;
568  register Pvecteur pv;
569 
570  for (pv=pvect;!VECTEUR_NUL_P(pv);pv=pv->succ)
571  if ((vecteur_var(pv) != var)
572  && ((rv =rank_of_variable(base,vecteur_var(pv))) > rank_pv)) {
573  rank_pv = rv;
574  higher_var = vecteur_var(pv);
575  }
576 
577  return(higher_var);
578 }

References base, rank_of_variable(), Svecteur::succ, TCST, VECTEUR_NUL_P, and vecteur_var.

+ Here is the call graph for this function:

◆ variable_of_rank()

Variable variable_of_rank ( Pbase  base,
int  rank 
)

Variable variable_of_rank(): this function returns the variable of rank "rank".

Parameters
basease
rankank

Definition at line 520 of file base.c.

523 {
524  int i;
525  register Pvecteur pv;
526 
527  if (rank ==0) return(TCST);
528  else {
529  for(pv=base, i=1;
530  !VECTEUR_NUL_P(pv) && i != rank; pv=pv->succ, i++);
531  if (!VECTEUR_NUL_P(pv))
532  return(vecteur_var(pv));
533  else return (TCST);
534  }
535 }

References base, rank, Svecteur::succ, TCST, VECTEUR_NUL_P, and vecteur_var.

Referenced by bases_strictly_equal_p().

+ Here is the caller graph for this function:

◆ vect_add_variable()

Pbase vect_add_variable ( Pbase  b,
Variable  v 
)

package vecteur - routines sur les bases

base.c

Francois Irigoin

The function variable_name should be inlined as much as possible to improve performances. It has to be used to be generic over the "Variable" type. For instance, variables represented by a character string cannot be decided equal by a simple pointer comparison.

Modifications: INTLIBRARY Pbase vect_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b; if variable v is already in basis b, do nothing; this is not clean but convenient to avoid a test;

Note that basis b contains a pointer towards variable v and not a copy of it. So some sharing is introduced.

A routine to check variable equality, variable_equal(), is used.

Definition at line 61 of file base.c.

64 {
65  Pbase b1 = b;
66 
67  for(; !VECTEUR_NUL_P(b1) && !variable_equal(vecteur_var(b1), v);
68  b1 = b1->succ)
69  ;
70 
71  if(b1 == VECTEUR_NUL) {
72  base_add_dimension(&b,v);
73  }
74 
75  return(b);
76 }
#define base_add_dimension(b, v)

References b1, base_add_dimension, variable_equal(), VECTEUR_NUL, VECTEUR_NUL_P, and vecteur_var.

Referenced by add_var_sup(), args_to_transformer(), base_difference(), build_sc_machine(), build_sc_with_several_uniform_ref(), create_tile_basis(), equations_to_bases(), filter_transformer(), loop_bounds_to_tile_bounds(), loop_index_domaine_to_contrainte(), MakeDibaseinorder(), module_to_wp65_modules(), new_ident(), sc_add_new_variable_name(), set_dimensions_of_local_variable_family(), transformer_add_modified_variable(), transformer_add_modified_variable_entity(), transformer_add_variable_incrementation(), var_ecart_sup(), and vect_read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_in_basis_p()

bool vect_in_basis_p ( Pvecteur  v,
Pbase  b 
)

Pvecteur vect_in_basis_p(Pvecteur v, Pbase b): check that all coordinates in v are in b, i.e.

vector v is a membre of the space generated by b

Bugs:

  • TCST and VARIABLE_UNDEFINED are equal; a dirty test is performed to screen TCST terms; on top of that, the special variable TCST is not kept in bases!

I do not know what should be done for constant terms...

Definition at line 342 of file base.c.

345 {
346  Pvecteur coord;
347 
348  for(coord = v; !VECTEUR_NUL_P(coord); coord = coord->succ) {
349 
350  if(VARIABLE_DEFINED_P(vecteur_var(coord))) {
351  if(!base_contains_variable_p(b, vecteur_var(coord))) {
352  return(false);
353  }
354  }
355  else {
356  /* I do not know what should be done for constant terms... */
357  abort();
358  }
359  }
360  return true;
361 }
#define abort()
Definition: misc-local.h:53
#define VARIABLE_DEFINED_P(v)
Definition: vecteur-local.h:66

References abort, base_contains_variable_p(), Svecteur::succ, VARIABLE_DEFINED_P, VECTEUR_NUL_P, and vecteur_var.

Referenced by algorithm_row_echelon_generic(), gcd_and_constant_dependence_test(), legal_point_p(), print_cone_vecteur(), and vect_fprint_as_dense().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_rename()

Pvecteur vect_rename ( Pvecteur  v,
Pbase  b,
char * (*)(Variable variable_name 
)

Pvecteur vect_rename(Pvecteur v, Pbase b, char * (*variable_name)()): modify vector v so that its coordinates are relative to basis b; each basis vector is defined by a pointer of type Variable, but different pointers can point to the same basis vector wrt variable_name; these pointers are unified with respect to b and variable_name to let us perform eq-type comparison in the library.

This function is identical to vect_translate, except that if a variable var of v does not appear in b, then the assert is not executed.

Bugs:

  • TCST and VARIABLE_UNDEFINED are equal; a dirty test is performed to screen TCST terms; on top of that, the special variable TCST is not kept in bases!

Definition at line 247 of file base.c.

251 {
252  Pvecteur coord;
253 
254  for(coord = v; !VECTEUR_NUL_P(coord); coord = coord->succ) {
255  Variable var;
256 
257  if(VARIABLE_DEFINED_P(vecteur_var(coord))) {
258  var = base_find_variable_name(b, vecteur_var(coord),
259  variable_name);
260  if (!VARIABLE_UNDEFINED_P(var))
261  vecteur_var(coord) = var;
262  }
263  }
264  return v;
265 }
Variable base_find_variable_name(Pbase b, Variable v, char *(*variable_name)(Variable))
Variable base_find_variable_name(Pbase b, Variable v, char * (*variable_name)()): returns the variabl...
Definition: base.c:170
#define VARIABLE_UNDEFINED_P(v)
Definition: vecteur-local.h:65

References base_find_variable_name(), Svecteur::succ, VARIABLE_DEFINED_P, variable_name(), VARIABLE_UNDEFINED_P, VECTEUR_NUL_P, and vecteur_var.

Referenced by movement_computation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_rename_variables()

Pvecteur vect_rename_variables ( Pvecteur  v,
bool(*)(Variable renamed_p,
Variable(*)(Variable new_variable 
)

Pvecteur vect_rename_variables(v, renamed_p, new_variable) Pvecteur v; bool (*renamed_p)(Variable); Variable (*new_variable)(Variable);.

what: driven renaming of variables in v. how: scans the vector, decides and replaces. input: Pvecteur v, decision and replacement functions. output: v is returned (the same) side effects:

  • the vector is modified in place. bugs or features:
  • was written by FC...

initial vector is kept

ar!=TCST &&

Definition at line 281 of file base.c.

285 {
286  Pvecteur i=v; /* initial vector is kept */
287  Variable var;
288 
289  for(; v!=NULL; v=v->succ)
290  {
291  var = var_of(v);
292  // FI: more flexible if TCST is not tested here, but the lack
293  // of lamdba expression may require a new function for
294  // renamed_p()
295  if (/*var!=TCST &&*/ renamed_p(var)) var_of(v)=new_variable(var);
296  }
297 
298  return(i);
299 }
static entity new_variable
entity to be replaced, the primary?
Definition: dynamic.c:860

References new_variable, Svecteur::succ, and var_of.

Referenced by sc_rename_variables(), and vect_variables_to_values().

+ Here is the caller graph for this function:

◆ vect_translate()

Pvecteur vect_translate ( Pvecteur  v,
Pbase  b,
char * (*)(Variable variable_name 
)

Pvecteur vect_translate(Pvecteur v, Pbase b, char * (*variable_name)()): modify vector v so that its coordinates are relative to basis b; each basis vector is defined by a pointer of type Variable, but different pointers can point to the same basis vector wrt variable_name; these pointers are unified with respect to b and variable_name to let us perform eq-type comparison in the library.

Bugs:

  • TCST and VARIABLE_UNDEFINED are equal; a dirty test is performed to screen TCST terms; on top of that, the special variable TCST is not kept in bases!

Definition at line 313 of file base.c.

317 {
318  Pvecteur coord;
319 
320  for(coord = v; !VECTEUR_NUL_P(coord); coord = coord->succ) {
321  Variable var;
322 
323  if(VARIABLE_DEFINED_P(vecteur_var(coord))) {
324  var = base_find_variable_name(b, vecteur_var(coord),
325  variable_name);
327  vecteur_var(coord) = var;
328  }
329  }
330  return v;
331 }

References assert, base_find_variable_name(), Svecteur::succ, VARIABLE_DEFINED_P, variable_name(), VARIABLE_UNDEFINED_P, VECTEUR_NUL_P, and vecteur_var.

Referenced by contrainte_translate(), and sc_translate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_variable_rename()

Pvecteur vect_variable_rename ( Pvecteur  v,
Variable  v_old,
Variable  v_new 
)

Pvecteur vect_variable_rename(Pvecteur v, Variable v_old, Variable v_new): rename the potential coordinate v_old in v as v_new.

Parameters
v_old_old
v_new_new

Definition at line 366 of file base.c.

370 {
371  Pvecteur coord;
372 
373  for(coord = v; !VECTEUR_NUL_P(coord); coord = coord->succ) {
374  Variable var = vecteur_var(coord);
375 
376  if(var==v_old)
377  vecteur_var(coord) = v_new;
378  }
379  return v;
380 }

References Svecteur::succ, VECTEUR_NUL_P, and vecteur_var.

Referenced by affine_to_transformer(), contrainte_variable_rename(), sc_variable_rename(), upwards_vect_rename(), and variables_to_new_values().

+ Here is the caller graph for this function: