physlib_h

/*
**	Copyright 1991, Universities Research Association.  All rights reserved.
*/
/******************************************************************************/
/* physlib.h
**  
**	prototypes and defined constants for phsylib routines
**
**  MODIFICATION HISTORY:
**
**	0.2   9 September 1992 John E. Goodwin
**	Added typedefs
**	Added nr.h header include
*/
/******************************************************************************/

#ifndef PHYSLIB_DEFINED			/* do this only once */
#define	PHYSLIB_DEFINED

#include "nr.h"

/******************************************************************************/
/* 
**	defined constants for argument values and structure definitions
*/
/******************************************************************************/

#ifdef PI
#undef PI
#endif
#define PI		3.141592654

#ifdef TWOPI
#undef TWOPI
#endif
#define TWOPI		(2.0*(PI))

#define	PROTON_MASS	0.9382796	/* proton rest mass (GeV) */
#define	PROTON_MASS2	0.8803686	/* proton rest mass squared (GeV**2) */
    					/* beta*gamma squared; x-> GeV */

#define	PROTON_BETA_GAMMA2(x) \
( ((x)*(x) - (PROTON_MASS2))/(PROTON_MASS2) )

#define	DETERM_2X2(m11, m12, m21, m22)	( (m11)*(m22)- (m21)*(m12) )
	
/* define types for nrutil.c routines */
#ifndef __NUMERICAL_RECIPE_TYPES__ 

typedef float  		Vector;
typedef float* 		Matrix;
typedef int    		IVector;
typedef int*  		IMatrix;
typedef double		DVector;
typedef double*		DMatrix;

/*typedef struct FCOMPLEX {float r,i;} fcomplex; */
/* note that fcomplex is defined by complex.c in NumericalRecipes */

typedef float (*trapzd_function)(float);		/* function typedef for trapzd */

#define __NUMERICAL_RECIPE_TYPES__ 1
#endif


/******************************************************************************/
/*
**	function prototypes
*/
/******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif

    int nr_error_init();
    int calc_3bump_posang(float *theta, float *beta, float *psi, float beta_ir,
		          float psi_ir, float alpha_ir, float tune, float *position,
		          float *angle, int set_pos);
    int calc_4bump_posang(float *theta, float *beta, float *psi, float beta_ir,
		          float psi_ir, float alpha_ir, float tune, float *position,
		          float *angle);
    void emitt_dp(float *sigma, float *beta, float *disp, float *emitt,
    		  float *dp);
    int fit_linear(float *u_x, float *u_y, int u_ndata, float *u_sig, int mwt,
	           float *u_a, float *u_b, float *u_siga, float *u_sigb,
	           float *u_chi2, float *u_q);
    int fit_poly(float *u_x, float *u_y, int ndata, float *u_sig, int mwt,
	         int ma, float *a, float *chisq);
    int fit_poly_double(double *u_x, double *u_y, int ndata, double *u_sig,
                 int mwt, int ord, double *a, double *chisq);
    Matrix *fortran_matrix_to_c(float *theMatrix,int rl,int ru,int cl, int cu);
    void fw_moment(float xi[], float yi[],  int n, float fmom[]);
    float qromb_p(trapzd_function func, float a, float b);
    void nrerror(char error_text[]);
    int nr_math_check(void);
    float revcst(float x[],float y[],int iorder[],int ncity,int n[]);
    void reverse(int iorder[],int ncity,int n[]);
    float trncst(float x[],float y[],int iorder[],int ncity,int n[]);
    void trnspt(int iorder[],int ncity,int n[]);
    int metrop(float de,float t);


#ifdef __cplusplus
    }
#endif
/*  Test to see if we can do without, provided we have nr.h
extern float **matrix();
extern void fpoly();
extern void free_matrix();
extern void fit();
*/

#endif