The Integrator../ns-2/integrator.h supports the approximation of (continuous) integration by (discrete) sums; it is defined in ~ns/integrator.h as
{\rm From integrator.h:} class Integrator : public TclObject { public: Integrator(); void set(double x, double y); void newPoint(double x, double y); int command(int argc, const char*const* argv); protected: double lastx_; double lasty_; double sum_; }; {\rm From integrator.cc:} Integrator::Integrator() : lastx_(0.), lasty_(0.), sum_(0.) { bind("lastx_", &lastx_); bind("lasty_", &lasty_); bind("sum_", &sum_); } void Integrator::set(double x, double y) { lastx_ = x; lasty_ = y; sum_ = 0.; } void Integrator::newPoint(double x, double y) { sum_ += (x - lastx_) * lasty_; lastx_ = x; lasty_ = y; } int Integrator::command(int argc, const char*const* argv) { if (argc == 4) { if (strcmp(argv[1], "newpoint") == 0) { double x = atof(argv[2]); double y = atof(argv[3]); newPoint(x, y); return (TCL_OK); } } return (TclObject::command(argc, argv)); }This class provides a base class used by other classes such as QueueMonitor that keep running sums. Each new element of the running sum is added by the [x, y]newPoint function. After the th execution of newPoint, the running sum is equal to where unless lastx