#ifndef GRID_2D_H
#define GRID_2D_H

//-----------------------------------------------------------------------------
//
//  Peter Richter (prichter@princeton.edu)
//  Princeton Plasma Physics Laboratory
//  August 2000
//
//  grid_2D.h - Two-dimensional grid object.
//
//-----------------------------------------------------------------------------

#include <stdlib.h>
#include <math.h>
#include "preact/util.h"

class grid_2D {
public:
  grid_2D() : matrix(NULL) { }
  void set(fp_64 parameters[], int errlo, int errhi)
    {
      endpoints1.minimum = parameters[0];
      endpoints1.maximum = parameters[1];
      endpoints1.min_policy = errlo;
      endpoints1.max_policy = errhi;
      npoints1 = int(parameters[2]);
      spacing1 = int(parameters[3]);
      endpoints2.minimum = parameters[4];
      endpoints2.maximum = parameters[5];
      endpoints2.min_policy = errlo;
      endpoints2.max_policy = errhi;
      npoints2 = int(parameters[6]);
      spacing2 = int(parameters[7]);
      ln1 = (spacing1 == LOG) ? log(parameters[1] / parameters[0]) : 0;
      ln2 = (spacing2 == LOG) ? log(parameters[5] / parameters[4]) : 0;
   }
  void modify1(int errlo, int errhi)
    {
      endpoints1.min_policy = errlo;
      endpoints1.max_policy = errhi;
    }
  void modify2(int errlo, int errhi)
    {
      endpoints2.min_policy = errlo;
      endpoints2.max_policy = errhi;
    }
  fp_64 *matrix, *domain1, *domain2;
  range endpoints1, endpoints2;
  int npoints1, npoints2, spacing1, spacing2;
  fp_64 ln1, ln2;
};

//-----------------------------------------------------------------------------

#endif


