1 #ifndef __Rat__
2 #define __Rat__
3 
4 typedef	struct {Long N; Long D;} 		             Rat;  /* = N/D */
5 
6 Long Fgcd(Long a, Long b);		   /* Fast greatest common divisor  */
7 Long NNgcd(Long a, Long b); 		   /* NonNegative gcd handling zero */
8 
9 Long Egcd(Long, Long, Long*,Long*);		     /*  extended gcd(a,b)  */
10 Long REgcd(Long *vec_in, int *d, Long *vec_out);/* extended gcd(a_1,...a_d) */
11 
12 Rat  rI(Long a);		/*  conversion  Long -> Rat  */
13 Rat  rR(Long a, Long b);	/*  conversion  a/b  -> Rat  */
14 Rat  irP(Long a, Rat b);	/*  a b		integer * Rat */
15 Rat  rS(Rat a, Rat b);		/*  a + b	rational Sum */
16 Rat  rD(Rat a, Rat b);		/*  a - b	rational Difference */
17 Rat  rP(Rat a, Rat b);		/*  a * b	rational Product   */
18 Rat  rQ(Rat a, Rat b);    	/*  a / b	rational Quotient */
19 int  rC(Rat a, Rat b);          /* Compare = [1 / 0 / -1] if a [gt/eq/lt] b */
20 void Rpr(Rat c);		/*  write  "c.N/c.D"  to outFN */
21 
22 #endif
23 
24 typedef	struct {LLong N; LLong D;} 		             LRat;  /* = N/D */
25 
26 LLong LFgcd(LLong a, LLong b);		   /* Fast greatest common divisor  */
27 LLong LNNgcd(LLong a, LLong b); 	   /* NonNegative gcd handling zero */
28 
29 LLong LEgcd(LLong, LLong, LLong*,LLong*);	     /*  extended gcd(a,b)  */
30 LLong LREgcd(LLong *vec_in, int *d, LLong *vec_out);
31                                                 /* extended gcd(a_1,...a_d) */
32 
33 LRat  LrI(LLong a);		/*  conversion  LLong -> LRat  		*/
34 LRat  LrR(LLong a, LLong b);	/*  conversion  a/b   -> LRat  		*/
35 LRat  LirP(LLong a, LRat b);	/*  a b		integer * LRat 		*/
36 LRat  LrS(LRat a, LRat b);	/*  a + b	LRational Sum 		*/
37 LRat  LrD(LRat a, LRat b);	/*  a - b	LRational Difference	*/
38 LRat  LrP(LRat a, LRat b);	/*  a * b	LRational Product   	*/
39 LRat  LrQ(LRat a, LRat b);    	/*  a / b	LRational Quotient 	*/
40 int   LrC(LRat a, LRat b);      /* Compare = [1 / 0 / -1] if a [gt/eq/lt] b */
41 void  LRpr(LRat c);		/*  write  "c.N/c.D"  to outFN */
42 
43 /*   Map Permutations: Do "ArgFun" for all permutations pi of *d elements */
44 #ifdef	__cplusplus
45 #define ARG_FUN		void (*ArgFun)(int *d,int *pi,int *pinv,void *info)
46 #else
47 #define	ARG_FUN 	void ( ArgFun() )
48 #endif
49 
50 void  Map_Permut(int *d,int *pi,int *pinv,ARG_FUN,void *AuxPtr);
51 
52 Long  W_to_GLZ(Long *W, int *d, Long **GLZ);	/* "triangluar" form of GLZ */
53 Long  PW_to_GLZ(Long *W, int *d, Long **GLZ);	/* improved by permutations */
54