00001
00002
00004
00005 #include "GnuPlotterResidualScatterPlot.h"
00006
00008
00010
00011 GnuPlotterResidualScatterPlot::GnuPlotterResidualScatterPlot()
00012 {
00013
00014 }
00015
00016 GnuPlotterResidualScatterPlot::~GnuPlotterResidualScatterPlot()
00017 {
00018
00019 }
00020
00021 void GnuPlotterResidualScatterPlot::Update(Subject *theChangedSubject)
00022 {
00023
00024 CStochasticSensitivityAnalysis *analysis = (CStochasticSensitivityAnalysis *)theChangedSubject;
00025 int nResid = analysis->GetEnsemble()->at(0)->GetResidualsSize();
00026
00027
00028 char titlestring[100];
00029 char commandstring[1000];
00030 sprintf(titlestring,"set title \"%s\"\n",title);
00031 SendPlotCommand(titlestring);
00032 SendPlotCommand("set grid\n");
00033 SendPlotCommand("set nokey\n");
00034 SendPlotCommand("set xlabel \"i\"\n");
00035 SendPlotCommand("set ylabel \"Residual i\"\n");
00036
00037 freopen(buffername,"w",buffer);
00038
00039 for(int i = 0; i < analysis->GetEnsemble()->size(); i++)
00040 {
00041 for(int j = 0; j < nResid; j++)
00042 {
00043 fprintf(buffer,"%i\t\t%e\n",j,analysis->GetEnsemble()->at(i)->GetResidual(j));
00044 }
00045 }
00046 fprintf(buffer,"\n\n");
00047 fflush(buffer);
00048
00049 sprintf(commandstring,"plot \"%s\" index 0 t \"residuals\" w points\n",buffername);
00050
00051
00052 #ifdef _WIN32
00053 int iterator = 0;
00054 while(commandstring[iterator] != '\0')
00055 {
00056 if(commandstring[iterator] == '\\') {commandstring[iterator] = '/';}
00057 iterator++;
00058 }
00059 #endif
00060
00061 SendPlotCommand(commandstring);
00062
00063 return;
00064
00065 }