/* erode.h      --      header def's for erode.c        jpb 6/24/95 */

#undef max
#define max(a,b) ((a) > (b) ? (a) : (b))
#undef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#undef abs
#define abs(a) ((a) >= 0 ? (a) : -(a))

unsigned int hxsize, hysize;       /* size of height matrix */
unsigned int xsize, ysize;       /* size of input matrix */

int fill_bn(PTYPE *h1, PTYPE *h2);      /* remove depressions from hf */
int alloc_mem();                        /* alloc arrays */
void find_upflow();                      /* set flow direction array flow */
void find_flow2();                       /* set flow direction array fl */
void quick_flow(PTYPE *h1);              /* find sinks */
void find_ua();                         /* solve for uphill area matrix */
int ua_iter(int x, int y);             /* try to find ua at one point x,y */
int down_vec(int x, int y, float *nx, float *ny);  /* return down vector */
double sgn(double a);                       /* returns sign of a */
void check_con();


PTYPE *hf;                              /* elevation array (height field) */
PTYPE *ua;                              /* uphill area array */
PTYPE *bn;                              /* basin accumulation array */

BYTE *fl;                               /* array of flow directions */
BYTE *flag;                             /* array of checked, peak flags */
int xo[9] =                      /* 8-dir index offset arrays */
   { 0,-1,0,1,1,1,0,-1,-1 };
int yo[9] =
   { 0,-1,-1,-1,0,1,1,1,0 };
int x4[4] =                      /* 4-dir index offset arr */
   { -1,0,1,0 };
int y4[4] =
   { 0,-1,0,1 };
int dhash[9] =                /* 8-direction hash mx */
  { 1,2,3,8,0,4,7,6,5 };


