/* Returns the sign of the affine function specified by T on the polyhedron D */
enum order_sign PL_polyhedron_affine_sign(Polyhedron *D, Matrix *T,
					    struct barvinok_options *options)
{
    enum order_sign sign;
    Polyhedron *I = Polyhedron_Image(D, T, options->MaxRays);
    if (POL_ISSET(options->MaxRays, POL_INTEGER))
	I = DomainConstraintSimplify(I, options->MaxRays);
    if (emptyQ2(I)) {
	Polyhedron_Free(I);
	I = Polyhedron_Image(D, T, options->MaxRays);
    }
    sign = interval_minmax(I);
    Polyhedron_Free(I);
    return sign;
}
Esempio n. 2
0
/*
 * Image: if cst is a list of constraints, just its first element's image
 * is taken.
 */
PlutoConstraints *pluto_constraints_image(const PlutoConstraints *cst, const PlutoMatrix *func)
{
    // IF_DEBUG(printf("pluto const image: domain\n"););
    // IF_DEBUG(pluto_constraints_print(stdout, cst););
    // IF_DEBUG(printf("pluto const image: func\n"););
    // IF_DEBUG(pluto_matrix_print(stdout, func););
    assert(func->ncols == cst->ncols);

    PlutoConstraints *imagecst;

    Polyhedron *pol = pluto_constraints_to_polylib(cst);
    Matrix *polymat = pluto_matrix_to_polylib(func);

    // Polyhedron_Print(stdout, "%4d", pol);
    Polyhedron *image = Polyhedron_Image(pol, polymat, 2*cst->nrows);

    // Polyhedron_Print(stdout, "%4d ",  image);
    imagecst = polylib_to_pluto_constraints(image);

    Matrix_Free(polymat);
    Domain_Free(pol);
    Polyhedron_Free(image);

    // IF_DEBUG(printf("pluto const image is\n"););
    // IF_DEBUG(pluto_constraints_print(stdout, imagecst););

    return imagecst;
}
Esempio n. 3
0
int main(int argc,char *argv[]) {
	
  Matrix *C1, *P1;
  Polyhedron *C, *P, *S;
  Polyhedron *CC, *PP;
  Enumeration *en;
  Value *p;
  int i,j,k;
  int m,M;
  char str[1024];
  Value c;

  /******* Read the input *********/
  P1 = Matrix_Read();
  C1 = Matrix_Read();
  if(C1->NbColumns < 2) {
    fprintf(stderr,"Not enough parameters !\n");
    exit(0);
  }
  P = Constraints2Polyhedron(P1, MAXRAYS);
  C = Constraints2Polyhedron(C1, MAXRAYS);
  Matrix_Free(C1);
  Matrix_Free(P1);
  
  
  /******* Compute the true context *******/
  CC = align_context(C,P->Dimension,MAXRAYS);
  PP = DomainIntersection(P,CC,MAXRAYS);
  Domain_Free(CC);
  C1 = Matrix_Alloc(C->Dimension+1,P->Dimension+1);
  for(i=0;i<C1->NbRows;i++)
    for(j=0;j<C1->NbColumns;j++)
      if(i==j-P->Dimension+C->Dimension)
	value_set_si(C1->p[i][j],1);
      else
	value_set_si(C1->p[i][j],0);
  CC = Polyhedron_Image(PP,C1,MAXRAYS);
  Domain_Free(C);
  Domain_Free(PP);
  Matrix_Free(C1);
  C = CC;
  
  /******* Initialize parameters *********/
  p = (Value *)malloc(sizeof(Value) * (P->Dimension+2));
  for(i=0;i<=P->Dimension;i++) {
    value_init(p[i]);
    value_set_si(p[i],0);
  }
  value_init(p[i]);
  value_set_si(p[i],1);
  
  /*** S = scanning list of polyhedra ***/
  S = Polyhedron_Scan(P,C,MAXRAYS);

  value_init(c);
  
  /******* Count now *********/
  FOREVER {
    fflush(stdin);
    printf("Enter %d parameters : ",C->Dimension);
    for(k=S->Dimension-C->Dimension+1;k<=S->Dimension;++k) {
      scanf(" %s", str);
      value_read(p[k],str);
    }      
    printf("EP( ");
    value_print(stdout,VALUE_FMT,p[S->Dimension-C->Dimension+1]);
    for(k=S->Dimension-C->Dimension+2;k<=S->Dimension;++k) {
      printf(", ");
      value_print(stdout,VALUE_FMT,p[k]);
    }  
    printf(" ) = "); 
    count_points(1,S,p,&c);
    value_print(stdout,VALUE_FMT,c);
    printf("\n"); 
  }
  for(i=0;i<=(P->Dimension+1);i++)
    value_clear(p[i]);
  value_clear(c);
  return(0);
} /* main */