Allink  v0.1
1 #ifndef VAR_DAT_FILE_H
2 #define VAR_DAT_FILE_H
3 #include "../include/Matematica.h"
4 #define DIS_IF_TYPE(c,t) ( ((c)&(t))==(t) )
5 #define DIS_ADD_TYPE(c,t) ( (c)|=(t) )
6 #define DIS_REM_TYPE(c,t) ( (c)&=(~t) )
7 enum VisLog{
10  DIS_NOLOG = 0x001,
12  DIS_LOGX = 0x002,
14  DIS_LOGY = 0x004,
16  DIS_LOGLOG= 0x006,
17 };
19 enum RefType{
21  REF_SEQ = -1,
23  REF_ASC = -2,
24 };
26 class VarDatFile:public Matematica{
27  private:
29  char XFormula[60];
31  char YFormula[60];
33  char Header[STRSIZE];
35  void Init();
37  void Allocate();
39  int NMax;
41  int NMaxPunti;
43  int NVar;
45  double **st;
47  double *sMin;
49  double *sMax;
51  char **sc;
53  int *SetNMax;
55  int *sType;
57  int *sColor;
59  int *RefAbsc;
61  double *Punti;
63  double *PuntiErr;
65  double *Punti1;
67  double *dInter;
69  double *dError;
71  double *dInter1;
73  double GlobMax;
75  double GlobMin;
77  double xGlobMax;
79  double xGlobMin;
81  int IfPuntiAlloc;
83  int IfPuntiFree;
85  //int Incr;
86  public:
88  VarDatFile(char *file,int NBin);
90  VarDatFile(int ExtNMax,int ExtNVar,int ExtNBin);
92  VarDatFile(double **ExtSt,int ExtNMax,int ExtNVar,int ExtNBin);
94  VarDatFile(char **FileList,int *Pos,int NFile,int Values);
96  ~VarDatFile();
98  int Aggiungi(char *file);
100  int FileInfo(FILE *InFIle,int *NCol);
102  int ReadLine(char *cLine,double *Value);
104  int ReadLine(FILE *InFile, const char *Format, ...);
106  int ElabSegnale(int NElMin,int NElMax);
108  MOMENTI DistrSegnale(int NElMin,int NElMax,int IfNorm);
110  MOMENTI DistrLogSegnale(int NElMin,int NElMax,int IfNorm);
112  MOMENTI DistrExpSegnale(int NElMin,int NElMax,int IfNorm);
114  MOMENTI DistrSegnale(int NElMin,int NElMax,double *Border,int IfNorm);
116  MOMENTI DistrSignErr(int NElMin,int NElMax,double *Border,int IfNorm);
118  MOMENTI DistrGaussSegnale(int ElMin,int ElMax,int IfNorm);
120  MOMENTI WeightAverageSet(int CoordY,int ElMin, int ElMax);
122  void DistrSignSample(int ElMin, int ElMax,double **Distr,int NSample,int IfNorm,double *xBound);
124  int SpettroSegnale(int NElMin,int NElMax);
126  void SpeLine(int ElMin,int ElMax,int NBin,double *Spe);
128  int NormalizzaSegnale(int NElMin,int NElMax);
130  int NormalizzaInter();
132  bool RadiceSegnale();
134  int AutocorSegnale(int NElMin,int NElMax);
136  double SumSegnale(int CoordY,int NElMin,int NElMax);
138  double IntSegnale();
140  void SommaSegnali();
142  void AverageOrdinate(int ElMin, int ElMax,double *Distr,double *xBound);
144  void Punta(int n);
146  void Punta(double **ExtSt,int n);
148  void Punta(double *sp,int n);
150  void PuntaInt(double *sp);
158  double VarieSegnale(int NElMin,int NElMax);
160  RETTA InterRettSegnale(int CoordY,int NElMin,int NElMax,int LogLog);
162  RETTA InterExpSegnale(int CoordY,int NElMin,int NElMax,int LogLog);
164  MOMENTI InterGaussSegnale(int CoordY,int NElMin,int NElMax,int LogLog);
166  PARABOLA ParabolaSegnale(int CoordY,int NElMin,int NElMax,int LogLog);
168  int MediaMobSegnale(int);
170  int WeightHistoSign(int NHisto);
172  int CorrelaADuePunti(int dist);
174  void AutosimilaritaSegnale(int);
176  void CambiaNBin(int);
179  void CambiaPunti();
181  void Print();
183  void Sort();
185  void ScriviPunti(char *file);
187  void ScriviFile(char *file,int CoordY,int LogLog,int NVisMin,int NVisMax);
189  void ScriviTutto(char *file,int LogLog,int NVisMin,int NVisMax);
191  void RescaleToBulk(char *FName);
193  void ExportTxvl(char *FName,int NElMin,int NElMax);
195  void TecPlot(char *FName);
197  void PuntiAlloc();
199  void PuntiFree();
201  int NBin;
203  int pNVar(){ return NVar;};
205  int pNMax(){return NMax;};
207  int pNRow(int CoordY);
209  void pGlobBorder(double *xMin,double *xMax,double *yMin,double *yMax){
210  *xMin = xGlobMin;
211  *xMax = xGlobMax;
212  *yMin = GlobMin;
213  *yMax = GlobMax;
214  };
216  double Val(int CoordY,int n);
218  double Abscissa(int CoordY,int n);
220  double pPunti(int n);
222  double pPuntiErr(int n);
224  void pMinMaxGlob(int NVisMin,int NVisMax);
226  double pMaxGlob(int NVisMin,int NVisMax);//{return GlobMax;};
228  double pMinGlob(int NVisMin,int NVisMax);//{return GlobMin;};
230  double pxMinGlob(int NVisMin,int NVisMax);//{return GlobMin;};
232  double pxMaxGlob(int NVisMin,int NVisMax);//{return GlobMax;};
234  double pMax(int CoordY,int NVisMin,int NVisMax);//{return sMax[n];};
236  double pMin(int CoordY,int NVisMin,int NVisMax);//{return sMin[n];};
238  double pMaxGlobLog(int NVisMin,int NVisMax);//{return GlobMax;};
240  double pMinGlobLog(int NVisMin,int NVisMax);//{return GlobMin;};
242  double pMaxLog(int CoordY,int NVisMin,int NVisMax);//{return sMax[n];};
244  double pMinLog(int CoordY,int NVisMin,int NVisMax);//{return sMin[n];};
246  double pInter(int n){return dInter[n];};
248  double pError(int n){return dError[n];};
250  double pInter1(int n){return dInter1[n];};
252  double PuntiMin();
254  double PuntiMax();
256  int IsAbscissa(int Col){
257  if(RefAbsc[Col] == Col) return 1; return 0;};
259  int pRefAbsc(int Col){return RefAbsc[Col];};
261  int pSetNMax(int Col){return SetNMax[Col];};
263  int IsSequence(int Col){return RefAbsc[Col]==REF_SEQ?1:0;};
265  void ImpSequence(int Col);
267  void ImpSequence();
269  void ImpCoordX(int vAbs);
271  void ImpCoordX(int vSet,int vAbs);
273  void ImpCoordY(int Ext);
275  void setXFormula(char *str);
277  void setYFormula(char *str);
279  void Reverse();
281  int Smooth(double Fact,int CoordY,int NVisMin,int NVisMax);
283  void SmoothGauss(double Fact,int CoordY,int NVisMin,int NVisMax);
285  void DoubleDistFluct();
287  void WriteFormula(char *Exit);
289  char *PrintHeader();
291  double *sp;
292 };
void Sort()
Sort with respect to a coordinate.
Definition: VarDatFile.cpp:733
double pPunti(int n)
Value of the elaborated array at position.
Definition: VarDatFile.cpp:673
int SpettroSegnale(int NElMin, int NElMax)
Calculate the spectrum.
Definition: VarDatFile.cpp:388
int pNRow(int CoordY)
Print the maximum number of data for the column.
Definition: VarDatFile.cpp:664
void ScriviPunti(char *file)
Writes the content of the elaborated array.
Definition: VarDatFile.cpp:745
double pMinLog(int CoordY, int NVisMin, int NVisMax)
Print the minimum of the column.
void SommaSegnali()
Sums all the yCoordinates.
Definition: VarDatFile.cpp:441
void SquareGradient(double *st, double *sw, int NMass)
Square of the gradient.
int pNMax()
Print the maximum number of data in the array.
Definition: VarDatFile.h:205
VarDatFile(char *file, int NBin)
Moltiplication factor for a scaled set (MediaMob)
int ElabSegnale(int NElMin, int NElMax)
Do a generic elaboration.
Definition: VarDatFile.cpp:376
void DerO4(double *st, double *sw, int NMass)
Derivate O(4) of.
int FileInfo(FILE *InFIle, int *NCol)
Reads information contained in the file.
Definition: VarDatFile.cpp:265
void AverageOrdinate(int ElMin, int ElMax, double *Distr, double *xBound)
Average of all ordinate.
Definition: VarDatFile.cpp:325
double pInter1(int n)
Print the postion.
Definition: VarDatFile.h:250
double pMinGlobLog(int NVisMin, int NVisMax)
Print the minimum of all sets.
int IsSequence(int Col)
If the column is an ascissa.
Definition: VarDatFile.h:263
void Print()
Prints the content in memory.
Definition: VarDatFile.cpp:719
Parabolas coefficients.
MOMENTI InterGaussSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a Gaussian fit.
Definition: VarDatFile.cpp:536
double pPuntiErr(int n)
Value of the error array at postion.
Definition: VarDatFile.cpp:680
int AutocorSegnale(int NElMin, int NElMax)
Autocorrelation of the signal.
Definition: VarDatFile.cpp:382
RETTA InterRettSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a liner fit.
Definition: VarDatFile.cpp:500
double pMinGlob(int NVisMin, int NVisMax)
Print the minimum of all sets.
Definition: VarDatFile.cpp:968
void Punta(int n)
Points to a different column.
Definition: VarDatFile.cpp:638
void SpeLine(int ElMin, int ElMax, int NBin, double *Spe)
Spectrum of a sequence of lines.
Definition: VarDatFile.cpp:394
int WeightHistoSign(int NHisto)
Weighted histogram analysis.
Definition: VarDatFile.cpp:578
double * sp
Points to a column of st.
Definition: VarDatFile.h:291
double PuntiMax()
Print the maximum of.
Definition: VarDatFile.cpp:700
void WriteFormula(char *Exit)
Execute a formula defined in XFormula and YFormula.
double pMaxGlob(int NVisMin, int NVisMax)
Print the maximum of all sets.
Definition: VarDatFile.cpp:949
MOMENTI WeightAverageSet(int CoordY, int ElMin, int ElMax)
Weighted distribution.
Definition: VarDatFile.cpp:371
double pMax(int CoordY, int NVisMin, int NVisMax)
Print the maximum of the column.
char * PrintHeader()
Print the header.
Definition: VarDatFile.cpp:687
int pRefAbsc(int Col)
If the column is an ascissa.
Definition: VarDatFile.h:259
void PuntaInt(double *sp)
Point the internal pointer to an external memory.
Definition: VarDatFile.cpp:648
Linear interpolation.
int ReadLine(char *cLine, double *Value)
Reads a single line.
Definition: VarDatFile.cpp:292
void Modulo(double *st, double *sw, int NMass)
Compute the modulus.
double PuntiMin()
Print the minimum of.
Definition: VarDatFile.cpp:690
Moments of a distribution.
void pGlobBorder(double *xMin, double *xMax, double *yMin, double *yMax)
Print global borders.
Definition: VarDatFile.h:209
void ImpCoordY(int Ext)
Set the column for the y array.
Definition: VarDatFile.cpp:938
void VarieSegnale()
Points the function Elab to the square gradient, probably not working.
Definition: VarDatFile.h:154
void DoubleDistFluct()
Distribution of distances.
double pMaxLog(int CoordY, int NVisMin, int NVisMax)
Print the maximum of the column.
void ImpSequence()
Set the natural sequence as abscissa for all sets.
Definition: VarDatFile.cpp:915
PARABOLA ParabolaSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a parabolic fit.
Definition: VarDatFile.cpp:541
double pMaxGlobLog(int NVisMin, int NVisMax)
Print the maximum of all sets.
void ModuloSegnale()
Points the function Elab to the module, probably not working.
Definition: VarDatFile.h:156
void setXFormula(char *str)
Set the value of XFormula.
bool RadiceSegnale()
Transforms the signal into its square root.
Definition: VarDatFile.cpp:422
void DistrSignSample(int ElMin, int ElMax, double **Distr, int NSample, int IfNorm, double *xBound)
Distributions of data organized in different samples.
Definition: VarDatFile.cpp:365
double IntSegnale()
Numerical integration of the signal.
Definition: VarDatFile.cpp:427
double pInter(int n)
Print the postion.
Definition: VarDatFile.h:246
Definition: VarDatFile.cpp:160
void ImpCoordX(int vAbs)
Set the columns for the x array.
Definition: VarDatFile.cpp:929
void RescaleToBulk(char *FName)
Rescale to bulk.
Definition: VarDatFile.cpp:788
MOMENTI DistrExpSegnale(int NElMin, int NElMax, int IfNorm)
Exponential distribution of a signal.
Definition: VarDatFile.cpp:352
MOMENTI DistrGaussSegnale(int ElMin, int ElMax, int IfNorm)
Tests a gaussian distribution of the signal.
Definition: VarDatFile.cpp:368
int pNVar()
Print the number of variables.
Definition: VarDatFile.h:203
int NBin
Number of point of the distribution.
Definition: VarDatFile.h:201
void Reverse()
Reverse the sets.
void AutosimilaritaSegnale(int)
Definition: VarDatFile.cpp:626
double pError(int n)
Print the postion.
Definition: VarDatFile.h:248
double Val(int CoordY, int n)
Value at the position.
Definition: VarDatFile.cpp:657
int IsAbscissa(int Col)
If the column is an ascissa.
Definition: VarDatFile.h:256
void ScriviFile(char *file, int CoordY, int LogLog, int NVisMin, int NVisMax)
Writes the content of the pointed vector.
Definition: VarDatFile.cpp:753
Reads and stores a data file to be elaborated via Matematica.
Definition: VarDatFile.h:26
void ExportTxvl(char *FName, int NElMin, int NElMax)
Export in the txvl file format.
Definition: VarDatFile.cpp:820
void DerivataSegnale()
Points the function Elab to the derivative, probably not working.
Definition: VarDatFile.h:152
void setYFormula(char *str)
Set the value of YFormula.
void SmoothGauss(double Fact, int CoordY, int NVisMin, int NVisMax)
Smooth the line.
int NormalizzaInter()
Normalize the intervals.
Definition: VarDatFile.cpp:415
void CambiaNBin(int)
Reallocate the pointer dInter dInter1.
Definition: VarDatFile.cpp:631
double pxMinGlob(int NVisMin, int NVisMax)
Print the abscissa minimum of all sets.
int CorrelaADuePunti(int dist)
To point correlation at a distance dist.
Definition: VarDatFile.cpp:621
int Smooth(double Fact, int CoordY, int NVisMin, int NVisMax)
Smooth the line.
void TecPlot(char *FName)
Export a contour plot.
Definition: VarDatFile.cpp:859
Implementation of useful algorythms.
Definition: Matematica.h:76
int pSetNMax(int Col)
If the column is an ascissa.
Definition: VarDatFile.h:261
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.
Definition: VarDatFile.cpp:431
void CambiaPunti()
Copies Punti in Punti1 to store the information of the already elaborated array, to be fixed...
Definition: VarDatFile.cpp:710
MOMENTI DistrLogSegnale(int NElMin, int NElMax, int IfNorm)
Logarithmic distribution of a signal.
Definition: VarDatFile.cpp:345
int Aggiungi(char *file)
Add the content of the file into the memory.
Definition: VarDatFile.cpp:189
void pMinMaxGlob(int NVisMin, int NVisMax)
Find the borders globally.
Definition: VarDatFile.cpp:986
void PuntiFree()
Free Punti if it is allocated.
Definition: VarDatFile.cpp:943
double Abscissa(int CoordY, int n)
Value of the Abscissa at position.
Definition: VarDatFile.cpp:667
int NormalizzaSegnale(int NElMin, int NElMax)
Normalize the signal.
Definition: VarDatFile.cpp:418
RETTA InterExpSegnale(int CoordY, int NElMin, int NElMax, int LogLog)
Computes a exponential fit.
Definition: VarDatFile.cpp:530
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.
Definition: VarDatFile.cpp:362
MOMENTI DistrSegnale(int NElMin, int NElMax, int IfNorm)
Distribution of a signal.
Definition: VarDatFile.cpp:342
void PuntiAlloc()
Definition: VarDatFile.cpp:900
void ScriviTutto(char *file, int LogLog, int NVisMin, int NVisMax)
Writes all the content in memory.
Definition: VarDatFile.cpp:766
int MediaMobSegnale(int)
Running average.
Definition: VarDatFile.cpp:573