version 1.1.1.1, 2000/01/10 15:35:22 |
version 1.1.1.2, 2000/09/09 14:13:15 |
|
|
/* Test that routines allow reusing a source variable as destination. */ |
/* Test that routines allow reusing a source variable as destination. |
|
|
|
Copyright (C) 1996, 2000 Free Software Foundation, Inc. |
|
|
|
This file is part of the GNU MP Library. |
|
|
|
The GNU MP Library is free software; you can redistribute it and/or modify |
|
it under the terms of the GNU Lesser General Public License as published by |
|
the Free Software Foundation; either version 2.1 of the License, or (at your |
|
option) any later version. |
|
|
|
The GNU MP Library is distributed in the hope that it will be useful, but |
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
|
License for more details. |
|
|
|
You should have received a copy of the GNU Lesser General Public License |
|
along with the GNU MP Library; see the file COPYING.LIB. If not, write to |
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
|
MA 02111-1307, USA. */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include "gmp.h" |
#include "gmp.h" |
#include "gmp-impl.h" |
#include "gmp-impl.h" |
Line 38 typedef void (*dsi_func) (); |
|
Line 57 typedef void (*dsi_func) (); |
|
dsi_func dsi_funcs[] = |
dsi_func dsi_funcs[] = |
{ |
{ |
mpf_div_ui, mpf_add_ui, mpf_mul_ui, mpf_sub_ui, |
mpf_div_ui, mpf_add_ui, mpf_mul_ui, mpf_sub_ui, |
|
mpf_mul_2exp, mpf_div_2exp |
}; |
}; |
|
|
char *dsi_func_names[] = |
char *dsi_func_names[] = |
{ |
{ |
"mpf_div_ui", "mpf_add_ui", "mpf_mul_ui", "mpf_sub_ui", |
"mpf_div_ui", "mpf_add_ui", "mpf_mul_ui", "mpf_sub_ui", |
|
"mpf_mul_2exp", "mpf_div_2exp" |
}; |
}; |
|
|
#if __STDC__ |
#if __STDC__ |
Line 119 main (argc, argv) |
|
Line 140 main (argc, argv) |
|
for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++) |
for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++) |
{ |
{ |
/* Don't divide by 0. */ |
/* Don't divide by 0. */ |
if (i == 0 && in2i == 0) |
if (strcmp (dsi_func_names[i], "mpf_div_ui") == 0 && in2i == 0) |
continue; |
continue; |
|
|
(dsi_funcs[i]) (res1, in1, in2i); |
(dsi_funcs[i]) (res1, in1, in2i); |
Line 136 main (argc, argv) |
|
Line 157 main (argc, argv) |
|
for (i = 0; i < sizeof (dis_funcs) / sizeof (dis_func); i++) |
for (i = 0; i < sizeof (dis_funcs) / sizeof (dis_func); i++) |
{ |
{ |
/* Don't divide by 0. */ |
/* Don't divide by 0. */ |
if (i == 0 && mpf_cmp_ui (in2, 0) == 0) |
if (strcmp (dis_func_names[i], "mpf_ui_div") == 0 |
|
&& mpf_cmp_ui (in2, 0) == 0) |
continue; |
continue; |
|
|
(dis_funcs[i]) (res1, in1i, in2); |
(dis_funcs[i]) (res1, in1i, in2); |
|
|
mpf_set (out1, in2); |
mpf_set (out1, in2); |
(dis_funcs[i]) (out1, in1i, in2); |
(dis_funcs[i]) (out1, in1i, out1); |
mpf_set (res2, out1); |
mpf_set (res2, out1); |
|
|
if (mpf_cmp (res1, res2) != 0) |
if (mpf_cmp (res1, res2) != 0) |
Line 158 dump_abort (name, res1, res2) |
|
Line 180 dump_abort (name, res1, res2) |
|
char *name; |
char *name; |
mpf_t res1, res2; |
mpf_t res1, res2; |
{ |
{ |
printf ("failure in %s:", name); |
printf ("failure in %s:\n", name); |
oo (res1); |
oo (res1); |
oo (res2); |
oo (res2); |
abort (); |
abort (); |
|
|
} |
} |
|
|
#if 0 |
#if 0 |
void mpf_div_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); |
|
void mpf_mul_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); |
|
|
|
void mpf_abs _PROTO ((mpf_ptr, mpf_srcptr)); |
void mpf_abs _PROTO ((mpf_ptr, mpf_srcptr)); |
void mpf_sqrt _PROTO ((mpf_ptr, mpf_srcptr)); |
void mpf_sqrt _PROTO ((mpf_ptr, mpf_srcptr)); |
void mpf_neg _PROTO ((mpf_ptr, mpf_srcptr)); |
void mpf_neg _PROTO ((mpf_ptr, mpf_srcptr)); |