/[m4]/m4/modules/mpeval.c
ViewVC logotype

Diff of /m4/modules/mpeval.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by gary, Fri Oct 12 19:57:29 2001 UTC revision 1.12 by gary, Fri Jun 20 15:43:20 2003 UTC
# Line 111  typedef mpq_t number; Line 111  typedef mpq_t number;
111  static void numb_initialise (void);  static void numb_initialise (void);
112  static void numb_obstack (struct obstack *obs, const number value,  static void numb_obstack (struct obstack *obs, const number value,
113                            const int radix, int min);                            const int radix, int min);
114  static void mpq2mpz (mpz_t z, const number q, const char *noisily);  static void mpq2mpz (m4 *context, mpz_t z, const number q, const char *noisily);
115  static void mpz2mpq (number q, const mpz_t z);  static void mpz2mpq (number q, const mpz_t z);
116  static void numb_divide (number *x, const number *y);  static void numb_divide (number *x, const number *y);
117  static void numb_modulo (number *x, const number *y);  static void numb_modulo (m4 *context, number *x, const number *y);
118  static void numb_and (number *x, const number *y);  static void numb_and (m4 *context, number *x, const number *y);
119  static void numb_ior (number *x, const number *y);  static void numb_ior (m4 *context, number *x, const number *y);
120  static void numb_eor (number *x, const number *y);  static void numb_eor (m4 *context, number *x, const number *y);
121  static void numb_not (number *x);  static void numb_not (m4 *context, number *x);
122  static void numb_lshift (number *x, const number *y);  static void numb_lshift (m4 *context, number *x, const number *y);
123  static void numb_rshift (number *x, const number *y);  static void numb_rshift (m4 *context, number *x, const number *y);
124    
125    
126  static number numb_ZERO;  static number numb_ZERO;
# Line 181  numb_obstack (struct obstack *obs, const Line 181  numb_obstack (struct obstack *obs, const
181  #define QUIET (char *)0  #define QUIET (char *)0
182    
183  static void  static void
184  mpq2mpz (mpz_t z, const number q, const char *noisily)  mpq2mpz (m4 *context, mpz_t z, const number q, const char *noisily)
185  {  {
186    if (noisily && mpz_cmp_si (mpq_denref (q), (long) 1) != 0)    if (noisily && mpz_cmp_si (mpq_denref (q), (long) 1) != 0)
187      {      {
188        M4ERROR ((warning_status, 0,        M4ERROR ((m4_get_warning_status_opt (context), 0,
189                  _("Loss of precision in eval: %s"), noisily));                  _("Loss of precision in eval: %s"), noisily));
190      }      }
191    
# Line 217  numb_divide (number * x, const number * Line 217  numb_divide (number * x, const number *
217  }  }
218    
219  static void  static void
220  numb_modulo (number * x, const number * y)  numb_modulo (m4 *context, number * x, const number * y)
221  {  {
222    mpz_t xx, yy, res;    mpz_t xx, yy, res;
223    
# Line 225  numb_modulo (number * x, const number * Line 225  numb_modulo (number * x, const number *
225    /* y should be integral */    /* y should be integral */
226    
227    mpz_init (xx);    mpz_init (xx);
228    mpq2mpz (xx, *x, NOISY);    mpq2mpz (context, xx, *x, NOISY);
229    
230    mpz_init (yy);    mpz_init (yy);
231    mpq2mpz (yy, *y, NOISY);    mpq2mpz (context, yy, *y, NOISY);
232    
233    mpz_init (res);    mpz_init (res);
234    mpz_mod (res, xx, yy);    mpz_mod (res, xx, yy);
# Line 241  numb_modulo (number * x, const number * Line 241  numb_modulo (number * x, const number *
241  }  }
242    
243  static void  static void
244  numb_and (number * x, const number * y)  numb_and (m4 *context, number * x, const number * y)
245  {  {
246    mpz_t xx, yy, res;    mpz_t xx, yy, res;
247    
# Line 249  numb_and (number * x, const number * y) Line 249  numb_and (number * x, const number * y)
249    /* y should be integral */    /* y should be integral */
250    
251    mpz_init (xx);    mpz_init (xx);
252    mpq2mpz (xx, *x, NOISY);    mpq2mpz (context, xx, *x, NOISY);
253    
254    mpz_init (yy);    mpz_init (yy);
255    mpq2mpz (yy, *y, NOISY);    mpq2mpz (context, yy, *y, NOISY);
256    
257    mpz_init (res);    mpz_init (res);
258    mpz_and (res, xx, yy);    mpz_and (res, xx, yy);
# Line 265  numb_and (number * x, const number * y) Line 265  numb_and (number * x, const number * y)
265  }  }
266    
267  static void  static void
268  numb_ior (number * x, const number * y)  numb_ior (m4 *context, number * x, const number * y)
269  {  {
270    mpz_t xx, yy, res;    mpz_t xx, yy, res;
271    
# Line 273  numb_ior (number * x, const number * y) Line 273  numb_ior (number * x, const number * y)
273    /* y should be integral */    /* y should be integral */
274    
275    mpz_init (xx);    mpz_init (xx);
276    mpq2mpz (xx, *x, NOISY);    mpq2mpz (context, xx, *x, NOISY);
277    
278    mpz_init (yy);    mpz_init (yy);
279    mpq2mpz (yy, *y, NOISY);    mpq2mpz (context, yy, *y, NOISY);
280    
281    mpz_init (res);    mpz_init (res);
282    mpz_ior (res, xx, yy);    mpz_ior (res, xx, yy);
# Line 289  numb_ior (number * x, const number * y) Line 289  numb_ior (number * x, const number * y)
289  }  }
290    
291  static void  static void
292  numb_eor (number * x, const number * y)  numb_eor (m4 *context, number * x, const number * y)
293  {  {
294    mpz_t xx, yy, res;    mpz_t xx, yy, res;
295    
# Line 297  numb_eor (number * x, const number * y) Line 297  numb_eor (number * x, const number * y)
297    /* y should be integral */    /* y should be integral */
298    
299    mpz_init (xx);    mpz_init (xx);
300    mpq2mpz (xx, *x, NOISY);    mpq2mpz (context, xx, *x, NOISY);
301    
302    mpz_init (yy);    mpz_init (yy);
303    mpq2mpz (yy, *y, NOISY);    mpq2mpz (context, yy, *y, NOISY);
304    
305    mpz_init (res);    mpz_init (res);
306    
# Line 336  numb_eor (number * x, const number * y) Line 336  numb_eor (number * x, const number * y)
336  }  }
337    
338  static void  static void
339  numb_not (number * x)  numb_not (m4 *context, number * x)
340  {  {
341    mpz_t xx, res;    mpz_t xx, res;
342    
343    /* x should be integral */    /* x should be integral */
344    
345    mpz_init (xx);    mpz_init (xx);
346    mpq2mpz (xx, *x, NOISY);    mpq2mpz (context, xx, *x, NOISY);
347    
348    mpz_init (res);    mpz_init (res);
349    mpz_com (res, xx);    mpz_com (res, xx);
# Line 355  numb_not (number * x) Line 355  numb_not (number * x)
355  }  }
356    
357  static void  static void
358  numb_lshift (number * x, const number * y)  numb_lshift (m4 *context, number * x, const number * y)
359  {  {
360    mpz_t xx, yy, res;    mpz_t xx, yy, res;
361    
# Line 363  numb_lshift (number * x, const number * Line 363  numb_lshift (number * x, const number *
363    /* y should be integral */    /* y should be integral */
364    
365    mpz_init (xx);    mpz_init (xx);
366    mpq2mpz (xx, *x, NOISY);    mpq2mpz (context, xx, *x, NOISY);
367    
368    mpz_init (yy);    mpz_init (yy);
369    mpq2mpz (yy, *y, NOISY);    mpq2mpz (context, yy, *y, NOISY);
370    
371    mpz_init (res);    mpz_init (res);
372    {    {
# Line 390  numb_lshift (number * x, const number * Line 390  numb_lshift (number * x, const number *
390  }  }
391    
392  static void  static void
393  numb_rshift (number * x, const number * y)  numb_rshift (m4 *context, number * x, const number * y)
394  {  {
395    mpz_t xx, yy, res;    mpz_t xx, yy, res;
396    
# Line 398  numb_rshift (number * x, const number * Line 398  numb_rshift (number * x, const number *
398    /* y should be integral */    /* y should be integral */
399    
400    mpz_init (xx);    mpz_init (xx);
401    mpq2mpz (xx, *x, NOISY);    mpq2mpz (context, xx, *x, NOISY);
402    
403    mpz_init (yy);    mpz_init (yy);
404    mpq2mpz (yy, *y, NOISY);    mpq2mpz (context, yy, *y, NOISY);
405    
406    mpz_init (res);    mpz_init (res);
407    {    {

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26