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

 Function      vfInit

 Usage         vfInit(Z, V)

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

	       V:     pointer to the array of doubles which stores the initial
	              value function.

 Description   This function initializes the value function.

 Dependencies  Global Variables: eta, 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 vfInit(const double* Z, double* V)
{ 

  int i,j;

  // initialize
  double Kj;
  for(i = 0 ; i < nk ; ++i){
    for(j = 0 ; j < nz ; ++j){
        Kj = pow((1/(alpha*Z[j]))*((1/beta)-1+delta),1/(alpha-1));
	V[i*nz+j] = pow(Z[j]*pow(Kj, alpha) - delta*Kj,1-eta)/(1-eta);
    }
  }

}
