1 #include "../../include/Matematica.h" 2 #include "../../include/VarDatFile.h" 7 int main(
int argc,
char **argv){
13 double *Dis =
new double;
31 double Border[4] = {0.,0.,0.,0.};
36 sprintf(Uscita,
"Risposta.dat");
39 int *ArgFile = (
int *)calloc(argc,
sizeof(
int));
43 for(
int i=1;i<argc;i++){
44 if(!strcmp(*(argv+i),
"--col")){
49 else if(!strcmp(*(argv+i),
"--exec")){
51 sprintf(Executex,
"%s",*(argv+i+1));
52 sprintf(Executey,
"%s",*(argv+i+2));
54 sprintf(Comando,
"exec");
58 else if(!strncmp(*(argv+i),
"--Border",8)){
59 if(argc < i){printf(
"How many values?\n");
return 0;}
60 sscanf(argv[i+1],
"%lf",Border);
61 sscanf(argv[i+2],
"%lf",Border+1);
65 else if(!strncmp(*(argv+i),
"-l",2)){
66 if(argc < i){printf(
"Whic log scale?\n");
return 0;}
68 sscanf(argv[i+1],
"%s",LogScale);
70 if(!strcmp(LogScale,
"logx"))
71 DIS_ADD_TYPE(LogLog,DIS_LOGX);
72 else if(!strcmp(LogScale,
"logy"))
73 DIS_ADD_TYPE(LogLog,DIS_LOGY);
74 else if(!strcmp(LogScale,
"loglog"))
75 DIS_ADD_TYPE(LogLog,DIS_LOGLOG);
77 printf(
"Log scale not recognized\n");
81 else if(!strncmp(*(argv+i),
"--NElMin",8)){
82 if(argc < i){printf(
"How many values?\n");
return 0;}
83 sscanf(argv[i+1],
"%d",&NElMin);
86 else if(!strncmp(*(argv+i),
"--NElMax",8)){
87 if(argc < i){printf(
"How many values?\n");
return 0;}
88 sscanf(argv[i+1],
"%d",&NElMax);
91 else if(!strncmp(*(argv+i),
"-m",2)){
92 if(argc < i){printf(
"which interval for the running average?\n");
return 0;}
93 sscanf(argv[i+1],
"%d",&NMedia);
96 else if(!strncmp(*(argv+i),
"--norm",6)){
99 else if(!strncmp(*(argv+i),
"--NSample",8)){
100 if(argc < i){printf(
"How many samples?\n");
return 0;}
101 sscanf(argv[i+1],
"%d",&NSample);
104 else if(!strncmp(*(argv+i),
"-o",2)){
105 if(argc < i){printf(
"which output file?\n");
return 0;}
106 sscanf(argv[i+1],
"%s",Uscita);
109 else if(!strncmp(*(argv+i),
"-p",2)){
110 if(argc < i){printf(
"what parameter?\n");
return 0;}
111 sscanf(argv[i+1],
"%lf",&Param);
114 else if(!strncmp(*(argv+i),
"-v",2)){
115 if(argc < i){printf(
"How many values?\n");
return 0;}
116 sscanf(argv[i+1],
"%d",&NBin);
119 else if(!strncmp(*(argv+i),
"-x",2)){
122 else if(!strncmp(*(argv+i),
"-y",2)){
125 else if(!strncmp(*(argv+i),
"--",2)){
126 sprintf(Comando,
"%s",argv[i]+2);
129 else if(strncmp(*(argv+i),
"-",1)){
135 printf(
"File arguments are missing\n");
139 for(
int i=1;i<argc;i++){
140 if(!strncmp(*(argv+i),
"-a",2)){
143 if(!strncmp(*(argv+i),
"--col",5)){
144 if(argc < i){printf(
"Which column?\n");
return 0;}
145 sscanf(argv[i+1],
"%d",&CoordY);
149 else if(!strncmp(*(argv+i),
"-l",2)){
150 if(argc < i){printf(
"Which coord for the log scale?\n");
return 0;}
152 sscanf(argv[i+1],
"%s",LogScale);
154 if(!strcmp(LogScale,
"logx"))
155 DIS_ADD_TYPE(LogLog,DIS_LOGX);
156 else if(!strcmp(LogScale,
"logy"))
157 DIS_ADD_TYPE(LogLog,DIS_LOGY);
158 else if(!strcmp(LogScale,
"loglog"))
159 DIS_ADD_TYPE(LogLog,DIS_LOGLOG);
161 printf(
"Log scale not recognized\n");
165 else if(!strncmp(*(argv+i),
"-y1",3)){
166 if(argc < i){printf(
"Which column?\n");
return 0;}
167 sscanf(argv[i+1],
"%d",&CoordY1);
170 else if(!strncmp(*(argv+i),
"-x1",3)){
171 if(argc < i){printf(
"Which column?\n");
return 0;}
172 sscanf(argv[i+1],
"%d",&CoordX1);
175 else if(!strncmp(*(argv+i),
"-x",2)){
176 if(argc < i){printf(
"which x coord?\n");
return 0;}
177 sscanf(argv[i+1],
"%d",&CoordX);
181 else if(!strncmp(*(argv+i),
"-y",2)){
182 if(argc < i){printf(
"Which column?\n");
return 0;}
183 sscanf(argv[i+1],
"%d",&CoordY);
189 if(NElMax == 0 || NElMax > NMax) NElMax = NMax;
190 if(NElMin > NMax || NElMin < 0) NElMin = 0;
193 sw =
new double[NMax];
194 Intervalli =
new double[NBin];
195 dInter =
new double[NBin];
196 printf(
"Loaded a file of %d points %d cols from %d files: %s ... to write on %s\n",NMax,NVar,NFile,argv[ArgFile[0]],Uscita);
199 while(strcmp(Comando,
"q") ){
201 printf(
"Matematica> ");
204 else if(!strcmp(Comando,
"agg")){
206 printf(
"Nome file :");
207 scanf(
"%s",NomeFile);
209 if(!IfUser)
return 0;
211 else if(!strcmp(Comando,
"create")){
212 FILE *Ciccia = fopen(Uscita,
"w");
213 if(Ciccia == NULL){printf(
"%s could not be created\n",Uscita);exit(0);}
215 double InvNPassi = 1./(double)NPassi;
218 for(
int px=0;px<NPassi;px++){
219 double x = px*InvNPassi*DUE_PI;
220 fprintf(Ciccia,
"%lf %lf\n",x,sin(x*Freq1));
223 else if(!strcmp(Comando,
"create2d")){
224 FILE *Ciccia = fopen(Uscita,
"w");
226 double InvNPassi = 1./(double)NPassi;
231 for(
int px=0;px<NPassi;px++){
232 for(
int py=0;py<NPassi;py++){
233 double x = px*InvNPassi*DUE_PI;
234 double y = py*InvNPassi*DUE_PI;
235 fprintf(Ciccia,
"%lf %lf %lf\n",x,y,sin(x*y*Freq1));
240 fprintf(Ciccia,
"# Created by ElPoly\n");
241 fprintf(Ciccia,
"# name: tz\n");
242 fprintf(Ciccia,
"# type: matrix\n");
243 fprintf(Ciccia,
"# rows: %d\n",NPassi);
244 fprintf(Ciccia,
"# columns: %d\n",NPassi);
245 for(
int px=0;px<NPassi;px++){
246 for(
int py=0;py<NPassi;py++){
247 double x = px*InvNPassi*DUE_PI;
248 double y = py*InvNPassi*DUE_PI;
249 fprintf(Ciccia,
"%lf ",sin(x*y*Freq2));
251 fprintf(Ciccia,
"\n");
255 if(!IfUser)
return 0;
257 else if(!strcmp(Comando,
"dis")){
260 if((USCITA = fopen(Uscita,
"w"))==0){
261 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
263 fprintf(USCITA,
"# %lf %lf %lf\n",Mom.
Uno,Mom.
Due,Mom.
Tre);
264 for(
int i=0;i<NBin;i++){
266 fprintf(USCITA,
"%lf %g\n",x,v1->
pInter(i));
269 printf(
"Media %lf Scarto %lf N %d\n",Mom.
Uno,Mom.
Due,Mom.
Num);
270 if(!IfUser)
return 0;
272 else if(!strcmp(Comando,
"disErr")){
275 if((USCITA = fopen(Uscita,
"w"))==0){
276 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
278 fprintf(USCITA,
"# %lf %lf %lf\n",Mom.
Uno,Mom.
Due,Mom.
Tre);
279 for(
int i=0;i<NBin;i++){
281 fprintf(USCITA,
"%lf %g %g\n",x,v1->
pInter(i),v1->
pError(i));
284 printf(
"Media %lf Scarto %lf N %d\n",Mom.
Uno,Mom.
Due,Mom.
Num);
285 if(!IfUser)
return 0;
287 else if(!strcmp(Comando,
"disB")){
290 if((USCITA = fopen(Uscita,
"w"))==0){
291 printf(
"Non s'apre %s\n Permessi?\n",
"Distribuzione.dat");
293 fprintf(USCITA,
"# %lf %lf %lf\n",Mom.
Uno,Mom.
Due,Mom.
Tre);
294 for(
int i=0;i<NBin;i++){
296 fprintf(USCITA,
"%lf %g\n",x,v1->
pInter(i));
299 printf(
"Media %lf Scarto %lf N %d\n",Mom.
Uno,Mom.
Due,Mom.
Num);
300 if(!IfUser)
return 0;
302 else if(!strcmp(Comando,
"disLog")){
305 if((USCITA = fopen(Uscita,
"w"))==0){
306 printf(
"Non s'apre %s\n Permessi?\n",
"Distribuzione.dat");
308 fprintf(USCITA,
"# %lf %lf %lf\n",Mom.
Uno,Mom.
Due,Mom.
Tre);
309 for(
int i=0;i<NBin;i++){
311 fprintf(USCITA,
"%lf %g\n",x,v1->
pInter(i));
314 printf(
"Media %lf Scarto %lf N %d\n",Mom.
Uno,Mom.
Due,Mom.
Num);
315 if(!IfUser)
return 0;
317 else if(!strcmp(Comando,
"disExp")){
320 if((USCITA = fopen(Uscita,
"w"))==0){
321 printf(
"Non s'apre %s\n Permessi?\n",
"Distribuzione.dat");
323 fprintf(USCITA,
"# %lf %lf %lf\n",Mom.
Uno,Mom.
Due,Mom.
Tre);
324 for(
int i=0;i<NBin;i++){
326 fprintf(USCITA,
"%lf %g\n",x,v1->
pInter(i));
329 printf(
"Media %lf Scarto %lf N %d\n",Mom.
Uno,Mom.
Due,Mom.
Num);
330 if(!IfUser)
return 0;
332 else if(!strcmp(Comando,
"disSample")){
333 double xBound[2] = {Border[0],Border[1]};
335 Distr =
new double*[NSample];
336 for(
int s=0;s<NSample;s++){
337 Distr[s] =
new double[NBin];
341 if((USCITA = fopen(Uscita,
"w"))==0){
342 printf(
"Non s'apre %s\n Permessi?\n",
"Distribuzione.dat");
344 fprintf(USCITA,
"# distribution per sample\n");
345 for(
int b=0;b<NBin;b++){
346 double x = b/(double)NBin*(xBound[1]-xBound[0]) + xBound[0];
347 fprintf(USCITA,
"%lf ",x);
348 for(
int s=0;s<NSample;s++){
349 fprintf(USCITA,
"%lf ",Distr[s][b]);
351 fprintf(USCITA,
"\n");
354 if(!IfUser)
return 0;
356 else if(!strcmp(Comando,
"DrawEq")){
357 FILE *FWrite = fopen(Uscita,
"w");
359 Border[0] = v1->
pxMinGlob(NElMin,NElMax);
360 Border[1] = v1->
pxMaxGlob(NElMin,NElMax);
362 double Dx = (Border[1]-Border[0])/(
double)NBin;
363 for(
int i=0;i<NBin;i++){
364 double x = i*Dx+Border[0];
365 fprintf(FWrite,
"%lf %lf\n",x,v1->
fProva(x));
368 if(!IfUser)
return 0;
370 else if(!strcmp(Comando,
"coord")){
371 printf(
"Number of coordinate: ");
374 if(NCoord >= 0 && NCoord<NVar)
376 if(!IfUser)
return 0;
378 else if(!strcmp(Comando,
"MatchCoord")){
379 double *st = (
double *)calloc(NMax,
sizeof(
double));
380 double tInit = v1->
Val(CoordX1,0);
382 for(
int n=NElMin,m=0;n<NElMax;n++){
385 double t = tInit + v1->
Val(CoordX,m);
387 if(v1->
Val(CoordX1,n) <= t && t < v1->
Val(CoordX1,n+1))
395 st[n] = v1->
Val(CoordY,m);
400 if((USCITA = fopen(Uscita,
"w"))==0)
401 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
402 for(
int i=NElMin;i<NElMax;i++){
403 fprintf(USCITA,
"%lf %.5g %.5g\n",st[i],v1->
Val(CoordY1,i),v1->
Val(CoordY1+1,i));
407 if(!IfUser)
return 0;
409 else if(!strcmp(Comando,
"norm")){
411 if((USCITA = fopen(Uscita,
"w"))==0)
412 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
414 for(
int i=NElMin;i<NElMax;i++){
415 fprintf(USCITA,
"%lf %.5g\n",v1->
Abscissa(CoordY,i),v1->
Val(CoordY,i));
418 if(!IfUser)
return 0;
420 else if(!strcmp(Comando,
"sin")){
422 if((USCITA = fopen(Uscita,
"w"))==0){
423 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
425 for(
int i=0;i<100;i++){
426 double x = i*DUE_PI*.01;
427 fprintf(USCITA,
"%g\n",sin(x));
430 if(!IfUser)
return 0;
432 else if(!strcmp(Comando,
"sum")){
434 for(
int i=NElMin;i<NElMax;i++){
435 Sum += v1->
Val(CoordY,i);
437 printf(
"Sum: %lf\n",Sum);
438 if(!IfUser)
return 0;
440 else if(!strcmp(Comando,
"SpD")){
441 printf(
"Calcolo lo spettro \n");
444 if((USCITA = fopen(Uscita,
"w"))==0){
445 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
448 for(
int i=0;i<NMax/2;i++){
449 fprintf(USCITA,
"%g\n",sw[i]);
452 if(!IfUser)
return 0;
454 else if(!strcmp(Comando,
"sort")){
458 if(!IfUser)
return 0;
460 else if(!strcmp(Comando,
"Cas")){
461 printf(
"Proviamo il generatore di numeri casuali \n");
463 if((USCITA = fopen(Uscita,
"w"))==0){
464 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
466 for(
int i=0;i<10000;i++){
467 fprintf(USCITA,
"%lf\n",m1->
Casuale());
470 if(!IfUser)
return 0;
472 else if(!strcmp(Comando,
"Func")){
474 printf(
"Proviamo una funzione \n");
475 if((USCITA = fopen(Uscita,
"w"))==0){
476 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
478 for(
double x=0.,Dx=.001,Max=5.;x<Max;x+=Dx){
479 printf(
"%lf\n",x/Max);
485 if(!IfUser)
return 0;
487 else if(!strcmp(Comando,
"SpeLine")){
488 int NBin = NElMax-NElMin;
489 double InvNVar = .5/(double)(NVar);
490 double InvNBin = 1./(double)(NMax);
491 double *Spe = (
double *)calloc(NBin,
sizeof(
double));
492 v1->
SpeLine(NElMin,NElMax,NBin,Spe);
493 FILE *FWrite = fopen(
"StalkLineSpectrum.dat",
"w");
494 fprintf(FWrite,
"# q=2\\pi n/N <h(q)^2>\n");
496 for(
int n=0;n<NBin;n++){
497 fprintf(FWrite,
"%lf %g \n",DUE_PI*InvNBin*n,Spe[n]*InvNVar*InvNBin);
501 if(!IfUser)
return 0;
503 else if(!strcmp(Comando,
"spe") ){
506 if((USCITA = fopen(Uscita,
"w"))==0){
507 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
509 for(
int i=0;i<NMax;i++){
510 fprintf(USCITA,
"%g\n",sw[i]);
514 if(!IfUser)
return 0;
516 else if(!strcmp(Comando,
"RadTens") ){
518 printf(
"I need the three components of the radial pressure\n");
519 if(!IfUser)
return 0;
521 FILE *RadTens = fopen(Uscita,
"w");
524 for(
int n=0;n<NMax-1;n++){
525 Vol1 = DUE_PI*SQR(v1->
Abscissa(CoordY,n+1));
526 double Prr = sqrt( SQR(v1->
Val(1,n)) + SQR(v1->
Val(6,n)));
527 double Pzz = v1->
Val(11,n);
528 double PTrace = v1->
Val(1,n)+v1->
Val(5,n)+v1->
Val(11,n);
529 double Ptt = .5*(PTrace - Prr);
530 double SurfTens = (Prr - .5*(Ptt+Pzz))/(Vol1-Vol2);
531 fprintf(RadTens,
"%lf %lf\n",v1->
Abscissa(CoordY,n),SurfTens);
535 if(!IfUser)
return 0;
537 else if(!strcmp(Comando,
"perm") ){
541 if(!IfUser)
return 0;
543 else if(!strcmp(Comando,
"solve") ){
555 A->
Set(0,0,1.);A->
Set(0,1,6.);A->
Set(0,2,5.);A->
Set(0,3,8.);
556 A->
Set(1,0,5.);A->
Set(1,1,2.);A->
Set(1,2,5.);A->
Set(1,3,5.);
557 A->
Set(2,0,6.);A->
Set(2,1,3.);A->
Set(2,2,7.);A->
Set(2,3,1.);
558 A->
Set(3,0,8.);A->
Set(3,1,7.);A->
Set(3,2,2.);A->
Set(3,3,6.);
566 double *Known = (
double *)calloc(4,
sizeof(
double));
567 Known[0] = 1.; Known[1] = 4.; Known[2] = 3.; Known[3] = 2.;
568 double *UnKnown = (
double *)calloc(4,
sizeof(
double));
569 A->
Solve(Known,UnKnown);
570 for(
int i=0;i<4;i++){
571 printf(
"%lf %lf\n",Known[i],UnKnown[i]);
573 if(!IfUser)
return 0;
575 else if(!strcmp(Comando,
"zeri") ){
591 Radici = (
double *)malloc(NRadici*
sizeof(
double));
592 rad = m1->
Zeri(0.,DUE_PI/2.,Radici,NRadici);
593 if(!IfUser)
return 0;
595 else if(!strcmp(Comando,
"fal") ){
603 printf(
"Lo Zero e in x %lf\n",Zero.
Zero);
604 if(!IfUser)
return 0;
606 else if(!strcmp(Comando,
"new") ){
609 printf(
"Punto iniziale: ");
612 printf(
"Lo Zero e in x %lf\n",Zero.
Zero);
613 if(!IfUser)
return 0;
615 else if(!strcmp(Comando,
"fun") ){
617 USCITA = fopen(
"Funzione.dat",
"w");
621 double Delta = (B-A)/(
double)NPunti;
625 for(
int i=0;i<NPunti;i++){
626 fprintf(USCITA,
"%g %g\n",Delta*(
double)i,m1->
Evalx(Delta*(
double)i));
629 if(!IfUser)
return 0;
631 else if(!strcmp(Comando,
"FitLin") ){
632 FILE *USCITA = fopen(Uscita,
"w");
634 printf(
"y = (%lf +- %lf)x + (%lf +- %lf)\n",r1.
m,r1.
ErrM,r1.
q,r1.
ErrQ);
635 fprintf(USCITA,
"#y = (%lf +- %lf)x + (%lf +- %lf)\n",r1.
m,r1.
ErrM,r1.
q,r1.
ErrQ);
637 for(
int i=0;i<NMax;i++){
638 fprintf(USCITA,
"%lf %lf %lf\n",v1->
Abscissa(CoordY,i),v1->
Val(CoordY,i),v1->
Abscissa(CoordY,i)*r1.
m+r1.
q);
642 for(
int i=0;i<NMax;i++){
643 if(v1->
Abscissa(CoordY,i) <= 0.)
continue;
644 if(v1->
Val(CoordY,i) <= 0.)
continue;
645 fprintf(USCITA,
"%lf %lf %lf\n",log10(v1->
Abscissa(CoordY,i)),log10(v1->
Val(CoordY,i)),log10(v1->
Abscissa(CoordY,i))*r1.
m+r1.
q);
649 if(!IfUser)
return 0;
651 else if(!strcmp(Comando,
"FitPara") ){
652 FILE *USCITA = fopen(Uscita,
"w");
654 printf(
"%.2g + %.2g x + %.2g x^2\n",p1.
a0,p1.
a1,p1.
a2);
655 printf(
"Minimum %.2g \n",p1.
Minimo);
656 fprintf(USCITA,
"#%.2g + %.2g x + %.2g x^2\n",p1.
a0,p1.
a1,p1.
a2);
657 fprintf(USCITA,
"#Minimum %.2g \n",p1.
Minimo);
658 for(
int i=0;i<NMax;i++){
662 if(!IfUser)
return 0;
664 else if(!strcmp(Comando,
"FitExp") ){
665 FILE *USCITA = fopen(Uscita,
"w");
667 printf(
"y=(%.3g+-%.3g)exp(x/(%.3g+-%.3g))\n",log10(r1.
q),log10(r1.
ErrQ),1./r1.
m,r1.
ErrM/SQR(r1.
m));
668 printf(
"decay t_d = %.4g +- %.4g\n",1./r1.
m,r1.
ErrM/SQR(r1.
m));
669 fprintf(USCITA,
"#y=(%.3g+-%.3g)exp(x/(%.3g+-%.3g))\n",log10(r1.
q),log10(r1.
ErrQ),1./r1.
m,r1.
ErrM/SQR(r1.
m));
670 fprintf(USCITA,
"#decay t_d = %.4g +- %.4g\n",1./r1.
m,r1.
ErrM/SQR(r1.
m));
671 for(
int i=0;i<NMax;i++){
672 fprintf(USCITA,
"%lf %lf %lf\n",v1->
Abscissa(CoordY,i),v1->
Val(CoordY,i),exp(r1.
q+r1.
m*v1->
Abscissa(CoordY,i)));
675 if(!IfUser)
return 0;
677 else if(!strcmp(Comando,
"Prob2Nrg") ){
678 FILE *File2Write = fopen(Uscita,
"w");
679 if(File2Write == NULL){
680 printf(
"Could not open %s\n",Uscita);
685 for(
int v=0;v<NBin;v++){
688 fprintf(File2Write,
"%lf %lf\n",x,-log(v1->
pInter(v)));
691 if(!IfUser)
return 0;
693 else if(!strcmp(Comando,
"min") ){
694 double Min = v1->
Val(CoordY,0);
696 for(
int n=0;n<NMax;n++){
697 if(Min > v1->
Val(CoordY,n)){
698 Min = v1->
Val(CoordY,n);
702 printf(
"%lf %lf\n",v1->
Val(CoordX,nMin),v1->
Val(CoordY,nMin));
703 if(!IfUser)
return 0;
705 else if(!strcmp(Comando,
"mm") ){
706 printf(
"Number of points per sample: %d\n",NMedia);
710 if((USCITA = fopen(Uscita,
"w"))==0)
711 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
712 for(
int i=0;i<NSample;i++){
716 if(!IfUser)
return 0;
718 else if(!strcmp(Comando,
"WeightHisto") ){
727 if(!IfUser)
return 0;
729 else if(!strcmp(Comando,
"int")){
732 if((USCITA = fopen(Uscita,
"w"))==0)
733 printf(
"Non s'apre %s\n Permessi?\n",Uscita);
734 printf(
"%d %d %d\n",NElMin,NElMax,v1->
pNMax());
735 for(
int i=NElMin;i<NElMax;i++){
739 if(!IfUser)
return 0;
741 else if(!strcmp(Comando,
"mom")){
742 for(
int v=0;v<NVar;v++){
745 printf(
"%d) %lf pm %lf\n",v,Mom.
Uno,Mom.
Due);
747 if(!IfUser)
return 0;
749 else if(!strcmp(Comando,
"exec")){
751 printf(
"Inserire la formula per x: ");
752 scanf(
"%s",Executex);
753 printf(
"Inserire la formula per y: ");
754 scanf(
"%s",Executey);
756 FILE *Ciccia = fopen(Uscita,
"w");
757 for(
int i=NElMin;i<NElMax;i++){
758 for(
int v=0;v<NVar;v++){
759 double Val = v1->
Val(v,i);
764 fprintf(Ciccia,
"%.5g ",Val);
766 fprintf(Ciccia,
"\n");
769 if(!IfUser)
return 0;
771 else if(!strcmp(Comando,
"widom")){
772 FILE *Widom = fopen(Uscita,
"w");
773 for(
int i=NElMin;i<NElMax;i++){
774 if(v1->
Val(3,i)*v1->
Val(1,i) > 0.){
775 double Arg = v1->
Val(3,i)/(v1->
Val(1,i));
776 double ChemPot = v1->
Val(0,i) + log(Arg);
777 fprintf(Widom,
"%lf %lf\n",v1->
Val(0,i),ChemPot);
781 if(!IfUser)
return 0;
783 else if(!strcmp(Comando,
"DecayTime")){
784 double *st =
new double[NVar];
785 double *sw =
new double[NVar];
786 FILE *DecayTime = fopen(Uscita,
"w");
787 for(
int f=0;f<NVar;f++){
788 for(
int i=NElMin;i<NElMax;i++){
789 st[f] = v1->
Val(0,i)*v1->
Val(f,i);
791 st[f] /= (double)v1->
pNMax();
794 for(
int f=0;f<NVar;f++){
795 fprintf(DecayTime,
"%d %g %g\n",f,sw[f],st[f]);
798 if(!IfUser)
return 0;
800 else if(!strcmp(Comando,
"reverse") ){
803 if(!IfUser)
return 0;
805 else if(!strcmp(Comando,
"DoubleDist") ){
808 if(!IfUser)
return 0;
810 else if(!strcmp(Comando,
"smooth") ){
811 v1->
Smooth(Param,CoordY,NElMin,NElMax);
812 v1->
Smooth(Param,CoordY,NElMin,NElMax);
813 v1->
Smooth(Param,CoordY,NElMin,NElMax);
815 if(!IfUser)
return 0;
817 else if(!strcmp(Comando,
"smoothGauss") ){
820 if(!IfUser)
return 0;
822 else if(!strcmp(Comando,
"salva") ){
824 if(!IfUser)
return 0;
826 else if(!strcmp(Comando,
"tecplot") ){
828 if(!IfUser)
return 0;
830 else if(!strcmp(Comando,
"txvl") ){
832 if(!IfUser)
return 0;
834 else if(!strcmp(Comando,
"ResBulk") ){
836 if(!IfUser)
return 0;
838 else if(!strcmp(Comando,
"conv") ){
839 FILE *FWrite = fopen(Uscita,
"w");
841 for(
int n=0;n<NMax;n++){
843 fprintf(FWrite,
"%lf %lf\n",x,v1->
Val(0,n)*1e12);
846 if(!IfUser)
return 0;
848 else if(!strcmp(Comando,
"salvacol") ){
849 v1->
ScriviFile(Uscita,CoordY,0,NElMin,NElMax);
850 if(!IfUser)
return 0;
852 else if(!strcmp(Comando,
"col") ){
853 printf(
"Number of column: ");
857 if(!IfUser)
return 0;
859 else if(!strcmp(Comando,
"print") ){
861 if(!IfUser)
return 0;
863 else if(!strcmp(Comando,
"vet")){
872 if(!IfUser)
return 0;
874 else if(!strcmp(Comando,
"OrdAv")){
875 double *Distr =
new double[NBin];
878 v1->
pGlobBorder(Border,Border+1,Border+2,Border+3);
879 printf(
"%lf %lf\n",Border[0],Border[1]);
880 Border[1] = Border[1] - Border[0];
881 Border[1] = 1./(1.001*Border[1]);
884 Border[1] = Border[1] - Border[0];
885 Border[1] = 1./(1.001*Border[1]);
887 printf(
"%lf %lf\n",Border[0],Border[1]);
889 FILE *WFile = fopen(Uscita,
"w");
890 for(
int b=0;b<NBin;b++){
891 double x = b/(Border[1]*NBin) + Border[0];
892 fprintf(WFile,
"%lf %lf\n",x,Distr[b]);
896 if(!IfUser)
return 0;
898 else if(!strcmp(Comando,
"WAv")){
900 printf(
"Mean %lf +- %lf\n",m1.
Uno,m1.
Due);
901 if(!IfUser)
return 0;
903 else if(!strcmp(Comando,
"q") ){}
905 printf(
"Comando sbagliato, riprovare\n");
909 printf(
"Te se qe ve be te ne?\n");
void Sort()
Sort with respect to a coordinate.
double pPunti(int n)
Value of the elaborated array at position.
double a1
a0 + a1 x + a2 x^2
void ScriviPunti(char *file)
Writes the content of the elaborated array.
double Ypsilon
External parameter to calculate the contact angle.
int pNMax()
Print the maximum number of data in the array.
int Solve(double *Known, double *UnKnown)
Solve a system A|b = y.
void AverageOrdinate(int ElMin, int ElMax, double *Distr, double *xBound)
Average of all ordinate.
Geometrical operations on vectors.
int Zeri(double a, double b, double *Radici, int NRadici)
Find the.
void Print()
Prints the content in memory.
double pPuntiErr(int n)
Value of the error array at postion.
double a2
a0 + a1 x + a2 x^2
RETTA InterRettSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a liner fit.
Indices for the permutation.
double fProva(double x)
Trial function.
void Punta(int n)
Points to a different column.
void SpeLine(int ElMin, int ElMax, int NBin, double *Spe)
Spectrum of a sequence of lines.
int PermuteRandomAll(int *Sequence, int NMass)
Permutes a sequence without repeating.
int WeightHistoSign(int NHisto)
Weighted histogram analysis.
double * sp
Points to a column of st.
double QuasiBessel(double Val, int Ord)
A faster Bessel.
double Bessel(double Val, int Ord)
Bessel function.
double ErrQ
Error on the intercept.
MOMENTI WeightAverageSet(int CoordY, int ElMin, int ElMax)
Weighted distribution.
FUNC Func
Pointer to a function.
Moments of a distribution.
void pGlobBorder(double *xMin, double *xMax, double *yMin, double *yMax)
Print global borders.
double Zero
Point of the zero.
void ImpSequence(int Col)
Set the natural sequence as abscissa for the column Col.
void ImpCoordY(int Ext)
Set the column for the y array.
void DoubleDistFluct()
Distribution of distances.
double Casuale()
Random uniform number.
double ErrM
Error on the slope.
PARABOLA ParabolaSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a parabolic fit.
double ContactAngle(double x)
Definition of the contact angle.
void DistrSignSample(int ElMin, int ElMax, double **Distr, int NSample, int IfNorm, double *xBound)
Distributions of data organized in different samples.
double IntSegnale()
Numerical integration of the signal.
double pInter(int n)
Print the postion.
double PreFact
External parameter in the definition of the contact angle.
void ImpCoordX(int vAbs)
Set the columns for the x array.
RADICE Newton(double a)
Use Newton to find the roots.
void RescaleToBulk(char *FName)
Rescale to bulk.
MOMENTI DistrExpSegnale(int NElMin, int NElMax, int IfNorm)
Exponential distribution of a signal.
MOMENTI DistrGaussSegnale(int ElMin, int ElMax, int IfNorm)
Tests a gaussian distribution of the signal.
double a0
a0 + a1 x + a2 x^2
int pNVar()
Print the number of variables.
void Reverse()
Reverse the sets.
double pError(int n)
Print the postion.
double Val(int CoordY, int n)
Value at the position.
void ScriviFile(char *file, int CoordY, int LogLog, int NVisMin, int NVisMax)
Writes the content of the pointed vector.
Reads and stores a data file to be elaborated via Matematica.
Matrice computes the algebric operations on matrices.
bool Set(int row, int column, double Val)
Set a coefficient.
Where a root was searched.
void ExportTxvl(char *FName, int NElMin, int NElMax)
Export in the txvl file format.
double Minimo
Minimum of the parabola.
void SmoothGauss(double Fact, int CoordY, int NVisMin, int NVisMax)
Smooth the line.
int NormalizzaInter()
Normalize the intervals.
double Evalx(double x)
Pointer to a generic function.
double ExecFormula(double x, double y, char *cmd)
Execute a formula.
double pxMinGlob(int NVisMin, int NVisMax)
Print the abscissa minimum of all sets.
int Smooth(double Fact, int CoordY, int NVisMin, int NVisMax)
Smooth the line.
void TecPlot(char *FName)
Export a contour plot.
Implementation of useful algorythms.
double pxMaxGlob(int NVisMin, int NVisMax)
Print the abscissa maximum of all sets.
int Num
Number of points considered.
MOMENTI DistrLogSegnale(int NElMin, int NElMax, int IfNorm)
Logarithmic distribution of a signal.
int Aggiungi(char *file)
Add the content of the file into the memory.
void pMinMaxGlob(int NVisMin, int NVisMax)
Find the borders globally.
RADICE RegulaFalsi(double a, double b)
Use regula falsi algorithm to find the roots.
double Abscissa(int CoordY, int n)
Value of the Abscissa at position.
int NormalizzaSegnale(int NElMin, int NElMax)
Normalize the signal.
RETTA InterExpSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a exponential fit.
void Print()
Print the entries.
MOMENTI DistrSignErr(int NElMin, int NElMax, double *Border, int IfNorm)
Distribution of a signal with error.
double Delta
Step interval.
void Spettro(double *st, double *sw, int NMass)
Compute the spectrum.
MOMENTI DistrSegnale(int NElMin, int NElMax, int IfNorm)
Distribution of a signal.
void ScriviTutto(char *file, int LogLog, int NVisMin, int NVisMax)
Writes all the content in memory.
int MediaMobSegnale(int)
Running average.