diff options
author | Kevin Ryde <user42@zip.com.au> | 2001-01-06 21:42:10 +0100 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2001-01-06 21:42:10 +0100 |
commit | e50a2626904ed32eaba3134d3f0c92c55b2a04fe (patch) | |
tree | fca57262408a04a623471bcc7a7abb97b7937911 /mpz | |
parent | 560b989934a5b1abf97faa1ccd5de6bcdce4d055 (diff) | |
download | gmp-e50a2626904ed32eaba3134d3f0c92c55b2a04fe.tar.gz |
* mpz/tests, mpq/tests, mpf/tests, mpbsd/tests: Move directories to
tests/mpz etc.
Diffstat (limited to 'mpz')
-rw-r--r-- | mpz/tests/Makefile.am | 35 | ||||
-rw-r--r-- | mpz/tests/Makefile.in | 702 | ||||
-rw-r--r-- | mpz/tests/bit.c | 209 | ||||
-rw-r--r-- | mpz/tests/convert.c | 106 | ||||
-rw-r--r-- | mpz/tests/dive.c | 114 | ||||
-rw-r--r-- | mpz/tests/io-binary.c | 94 | ||||
-rw-r--r-- | mpz/tests/io.c | 132 | ||||
-rw-r--r-- | mpz/tests/logic.c | 158 | ||||
-rw-r--r-- | mpz/tests/reuse.c | 551 | ||||
-rw-r--r-- | mpz/tests/t-2exp.c | 103 | ||||
-rw-r--r-- | mpz/tests/t-bin.c | 217 | ||||
-rw-r--r-- | mpz/tests/t-fac_ui.c | 93 | ||||
-rw-r--r-- | mpz/tests/t-fdiv.c | 149 | ||||
-rw-r--r-- | mpz/tests/t-fdiv_ui.c | 145 | ||||
-rw-r--r-- | mpz/tests/t-fib_ui.c | 92 | ||||
-rw-r--r-- | mpz/tests/t-gcd.c | 141 | ||||
-rw-r--r-- | mpz/tests/t-get_si.c | 90 | ||||
-rw-r--r-- | mpz/tests/t-jac.c | 684 | ||||
-rw-r--r-- | mpz/tests/t-misc.c | 204 | ||||
-rw-r--r-- | mpz/tests/t-mul.c | 282 | ||||
-rw-r--r-- | mpz/tests/t-pow_ui.c | 148 | ||||
-rw-r--r-- | mpz/tests/t-powm.c | 156 | ||||
-rw-r--r-- | mpz/tests/t-powm_ui.c | 152 | ||||
-rw-r--r-- | mpz/tests/t-root.c | 139 | ||||
-rw-r--r-- | mpz/tests/t-scan.c | 136 | ||||
-rw-r--r-- | mpz/tests/t-sqrtrem.c | 118 | ||||
-rw-r--r-- | mpz/tests/t-tdiv.c | 149 | ||||
-rw-r--r-- | mpz/tests/t-tdiv_ui.c | 145 |
28 files changed, 0 insertions, 5444 deletions
diff --git a/mpz/tests/Makefile.am b/mpz/tests/Makefile.am deleted file mode 100644 index 298d0f461..000000000 --- a/mpz/tests/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -## Process this file with automake to generate Makefile.in - -# Copyright 1996, 1997, 1999, 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. - - -AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr - -INCLUDES = -I$(top_srcdir) -LDADD = $(top_builddir)/libgmp.la - -check_PROGRAMS = t-mul t-tdiv t-tdiv_ui t-fdiv t-fdiv_ui t-gcd \ - dive t-sqrtrem convert io logic bit t-powm t-powm_ui t-pow_ui t-2exp reuse \ - t-root t-jac t-bin t-misc t-get_si t-fac_ui t-fib_ui t-scan - -TESTS = $(check_PROGRAMS) - -# io.tmp is used by io.c, removed automatically if the tests pass -CLEANFILES = io.tmp diff --git a/mpz/tests/Makefile.in b/mpz/tests/Makefile.in deleted file mode 100644 index 60c79cbaa..000000000 --- a/mpz/tests/Makefile.in +++ /dev/null @@ -1,702 +0,0 @@ -# Makefile.in generated automatically by automake 1.4a from Makefile.am - -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000 -# Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -SHELL = @SHELL@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = ../.. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_FLAG = -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : - -@SET_MAKE@ -host_alias = @host_alias@ -host_triplet = @host@ -AMDEP = @AMDEP@ -AMTAR = @AMTAR@ -AR = @AR@ -AS = @AS@ -AWK = @AWK@ -CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@ -CC = @CC@ -CCAS = @CCAS@ -CPP = @CPP@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ -ECHO = @ECHO@ -EXEEXT = @EXEEXT@ -GMP_LDFLAGS = @GMP_LDFLAGS@ -LIBM = @LIBM@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -M4 = @M4@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@ -STRIP = @STRIP@ -TUNE_SQR_OBJ = @TUNE_SQR_OBJ@ -U = @U@ -VERSION = @VERSION@ -gmp_srclinks = @gmp_srclinks@ -install_sh = @install_sh@ -mpn_objects = @mpn_objects@ -mpn_objs_in_libgmp = @mpn_objs_in_libgmp@ - -# Copyright 1996, 1997, 1999, 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. - - -AUTOMAKE_OPTIONS = gnu no-dependencies $(top_builddir)/ansi2knr - -INCLUDES = -I$(top_srcdir) -LDADD = $(top_builddir)/libgmp.la - -check_PROGRAMS = t-mul t-tdiv t-tdiv_ui t-fdiv t-fdiv_ui t-gcd \ - dive t-sqrtrem convert io logic bit t-powm t-powm_ui t-pow_ui t-2exp reuse \ - t-root t-jac t-bin t-misc t-get_si t-fac_ui t-fib_ui t-scan - - -TESTS = $(check_PROGRAMS) - -# io.tmp is used by io.c, removed automatically if the tests pass -CLEANFILES = io.tmp -subdir = mpz/tests -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../../config.h -CONFIG_CLEAN_FILES = -check_PROGRAMS = t-mul$(EXEEXT) t-tdiv$(EXEEXT) t-tdiv_ui$(EXEEXT) \ -t-fdiv$(EXEEXT) t-fdiv_ui$(EXEEXT) t-gcd$(EXEEXT) dive$(EXEEXT) \ -t-sqrtrem$(EXEEXT) convert$(EXEEXT) io$(EXEEXT) logic$(EXEEXT) \ -bit$(EXEEXT) t-powm$(EXEEXT) t-powm_ui$(EXEEXT) t-pow_ui$(EXEEXT) \ -t-2exp$(EXEEXT) reuse$(EXEEXT) t-root$(EXEEXT) t-jac$(EXEEXT) \ -t-bin$(EXEEXT) t-misc$(EXEEXT) t-get_si$(EXEEXT) t-fac_ui$(EXEEXT) \ -t-fib_ui$(EXEEXT) t-scan$(EXEEXT) - -DEFS = @DEFS@ -I. -I$(srcdir) -I../.. -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -ANSI2KNR = $(top_builddir)/ansi2knr -bit_SOURCES = bit.c -bit_OBJECTS = bit$U.$(OBJEXT) -bit_LDADD = $(LDADD) -bit_DEPENDENCIES = $(top_builddir)/libgmp.la -bit_LDFLAGS = -convert_SOURCES = convert.c -convert_OBJECTS = convert$U.$(OBJEXT) -convert_LDADD = $(LDADD) -convert_DEPENDENCIES = $(top_builddir)/libgmp.la -convert_LDFLAGS = -dive_SOURCES = dive.c -dive_OBJECTS = dive$U.$(OBJEXT) -dive_LDADD = $(LDADD) -dive_DEPENDENCIES = $(top_builddir)/libgmp.la -dive_LDFLAGS = -io_SOURCES = io.c -io_OBJECTS = io$U.$(OBJEXT) -io_LDADD = $(LDADD) -io_DEPENDENCIES = $(top_builddir)/libgmp.la -io_LDFLAGS = -logic_SOURCES = logic.c -logic_OBJECTS = logic$U.$(OBJEXT) -logic_LDADD = $(LDADD) -logic_DEPENDENCIES = $(top_builddir)/libgmp.la -logic_LDFLAGS = -reuse_SOURCES = reuse.c -reuse_OBJECTS = reuse$U.$(OBJEXT) -reuse_LDADD = $(LDADD) -reuse_DEPENDENCIES = $(top_builddir)/libgmp.la -reuse_LDFLAGS = -t_2exp_SOURCES = t-2exp.c -t_2exp_OBJECTS = t-2exp$U.$(OBJEXT) -t_2exp_LDADD = $(LDADD) -t_2exp_DEPENDENCIES = $(top_builddir)/libgmp.la -t_2exp_LDFLAGS = -t_bin_SOURCES = t-bin.c -t_bin_OBJECTS = t-bin$U.$(OBJEXT) -t_bin_LDADD = $(LDADD) -t_bin_DEPENDENCIES = $(top_builddir)/libgmp.la -t_bin_LDFLAGS = -t_fac_ui_SOURCES = t-fac_ui.c -t_fac_ui_OBJECTS = t-fac_ui$U.$(OBJEXT) -t_fac_ui_LDADD = $(LDADD) -t_fac_ui_DEPENDENCIES = $(top_builddir)/libgmp.la -t_fac_ui_LDFLAGS = -t_fdiv_SOURCES = t-fdiv.c -t_fdiv_OBJECTS = t-fdiv$U.$(OBJEXT) -t_fdiv_LDADD = $(LDADD) -t_fdiv_DEPENDENCIES = $(top_builddir)/libgmp.la -t_fdiv_LDFLAGS = -t_fdiv_ui_SOURCES = t-fdiv_ui.c -t_fdiv_ui_OBJECTS = t-fdiv_ui$U.$(OBJEXT) -t_fdiv_ui_LDADD = $(LDADD) -t_fdiv_ui_DEPENDENCIES = $(top_builddir)/libgmp.la -t_fdiv_ui_LDFLAGS = -t_fib_ui_SOURCES = t-fib_ui.c -t_fib_ui_OBJECTS = t-fib_ui$U.$(OBJEXT) -t_fib_ui_LDADD = $(LDADD) -t_fib_ui_DEPENDENCIES = $(top_builddir)/libgmp.la -t_fib_ui_LDFLAGS = -t_gcd_SOURCES = t-gcd.c -t_gcd_OBJECTS = t-gcd$U.$(OBJEXT) -t_gcd_LDADD = $(LDADD) -t_gcd_DEPENDENCIES = $(top_builddir)/libgmp.la -t_gcd_LDFLAGS = -t_get_si_SOURCES = t-get_si.c -t_get_si_OBJECTS = t-get_si$U.$(OBJEXT) -t_get_si_LDADD = $(LDADD) -t_get_si_DEPENDENCIES = $(top_builddir)/libgmp.la -t_get_si_LDFLAGS = -t_jac_SOURCES = t-jac.c -t_jac_OBJECTS = t-jac$U.$(OBJEXT) -t_jac_LDADD = $(LDADD) -t_jac_DEPENDENCIES = $(top_builddir)/libgmp.la -t_jac_LDFLAGS = -t_misc_SOURCES = t-misc.c -t_misc_OBJECTS = t-misc$U.$(OBJEXT) -t_misc_LDADD = $(LDADD) -t_misc_DEPENDENCIES = $(top_builddir)/libgmp.la -t_misc_LDFLAGS = -t_mul_SOURCES = t-mul.c -t_mul_OBJECTS = t-mul$U.$(OBJEXT) -t_mul_LDADD = $(LDADD) -t_mul_DEPENDENCIES = $(top_builddir)/libgmp.la -t_mul_LDFLAGS = -t_pow_ui_SOURCES = t-pow_ui.c -t_pow_ui_OBJECTS = t-pow_ui$U.$(OBJEXT) -t_pow_ui_LDADD = $(LDADD) -t_pow_ui_DEPENDENCIES = $(top_builddir)/libgmp.la -t_pow_ui_LDFLAGS = -t_powm_SOURCES = t-powm.c -t_powm_OBJECTS = t-powm$U.$(OBJEXT) -t_powm_LDADD = $(LDADD) -t_powm_DEPENDENCIES = $(top_builddir)/libgmp.la -t_powm_LDFLAGS = -t_powm_ui_SOURCES = t-powm_ui.c -t_powm_ui_OBJECTS = t-powm_ui$U.$(OBJEXT) -t_powm_ui_LDADD = $(LDADD) -t_powm_ui_DEPENDENCIES = $(top_builddir)/libgmp.la -t_powm_ui_LDFLAGS = -t_root_SOURCES = t-root.c -t_root_OBJECTS = t-root$U.$(OBJEXT) -t_root_LDADD = $(LDADD) -t_root_DEPENDENCIES = $(top_builddir)/libgmp.la -t_root_LDFLAGS = -t_scan_SOURCES = t-scan.c -t_scan_OBJECTS = t-scan$U.$(OBJEXT) -t_scan_LDADD = $(LDADD) -t_scan_DEPENDENCIES = $(top_builddir)/libgmp.la -t_scan_LDFLAGS = -t_sqrtrem_SOURCES = t-sqrtrem.c -t_sqrtrem_OBJECTS = t-sqrtrem$U.$(OBJEXT) -t_sqrtrem_LDADD = $(LDADD) -t_sqrtrem_DEPENDENCIES = $(top_builddir)/libgmp.la -t_sqrtrem_LDFLAGS = -t_tdiv_SOURCES = t-tdiv.c -t_tdiv_OBJECTS = t-tdiv$U.$(OBJEXT) -t_tdiv_LDADD = $(LDADD) -t_tdiv_DEPENDENCIES = $(top_builddir)/libgmp.la -t_tdiv_LDFLAGS = -t_tdiv_ui_SOURCES = t-tdiv_ui.c -t_tdiv_ui_OBJECTS = t-tdiv_ui$U.$(OBJEXT) -t_tdiv_ui_LDADD = $(LDADD) -t_tdiv_ui_DEPENDENCIES = $(top_builddir)/libgmp.la -t_tdiv_ui_LDFLAGS = -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CFLAGS = @CFLAGS@ -CCLD = $(CC) -LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -DIST_SOURCES = bit.c convert.c dive.c io.c logic.c reuse.c t-2exp.c \ -t-bin.c t-fac_ui.c t-fdiv.c t-fdiv_ui.c t-fib_ui.c t-gcd.c t-get_si.c \ -t-jac.c t-misc.c t-mul.c t-pow_ui.c t-powm.c t-powm_ui.c t-root.c \ -t-scan.c t-sqrtrem.c t-tdiv.c t-tdiv_ui.c -depcomp = -DIST_COMMON = Makefile.am Makefile.in - - -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) - -GZIP_ENV = --best -SOURCES = bit.c convert.c dive.c io.c logic.c reuse.c t-2exp.c t-bin.c t-fac_ui.c t-fdiv.c t-fdiv_ui.c t-fib_ui.c t-gcd.c t-get_si.c t-jac.c t-misc.c t-mul.c t-pow_ui.c t-powm.c t-powm_ui.c t-root.c t-scan.c t-sqrtrem.c t-tdiv.c t-tdiv_ui.c -OBJECTS = bit$U.$(OBJEXT) convert$U.$(OBJEXT) dive$U.$(OBJEXT) io$U.$(OBJEXT) logic$U.$(OBJEXT) reuse$U.$(OBJEXT) t-2exp$U.$(OBJEXT) t-bin$U.$(OBJEXT) t-fac_ui$U.$(OBJEXT) t-fdiv$U.$(OBJEXT) t-fdiv_ui$U.$(OBJEXT) t-fib_ui$U.$(OBJEXT) t-gcd$U.$(OBJEXT) t-get_si$U.$(OBJEXT) t-jac$U.$(OBJEXT) t-misc$U.$(OBJEXT) t-mul$U.$(OBJEXT) t-pow_ui$U.$(OBJEXT) t-powm$U.$(OBJEXT) t-powm_ui$U.$(OBJEXT) t-root$U.$(OBJEXT) t-scan$U.$(OBJEXT) t-sqrtrem$U.$(OBJEXT) t-tdiv$U.$(OBJEXT) t-tdiv_ui$U.$(OBJEXT) - -all: all-redirect -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu mpz/tests/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - - -mostlyclean-checkPROGRAMS: - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) - -distclean-checkPROGRAMS: - -maintainer-clean-checkPROGRAMS: - -mostlyclean-compile: - -rm -f *.o core *.core - -rm -f *.$(OBJEXT) - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: -$(top_builddir)/ansi2knr: $(top_builddir)/ansi2knr.$(OBJEXT) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ansi2knr - -$(top_builddir)/ansi2knr.$(OBJEXT): - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) ansi2knr.$(OBJEXT) - - -mostlyclean-kr: - -rm -f *_.c - -clean-kr: - -distclean-kr: - -maintainer-clean-kr: - -bit$(EXEEXT): $(bit_OBJECTS) $(bit_DEPENDENCIES) - @rm -f bit$(EXEEXT) - $(LINK) $(bit_LDFLAGS) $(bit_OBJECTS) $(bit_LDADD) $(LIBS) - -convert$(EXEEXT): $(convert_OBJECTS) $(convert_DEPENDENCIES) - @rm -f convert$(EXEEXT) - $(LINK) $(convert_LDFLAGS) $(convert_OBJECTS) $(convert_LDADD) $(LIBS) - -dive$(EXEEXT): $(dive_OBJECTS) $(dive_DEPENDENCIES) - @rm -f dive$(EXEEXT) - $(LINK) $(dive_LDFLAGS) $(dive_OBJECTS) $(dive_LDADD) $(LIBS) - -io$(EXEEXT): $(io_OBJECTS) $(io_DEPENDENCIES) - @rm -f io$(EXEEXT) - $(LINK) $(io_LDFLAGS) $(io_OBJECTS) $(io_LDADD) $(LIBS) - -logic$(EXEEXT): $(logic_OBJECTS) $(logic_DEPENDENCIES) - @rm -f logic$(EXEEXT) - $(LINK) $(logic_LDFLAGS) $(logic_OBJECTS) $(logic_LDADD) $(LIBS) - -reuse$(EXEEXT): $(reuse_OBJECTS) $(reuse_DEPENDENCIES) - @rm -f reuse$(EXEEXT) - $(LINK) $(reuse_LDFLAGS) $(reuse_OBJECTS) $(reuse_LDADD) $(LIBS) - -t-2exp$(EXEEXT): $(t_2exp_OBJECTS) $(t_2exp_DEPENDENCIES) - @rm -f t-2exp$(EXEEXT) - $(LINK) $(t_2exp_LDFLAGS) $(t_2exp_OBJECTS) $(t_2exp_LDADD) $(LIBS) - -t-bin$(EXEEXT): $(t_bin_OBJECTS) $(t_bin_DEPENDENCIES) - @rm -f t-bin$(EXEEXT) - $(LINK) $(t_bin_LDFLAGS) $(t_bin_OBJECTS) $(t_bin_LDADD) $(LIBS) - -t-fac_ui$(EXEEXT): $(t_fac_ui_OBJECTS) $(t_fac_ui_DEPENDENCIES) - @rm -f t-fac_ui$(EXEEXT) - $(LINK) $(t_fac_ui_LDFLAGS) $(t_fac_ui_OBJECTS) $(t_fac_ui_LDADD) $(LIBS) - -t-fdiv$(EXEEXT): $(t_fdiv_OBJECTS) $(t_fdiv_DEPENDENCIES) - @rm -f t-fdiv$(EXEEXT) - $(LINK) $(t_fdiv_LDFLAGS) $(t_fdiv_OBJECTS) $(t_fdiv_LDADD) $(LIBS) - -t-fdiv_ui$(EXEEXT): $(t_fdiv_ui_OBJECTS) $(t_fdiv_ui_DEPENDENCIES) - @rm -f t-fdiv_ui$(EXEEXT) - $(LINK) $(t_fdiv_ui_LDFLAGS) $(t_fdiv_ui_OBJECTS) $(t_fdiv_ui_LDADD) $(LIBS) - -t-fib_ui$(EXEEXT): $(t_fib_ui_OBJECTS) $(t_fib_ui_DEPENDENCIES) - @rm -f t-fib_ui$(EXEEXT) - $(LINK) $(t_fib_ui_LDFLAGS) $(t_fib_ui_OBJECTS) $(t_fib_ui_LDADD) $(LIBS) - -t-gcd$(EXEEXT): $(t_gcd_OBJECTS) $(t_gcd_DEPENDENCIES) - @rm -f t-gcd$(EXEEXT) - $(LINK) $(t_gcd_LDFLAGS) $(t_gcd_OBJECTS) $(t_gcd_LDADD) $(LIBS) - -t-get_si$(EXEEXT): $(t_get_si_OBJECTS) $(t_get_si_DEPENDENCIES) - @rm -f t-get_si$(EXEEXT) - $(LINK) $(t_get_si_LDFLAGS) $(t_get_si_OBJECTS) $(t_get_si_LDADD) $(LIBS) - -t-jac$(EXEEXT): $(t_jac_OBJECTS) $(t_jac_DEPENDENCIES) - @rm -f t-jac$(EXEEXT) - $(LINK) $(t_jac_LDFLAGS) $(t_jac_OBJECTS) $(t_jac_LDADD) $(LIBS) - -t-misc$(EXEEXT): $(t_misc_OBJECTS) $(t_misc_DEPENDENCIES) - @rm -f t-misc$(EXEEXT) - $(LINK) $(t_misc_LDFLAGS) $(t_misc_OBJECTS) $(t_misc_LDADD) $(LIBS) - -t-mul$(EXEEXT): $(t_mul_OBJECTS) $(t_mul_DEPENDENCIES) - @rm -f t-mul$(EXEEXT) - $(LINK) $(t_mul_LDFLAGS) $(t_mul_OBJECTS) $(t_mul_LDADD) $(LIBS) - -t-pow_ui$(EXEEXT): $(t_pow_ui_OBJECTS) $(t_pow_ui_DEPENDENCIES) - @rm -f t-pow_ui$(EXEEXT) - $(LINK) $(t_pow_ui_LDFLAGS) $(t_pow_ui_OBJECTS) $(t_pow_ui_LDADD) $(LIBS) - -t-powm$(EXEEXT): $(t_powm_OBJECTS) $(t_powm_DEPENDENCIES) - @rm -f t-powm$(EXEEXT) - $(LINK) $(t_powm_LDFLAGS) $(t_powm_OBJECTS) $(t_powm_LDADD) $(LIBS) - -t-powm_ui$(EXEEXT): $(t_powm_ui_OBJECTS) $(t_powm_ui_DEPENDENCIES) - @rm -f t-powm_ui$(EXEEXT) - $(LINK) $(t_powm_ui_LDFLAGS) $(t_powm_ui_OBJECTS) $(t_powm_ui_LDADD) $(LIBS) - -t-root$(EXEEXT): $(t_root_OBJECTS) $(t_root_DEPENDENCIES) - @rm -f t-root$(EXEEXT) - $(LINK) $(t_root_LDFLAGS) $(t_root_OBJECTS) $(t_root_LDADD) $(LIBS) - -t-scan$(EXEEXT): $(t_scan_OBJECTS) $(t_scan_DEPENDENCIES) - @rm -f t-scan$(EXEEXT) - $(LINK) $(t_scan_LDFLAGS) $(t_scan_OBJECTS) $(t_scan_LDADD) $(LIBS) - -t-sqrtrem$(EXEEXT): $(t_sqrtrem_OBJECTS) $(t_sqrtrem_DEPENDENCIES) - @rm -f t-sqrtrem$(EXEEXT) - $(LINK) $(t_sqrtrem_LDFLAGS) $(t_sqrtrem_OBJECTS) $(t_sqrtrem_LDADD) $(LIBS) - -t-tdiv$(EXEEXT): $(t_tdiv_OBJECTS) $(t_tdiv_DEPENDENCIES) - @rm -f t-tdiv$(EXEEXT) - $(LINK) $(t_tdiv_LDFLAGS) $(t_tdiv_OBJECTS) $(t_tdiv_LDADD) $(LIBS) - -t-tdiv_ui$(EXEEXT): $(t_tdiv_ui_OBJECTS) $(t_tdiv_ui_DEPENDENCIES) - @rm -f t-tdiv_ui$(EXEEXT) - $(LINK) $(t_tdiv_ui_LDFLAGS) $(t_tdiv_ui_OBJECTS) $(t_tdiv_ui_LDADD) $(LIBS) -.c.o: - $(COMPILE) -c $< -.c.obj: - $(COMPILE) -c `cygpath -w $<` -.c.lo: - $(LTCOMPILE) -c -o $@ $< -bit_.c: bit.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/bit.c; then echo $(srcdir)/bit.c; else echo bit.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > bit_.c -convert_.c: convert.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/convert.c; then echo $(srcdir)/convert.c; else echo convert.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > convert_.c -dive_.c: dive.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dive.c; then echo $(srcdir)/dive.c; else echo dive.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > dive_.c -io_.c: io.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/io.c; then echo $(srcdir)/io.c; else echo io.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > io_.c -logic_.c: logic.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/logic.c; then echo $(srcdir)/logic.c; else echo logic.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > logic_.c -reuse_.c: reuse.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/reuse.c; then echo $(srcdir)/reuse.c; else echo reuse.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > reuse_.c -t-2exp_.c: t-2exp.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-2exp.c; then echo $(srcdir)/t-2exp.c; else echo t-2exp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-2exp_.c -t-bin_.c: t-bin.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-bin.c; then echo $(srcdir)/t-bin.c; else echo t-bin.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-bin_.c -t-fac_ui_.c: t-fac_ui.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-fac_ui.c; then echo $(srcdir)/t-fac_ui.c; else echo t-fac_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-fac_ui_.c -t-fdiv_.c: t-fdiv.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-fdiv.c; then echo $(srcdir)/t-fdiv.c; else echo t-fdiv.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-fdiv_.c -t-fdiv_ui_.c: t-fdiv_ui.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-fdiv_ui.c; then echo $(srcdir)/t-fdiv_ui.c; else echo t-fdiv_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-fdiv_ui_.c -t-fib_ui_.c: t-fib_ui.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-fib_ui.c; then echo $(srcdir)/t-fib_ui.c; else echo t-fib_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-fib_ui_.c -t-gcd_.c: t-gcd.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-gcd.c; then echo $(srcdir)/t-gcd.c; else echo t-gcd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-gcd_.c -t-get_si_.c: t-get_si.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-get_si.c; then echo $(srcdir)/t-get_si.c; else echo t-get_si.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-get_si_.c -t-jac_.c: t-jac.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-jac.c; then echo $(srcdir)/t-jac.c; else echo t-jac.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-jac_.c -t-misc_.c: t-misc.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-misc.c; then echo $(srcdir)/t-misc.c; else echo t-misc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-misc_.c -t-mul_.c: t-mul.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-mul.c; then echo $(srcdir)/t-mul.c; else echo t-mul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-mul_.c -t-pow_ui_.c: t-pow_ui.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-pow_ui.c; then echo $(srcdir)/t-pow_ui.c; else echo t-pow_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-pow_ui_.c -t-powm_.c: t-powm.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-powm.c; then echo $(srcdir)/t-powm.c; else echo t-powm.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-powm_.c -t-powm_ui_.c: t-powm_ui.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-powm_ui.c; then echo $(srcdir)/t-powm_ui.c; else echo t-powm_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-powm_ui_.c -t-root_.c: t-root.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-root.c; then echo $(srcdir)/t-root.c; else echo t-root.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-root_.c -t-scan_.c: t-scan.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-scan.c; then echo $(srcdir)/t-scan.c; else echo t-scan.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-scan_.c -t-sqrtrem_.c: t-sqrtrem.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-sqrtrem.c; then echo $(srcdir)/t-sqrtrem.c; else echo t-sqrtrem.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-sqrtrem_.c -t-tdiv_.c: t-tdiv.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-tdiv.c; then echo $(srcdir)/t-tdiv.c; else echo t-tdiv.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-tdiv_.c -t-tdiv_ui_.c: t-tdiv_ui.c $(ANSI2KNR) - $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/t-tdiv_ui.c; then echo $(srcdir)/t-tdiv_ui.c; else echo t-tdiv_ui.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > t-tdiv_ui_.c -bit_.$(OBJEXT) bit_.lo convert_.$(OBJEXT) convert_.lo dive_.$(OBJEXT) \ -dive_.lo io_.$(OBJEXT) io_.lo logic_.$(OBJEXT) logic_.lo \ -reuse_.$(OBJEXT) reuse_.lo t-2exp_.$(OBJEXT) t-2exp_.lo \ -t-bin_.$(OBJEXT) t-bin_.lo t-fac_ui_.$(OBJEXT) t-fac_ui_.lo \ -t-fdiv_.$(OBJEXT) t-fdiv_.lo t-fdiv_ui_.$(OBJEXT) t-fdiv_ui_.lo \ -t-fib_ui_.$(OBJEXT) t-fib_ui_.lo t-gcd_.$(OBJEXT) t-gcd_.lo \ -t-get_si_.$(OBJEXT) t-get_si_.lo t-jac_.$(OBJEXT) t-jac_.lo \ -t-misc_.$(OBJEXT) t-misc_.lo t-mul_.$(OBJEXT) t-mul_.lo \ -t-pow_ui_.$(OBJEXT) t-pow_ui_.lo t-powm_.$(OBJEXT) t-powm_.lo \ -t-powm_ui_.$(OBJEXT) t-powm_ui_.lo t-root_.$(OBJEXT) t-root_.lo \ -t-scan_.$(OBJEXT) t-scan_.lo t-sqrtrem_.$(OBJEXT) t-sqrtrem_.lo \ -t-tdiv_.$(OBJEXT) t-tdiv_.lo t-tdiv_ui_.$(OBJEXT) t-tdiv_ui_.lo : \ -$(ANSI2KNR) - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: -check-TESTS: $(TESTS) - @failed=0; all=0; xfail=0; xpass=0; \ - srcdir=$(srcdir); export srcdir; \ - list='$(TESTS)'; \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *" $$tst "*) \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - echo "XPASS: $$tst"; \ - ;; \ - *) \ - echo "PASS: $$tst"; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *" $$tst "*) \ - xfail=`expr $$xfail + 1`; \ - echo "XFAIL: $$tst"; \ - ;; \ - *) \ - failed=`expr $$failed + 1`; \ - echo "FAIL: $$tst"; \ - ;; \ - esac; \ - fi; \ - done; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="All $$all tests passed"; \ - else \ - banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ - fi; \ - else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all tests failed"; \ - else \ - banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ - fi; \ - fi; \ - dashes=`echo "$$banner" | sed s/./=/g`; \ - echo "$$dashes"; \ - echo "$$banner"; \ - echo "$$dashes"; \ - test "$$failed" -eq 0; \ - fi - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -distdir: $(DISTFILES) - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - if test -d $$d/$$file; then \ - cp -pR $$d/$$file $(distdir) \ - || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -info-am: -info: info-am -dvi-am: -dvi: dvi-am -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) - $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: -install-exec: install-exec-am - -install-data-am: -install-data: install-data-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am -install: install-am -uninstall-am: -uninstall: uninstall-am -all-am: Makefile -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install -installdirs: - - -mostlyclean-generic: - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -maintainer-clean-generic: - -rm -f Makefile.in -mostlyclean-am: mostlyclean-checkPROGRAMS mostlyclean-compile \ - mostlyclean-libtool mostlyclean-kr mostlyclean-tags \ - mostlyclean-generic - -mostlyclean: mostlyclean-am - -clean-am: clean-checkPROGRAMS clean-compile clean-libtool clean-kr \ - clean-tags clean-generic mostlyclean-am - -clean: clean-am - -distclean-am: distclean-checkPROGRAMS distclean-compile \ - distclean-libtool distclean-kr distclean-tags \ - distclean-generic clean-am - -rm -f libtool - -distclean: distclean-am - -maintainer-clean-am: maintainer-clean-checkPROGRAMS \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-kr maintainer-clean-tags \ - maintainer-clean-generic distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -maintainer-clean: maintainer-clean-am - -.PHONY: mostlyclean-checkPROGRAMS distclean-checkPROGRAMS \ -clean-checkPROGRAMS maintainer-clean-checkPROGRAMS mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -mostlyclean-libtool distclean-libtool clean-libtool \ -maintainer-clean-libtool mostlyclean-kr distclean-kr clean-kr \ -maintainer-clean-kr tags mostlyclean-tags distclean-tags clean-tags \ -maintainer-clean-tags check-TESTS distdir info-am info dvi-am dvi check \ -check-am installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all install-strip installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/mpz/tests/bit.c b/mpz/tests/bit.c deleted file mode 100644 index 3a36bbd03..000000000 --- a/mpz/tests/bit.c +++ /dev/null @@ -1,209 +0,0 @@ -/* Test mpz_setbit, mpz_clrbit, mpz_tstbit. - -Copyright 1997, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 4 -#endif - - -void -debug_mp (mpz_srcptr x, int base) -{ - mpz_out_str (stdout, base, x); fputc ('\n', stdout); -} - -/* twos complement, return borrow */ -mp_limb_t -mpn_neg (mp_ptr dst, mp_srcptr src, mp_size_t size) -{ - mpn_com_n (dst, src, size); - return mpn_add_1 (dst, dst, size, 1) ^ 1; -} - -mp_limb_t -mpn_tstbit (mp_srcptr ptr, mp_size_t size) -{ - return (ptr[size/BITS_PER_MP_LIMB] - & (CNST_LIMB(1) << size%BITS_PER_MP_LIMB)) != 0; -} - -void -mpz_set_n (mpz_ptr z, mp_srcptr p, mp_size_t size) -{ - ASSERT (size >= 0); - MPN_NORMALIZE (p, size); - MPZ_REALLOC (z, size); - MPN_COPY (PTR(z), p, size); - SIZ(z) = size; -} - - -/* See that mpz_tstbit matches a twos complement calculated explicitly, for - various low zeros. */ -void -check_tstbit (void) -{ -#define MAX_ZEROS 3 -#define NUM_LIMBS 3 - - mp_limb_t pos[1+NUM_LIMBS+MAX_ZEROS]; - mp_limb_t neg[1+NUM_LIMBS+MAX_ZEROS]; - mpz_t z; - unsigned long i; - int zeros, low1; - int got, want; - - mpz_init (z); - for (zeros = 0; zeros <= MAX_ZEROS; zeros++) - { - MPN_ZERO (pos, numberof(pos)); - mpn_random2 (pos+zeros, NUM_LIMBS); - - for (low1 = 0; low1 <= 1; low1++) - { - if (low1) - pos[0] |= 1; - - mpn_neg (neg, pos, numberof(neg)); - mpz_set_n (z, neg, numberof(neg)); - mpz_neg (z, z); - - for (i = 0; i < numberof(pos)*BITS_PER_MP_LIMB; i++) - { - got = mpz_tstbit (z, i); - want = mpn_tstbit (pos, i); - if (got != want) - { - printf ("wrong at bit %lu, with %d zeros\n", i, zeros); - printf ("z neg "); debug_mp (z, -16); - mpz_set_n (z, pos, numberof(pos)); - printf ("pos "); debug_mp (z, -16); - mpz_set_n (z, neg, numberof(neg)); - printf ("neg "); debug_mp (z, -16); - exit (1); - } - } - } - } - mpz_clear (z); -} - -int -main (int argc, char *argv[]) -{ - mpz_t x, s0, s1, s2, s3, m; - mp_size_t xsize; - int i; - int reps = 100000; - int bit0, bit1, bit2, bit3; - unsigned long int bitindex; - const char *s = ""; - - if (argc == 2) - reps = atoi (argv[1]); - - check_tstbit (); - - mpz_init (x); - mpz_init (s0); - mpz_init (s1); - mpz_init (s2); - mpz_init (s3); - mpz_init (m); - - for (i = 0; i < reps; i++) - { - xsize = urandom () % (2 * SIZE) - SIZE; - mpz_random2 (x, xsize); - bitindex = urandom () % SIZE; - - mpz_set (s0, x); - bit0 = mpz_tstbit (x, bitindex); - mpz_setbit (x, bitindex); - MPZ_CHECK_FORMAT (x); - - mpz_set (s1, x); - bit1 = mpz_tstbit (x, bitindex); - mpz_clrbit (x, bitindex); - MPZ_CHECK_FORMAT (x); - - mpz_set (s2, x); - bit2 = mpz_tstbit (x, bitindex); - mpz_setbit (x, bitindex); - MPZ_CHECK_FORMAT (x); - - mpz_set (s3, x); - bit3 = mpz_tstbit (x, bitindex); - -#define FAIL(str) do { s = str; goto fail; } while (0) - - if (bit1 != 1) FAIL ("bit1 != 1"); - if (bit2 != 0) FAIL ("bit2 != 0"); - if (bit3 != 1) FAIL ("bit3 != 1"); - - if (bit0 == 0) - { - if (mpz_cmp (s0, s1) == 0 || mpz_cmp (s0, s2) != 0 || mpz_cmp (s0, s3) == 0) - abort (); - } - else - { - if (mpz_cmp (s0, s1) != 0 || mpz_cmp (s0, s2) == 0 || mpz_cmp (s0, s3) != 0) - abort (); - } - - if (mpz_cmp (s1, s2) == 0 || mpz_cmp (s1, s3) != 0) - abort (); - if (mpz_cmp (s2, s3) == 0) - abort (); - - mpz_ui_pow_ui (m, 2L, bitindex); - MPZ_CHECK_FORMAT (m); - mpz_ior (x, s2, m); - MPZ_CHECK_FORMAT (x); - if (mpz_cmp (x, s3) != 0) - abort (); - - mpz_com (m, m); - MPZ_CHECK_FORMAT (m); - mpz_and (x, s1, m); - MPZ_CHECK_FORMAT (x); - if (mpz_cmp (x, s2) != 0) - abort (); - } - - exit (0); - - - fail: - printf ("%s\n", s); - printf ("bitindex = %lu\n", bitindex); - printf ("x = "); mpz_out_str (stdout, -16, x); printf (" hex\n"); - exit (1); -} diff --git a/mpz/tests/convert.c b/mpz/tests/convert.c deleted file mode 100644 index 97d1c1a1e..000000000 --- a/mpz/tests/convert.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Test conversion using mpz_get_str and mpz_set_str. - -Copyright 1993, 1994, 1996, 1999, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t op1, op2; - mp_size_t size; - int i; - int reps = 10000; - char *str; - int base; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (op1); - mpz_init (op2); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 10 + 2; - mpz_urandomb (bs, rands, size_range); - size = mpz_get_ui (bs); - mpz_rrandomb (op1, rands, size); - - mpz_urandomb (bs, rands, 1); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (op1, op1); - - mpz_urandomb (bs, rands, 32); - bsi = mpz_get_ui (bs); - base = bsi % 36 + 1; - if (base == 1) - base = 0; - - str = mpz_get_str ((char *) 0, base, op1); - MPZ_SET_STR_OR_ABORT (op2, str, base); - (*__gmp_free_func) (str, 0); - - if (mpz_cmp (op1, op2)) - { - fprintf (stderr, "ERROR, op1 and op2 different\n"); - fprintf (stderr, "str = %s\n", str); - fprintf (stderr, "base = %d\n", base); - fprintf (stderr, "op1 = "); debug_mp (op1, -16); - fprintf (stderr, "op2 = "); debug_mp (op2, -16); - abort (); - } - } - - exit (0); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/dive.c b/mpz/tests/dive.c deleted file mode 100644 index 32ce48bee..000000000 --- a/mpz/tests/dive.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Test mpz_mul, mpz_divexact. - -Copyright 1996, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mpz_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t op1, op2; - mpz_t prod, quot; - mp_size_t size; - int i; - int reps = 20000; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (op1); - mpz_init (op2); - mpz_init (prod); - mpz_init (quot); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 10 + 2; /* 0..2047 bit operands */ - - mpz_urandomb (bs, rands, size_range); - size = mpz_get_ui (bs); - mpz_rrandomb (op1, rands, size); - - do - { - mpz_urandomb (bs, rands, size_range); - size = mpz_get_ui (bs); - mpz_rrandomb (op2, rands, size); - } - while (mpz_sgn (op2) == 0); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (op1, op1); - if ((bsi & 2) != 0) - mpz_neg (op2, op2); - - mpz_mul (prod, op1, op2); - - mpz_divexact (quot, prod, op2); - if (mpz_cmp (quot, op1) != 0) - dump_abort (quot, op1); - } - - exit (0); -} - -void -dump_abort (mpz_t op1, mpz_t op2) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "ref = "); debug_mp (op1, -16); - fprintf (stderr, "wrong = "); debug_mp (op2, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/io-binary.c b/mpz/tests/io-binary.c deleted file mode 100644 index d0c4b6c75..000000000 --- a/mpz/tests/io-binary.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Test mpz_inp_binary and mpz_out_binary. - - We write and read back some test strings, and both compare - the numerical result, and make sure the pattern on file is - what we expect. The latter is important for compatibility - between machines with different word sizes. */ - -/* -Copyright 1996, 2001 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 "gmp.h" - -FILE *file; - -test (char *str, int binary_len, char *binary_str) -{ - mpz_t x, y; - int n_written; - char buf[100]; - - mpz_init_set_str (x, str, 0); - mpz_init (y); - - fseek (file, 0, SEEK_SET); - mpz_out_binary (file, x); - n_written = ftell (file); - if (n_written != binary_len) - abort (); - - fseek (file, 0, SEEK_SET); - mpz_inp_binary (y, file); - if (n_written != ftell (file)) - abort (); - if (mpz_cmp (x, y) != 0) - abort (); - - fseek (file, 0, SEEK_SET); - fread (buf, n_written, 1, file); - if (memcmp (buf, binary_str, binary_len) != 0) - abort (); - - mpz_clear (x); -} - -main () -{ - file = fopen ("xtmpfile", "w+"); - - test ("0", 4, - "\000\000\000\000"); - - test ("1", 5, - "\000\000\000\001\001"); - test ("0x123", 6, - "\000\000\000\002\001\043"); - test ("0xdeadbeef", 8, - "\000\000\000\004\336\255\276\357"); - test ("0xbabefaced", 9, - "\000\000\000\005\013\253\357\254\355"); - test ("0x123456789facade0", 12, - "\000\000\000\010\022\064\126\170\237\254\255\340"); - - test ("-1", 5, - "\377\377\377\377\001"); - test ("-0x123", 6, - "\377\377\377\376\001\043"); - test ("-0xdeadbeef", 8, - "\377\377\377\374\336\255\276\357"); - test ("-0xbabefaced", 9, - "\377\377\377\373\013\253\357\254\355"); - test ("-0x123456789facade0", 12, - "\377\377\377\370\022\064\126\170\237\254\255\340"); - - exit (0); -} diff --git a/mpz/tests/io.c b/mpz/tests/io.c deleted file mode 100644 index 134eecf67..000000000 --- a/mpz/tests/io.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Test conversion and I/O using mpz_out_str and mpz_inp_str. - -Copyright 1993, 1994, 1996, 2000, 2001 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 "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <sys/time.h> -#if HAVE_UNISTD_H -#include <unistd.h> /* for unlink */ -#endif - -#include "gmp.h" -#include "gmp-impl.h" - -#define FILENAME "io.tmp" - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} - -int -main (int argc, char **argv) -{ - mpz_t op1, op2; - mp_size_t size; - int i; - int reps = 10000; - FILE *fp; - int base; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (op1); - mpz_init (op2); - - fp = fopen (FILENAME, "w+"); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 10 + 2; - - mpz_urandomb (bs, rands, size_range); - size = mpz_get_ui (bs); - mpz_rrandomb (op1, rands, size); - mpz_urandomb (bs, rands, 1); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (op1, op1); - - mpz_urandomb (bs, rands, 16); - bsi = mpz_get_ui (bs); - base = bsi % 36 + 1; - if (base == 1) - base = 0; - - rewind (fp); - if (mpz_out_str (fp, base, op1) == 0 - || putc (' ', fp) == EOF - || fflush (fp) != 0) - { - fprintf (stderr, "mpz_out_str write error\n"); - abort (); - } - - rewind (fp); - if (mpz_inp_str (op2, fp, base) == 0) - { - if (ferror (fp)) - fprintf (stderr, "mpz_inp_str stream read error\n"); - else - fprintf (stderr, "mpz_inp_str data conversion error\n"); - abort (); - } - - if (mpz_cmp (op1, op2)) - { - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (op1, -16); - fprintf (stderr, "op2 = "); debug_mp (op2, -16); - fprintf (stderr, "base = %d\n", base); - abort (); - } - } - - fclose (fp); - - unlink (FILENAME); - - exit (0); -} diff --git a/mpz/tests/logic.c b/mpz/tests/logic.c deleted file mode 100644 index 3b8cc324d..000000000 --- a/mpz/tests/logic.c +++ /dev/null @@ -1,158 +0,0 @@ -/* Test mpz_com, mpz_and, mpz_ior, and mpz_xor. - -Copyright 1993, 1994, 1996, 1997, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO (()); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t x, y, r1, r2; - mpz_t t1, t2, t3; - mp_size_t xsize, ysize; - int i; - int reps = 40000; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (x); - mpz_init (y); - mpz_init (r1); - mpz_init (r2); - mpz_init (t1); - mpz_init (t2); - mpz_init (t3); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 8 + 2; - - mpz_urandomb (bs, rands, size_range); - xsize = mpz_get_ui (bs); - mpz_rrandomb (x, rands, xsize); - mpz_urandomb (bs, rands, 1); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (x, x); - - mpz_urandomb (bs, rands, size_range); - ysize = mpz_get_ui (bs); - mpz_rrandomb (y, rands, ysize); - mpz_urandomb (bs, rands, 1); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (y, y); - - mpz_com (r1, x); - MPZ_CHECK_FORMAT (r1); - mpz_com (r1, r1); - MPZ_CHECK_FORMAT (r1); - if (mpz_cmp (r1, x) != 0) - dump_abort (); - - mpz_com (r1, y); - MPZ_CHECK_FORMAT (r1); - mpz_com (r2, r1); - MPZ_CHECK_FORMAT (r2); - if (mpz_cmp (r2, y) != 0) - dump_abort (); - - mpz_com (t1, x); - MPZ_CHECK_FORMAT (t1); - mpz_com (t2, y); - MPZ_CHECK_FORMAT (t2); - mpz_and (t3, t1, t2); - MPZ_CHECK_FORMAT (t3); - mpz_com (r1, t3); - MPZ_CHECK_FORMAT (r1); - mpz_ior (r2, x, y); - MPZ_CHECK_FORMAT (r2); - if (mpz_cmp (r1, r2) != 0) - dump_abort (); - - mpz_com (t1, x); - MPZ_CHECK_FORMAT (t1); - mpz_com (t2, y); - MPZ_CHECK_FORMAT (t2); - mpz_ior (t3, t1, t2); - MPZ_CHECK_FORMAT (t3); - mpz_com (r1, t3); - MPZ_CHECK_FORMAT (r1); - mpz_and (r2, x, y); - MPZ_CHECK_FORMAT (r2); - if (mpz_cmp (r1, r2) != 0) - dump_abort (); - - mpz_ior (t1, x, y); - MPZ_CHECK_FORMAT (t1); - mpz_and (t2, x, y); - MPZ_CHECK_FORMAT (t2); - mpz_com (t3, t2); - MPZ_CHECK_FORMAT (t3); - mpz_and (r1, t1, t3); - MPZ_CHECK_FORMAT (r1); - mpz_xor (r2, x, y); - MPZ_CHECK_FORMAT (r2); - if (mpz_cmp (r1, r2) != 0) - dump_abort (); - } - - exit (0); -} - -void -dump_abort () -{ - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/reuse.c b/mpz/tests/reuse.c deleted file mode 100644 index 615aa5c88..000000000 --- a/mpz/tests/reuse.c +++ /dev/null @@ -1,551 +0,0 @@ -/* Test that routines allow reusing a source variable as destination. - - Test all relevant functions except: - mpz_bin_ui - mpz_nextprime - mpz_mul_si - mpz_addmul_ui (should this really allow a+=a*c?) -Copyright 1996, 1999, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump (char *, mpz_t, mpz_t, mpz_t); - -typedef void (*dss_func) _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); -typedef void (*dsi_func) _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -typedef unsigned long int (*dsi_div_func) _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -typedef unsigned long int (*ddsi_div_func) _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); -typedef void (*ddss_div_func) _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -typedef void (*ds_func) _PROTO ((mpz_ptr, mpz_srcptr)); - - -void -mpz_xinvert (mpz_ptr r, mpz_srcptr a, mpz_srcptr b) -{ - int res; - res = mpz_invert (r, a, b); - if (res == 0) - mpz_set_ui (r, 0); -} - -dss_func dss_funcs[] = -{ - mpz_add, mpz_sub, mpz_mul, - mpz_cdiv_q, mpz_cdiv_r, mpz_fdiv_q, mpz_fdiv_r, mpz_tdiv_q, mpz_tdiv_r, - mpz_xinvert, - mpz_gcd, mpz_lcm, mpz_and, mpz_ior, mpz_xor -}; -char *dss_func_names[] = -{ - "mpz_add", "mpz_sub", "mpz_mul", - "mpz_cdiv_q", "mpz_cdiv_r", "mpz_fdiv_q", "mpz_fdiv_r", "mpz_tdiv_q", "mpz_tdiv_r", - "mpz_xinvert", - "mpz_gcd", "mpz_lcm", "mpz_and", "mpz_ior", "mpz_xor" -}; -char dss_func_division[] = {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}; - -dsi_func dsi_funcs[] = -{ - /* Don't change order here without changing the code in main(). */ - mpz_add_ui, mpz_mul_ui, mpz_sub_ui, - mpz_fdiv_q_2exp, mpz_fdiv_r_2exp, - mpz_tdiv_q_2exp, mpz_tdiv_r_2exp, - mpz_mul_2exp, - mpz_pow_ui -}; -char *dsi_func_names[] = -{ - "mpz_add_ui", "mpz_mul_ui", "mpz_sub_ui", - "mpz_fdiv_q_2exp", "mpz_fdiv_r_2exp", - "mpz_tdiv_q_2exp", "mpz_tdiv_r_2exp", - "mpz_mul_2exp", - "mpz_pow_ui" -}; - -dsi_div_func dsi_div_funcs[] = -{ - mpz_cdiv_q_ui, mpz_cdiv_r_ui, - mpz_fdiv_q_ui, mpz_fdiv_r_ui, - mpz_tdiv_q_ui, mpz_tdiv_r_ui -}; -char *dsi_div_func_names[] = -{ - "mpz_cdiv_q_ui", "mpz_cdiv_r_ui", - "mpz_fdiv_q_ui", "mpz_fdiv_r_ui", - "mpz_tdiv_q_ui", "mpz_tdiv_r_ui" -}; - -ddsi_div_func ddsi_div_funcs[] = -{ - mpz_cdiv_qr_ui, - mpz_fdiv_qr_ui, - mpz_tdiv_qr_ui -}; -char *ddsi_div_func_names[] = -{ - "mpz_cdiv_qr_ui", - "mpz_fdiv_qr_ui", - "mpz_tdiv_qr_ui" -}; - -ddss_div_func ddss_div_funcs[] = -{ - mpz_cdiv_qr, - mpz_fdiv_qr, - mpz_tdiv_qr -}; -char *ddss_div_func_names[] = -{ - "mpz_cdiv_qr", - "mpz_fdiv_qr", - "mpz_tdiv_qr" -}; - -ds_func ds_funcs[] = -{ - mpz_abs, mpz_com, mpz_neg, mpz_sqrt -}; -char *ds_func_names[] = -{ - "mpz_abs", "mpz_com", "mpz_neg", "mpz_sqrt" -}; - - -/* Really use `defined (__STDC__)' here; we want it to be true for Sun C */ -#if defined (__STDC__) || defined (__cplusplus) -#define FAIL(class,indx,op1,op2,op3) \ - do { \ - class##_funcs[indx] = 0; \ - dump (class##_func_names[indx], op1, op2, op3); \ - failures++; \ - } while (0) -#define FAIL2(fname,op1,op2,op3) \ - do { \ - dump (#fname, op1, op2, op3); \ - failures++; \ - } while (0) -#else -#define FAIL(class,indx,op1,op2,op3) \ - do { \ - class/**/_funcs[indx] = 0; \ - dump (class/**/_func_names[indx], op1, op2, op3); \ - failures++; \ - } while (0) -#define FAIL2(fname,op1,op2,op3) \ - do { \ - dump ("fname", op1, op2, op3); \ - failures++; \ - } while (0) -#endif - - -main (int argc, char **argv) -{ - int i; - int pass, reps = 1000; - mpz_t in1, in2, in3; - unsigned long int in2i; - mp_size_t size; - mpz_t res1, res2, res3; - mpz_t ref1, ref2, ref3; - mpz_t t; - unsigned long int r1, r2; - long failures = 0; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (in1); - mpz_init (in2); - mpz_init (in3); - mpz_init (ref1); - mpz_init (ref2); - mpz_init (ref3); - mpz_init (res1); - mpz_init (res2); - mpz_init (res3); - mpz_init (t); - - for (pass = 1; pass <= reps; pass++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 10 + 2; - - mpz_urandomb (bs, rands, size_range); - size = mpz_get_ui (bs); - mpz_rrandomb (in1, rands, size); - - mpz_urandomb (bs, rands, size_range); - size = mpz_get_ui (bs); - mpz_rrandomb (in2, rands, size); - - mpz_urandomb (bs, rands, size_range); - size = mpz_get_ui (bs); - mpz_rrandomb (in3, rands, size); - - mpz_urandomb (bs, rands, 3); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (in1, in1); - if ((bsi & 1) != 0) - mpz_neg (in2, in2); - if ((bsi & 1) != 0) - mpz_neg (in3, in3); - - for (i = 0; i < sizeof (dss_funcs) / sizeof (dss_func); i++) - { - if (dss_funcs[i] == 0) - continue; - if (dss_func_division[i] && mpz_sgn (in2) == 0) - continue; - - (dss_funcs[i]) (ref1, in1, in2); - - mpz_set (res1, in1); - (dss_funcs[i]) (res1, res1, in2); - if (mpz_cmp (ref1, res1) != 0) - FAIL (dss, i, in1, in2, NULL); - - mpz_set (res1, in2); - (dss_funcs[i]) (res1, in1, res1); - if (mpz_cmp (ref1, res1) != 0) - FAIL (dss, i, in1, in2, NULL); - } - - for (i = 0; i < sizeof (ddss_div_funcs) / sizeof (ddss_div_func); i++) - { - if (ddss_div_funcs[i] == 0) - continue; - if (mpz_sgn (in2) == 0) - continue; - - (ddss_div_funcs[i]) (ref1, ref2, in1, in2); - - mpz_set (res1, in1); - (ddss_div_funcs[i]) (res1, res2, res1, in2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) - FAIL (ddss_div, i, in1, in2, NULL); - - mpz_set (res2, in1); - (ddss_div_funcs[i]) (res1, res2, res2, in2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) - FAIL (ddss_div, i, in1, in2, NULL); - - mpz_set (res1, in2); - (ddss_div_funcs[i]) (res1, res2, in1, res1); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) - FAIL (ddss_div, i, in1, in2, NULL); - - mpz_set (res2, in2); - (ddss_div_funcs[i]) (res1, res2, in1, res2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) - FAIL (ddss_div, i, in1, in2, NULL); - } - - for (i = 0; i < sizeof (ds_funcs) / sizeof (ds_func); i++) - { - if (ds_funcs[i] == 0) - continue; - if (strcmp (ds_func_names[i], "mpz_sqrt") == 0 - && mpz_sgn (in1) < 0) - continue; - - (ds_funcs[i]) (ref1, in1); - - mpz_set (res1, in1); - (ds_funcs[i]) (res1, res1); - if (mpz_cmp (ref1, res1) != 0) - FAIL (ds, i, in1, in2, NULL); - } - - in2i = mpz_get_ui (in2); - - for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++) - { - if (dsi_funcs[i] == 0) - continue; - if (strcmp (dsi_func_names[i], "mpz_fdiv_q_2exp") == 0) - /* Limit exponent to something reasonable for the division - functions. Without this, we'd normally shift things off - the end and just generate the trivial values 1, 0, -1. */ - in2i %= 0x1000; - if (strcmp (dsi_func_names[i], "mpz_mul_2exp") == 0) - /* Limit exponent more for mpz_mul_2exp to save time. */ - in2i %= 0x100; - if (strcmp (dsi_func_names[i], "mpz_pow_ui") == 0) - /* Limit exponent yet more for mpz_pow_ui to save time. */ - in2i %= 0x10; - - (dsi_funcs[i]) (ref1, in1, in2i); - - mpz_set (res1, in1); - (dsi_funcs[i]) (res1, res1, in2i); - if (mpz_cmp (ref1, res1) != 0) - FAIL (dsi, i, in1, in2, NULL); - } - - if (in2i != 0) /* Don't divide by 0. */ - { - for (i = 0; i < sizeof (dsi_div_funcs) / sizeof (dsi_div_funcs); i++) - { - r1 = (dsi_div_funcs[i]) (ref1, in1, in2i); - - mpz_set (res1, in1); - r2 = (dsi_div_funcs[i]) (res1, res1, in2i); - if (mpz_cmp (ref1, res1) != 0 || r1 != r2) - FAIL (dsi_div, i, in1, in2, NULL); - } - - for (i = 0; i < sizeof (ddsi_div_funcs) / sizeof (ddsi_div_funcs); i++) - { - r1 = (ddsi_div_funcs[i]) (ref1, ref2, in1, in2i); - - mpz_set (res1, in1); - r2 = (ddsi_div_funcs[i]) (res1, res2, res1, in2i); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 || r1 != r2) - FAIL (ddsi_div, i, in1, in2, NULL); - - mpz_set (res2, in1); - (ddsi_div_funcs[i]) (res1, res2, res2, in2i); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 || r1 != r2) - FAIL (ddsi_div, i, in1, in2, NULL); - } - } - - if (mpz_sgn (in1) >= 0) - { - mpz_sqrtrem (ref1, ref2, in1); - - mpz_set (res1, in1); - mpz_sqrtrem (res1, res2, res1); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) - FAIL2 (mpz_sqrtrem, in1, NULL, NULL); - - mpz_set (res2, in1); - mpz_sqrtrem (res1, res2, res2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0) - FAIL2 (mpz_sqrtrem, in1, NULL, NULL); - } - - if (mpz_sgn (in1) >= 0) - { - mpz_root (ref1, in1, in2i % 0x100 + 1); - - mpz_set (res1, in1); - mpz_root (res1, res1, in2i % 0x100 + 1); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_root, in1, in2, NULL); - } - - if (pass < reps / 2) /* run fewer tests since gcdext lots of time */ - { - mpz_gcdext (ref1, ref2, ref3, in1, in2); - - mpz_set (res1, in1); - mpz_gcdext (res1, res2, res3, res1, in2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res2, in1); - mpz_gcdext (res1, res2, res3, res2, in2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res3, in1); - mpz_gcdext (res1, res2, res3, res3, in2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res1, in2); - mpz_gcdext (res1, res2, res3, in1, res1); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res2, in2); - mpz_gcdext (res1, res2, res3, in1, res2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res3, in2); - mpz_gcdext (res1, res2, res3, in1, res3); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res1, in1); - mpz_gcdext (res1, res2, NULL, res1, in2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res2, in1); - mpz_gcdext (res1, res2, NULL, res2, in2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res1, in2); - mpz_gcdext (res1, res2, NULL, in1, res1); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - - mpz_set (res2, in2); - mpz_gcdext (res1, res2, NULL, in1, res2); - if (mpz_cmp (ref1, res1) != 0 || mpz_cmp (ref2, res2) != 0 - || mpz_cmp (ref3, res3) != 0) - FAIL2 (mpz_gcdext, in1, in2, NULL); - } - - /* Don't run mpz_powm for huge exponents or when undefined. */ - if (mpz_sizeinbase (in2, 2) < 250 && mpz_sgn (in3) != 0) - { - mpz_powm (ref1, in1, in2, in3); - - mpz_set (res1, in1); - mpz_powm (res1, res1, in2, in3); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_powm, in1, in2, in3); - - mpz_set (res1, in2); - mpz_powm (res1, in1, res1, in3); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_powm, in1, in2, in3); - - mpz_set (res1, in3); - mpz_powm (res1, in1, in2, res1); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_powm, in1, in2, in3); - } - - /* Don't run mpz_powm_ui when undefined. */ - if (mpz_sgn (in3) != 0) - { - mpz_powm_ui (ref1, in1, in2i, in3); - - mpz_set (res1, in1); - mpz_powm_ui (res1, res1, in2i, in3); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_powm_ui, in1, in2, in3); - - mpz_set (res1, in3); - mpz_powm_ui (res1, in1, in2i, res1); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_powm_ui, in1, in2, in3); - } - - { - r1 = mpz_gcd_ui (ref1, in1, in2i); - - mpz_set (res1, in1); - r2 = mpz_gcd_ui (res1, res1, in2i); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_gcd_ui, in1, in2, NULL); - } - - if (mpz_cmp_ui (in2, 1L) > 0 && mpz_sgn (in1) != 0) - { - /* Test mpz_remove */ - mpz_remove (ref1, in1, in2); - - mpz_set (res1, in1); - mpz_remove (res1, res1, in2); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_remove, in1, in2, NULL); - - mpz_set (res1, in2); - mpz_remove (res1, in1, res1); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_remove, in1, in2, NULL); - } - - if (mpz_sgn (in2) != 0) - { - /* Test mpz_divexact */ - mpz_mul (t, in1, in2); - mpz_divexact (ref1, t, in2); - - mpz_set (res1, t); - mpz_divexact (res1, res1, in2); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_divexact, t, in2, NULL); - - mpz_set (res1, in2); - mpz_divexact (res1, t, res1); - if (mpz_cmp (ref1, res1) != 0) - FAIL2 (mpz_divexact, t, in2, NULL); - } - } - - if (failures != 0) - { - fprintf (stderr, "mpz/reuse: %ld error%s\n", failures, "s" + (failures == 1)); - exit (1); - } - - exit (0); -} - -void -dump (char *name, mpz_t in1, mpz_t in2, mpz_t in3) -{ - printf ("failure in %s (", name); - mpz_out_str (stdout, -16, in1); - if (in2 != NULL) - { - printf (" "); - mpz_out_str (stdout, -16, in2); - } - if (in3 != NULL) - { - printf (" "); - mpz_out_str (stdout, -16, in3); - } - printf (")\n"); -} diff --git a/mpz/tests/t-2exp.c b/mpz/tests/t-2exp.c deleted file mode 100644 index 519a48ea9..000000000 --- a/mpz/tests/t-2exp.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Test mpz_ui_pow_ui, mpz_fdiv_q, mpz_fdiv_q_2exp, mpz_fdiv_r, - mpz_fdiv_r_2exp, and mpz_mul_2exp. - -Copyright 1997, 1999, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -main (int argc, char **argv) -{ - mpz_t x, r1, r2, q1, q2, d, t; - unsigned long n; - unsigned long int c; - int test; - int ntests = 50000; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - ntests = atoi (argv[1]); - - mpz_init (x); - mpz_init (q1); - mpz_init (q2); - mpz_init (r1); - mpz_init (r2); - mpz_init (d); - mpz_init (t); - - for (test = 1; test <= ntests; test++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 8 + 2; - - mpz_urandomb (bs, rands, size_range); - n = mpz_get_ui (bs); - mpz_rrandomb (x, rands, n); - mpz_urandomb (bs, rands, 1); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (x, x); - - mpz_urandomb (bs, rands, 8); - c = mpz_get_ui (bs); - mpz_ui_pow_ui (d, (unsigned long) 2, c); - - mpz_fdiv_q (q1, x, d); - mpz_fdiv_q_2exp (q2, x, c); - mpz_fdiv_r (r1, x, d); - mpz_fdiv_r_2exp (r2, x, c); - - if (mpz_cmp (q1, q2) != 0 || mpz_cmp (r1, r2) != 0) - abort (); - - mpz_mul_2exp (t, q1, c); - mpz_add (t, t, r1); - if (mpz_cmp (t, x) != 0) - abort (); - - if (mpz_cmp (r1, d) >= 0) - abort (); - } - - exit (0); -} diff --git a/mpz/tests/t-bin.c b/mpz/tests/t-bin.c deleted file mode 100644 index a6f011acd..000000000 --- a/mpz/tests/t-bin.c +++ /dev/null @@ -1,217 +0,0 @@ -/* Exercise mpz_bin_ui and mpz_bin_uiui. */ - -/* -Copyright 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 "gmp.h" -#include "gmp-impl.h" - - -void -try_mpz_bin_ui (mpz_srcptr want, mpz_srcptr n, unsigned long k) -{ - mpz_t got; - - mpz_init (got); - mpz_bin_ui (got, n, k); - MPZ_CHECK_FORMAT (got); - if (mpz_cmp (got, want) != 0) - { - printf ("mpz_bin_ui wrong\n"); - printf (" n="); mpz_out_str (stdout, 10, n); printf ("\n"); - printf (" k=%lu\n", k); - printf (" got="); mpz_out_str (stdout, 10, got); printf ("\n"); - printf (" want="); mpz_out_str (stdout, 10, want); printf ("\n"); - abort(); - } - mpz_clear (got); -} - - -void -try_mpz_bin_uiui (mpz_srcptr want, unsigned long n, unsigned long k) -{ - mpz_t got; - - mpz_init (got); - mpz_bin_uiui (got, n, k); - MPZ_CHECK_FORMAT (got); - if (mpz_cmp (got, want) != 0) - { - printf ("mpz_bin_uiui wrong\n"); - printf (" n=%lu\n", n); - printf (" k=%lu\n", k); - printf (" got="); mpz_out_str (stdout, 10, got); printf ("\n"); - printf (" want="); mpz_out_str (stdout, 10, want); printf ("\n"); - abort(); - } - mpz_clear (got); -} - - -void -samples (void) -{ - static const struct { - const char *n; - unsigned long k; - const char *want; - } data[] = { - - { "0", 0, "1" }, - { "0", 1, "0" }, - { "0", 2, "0" }, - { "0", 3, "0" }, - { "0", 4, "0" }, - { "0", 123456, "0" }, - - { "1", 0, "1" }, - { "1", 1, "1" }, - { "1", 2, "0" }, - { "1", 3, "0" }, - { "1", 4, "0" }, - { "1", 123456, "0" }, - - { "2", 0, "1" }, - { "2", 1, "2" }, - { "2", 2, "1" }, - { "2", 3, "0" }, - { "2", 4, "0" }, - { "2", 123456, "0" }, - - { "3", 0, "1" }, - { "3", 1, "3" }, - { "3", 2, "3" }, - { "3", 3, "1" }, - { "3", 4, "0" }, - { "3", 5, "0" }, - { "3", 123456, "0" }, - - { "4", 0, "1" }, - { "4", 1, "4" }, - { "4", 2, "6" }, - { "4", 3, "4" }, - { "4", 4, "1" }, - { "4", 5, "0" }, - { "4", 6, "0" }, - { "4", 123456, "0" }, - - { "10", 0, "1" }, - { "10", 1, "10" }, - { "10", 2, "45" }, - { "10", 3, "120" }, - { "10", 4, "210" }, - { "10", 5, "252" }, - { "10", 6, "210" }, - { "10", 7, "120" }, - { "10", 8, "45" }, - { "10", 9, "10" }, - { "10", 10, "1" }, - { "10", 11, "0" }, - { "10", 12, "0" }, - { "10", 123456, "0" }, - - /* negatives, using bin(-n,k)=bin(n+k-1,k) */ - { "-1", 0, "1" }, - { "-1", 1, "-1" }, - { "-1", 2, "1" }, - { "-1", 3, "-1" }, - { "-1", 4, "1" }, - - { "-2", 0, "1" }, - { "-2", 1, "-2" }, - { "-2", 2, "3" }, - { "-2", 3, "-4" }, - { "-2", 4, "5" }, - { "-2", 5, "-6" }, - { "-2", 6, "7" }, - - { "-3", 0, "1" }, - { "-3", 1, "-3" }, - { "-3", 2, "6" }, - { "-3", 3, "-10" }, - { "-3", 4, "15" }, - { "-3", 5, "-21" }, - { "-3", 6, "28" }, - - { "40", 20, "137846528820" }, - { "60", 30, "118264581564861424" }, - }; - - mpz_t n, want; - int i; - - mpz_init (n); - mpz_init (want); - - for (i = 0; i < numberof (data); i++) - { - MPZ_SET_STR_OR_ABORT (n, data[i].n, 0); - MPZ_SET_STR_OR_ABORT (want, data[i].want, 0); - - try_mpz_bin_ui (want, n, data[i].k); - - if (mpz_fits_ulong_p (n)) - try_mpz_bin_uiui (want, mpz_get_ui (n), data[i].k); - } - - mpz_clear (n); - mpz_clear (want); -} - - -/* Test some bin(2k,k) cases. This produces some biggish numbers to - exercise the limb accumulating code. */ -void -twos (void) -{ - mpz_t n, want; - unsigned long k; - - mpz_init (n); - mpz_init (want); - - mpz_set_ui (want, (unsigned long) 2); - for (k = 1; k < 200; k++) - { - mpz_set_ui (n, 2*k); - try_mpz_bin_ui (want, n, k); - - try_mpz_bin_uiui (want, 2*k, k); - - mpz_mul_ui (want, want, 2*(2*k+1)); - mpz_fdiv_q_ui (want, want, k+1); - } - - mpz_clear (n); - mpz_clear (want); -} - - -int -main (void) -{ - samples (); - twos (); - - exit (0); -} diff --git a/mpz/tests/t-fac_ui.c b/mpz/tests/t-fac_ui.c deleted file mode 100644 index 967d1a06c..000000000 --- a/mpz/tests/t-fac_ui.c +++ /dev/null @@ -1,93 +0,0 @@ -/* Exercise mpz_fac_ui. - -Copyright (C) 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 <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" - - -/* Usage: t-fac_ui [x|num] - - With no arguments testing goes up to the initial value of "limit" below. - With a number argument tests are carried that far, or with a literal "x" - tests are continued without limit (this being meant only for development - purposes). */ - - -unsigned long allocate_count = 0; -void * -allocate (size_t size) -{ - allocate_count++; - return __gmp_default_allocate (size); -} -void -release (void *ptr, size_t size) -{ - allocate_count--; - __gmp_default_free (ptr, size); -} - - -int -main (int argc, char *argv[]) -{ - unsigned long n; - unsigned long limit = 1500; - mpz_t f, r; - - if (argc > 1 && argv[1][0] == 'x') - limit = ULONG_MAX; - else if (argc > 1) - limit = atoi (argv[1]); - - if (BITS_PER_MP_LIMB < BITS_PER_LONGINT) - limit = MIN (limit, MP_LIMB_T_MAX); - - mp_set_memory_functions (allocate, NULL, release); - - mpz_init_set_ui (f, 1); /* 0! = 1 */ - mpz_init (r); - - for (n = 0; n < limit; n++) - { - mpz_fac_ui (r, n); - MPZ_CHECK_FORMAT (r); - - if (mpz_cmp (f, r) != 0) - { - printf ("mpz_fib_ui(%lu) wrong\n", n); - printf (" got "); mpz_out_str (stdout, 10, r); printf("\n"); - printf (" want "); mpz_out_str (stdout, 10, f); printf("\n"); - abort (); - } - - mpz_mul_ui (f, f, n+1); /* (n+1)! = n! * n */ - } - - mpz_clear (f); - mpz_clear (r); - - ASSERT_ALWAYS (allocate_count == 0); - - exit (0); -} diff --git a/mpz/tests/t-fdiv.c b/mpz/tests/t-fdiv.c deleted file mode 100644 index e87df3d97..000000000 --- a/mpz/tests/t-fdiv.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_fdiv_qr, mpz_fdiv_q, - mpz_fdiv_r, mpz_mul. - -Copyright 1993, 1994, 1996, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mpz_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t dividend, divisor; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size, divisor_size; - int i; - int reps = 200; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (divisor); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 16 + 2; /* 0..131071 bit operands */ - - do - { - mpz_urandomb (bs, rands, size_range); - divisor_size = mpz_get_ui (bs); - mpz_rrandomb (divisor, rands, divisor_size); - } - while (mpz_sgn (divisor) == 0); - - mpz_urandomb (bs, rands, size_range); - dividend_size = mpz_get_ui (bs) + divisor_size; - mpz_rrandomb (dividend, rands, dividend_size); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (dividend, dividend); - if ((bsi & 2) != 0) - mpz_neg (divisor, divisor); - - /* printf ("%ld %ld\n", SIZ (dividend), SIZ (divisor)); */ - - mpz_fdiv_qr (quotient, remainder, dividend, divisor); - mpz_fdiv_q (quotient2, dividend, divisor); - mpz_fdiv_r (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != ((mpz_cmp_ui (dividend, 0) ^ mpz_cmp_ui (divisor, 0)) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the divisor - (quotient rounded towards minus infinity). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if ((mpz_cmp_ui (remainder, 0) < 0) != (mpz_cmp_ui (divisor, 0) < 0)) - dump_abort (dividend, divisor); - - mpz_mul (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (temp, divisor); - mpz_abs (remainder, remainder); - if (mpz_cmp (remainder, temp) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -void -dump_abort (mpz_t dividend, mpz_t divisor) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-fdiv_ui.c b/mpz/tests/t-fdiv_ui.c deleted file mode 100644 index 985f91aa2..000000000 --- a/mpz/tests/t-fdiv_ui.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_fdiv_qr_ui, mpz_fdiv_q_ui, - mpz_fdiv_r_ui, mpz_mul, mpz_mul_ui. - -Copyright 1993, 1994, 1996, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mp_limb_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t dividend; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size; - mp_limb_t divisor; - int i; - int reps = 10000; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 10 + 2; /* 0..2047 bit operands */ - - do - { - mpz_rrandomb (bs, rands, 64); - divisor = mpz_get_ui (bs); - } - while (divisor == 0); - - mpz_urandomb (bs, rands, size_range); - dividend_size = mpz_get_ui (bs); - mpz_rrandomb (dividend, rands, dividend_size); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (dividend, dividend); - - /* printf ("%ld\n", SIZ (dividend)); */ - - mpz_fdiv_qr_ui (quotient, remainder, dividend, divisor); - mpz_fdiv_q_ui (quotient2, dividend, divisor); - mpz_fdiv_r_ui (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the divisor - (quotient rounded towards minus infinity). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if (mpz_cmp_ui (remainder, 0) < 0) - dump_abort (dividend, divisor); - - mpz_mul_ui (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (remainder, remainder); - if (mpz_cmp_ui (remainder, divisor) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -void -dump_abort (mpz_t dividend, mp_limb_t divisor) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = %lX\n", divisor); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-fib_ui.c b/mpz/tests/t-fib_ui.c deleted file mode 100644 index 293d30112..000000000 --- a/mpz/tests/t-fib_ui.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Test mpz_fib_ui. - -Copyright (C) 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 <stdlib.h> -#include "gmp.h" -#include "gmp-impl.h" - - -#define MPZ_FIB_SIZE_FLOAT(n) \ - ((mp_size_t) ((n) * 0.6942419 / BITS_PER_MP_LIMB + 1)) - - -int -main (int argc, char *argv[]) -{ - unsigned long n; - unsigned long limit = MAX (2000, 32*FIB_THRESHOLD); - mpz_t fn, fn1, r; - - if (argc > 1 && argv[1][0] == 'x') - limit = ULONG_MAX; - else if (argc > 1) - limit = atoi (argv[1]); - - /* start at n==0 */ - mpz_init_set_ui (fn1, 1); /* F[n-1] */ - mpz_init_set_ui (fn, 0); /* F[n] */ - mpz_init (r); - - for (n = 0; n < limit; n++) - { - if (MPZ_FIB_SIZE (n) < MPZ_FIB_SIZE_FLOAT (n)) - { - printf ("MPZ_FIB_SIZE wrong at n=%lu\n", n); - printf (" MPZ_FIB_SIZE %ld\n", MPZ_FIB_SIZE (n)); - printf (" MPZ_FIB_SIZE_FLOAT %ld\n", MPZ_FIB_SIZE_FLOAT (n)); - abort (); - } - - mpz_fib_ui (r, n); - - if (MPZ_FIB_SIZE_FLOAT (n) < SIZ(r)) - { - printf ("MPZ_FIB_SIZE_FLOAT wrong at n=%lu\n", n); - printf (" MPZ_FIB_SIZE_FLOAT %ld\n", MPZ_FIB_SIZE_FLOAT (n)); - printf (" SIZ(r) %d\n", SIZ(r)); - abort (); - } - - if (MPZ_FIB_SIZE (n) < SIZ(r)) - { - printf ("MPZ_FIB_SIZE wrong at n=%lu\n", n); - printf (" MPZ_FIB_SIZE %ld\n", MPZ_FIB_SIZE (n)); - printf (" SIZ(r) %d\n", SIZ(r)); - abort (); - } - - MPZ_CHECK_FORMAT (r); - - if (mpz_cmp (r, fn) != 0) - { - printf ("mpz_fib_ui(%lu) wrong\n", n); - printf (" got "); mpz_out_str (stdout, 10, r); printf("\n"); - printf (" want "); mpz_out_str (stdout, 10, fn); printf("\n"); - abort (); - } - - mpz_add (fn1, fn1, fn); /* F[n+1] = F[n] + F[n-1] */ - mpz_swap (fn1, fn); - } - - exit (0); -} diff --git a/mpz/tests/t-gcd.c b/mpz/tests/t-gcd.c deleted file mode 100644 index 95f134510..000000000 --- a/mpz/tests/t-gcd.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Test mpz_gcd, mpz_gcdext, mpz_mul, mpz_tdiv_r, mpz_add, mpz_cmp, - mpz_cmp_ui, mpz_init_set, mpz_set, mpz_clear. - -Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mpz_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t op1, op2, x; - mpz_t gcd, gcd2, s, t; - mpz_t temp1, temp2; - mp_size_t op1_size, op2_size, x_size; - int i; - int reps = 2000; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - gmp_randseed_ui (rands, atoi (argv[1])); - - mpz_init (op1); - mpz_init (op2); - mpz_init (x); - mpz_init (gcd); - mpz_init (gcd2); - mpz_init (temp1); - mpz_init (temp2); - mpz_init (s); - mpz_init (t); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 12 + 2; /* 0..8191 bit operands */ - - mpz_urandomb (bs, rands, size_range); - op1_size = mpz_get_ui (bs); - mpz_rrandomb (op1, rands, op1_size); - - mpz_urandomb (bs, rands, size_range); - op2_size = mpz_get_ui (bs); - mpz_rrandomb (op2, rands, op2_size); - - mpz_urandomb (bs, rands, size_range); - x_size = mpz_get_ui (bs); - mpz_rrandomb (x, rands, x_size); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (op1, op1); - if ((bsi & 2) != 0) - mpz_neg (op2, op2); - - /* printf ("%ld %ld\n", SIZ (op1), SIZ (op2)); */ - - mpz_mul (op1, op1, x); - mpz_mul (op2, op2, x); - - mpz_gcd (gcd, op1, op2); - /* We know GCD will be at least X, since we multiplied both operands - with it. */ - if (mpz_cmp (gcd, x) < 0 && mpz_sgn (op1) != 0 && mpz_sgn (op2) != 0) - dump_abort (op1, op2); - - mpz_gcdext (gcd2, s, t, op1, op2); - if (mpz_cmp (gcd, gcd2)) - dump_abort (op1, op2); - - mpz_gcdext (gcd2, s, NULL, op1, op2); - if (mpz_cmp (gcd, gcd2)) - dump_abort (op1, op2); - - mpz_mul (temp1, s, op1); - mpz_mul (temp2, t, op2); - mpz_add (gcd2, temp1, temp2); - if (mpz_cmp (gcd, gcd2)) - dump_abort (op1, op2); - } - - exit (0); -} - -void -dump_abort (mpz_t op1, mpz_t op2) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (op1, -16); - fprintf (stderr, "op2 = "); debug_mp (op2, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-get_si.c b/mpz/tests/t-get_si.c deleted file mode 100644 index a43a69a00..000000000 --- a/mpz/tests/t-get_si.c +++ /dev/null @@ -1,90 +0,0 @@ -/* Exercise mpz_get_si. */ - -/* -Copyright 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 "gmp.h" -#include "gmp-impl.h" - -int -main (void) -{ - static const struct { - const char *n; - long want; - - } data[] = { - - { "0", 0L }, - { "1", 1L }, - { "-1", -1L }, - { "2", 2L }, - { "-2", -2L }, - { "12345", 12345L }, - { "-12345", -12345L }, - - /* The -0x100000000 case doesn't fit in a long and the result from - mpz_get_si() is undefined, but -0x80000000 is what comes out - currently, and it should be that value irrespective of the size of - mp_limb_t size (long or long long). */ -#if BITS_PER_LONGINT==32 - { " 0x7FFFFFFF", 0x7FFFFFFFL }, - { "-0x80000000", -0x80000000L }, - { "-0x100000000", -0x80000000L }, - -#else -#if BITS_PER_LONGINT==64 - { " 0x7FFFFFFFFFFFFFFF", 0x7FFFFFFFFFFFFFFFL }, - { "-0x8000000000000000", -0x8000000000000000L }, - { "-0x10000000000000000", -0x8000000000000000L }, - -#else - Unrecognised BITS_PER_LONGINT -#endif -#endif - }; - - int i; - mpz_t n; - long got; - - mpz_init (n); - for (i = 0; i < numberof (data); i++) - { - MPZ_SET_STR_OR_ABORT (n, data[i].n, 0); - - got = mpz_get_si (n); - if (got != data[i].want) - { - printf ("mpz_get_si wrong at data[%d]\n", i); - printf (" n \"%s\" (", data[i].n); - mpz_out_str (stdout, 10, n); printf (", hex "); - mpz_out_str (stdout, 16, n); printf (")\n"); - printf (" got %ld (0x%lX)\n", got, got); - printf (" want %ld (0x%lX)\n", data[i].want, data[i].want); - abort(); - } - } - mpz_clear (n); - - exit (0); -} diff --git a/mpz/tests/t-jac.c b/mpz/tests/t-jac.c deleted file mode 100644 index 84e09c7be..000000000 --- a/mpz/tests/t-jac.c +++ /dev/null @@ -1,684 +0,0 @@ -/* Exercise mpz_*_kronecker_*() and mpz_jacobi() functions. */ - -/* -Copyright 1999, 2000, 2001 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. -*/ - - -/* With no arguments the various Kronecker/Jacobi symbol routines are - checked against some test data and a lot of derived data. - - To check the test data against PARI-GP, run - - t-jac -p | gp -q - - It takes a while because the output from "t-jac -p" is big. - - - Enhancements: - - More big test cases than those given by check_squares_zi would be good. */ - - -#include <stdio.h> -#include <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - - -int option_pari = 0; -gmp_randstate_t rands; - - -unsigned long -mpz_mod4 (mpz_srcptr z) -{ - mpz_t m; - unsigned long ret; - - mpz_init (m); - mpz_fdiv_r_2exp (m, z, 2); - ret = mpz_get_ui (m); - mpz_clear (m); - return ret; -} - -int -mpz_fits_ulimb_p (mpz_srcptr z) -{ - return (SIZ(z) == 1 || SIZ(z) == 0); -} - -mp_limb_t -mpz_get_ulimb (mpz_srcptr z) -{ - if (SIZ(z) == 0) - return 0; - else - return PTR(z)[0]; -} - - -void -try_base (mp_limb_t a, mp_limb_t b, int answer) -{ - int got; - - if ((b & 1) == 0 || b == 1 || a > b) - return; - - got = mpn_jacobi_base (a, b, 0); - if (got != answer) - { - printf ("mpn_jacobi_base (%lu, %lu) is %d should be %d\n", - a, b, got, answer); - exit (1); - } -} - - -void -try_zi_ui (mpz_srcptr a, unsigned long b, int answer) -{ - int got; - - got = mpz_kronecker_ui (a, b); - if (got != answer) - { - printf ("mpz_kronecker_ui ("); - mpz_out_str (stdout, 10, a); - printf (", %lu) is %d should be %d\n", b, got, answer); - exit (1); - } -} - - -void -try_zi_si (mpz_srcptr a, long b, int answer) -{ - int got; - - got = mpz_kronecker_si (a, b); - if (got != answer) - { - printf ("mpz_kronecker_si ("); - mpz_out_str (stdout, 10, a); - printf (", %ld) is %d should be %d\n", b, got, answer); - exit (1); - } -} - - -void -try_ui_zi (unsigned long a, mpz_srcptr b, int answer) -{ - int got; - - got = mpz_ui_kronecker (a, b); - if (got != answer) - { - printf ("mpz_ui_kronecker (%lu, ", a); - mpz_out_str (stdout, 10, b); - printf (") is %d should be %d\n", got, answer); - exit (1); - } -} - - -void -try_si_zi (int a, mpz_srcptr b, int answer) -{ - int got; - - got = mpz_si_kronecker (a, b); - if (got != answer) - { - printf ("mpz_si_kronecker (%d, ", a); - mpz_out_str (stdout, 10, b); - printf (") is %d should be %d\n", got, answer); - exit (1); - } -} - - -void -try_zi_zi (mpz_srcptr a, mpz_srcptr b, int answer) -{ - int got; - - /* gmp 2.0.2 mpz_jacobi() doesn't handle negative or even b */ - if (mpz_sgn (b) <= 0 || mpz_even_p (b)) - return; - - got = mpz_jacobi (a, b); - if (got != answer) - { - printf ("mpz_jacobi ("); - mpz_out_str (stdout, 10, a); - printf (", "); - mpz_out_str (stdout, 10, b); - printf (") is %d should be %d\n", got, answer); - exit (1); - } -} - - -void -try_pari (mpz_srcptr a, mpz_srcptr b, int answer) -{ - printf ("try("); - mpz_out_str (stdout, 10, a); - printf (","); - mpz_out_str (stdout, 10, b); - printf (",%d)\n", answer); -} - - -void -try_each (mpz_srcptr a, mpz_srcptr b, int answer) -{ - if (option_pari) - { - try_pari (a, b, answer); - return; - } - - if (mpz_fits_ulimb_p (a) && mpz_fits_ulimb_p (b)) - try_base (mpz_get_ulimb (a), mpz_get_ulimb (b), answer); - - if (mpz_fits_ulong_p (b)) - try_zi_ui (a, mpz_get_ui (b), answer); - - if (mpz_fits_slong_p (b)) - try_zi_si (a, mpz_get_si (b), answer); - - if (mpz_fits_ulong_p (a)) - try_ui_zi (mpz_get_ui (a), b, answer); - - if (mpz_fits_sint_p (a)) - try_si_zi (mpz_get_si (a), b, answer); - - try_zi_zi (a, b, answer); -} - - -/* Try (a/b) and (a/-b). */ -void -try_pn (mpz_srcptr a, mpz_srcptr b_orig, int answer) -{ - mpz_t b; - - mpz_init_set (b, b_orig); - try_each (a, b, answer); - - mpz_neg (b, b); - if (mpz_sgn (a) < 0) - answer = -answer; - - try_each (a, b, answer); - - mpz_clear (b); -} - - -/* Try (a+k*p/b) for various k, using the fact (a/b) is periodic in a with - period p. For b>0, p=b if b!=2mod4 or p=4*b if b==2mod4. */ - -void -try_periodic_num (mpz_srcptr a_orig, mpz_srcptr b, int answer) -{ - mpz_t a, a_period; - int i; - - if (mpz_sgn (b) <= 0) - return; - - mpz_init_set (a, a_orig); - mpz_init_set (a_period, b); - if (mpz_mod4 (b) == 2) - mpz_mul_ui (a_period, a_period, 4); - - /* don't bother with these tests if they're only going to produce - even/even */ - if (mpz_even_p (a) && mpz_even_p (b) && mpz_even_p (a_period)) - goto done; - - for (i = 0; i < 10; i++) - { - mpz_add (a, a, a_period); - try_pn (a, b, answer); - } - - mpz_set (a, a_orig); - for (i = 0; i < 10; i++) - { - mpz_sub (a, a, a_period); - try_pn (a, b, answer); - } - - done: - mpz_clear (a); - mpz_clear (a_period); -} - - -/* Try (a/b+k*p) for various k, using the fact (a/b) is periodic in b of - period p. - - period p - a==0,1mod4 a - a==2mod4 4*a - a==3mod4 and b odd 4*a - a==3mod4 and b even 8*a - - In Henri Cohen's book the period is given as 4*a for all a==2,3mod4, but - a counterexample would seem to be (3/2)=-1 which with (3/14)=+1 doesn't - have period 4*a (but rather 8*a with (3/26)=-1). Maybe the plain 4*a is - to be read as applying to a plain Jacobi symbol with b odd, rather than - the Kronecker extension to b even. */ - -void -try_periodic_den (mpz_srcptr a, mpz_srcptr b_orig, int answer) -{ - mpz_t b, b_period; - int i; - - if (mpz_sgn (a) == 0 || mpz_sgn (b_orig) == 0) - return; - - mpz_init_set (b, b_orig); - - mpz_init_set (b_period, a); - if (mpz_mod4 (a) == 3 && mpz_even_p (b)) - mpz_mul_ui (b_period, b_period, 8); - else if (mpz_mod4 (a) >= 2) - mpz_mul_ui (b_period, b_period, 4); - - /* don't bother with these tests if they're only going to produce - even/even */ - if (mpz_even_p (a) && mpz_even_p (b) && mpz_even_p (b_period)) - goto done; - - for (i = 0; i < 10; i++) - { - mpz_add (b, b, b_period); - try_pn (a, b, answer); - } - - mpz_set (b, b_orig); - for (i = 0; i < 10; i++) - { - mpz_sub (b, b, b_period); - try_pn (a, b, answer); - } - - done: - mpz_clear (b); - mpz_clear (b_period); -} - - -/* Try (a/b*2^k) for various k. If it happens mpz_ui_kronecker() gets (a/2) - wrong it will show up as wrong answers demanded. */ -void -try_2den (mpz_srcptr a, mpz_srcptr b_orig, int answer) -{ - mpz_t b; - int i; - int answer_two; - - /* don't bother when b==0 */ - if (mpz_sgn (b_orig) == 0) - return; - - mpz_init_set (b, b_orig); - answer_two = mpz_kronecker_ui (a, 2); - - for (i = 0; i < 3 * BITS_PER_MP_LIMB; i++) - { - answer *= answer_two; - mpz_mul_2exp (b, b, 1); - try_pn (a, b, answer); - } - - mpz_clear (b); -} - - -/* Try (a*2^k/b) for various k. If it happens mpz_ui_kronecker() gets (2/b) - wrong it will show up as wrong answers demanded. */ -void -try_2num (mpz_srcptr a_orig, mpz_srcptr b, int answer) -{ - mpz_t a; - int i; - int answer_twos; - - /* don't bother when a==0 */ - if (mpz_sgn (a_orig) == 0) - return; - - mpz_init_set (a, a_orig); - answer_twos = mpz_ui_kronecker (2, b); - - for (i = 0; i < 3 * BITS_PER_MP_LIMB; i++) - { - answer *= answer_twos; - mpz_mul_2exp (a, a, 1); - try_pn (a, b, answer); - } - - mpz_clear (a); -} - - -/* The try_2num() and try_2den() routines don't in turn call - try_periodic_num() and try_periodic_den() because it hugely increases the - number of tests performed, without obviously increasing coverage. - - Useful extra derived cases can be added here. */ - -void -try_all (mpz_t a, mpz_t b, int answer) -{ - try_pn (a, b, answer); - try_periodic_num (a, b, answer); - try_periodic_den (a, b, answer); - try_2num (a, b, answer); - try_2den (a, b, answer); -} - - -void -check_data (void) -{ - static const struct { - const char *a; - const char *b; - int answer; - - } data[] = { - - /* Note that the various derived checks in try_all() reduce the cases - that need to be given here. */ - - /* some zeros */ - { "0", "0", 0 }, - { "0", "2", 0 }, - { "0", "6", 0 }, - { "5", "0", 0 }, - { "24", "60", 0 }, - - /* (a/1) = 1, any a - In particular note (0/1)=1 so that (a/b)=(a mod b/b). */ - { "0", "1", 1 }, - { "1", "1", 1 }, - { "2", "1", 1 }, - { "3", "1", 1 }, - { "4", "1", 1 }, - { "5", "1", 1 }, - - /* (0/b) = 0, b != 1 */ - { "0", "3", 0 }, - { "0", "5", 0 }, - { "0", "7", 0 }, - { "0", "9", 0 }, - { "0", "11", 0 }, - { "0", "13", 0 }, - { "0", "15", 0 }, - - /* (1/b) = 1 */ - { "1", "1", 1 }, - { "1", "3", 1 }, - { "1", "5", 1 }, - { "1", "7", 1 }, - { "1", "9", 1 }, - { "1", "11", 1 }, - - /* (-1/b) = (-1)^((b-1)/2) which is -1 for b==3 mod 4 */ - { "-1", "1", 1 }, - { "-1", "3", -1 }, - { "-1", "5", 1 }, - { "-1", "7", -1 }, - { "-1", "9", 1 }, - { "-1", "11", -1 }, - { "-1", "13", 1 }, - { "-1", "15", -1 }, - { "-1", "17", 1 }, - { "-1", "19", -1 }, - - /* (2/b) = (-1)^((b^2-1)/8) which is -1 for b==3,5 mod 8. - try_2num() will exercise multiple powers of 2 in the numerator. */ - { "2", "1", 1 }, - { "2", "3", -1 }, - { "2", "5", -1 }, - { "2", "7", 1 }, - { "2", "9", 1 }, - { "2", "11", -1 }, - { "2", "13", -1 }, - { "2", "15", 1 }, - { "2", "17", 1 }, - - /* (-2/b) = (-1)^((b^2-1)/8)*(-1)^((b-1)/2) which is -1 for b==5,7mod8. - try_2num() will exercise multiple powers of 2 in the numerator, which - will test that the shift in mpz_si_kronecker() uses unsigned not - signed. */ - { "-2", "1", 1 }, - { "-2", "3", 1 }, - { "-2", "5", -1 }, - { "-2", "7", -1 }, - { "-2", "9", 1 }, - { "-2", "11", 1 }, - { "-2", "13", -1 }, - { "-2", "15", -1 }, - { "-2", "17", 1 }, - - /* (a/2)=(2/a). - try_2den() will exercise multiple powers of 2 in the denominator. */ - { "3", "2", -1 }, - { "5", "2", -1 }, - { "7", "2", 1 }, - { "9", "2", 1 }, - { "11", "2", -1 }, - - /* Harriet Griffin, "Elementary Theory of Numbers", page 155, various - examples. */ - { "2", "135", 1 }, - { "135", "19", -1 }, - { "2", "19", -1 }, - { "19", "135", 1 }, - { "173", "135", 1 }, - { "38", "135", 1 }, - { "135", "173", 1 }, - { "173", "5", -1 }, - { "3", "5", -1 }, - { "5", "173", -1 }, - { "173", "3", -1 }, - { "2", "3", -1 }, - { "3", "173", -1 }, - { "253", "21", 1 }, - { "1", "21", 1 }, - { "21", "253", 1 }, - { "21", "11", -1 }, - { "-1", "11", -1 }, - - /* Griffin page 147 */ - { "-1", "17", 1 }, - { "2", "17", 1 }, - { "-2", "17", 1 }, - { "-1", "89", 1 }, - { "2", "89", 1 }, - - /* Griffin page 148 */ - { "89", "11", 1 }, - { "1", "11", 1 }, - { "89", "3", -1 }, - { "2", "3", -1 }, - { "3", "89", -1 }, - { "11", "89", 1 }, - { "33", "89", -1 }, - - /* H. Davenport, "The Higher Arithmetic", page 65, the quadratic - residues and non-residues mod 19. */ - { "1", "19", 1 }, - { "4", "19", 1 }, - { "5", "19", 1 }, - { "6", "19", 1 }, - { "7", "19", 1 }, - { "9", "19", 1 }, - { "11", "19", 1 }, - { "16", "19", 1 }, - { "17", "19", 1 }, - { "2", "19", -1 }, - { "3", "19", -1 }, - { "8", "19", -1 }, - { "10", "19", -1 }, - { "12", "19", -1 }, - { "13", "19", -1 }, - { "14", "19", -1 }, - { "15", "19", -1 }, - { "18", "19", -1 }, - - /* Residues and non-residues mod 13 */ - { "0", "13", 0 }, - { "1", "13", 1 }, - { "2", "13", -1 }, - { "3", "13", 1 }, - { "4", "13", 1 }, - { "5", "13", -1 }, - { "6", "13", -1 }, - { "7", "13", -1 }, - { "8", "13", -1 }, - { "9", "13", 1 }, - { "10", "13", 1 }, - { "11", "13", -1 }, - { "12", "13", 1 }, - - /* various */ - { "5", "7", -1 }, - { "15", "17", 1 }, - { "67", "89", 1 }, - - }; - - int i, answer; - mpz_t a, b; - - mpz_init (a); - mpz_init (b); - - for (i = 0; i < numberof (data); i++) - { - MPZ_SET_STR_OR_ABORT (a, data[i].a, 0); - MPZ_SET_STR_OR_ABORT (b, data[i].b, 0); - - answer = data[i].answer; - try_all (a, b, data[i].answer); - } - - mpz_clear (a); - mpz_clear (b); -} - - -/* (a^2/b)=1 if gcd(a,b)=1, or (a^2/b)=0 if gcd(a,b)!=1. */ -void -check_squares_zi (void) -{ - mpz_t a, b, g; - int i, answer; - mp_size_t size_range, an, bn; - mpz_t bs; - - mpz_init (bs); - - mpz_init (a); - mpz_init (b); - mpz_init (g); - - for (i = 0; i < 200; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 10 + 2; - - mpz_urandomb (bs, rands, size_range); - an = mpz_get_ui (bs); - mpz_rrandomb (a, rands, an); - - mpz_urandomb (bs, rands, size_range); - bn = mpz_get_ui (bs); - mpz_rrandomb (b, rands, bn); - - mpz_mul (a, a, b); - - mpz_gcd (g, a, b); - if (mpz_cmp_ui (g, 1) == 0) - answer = 1; - else - answer = 0; - - try_all (a, b, answer); - } - - mpz_clear (a); - mpz_clear (b); - mpz_clear (g); -} - - -int -main (int argc, char *argv[]) -{ - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - if (argc >= 2 && strcmp (argv[1], "-p") == 0) - { - option_pari = 1; - - printf ("\ -try(a,b,answer) =\n\ -{\n\ - if (kronecker(a,b) != answer,\n\ - print(\"wrong at \", a, \",\", b,\n\ - \" expected \", answer,\n\ - \" pari says \", kronecker(a,b)))\n\ -}\n"); - } - - check_data (); - check_squares_zi (); - - exit (0); -} diff --git a/mpz/tests/t-misc.c b/mpz/tests/t-misc.c deleted file mode 100644 index bfc19f619..000000000 --- a/mpz/tests/t-misc.c +++ /dev/null @@ -1,204 +0,0 @@ -/* Exercise various mpz functions. */ - -/* -Copyright 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 "gmp.h" -#include "gmp-impl.h" - -#define SGN(x) ((x) < 0 ? -1 : (x) == 0 ? 0 : 1) - - -void -check_oddeven (void) -{ - static const struct { - const char *n; - int odd, even; - } data[] = { - { "0", 0, 1 }, - { "1", 1, 0 }, - { "2", 0, 1 }, - { "3", 1, 0 }, - { "4", 0, 1 }, - - { "-4", 0, 1 }, - { "-3", 1, 0 }, - { "-2", 0, 1 }, - { "-1", 1, 0 }, - - { "0x1000000000000000000000000000000000000000000000000000", 0, 1 }, - { "0x1000000000000000000000000000000000000000000000000001", 1, 0 }, - { "0x1000000000000000000000000000000000000000000000000002", 0, 1 }, - { "0x1000000000000000000000000000000000000000000000000003", 1, 0 }, - - { "-0x1000000000000000000000000000000000000000000000000004", 0, 1 }, - { "-0x1000000000000000000000000000000000000000000000000003", 1, 0 }, - { "-0x1000000000000000000000000000000000000000000000000002", 0, 1 }, - { "-0x1000000000000000000000000000000000000000000000000001", 1, 0 }, - }; - - mpz_t n; - int i; - - mpz_init (n); - for (i = 0; i < numberof (data); i++) - { - MPZ_SET_STR_OR_ABORT (n, data[i].n, 0); - - if ((mpz_odd_p (n) != 0) != data[i].odd) - { - printf ("mpz_odd_p wrong on data[%d]\n", i); - abort(); - } - - if ((mpz_even_p (n) != 0) != data[i].even) - { - printf ("mpz_even_p wrong on data[%d]\n", i); - abort(); - } - } - - mpz_clear (n); -} - - -void -check_mpz_set_si (void) -{ - static const struct { - long n; - mp_size_t want_size; - mp_limb_t want_limb; - } data[] = { - - { 0L, 0 }, - { 1L, 1, 1 }, - { -1L, -1, 1 }, - - { LONG_MAX, 1, LONG_MAX }, - { -LONG_MAX, -1, LONG_MAX }, - - { LONG_HIGHBIT, -1, ULONG_HIGHBIT }, - }; - - mpz_t n; - int i; - - for (i = 0; i < numberof (data); i++) - { - mpz_init (n); - mpz_set_si (n, data[i].n); - if (n->_mp_size != data[i].want_size - || (n->_mp_size != 0 && n->_mp_d[0] != data[i].want_limb)) - { - printf ("mpz_set_si wrong on data[%d]\n", i); - abort(); - } - mpz_clear (n); - - mpz_init_set_si (n, data[i].n); - if (n->_mp_size != data[i].want_size - || (n->_mp_size != 0 && n->_mp_d[0] != data[i].want_limb)) - { - printf ("mpz_init_set_si wrong on data[%d]\n", i); - abort(); - } - mpz_clear (n); - } -} - - -void -check_mpz_cmp_si (void) -{ - static const struct { - const char *a, *b; - int want; - } data[] = { - { "0", "1", -1 }, - { "0", "0", 0 }, - { "0", "-1", 1 }, - - { "1", "1", 0 }, - { "1", "0", 1 }, - { "1", "-1", 1 }, - - { "-1", "1", -1 }, - { "-1", "0", -1 }, - { "-1", "-1", 0 }, - - { "0", "-0x80000000", 1 }, - { "0x80000000", "-0x80000000", 1 }, - { "0x80000001", "-0x80000000", 1 }, - { "-0x80000000", "-0x80000000", 0 }, - { "-0x80000001", "-0x80000000", -1 }, - - { "0", "-0x8000000000000000", 1 }, - { "0x8000000000000000", "-0x8000000000000000", 1 }, - { "0x8000000000000001", "-0x8000000000000000", 1 }, - { "-0x8000000000000000", "-0x8000000000000000", 0 }, - { "-0x8000000000000001", "-0x8000000000000000", -1 }, - }; - - mpz_t a, bz; - long b; - int got; - int i; - - mpz_init (a); - mpz_init (bz); - for (i = 0; i < numberof (data); i++) - { - MPZ_SET_STR_OR_ABORT (a, data[i].a, 0); - MPZ_SET_STR_OR_ABORT (bz, data[i].b, 0); - - if (mpz_fits_slong_p (bz)) - { - b = mpz_get_si (bz); - got = mpz_cmp_si (a, b); - if (SGN (got) != data[i].want) - { - printf ("mpz_cmp_si wrong on data[%d]\n", i); - printf (" a="); mpz_out_str (stdout, 10, a); printf ("\n"); - printf (" b=%ld\n", b); - printf (" got=%d\n", got); - printf (" want=%d\n", data[i].want); - abort(); - } - } - } - - mpz_clear (a); - mpz_clear (bz); -} - - -int -main (void) -{ - check_oddeven (); - check_mpz_set_si (); - check_mpz_cmp_si (); - - exit (0); -} diff --git a/mpz/tests/t-mul.c b/mpz/tests/t-mul.c deleted file mode 100644 index e682cf7bd..000000000 --- a/mpz/tests/t-mul.c +++ /dev/null @@ -1,282 +0,0 @@ -/* Test mpz_cmp, mpz_cmp_ui, mpz_tdiv_qr, mpz_mul. - -Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void debug_mp _PROTO ((mpz_t, int)); -static void base_mul _PROTO ((mp_ptr,mp_srcptr,mp_size_t,mp_srcptr,mp_size_t)); -static void ref_mpz_mul _PROTO ((mpz_t, const mpz_t, const mpz_t)); -void dump_abort _PROTO ((char *, mpz_t, mpz_t, mpz_t, mpz_t)); - -main (int argc, char **argv) -{ - mpz_t multiplier, multiplicand; - mpz_t product, ref_product; - mpz_t quotient, remainder; - mp_size_t multiplier_size, multiplicand_size; - int i; - int reps = 100; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (multiplier); - mpz_init (multiplicand); - mpz_init (product); - mpz_init (ref_product); - mpz_init (quotient); - mpz_init (remainder); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 18 + 2; - mpz_urandomb (bs, rands, size_range); - multiplier_size = mpz_get_ui (bs); - mpz_rrandomb (multiplier, rands, multiplier_size); - - mpz_urandomb (bs, rands, size_range); - multiplicand_size = mpz_get_ui (bs); - mpz_rrandomb (multiplicand, rands, multiplicand_size); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (multiplier, multiplier); - if ((bsi & 2) != 0) - mpz_neg (multiplicand, multiplicand); - - /* printf ("%ld %ld\n", SIZ (multiplier), SIZ (multiplicand)); */ - - mpz_mul (product, multiplier, multiplicand); - - if (size_range <= 16) /* avoid calling ref_mpz_mul for huge operands */ - { - - ref_mpz_mul (ref_product, multiplier, multiplicand); - if (mpz_cmp (product, ref_product)) - dump_abort ("incorrect plain product", - multiplier, multiplicand, product, ref_product); - } - - if (mpz_cmp_ui (multiplicand, 0) != 0) - { - mpz_tdiv_qr (quotient, remainder, product, multiplicand); - if (mpz_cmp_ui (remainder, 0) || mpz_cmp (quotient, multiplier)) - { - debug_mp (quotient, -16); - debug_mp (remainder, -16); - dump_abort ("incorrect quotient or remainder", - multiplier, multiplicand, product, ref_product); - } - } - - if (size_range <= 16) /* avoid calling ref_mpz_mul for huge operands */ - { - /* Test squaring. */ - mpz_mul (product, multiplier, multiplier); - ref_mpz_mul (ref_product, multiplier, multiplier); - - if (mpz_cmp (product, ref_product)) - dump_abort ("incorrect square product", - multiplier, multiplier, product, ref_product); - } - } - - exit (0); -} - -static void -ref_mpz_mul (mpz_t w, const mpz_t u, const mpz_t v) -{ - mp_size_t usize = u->_mp_size; - mp_size_t vsize = v->_mp_size; - mp_size_t wsize; - mp_size_t sign_product; - mp_ptr up, vp; - mp_ptr wp; - mp_ptr free_me = NULL; - size_t free_me_size; - TMP_DECL (marker); - - TMP_MARK (marker); - sign_product = usize ^ vsize; - usize = ABS (usize); - vsize = ABS (vsize); - - if (usize < vsize) - { - /* Swap U and V. */ - {const __mpz_struct *t = u; u = v; v = t;} - {mp_size_t t = usize; usize = vsize; vsize = t;} - } - - if (vsize == 0) - { - SIZ (w) = 0; - return; - } - - up = u->_mp_d; - vp = v->_mp_d; - wp = w->_mp_d; - - /* Ensure W has space enough to store the result. */ - wsize = usize + vsize; - if (w->_mp_alloc < wsize) - { - if (wp == up || wp == vp) - { - free_me = wp; - free_me_size = w->_mp_alloc; - } - else - (*__gmp_free_func) (wp, w->_mp_alloc * BYTES_PER_MP_LIMB); - - w->_mp_alloc = wsize; - wp = (mp_ptr) (*__gmp_allocate_func) (wsize * BYTES_PER_MP_LIMB); - w->_mp_d = wp; - } - else - { - /* Make U and V not overlap with W. */ - if (wp == up) - { - /* W and U are identical. Allocate temporary space for U. */ - up = (mp_ptr) TMP_ALLOC (usize * BYTES_PER_MP_LIMB); - /* Is V identical too? Keep it identical with U. */ - if (wp == vp) - vp = up; - /* Copy to the temporary space. */ - MPN_COPY (up, wp, usize); - } - else if (wp == vp) - { - /* W and V are identical. Allocate temporary space for V. */ - vp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - /* Copy to the temporary space. */ - MPN_COPY (vp, wp, vsize); - } - } - - base_mul (wp, up, usize, vp, vsize); - wsize = usize + vsize; - wsize -= wp[wsize - 1] == 0; - w->_mp_size = sign_product < 0 ? -wsize : wsize; - if (free_me != NULL) - (*__gmp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - - TMP_FREE (marker); -} - -static void -base_mul (mp_ptr wp, mp_srcptr up, mp_size_t un, mp_srcptr vp, mp_size_t vn) -{ - mp_size_t i, j; - mp_limb_t prod_low, prod_high; - mp_limb_t cy_dig; - mp_limb_t v_limb, c; - - /* Multiply by the first limb in V separately, as the result can - be stored (not added) to PROD. We also avoid a loop for zeroing. */ - v_limb = vp[0]; - cy_dig = 0; - for (j = un; j > 0; j--) - { - mp_limb_t u_limb, w_limb; - u_limb = *up++; - umul_ppmm (prod_high, prod_low, u_limb, v_limb); - add_ssaaaa (cy_dig, w_limb, prod_high, prod_low, 0, cy_dig); - *wp++ = w_limb; - } - - *wp++ = cy_dig; - wp -= un; - up -= un; - - /* For each iteration in the outer loop, multiply one limb from - U with one limb from V, and add it to PROD. */ - for (i = 1; i < vn; i++) - { - v_limb = vp[i]; - cy_dig = 0; - - for (j = un; j > 0; j--) - { - mp_limb_t u_limb, w_limb; - u_limb = *up++; - umul_ppmm (prod_high, prod_low, u_limb, v_limb); - w_limb = *wp; - add_ssaaaa (prod_high, prod_low, prod_high, prod_low, 0, w_limb); - prod_low += cy_dig; - cy_dig = prod_high + (prod_low < cy_dig); - *wp++ = prod_low; - } - - *wp++ = cy_dig; - wp -= un; - up -= un; - } -} - -void -dump_abort (char *s, - mpz_t multiplier, mpz_t multiplicand, mpz_t product, mpz_t ref_product) -{ - fprintf (stderr, "ERROR: %s\n", s); - fprintf (stderr, "multiplier = "); debug_mp (multiplier, -16); - fprintf (stderr, "multiplicand = "); debug_mp (multiplicand, -16); - fprintf (stderr, " product = "); debug_mp (product, -16); - fprintf (stderr, "ref_product = "); debug_mp (ref_product, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-pow_ui.c b/mpz/tests/t-pow_ui.c deleted file mode 100644 index 00f45d065..000000000 --- a/mpz/tests/t-pow_ui.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Test mpz_pow_ui and mpz_ui_pow_ui. - -Copyright 1997, 1999, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void debug_mp _PROTO ((char *, mpz_t, int)); -void ref_mpz_pow_ui _PROTO ((mpz_t, const mpz_t, unsigned long int)); - -main (int argc, char **argv) -{ - mpz_t base, exp; - mpz_t result, ref_result; - mp_size_t base_size; - unsigned long int exp2; - int i; - int reps = 500; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (base); - mpz_init (exp); - mpz_init (result); - mpz_init (ref_result); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 12 + 2; - - mpz_urandomb (bs, rands, size_range); - base_size = mpz_get_ui (bs); - mpz_rrandomb (base, rands, base_size); - - mpz_urandomb (exp, rands, 5L); - exp2 = mpz_getlimbn (exp, 0); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (base, base); - - /* printf ("%ld %lu\n", SIZ (base), exp2); */ - - ref_mpz_pow_ui (ref_result, base, exp2); - - mpz_pow_ui (result, base, exp2); - if (mpz_cmp (result, ref_result)) - { - fprintf (stderr, "ERROR (mpz_pow_ui):\n"); - debug_mp (" base = ", base, -16); - fprintf (stderr, " exp = %lu (0x%lX)\n", exp2, exp2); - debug_mp (" result = ", result, -16); - debug_mp ("ref_result = ", ref_result, -16); - abort (); - } - - if (mpz_cmp_ui (base, 0L) >= 0 - && mpz_cmp_ui (base, ~(unsigned long int) 0) <= 0) - { - mpz_ui_pow_ui (result, mpz_get_ui (base), exp2); - if (mpz_cmp (result, ref_result)) - { - fprintf (stderr, "ERROR (mpz_ui_pow_ui):\n"); - debug_mp (" base = ", base, -16); - fprintf (stderr, " exp = %lu (0x%lX)\n", exp2, exp2); - debug_mp (" result = ", result, -16); - debug_mp ("ref_result = ", ref_result, -16); - abort (); - } - } - } - - exit (0); -} - -void -ref_mpz_pow_ui (mpz_t w, const mpz_t u, unsigned long int e) -{ - mpz_t s, t; - unsigned long int i; - - mpz_init_set_ui (t, 1); - mpz_init_set (s, u); - - if ((e & 1) != 0) - mpz_mul (t, t, s); - - for (i = 2; i <= e; i <<= 1) - { - mpz_mul (s, s, s); - if ((i & e) != 0) - mpz_mul (t, t, s); - } - - mpz_set (w, t); - mpz_clear (s); - mpz_clear (t); -} - -void -debug_mp (char *str, mpz_t x, int base) -{ - fprintf (stderr, "%s", str); - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-powm.c b/mpz/tests/t-powm.c deleted file mode 100644 index a218b3233..000000000 --- a/mpz/tests/t-powm.c +++ /dev/null @@ -1,156 +0,0 @@ -/* Test mpz_powm, mpz_mul. mpz_mod, mpz_mod_ui, mpz_div_ui. - -Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mpz_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t base, exp, mod; - mpz_t r1, r2, t1, exp2, base2; - mp_size_t base_size, exp_size, mod_size; - int i; - int reps = 200; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (base); - mpz_init (exp); - mpz_init (mod); - mpz_init (r1); - mpz_init (r2); - mpz_init (t1); - mpz_init (exp2); - mpz_init (base2); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 13 + 2; - - do /* Loop until mathematically well-defined. */ - { - mpz_urandomb (bs, rands, size_range); - base_size = mpz_get_ui (bs); - mpz_rrandomb (base, rands, base_size); - - mpz_urandomb (bs, rands, 7L); - exp_size = mpz_get_ui (bs); - mpz_rrandomb (exp, rands, exp_size); - } - while (mpz_cmp_ui (base, 0) == 0 && mpz_cmp_ui (exp, 0) == 0); - - do - { - mpz_urandomb (bs, rands, size_range); - mod_size = mpz_get_ui (bs); - mpz_rrandomb (mod, rands, mod_size); - } - while (mpz_cmp_ui (mod, 0) == 0); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (base, base); - - /* printf ("%ld %ld %ld\n", SIZ (base), SIZ (exp), SIZ (mod)); */ - -#if 0 - putc ('\n', stderr); - debug_mp (base, -16); - debug_mp (exp, -16); - debug_mp (mod, -16); -#endif - - mpz_powm (r1, base, exp, mod); - - mpz_set_ui (r2, 1); - mpz_set (base2, base); - mpz_set (exp2, exp); - - mpz_mod (r2, r2, mod); /* needed when exp==0 and mod==1 */ - while (mpz_cmp_ui (exp2, 0) != 0) - { - mpz_mod_ui (t1, exp2, 2); - if (mpz_cmp_ui (t1, 0) != 0) - { - mpz_mul (r2, r2, base2); - mpz_mod (r2, r2, mod); - } - mpz_mul (base2, base2, base2); - mpz_mod (base2, base2, mod); - mpz_div_ui (exp2, exp2, 2); - } - -#if 0 - debug_mp (r1, -16); - debug_mp (r2, -16); -#endif - - if (mpz_cmp (r1, r2) != 0) - abort (); - } - - exit (0); -} - -void -dump_abort (mpz_t dividend, mpz_t divisor) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-powm_ui.c b/mpz/tests/t-powm_ui.c deleted file mode 100644 index d3bc7b172..000000000 --- a/mpz/tests/t-powm_ui.c +++ /dev/null @@ -1,152 +0,0 @@ -/* Test mpz_powm_ui, mpz_mul. mpz_mod, mpz_mod_ui, mpz_div_ui. - -Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mpz_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t base, exp, mod; - mpz_t r1, r2, base2; - mp_size_t base_size, exp_size, mod_size; - unsigned long int exp2; - int i; - int reps = 400; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (base); - mpz_init (exp); - mpz_init (mod); - mpz_init (r1); - mpz_init (r2); - mpz_init (base2); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 13 + 2; - - do /* Loop until mathematically well-defined. */ - { - mpz_urandomb (bs, rands, size_range); - base_size = mpz_get_ui (bs); - mpz_rrandomb (base, rands, base_size); - - mpz_urandomb (bs, rands, 6L); - exp_size = mpz_get_ui (bs); - mpz_rrandomb (exp, rands, exp_size); - exp2 = mpz_getlimbn (exp, 0); - } - while (mpz_cmp_ui (base, 0) == 0 && exp2 == 0); - - do - { - mpz_urandomb (bs, rands, size_range); - mod_size = mpz_get_ui (bs); - mpz_rrandomb (mod, rands, mod_size); - } - while (mpz_cmp_ui (mod, 0) == 0); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (base, base); - - /* printf ("%ld %ld\n", SIZ (base), SIZ (mod)); */ - -#if 0 - putc ('\n', stderr); - debug_mp (base, -16); - debug_mp (mod, -16); -#endif - - mpz_powm_ui (r1, base, exp2, mod); - - mpz_set_ui (r2, 1); - mpz_set (base2, base); - - mpz_mod (r2, r2, mod); /* needed when exp==0 and mod==1 */ - while (exp2 != 0) - { - if (exp2 % 2 != 0) - { - mpz_mul (r2, r2, base2); - mpz_mod (r2, r2, mod); - } - mpz_mul (base2, base2, base2); - mpz_mod (base2, base2, mod); - exp2 = exp2 / 2; - } - -#if 0 - debug_mp (r1, -16); - debug_mp (r2, -16); -#endif - - if (mpz_cmp (r1, r2) != 0) - abort (); - } - - exit (0); -} - -void -dump_abort (mpz_t dividend, mpz_t divisor) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-root.c b/mpz/tests/t-root.c deleted file mode 100644 index 06b8deb20..000000000 --- a/mpz/tests/t-root.c +++ /dev/null @@ -1,139 +0,0 @@ -/* Test mpz_add, mpz_add_ui, mpz_cmp, mpz_cmp, mpz_mul, mpz_sqrtrem. - -Copyright 1991, 1993, 1994, 1996, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t x2; - mpz_t x; - mpz_t temp, temp2; - mp_size_t x2_size; - int i; - int reps = 5000; - unsigned long nth; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (x2); - mpz_init (x); - mpz_init (temp); - mpz_init (temp2); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 12 + 2; - - mpz_urandomb (bs, rands, size_range); - x2_size = mpz_get_ui (bs) + 10; - mpz_rrandomb (x2, rands, x2_size); - - mpz_urandomb (bs, rands, 5L); - nth = mpz_getlimbn (bs, 0) % mpz_sizeinbase (x2, 2) + 1; - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - { - /* With 50% probability, set x2 just below a perfect power. */ - mpz_root (x, x2, nth); - mpz_pow_ui (x2, x, nth); - if (mpz_sgn (x2) != 0) - mpz_sub_ui (x2, x2, 1L); - } - - /* printf ("%ld %lu\n", SIZ (x2), nth); */ - - mpz_root (x, x2, nth); - mpz_pow_ui (temp, x, nth); - - /* Is power of result > argument? */ - if (mpz_cmp (temp, x2) > 0) - { - fprintf (stderr, "ERROR after test %d\n", i); - debug_mp (x2, 10); - debug_mp (x, 10); - fprintf (stderr, "nth: %lu\n", nth); - abort (); - } - - if (nth > 1 && mpz_cmp_ui (temp, 1L) > 0 && ! mpz_perfect_power_p (temp)) - { - fprintf (stderr, "ERROR in mpz_perfect_power_p after test %d\n", i); - debug_mp (temp, 10); - debug_mp (x, 10); - fprintf (stderr, "nth: %lu\n", nth); - abort (); - } - - if (nth > 10000) - continue; /* skip too expensive test */ - - mpz_add_ui (temp2, x, 1L); - mpz_pow_ui (temp2, temp2, nth); - - /* Is square of (result + 1) <= argument? */ - if (mpz_cmp (temp2, x2) <= 0) - { - fprintf (stderr, "ERROR after test %d\n", i); - debug_mp (x2, 10); - debug_mp (x, 10); - fprintf (stderr, "nth: %lu\n", nth); - abort (); - } - } - - exit (0); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-scan.c b/mpz/tests/t-scan.c deleted file mode 100644 index ecd22adbe..000000000 --- a/mpz/tests/t-scan.c +++ /dev/null @@ -1,136 +0,0 @@ -/* Tests of mpz_scan0 and mpz_scan1. - -Copyright 2000, 2001 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 "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - - -/* Twos complement, return borrow. Same as mpn_sub_n(dst,zeros,src,size) - where zero contains size many 0 limbs. */ - -mp_limb_t -mpn_neg (mp_ptr dst, mp_srcptr src, mp_size_t size) -{ - mpn_com_n (dst, src, size); - return mpn_add_1 (dst, dst, size, 1) ^ 1; -} - -void -mpz_set_n (mpz_ptr z, mp_srcptr p, mp_size_t size) -{ - ASSERT (size >= 0); - MPN_NORMALIZE (p, size); - MPZ_REALLOC (z, size); - MPN_COPY (PTR(z), p, size); - SIZ(z) = size; -} - - -unsigned long -refmpz_scan (mpz_srcptr z, unsigned long i, int sought) -{ - unsigned long z_bits = (unsigned long) ABSIZ(z) * BITS_PER_MP_LIMB; - - do - { - if (mpz_tstbit (z, i) == sought) - return i; - i++; - } - while (i <= z_bits); - - return ULONG_MAX; -} - -unsigned long -refmpz_scan0 (mpz_srcptr z, unsigned long starting_bit) -{ - return refmpz_scan (z, starting_bit, 0); -} - -unsigned long -refmpz_scan1 (mpz_srcptr z, unsigned long starting_bit) -{ - return refmpz_scan (z, starting_bit, 1); -} - - -void -check_ref (void) -{ - mpz_t z; - int test, size, neg, sought; - unsigned long i, got, want; - - mpz_init (z); - for (test = 0; test < 10; test++) - { - for (size = 0; size < 5; size++) - { - mpz_random2 (z, size); - - for (neg = 0; neg <= 1; neg++) - { - if (neg) - mpz_neg (z, z); - - for (i = 0; i < size*BITS_PER_MP_LIMB + 8; i++) - { - for (sought = 0; sought <= 1; sought++) - { - if (sought == 0) - { - got = mpz_scan0 (z, i); - want = refmpz_scan0 (z, i); - } - else - { - got = mpz_scan1 (z, i); - want = refmpz_scan1 (z, i); - } - - if (got != want) - { - printf ("wrong at test=%d, size=%d, neg=%d, i=%lu, sought=%d\n", - test, size, neg, i, sought); - printf (" z 0x"); - mpz_out_str (stdout, -16, z); - printf ("\n"); - printf (" got=%lu, want=%lu\n", got, want); - exit (1); - } - } - } - } - } - } - mpz_clear (z); -} - - -int -main (int argc, char *argv[]) -{ - check_ref (); - exit (0); -} diff --git a/mpz/tests/t-sqrtrem.c b/mpz/tests/t-sqrtrem.c deleted file mode 100644 index 868ab7797..000000000 --- a/mpz/tests/t-sqrtrem.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Test mpz_add, mpz_add_ui, mpz_cmp, mpz_cmp, mpz_mul, mpz_sqrtrem. - -Copyright 1991, 1993, 1994, 1996, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mpz_t, mpz_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t x2; - mpz_t x, rem; - mpz_t temp, temp2; - mp_size_t x2_size; - int i; - int reps = 20000; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - gmp_randseed_ui (rands, atoi (argv[1])); - - mpz_init (x2); - mpz_init (x); - mpz_init (rem); - mpz_init (temp); - mpz_init (temp2); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 12 + 2; /* 0..8191 bit operands */ - - mpz_urandomb (bs, rands, size_range); - x2_size = mpz_get_ui (bs); - mpz_rrandomb (x2, rands, x2_size); - - /* printf ("%ld\n", SIZ (x2)); */ - - mpz_sqrtrem (x, rem, x2); - mpz_mul (temp, x, x); - - /* Is square of result > argument? */ - if (mpz_cmp (temp, x2) > 0) - dump_abort (x2, x, rem); - - mpz_add_ui (temp2, x, 1); - mpz_mul (temp2, temp2, temp2); - - /* Is square of (result + 1) <= argument? */ - if (mpz_cmp (temp2, x2) <= 0) - dump_abort (x2, x, rem); - - mpz_add (temp2, temp, rem); - - /* Is the remainder wrong? */ - if (mpz_cmp (x2, temp2) != 0) - dump_abort (x2, x, rem); - } - - exit (0); -} - -void -dump_abort (mpz_t x2, mpz_t x, mpz_t rem) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "x2 = "); debug_mp (x2, -16); - fprintf (stderr, "x = "); debug_mp (x, -16); - fprintf (stderr, "remainder = "); debug_mp (rem, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-tdiv.c b/mpz/tests/t-tdiv.c deleted file mode 100644 index 6c6e53841..000000000 --- a/mpz/tests/t-tdiv.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_tdiv_qr, mpz_tdiv_q, - mpz_tdiv_r, mpz_mul. - -Copyright 1991, 1993, 1994, 1996, 1997, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mpz_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t dividend, divisor; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size, divisor_size; - int i; - int reps = 200; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (divisor); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 16 + 2; /* 0..131071 bit operands */ - - do - { - mpz_urandomb (bs, rands, size_range); - divisor_size = mpz_get_ui (bs); - mpz_rrandomb (divisor, rands, divisor_size); - } - while (mpz_sgn (divisor) == 0); - - mpz_urandomb (bs, rands, size_range); - dividend_size = mpz_get_ui (bs) + divisor_size; - mpz_rrandomb (dividend, rands, dividend_size); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (dividend, dividend); - if ((bsi & 2) != 0) - mpz_neg (divisor, divisor); - - /* printf ("%ld %ld\n", SIZ (dividend), SIZ (divisor)); */ - - mpz_tdiv_qr (quotient, remainder, dividend, divisor); - mpz_tdiv_q (quotient2, dividend, divisor); - mpz_tdiv_r (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != ((mpz_cmp_ui (dividend, 0) ^ mpz_cmp_ui (divisor, 0)) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the dividend - (quotient rounded towards 0). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if ((mpz_cmp_ui (remainder, 0) < 0) != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - mpz_mul (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (temp, divisor); - mpz_abs (remainder, remainder); - if (mpz_cmp (remainder, temp) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -void -dump_abort (mpz_t dividend, mpz_t divisor) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/mpz/tests/t-tdiv_ui.c b/mpz/tests/t-tdiv_ui.c deleted file mode 100644 index 0a7a04b3e..000000000 --- a/mpz/tests/t-tdiv_ui.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_tdiv_qr_ui, mpz_tdiv_q_ui, - mpz_tdiv_r_ui, mpz_mul_ui. - -Copyright 1993, 1994, 1996, 2000, 2001 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 <stdlib.h> -#include <sys/time.h> - -#include "gmp.h" -#include "gmp-impl.h" - -void dump_abort _PROTO ((mpz_t, mp_limb_t)); -void debug_mp _PROTO ((mpz_t, int)); - -main (int argc, char **argv) -{ - mpz_t dividend; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size; - mp_limb_t divisor; - int i; - int reps = 10000; - gmp_randstate_t rands; - mpz_t bs; - unsigned long bsi, size_range; - char *perform_seed; - - gmp_randinit (rands, GMP_RAND_ALG_LC, 64); - - perform_seed = getenv ("GMP_CHECK_RANDOMIZE"); - if (perform_seed != 0) - { - struct timeval tv; - gettimeofday (&tv, NULL); - gmp_randseed_ui (rands, tv.tv_sec + tv.tv_usec); - printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n"); - printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n", - tv.tv_sec + tv.tv_usec); - } - - mpz_init (bs); - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - mpz_urandomb (bs, rands, 32); - size_range = mpz_get_ui (bs) % 10 + 2; /* 0..2047 bit operands */ - - do - { - mpz_rrandomb (bs, rands, 64); - divisor = mpz_get_ui (bs); - } - while (divisor == 0); - - mpz_urandomb (bs, rands, size_range); - dividend_size = mpz_get_ui (bs); - mpz_rrandomb (dividend, rands, dividend_size); - - mpz_urandomb (bs, rands, 2); - bsi = mpz_get_ui (bs); - if ((bsi & 1) != 0) - mpz_neg (dividend, dividend); - - /* printf ("%ld\n", SIZ (dividend)); */ - - mpz_tdiv_qr_ui (quotient, remainder, dividend, divisor); - mpz_tdiv_q_ui (quotient2, dividend, divisor); - mpz_tdiv_r_ui (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the dividend - (quotient rounded towards 0). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if ((mpz_cmp_ui (remainder, 0) < 0) != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - mpz_mul_ui (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (remainder, remainder); - if (mpz_cmp_ui (remainder, divisor) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -void -dump_abort (mpz_t dividend, mp_limb_t divisor) -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = %lX\n", divisor); - abort(); -} - -void -debug_mp (mpz_t x, int base) -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} |