/* This is ransim_a.h */

struct rsmgff {
        char header[1024];
        int nums, numr, numc;
        int t_p_s, numsets;
        int no_cx, csdev, csduv, fsdt, sdtev, sdtuv;
        int nallparams;
        int dec_r;
        double qracc;
        long int liseed;
        int sm_start, sm_end, ssd_start, ssd_end, cm_start, cm_end;
        int  csd_start, csd_end, pstart;
        double ssdsum, csdsum;
        double *allparameters;
	double **dprob_1_mat;
	double **dprob_2_mat;
	double **dprob_3_mat;
	double **dprob_mat;
        double **prop_mat;
        int **freq1_mat;
        int **freq2_mat;
        int **freq3_mat;
        int **freq_mat;
        double *mgf;
        int num_mgf;
        FILE *inPtr;
};


// Functions
void open_file( char gen_name [ 50 ], struct rsmgff *isp );

void rsmgff_init ( struct rsmgff *isp );

void start_output ( struct rsmgff *isp );

void alloc_mats( struct rsmgff *isp );

void calc_pf_pairs ( struct rsmgff *isp );

void calc_sim_params ( struct rsmgff *isp );

double get_ran ( double l_llim, double u_lim, double mltp );

void calc_freq_mats ( struct rsmgff *isp );

void wsdo_logp ( struct rsmgff *isp );

void missing_entry( double **dpmat, struct rsmgff *isp, int snum, int r_start, int r_end );

double normal ( double x, double mu, double sigma );

double eq3_wrap ( int r12, int ie3, int je3, double *pp, C struct rsmgff *isp );

double eq3 ( int r12, int j, int n, double *mu, double *sigma, double mus, double sigmas,
		C struct rsmgff *isp );

double outerkernel ( double s,  void *infoptr, int nc );

double innerkernel ( double cj,  void *infoptr, int nc );


double eq3a_wrap ( int r12, int ie3a, int je3a, double *pp, C struct rsmgff *isp );

double eq3a ( int r12, int j, int n, double *mu, double *sigma, double mus, double sigmas,
		C struct rsmgff *isp );

int sdt ( int isdtx, struct rsmgff *isp );

double Max(double a, double b);

void wsdo_l_f_mgf ( struct rsmgff *isp );

void write_p_f_pair ( C struct rsmgff *isp, int nset );

// void mat_out ( int **fmat, C struct rsmgff *isp ) ;

void free_dm ( C struct rsmgff *isp );
