#include <stdio.h>
#include <stdlib.h>

#include "Driver.h"

using namespace functions::oo;
using namespace integrators::oo;

int
main (int argc, char *argv[])
{
  double
    value;
  int
    count = 100;
  double
    lowerBound = 0.0,
    upperBound = 1.0;

  if (argc > 1)
    count = atoi (argv[1]);     // Number of sampling points

  functions::Function * function = new PiFunction ();
  integrators::Integrator * integrator;

  // MonteCarlo integrator
  integrator = new MonteCarloIntegrator ();
  integrator->setFunction (function);
  value = integrator->integrate (lowerBound, upperBound, count);
  printf ("MonteCarloIntegrator: integral = %f\n", value);
  delete integrator;

  // Midpoint integrator
  integrator = new MidpointIntegrator ();
  integrator->setFunction (function);
  value = integrator->integrate (lowerBound, upperBound, count);
  printf ("MidpointIntegrator: integral = %f\n", value);
  delete integrator;

  return 0;
}