/*@@@@@@@@@@@@@@@@@@@@@@@@ Continium.h @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 Random Option Pricing
 Summer 2002
 Authors: A. Korobchevsky
          S. Ferrando
 Ryerson University ALL RIGHTS RESERVED
 
 Purpose: Declares and Imlements the Continium Underlying Structure
          All functions defined inline.

 Instance variables:
      sigma - volatility
 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#ifndef CONTIN_H__
#define CONTIN_H__

#include <cmath>
#include "../Rng/GSL_RandomGen.h" 
#include "Underlying.h"




struct Continium : Underlying
{ double sigma;

  /************************** Underlying ******************************* 
  Function: Continium 
  Purpose: Constructor (inline)
  Param: char* - random generator abbreviated name (mt, taus, gfsr)
  Returns: None
  Note: Seed and precision are hardcoded
  *********************************************************************/ 
  Continium(char* name, double sigma = 0.3) 
  { gen = new GSL_RandomGen(name, 35345, 8);
    P = 0.5;     /*   Up/down probabilities are constant   */ 
    this->sigma = sigma;
  }   




  /***************************** next ********************************* 
  Function: next 
  Purpose: Calculates next stock value
  Param: double - Current stock value
  Returns: Next stock value
  *********************************************************************/ 
  double next(double ST) 
  { return ST * exp((r - sigma * sigma / 2) * (T / N) + sigma * sqrt(T / N) * gen->gauss(1.0));
  }




  /*************************** generatePath *************************** 
  Function: generatePath 
  Purpose: Dumps the whole path at once. Forces specified number of ups 
  Param: int - length of the path
         int - number of ups forced in the path
  Returns: Array of ups and downs
  *********************************************************************/ 
  double* generatePath(int N, int n)
  { double* path = new double[N];

    // Need to be implemented 
    return path;
  }
};

#endif
