PIPS
time_sg_union.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "boolean.h"
#include "arithmetique.h"
#include "linear_assert.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sc.h"
#include "sg.h"
#include "types.h"
#include "polyedre.h"
+ Include dependency graph for time_sg_union.c:

Go to the source code of this file.

Functions

int fprintf ()
 
int printf ()
 
char * strdup ()
 
 main (int argc, char **argv)
 

Function Documentation

◆ fprintf()

int fprintf ( )

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

main ( int  argc,
char **  argv 
)

lecture du premier systeme

lecture du deuxieme systeme

Homogeneiser les bases des systemes

conversion en systemes generateurs

printf("systemes initiaux \n"); sc_dump(sc1); sc_dump(sc2);

calcul de l'enveloppe convexe

rintf("union des systemes generateurs\n"); sg_fprint(stdout,sg,variable_dump_name);

printf("systeme final \n"); sc_dump(s);

Definition at line 51 of file time_sg_union.c.

54 {
55  FILE * f1;
56  FILE * f2;
57  char * filename = "stdin";
58  Psysteme sc1=sc_new();
59  Psysteme sc2=sc_new();
60  Psysteme sc=sc_new();
61  Ptsg sg = sg_new();
62  Ptsg sg1 = sg_new();
63  Ptsg sg2 = sg_new();
64 
65  if(argc!=3) {
66  fprintf(stdout,"Usage: %s sc1 sc2\n",argv[0]);
67  exit(1);
68  }
69 
70  if((f1 = fopen(argv[1],"r")) == NULL) {
71  fprintf(stdout,"Ouverture du fichier %s impossible\n",
72  argv[1]);
73  exit(4);
74  }
75 
76  if((f2 = fopen(argv[2],"r")) == NULL) {
77  fprintf(stdout,"Ouverture du fichier %s impossible\n",
78  argv[2]);
79  exit(4);
80  }
81 
82  /* lecture du premier systeme */
83  if(sc_fscan(f1,&sc1)) {
84  fprintf(stderr,"syntaxe correcte dans %s\n",argv[1]);
85  sc_fprint(stdout, sc1, *variable_default_name);
86  }
87  else {
88  fprintf(stderr,"erreur de syntaxe dans %s\n",argv[1]);
89  exit(1);
90  }
91 
92  /* lecture du deuxieme systeme */
93  if(sc_fscan(f2,&sc2)) {
94  fprintf(stderr,"syntaxe correcte dans %s\n",argv[2]);
95  sc_fprint(stdout, sc2, *variable_default_name);
96  }
97  else {
98  fprintf(stderr,"erreur de syntaxe dans %s\n",argv[2]);
99  exit(1);
100  }
101 
102  /* Homogeneiser les bases des systemes */
103  assert(vect_size(sc1->base) == vect_size(sc2->base));
104  sc2 = sc_translate(sc2,sc1->base, *variable_default_name);
105 
106  assert(!SC_UNDEFINED_P(sc1) && !SC_UNDEFINED_P(sc2));
107 
108  if (SC_RN_P(sc2) || sc_rn_p(sc2) || sc_dimension(sc2)==0
109  || sc_empty_p(sc1) || !sc_faisabilite(sc1)) {
110  Psysteme sc3 = sc_dup(sc2);
111  sc3 = sc_elim_redond(sc3);
112  sc = (SC_UNDEFINED_P(sc3)) ? sc_empty(base_dup(sc_base(sc2))) : sc3;
113  }
114  else if (SC_RN_P(sc1) ||sc_rn_p(sc1) || sc_dimension(sc1)==0
115  || sc_empty_p(sc2) || !sc_faisabilite(sc2)) {
116  Psysteme sc4 = sc_dup(sc1);
117  sc4 = sc_elim_redond(sc4);
118  sc = (SC_UNDEFINED_P(sc4)) ? sc_empty(base_dup(sc_base(sc1))) : sc4;
119  }
120  else {
121  /* conversion en systemes generateurs */
122  /* printf("systemes initiaux \n");
123  sc_dump(sc1);
124  sc_dump(sc2); */
125  sg1 = sc_to_sg_chernikova(sc1);
126  sg2 = sc_to_sg_chernikova(sc2);
127 
128  /* calcul de l'enveloppe convexe */
129  sg = sg_union(sg1, sg2);
130  /*printf("union des systemes generateurs\n");
131  sg_fprint(stdout,sg,variable_dump_name);
132  */
133  sc = sg_to_sc_chernikova(sg);
134  /* printf("systeme final \n");
135  sc_dump(s); */
136  }
137 
138  printf("systeme correspondant \n");
139  sc_fprint(stdout, sc, *variable_default_name);
140 } /* main */
Psysteme sg_to_sc_chernikova(Ptsg sg)
Definition: chernikova.c:58
Ptsg sc_to_sg_chernikova(Psysteme sc)
chernikova_mulprec.c
Definition: chernikova.c:42
Ptsg sg
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
char * variable_default_name(Variable v)
char * variable_default_name(Variable v): returns the name of variable v
Definition: variable.c:81
#define exit(code)
Definition: misc-local.h:54
#define assert(ex)
Definition: newgen_assert.h:41
int f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
Psysteme sc_translate(Psysteme s, Pbase b, char *(*variable_name)())
Psysteme sc_translate(Psysteme s, Pbase b, char * (*variable_name)()): reecriture du systeme s dans l...
Definition: sc.c:99
bool sc_rn_p(Psysteme sc)
bool sc_rn_p(Psysteme sc): check if the set associated to sc is the whole space, rn
Definition: sc_alloc.c:369
Psysteme sc_empty(Pbase b)
Psysteme sc_empty(Pbase b): build a Psysteme with one unfeasible constraint to define the empty subsp...
Definition: sc_alloc.c:319
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
bool sc_empty_p(Psysteme sc)
bool sc_empty_p(Psysteme sc): check if the set associated to sc is the constant sc_empty or not.
Definition: sc_alloc.c:350
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
bool sc_fscan(FILE *f, Psysteme *ps)
bool sc_fscan(FILE * f, Psysteme * ps): construit un systeme d'inegalites et d'egalites lineaires a p...
Definition: sc_io.c:121
Ptsg sg_new()
Ptsg sg_new(): allocation d'un systeme generateur et initialisation a la valeur ensemble vide.
Definition: sg.c:55
Ptsg sg_union(Ptsg sg1, Ptsg sg2)
Definition: sg.c:552
Pbase base
Definition: sc-local.h:75
Representation d'un systeme generateur par trois ensembles de sommets de rayons et de droites.
Definition: sg-local.h:66
int fprintf()
int printf()
Pbase base_dup(Pbase b)
Pbase base_dup(Pbase b) Note: this function changes the value of the pointer.
Definition: alloc.c:268

References assert, Ssysteme::base, base_dup(), exit, f2(), fprintf(), printf(), sc_dup(), sc_empty(), sc_empty_p(), sc_fprint(), sc_fscan(), sc_new(), sc_rn_p(), sc_to_sg_chernikova(), sc_translate(), sg, sg_new(), sg_to_sc_chernikova(), sg_union(), variable_default_name(), and vect_size().

+ Here is the call graph for this function:

◆ printf()

int printf ( )

Referenced by main().

+ Here is the caller graph for this function:

◆ strdup()

char* strdup ( )