void valid_ints( int eqdimpar, RAT *eqarpar, int neqpar,int eqrlpar, int iedimpar, RAT *iearpar, int niepar, int ierlpar, char *fname ) { RAT *eqsum = (RAT *)0; RAT *iesum = (RAT *)0; fprintf (prt,"computing all valid integral points "); fflush(prt); /* 17.01.1994: include logging on file porta.log */ porta_log( "computing all valid integral points "); fflush(logfile); if (!lowbds || !upbds) msg( "\nno bounds are given", "", 0 ); for (eqdim = 0 ; eqdim < eqdimpar; eqdim++) if (lowbds[eqdim] > upbds[eqdim]) msg("lower bound greater than upper bound", "", 0); neq = neqpar; eqdim = eqdimpar; eqar = eqarpar; eqrl = eqrlpar; ubea = eqar+neq*eqrl; nie = niepar; iedim = iedimpar; iear = iearpar; ierl = ierlpar; ubia = iear+nie*ierl; fname[strlen(fname)-4] = '\0'; strcat(fname,".poi"); fp = wfopen(fname); fprintf(fp,"DIM =%3d\n\nCONV_SECTION\n",dim); integ = (int *) allo(integ,0,eqdim*sizeof(int)); reknum = intnum = 0; eqsum = (RAT *) RATallo(eqsum,0,(1+neq)*(eqdim+1)); iesum = (RAT *) RATallo(iesum,0,(1+nie)*(iedim+1)); integ_rekurs(eqsum,iesum,0); #if defined WIN32 || defined __CYGWIN32__ || defined __APPLE__ free(integ); #else // WIN32 cfree(integ); #endif // WIN32 fprintf(fp,"\nEND\n"); fclose(fp); fprintf(prt,"\n\nnumber of valid integral points : %i\n\n",intnum); fprintf(prt,"integral points written to file %s\n",fname); /* 17.01.1994: include logging on file porta.log */ porta_log( "\n\nnumber of valid integral points : %i\n\n",intnum); porta_log( "integral points written to file %s\n",fname); }
void write_ieq_file( char *fname, FILE *fp, int equa, int feq, int eqrl, int *eqindx, int ineq, int fie, int ierl, int *ieindx ) { char filename[100]; int i, start; fprintf(prt,"\nnumber of equations : %4i \n",equa); fprintf(prt,"number of inequalities : %4i \n\n",ineq); /* 17.01.1994: include logging on file porta.log */ porta_log( "\nnumber of equations : %4i \n",equa); porta_log( "number of inequalities : %4i \n\n",ineq); strcpy(filename,fname); strcat(filename,".ieq"); if (!fp) { fp = wfopen(filename); fprintf(fp, "DIM = %d\n\n",dim); if (is_set(Traf) ) { fprintf(fp, "VALID\n"); for (i = 0; i< dim; i++) { fprintf(fp, "%ld", ar6[i].num); if (ar6[i].den.i > 1) fprintf(fp, "/%i ", ar6[i].den.i); else fprintf(fp, " "); } fprintf(fp, "\n\n"); } } fprintf(fp, "INEQUALITIES_SECTION\n"); start=1; if (equa) { writesys(fp,feq,feq+equa,eqrl,0,eqindx,'=',&start); fprintf(fp,"\n"); } start=1; if (ineq) writesys(fp,fie,fie+ineq,ierl,0,ieindx,'<',&start); fprintf(fp,"\n"); fprintf(fp, "END\n"); if (is_set(Validity_table_out)) writepoionie(fp,fie,fie+ineq,points,0); fclose(fp); fprintf(prt,"output written to file %s\n\n",filename); /* 17.01.1994: include logging on file porta.log */ porta_log( "output written to file %s\n\n",filename); }
FILE *wfopen( char *fname ) { struct stat statbuf; char command[BUFSIZ]; if( !stat(fname,&statbuf) ) { #if defined WIN32 if( fname[0] == '\\' ) { fprintf( prt, "cannot make bakup file of old %s\n", fname ); porta_log( "cannot make bakup file of old %s\n", fname ); } else { fprintf(prt,"%s moved into %s.bak\n", fname, fname ); porta_log( "%s moved into %s.bak\n", fname, fname ); sprintf( command, "%s.bak", fname ); if( !stat( command, &statbuf ) ) { sprintf( command, "del %s.bak", fname ); system( command ); } sprintf( command, "ren %s %s.bak", fname, fname ); system( command ); } #else // WIN32 fprintf(prt,"%s moved into %s%c\n",fname,fname,'%'); porta_log( "%s moved into %s%c\n",fname,fname,'%'); sprintf( command, "mv -f %s %s%c", fname, fname, '%'); system( command ); #endif // WIN32 } return( fopen(fname,"w") ); }
int valid_main( int argc, char *argv[] ) { char *fout; int i, j,k,iethpo, pothie; FILE *outfp = 0; printf("\nPORTA - a POlyhedron Representation Transformation Algorithm\n"); printf( "Version %s\n\n", VERSION ); printf( "Written by Thomas Christof (Uni Heidelberg)\n" ); printf( "Revised by Andreas Loebel (ZIB Berlin)\n\n" ); printf( "PORTA is free software and comes with ABSOLUTELY NO WARRENTY! You are welcome\n" ); printf( "to use, modify, and redistribute it under the GNU General Public Lincese.\n\n" ); printf( "This is the program VALID from the PORTA package.\n\n" ); if( argc <= 2 ) { fprintf( stderr, "For more information read the manpages about porta.\n\n"); exit(-1); } /* 17.01.1994: include logging on file porta.log */ if( !(logfile = fopen( "porta.log", "a" )) ) fprintf( stderr, "can't open logfile porta.log\n" ); else { porta_log( "\n\n\nlog for " ); for( i = 0; i < argc; i++ ) porta_log( "%s ", argv[i] ); porta_log( "\n\n" ); } initialize(); set_I_functions(); SET_MP_not_ready; prt = stdout; get_options(&argc,&argv); if (option & Protocol_to_file) { strcat(*argv,".prt"); prt = fopen(*argv,"w"); (*argv)[strlen(*argv)-4] = '\0'; } setbuf(prt,CP 0); if (is_set(Vint) && !strcmp(*argv+strlen(*argv)-4,".ieq")) { char *cp1,*cp2; cp1=strdup("LOWER_BOUNDS"); cp2=strdup("UPPER_BOUNDS"); if(!cp1||!cp2) msg("allocation of new space failed", "", 0 ); points = read_input_file(*argv,outfp,&dim,&ar1,(int *)&nel_ar1, cp1,&lowbds,cp2,&upbds,"\0",(RAT **)&i); free(cp1);free(cp2); sort_eqie_cvce(ar1,points,dim+2,&equa,&ineq); valid_ints( dim, ar1, equa, dim+2, dim, ar1+(dim+2)*equa, ineq, dim+2, *argv ); } else { pothie = !strcmp(*argv+strlen(*argv)-4,".poi") && !strcmp(*(argv+1)+strlen(*(argv+1))-4,".ieq"); iethpo = !strcmp(*argv+strlen(*argv)-4,".ieq") && !strcmp(*(argv+1)+strlen(*(argv+1))-4,".poi"); if (!iethpo && !pothie) msg("invalid format of command line", "", 0 ); if (iethpo) { ineq = read_input_file(*argv,outfp,&dim,&ar1,(int *)&nel_ar1, "\0",(int **)&i,"\0",(int **)&i,"\0",(RAT **)&i ); points = read_input_file(*(argv+1),outfp,&j,&ar2,(int *)&nel_ar2, "\0",(int **)&i,"\0",(int **)&i,"\0",(RAT **)&i ); } else { ineq = read_input_file(*(argv+1),outfp,&dim,&ar1, (int *)&nel_ar1, "\0", (int **)&i,"\0", (int **)&i,"\0", (RAT **)&i ); points = read_input_file(*argv,outfp,&j,&ar2, (int *)&nel_ar2, "\0", (int **)&i,"\0", (int **)&i,"\0", (RAT **)&i ); } if (j != dim) msg("dimensions in input files are different", "", 0 ); if (is_set(Iespo)) { sort_eqie_cvce(ar1,ineq,dim+2,&equa,&ineq); valid_ieqs(dim,ar1,ineq+equa,&equa,&ineq,dim+2, ar2,points,dim+1,(char **)(pothie?*argv:*(argv+1))); } else if (is_set(Posie) || is_set(Cfctp)) { fout = iethpo?*argv:*(argv+1); sort_eqie_cvce(ar2,points,dim+1,&cone,&conv); if (is_set(Posie)) valid_points(dim,ar2,points,dim+1, ar1,ineq,dim+2,0,(char **)fout); else { char fname[100]; char command[100]; RAT *ar1p; sort_eqie_cvce(ar1,ineq,dim+2,&equa,&ineq); if (equa ) msg( "only inequalities are allowed", "" , 0 ); for (i = 0,ar1p = ar1; i < ineq; i++, ar1p += dim+2) { sprintf(fname,"%s%i",fout,i+1); fprintf(prt,"I n e q u a l i t y %2i :\n",i+1); fprintf(prt,"==========================\n\n"); /* 17.01.1994: include logging on file porta.log */ porta_log( "I n e q u a l i t y %2i :\n",i+1); porta_log( "==========================\n\n"); fprintf(prt,"computing points i n v a l i d for the inequality :\n"); fprintf(prt,"=====================================================\n"); /* 17.01.1994: include logging on file porta.log */ porta_log( "computing points i n v a l i d for the inequality :\n"); porta_log( "=====================================================\n"); var[3].num = -1; var[3].den.i = 1; scal_mul(var+3,ar1p,ar1p,dim+1); j = valid_points(dim,ar2,points,dim+1, ar1p,1,dim+2,1, (char **)fname); (ar1p+dim+1)->num = 0; fprintf(prt,"computing points satisfying inequalitiy with equation :\n"); fprintf(prt,"=======================================================\n"); /* 17.01.1994: include logging on file porta.log */ porta_log( "computing points satisfying inequalitiy with equation :\n"); porta_log( "=======================================================\n"); if (j) strcat(fname,".poi"); k = valid_points(dim,ar2,points,dim+1, ar1p,1,dim+2,0, (char **)fname); strcat(fname,".poi"); if (!j && k) { sprintf(command,"dim %s",fname); fprintf(prt,"dimension of the points :\n"); fprintf(prt,"=========================\n"); fflush(prt); /* 17.01.1994: include logging on file porta.log */ porta_log( "dimension of the points :\n"); porta_log( "=========================\n"); fflush( logfile ); system(command); } } } } else msg( "invalid format of command line", "", 0 ); } return 0; }
void integ_rekurs( RAT *eqsum, RAT *iesum, int lev ) { val.den.i = 1; if (reknum % 1000 == 0) { fprintf(prt,"."); fflush(prt); /* 17.01.1994: include logging on file porta.log */ porta_log("."); fflush(logfile); } reknum++; if (lev == eqdim) { for (ptr = eqar+eqdim; ptr < ubea; ptr += eqrl, eqsum++) { I_RAT_sub(*eqsum,*ptr,&val); if (val.num != 0) return; } for (ptr = iear+iedim; ptr < ubia; ptr += ierl, iesum++) { I_RAT_sub(*iesum,*ptr,&val); if (val.num > 0) return; } intnum++; fprintf(fp,"(%3d) ",intnum); for (i = 0; i < eqdim; i++) fprintf(fp,"%i ",integ[i]); fprintf(fp,"\n"); } else { val.num = lowbds[lev]; osump = eqsum; nsump = eqsum+neq; for (ptr = eqar+lev; ptr < ubea; ptr += eqrl,osump++,nsump++) { I_RAT_mul(*ptr,val,nsump); I_RAT_add(*osump,*nsump,nsump); } osump = iesum; nsump = iesum+nie; for (ptr = iear+lev; ptr < ubia; ptr += ierl,osump++,nsump++) { I_RAT_mul(*ptr,val,nsump); I_RAT_add(*osump,*nsump,nsump); } for (integ[lev]=lowbds[lev]; integ[lev]<upbds[lev]; integ[lev]+=1) { integ_rekurs(eqsum+neq,iesum+nie,lev+1); osump = eqsum; nsump = eqsum+neq; for (ptr = eqar+lev; ptr < ubea; ptr += eqrl,nsump++) I_RAT_add(*nsump,*ptr,nsump); osump = iesum; nsump = iesum+nie; for (ptr = iear+lev; ptr < ubia; ptr += ierl,nsump++) I_RAT_add(*nsump,*ptr,nsump); } integ_rekurs(eqsum+neq,iesum+nie,lev+1); } }
void valid_ieqs( int dim, RAT *iear, int neqie_in, int *neq_out, int *nie_out, int ieard, RAT *par, int npoi, int pard, char **fname ) { RAT *pptr,*ieptr,*ubpar,*ubiear,*np,s; int i,ie,b,p,valid; unsigned *mp,m; printf ("filtering inequalities and equations valid for all given points "); /* 17.01.1994: include logging on file porta.log */ porta_log( "filtering inequalities and equations valid for all given points "); ubpar = par+npoi*pard; ubiear = iear+neqie_in*ieard; np = iear; *neq_out = *nie_out = 0; blocks = (is_set(Validity_table_out)) ? (npoi-1)/32+1 : 0; allo_list(0,&mp,blocks); for (ieptr = iear,ie=0; ieptr < ubiear; ieptr += ieard,ie++) { for (b = 0; b < blocks; b++) mp[b] = 0; if (ie%100 == 0) { fprintf(prt,"."); fflush(prt); /* 17.01.1994: include logging on file porta.log */ porta_log( "." ); fflush(logfile); } for (pptr = par, p = 0; pptr < ubpar; pptr += pard, p++) { if (! pptr[dim].num) { /* cone */ s = ieptr[dim]; ieptr[dim] = RAT_const[0]; } valid = eqie_satisfied(ieptr,pptr,dim,(ieptr+ieard-1)->num); if (valid == 2 && is_set(Validity_table_out)) { /* ieq strong valid */ m = 1; m <<= p %32; mp[p/32] |= m; } if (! pptr[dim].num) { /* cone */ ieptr[dim] = s; if (!valid) break; } } if (pptr == par+npoi*pard) /* valid */ { porta_list[*nie_out+*neq_out]->sys = np; if ((ieptr+ieard-1)->num) (*nie_out)++; else (*neq_out)++; allo_list(*nie_out+*neq_out,&mp,blocks); for (i = 0; i < ieard; i++) *np++ = ieptr[i]; } } write_ieq_file((char *)fname,0,*neq_out,0,dim+1,0,*nie_out,*neq_out,dim+1,0); fprintf(prt,"\n"); /* 17.01.1994: include logging on file porta.log */ porta_log("\n"); }
int valid_points( int dim, RAT *par, int npoi, int pard, RAT *iear, int nie, int ieard, int not_equal, char **fname) { RAT *pptr,*ieptr,*ubpar,*ubiear,*np,s; int v,ie,ncv=0,nce=0; fprintf (prt,"filtering points satisfying given linear system "); /* 17.01.1994: include logging on file porta.log */ porta_log( "filtering points satisfying given linear system "); ubpar = par+npoi*pard; ubiear = iear+nie*ieard; np = par; for (pptr = par,ie = 0; pptr < ubpar; pptr += pard, ie++) { if (ie%100 == 1) { fprintf(prt,"."); fflush(prt); /* 17.01.1994: include logging on file porta.log */ porta_log("."); fflush(logfile); } for (ieptr = iear; ieptr < ubiear; ieptr += ieard) { if (! pptr[dim].num) { /* cone */ s = ieptr[dim]; ieptr[dim] = RAT_const[0]; } if (!(v = eqie_satisfied(ieptr,pptr,dim,(ieptr+dim+1)->num)) || (not_equal && v==2)) v = 0; if (! pptr[dim].num) /* cone */ ieptr[dim] = s; if (!v) break; } if (ieptr == iear + nie*ieard) { allo_list(nce+ncv,0,blocks); porta_list[nce+ncv]->sys = pptr; if ((pptr+dim)->num) ncv++; else nce++; } } if (!nce && !ncv) { fprintf(prt,"\nno points found\n\n"); /* 17.01.1994: include logging on file porta.log */ porta_log( "\nno points found\n\n"); } else write_poi_file( (char *)fname,0,dim,0,0,nce,0,ncv,nce); return(nce+ncv); }
int read_input_file( char *fname, FILE *outfp, int *dim, RAT **ar, int *nel_ar, char *intkey1, int **intli1, char *intkey2, int **intli2, char *RATkey1, RAT **RATli1 ) /*****************************************************************/ /* * Read the dimension "dim", * a table "ar" of points (in case of a .poi file), * or of inequalities (in case of a .ieq file), * a line "intli1" of integers occurring after keyword "intkey1", * a line "intli2" of integers occurring after keyword "intkey2", * a line "RATli1" of rationals occurring after keyword "RATkey1". * "ar6" is a point that is output in the VALID section in the .ieq file. * * Change by M.S. 5.6.92: * If "outfp" exists (e.g. if is_set(Sort)), * copy the input file into outfp, * except for the INEQUALITIES_SECTION, the CONV_SECTION, and the CONE_SECTION, * and END. */ { int i,j,ieqs,nonempty,arrows=0,arrowl=0,cone = 0,conv = 0,line; int *hip; char *in,*end = "END", equalities[22], convstr[13],conestr[13],key_eli[18],key_val[6],key_low[13],key_upp[13], *comm = "COMMENT" ; char scanned_inline[MAXLINE]; char in_line[MAXLINE]; RAT val; line = 0; strcpy (equalities,"INEQUALITIES_SECTION"); strcpy (convstr,"CONV_SECTION"); strcpy (conestr,"CONE_SECTION"); strcpy (key_eli,"ELIMINATION_ORDER"); strcpy (key_val,"VALID"); strcpy (key_upp,"UPPER_BOUNDS"); strcpy (key_low,"LOWER_BOUNDS"); fp = fopen(fname,"r"); if (fp == 0) msg( "%s : no such file", fname, 0 ); /* * Read the first line into string "in_line". Leading blanks are skipped. * In_Line should start with "DIM=". */ do { nonempty = get_line(fp,fname,in_line,&line ); } while (!nonempty); scan_line(&val,3,0,line,fname,in_line,scanned_inline); if (strncmp(scanned_inline,"DIM=",4) == 0) { in = scanned_inline+4; *dim = atoi(in); if (*dim == 0) msg("%s, line %i : dimension error",fname,line); if (outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } } ieqs = (strcmp(fname+strlen(fname)-4,".ieq") == 0); if( ieqs ) { equa = ineq = 0; convstr[0] = conestr[0] = '\n'; arrowl = *dim+2; if (!strcmp(intkey1,"ELIMINATION_ORDER") || !strcmp(intkey2,"ELIMINATION_ORDER")) key_eli[0] = '\n'; if (!strcmp(intkey1,"LOWER_BOUNDS") || !strcmp(intkey2,"LOWER_BOUNDS")) key_low[0] = '\n'; if (!strcmp(intkey1,"UPPER_BOUNDS") || !strcmp(intkey2,"UPPER_BOUNDS")) key_upp[0] = '\n'; if (!strcmp(RATkey1,"VALID")) key_val[0] = '\n'; } else { /* * key_eli, key_low, key_upp, and key_val are set to 0, * if they already appear as input parameters to this subroutine. * In this way, if e.g. the keyword "VALID" is encountered twice in the * input file, an error message is produced. * "convstr" and "conestr" are set to "\n", * so that the keywords "CONV_SECTION" and "CONE_SECTION" * result in an error message, if they appear in the .ieq file. */ cone = conv = 0; key_val[0] = key_upp[0] = key_low[0] = key_eli[0] = equalities[0] = '\n'; arrowl = *dim+1; } /* * ar6 is initialized to 0. * It is overwritten by a point in the CONV_SECTION, * or by a point in the VALID section. */ ar6 = (RAT *) RATallo(ar6,0,*dim); for (j = 0; j < *dim; j++) { ar6[j].num = 0; ar6[j].den.i = 1; } /* Read the next line into string "in_line" and scan it */ nonempty = get_line(fp,fname,in_line,&line ); scan_line(&val,3,0,line,fname,in_line,scanned_inline); do { if (!nonempty) { if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } nonempty = get_line(fp,fname,in_line,&line); scan_line(&val,3,0,line,fname,in_line,scanned_inline); } else if (strncmp(scanned_inline,comm,7) == 0) { /* * Overread keyword COMMENT and all following lines, * until the next keyword (i.e. one of the arguments of nstrcmp() ) * is encountered. */ do { if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } nonempty = get_line(fp,fname,in_line,&line); scan_line(&val,3,0,line,fname,in_line,scanned_inline); } while (nstrcmp(scanned_inline,conestr,equalities,end, intkey1,intkey2,RATkey1,convstr) || !nonempty); } else if (strcmp(scanned_inline,RATkey1) == 0) { /* * If the keyword RATkey1 is encountered, * read the next line of "dim" rationals into array RATli1. * RATkey1 is "VALID" for "traf *.ieq" applications. */ if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } /* When calling read_input_file, RATkey1 is always assigned to a const argument (string). Therefore it isn't allowed to assign new values to this argument. By the way, this statement causes a bus error on some architectures like the HP! 18.01.1994, Andreas Loebel RATkey1[0] = '\n'; *RATli1 = (RAT *) RATallo(*RATkey1,0,*dim); */ *RATli1 = (RAT *) RATallo(CP 0,0,*dim); do { nonempty = get_line(fp,fname,in_line,&line); if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } } while (!nonempty); scan_line(*RATli1,1,*dim,line,fname,in_line,scanned_inline); nonempty = get_line(fp,fname,in_line,&line); scan_line(&val,3,0,line,fname,in_line,scanned_inline); } else if (strcmp(scanned_inline,key_val) == 0) { /* * keyval[0] == "VALID", iff * Ratkey1 was not "VALID" at the start of function read_input_file() * Otherwise keyval[0] = '\n' * --> "VALID" is accepted as a keyword at most once. */ if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } key_val[0] = '\n'; /* * Change by M.S.: "ar6" was already allocated earlier, * and it is never freed in this loop. ar6 = (RAT *) RATallo(ar6,0,*dim); */ do { nonempty = get_line(fp,fname,in_line,&line); if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } } while (!nonempty); scan_line(ar6,1,*dim,line,fname,in_line,scanned_inline); nonempty = get_line(fp,fname,in_line,&line); scan_line(&val,3,0,line,fname,in_line,scanned_inline); /* change by M.S. 31.5.92: * "ar6" is also used when reading the CONV_SECTION, so don't free it. ar6 = (RAT *) RATallo(ar6,*dim,0); */ } else if (strcmp(scanned_inline,intkey1) == 0) { if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } intkey1[0] = '\n'; *intli1 = (int *) allo(*intli1,0,*dim*sizeof(int)); do { nonempty = get_line(fp,fname,in_line,&line); if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } } while (!nonempty); scan_line((RAT *)*intli1,2,*dim,line,fname,in_line,scanned_inline); nonempty = get_line(fp,fname,in_line,&line); scan_line(&val,3,0,line,fname,in_line,scanned_inline); } else if (strcmp(scanned_inline,intkey2) == 0) { if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } intkey2[0] = '\n'; *intli2 = (int *) allo(*intli2,0,*dim*sizeof(int)); do { nonempty = get_line(fp,fname,in_line,&line); if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } } while (!nonempty); scan_line((RAT *)*intli2,2,*dim,line,fname,in_line,scanned_inline); nonempty = get_line(fp,fname,in_line,&line); scan_line(&val,3,0,line,fname,in_line,scanned_inline); } else if (!strcmp(scanned_inline,key_eli) || !strcmp(scanned_inline,key_low) || !strcmp(scanned_inline,key_upp) ) { /* * array "hip" is just a temporary array. */ if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } if (!strcmp(scanned_inline,key_eli)) key_eli[0] = '\n'; if (!strcmp(scanned_inline,key_low)) key_low[0] = '\n'; if (!strcmp(scanned_inline,key_upp)) key_upp[0] = '\n'; hip = (int *) allo(CP 0,0,*dim*sizeof(int)); do { nonempty = get_line(fp,fname,in_line,&line); if(outfp) { fprintf(outfp,"%s",in_line); /* 17.01.1994: include logging on file porta.log */ porta_log( "%s",in_line); } } while (!nonempty); scan_line((RAT *)hip,2,*dim,line,fname,in_line,scanned_inline); nonempty = get_line(fp,fname,in_line,&line); scan_line(&val,3,0,line,fname,in_line,scanned_inline); hip = (int *) allo(hip,*dim*sizeof(int),0); } else if (strcmp(scanned_inline, convstr) == 0) { /* * Read the CONV_SECTION into array "ar". * For all points j=1,...,conv in the CONV_SECTION, * ar[j-1][dim] is set to 1. * "arrowl" was set to dim+1 earlier. */ convstr[0] = '\n'; *ar = (RAT *) RATallo(*ar,arrows*arrowl, (arrows+INCR_INSYS_ROW)*arrowl); arrows += INCR_INSYS_ROW; do { nonempty = get_line(fp,fname,in_line,&line); } while (!nonempty); while (scan_line(*ar+(conv+cone)*arrowl,0,*dim,line,fname, in_line,scanned_inline)) { (*ar+(conv+cone)*arrowl+*dim)->num = 1; if (conv+cone+2 > arrows) { *ar = (RAT *) RATallo(*ar,arrows*arrowl, (arrows+INCR_INSYS_ROW)*arrowl); arrows += INCR_INSYS_ROW; } do { nonempty = get_line(fp,fname,in_line,&line); } while (!nonempty); conv++; } /* repeat the last point in array "ar6" */ for (j = 0; j < *dim; j++) ar6[j] = (*ar+(conv+cone-1)*arrowl)[j]; } else if ((strcmp(scanned_inline, conestr) == 0)) { /* * Read the CONE_SECTION * ar[j-1][dim] is initialized by RATallo to 0. */ conestr[0] = '\n'; *ar = (RAT *) RATallo(*ar,arrows*arrowl, (arrows+INCR_INSYS_ROW)*arrowl); arrows += INCR_INSYS_ROW; do { nonempty = get_line(fp,fname,in_line,&line); } while (!nonempty); while (scan_line(*ar+(conv+cone)*arrowl,0,*dim,line,fname, in_line,scanned_inline)) { if (conv+cone+2 > arrows) { *ar = (RAT *) RATallo(*ar,arrows*arrowl, (arrows+INCR_INSYS_ROW)*arrowl); arrows += INCR_INSYS_ROW; } do { nonempty = get_line(fp,fname,in_line,&line); } while (!nonempty); cone++; } } else if ( (strcmp(scanned_inline, equalities) == 0)) { /* * Read the INEQUALITIES_SECTION * "arrowl" was set to dim+2 earlier. */ equalities[0] = '\n'; *ar = (RAT *) RATallo(*ar,arrows*arrowl, (arrows+INCR_INSYS_ROW)*arrowl); arrows += INCR_INSYS_ROW; read_eqie(ar,*dim,&equa,&ineq,&arrows,&line, fname,in_line,scanned_inline); nonempty = 1; } else if (strcmp(scanned_inline,end) == 0) { i = (ieqs) ? equa+ineq : conv+cone; *nel_ar = (i+1)*arrowl; *ar = (RAT *) RATallo(*ar,arrows*arrowl,*nel_ar); fclose(fp); fprintf(prt,"input file %s o.k.\n",fname); fprintf(prt, "dimension : %4i \n",*dim); /* 17.01.1994: include logging on file porta.log */ porta_log( "input file %s o.k.\n",fname); porta_log( "dimension : %4i \n",*dim); if (ieqs) { fprintf(prt,"number of equations : %4i \n",equa); fprintf(prt,"number of inequalities : %4i \n\n",ineq); /* 17.01.1994: include logging on file porta.log */ porta_log( "number of equations : %4i \n",equa); porta_log( "number of inequalities : %4i \n\n",ineq); } else { fprintf(prt,"number of cone-points : %4i \n",cone); fprintf(prt,"number of conv-points : %4i \n\n",conv); /* 17.01.1994: include logging on file porta.log */ porta_log( "number of cone-points : %4i \n",cone); porta_log( "number of conv-points : %4i \n\n",conv); } return (i); } else msg("%s, line %i : invalid format",fname,line); } while (1); }
void write_poi_file( char *fname, FILE *fp, int dim, int lr, int flr, int cone, int fce, int conv, int fcv ) { char filename[100]; int i,j,start; fprintf(prt,"\nnumber of cone-points : %4i \n",cone+2*lr); fprintf(prt,"number of conv-points : %4i \n\n",conv); /* 17.01.1994: include logging on file porta.log */ porta_log( "\nnumber of cone-points : %4i \n",cone+2*lr); porta_log( "number of conv-points : %4i \n\n",conv); strcpy(filename,fname); strcat(filename,".poi"); if (!fp) { fp = wfopen(filename); fprintf(fp, "DIM = %d\n\n",dim); } start = 1; if (cone > 0 || lr > 0) { fprintf(fp, "CONE_SECTION\n"); if (lr > 0) { /* CONE(xi,-xi,....) */ writesys(fp,flr,flr+lr,dim,1,0,' ',&start); for (i = flr; i < flr+lr; i++) for (j = 0; j < dim; j++) (porta_list[i]->sys+j)->num *= -1; writesys(fp,flr,flr+lr,dim,1,0,' ',&start); for (i = flr; i < flr+lr; i++) for (j = 0; j < dim; j++) (porta_list[i]->sys+j)->num *= -1; } writesys(fp,fce,fce+cone,dim,1,0,' ',&start); fprintf(fp,"\n"); } if (conv > 0) { start = 1; fprintf(fp, "CONV_SECTION\n"); writesys(fp,fcv,fcv+conv,dim,1,0,' ',&start); fprintf(fp,"\n"); } fprintf(fp, "END\n"); if (is_set(Validity_table_out)) writepoionie(fp,0,ineq,points-1,1); fprintf(prt,"output written to file %s\n\n",filename); /* 17.01.1994: include logging on file porta.log */ porta_log( "output written to file %s\n\n",filename); fclose(fp); }