1 #include "../include/VarDatFile.h" 76 int *NMaxFile = (
int *)calloc(NFile,
sizeof(
int));
77 int *NColFile = (
int *)calloc(NFile+1,
sizeof(
int));
79 for(
int f=0;f<NFile;f++){
80 FILE *FileIn = fopen(FileList[Pos[f]],
"r");
82 printf(
"File %s not found\n",FileList[Pos[f]]);
86 NMaxFile[f] =
FileInfo(FileIn,&NCol);
87 NColFile[f+1] = NCol + NColFile[f];
88 if(NMaxFile[f] > NMax) NMax = NMaxFile[f];
95 double *dLine = (
double *)calloc(NVar,
sizeof(
double));
96 for(
int f=0;f<NFile;f++){
97 for(
int v=NColFile[f];v<NColFile[f+1];v++)
98 SetNMax[v] = NMaxFile[f];
99 FILE *FileIn = fopen(FileList[Pos[f]],
"r");
100 for(
int l=0;l<NMaxFile[f];l++){
101 if(!fgets(cLine,512,FileIn))
break;
102 if(
ReadLine(cLine,dLine)){l--;
continue;}
103 for(
int v=NColFile[f],vv=0;v<NColFile[f+1];v++,vv++){
104 st[v][l] = dLine[vv];
108 if(NColFile[f+1]-NColFile[f] == 1){
109 RefAbsc[NColFile[f]] = NVar;
112 for(
int v=NColFile[f];v<NColFile[f+1];v++){
113 RefAbsc[v] = NColFile[f];
117 if(NVar == 1)
Punta(0);
123 void VarDatFile::Allocate(){
124 dInter = (
double *)calloc(
NBin,
sizeof(*dInter));
125 dError = (
double *)calloc(
NBin,
sizeof(*dError));
126 dInter1 = (
double *)calloc(
NBin,
sizeof(*dInter));
127 sp = (
double *)malloc(
sizeof(
double));
128 sType = (
int *)calloc(NVar,
sizeof(
int));
129 SetNMax = (
int *)calloc(NVar,
sizeof(
int));
130 sColor = (
int *)calloc(NVar,
sizeof(
int));
131 sMin = (
double *)calloc(NVar,
sizeof(
double));
132 sMax = (
double *)calloc(NVar,
sizeof(
double));
133 sColor = (
int *)calloc(NVar,
sizeof(
int));
134 RefAbsc = (
int *)calloc(NVar,
sizeof(
int));
135 st = (
double **)calloc(NVar+1,
sizeof(
double));
137 printf(
"Could not allocate st \n");
141 for(
int v=0;v<NVar+1;v++){
142 st[v] = (
double *)calloc(NMax,
sizeof(
double));
144 printf(
"Could not allocate st[%d] \n",v);
149 for(
int n=0;n<NMax;n++){
150 st[NVar][n] = (double)n;
155 for(
int v=0;v<NVar;v++){
161 for(
int v=0;v<NVar;v++){
167 for(
int v=0;v<NVar;v++){
184 void VarDatFile::Init(){
191 if((InFile = fopen(file,
"r"))==NULL){
192 printf(
"Non s'apre %s\n",file);
196 double **stTemp = (
double **)calloc(NVar,
sizeof(
double));
197 if(stTemp == NULL){printf(
"stTemp non s'alloca\n");
return 0;}
198 for(
int v=0;v<NVar;v++){
199 stTemp[v] = (
double *)calloc(NMax,
sizeof(
double));
200 if( stTemp[v] == NULL){printf(
"stTemp non s'alloca\n");
return 0;}
202 for(
int v=0;v<NVar;v++){
203 for(
int n=0;n<NMax;n++){
204 stTemp[v][n] = st[v][n];
209 int nPoint =
FileInfo(InFile,&NCol);
211 if(nPoint > NMax) NMax = nPoint;
214 for(
int v=0;v<NVarOld;v++){
220 st = (
double **)calloc(NVar,
sizeof(
double));
221 if( st == NULL){printf(
"st non s'alloca\n");
return 0;}
222 for(
int v=0;v<NVar;v++){
223 st[v] = (
double *)calloc(NMax,
sizeof(
double));
224 if( st[v] == NULL){printf(
"st non s'alloca\n");
return 0;}
233 double *dLine = (
double *)calloc(NVar,
sizeof(
double));
234 for(
int l=0; l<NMax;l++){
235 fgets(cLine,512,InFile);
237 for(
int v=NVarOld;v<NVar;v++){
238 st[v][l] = dLine[v-NVarOld];
239 if(sMin[v] > st[v][l])
241 if(sMax[v] < st[v][l])
247 for(
int v=0;v<NVar;v++){
248 if(GlobMax < sMax[v])
250 if(GlobMin > sMin[v])
253 for(
int n=0;n<NMax;n++)
254 for(
int v=0;v<NVarOld;v++)
255 st[v][n] = stTemp[v][n];
256 for(
int v=0;v<NVarOld;v++)
268 for(
int k=0;!(fgets(cLine,STRSIZE,InFile)==NULL);k++){
269 if(k == 0 && cLine[0] ==
'#'){
270 sprintf(Header,
"%s",cLine);
273 int iLen = (int) (strlen(cLine));
274 if(cLine[0] !=
'#' && cLine[0] !=
'\n')
276 for(
int i=0,var=1;i<iLen;i++){
280 if(cLine[i] ==
'\n')
break;
282 if( (cLine[i-1] ==
' ' || cLine[i-1] ==
'\t' ) &&
283 (cLine[i] !=
' ' && cLine[i] !=
'\t' ))
286 if(*NCol < var) *NCol = var;
293 int iLen = (int) (strlen(cLine));
294 if(cLine[0] ==
' ' || cLine[0] ==
'\t'){
295 for(
int i=0;i<iLen;i++){
296 if(cLine[i] !=
' ' && cLine[i] !=
'\t'){
302 sscanf(cLine,
"%lf",sLine);
303 for(
int i=0,v=1;i<iLen;i++){
304 if(cLine[i]==
'#')
return 1;
305 if(v>=NVar)
return 0;
306 if(cLine[i]==
' ' || cLine[i] ==
'\n' || cLine[i]==
'\t'){
307 sscanf(cLine+i,
"%lf",sLine+v);
319 va_start(ap, Format);
320 fgets(line, 256, InFile);
321 NVariable = vsscanf(line, Format, ap);
326 double *Count = (
double *)calloc(
NBin,
sizeof(
double));
327 for(
int n=0;n<NMax;n++){
328 for(
int v=0;v<NVar;v++){
330 if(isnan(st[v][n]))
continue;
331 int bx = (int)((
Abscissa(v,n) - xBound[0])*xBound[1]*
NBin);
332 if(bx < 0 || bx >= NBin)
continue;
333 Distr[bx] += st[v][n];
337 for(
int bx=0;bx<
NBin;bx++){
338 Distr[bx] /= Count[bx] > 0. ? Count[bx] : 1.;
347 for(
int n=0;n<NMax;n++){
348 Punti[n] = log10(
sp[n]);
354 for(
int n=0;n<NMax;n++){
355 Punti[n] = exp(
sp[n]);
363 return DistrErr(
sp+ElMin,ElMax-ElMin,dInter,dError,
NBin,Border,IfNorm);
372 int CoordX = RefAbsc[CoordY];
392 return (
int)( (NMax));
396 double InvNBin = 1./(double)(NBin);
397 fftw_complex *out = (fftw_complex *)fftw_malloc(NBin*
sizeof(fftw_complex));
398 fftw_complex *in = (fftw_complex *)fftw_malloc(NBin*
sizeof(fftw_complex));
399 fftw_plan plan = fftw_plan_dft_1d(NBin,in,out,FFTW_FORWARD,FFTW_ESTIMATE);
400 fftw_plan plan2 = fftw_plan_dft_1d(NBin,out,in,FFTW_BACKWARD,FFTW_ESTIMATE);
401 for(
int v=0;v<NVar;v++){
403 for(
int n=0;n<
NBin;n++) in[n][0] = st[v][n];
405 for(
int n=0;n<
NBin;n++){
406 Spe[n] += SQR(out[n][0]) + SQR(out[n][1]);
412 printf(
"fftw not present\n");
433 int CoordX = RefAbsc[CoordY];
434 double Dx = (st[CoordX][ElMax]-st[CoordX][ElMin]);
435 double NumInv = 1./(double)(ElMax-ElMin);
436 for(
int i=ElMin;i<ElMax;i++){
437 Resp += st[CoordY][ElMax];
439 return Resp*Dx*NumInv;
443 for(
int nm=0;nm<NMax;nm++){
445 for(
int nv=0;nv<NVar;nv++){
447 Punti[nm] += st[nv][nm];
452 if(NVar < 2)
return 0.;
454 double *temp1 = (
double *)malloc(NMax*
sizeof(
double));
455 double *temp2 = (
double *)malloc(NMax*
sizeof(
double));
456 double VolA=0.,VolB=0.;
457 double VolFracA=0.,VolFracB=0.;
458 double SqrGradCoeff=0.;
459 for(
int n=0;n<NMax;n++){
463 double Coeff[4] = {1.,0.,0.,1.};
464 double MaxA=0.,MaxB=0.;
465 for(
int n=0;n<NMax;n++){
466 if(MaxA < st[1][n]) MaxA = st[1][n];
467 if(MaxB < st[2][n]) MaxB = st[2][n];
469 for(
int n=0;n<NMax;n++){
470 if(st[1][n] > MaxA*.5)
472 if(st[2][n] > MaxB*.5)
475 VolFracA = VolA / (VolA + VolB);
476 VolFracB = VolB / (VolA + VolB);
477 SqrGradCoeff = 19.13/(24.*VolFracA*VolA)+3.04/(24.*VolFracB*VolB);
479 DerO4(
sp+ElMin,temp1,ElMax-ElMin);
481 DerO4(
sp+ElMin,temp2,ElMax-ElMin);
482 for(
int i=0;i<4;i++){
483 Coeff[i] *= SqrGradCoeff;
485 for(
int n=0;n<NMax;n++){
486 Punti[n] = Coeff[0]*temp1[n]*temp1[n];
487 Punti[n] += Coeff[1]*temp1[n]*temp2[n];
488 Punti[n] += Coeff[2]*temp2[n]*temp1[n];
489 Punti[n] += Coeff[3]*temp2[n]*temp2[n];
493 for(
int n=75;n<125;n++){
504 int CoordX = RefAbsc[CoordY];
505 if(DIS_IF_TYPE(LogLog,DIS_LOGX)){
506 Puntix = (
double *)calloc(ElMax-ElMin,
sizeof(*Puntix));
507 for(
int i=ElMin;i<ElMax;i++){
508 if(st[CoordX][i] > 0.)
509 Puntix[i-ElMin] = log10(st[CoordX][i]);
513 Puntix = st[CoordX]+ElMin;
515 if(DIS_IF_TYPE(LogLog,DIS_LOGY)){
516 Puntiy = (
double *)calloc(ElMax-ElMin,
sizeof(*Puntiy));
517 for(
int i=ElMin;i<ElMax;i++){
518 if(st[CoordY][i] > 0.)
519 Puntiy[i-ElMin] = log10(st[CoordY][i]);
523 Puntiy = st[CoordY]+ElMin;
525 r1 =
InterRett(Puntix,Puntiy,ElMax-ElMin);
526 if(DIS_IF_TYPE(LogLog,DIS_LOGX)) free(Puntix);
527 if(DIS_IF_TYPE(LogLog,DIS_LOGY)) free(Puntiy);
532 int CoordX = RefAbsc[CoordY];
533 r1 =
InterExp(st[CoordX]+ElMin,st[CoordY]+ElMin,ElMax-ElMin);
537 int CoordX = RefAbsc[CoordY];
545 int CoordX = RefAbsc[CoordY];
546 if(DIS_IF_TYPE(LogLog,DIS_LOGX)){
547 Puntix = (
double *)calloc(ElMax-ElMin,
sizeof(*Puntix));
548 for(
int i=ElMin;i<ElMax;i++){
549 if(st[CoordX][i] > 0.)
550 Puntix[i] = log(st[CoordX][i]);
556 if(DIS_IF_TYPE(LogLog,DIS_LOGY)){
557 Puntiy = (
double *)calloc(ElMax-ElMin,
sizeof(*Puntix));
558 for(
int i=ElMin;i<ElMax;i++){
559 if(st[CoordY][i] > 0.)
560 Puntiy[i] = log10(st[CoordY][i]);
567 if(DIS_IF_TYPE(LogLog,DIS_LOGX))
569 if(DIS_IF_TYPE(LogLog,DIS_LOGY))
580 double **Histo = (
double **)calloc(NHisto,
sizeof(
double));
581 for(
int h=0;h<NHisto;h++){
582 Histo[h] = (
double *)calloc(NBin,
sizeof(
double));
584 for(
int v=0,h=0;v<NVar;v++){
586 for(
int b=0;b<
NBin;b++){
587 Histo[h][b] = st[v][b];
593 double Border[2] = {xGlobMin,xGlobMax};
594 double tolerance = 0.00001;
595 double *NanoDist = (
double *)calloc(NHisto,
sizeof(
double));
596 double *kSpring = (
double *)calloc(NHisto,
sizeof(
double));
597 for(
int h=0;h<NHisto;h++){
598 kSpring[h] = Histo[h][NBin-2];
599 NanoDist[h] = Histo[h][NBin-1];
614 WeightHisto(Histo,Border,NBin-2,NHisto,tolerance,NanoDist,kSpring);
615 for(
int h=0;h<NHisto;h++)
635 dInter = (
double *)realloc(dInter,
NBin*
sizeof(
double));
636 dInter1 = (
double *)realloc(dInter1,
NBin*
sizeof(
double));
639 if(n < 0 || n > NVar)
644 if(n < 0 || n >= NVar)
659 if(n<0 || n>NMax-1 ){printf(
"Wrong row\n");
return 0.;}
660 if(CoordY<0 || v>
NBin-1){printf(
"Wrong col\n");
return 0.;}
662 return st[CoordY][n];
665 return SetNMax[CoordY];
669 if(CoordY<0 || n>NMax-1){ printf(
"Wrong row\n");
return 0.;}
671 return st[RefAbsc[CoordY]][n];
675 if(n<0 || n>NMax-1){ printf(
"Wrong row\n");
return 0.;}
676 if(IfPuntiAlloc)
return 0.;
682 if(n<0 || n>NMax-1){ printf(
"Wrong row\n");
return 0.;}
683 if(IfPuntiAlloc)
return 0.;
692 if(IfPuntiAlloc)
return 0.;
694 double Min = Punti[0];
695 for(
int p=0;p<NMaxPunti;p++)
702 if(IfPuntiAlloc)
return 0.;
704 double Max = Punti[0];
705 for(
int p=0;p<NMaxPunti;p++)
713 Punti1 = (
double *)realloc(Punti1,NMaxPunti*
sizeof(
double));
714 for(
int n=0;n<NMax;n++){
715 Punti1[n] = Punti[n];
720 for(
int c=0;c<NVar;c++){
721 printf(
"%d ",RefAbsc[c]);
723 printf(
"\n--------------\n");
724 for(
int r=0;r<NMax;r++){
726 for(
int c=0;c<NVar;c++){
728 printf(
"%.5g ",st[r][c]);
734 for(
int i=0;i<NMax;i++){
735 for(
int j=i;j>0;j--){
737 for(
int n=0;n<NVar;n++){
747 if((SALVA = fopen(file,
"w"))==0)
748 printf(
"Non s'apre %s, Permessi?\n",file);
749 for(
int n=0;n<NMaxPunti;n++)
750 fprintf(SALVA,
"%lf %lf\n",Punti1[n],Punti[n]);
755 int CoordX = RefAbsc[CoordY];
756 if((SALVA = fopen(file,
"w"))==0)
757 printf(
"Non s'apre %s, Permessi?\n",file);
758 for(
int n=NVisMin;n<NVisMax;n++){
759 if(DIS_IF_TYPE(LogLog,DIS_LOGLOG))
760 fprintf(SALVA,
"%lf %lf \n",log10(st[CoordX][n]),log10(st[CoordY][n]));
762 fprintf(SALVA,
"%lf %lf \n",st[CoordX][n],st[CoordY][n]);
768 if((SALVA = fopen(file,
"w"))==0)
769 printf(
"Non s'apre %s, Permessi?\n",file);
770 if(DIS_IF_TYPE(LogLog,DIS_LOGLOG)){
771 for(
int n=NVisMin;n<NVisMax;n++){
772 for(
int v=0;v<NVar;v++){
773 fprintf(SALVA,
"%.4g ",log10(st[v][n]));
779 for(
int n=NVisMin;n<NVisMax;n++){
780 for(
int v=0;v<NVar;v++){
781 fprintf(SALVA,
"%.4g ",st[v][n]);
789 double *BulkVal = (
double *)calloc(NVar,
sizeof(
double));
792 for(
int v=0;v<NVar;v++){
796 int NThick = (int)(NMax/(
double)NCol);
798 for(
int v=0;v<NVar;v++){
799 for(
int nx=NMax/2;nx<3*(NMax/4);nx++){
800 if(isnan(st[v][nx]))
continue;
801 BulkVal[v] += st[v][nx];
805 for(
int v=0;v<NVar;v++){
806 BulkVal[v] /= Count > 0. ? Count/(double)NVar : 1.;
807 BulkVal[v] = fabs(BulkVal[v]) > 0. ? 1./BulkVal[v] : 1.;
809 FILE *FWrite = fopen(FName,
"w");
810 for(
int nx=0;nx<NMax;nx++){
811 fprintf(FWrite,
"%lf ",
Abscissa(1,nx));
812 for(
int v=1;v<NVar;v++){
813 fprintf(FWrite,
"%lf ",st[v][nx]*BulkVal[v]);
815 fprintf(FWrite,
"\n");
821 FILE *FOut = fopen(FName,
"w");
824 double Dx = 1./(xGlobMax-xGlobMin);
826 double Dz = 1./(GlobMax-GlobMin);
827 fprintf(FOut,
"# l(1 1 1) v[%d] d[part] \n",NMax/2);
828 double *Cm = (
double *)calloc(NVar,
sizeof(
double));
830 double *Bulk = (
double *)calloc(NVar,
sizeof(
double));
831 int NBulk = NElMax-NElMin;
832 for(
int v=0;v<NVar;v++){
833 for(
int n=0;n<NMax;n++){
834 if(n >= NBulk) Cm[v] +=
Val(v,n);
837 for(
int v=0;v<NVar;v++){
839 Cm[v] /= (double)(NMax-NBulk);
842 CmTot = CmTot/(double)(NVar-1);
843 for(
int v=0;v<NVar;v++){
844 Bulk[v] = .1/fabs(Cm[v]-CmTot);
846 for(
int v=0;v<NVar;v++){
848 double OffSet = .6 - .2*(v-1);
849 for(
int n=0;n<NMax;n++){
850 double Zed = (
Val(v,n)-Cm[v])*Bulk[v]+OffSet;
852 fprintf(FOut,
"{t[%d %d %d] x(%lf %lf %lf)}\n",p++,2,2,
Abscissa(v,n)*Dx,.5,Zed);
860 FILE *
TecPlot = fopen(FName,
"w");
861 double *BulkVal = (
double *)calloc(NVar,
sizeof(
double));
865 for(
int v=0;v<NVar;v++){
869 int NThick = (int)(NMax/(
double)NCol);
870 int Nx = 2*(int)(NMax/3.);
872 for(
int v=0;v<NVar;v++){
873 for(
int nx=NMax/2;nx<3*(NMax/4);nx++){
874 if(isnan(st[v][nx]))
continue;
875 BulkVal[v] += st[v][nx];
879 for(
int v=0;v<NVar;v++){
880 BulkVal[v] /= Count > 0. ? Count/(double)NVar : 1.;
881 printf(
"%d %lf\n",v,BulkVal[v]);
882 BulkVal[v] = fabs(BulkVal[v]) > 0. ? 1./BulkVal[v] : 1.;
884 fprintf(TecPlot,
"VARIABLES = \"R\", \"Z\", \"percentage\"\n");
885 fprintf(TecPlot,
"ZONE J=%d, K=%d, F=POINT\n",Nx,Ny);
886 double Int = .5*(xGlobMax-xGlobMin)/(
double)(Ny);
887 for(
int nx=0,v=0;nx<Nx;nx++){
888 for(
int ny=0;ny<Ny;ny++){
889 if((ny%(NThick/2))==0) v++;
892 double z =
Val(v,nx)*BulkVal[v];
894 fprintf(TecPlot,
"%lf %lf %lf\n",
Abscissa(v,nx),Int*ny,z);
902 Punti = (
double *)calloc(NMaxPunti,
sizeof(*Punti));
903 if( Punti == NULL){printf(
"Punti non s'alloca\n");return ;}
904 Punti1 = (
double *)calloc(NMaxPunti,
sizeof(*Punti));
905 if( Punti1 == NULL){printf(
"Punti non s'alloca\n");return ;}
906 PuntiErr = (
double *)calloc(NMaxPunti,
sizeof(*Punti));
907 if( PuntiErr == NULL){printf(
"Punti non s'alloca\n");return ;}
916 for(
int v=0;v<NVar;v++){
921 if(vAbs > NVar)
return;
924 if(NVar == 1) RefAbsc[vSet] = NVar;
926 else if(vAbs == REF_SEQ) RefAbsc[vSet] = NVar;
927 else RefAbsc[vSet] = vAbs;
930 if(vAbs > NVar || vAbs < REF_ASC)
return;
932 if(NVar == 1){ RefAbsc[0] = NVar;
return;}
933 for(
int v=0;v<NVar;v++){
934 if(vAbs == REF_SEQ) RefAbsc[v] = NVar;
935 else RefAbsc[v] = vAbs;
939 if(Ext < NVar && Ext >= 0){
950 double Resp = st[0][0];
952 for(
int v=0;v<NVar;v++){
954 Resp = st[v][NVisMin];
956 for(
int v=0;v<NVar;v++){
958 for(
int n=NVisMin;n<NVisMax;n++){
959 if(n >
pNRow(v))
continue;
960 if(isnan(st[v][n]))
continue;
969 double Resp = st[0][0];
971 for(
int v=0;v<NVar;v++){
973 Resp = st[v][NVisMin];
975 for(
int v=0;v<NVar;v++){
977 for(
int n=NVisMin;n<NVisMax;n++){
978 if(n >
pNRow(v))
continue;
979 if(isnan(st[v][n]))
continue;
989 for(
int v=0;v<NVar;v++){
993 Border[2] = st[v][NVisMin];
994 Border[3] = st[v][NVisMin];
999 for(
int v=0;v<NVar;v++){
1001 for(
int n=NVisMin;n<NVisMax;n++){
1002 if(n >=
pNRow(v))
continue;
1003 if(isnan(st[v][n]))
continue;
1006 if(Border[2] > st[v][n]) Border[2] = st[v][n];
1007 if(Border[3] < st[v][n]) Border[3] = st[v][n];
1010 xGlobMin = Border[0];
1011 xGlobMax = Border[1];
1012 GlobMin = Border[2];
1013 GlobMax = Border[3];
1016 double Resp = st[0][NVisMin];
1018 for(
int v=0;v<NVar;v++){
1019 if(RefAbsc[v] == NVar)
return NVisMin;
1021 Resp = st[v][NVisMin];
1025 for(
int v=0;v<NVar;v++){
1027 for(
int n=NVisMin;n<NVisMax;n++){
1028 if(n >
pNRow(v))
continue;
1029 if(isnan(st[v][n]))
continue;
1030 if(isinf(st[v][n]))
continue;
1036 printf(
"%lf\n",Resp);
1040 double Resp = st[0][NVisMin];
1042 for(
int v=0;v<NVar;v++){
1044 Resp = st[v][NVisMin];
1048 for(
int v=0;v<NVar;v++){
1050 for(
int n=NVisMin;n<NVisMax;n++){
1051 if(n >=
pNRow(v))
continue;
1052 if(Resp > st[v][n]){
1061 double Resp = st[0][NVisMin];
1064 for(
int v=0;v<NVar;v++){
1066 for(
int n=0;n<NMax;n++){
1067 if(st[v][n] <= 0.)
continue;
1072 if(IfContinue)
break;
1074 for(
int v=0;v<NVar;v++){
1076 for(
int n=NVisMin;n<NVisMax;n++){
1077 if(st[v][n] <= 0.)
continue;
1078 if(n >=
pNRow(v))
continue;
1079 if(Resp < st[v][n]) Resp = st[v][n];
1082 return log10(Resp > 0. ? Resp : 1.);
1085 double Resp = st[0][NVisMin];
1088 for(
int v=0;v<NVar;v++){
1090 for(
int n=0;n<NMax;n++){
1091 if(st[v][n] <= 0.)
continue;
1096 if(!IfContinue)
break;
1098 for(
int v=0;v<NVar;v++){
1100 for(
int n=NVisMin;n<NVisMax;n++){
1101 if(st[v][n] <= 0.)
continue;
1102 if(n >
pNRow(v))
continue;
1103 if(Resp > st[v][n]) Resp = st[v][n];
1106 return log10(Resp > 0. ? Resp : 1.);
1109 double Resp = st[CoordY][NVisMin];
1110 for(
int n=NVisMin;n<NVisMax;n++){
1111 if(Resp < st[CoordY][n])
1112 Resp = st[CoordY][n];
1117 double Resp = st[CoordY][NVisMin];
1118 for(
int n=NVisMin;n<NVisMax;n++){
1119 if(Resp > st[CoordY][n])
1120 Resp = st[CoordY][n];
1125 double Resp = st[CoordY][NVisMin];
1126 for(
int n=NVisMin;n<NVisMax;n++){
1127 if(st[CoordY][n] <= 0.)
continue;
1128 if(Resp < st[CoordY][n])
1129 Resp = st[CoordY][n];
1131 return log10(Resp > 0. ? Resp : 1.);
1135 for(
int n=NVisMin;n<NVisMax;n++){
1136 if(st[CoordY][n] <= 0.)
continue;
1137 Resp = st[CoordY][n];
1140 for(
int n=NVisMin;n<NVisMax;n++){
1141 if(st[CoordY][n] <= 0.)
continue;
1142 if(Resp > st[CoordY][n])
1143 Resp = st[CoordY][n];
1145 return log10(Resp > 0. ? Resp : 1.);
1148 strcpy(XFormula,str);
1151 strcpy(YFormula,str);
1155 for(
int n=0;n<NMax/2;n++){
1156 for(
int v=0;v<NVar;v++){
1158 st[v][n] = st[v][NMax-n-1];
1159 st[v][NMax-n-1] = Temp;
1167 int NOut = (int)(NMax*Fact);
1170 double *sw = (
double *)calloc(NOut,
sizeof(
double));
1173 double Max=st[CoordY][0];
1174 double Min=st[CoordY][0];
1175 for(
int n=0;n<NMax;n++){
1176 if(Max < st[CoordY][n]) Max = st[CoordY][n];
1177 if(Min > st[CoordY][n]) Min = st[CoordY][n];
1179 double DeltaIn=(Max-Min)/(
double)(NMax-1);
1180 double DeltaOut=(Max-Min)/(
double)(NOut-1);
1181 double *dArray = (
double *)calloc(NMax+2*NOrder+2,
sizeof(
double));
1182 int CoordX = RefAbsc[CoordY];
1183 for(
int vi=0;vi<NMax;vi++){
1184 Punti1[vi] = st[CoordX][vi];
1186 for(
int vi=0;vi<=NMax+2*NOrder;vi++){
1191 dArray[vi] = (vi-NOrder+2)*DeltaIn+Min;
1194 dArray[vi] = (vi-NOrder+1)*DeltaIn+Min;
1197 Punti[0] = st[CoordY][0];
1198 Punti[NOut-1] = st[CoordY][NMax-1];
1199 for(
int vo=1;vo<NOut-1;vo++){
1201 double x = DeltaOut*vo+Min;
1202 for(
int vi=vo-1,vn=0;vi<vo+NOrder+1;vi++){
1210 double Blendx =
Blend(dArray,x,vn,NOrder);
1211 Punti[vo] += Blendx*st[CoordY][vn];
1220 int NOut = (int)(NMax*Fact);
1224 int CoordX = RefAbsc[CoordY];
1225 for(
int n=0;n<NMax;n++){
1226 Punti[n] = st[CoordY][n];
1227 Punti1[n] = st[CoordX][n];
1233 int IfMinImConv = 0;
1234 for(
int v=0;v<NVar;v++){
1241 SigErr(NVar < 8,
"Two files are with the coordinate positions are expected\n");
1242 for(
int n=0;n<NMax;n++){
1243 if(n >
pNRow(0))
continue;
1244 if(n >
pNRow(1))
continue;
1246 for(
int d=0;d<3;d++){
1247 Dist += SQR(st[1+d][n] - st[5+d][n]);
1251 Punti1[n] = (double)n;
void Sort()
Sort with respect to a coordinate.
double pPunti(int n)
Value of the elaborated array at position.
int SpettroSegnale(int NElMin, int NElMax)
Calculate the spectrum.
int pNRow(int CoordY)
Print the maximum number of data for the column.
void ScriviPunti(char *file)
Writes the content of the elaborated array.
double pMinLog(int CoordY, int NVisMin, int NVisMax)
Print the minimum of the column.
void SommaSegnali()
Sums all the yCoordinates.
void Radice(double *st, double *sw, int N)
Compute the root of the signal.
VarDatFile(char *file, int NBin)
Moltiplication factor for a scaled set (MediaMob)
int ElabSegnale(int NElMin, int NElMax)
Do a generic elaboration.
void DerO4(double *st, double *sw, int NMass)
Derivate O(4) of.
int FileInfo(FILE *InFIle, int *NCol)
Reads information contained in the file.
double Integrazione(double *Punti, double *sw, int NMass)
Integral of.
void AverageOrdinate(int ElMin, int ElMax, double *Distr, double *xBound)
Average of all ordinate.
double pMinGlobLog(int NVisMin, int NVisMax)
Print the minimum of all sets.
void Print()
Prints the content in memory.
MOMENTI InterGaussSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a Gaussian fit.
double pPuntiErr(int n)
Value of the error array at postion.
PARABOLA MinimoParabola(double a, double b, double *Px, double *Py, int NMass)
Minimum of the Parabola between.
int AutocorSegnale(int NElMin, int NElMax)
Autocorrelation of the signal.
RETTA InterRettSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a liner fit.
double pMinGlob(int NVisMin, int NVisMax)
Print the minimum of all sets.
void ElabSt(double *st, double *sw, int NMass)
Pointer to a function which operates on.
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.
MOMENTI Distribuzione(const double *st, int NMass)
Moments of a signal.
int WeightHistoSign(int NHisto)
Weighted histogram analysis.
MOMENTI WeightAverage(const double *sx, const double *sy, int NMax)
Calculate the weighted average.
double * sp
Points to a column of st.
void ConvoluteMatrix(double *Plot, int NGrid, int NDim, int IfMinImConv)
Convolute with a matrix.
double PuntiMax()
Print the maximum of.
double pMaxGlob(int NVisMin, int NVisMax)
Print the maximum of all sets.
MOMENTI WeightAverageSet(int CoordY, int ElMin, int ElMax)
Weighted distribution.
double pMax(int CoordY, int NVisMin, int NVisMax)
Print the maximum of the column.
char * PrintHeader()
Print the header.
void PuntaInt(double *sp)
Point the internal pointer to an external memory.
int ReadLine(char *cLine, double *Value)
Reads a single line.
double PuntiMin()
Print the minimum of.
Moments of a distribution.
RETTA InterExp(double *Px, double *Py, int NMass)
Exponential interpolation.
void ImpCoordY(int Ext)
Set the column for the y array.
void VarieSegnale()
Points the function Elab to the square gradient, probably not working.
void WeightHisto(double **hist, double *Border, int NBin, int NHisto, double tolerance, double *OrPos, double *kSpring)
Weighted histogram analysis.
void DoubleDistFluct()
Distribution of distances.
double pMaxLog(int CoordY, int NVisMin, int NVisMax)
Print the maximum of the column.
MOMENTI DistrErr(const double *st, int NMass, double *Intervalli, double *Err, int Valori, double *Confine, int IfNorm)
Moments and histogram of a signal between two values.
void ImpSequence()
Set the natural sequence as abscissa for all sets.
PARABOLA ParabolaSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a parabolic fit.
double pMaxGlobLog(int NVisMin, int NVisMax)
Print the maximum of all sets.
int NormalizeArea(double *st, int NMass)
Normalize.
void Swap(int i, int j, double *Sign)
Swap to indices.
void setXFormula(char *str)
Set the value of XFormula.
bool RadiceSegnale()
Transforms the signal into its square root.
void DistrSample(double *Px, double *Py, int NMax, double **Distr, int NBin, const int NSample, int IfNorm, double *xBound)
Compare the distribution of a sample of data.
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.
void ImpCoordX(int vAbs)
Set the columns for the x array.
MOMENTI DistribuzioneGauss(const double *st, int NMass, double *Intervalli, double *dInt, int Valori, int IfNorm)
Look for the Gaussian distribution.
int CorrelaDuePunti(double *st, int NMass, double *sw, int Punti)
Two points correlation.
void RescaleToBulk(char *FName)
Rescale to bulk.
MOMENTI DistrExpSegnale(int NElMin, int NElMax, int IfNorm)
Exponential distribution of a signal.
void FillGaussian(double Sigma, double CutOff)
Fill the entries for the Gauss blur.
MOMENTI DistrGaussSegnale(int ElMin, int ElMax, int IfNorm)
Tests a gaussian distribution of the signal.
int NBin
Number of point of the distribution.
void Reverse()
Reverse the sets.
void AutosimilaritaSegnale(int)
Selfsimilarity.
double Val(int CoordY, int n)
Value at the position.
int IsAbscissa(int Col)
If the column is an ascissa.
void ScriviFile(char *file, int CoordY, int LogLog, int NVisMin, int NVisMax)
Writes the content of the pointed vector.
Matrice computes the algebric operations on matrices.
void ExportTxvl(char *FName, int NElMin, int NElMax)
Export in the txvl file format.
void setYFormula(char *str)
Set the value of YFormula.
MOMENTI InterGauss(double *Px, double *Py, int NMass)
Gaussian interpolation.
void SmoothGauss(double Fact, int CoordY, int NVisMin, int NVisMax)
Smooth the line.
int NormalizzaInter()
Normalize the intervals.
void CambiaNBin(int)
Reallocate the pointer dInter dInter1.
double pxMinGlob(int NVisMin, int NVisMax)
Print the abscissa minimum of all sets.
int CorrelaADuePunti(int dist)
To point correlation at a distance dist.
int Smooth(double Fact, int CoordY, int NVisMin, int NVisMax)
Smooth the line.
void TecPlot(char *FName)
Export a contour plot.
double pxMaxGlob(int NVisMin, int NVisMax)
Print the abscissa maximum of all sets.
double SumSegnale(int CoordY, int NElMin, int NElMax)
Sum the values between ElMin and ElMax.
void CambiaPunti()
Copies Punti in Punti1 to store the information of the already elaborated array, to be fixed...
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.
void Autocor(bool *st, double *sAuto, int N)
Compute the autocorrelation of a boolean signal.
void PuntiFree()
Free Punti if it is allocated.
double Blend(const double *dPoint, double x, int nPoint, int nOrder)
For the BSpline.
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.
int Normalizza(double *st, int NMass)
Normalize.
double pMin(int CoordY, int NVisMin, int NVisMax)
Print the minimum of the column.
MOMENTI DistrSignErr(int NElMin, int NElMax, double *Border, int IfNorm)
Distribution of a signal with error.
void Spettro(double *st, double *sw, int NMass)
Compute the spectrum.
MOMENTI DistrSegnale(int NElMin, int NElMax, int IfNorm)
Distribution of a signal.
void Autosimilarita(double *st, int NMass, double *sw, int Valori)
Self similarity.
void PuntiAlloc()
Allocates.
void ScriviTutto(char *file, int LogLog, int NVisMin, int NVisMax)
Writes all the content in memory.
void MediaMobile(double *st, int NMass, double *sw, int Parti)
Running average.
RETTA InterRett(double *Px, double *Py, int NMass)
Linear interpolation.
int MediaMobSegnale(int)
Running average.