/[ascend]/trunk/pygtk/integratorreporter.cpp
ViewVC logotype

Diff of /trunk/pygtk/integratorreporter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 943 by johnpye, Fri Nov 24 08:07:33 2006 UTC revision 944 by johnpye, Sat Nov 25 10:46:13 2006 UTC
# Line 6  extern "C"{ Line 6  extern "C"{
6  #include <solver/integrator.h>  #include <solver/integrator.h>
7  }  }
8    
9    #include <vector>
10  #include <stdexcept>  #include <stdexcept>
11    #include <iostream>
12    #include <iterator>
13    #include <sstream>
14  using namespace std;  using namespace std;
15    
16  //---------------------------------------------  //---------------------------------------------
# Line 37  int IntegratorReporterNull::recordObserv Line 41  int IntegratorReporterNull::recordObserv
41      return 1;      return 1;
42  }  }
43    
44    //------------------------------------------------------------------------------
45    // SIMPLE CONSOLE INTEGRATOR REPORTER
46    
47    IntegratorReporterConsole::IntegratorReporterConsole(Integrator *integrator)
48             : IntegratorReporterCxx(integrator), f(cout){
49        // nothing else
50    }
51    
52    IntegratorReporterConsole::~IntegratorReporterConsole(){
53        // nothing else
54    }
55    
56    int
57    IntegratorReporterConsole::initOutput(){
58        long nobs = integrator->getNumObservedVars();
59        stringstream ss;
60        for(long i=0; i<nobs; ++i){
61            if(i){
62                f << "\t";
63                ss << "\t";
64            }
65            Variable v = integrator->getObservedVariable(i);
66            f << v.getName();
67            ss << "-------";
68        }
69        f << endl;
70        f << ss.str() << endl;
71        return 1;
72    }
73    
74    int IntegratorReporterConsole::closeOutput(){
75        return 1;
76    }
77    
78    int IntegratorReporterConsole::updateStatus(){
79        return 1;
80    }
81    
82    int IntegratorReporterConsole::recordObservedValues(){
83        vector<double> data(integrator->getNumObservedVars());
84        integrator_get_observations(integrator->getInternalType(),&data[0]);
85        copy(data.begin(),data.end(),ostream_iterator<double>(f,"\t"));
86        f << endl;
87        return 1;
88    }
89    
90  //----------------------------------------------------  //----------------------------------------------------
91  // DEFAULT INTEGRATOR REPORTER (reporter start and end, outputs time at each step)  // DEFAULT INTEGRATOR REPORTER (reporter start and end, outputs time at each step)

Legend:
Removed from v.943  
changed lines
  Added in v.944

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22