#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>

/*
 * This file collects the declarations of the various functions and type-definitions that need to be  accessible globally.
 * */


/*this struct is used to save the starting configuration of the potential,
 *where .pos[0]=x1, .pos[1]=x2, .pos[2]=y1, .pos[3]=y2 of the rectangle.
 * */

typedef struct {
 int pos[4];
 double val;
} pot;

/*struct for plot parameters such as point type, line width etc.
 * */

typedef struct{
        int lw, pt, u, v, x, y;
        char data[1000], label[1000], color[100];
} plotinfo;


#ifndef MYIO_C
        extern void write_phi(char *out, double *data, int X, int Y);
        extern void print_phi(double *data, int X, int Y);
        extern void plot_data(char *outdir, char *plot, char *title, char *xlabel, char *ylabel,
                        double *range, int npi, plotinfo *pi);
        extern void plot_data_color(char *outdir, char *plot, char *title, char *xlabel, char *ylabel,
                        double *range, int X, int Y, int npi, plotinfo *pi);
        extern void plot_data_vecfield(char *outdir, char *plot, char *title, char *xlabel, char *ylabel,
                        double *range, int X, int Y, int npi, plotinfo *pi);
#endif

#ifndef FUNCTIONS_C
        extern void check_file(char *in, char *tags);
        extern int map(int ix, int *x, int *y, int X, int Y);
        extern void jacobi(int X, int Y, double NP, double *phi, int NPHI,
                        pot *phi0, int NGROUND, int **ground, char *dif, char *logf);
        extern void red_black(int X, int Y, double NP, double *phi, int NPHI,
                        pot *phi0, char *dif, char *logf);
        extern void gauss_seidel(int X, int Y, double NP, double *phi, int NPHI,
                        pot *phi0, char *dif, char *logf);
        extern int check_potential(int ix, int iy, int NPHI, pot *phi0);
        extern int check_ground(int ix, int iy, int NGROUND, int **ground);
#endif