int main()
{
	cout << "Forward sweep, Wilmott, Student Edition p. 193\n";

	int depth;
	cout << "How many subdivisions? ";
	cin >> depth;

	// Create the binomal lattice data conainer
	const int n = 2;
	Lattice<double, int, n> lattice1(depth);


	// Test data; change to suit your own needs
	double rootValue = 12.0;// Stock price now
	double D0 = 0.04;		// Dividend yield
	double vol = 0.3;		// Volatility
	double r = 0.06;		// Interest
	double T = 1.0;				// Time to expiry

	cout << "Give value for expiry T: ";
	cin >> T;

	// Create the 'special' parameters
	double k = T / double (depth);
	double e = ::exp((r-D0)*k);
	double sr = ::sqrt(exp(vol*vol*k) - 1.0);

	double up = e * (1.0 + sr);
	double down = e * (1.0 - sr);

	// Populate lattice: forward induction
	Lattice<double, int, 2> newLattice = 
			StandardLattice::createLattice(depth, rootValue, up, down);

	// Now work back from the payoff function; BACKWARD INDUCTION

	// First make the discrete payoff
	double K = 10.0;
	Vector<double, int> RHS = CallPayOff(K, newLattice[newLattice.MaxIndex()]);
	Vector<double, int> RHS2 = PutPayOff(K, lattice1[lattice1.MaxIndex()]);

	double p = 0.5;
	double discounting = ::exp(- r*k);
	
	double optionPrice = StandardLattice::traverse(newLattice, RHS, p, discounting);
	double optionPrice2 = StandardLattice::traverse(newLattice, RHS2, p, discounting);

	cout << "\nOption price C " << optionPrice << endl;
	cout << "\nOption price P " << optionPrice2 << endl;

	return 0;
}
template <class V, class I, int NumberNodes> void print(const Lattice<V, I, NumberNodes>& source)
{
	
	for (I j = source.MinIndex(); j <= source.MaxIndex(); j++)
	{

		cout << "\nBranch Number " << j << ": [";
		for (I i = source[j].MinIndex(); i <= source[j].MaxIndex(); i++)
		{
			cout << source[j][i] << ", ";
	
		}

		cout << "]";
			
	}

}