/*============================================================================

 Function      kGrid

 Usage         kGrid(Z, K)

 Arguments     Z:     pointer to the array of constant doubles which stores
                      the AR1 grid values.	      

	       K:     pointer to the array of doubles which stores the capital
	              grid values.

 Description   This function computes the values of an equally spaced capital
               grid. The upper and lower bounds are the deterministic
	       steady-state values of capital at the highest and lowest values
	       of the TFP process (respectively), scaled by 0.95 and 1.05
	       (respectively).

 Dependencies  Global variables: beta, alpha, delta, nk, nz (globalvars.h).

               Functions:        pow (math.h).

 Return value  void.

 =============================================================================

 Author:       Eric M. Aldrich

 Contact:      ealdrich@gmail.com

 Date:         20 April 2010

 ============================================================================*/

#include "globalvars.h"
#include <math.h>

void kGrid(const double* Z, double* K)
{

  int i;

  // initial grid for capital
  double kmin = 0.95*pow((1/(alpha*Z[0]))*((1/beta)-1+delta),1/(alpha-1));
  double kmax = 1.05*pow((1/(alpha*Z[nz-1]))*((1/beta)-1+delta),1/(alpha-1));
  double kstep = (kmax - kmin)/(nk-1);
  for(i = 0 ; i < nk ; ++i) K[i] = kmin + i*kstep;

}
