-Float_t AliCheb3DCalc::Eval(Float_t *par) const
-{
- // evaluate Chebyshev parameterization for 3D function.
- // VERY IMPORTANT: par must contain the function arguments ALREADY MAPPED to [-1:1] interval
- Float_t &z = par[2];
- Float_t &y = par[1];
- Float_t &x = par[0];
- //
- int ncfRC;
- for (int id0=fNRows;id0--;) {
- int nCLoc = fNColsAtRow[id0]; // number of significant coefs on this row
- int Col0 = fColAtRowBg[id0]; // beginning of local column in the 2D boundary matrix
- for (int id1=nCLoc;id1--;) {
- int id = id1+Col0;
- fTmpCf1[id1] = (ncfRC=fCoefBound2D0[id]) ? ChebEval1D(z,fCoefs + fCoefBound2D1[id], ncfRC) : 0.0;
- }
- fTmpCf0[id0] = nCLoc>0 ? ChebEval1D(y,fTmpCf1,nCLoc):0.0;
- }
- return ChebEval1D(x,fTmpCf0,fNRows);
- //
-}
-
-//_______________________________________________
-#ifdef _INC_CREATION_ALICHEB3D_
-void AliCheb3DCalc::SaveData(const char* outfile,Bool_t append) const
-{
- // writes coefficients data to output text file, optionallt appending on the end of existing file
- TString strf = outfile;
- gSystem->ExpandPathName(strf);
- FILE* stream = fopen(strf,append ? "a":"w");
- SaveData(stream);
- fclose(stream);
- //
-}
-#endif
-
-//_______________________________________________
-#ifdef _INC_CREATION_ALICHEB3D_
-void AliCheb3DCalc::SaveData(FILE* stream) const
-{
- // writes coefficients data to existing output stream
- // Note: fNCols, fNElemBound2D and fColAtRowBg is not stored, will be computed on fly during the loading of this file
- fprintf(stream,"#\nSTART %s\n",GetName());
- fprintf(stream,"# Number of rows\n%d\n",fNRows);
- //
- fprintf(stream,"# Number of columns per row\n");
- for (int i=0;i<fNRows;i++) fprintf(stream,"%d\n",fNColsAtRow[i]);
- //
- fprintf(stream,"# Number of Coefs in each significant block of third dimension\n");
- for (int i=0;i<fNElemBound2D;i++) fprintf(stream,"%d\n",fCoefBound2D0[i]);
- //
- fprintf(stream,"# Coefficients\n");
- for (int i=0;i<fNCoefs;i++) fprintf(stream,"%+.8e\n",fCoefs[i]);
- fprintf(stream,"END %s\n",GetName());
- //
-}
-#endif
-
-//_______________________________________________
-void AliCheb3DCalc::LoadData(FILE* stream)
-{
- // Load coefs. from the stream
- if (!stream) {Error("LoadData","No stream provided.\nStop"); exit(1);}
- TString buffs;
- Clear();
- ReadLine(buffs,stream);
- if (!buffs.BeginsWith("START")) {Error("LoadData","Expected: \"START <fit_name>\", found \"%s\"\nStop\n",buffs.Data());exit(1);}
- if (buffs.First(' ')>0) SetName(buffs.Data()+buffs.First(' ')+1);
- //
- ReadLine(buffs,stream); // NRows
- fNRows = buffs.Atoi();
- if (fNRows<1) {Error("LoadData","Expected: '<number_of_rows>', found \"%s\"\nStop\n",buffs.Data());exit(1);}
- //
- fNCols = 0;
- fNElemBound2D = 0;
- InitRows(fNRows);
- //
- for (int id0=0;id0<fNRows;id0++) {
- ReadLine(buffs,stream); // n.cols at this row
- fNColsAtRow[id0] = buffs.Atoi();
- fColAtRowBg[id0] = fNElemBound2D; // begining of this row in 2D boundary surface
- fNElemBound2D += fNColsAtRow[id0];
- if (fNCols<fNColsAtRow[id0]) fNCols = fNColsAtRow[id0];
- }
- InitCols(fNCols);
- //
- fNCoefs = 0;
- InitElemBound2D(fNElemBound2D);
- //
- for (int i=0;i<fNElemBound2D;i++) {
- ReadLine(buffs,stream); // n.coeffs at 3-d dimension for the given column/row
- fCoefBound2D0[i] = buffs.Atoi();
- fCoefBound2D1[i] = fNCoefs;
- fNCoefs += fCoefBound2D0[i];
- }
- //
- if (fNCoefs<=0) {Error("LoadData","Negtive (%d) number of Chebychef coeffs. is obtained.\nStop\n",fNCoefs);exit(1);}
- //
- InitCoefs(fNCoefs);
- for (int i=0;i<fNCoefs;i++) {
- ReadLine(buffs,stream);
- fCoefs[i] = buffs.Atof();
- }
- // check end_of_data record
- ReadLine(buffs,stream);
- if (!buffs.BeginsWith("END") || !buffs.Contains(GetName())) {
- Error("LoadData","Expected \"END %s\", found \"%s\".\nStop\n",GetName(),buffs.Data());
- exit(1);