/* erlib.h      --      header file for erode.c, inout.c etc. */

#include <stdio.h>                      /* fopen() sprintf() etc. */
#include <stdlib.h>                     /* strtod() rand() */
#include <math.h>                       /* math stuff */
#include <string.h>                     /* strcpy() */
#include <time.h>                       /* time() */

#define VERSION "0.01b"                       /* version number */
#define Eh(vv,xq,yq) vv[((yq)*(xsize+2))+xq]  /* element of height array */
#define Ehn(vv,xq,yq) vv[((yq+1)*(xsize+2))+(xq+1)] /* hf indexed like ua */
#define El(vv, xq, yq) vv[((yq) * xsize) + xq]  /* element of flag, ua array */
#define BYTE unsigned char
#define PTYPE float                             /* hf array data type */
#define RIVER_XRES 600
#define RIVER_YRES 600
#define P(xprob) ( ((float)rand()/RAND_MAX) < xprob)

int hf_read(char *fname);           /* read in heightfield from <fname> */
int hf_write(char *fname);                /* print out hf array to file */
int pgm_write(char *fname, float *array);  /* write out an array to disk */
int pgm_write_hf(char *fname, float *array);  /* write out an array to disk */
int gif_write(char *fname, float *array);  /* scale array to 0..255, call gwrite */
int gif_vwrite(char *fname, float *array);  /* scale ar, call gvec_write */
int gwrite(char *fname, float *ar);        /* output gif file */
int gvec_write(char *fname, float *ar);    /* write gif using vector strokes */

int read_mfile(char *fname);               /* read matlab file */
int write_mfile(char *f, char *p, PTYPE *hf, 
            unsigned int x, unsigned int y); /* write matlab file */

void hf_print();                        /* print out hf array to stdout */
void fl_print();                        /* print out fl flow array */
void fl_p2();                           /* print out fl as graph */
void fl_p3();                           /* print out flag as graph */
void flag_print();                      /* print flags array */
void ar_print(float *ar);               /* print an array */

