/home/peifer/diffit/modules/outFit.cc

Go to the documentation of this file.
00001 #include<iostream>
00002 #include<math.h>
00003 #include<stdlib.h>
00004 
00005 #include "../def.h"
00006 #include "../model.h"
00007 #include "../nr.h"
00008 
00009 using namespace std;
00010 
00011 void outFit(GlobExp ex[],Glob *globs)
00012 {
00013   long i,j;
00014   long nExp;
00015   long nvar,npar,nglob=0;
00016   long ind=1;
00017 
00018   npar=globs->npar;     
00019   nvar=ex[1].nvar;
00020 
00021   double **errorS=dmatrix(1,globs->nrExp,1,nvar);
00022   double **errorP=dmatrix(1,globs->nrExp,1,npar);
00023   
00024 
00025   if(globs->strategy!=2)
00026     {
00027       //prepare output
00028       for(nExp=1;nExp<=globs->nrExp;++nExp) 
00029         {
00030           for(i=1;i<=nvar;i++)
00031             errorS[nExp][i]=-1;
00032           for(i=1;i<=npar;i++)
00033             errorP[nExp][i]=-1;
00034           
00035           for(i=1;i<=nvar;i++)
00036             {
00037               if(globs->y0fix[i]!=FALSE)
00038                 {
00039                   errorS[nExp][i]=sqrt(globs->covar[ind][ind]);
00040                   ind++;
00041                 }
00042             }
00043           for(i=1;i<=npar;i++)
00044             {
00045               if(globs->doP[i]=='L')
00046                 {
00047                   errorP[nExp][i]=sqrt(globs->covar[ind][ind]);
00048                   ind++;
00049                   nglob++;
00050                 }
00051             }
00052         }
00053       
00054       for(i=1;i<=npar;i++)
00055         {
00056           if(globs->doP[i]==TRUE)
00057             {
00058               for(nExp=1;nExp<=globs->nrExp;++nExp) 
00059                 {
00060                   errorP[nExp][i]=sqrt(globs->covar[ind][ind]);
00061                 }
00062               ind++;
00063             }
00064         } 
00065     }  //end if(globs->strategy..)
00066 
00067   /* print results */
00068   if(globs->silent!=TRUE)
00069     {
00070       cout << "Number of iterations: " << globs->nIter << ", chi^2 = " << globs->chisq << "\n\n";
00071       cout << "\nBest fit parameters +/- standard errors:\n";
00072       cout << "----------------------------------------\n\n"; 
00073       
00074       cout << "Global Parameters:\n";
00075       for(j=1;j<=npar;j++)
00076         { 
00077           if(globs->doP[j]!='L')
00078             {
00079               if(globs->strategy!=2)
00080                 {
00081                   for(nExp=1;nExp<=globs->nrExp;++nExp) 
00082                     ex[nExp].errP[j]=errorP[1][j];
00083                   cout << ParameterNames[j-1];
00084                   if(errorP[1][j]!=-1)
00085                     cout << " = " << ex[1].par[j] <<  " +/- " << errorP[1][j] << endl;
00086                   else
00087                     cout << " (fixed)\n";
00088                 }
00089               else
00090                 cout << ParameterNames[j-1] << " = " << ex[1].par[j] << endl;
00091                 
00092                 
00093             }
00094         }
00095       cout << endl;
00096       for(i=1;i<=globs->nrExp;++i) 
00097         {
00098           cout << "Experiment " << i << ":";
00099           if(nglob!=0)
00100             cout << "\n\nLocal Parameters:\n";
00101           else
00102             cout << endl;
00103           
00104           for(j=1;j<=npar;j++)
00105             {
00106               if(globs->doP[j]=='L')
00107                 {
00108                   if(globs->strategy!=2)
00109                     {
00110                       ex[i].errP[j]=errorP[i][j];
00111                       cout << ParameterNames[j-1] << " = " << ex[i].par[j];
00112                       if(errorP[i][j]!=-1)
00113                         cout <<  " +/- " << errorP[i][j] << endl;
00114                       else
00115                         cout << " (fixed)\n";
00116                     }
00117                   else
00118                     cout << ParameterNames[j-1] << " = " << ex[i].par[j] << endl;
00119                 }
00120             }
00121           cout << "Initial Values" << endl;
00122           for(j=1;j<=nvar;j++)
00123             {
00124               if(globs->strategy!=2)
00125                 {
00126                   ex[i].errY0[j]=errorS[i][j];
00127                   cout << VariableNames[j-1] << " = " << ex[i].yTry[1][j];
00128                   if(errorS[i][j]!=-1)
00129                     cout <<  " +/- " << errorS[i][j] << endl;
00130                   else
00131                     cout << " (fixed)\n";
00132                 }
00133               else
00134                 cout << VariableNames[j-1] << " = " << ex[i].yTry[1][j] << endl;
00135             }
00136           cout << endl;
00137         }
00138     } //end of --> if(silent!=TRUE)
00139 
00140   free_dmatrix(errorS,1,globs->nrExp,1,nvar);
00141   free_dmatrix(errorP,1,globs->nrExp,1,npar);
00142 }

Generated on Mon Jan 29 17:09:12 2007 for Diffit by  doxygen 1.4.6