#ifndef _UTILS_H
#define _UTILS_H

#include <string>
#include <stdarg.h>

using namespace std;

class model;

class utils {
private: 
	static double r8_epsilon(void); 
	static double r8_huge(void); 
public:
	// generates an arbitary seed for the random number generator. 
	static int get_seed(void); 
	// sets the seed of the random number generator to a specific value. 
	static void set_seed(int seed); 
	// returns a (float) pseudo random number in the interval [0, 1]. 
	static double get_rand(void); 

	// print error message
	static void print_error(char *fmt, ...); 
  
    // read and parse model parameters from <model_name>.others
    static int read_and_parse(string filename, model *model); 
    
    // generate the model name for the current iteration
    // iter = -1 => final model
    static string generate_model_name(int iter);  
    
    // quick sort    
    static void quicksort(vector<pair<int, double> > &vect, int left, int right); 

	// probability density function (PDF) for Beta distribution
	static double beta_pdf(double x, double a, double b); 
	// Beta function
	static double beta(double x, double y); 
	// natural logarithm of Gamma(x) for positve x
	static double gamma_log (double x); 

	// return the maximal value 
	static double get_max(vector<double> v); 
	// return the minimal value
	static double get_min(vector<double> v); 
};

#endif