#ifndef vector_included
#define vector_included
#ifndef dbhost_included
#include "dbhost.h"       /* PROTOTYPE_ALLOWED */
#endif

#ifndef BADFLOAT
#define BADFLOAT ((float) 1.0e38)
#endif

#ifndef ADJ_BADFLOAT
#define ADJ_BADFLOAT ((float) 9.99999e37)
#endif

#define good_float(x) ( (x) < ADJ_BADFLOAT )
#define average(a,b)  ( 0.5 * ( (a) + (b) ) )

#if PROTOTYPE_ALLOWED

/* VECTORS */
void make_uniform_grid(double first, double last, int n, float array[]);
void scale_elements(float scales[], float array[], float out_array[], int n);
void make_sinusoid(float array[], int n, double amp, double cycles,
                                   double degrees);
void integrate_tr( float f[], float z[], float integral[], int n);
double average_tr( float f[], float z[], int n);
double scalar_product(float a[], float b[], int n);
double mode_projection(float a[], float b[], int n);
void stats(float a[], int n, double *mean_ptr, double *variance_ptr);


/* MATRIX  */
void matrix_mult(float *c, float *a, float *b, int m, int n, int p);
   /*  c=a*b:   c,  m by p;  a,  m by n;  b   n by p */
void make_identity_matrix(float *imatrix, int n);
                    /* must be dimension [n][n] */


/* FLATFILE */

int read_array_double( FILE *fp_in, double array[], int n, char format[]);
int read_array_float( FILE *fp_in, float array[], int n, char format[]);
int read_array_4( FILE *fp_in, long array[], int n, char format[]);
int read_array_2( FILE *fp_in, int array[], int n, char format[]);
int read_array_1( FILE *fp_in, char array[], int n, char format[]);

/* INTERP */
double    interpolate (float *z, float *f, double zi);

/* REGRID */
void      regrid (float zo[], float fo[], float zn[], float fn[],
               int m, int n, int *n0_ptr, int *nout_ptr);

/* INTGRID */
void      intgrid (float zo[], float fo[], float zn[], float fn[],
               int m, int n, int *n0_ptr, int *nout_ptr);

/* REGRIDLI */
void      regridli (float zo[], float fo[], float zn[], float fn[],
               int m, int n, int *n0_ptr, int *nout_ptr);

/* DETREND */
void detrend(float array[], int n);

/* SCOMPLEX */
void split_odd_even( float *a, int n);

/* REFCALC */
double subtract_reference(float *data, int n, int first, int last);
double array_mean(float *data, int n);

/* DERIV */
void dif1(float *array, float *dif, int n);
void avg_adjacent1(float *array, float *array_aa, int n);
void dif2(float *array, float *dif, int n);
void avg_adjacent2(float *array, float *array_aa, int n);
void deriv1(float *x, float *y, float *xa, float *yd, int n);
void deriv2(float *x, float *y, float *xa, float *yd, int n);

/* Added 88-04-26:
*/
 
/* FILLGAPS*/
int fill_gaps(float *f, int n);

/* S_REGRID */
int s_regrid(float *zo, float *fo, float *zn, float *fn, int no, int nn);

/* S_INTGRD */
int s_intgrid(float *zo, float *fo, float *zn, float *fn, int no, int nn);

/* ROTATE */
void rotate_vector(double angle, float *u, float *v, int n);

/* added Thu  10-06-1988  */
/* S_REGRLI.C */
int s_regridli(float *zo, float *fo, float *zn, float *fn, int no, int nn);

#else
/* VECTORS */
void make_uniform_grid();
void scale_elements();
void make_sinusoid();
void integrate_tr();
double average_tr();
double scalar_product();
double mode_projection();
void stats();

/* MATRIX  */
void matrix_mult();
void make_identity_matrix();

/* FLATFILE */

int read_array_double();
int read_array_float();
int read_array_4();
int read_array_2();
int read_array_1();

/* INTERP */
double    interpolate();

/* REGRID */
void      regrid();

/* INTGRID */
void      intgrid();

/* REGRIDLI */
void      regridli();

/* DETREND */
void detrend();

/* SCOMPLEX */
void split_odd_even();

/* REFCALC */
double subtract_reference();
double array_mean();

/* DERIV */
void dif1();
void avg_adjacent1();
void dif2();
void avg_adjacent2();
void deriv1();
void deriv2();

/* Added 88-04-26:
*/
 
/* FILLGAPS*/
int fill_gaps();

/* S_REGRID */
int s_regrid();

/* S_INTGRD */
int s_intgrid();

/* ROTATE */
void rotate_vector();

/* added Thu  10-06-1988  */
/* S_REGRLI.C */
int s_regridli();

#endif

#endif /* ifndef vector_included */

