summaryrefslogtreecommitdiff
path: root/gmp/doc
diff options
context:
space:
mode:
Diffstat (limited to 'gmp/doc')
-rw-r--r--gmp/doc/Makefile.am33
-rw-r--r--gmp/doc/Makefile.in441
-rw-r--r--gmp/doc/configuration90
-rw-r--r--gmp/doc/fdl-1.3.texi4
-rw-r--r--gmp/doc/gmp.info177
-rw-r--r--gmp/doc/gmp.info-12310
-rw-r--r--gmp/doc/gmp.info-21505
-rw-r--r--gmp/doc/gmp.texi1974
-rw-r--r--gmp/doc/isa_abi_headache25
-rwxr-xr-xgmp/doc/mdate-sh87
-rw-r--r--gmp/doc/projects.html258
-rw-r--r--gmp/doc/stamp-vti8
-rw-r--r--gmp/doc/tasks.html96
-rw-r--r--gmp/doc/texinfo.tex3042
-rw-r--r--gmp/doc/version.texi8
15 files changed, 4092 insertions, 5966 deletions
diff --git a/gmp/doc/Makefile.am b/gmp/doc/Makefile.am
index 083f25a630..2bc34ddbf9 100644
--- a/gmp/doc/Makefile.am
+++ b/gmp/doc/Makefile.am
@@ -3,31 +3,20 @@
# Copyright 2003 Free Software Foundation, Inc.
#
-# This file is part of the GNU MP Library.
+# 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 either:
+# 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 3 of the License, or (at your
+# option) any later version.
#
-# * the GNU Lesser General Public License as published by the Free
-# Software Foundation; either version 3 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.
#
-# or
-#
-# * the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any
-# later version.
-#
-# or both in parallel, as here.
-#
-# 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 General Public License
-# for more details.
-#
-# You should have received copies of the GNU General Public License and the
-# GNU Lesser General Public License along with the GNU MP Library. If not,
-# see https://www.gnu.org/licenses/.
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
EXTRA_DIST = configuration isa_abi_headache projects.html tasks.html
diff --git a/gmp/doc/Makefile.in b/gmp/doc/Makefile.in
index 1acf6029ef..3d9dadbc31 100644
--- a/gmp/doc/Makefile.in
+++ b/gmp/doc/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.8.4 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# 2003, 2004 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.
@@ -17,54 +16,29 @@
# Copyright 2003 Free Software Foundation, Inc.
#
-# This file is part of the GNU MP Library.
+# 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 either:
+# 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 3 of the License, or (at your
+# option) any later version.
#
-# * the GNU Lesser General Public License as published by the Free
-# Software Foundation; either version 3 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.
#
-# or
-#
-# * the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any
-# later version.
-#
-# or both in parallel, as here.
-#
-# 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 General Public License
-# for more details.
-#
-# You should have received copies of the GNU General Public License and the
-# GNU Lesser General Public License along with the GNU MP Library. If not,
-# see https://www.gnu.org/licenses/.
+# You should have received a copy of the GNU Lesser General Public License
+# along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
VPATH = @srcdir@
-am__make_dryrun = \
- { \
- am__dry=no; \
- case $$MAKEFLAGS in \
- *\\[\ \ ]*) \
- echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
- | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
- *) \
- for am__flg in $$MAKEFLAGS; do \
- case $$am__flg in \
- *=*|--*) ;; \
- *n*) am__dry=yes; break;; \
- esac; \
- done;; \
- esac; \
- test $$am__dry = yes; \
- }
pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
@@ -76,7 +50,6 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
-build_triplet = @build@
host_triplet = @host@
subdir = doc
DIST_COMMON = $(gmp_TEXINFOS) $(srcdir)/Makefile.am \
@@ -84,13 +57,12 @@ DIST_COMMON = $(gmp_TEXINFOS) $(srcdir)/Makefile.am \
$(srcdir)/version.texi mdate-sh texinfo.tex
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
+ $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
+mkinstalldirs = $(mkdir_p)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
depcomp =
am__depfiles_maybe =
SOURCES =
@@ -107,39 +79,7 @@ TEXI2PDF = $(TEXI2DVI) --pdf --batch
MAKEINFOHTML = $(MAKEINFO) --html
AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
DVIPS = dvips
-am__can_run_installinfo = \
- case $$AM_UPDATE_INFO_DIR in \
- n|no|NO) false;; \
- *) (install-info --version) >/dev/null 2>&1;; \
- esac
am__installdirs = "$(DESTDIR)$(infodir)"
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
- srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
- for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
- for p in $$list; do echo "$$p $$p"; done | \
- sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
- $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
- if (++n[$$2] == $(am__install_max)) \
- { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
- END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__uninstall_files_from_dir = { \
- test -z "$$files" \
- || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
- || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
- $(am__cd) "$$dir" && rm -f $$files; }; \
- }
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ABI = @ABI@
ACLOCAL = @ACLOCAL@
@@ -151,6 +91,7 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BITS_PER_MP_LIMB = @BITS_PER_MP_LIMB@
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
CC = @CC@
CCAS = @CCAS@
@@ -166,17 +107,16 @@ CYGPATH_W = @CYGPATH_W@
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
DEFS = @DEFS@
DLLTOOL = @DLLTOOL@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
+ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ENABLE_STATIC_FALSE = @ENABLE_STATIC_FALSE@
+ENABLE_STATIC_TRUE = @ENABLE_STATIC_TRUE@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
-FGREP = @FGREP@
GMP_LDFLAGS = @GMP_LDFLAGS@
-GMP_LIMB_BITS = @GMP_LIMB_BITS@
GMP_NAIL_BITS = @GMP_NAIL_BITS@
GREP = @GREP@
HAVE_CLOCK_01 = @HAVE_CLOCK_01@
@@ -190,12 +130,10 @@ HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@
HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@
HAVE_STACK_T_01 = @HAVE_STACK_T_01@
HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@
-INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-LD = @LD@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
@@ -210,26 +148,20 @@ LIBOBJS = @LIBOBJS@
LIBREADLINE = @LIBREADLINE@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
-LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
M4 = @M4@
MAINT = @MAINT@
+MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
+MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
-MANIFEST_TOOL = @MANIFEST_TOOL@
-MKDIR_P = @MKDIR_P@
-NM = @NM@
-NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
-OTOOL = @OTOOL@
-OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@@ -239,31 +171,26 @@ SHELL = @SHELL@
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
STRIP = @STRIP@
TAL_OBJECT = @TAL_OBJECT@
-TUNE_LIBS = @TUNE_LIBS@
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
+U = @U@
U_FOR_BUILD = @U_FOR_BUILD@
VERSION = @VERSION@
+WANT_CXX_FALSE = @WANT_CXX_FALSE@
+WANT_CXX_TRUE = @WANT_CXX_TRUE@
+WANT_MPBSD_FALSE = @WANT_MPBSD_FALSE@
+WANT_MPBSD_TRUE = @WANT_MPBSD_TRUE@
WITH_READLINE_01 = @WITH_READLINE_01@
YACC = @YACC@
YFLAGS = @YFLAGS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
-ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__leading_dot = @am__leading_dot@
-am__tar = @am__tar@
-am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
-builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
@@ -287,6 +214,7 @@ mandir = @mandir@
mkdir_p = @mkdir_p@
mpn_objects = @mpn_objects@
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
+mpn_objs_in_libmp = @mpn_objs_in_libmp@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
@@ -294,12 +222,8 @@ program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
EXTRA_DIST = configuration isa_abi_headache projects.html tasks.html
info_TEXINFOS = gmp.texi
gmp_TEXINFOS = fdl-1.3.texi
@@ -311,14 +235,14 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps doc/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --gnu --ignore-deps doc/Makefile
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps doc/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu --ignore-deps doc/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -336,7 +260,6 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
@@ -344,27 +267,33 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
+distclean-libtool:
+ -rm -f libtool
+
.texi.info:
- restore=: && backupdir="$(am__leading_dot)am$$$$" && \
- am__cwd=`pwd` && $(am__cd) $(srcdir) && \
+ restore=: && \
+ backupdir="$(am__leading_dot)am$$$$" && \
+ am__cwd=`pwd` && cd $(srcdir) && \
rm -rf $$backupdir && mkdir $$backupdir && \
- if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
- for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
- if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
- done; \
- else :; fi && \
+ for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
+ if test -f $$f; then \
+ mv $$f $$backupdir; \
+ restore=mv; \
+ fi; \
+ done; \
cd "$$am__cwd"; \
if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
-o $@ $<; \
then \
rc=0; \
- $(am__cd) $(srcdir); \
+ cd $(srcdir); \
else \
rc=$$?; \
- $(am__cd) $(srcdir) && \
+ cd $(srcdir) && \
$$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
fi; \
- rm -rf $$backupdir; exit $$rc
+ rm -rf $$backupdir; \
+ exit $$rc
.texi.dvi:
TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
@@ -377,18 +306,10 @@ clean-libtool:
$(TEXI2PDF) $<
.texi.html:
- rm -rf $(@:.html=.htp)
- if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
- -o $(@:.html=.htp) $<; \
- then \
- rm -rf $@; \
- if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
- mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \
- else \
- if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
- rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \
- exit 1; \
- fi
+ $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \
+ -o $@ $<
+ if test ! -d $@ && test -d $(@:.html=); then \
+ mv $(@:.html=) $@; else :; fi
$(srcdir)/gmp.info: gmp.texi $(srcdir)/version.texi $(gmp_TEXINFOS)
gmp.dvi: gmp.texi $(srcdir)/version.texi $(gmp_TEXINFOS)
gmp.pdf: gmp.texi $(srcdir)/version.texi $(gmp_TEXINFOS)
@@ -413,36 +334,17 @@ mostlyclean-vti:
maintainer-clean-vti:
@MAINTAINER_MODE_TRUE@ -rm -f $(srcdir)/stamp-vti $(srcdir)/version.texi
.dvi.ps:
- TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
$(DVIPS) -o $@ $<
-uninstall-dvi-am:
- @$(NORMAL_UNINSTALL)
- @list='$(DVIS)'; test -n "$(dvidir)" || list=; \
- for p in $$list; do \
- $(am__strip_dir) \
- echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
- rm -f "$(DESTDIR)$(dvidir)/$$f"; \
- done
-
-uninstall-html-am:
- @$(NORMAL_UNINSTALL)
- @list='$(HTMLS)'; test -n "$(htmldir)" || list=; \
- for p in $$list; do \
- $(am__strip_dir) \
- echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \
- rm -rf "$(DESTDIR)$(htmldir)/$$f"; \
- done
-
uninstall-info-am:
- @$(PRE_UNINSTALL)
- @if test -d '$(DESTDIR)$(infodir)' && $(am__can_run_installinfo); then \
+ $(PRE_UNINSTALL)
+ @if (install-info --version && \
+ install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \
- if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
- then :; else test ! -f "$(DESTDIR)$(infodir)/$$relfile" || exit 1; fi; \
+ install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
done; \
else :; fi
@$(NORMAL_UNINSTALL)
@@ -450,30 +352,12 @@ uninstall-info-am:
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
- (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \
- echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \
+ (if cd "$(DESTDIR)$(infodir)"; then \
+ echo " rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9])"; \
rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
else :; fi); \
done
-uninstall-pdf-am:
- @$(NORMAL_UNINSTALL)
- @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \
- for p in $$list; do \
- $(am__strip_dir) \
- echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \
- rm -f "$(DESTDIR)$(pdfdir)/$$f"; \
- done
-
-uninstall-ps-am:
- @$(NORMAL_UNINSTALL)
- @list='$(PSS)'; test -n "$(psdir)" || list=; \
- for p in $$list; do \
- $(am__strip_dir) \
- echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \
- rm -f "$(DESTDIR)$(psdir)/$$f"; \
- done
-
dist-info: $(INFO_DEPS)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
list='$(INFO_DEPS)'; \
@@ -482,23 +366,17 @@ dist-info: $(INFO_DEPS)
$(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
esac; \
if test -f $$base; then d=.; else d=$(srcdir); fi; \
- base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \
- for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \
- if test -f $$file; then \
- relfile=`expr "$$file" : "$$d/\(.*\)"`; \
- test -f "$(distdir)/$$relfile" || \
- cp -p $$file "$(distdir)/$$relfile"; \
- else :; fi; \
+ for file in $$d/$$base*; do \
+ relfile=`expr "$$file" : "$$d/\(.*\)"`; \
+ test -f $(distdir)/$$relfile || \
+ cp -p $$file $(distdir)/$$relfile; \
done; \
done
mostlyclean-aminfo:
-rm -rf gmp.aux gmp.cp gmp.cps gmp.fn gmp.fns gmp.ky gmp.kys gmp.log gmp.pg \
- gmp.pgs gmp.tmp gmp.toc gmp.tp gmp.vr gmp.vrs
-
-clean-aminfo:
- -test -z "gmp.dvi gmp.pdf gmp.ps gmp.html" \
- || rm -rf gmp.dvi gmp.pdf gmp.ps gmp.html
+ gmp.pgs gmp.tmp gmp.toc gmp.tp gmp.vr gmp.vrs gmp.dvi \
+ gmp.pdf gmp.ps gmp.html
maintainer-clean-aminfo:
@list='$(INFO_DEPS)'; for i in $$list; do \
@@ -514,32 +392,29 @@ CTAGS:
distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
@@ -551,7 +426,7 @@ check: check-am
all-am: Makefile $(INFO_DEPS)
installdirs:
for dir in "$(DESTDIR)$(infodir)"; do \
- test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
@@ -563,33 +438,27 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
- if test -z '$(STRIP)'; then \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- install; \
- else \
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
- fi
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-aminfo clean-generic clean-libtool mostlyclean-am
+clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
-distclean-am: clean-am distclean-generic
+distclean-am: clean-am distclean-generic distclean-libtool
dvi: dvi-am
@@ -605,62 +474,15 @@ info-am: $(INFO_DEPS)
install-data-am: install-info-am
-install-dvi: install-dvi-am
-
-install-dvi-am: $(DVIS)
- @$(NORMAL_INSTALL)
- @list='$(DVIS)'; test -n "$(dvidir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \
- done
install-exec-am:
-install-html: install-html-am
-
-install-html-am: $(HTMLS)
- @$(NORMAL_INSTALL)
- @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \
- $(am__strip_dir) \
- d2=$$d$$p; \
- if test -d "$$d2"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \
- $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
- echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \
- $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \
- else \
- list2="$$list2 $$d2"; \
- fi; \
- done; \
- test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \
- done; }
install-info: install-info-am
install-info-am: $(INFO_DEPS)
@$(NORMAL_INSTALL)
+ test -z "$(infodir)" || $(mkdir_p) "$(DESTDIR)$(infodir)"
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
- list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \
- fi; \
+ list='$(INFO_DEPS)'; \
for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
@@ -668,18 +490,18 @@ install-info-am: $(INFO_DEPS)
if test -f $$file; then d=.; else d=$(srcdir); fi; \
file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
- $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
+ $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
if test -f $$ifile; then \
- echo "$$ifile"; \
+ relfile=`echo "$$ifile" | sed 's|^.*/||'`; \
+ echo " $(INSTALL_DATA) '$$ifile' '$(DESTDIR)$(infodir)/$$relfile'"; \
+ $(INSTALL_DATA) "$$ifile" "$(DESTDIR)$(infodir)/$$relfile"; \
else : ; fi; \
done; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done
+ done
@$(POST_INSTALL)
- @if $(am__can_run_installinfo); then \
- list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \
+ @if (install-info --version && \
+ install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \
+ list='$(INFO_DEPS)'; \
for file in $$list; do \
relfile=`echo "$$file" | sed 's|^.*/||'`; \
echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
@@ -688,38 +510,6 @@ install-info-am: $(INFO_DEPS)
else : ; fi
install-man:
-install-pdf: install-pdf-am
-
-install-pdf-am: $(PDFS)
- @$(NORMAL_INSTALL)
- @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(pdfdir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(pdfdir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)" || exit $$?; done
-install-ps: install-ps-am
-
-install-ps-am: $(PSS)
- @$(NORMAL_INSTALL)
- @list='$(PSS)'; test -n "$(psdir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(psdir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(psdir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)" || exit $$?; done
installcheck-am:
maintainer-clean: maintainer-clean-am
@@ -740,26 +530,19 @@ ps: ps-am
ps-am: $(PSS)
-uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
- uninstall-pdf-am uninstall-ps-am
-
-.MAKE: install-am install-strip
+uninstall-am: uninstall-info-am
-.PHONY: all all-am check check-am clean clean-aminfo clean-generic \
- clean-libtool dist-info distclean distclean-generic \
- distclean-libtool distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ dist-info distclean distclean-generic distclean-libtool \
+ distdir dvi dvi-am html html-am info info-am install \
+ install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-aminfo \
maintainer-clean-generic maintainer-clean-vti mostlyclean \
mostlyclean-aminfo mostlyclean-generic mostlyclean-libtool \
mostlyclean-vti pdf pdf-am ps ps-am uninstall uninstall-am \
- uninstall-dvi-am uninstall-html-am uninstall-info-am \
- uninstall-pdf-am uninstall-ps-am
-
+ uninstall-info-am
# 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.
diff --git a/gmp/doc/configuration b/gmp/doc/configuration
index b6903866b2..fbd3b960d2 100644
--- a/gmp/doc/configuration
+++ b/gmp/doc/configuration
@@ -1,32 +1,21 @@
/* doc/configuration (in Emacs -*-outline-*- format). */
-Copyright 2000-2004 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004 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 either:
-
- * the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
-or
-
- * the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any
- later version.
-
-or both in parallel, as here.
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 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 General Public License
-for more details.
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
-You should have received copies of the GNU General Public License and the
-GNU Lesser General Public License along with the GNU MP Library. If not,
-see https://www.gnu.org/licenses/.
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
@@ -57,7 +46,7 @@ The same applies to mpf, mpq, scanf and printf.
The way we build libmpn (in the `mpn' subdirectory) is quite special.
-Currently only mpn/mp_bases.c is truly generic and included in every
+Currently only mpn/mp_bases.c is truely generic and included in every
configuration. All other files are linked at build time into the mpn
build directory from one of the CPU specific sub-directories, or from
the mpn/generic directory.
@@ -132,9 +121,14 @@ To add a completely new mpn function file, do the following,
iii) If HAVE_NATIVE_func is going to be used, then add a #undef to
the AH_VERBATIM([HAVE_NATIVE] block in configure.in.
- iv) If the function can be provided by a multi-function file, then
- add to the "case" statement in configure.in which lists each
- multi-function filename and what function files it can provide.
+ iv) Add file.c to nodist_libdummy_la_SOURCES in mpn/Makefile.am (in
+ order to get an ansi2knr rule). If the file is only in
+ assembler then this step is unnecessary, but do it anyway so as
+ not to forget if later a .c version is added.
+
+ v) If the function can be provided by a multi-function file, then
+ add to the "case" statement in configure.in which lists each
+ multi-function filename and what function files it can provide.
** Adding a test program
@@ -166,6 +160,18 @@ purposes and are not for use in "make check". These should be listed
in EXTRA_PROGRAMS to get Makefile rules created, but they're never
built or run unless an explicit "make someprog" is used.
+** Macos directory
+
+The macos/configure script will automatically pick up additions to
+gmp_mpn_functions, MPZ_OBJECTS, etc, but currently test programs need
+to be added to Makefile.in manually.
+
+When modifying the top-level configure.in ensure that it doesn't upset
+the macos/configure script heuristics.
+
+Unfortunately there's no way to test this stuff without getting an
+actual MacOS 9 system.
+
* Adding a new CPU
@@ -251,6 +257,10 @@ INSTALL.autoconf can be copied from INSTALL in autoconf.
ltmain.sh comes from libtool. Remove it and run "libtoolize --copy",
or just copy the file by hand.
+ansi2knr.c, ansi2knr.1, install-sh and doc/mdate-sh come from automake
+and can be updated by copying or by removing and running "automake
+--add-missing --copy".
+
texinfo.tex can be updated from ftp.gnu.org. Check it still works
with "make gmp.dvi", "make gmp.ps" and "make gmp.pdf".
@@ -334,6 +344,10 @@ errors rather than mysterious failures from a mismatch.
--disable-shared will make builds go much faster, though of course
shared or shared+static should be tested too.
+--enable-mpbsd grabs various bits of mpz, which might need to be
+adjusted if things in those routines are changed. Building mpbsd all
+the time doesn't cost much.
+
--prefix to a dummy directory followed by "make install" will show
what's installed.
@@ -365,6 +379,30 @@ they're the same size, which is unfortunate because casts should be
used in such cases, for the benefit of K&R compilers with int!=long
and where the difference matters in function calls.
+** K&R support
+
+Function definitions must be in the GNU stylized form to work. See
+the ansi2knr.1 man page (included in the GMP sources).
+
+__GMP_PROTO is used for function prototypes, other ANSI / K&R
+differences are conditionalized in various places.
+
+Proper testing of the K&R support requires a compiler which gives an
+error for ANSI-isms. Configuring with --host=none is a good idea, to
+test all the generic C code.
+
+When using an ANSI compiler, the ansi2knr setups can be partially
+tested with
+
+ ./configure am_cv_prog_cc_stdc=no ac_cv_prog_cc_stdc=no
+
+This will test the use of $U and the like in the makefiles, but not
+much else.
+
+Forcing the cache variables can be used with a compiler like HP C
+which is K&R by default but to which configure normally adds ANSI mode
+flags. This then should be a good full K&R test.
+
* Other Notes
** Compatibility
@@ -377,6 +415,12 @@ struct __mpz_struct etc - this must be retained for C++ compatibility.
will get this in the mangled name because C++ "sees though" the
typedef mpz_t to the underlying struct.
+ Incidentally, this probably means for C++ that our mp.h is not
+ compatible with an original BSD mp.h, since we use struct
+ __mpz_struct for MINT in ours. Maybe we could change to whatever
+ the original did, but it seems unlikely anyone would be using C++
+ with mp.h.
+
__gmpn - note that glibc defines some __mpn symbols, old versions of
some mpn routines, which it uses for floating point printfs.
diff --git a/gmp/doc/fdl-1.3.texi b/gmp/doc/fdl-1.3.texi
index 05804eecbb..8805f1a47d 100644
--- a/gmp/doc/fdl-1.3.texi
+++ b/gmp/doc/fdl-1.3.texi
@@ -5,7 +5,7 @@
@c hence no sectioning command or @node.
@display
-Copyright @copyright{} 2000-2002, 2007, 2008 Free Software Foundation, Inc.
+Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
@uref{http://fsf.org/}
Everyone is permitted to copy and distribute verbatim copies
@@ -414,7 +414,7 @@ The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
-@uref{https://www.gnu.org/copyleft/}.
+@uref{http://www.gnu.org/copyleft/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
diff --git a/gmp/doc/gmp.info b/gmp/doc/gmp.info
new file mode 100644
index 0000000000..79a544546f
--- /dev/null
+++ b/gmp/doc/gmp.info
@@ -0,0 +1,177 @@
+This is ../../gmp/doc/gmp.info, produced by makeinfo version 4.8 from
+../../gmp/doc/gmp.texi.
+
+ This manual describes how to install and use the GNU multiple
+precision arithmetic library, version 4.3.2.
+
+ Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+Foundation, Inc.
+
+ Permission is granted to copy, distribute and/or modify this
+document under the terms of the GNU Free Documentation License, Version
+1.3 or any later version published by the Free Software Foundation;
+with no Invariant Sections, with the Front-Cover Texts being "A GNU
+Manual", and with the Back-Cover Texts being "You have freedom to copy
+and modify this GNU Manual, like GNU software". A copy of the license
+is included in *Note GNU Free Documentation License::.
+
+INFO-DIR-SECTION GNU libraries
+START-INFO-DIR-ENTRY
+* gmp: (gmp). GNU Multiple Precision Arithmetic Library.
+END-INFO-DIR-ENTRY
+
+
+Indirect:
+gmp.info-1: 975
+gmp.info-2: 299474
+
+Tag Table:
+(Indirect)
+Node: Top975
+Node: Copying3199
+Node: Introduction to GMP5050
+Node: Installing GMP7761
+Node: Build Options8493
+Node: ABI and ISA24561
+Node: Notes for Package Builds34239
+Node: Notes for Particular Systems37326
+Node: Known Build Problems44085
+Node: Performance optimization47619
+Node: GMP Basics48753
+Node: Headers and Libraries49401
+Node: Nomenclature and Types50825
+Node: Function Classes52533
+Node: Variable Conventions54226
+Node: Parameter Conventions55835
+Node: Memory Management57891
+Node: Reentrancy59019
+Node: Useful Macros and Constants60892
+Node: Compatibility with older versions61890
+Node: Demonstration Programs62851
+Node: Efficiency64716
+Node: Debugging72340
+Node: Profiling78898
+Node: Autoconf82889
+Node: Emacs84668
+Node: Reporting Bugs85274
+Node: Integer Functions87817
+Node: Initializing Integers88593
+Node: Assigning Integers90478
+Node: Simultaneous Integer Init & Assign92065
+Node: Converting Integers93690
+Node: Integer Arithmetic96612
+Node: Integer Division98214
+Node: Integer Exponentiation104642
+Node: Integer Roots105503
+Node: Number Theoretic Functions107177
+Node: Integer Comparisons113336
+Node: Integer Logic and Bit Fiddling114714
+Node: I/O of Integers117337
+Node: Integer Random Numbers120221
+Node: Integer Import and Export122844
+Node: Miscellaneous Integer Functions126854
+Node: Integer Special Functions128714
+Node: Rational Number Functions131801
+Node: Initializing Rationals132994
+Node: Rational Conversions135187
+Node: Rational Arithmetic136918
+Node: Comparing Rationals138254
+Node: Applying Integer Functions139621
+Node: I/O of Rationals141104
+Node: Floating-point Functions142964
+Node: Initializing Floats145849
+Node: Assigning Floats149546
+Node: Simultaneous Float Init & Assign152113
+Node: Converting Floats153641
+Node: Float Arithmetic156889
+Node: Float Comparison158934
+Node: I/O of Floats160521
+Node: Miscellaneous Float Functions163119
+Node: Low-level Functions165019
+Node: Random Number Functions187301
+Node: Random State Initialization188369
+Node: Random State Seeding191231
+Node: Random State Miscellaneous192620
+Node: Formatted Output193261
+Node: Formatted Output Strings193506
+Node: Formatted Output Functions198720
+Node: C++ Formatted Output202795
+Node: Formatted Input205477
+Node: Formatted Input Strings205713
+Node: Formatted Input Functions210365
+Node: C++ Formatted Input213334
+Node: C++ Class Interface215237
+Node: C++ Interface General216238
+Node: C++ Interface Integers219308
+Node: C++ Interface Rationals222739
+Node: C++ Interface Floats226416
+Node: C++ Interface Random Numbers231708
+Node: C++ Interface Limitations234114
+Node: BSD Compatible Functions236934
+Node: Custom Allocation241645
+Node: Language Bindings245963
+Node: Algorithms249916
+Node: Multiplication Algorithms250616
+Node: Basecase Multiplication251594
+Node: Karatsuba Multiplication253502
+Node: Toom 3-Way Multiplication257130
+Node: Toom 4-Way Multiplication263544
+Node: FFT Multiplication264916
+Node: Other Multiplication270252
+Node: Unbalanced Multiplication272726
+Node: Division Algorithms273517
+Node: Single Limb Division273864
+Node: Basecase Division276755
+Node: Divide and Conquer Division277958
+Node: Exact Division280195
+Node: Exact Remainder283362
+Node: Small Quotient Division285654
+Node: Greatest Common Divisor Algorithms287252
+Node: Binary GCD287549
+Node: Lehmer's Algorithm290398
+Node: Subquadratic GCD292618
+Node: Extended GCD295077
+Node: Jacobi Symbol296389
+Node: Powering Algorithms297305
+Node: Normal Powering Algorithm297568
+Node: Modular Powering Algorithm298096
+Node: Root Extraction Algorithms299159
+Node: Square Root Algorithm299474
+Node: Nth Root Algorithm301615
+Node: Perfect Square Algorithm302400
+Node: Perfect Power Algorithm304486
+Node: Radix Conversion Algorithms305107
+Node: Binary to Radix305483
+Node: Radix to Binary309412
+Node: Other Algorithms311500
+Node: Prime Testing Algorithm311852
+Node: Factorial Algorithm313036
+Node: Binomial Coefficients Algorithm314439
+Node: Fibonacci Numbers Algorithm315333
+Node: Lucas Numbers Algorithm317807
+Node: Random Number Algorithms318528
+Node: Assembly Coding320649
+Node: Assembly Code Organisation321609
+Node: Assembly Basics322576
+Node: Assembly Carry Propagation323726
+Node: Assembly Cache Handling325557
+Node: Assembly Functional Units327718
+Node: Assembly Floating Point329331
+Node: Assembly SIMD Instructions333109
+Node: Assembly Software Pipelining334091
+Node: Assembly Loop Unrolling335153
+Node: Assembly Writing Guide337368
+Node: Internals340133
+Node: Integer Internals340645
+Node: Rational Internals342901
+Node: Float Internals344139
+Node: Raw Output Internals351553
+Node: C++ Interface Internals352747
+Node: Contributors356045
+Node: References360597
+Node: GNU Free Documentation License366255
+Node: Concept Index391424
+Node: Function Index437886
+
+End Tag Table
diff --git a/gmp/doc/gmp.info-1 b/gmp/doc/gmp.info-1
index 171d224635..01d137bacf 100644
--- a/gmp/doc/gmp.info-1
+++ b/gmp/doc/gmp.info-1
@@ -1,10 +1,12 @@
-This is ../../gmp/doc/gmp.info, produced by makeinfo version 4.13 from
+This is ../../gmp/doc/gmp.info, produced by makeinfo version 4.8 from
../../gmp/doc/gmp.texi.
-This manual describes how to install and use the GNU multiple precision
-arithmetic library, version 6.0.0.
+ This manual describes how to install and use the GNU multiple
+precision arithmetic library, version 4.3.2.
- Copyright 1991, 1993-2014 Free Software Foundation, Inc.
+ Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+Foundation, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version
@@ -12,7 +14,7 @@ document under the terms of the GNU Free Documentation License, Version
with no Invariant Sections, with the Front-Cover Texts being "A GNU
Manual", and with the Back-Cover Texts being "You have freedom to copy
and modify this GNU Manual, like GNU software". A copy of the license
-is included in *note GNU Free Documentation License::.
+is included in *Note GNU Free Documentation License::.
INFO-DIR-SECTION GNU libraries
START-INFO-DIR-ENTRY
@@ -26,9 +28,11 @@ GNU MP
******
This manual describes how to install and use the GNU multiple
-precision arithmetic library, version 6.0.0.
+precision arithmetic library, version 4.3.2.
- Copyright 1991, 1993-2014 Free Software Foundation, Inc.
+ Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+Foundation, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version
@@ -36,7 +40,7 @@ document under the terms of the GNU Free Documentation License, Version
with no Invariant Sections, with the Front-Cover Texts being "A GNU
Manual", and with the Back-Cover Texts being "You have freedom to copy
and modify this GNU Manual, like GNU software". A copy of the license
-is included in *note GNU Free Documentation License::.
+is included in *Note GNU Free Documentation License::.
* Menu:
@@ -54,6 +58,7 @@ is included in *note GNU Free Documentation License::.
* Formatted Output:: `printf' style output.
* Formatted Input:: `scanf' style input.
* C++ Class Interface:: Class wrappers around GMP types.
+* BSD Compatible Functions:: All functions found in BSD MP.
* Custom Allocation:: How to customize the internal allocation.
* Language Bindings:: Using GMP from other languages.
* Algorithms:: What happens behind the scenes.
@@ -96,20 +101,11 @@ modified by someone else and passed on, we want their recipients to
know that what they have is not what we distributed, so that any
problems introduced by others will not reflect on our reputation.
- More precisely, the GNU MP library is dual licensed, under the
-conditions of the GNU Lesser General Public License version 3 (see
-`COPYING.LESSERv3'), or the GNU General Public License version 2 (see
-`COPYINGv2'). This is the recipient's choice, and the recipient also has
-the additional option of applying later versions of these licenses. (The
-reason for this dual licensing is to make it possible to use the
-library with programs which are licensed under GPL version 2, but which
-for historical or other reasons do not allow use under later versions
-of the GPL).
-
- Programs which are not part of the library itself, such as
-demonstration programs and the GMP testsuite, are licensed under the
-terms of the GNU General Public License version 3 (see `COPYINGv3'), or
-any later version.
+ The precise conditions of the license for the GNU MP library are
+found in the Lesser General Public License version 3 that accompanies
+the source code, see `COPYING.LIB'. Certain demonstration programs are
+provided under the terms of the plain General Public License version 3,
+see `COPYING'.

File: gmp.info, Node: Introduction to GMP, Next: Installing GMP, Prev: Copying, Up: Top
@@ -135,42 +131,43 @@ carefully optimized assembly code for the most common inner loops for
many different CPUs, and by a general emphasis on speed (as opposed to
simplicity or elegance).
- There is assembly code for these CPUs: ARM Cortex-A9, Cortex-A15,
-and generic ARM, DEC Alpha 21064, 21164, and 21264, AMD K8 and K10
-(sold under many brands, e.g. Athlon64, Phenom, Opteron) Bulldozer, and
-Bobcat, Intel Pentium, Pentium Pro/II/III, Pentium 4, Core2, Nehalem,
-Sandy bridge, Haswell, generic x86, Intel IA-64, Motorola/IBM PowerPC
-32 and 64 such as POWER970, POWER5, POWER6, and POWER7, MIPS 32-bit and
-64-bit, SPARC 32-bit ad 64-bit with special support for all UltraSPARC
-models. There is also assembly code for many obsolete CPUs.
+ There is assembly code for these CPUs: ARM, DEC Alpha 21064, 21164,
+and 21264, AMD 29000, AMD K6, K6-2, Athlon, and Athlon64, Hitachi
+SuperH and SH-2, HPPA 1.0, 1.1 and 2.0, Intel Pentium, Pentium
+Pro/II/III, Pentium 4, generic x86, Intel IA-64, i960, Motorola
+MC68000, MC68020, MC88100, and MC88110, Motorola/IBM PowerPC 32 and 64,
+National NS32000, IBM POWER, MIPS R3000, R4000, SPARCv7, SuperSPARC,
+generic SPARCv8, UltraSPARC, DEC VAX, and Zilog Z8000. Some
+optimizations also for Cray vector systems, Clipper, IBM ROMP (RT), and
+Pyramid AP/XP.
For up-to-date information on GMP, please see the GMP web pages at
- `https://gmplib.org/'
+ `http://gmplib.org/'
The latest version of the library is available at
- `https://ftp.gnu.org/gnu/gmp/'
+ `ftp://ftp.gnu.org/gnu/gmp/'
Many sites around the world mirror `ftp.gnu.org', please use a mirror
-near you, see `https://www.gnu.org/order/ftp.html' for a full list.
+near you, see `http://www.gnu.org/order/ftp.html' for a full list.
There are three public mailing lists of interest. One for release
announcements, one for general questions and discussions about usage of
the GMP library and one for bug reports. For more information, see
- `https://gmplib.org/mailman/listinfo/'.
+ `http://gmplib.org/mailman/listinfo/'.
The proper place for bug reports is <gmp-bugs@gmplib.org>. See
-*note Reporting Bugs:: for information about reporting bugs.
+*Note Reporting Bugs:: for information about reporting bugs.
1.1 How to use this Manual
==========================
-Everyone should read *note GMP Basics::. If you need to install the
-library yourself, then read *note Installing GMP::. If you have a
-system with multiple ABIs, then read *note ABI and ISA::, for the
+Everyone should read *Note GMP Basics::. If you need to install the
+library yourself, then read *Note Installing GMP::. If you have a
+system with multiple ABIs, then read *Note ABI and ISA::, for the
compiler options that must be used on applications.
The rest of the manual can be used for later reference, although it
@@ -197,7 +194,7 @@ And you can install (under `/usr/local' by default) with
make install
If you experience problems, please report them to
-<gmp-bugs@gmplib.org>. See *note Reporting Bugs::, for information on
+<gmp-bugs@gmplib.org>. See *Note Reporting Bugs::, for information on
what to include in useful bug reports.
* Menu:
@@ -220,7 +217,7 @@ All the usual autoconf configure options are available, run `./configure
installation information too.
Tools
- `configure' requires various Unix-like tools. See *note Notes for
+ `configure' requires various Unix-like tools. See *Note Notes for
Particular Systems::, for some options on non-Unix systems.
It might be possible to build without the help of `configure',
@@ -233,7 +230,7 @@ Build Directory
directory. For example
cd /my/build/dir
- /my/sources/gmp-6.0.0/configure
+ /my/sources/gmp-4.3.2/configure
Not all `make' programs have the necessary features (`VPATH') to
support this. In particular, SunOS and Slowaris `make' have bugs
@@ -324,7 +321,7 @@ CPU types
The best idea is always to build GMP for the exact machine type
you intend to run it on.
- The following CPUs have specific support. See `configure.ac' for
+ The following CPUs have specific support. See `configure.in' for
details of what code and compiler options they select.
* Alpha: alpha, alphaev5, alphaev56, alphapca56, alphapca57,
@@ -356,14 +353,17 @@ CPU types
pentium2, pentium3, pentium4, k6, k62, k63, athlon, amd64,
viac3, viac32
- * Other: arm, sh, sh2, vax,
+ * Other: a29k, arm, clipper, i960, ns32k, pyramid, sh, sh2, vax,
+ z8k
CPUs not listed will use generic C code.
Generic C Build
If some of the assembly code causes problems, or if otherwise
- desired, the generic C code can be selected with the configure
- `--disable-assembly'.
+ desired, the generic C code can be selected with CPU `none'. For
+ example,
+
+ ./configure --host=none-unknown-freebsd3.5
Note that this will run quite slowly, but it should be portable
and should at least make it possible to get something running if
@@ -384,7 +384,7 @@ Fat binary, `--enable-fat'
./configure --host=mips64-sgi-irix6 ABI=n32
- See *note ABI and ISA::, for the available choices on relevant
+ See *Note ABI and ISA::, for the available choices on relevant
CPUs, and what applications need to do.
`CC', `CFLAGS'
@@ -419,7 +419,8 @@ Fat binary, `--enable-fat'
Compiling is done with both `CPPFLAGS' and `CFLAGS', but
preprocessing uses just `CPPFLAGS'. This distinction is because
most preprocessors won't accept all the flags the compiler does.
- Preprocessing is done separately in some configure tests.
+ Preprocessing is done separately in some configure tests, and in
+ the `ansi2knr' support for K&R compilers.
`CC_FOR_BUILD'
Some build-time programs are compiled and run to generate
@@ -523,9 +524,13 @@ Temporary Memory, `--enable-alloca=<choice>'
FFT Multiplication, `--disable-fft'
By default multiplications are done using Karatsuba, 3-way Toom,
- higher degree Toom, and Fermat FFT. The FFT is only used on large
- to very large operands and can be disabled to save code size if
- desired.
+ and Fermat FFT. The FFT is only used on large to very large
+ operands and can be disabled to save code size if desired.
+
+Berkeley MP, `--enable-mpbsd'
+ The Berkeley MP compatibility library (`libmp') and header file
+ (`mp.h') are built and installed only if `--enable-mpbsd' is used.
+ *Note BSD Compatible Functions::.
Assertion Checking, `--enable-assert'
This option enables some consistency checking within the library.
@@ -549,14 +554,14 @@ Execution Profiling, `--enable-profiling=prof/gprof/instrument'
Documentation
The source for the document you're now reading is `doc/gmp.texi',
- in Texinfo format, see *note Texinfo: (texinfo)Top.
+ in Texinfo format, see *Note Texinfo: (texinfo)Top.
Info format `doc/gmp.info' is included in the distribution. The
usual automake targets are available to make PostScript, DVI, PDF
and HTML (these will require various TeX and Texinfo tools).
DocBook and XML can be generated by the Texinfo `makeinfo' program
- too, see *note Options for `makeinfo': (texinfo)makeinfo options.
+ too, see *Note Options for `makeinfo': (texinfo)makeinfo options.
Some supplementary notes can also be found in the `doc'
subdirectory.
@@ -628,15 +633,6 @@ AMD64 (`x86_64')
(In GCC 2.95 and earlier there's no `-m32' option, it's the
only mode.)
- `ABI=x32'
- The x32 ABI uses 64-bit limbs but 32-bit pointers. Like the
- 64-bit ABI, it makes full use of the chip's arithmetic
- capabilities. This ABI is not supported by all operating
- systems.
-
- gcc -mx32
-
-
HPPA 2.0 (`hppa2.0*', `hppa64')
@@ -739,7 +735,7 @@ MIPS under IRIX 6 (`mips*-*-irix[6789]')
PowerPC 64 (`powerpc64', `powerpc620', `powerpc630', `powerpc970', `power4', `power5')
- `ABI=mode64'
+ `ABI=aix64'
The AIX 64 ABI uses 64-bit limbs and pointers and is the
default on PowerPC 64 `*-*-aix*' systems. Applications must
be compiled with
@@ -747,26 +743,28 @@ PowerPC 64 (`powerpc64', `powerpc620', `powerpc630', `powerpc970', `power4', `po
gcc -maix64
xlc -q64
- On 64-bit GNU/Linux, BSD, and Mac OS X/Darwin systems, the
- applications must be compiled with
+ `ABI=mode64'
+ The `mode64' ABI uses 64-bit limbs and pointers, and is the
+ default on 64-bit GNU/Linux, BSD, and Mac OS X/Darwin
+ systems. Applications must be compiled with
gcc -m64
`ABI=mode32'
The `mode32' ABI uses a 64-bit `long long' limb but with the
chip still in 32-bit mode and using 32-bit calling
- conventions. This is the default for systems where the true
- 64-bit ABI is unavailable. No special compiler options are
- typically needed for applications. This ABI is not available
- under AIX.
+ conventions. This is the default on for systems where the
+ true 64-bit ABIs are unavailable. No special compiler
+ options are needed for applications.
`ABI=32'
This is the basic 32-bit PowerPC ABI, with a 32-bit limb. No
special compiler options are needed for applications.
- GMP's speed is greatest for the `mode64' ABI, the `mode32' ABI is
- 2nd best. In `ABI=32' only the 32-bit ISA is used and this
- doesn't make full use of a 64-bit chip.
+ GMP speed is greatest in `aix64' and `mode32'. In `ABI=32' only
+ the 32-bit ISA is used and this doesn't make full use of a 64-bit
+ chip. On a suitable system we could perhaps use more of the ISA,
+ but there are no plans to do so.
Sparc V9 (`sparc64', `sparcv9', `ultrasparc*')
@@ -866,7 +864,7 @@ as making it possible for a user to omit `--build' (and `--host') so
`--build' will be wanted for systems where `./config.guess' is inexact.
On systems with multiple ABIs, a packaged build will need to decide
-which among the choices is to be provided, see *note ABI and ISA::. A
+which among the choices is to be provided, see *Note ABI and ISA::. A
given run of `./configure' etc will only build one ABI. If a second
ABI is also required then a second run of `./configure' etc must be
made, starting from a clean directory tree (`make distclean').
@@ -926,19 +924,10 @@ Floating Point Mode
in single precision mode. Of course this affects all code,
including application code, not just GMP.
-FreeBSD 7.x, 8.x, 9.0, 9.1, 9.2
- `m4' in these releases of FreeBSD has an eval function which
- ignores its 2nd and 3rd arguments, which makes it unsuitable for
- `.asm' file processing. `./configure' will detect the problem and
- either abort or choose another m4 in the `PATH'. The bug is fixed
- in FreeBSD 9.3 and 10.0, so either upgrade or use GNU m4. Note
- that the FreeBSD package system installs GNU m4 under the name
- `gm4', which GMP cannot guess.
-
-FreeBSD 7.x, 8.x, 9.x
- GMP releases starting with 6.0 do not support `ABI=32' on
- FreeBSD/amd64 prior to release 10.0 of the system. The cause is a
- broken `limits.h', which GMP no longer works around.
+MacOS 9
+ The `macos' directory contains an unsupported port to MacOS 9 on
+ Power Macintosh, see `macos/README'. Note that MacOS X "Darwin"
+ should use the normal Unix-style `./configure'.
MS-DOS and MS Windows
On an MS-DOS system DJGPP can be used to build GMP, and on an MS
@@ -983,15 +972,6 @@ Motorola 68k CPU Types
CPU32 series chips. `m68302' can be used for "Dragonball" series
chips, though this is merely a synonym for `m68000'.
-NetBSD 5.x
- `m4' in these releases of NetBSD has an eval function which
- ignores its 2nd and 3rd arguments, which makes it unsuitable for
- `.asm' file processing. `./configure' will detect the problem and
- either abort or choose another m4 in the `PATH'. The bug is fixed
- in NetBSD 6, so either upgrade or use GNU m4. Note that the
- NetBSD package system installs GNU m4 under the name `gm4', which
- GMP cannot guess.
-
OpenBSD 2.6
`m4' in this release of OpenBSD has a bug in `eval' that makes it
unsuitable for `.asm' file processing. `./configure' will detect
@@ -1004,11 +984,10 @@ Power CPU Types
choose the right one for the CPU that will be used. Currently GMP
has no assembly code support for using just the common instruction
subset. To get executables that run on both, the current
- suggestion is to use the generic C code (`--disable-assembly'),
- possibly with appropriate compiler options (like `-mcpu=common' for
- `gcc'). CPU `rs6000' (which is not a CPU but a family of
- workstations) is accepted by `config.sub', but is currently
- equivalent to `--disable-assembly'.
+ suggestion is to use the generic C code (CPU `none'), possibly
+ with appropriate compiler options (like `-mcpu=common' for `gcc').
+ CPU `rs6000' (which is not a CPU but a family of workstations) is
+ accepted by `config.sub', but is currently equivalent to `none'.
Sparc CPU Types
`sparcv8' or `supersparc' on relevant systems will give a
@@ -1025,7 +1004,7 @@ Sparc App Regs
`-mcmodel=embmedany' (which uses `g4' as a data segment pointer),
and for applications wanting to use those registers for special
purposes. In these cases the only suggestion currently is to
- build GMP with `--disable-assembly' to avoid the assembly code.
+ build GMP with CPU `none' to avoid the assembly code.
SunOS 4
`/usr/bin/m4' lacks various features needed to process `.asm'
@@ -1061,7 +1040,7 @@ File: gmp.info, Node: Known Build Problems, Next: Performance optimization, P
2.5 Known Build Problems
========================
-You might find more up-to-date information at `https://gmplib.org/'.
+You might find more up-to-date information at `http://gmplib.org/'.
Compiler link options
The version of libtool currently in use rather aggressively strips
@@ -1145,7 +1124,7 @@ File: gmp.info, Node: Performance optimization, Prev: Known Build Problems, U
============================
For optimal performance, build GMP for the exact CPU type of the target
-computer, see *note Build Options::.
+computer, see *Note Build Options::.
Unlike what is the case for most other programs, the compiler
typically doesn't matter much, since GMP uses assembly language for the
@@ -1161,7 +1140,7 @@ program in the `tune' subdirectory, can be important. For example,
will generate better contents for the `gmp-mparam.h' parameter file.
- To use the results, put the output in the file indicated in the
+ To use the results, put the output in the file file indicated in the
`Parameters for ...' header. Then recompile from scratch.
The `tuneup' program takes one useful parameter, `-f NNN', which
@@ -1214,10 +1193,10 @@ parameters are only provided if `<stdio.h>' is included too.
#include <stdio.h>
#include <gmp.h>
- Likewise `<stdarg.h>' is required for prototypes with `va_list'
-parameters, such as `gmp_vprintf'. And `<obstack.h>' for prototypes
-with `struct obstack' parameters, such as `gmp_obstack_printf', when
-available.
+ Likewise `<stdarg.h>' (or `<varargs.h>') is required for prototypes
+with `va_list' parameters, such as `gmp_vprintf'. And `<obstack.h>'
+for prototypes with `struct obstack' parameters, such as
+`gmp_obstack_printf', when available.
All programs using GMP must link against the `libgmp' library. On a
typical Unix-like system this can be done with `-lgmp', for example
@@ -1274,22 +1253,17 @@ body is analogous to a digit, only larger, and containing several
digits.) Normally a limb is 32 or 64 bits. The C data type for a limb
is `mp_limb_t'.
- Counts of limbs of a multi-precision number represented in the C type
-`mp_size_t'. Currently this is normally a `long', but on some systems
-it's an `int' for efficiency, and on some systems it will be `long
-long' in the future.
-
- Counts of bits of a multi-precision number are represented in the C
-type `mp_bitcnt_t'. Currently this is always an `unsigned long', but on
-some systems it will be an `unsigned long long' in the future.
+ Counts of limbs are represented in the C type `mp_size_t'. Currently
+this is normally a `long', but on some systems it's an `int' for
+efficiency.
"Random state" means an algorithm selection and current state data.
The C data type for such objects is `gmp_randstate_t'. For example:
gmp_randstate_t rstate;
- Also, in general `mp_bitcnt_t' is used for bit counts and ranges, and
-`size_t' is used for byte or character counts.
+ Also, in general `unsigned long' is used for bit counts and ranges,
+and `size_t' is used for byte or character counts.

File: gmp.info, Node: Function Classes, Next: Variable Conventions, Prev: Nomenclature and Types, Up: GMP Basics
@@ -1304,23 +1278,27 @@ There are six classes of functions in the GMP library:
functions in this class. (*note Integer Functions::)
2. Functions for rational number arithmetic, with names beginning with
- `mpq_'. The associated type is `mpq_t'. There are about 35
+ `mpq_'. The associated type is `mpq_t'. There are about 40
functions in this class, but the integer functions can be used for
arithmetic on the numerator and denominator separately. (*note
Rational Number Functions::)
3. Functions for floating-point arithmetic, with names beginning with
- `mpf_'. The associated type is `mpf_t'. There are about 70
+ `mpf_'. The associated type is `mpf_t'. There are about 60
functions is this class. (*note Floating-point Functions::)
- 4. Fast low-level functions that operate on natural numbers. These
+ 4. Functions compatible with Berkeley MP, such as `itom', `madd', and
+ `mult'. The associated type is `MINT'. (*note BSD Compatible
+ Functions::)
+
+ 5. Fast low-level functions that operate on natural numbers. These
are used by the functions in the preceding groups, and you can
also call them directly from very time-critical user programs.
These functions' names begin with `mpn_'. The associated type is
- array of `mp_limb_t'. There are about 60 (hard-to-use) functions
+ array of `mp_limb_t'. There are about 30 (hard-to-use) functions
in this class. (*note Low-level Functions::)
- 5. Miscellaneous functions. Functions for setting up custom
+ 6. Miscellaneous functions. Functions for setting up custom
allocation and functions for generating random numbers. (*note
Custom Allocation::, and *note Random Number Functions::)
@@ -1447,9 +1425,9 @@ of space, determined by the chosen precision and allocated at
initialization, so their size doesn't change.
All memory is allocated using `malloc' and friends by default, but
-this can be changed, see *note Custom Allocation::. Temporary memory
+this can be changed, see *Note Custom Allocation::. Temporary memory
on the stack is also used (via `alloca'), but this can be changed at
-build-time if desired, see *note Build Options::.
+build-time if desired, see *Note Build Options::.

File: gmp.info, Node: Reentrancy, Next: Useful Macros and Constants, Prev: Memory Management, Up: GMP Basics
@@ -1488,11 +1466,11 @@ GMP is reentrant and thread-safe, with some exceptions:
then the GMP I/O functions using them will not be reentrant either.
* It's safe for two threads to read from the same GMP variable
- simultaneously, but it's not safe for one to read while another
- might be writing, nor for two threads to write simultaneously.
- It's not safe for two threads to generate a random number from the
- same `gmp_randstate_t' simultaneously, since this involves an
- update of that variable.
+ simultaneously, but it's not safe for one to read while the
+ another might be writing, nor for two threads to write
+ simultaneously. It's not safe for two threads to generate a
+ random number from the same `gmp_randstate_t' simultaneously,
+ since this involves an update of that variable.

File: gmp.info, Node: Useful Macros and Constants, Next: Compatibility with older versions, Prev: Reentrancy, Up: GMP Basics
@@ -1513,8 +1491,8 @@ File: gmp.info, Node: Useful Macros and Constants, Next: Compatibility with ol
-- Global Constant: const char * const gmp_version
The GMP version number, as a null-terminated string, in the form
- "i.j.k". This release is "6.0.0". Note that the format "i.j" was
- used, before version 4.3.0, when k was zero.
+ "i.j.k". This release is "4.3.2". Note that the format "i.j" was
+ used when k was zero was used before version 4.3.0.
-- Macro: __GMP_CC
-- Macro: __GMP_CFLAGS
@@ -1527,9 +1505,9 @@ File: gmp.info, Node: Compatibility with older versions, Next: Demonstration P
3.9 Compatibility with older versions
=====================================
-This version of GMP is upwardly binary compatible with all 5.x, 4.x,
-and 3.x versions, and upwardly compatible at the source level with all
-2.x versions, with the following exceptions.
+This version of GMP is upwardly binary compatible with all 4.x and 3.x
+versions, and upwardly compatible at the source level with all 2.x
+versions, with the following exceptions.
* `mpn_gcd' had its source arguments swapped as of GMP 3.0, for
consistency with other `mpn' functions.
@@ -1537,12 +1515,12 @@ and 3.x versions, and upwardly compatible at the source level with all
* `mpf_get_prec' counted precision slightly differently in GMP 3.0
and 3.0.1, but in 3.1 reverted to the 2.x style.
- * `mpn_bdivmod', documented as preliminary in GMP 4, has been
- removed.
-
There are a number of compatibility issues between GMP 1 and GMP 2
that of course also apply when porting applications from GMP 1 to GMP
-5. Please see the GMP 2 manual for details.
+4. Please see the GMP 2 manual for details.
+
+ The Berkeley MP compatibility library (*note BSD Compatible
+Functions::) is source and binary compatible with the standard `libmp'.

File: gmp.info, Node: Demonstration Programs, Next: Efficiency, Prev: Compatibility with older versions, Up: GMP Basics
@@ -1765,7 +1743,7 @@ File: gmp.info, Node: Debugging, Next: Profiling, Prev: Efficiency, Up: GMP
Stack Overflow
Depending on the system, a segmentation violation or bus error
might be the only indication of stack overflow. See
- `--enable-alloca' choices in *note Build Options::, for how to
+ `--enable-alloca' choices in *Note Build Options::, for how to
address this.
In new enough versions of GCC, `-fstack-check' may be able to
@@ -1788,7 +1766,7 @@ Heap Problems
In all such cases a `malloc' debugger is recommended. On a GNU or
BSD system the standard C library `malloc' has some diagnostic
- facilities, see *note Allocation Debugging: (libc)Allocation
+ facilities, see *Note Allocation Debugging: (libc)Allocation
Debugging, or `man 3 malloc'. Other possibilities, in no
particular order, include
@@ -1829,14 +1807,14 @@ Source File Paths
path to the source directory.
cd /my/build/dir
- /my/source/dir/gmp-6.0.0/configure
+ /my/source/dir/gmp-4.3.2/configure
This works via `VPATH', and might require GNU `make'. Alternately
it might be possible to change the `.c.lo' rules appropriately.
Assertion Checking
The build option `--enable-assert' is available to add some
- consistency checks to the library (see *note Build Options::).
+ consistency checks to the library (see *Note Build Options::).
These are likely to be of limited value to most applications.
Assertion failures are just as likely to indicate memory
corruption as a library or compiler bug.
@@ -1845,8 +1823,8 @@ Assertion Checking
benefit from `--enable-assert' since it adds checks on the
parameters of most such functions, many of which have subtle
restrictions on their usage. Note however that only the generic C
- code has checks, not the assembly code, so `--disable-assembly'
- should be used for maximum checking.
+ code has checks, not the assembly code, so CPU `none' should be
+ used for maximum checking.
Temporary Memory Checking
The build option `--enable-alloca=debug' arranges that each block
@@ -1866,47 +1844,39 @@ Maximum Debuggability
would be
./configure --disable-shared --enable-assert \
- --enable-alloca=debug --disable-assembly CFLAGS=-g
+ --enable-alloca=debug --host=none CFLAGS=-g
For C++, add `--enable-cxx CXXFLAGS=-g'.
Checker
- The GCC checker (`https://savannah.nongnu.org/projects/checker/')
+ The GCC checker (`http://savannah.nongnu.org/projects/checker/')
can be used with GMP. It contains a stub library which means GMP
applications compiled with checker can use a normal GMP build.
A build of GMP with checking within GMP itself can be made. This
will run very very slowly. On GNU/Linux for example,
- ./configure --disable-assembly CC=checkergcc
+ ./configure --host=none-pc-linux-gnu CC=checkergcc
- `--disable-assembly' must be used, since the GMP assembly code
- doesn't support the checking scheme. The GMP C++ features cannot
- be used, since current versions of checker (0.9.9.1) don't yet
- support the standard C++ library.
+ `--host=none' must be used, since the GMP assembly code doesn't
+ support the checking scheme. The GMP C++ features cannot be used,
+ since current versions of checker (0.9.9.1) don't yet support the
+ standard C++ library.
Valgrind
- Valgrind (`http://valgrind.org/') is a memory checker for x86,
- ARM, MIPS, PowerPC, and S/390. It translates and emulates machine
- instructions to do strong checks for uninitialized data (at the
- level of individual bits), memory accesses through bad pointers,
- and memory leaks.
-
- Valgrind does not always support every possible instruction, in
- particular ones recently added to an ISA. Valgrind might
- therefore be incompatible with a recent GMP or even a less recent
- GMP which is compiled using a recent GCC.
-
- GMP's assembly code sometimes promotes a read of the limbs to some
- larger size, for efficiency. GMP will do this even at the start
- and end of a multilimb operand, using naturally aligned operations
- on the larger type. This may lead to benign reads outside of
- allocated areas, triggering complaints from Valgrind. Valgrind's
- option `--partial-loads-ok=yes' should help.
+ The valgrind program (`http://valgrind.org/') is a memory checker
+ for x86s. It translates and emulates machine instructions to do
+ strong checks for uninitialized data (at the level of individual
+ bits), memory accesses through bad pointers, and memory leaks.
+
+ Recent versions of Valgrind are getting support for MMX and
+ SSE/SSE2 instructions, for past versions GMP will need to be
+ configured not to use those, ie. for an x86 without them (for
+ instance plain `i486').
Other Problems
Any suspected bug in GMP itself should be isolated to make sure
- it's not an application problem, see *note Reporting Bugs::.
+ it's not an application problem, see *Note Reporting Bugs::.

File: gmp.info, Node: Profiling, Next: Autoconf, Prev: Debugging, Up: GMP Basics
@@ -2020,7 +1990,7 @@ found, but an application that must have GMP would want to generate an
error if not found. For example,
AC_CHECK_LIB(gmp, __gmpz_init, ,
- [AC_MSG_ERROR([GNU MP not found, see https://gmplib.org/])])
+ [AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
If functions added in some particular version of GMP are required,
then one of those can be used when checking. For example `mpz_mul_si'
@@ -2028,7 +1998,7 @@ was added in GMP 3.1,
AC_CHECK_LIB(gmp, __gmpz_mul_si, ,
[AC_MSG_ERROR(
- [GNU MP not found, or not 3.1 or up, see https://gmplib.org/])])
+ [GNU MP not found, or not 3.1 or up, see http://gmplib.org/])])
An alternative would be to test the version number in `gmp.h' using
say `AC_EGREP_CPP'. That would make it possible to test the exact
@@ -2076,10 +2046,10 @@ If you think you have found a bug in the GMP library, please
investigate it and report it. We have made this library available to
you, and it is not too much to ask you to report the bugs you find.
- Before you report a bug, check it's not already addressed in *note
-Known Build Problems::, or perhaps *note Notes for Particular
-Systems::. You may also want to check `https://gmplib.org/' for
-patches for this release.
+ Before you report a bug, check it's not already addressed in *Note
+Known Build Problems::, or perhaps *Note Notes for Particular
+Systems::. You may also want to check `http://gmplib.org/' for patches
+for this release.
Please include the following in any report,
@@ -2096,10 +2066,7 @@ patches for this release.
* Please do not send core dumps, executables or `strace's.
- * The `configure' options you used when building GMP, if any.
-
- * The output from `configure', as printed to stdout, with any
- options used.
+ * The configuration options you used when building GMP, if any.
* The name of the compiler and its version. For `gcc', get the
version with `gcc -v', otherwise perhaps `what `which cc`', or
@@ -2194,35 +2161,22 @@ object is initialized.
-- Function: void mpz_init (mpz_t X)
Initialize X, and set its value to 0.
- -- Function: void mpz_inits (mpz_t X, ...)
- Initialize a NULL-terminated list of `mpz_t' variables, and set
- their values to 0.
-
- -- Function: void mpz_init2 (mpz_t X, mp_bitcnt_t N)
+ -- Function: void mpz_init2 (mpz_t X, unsigned long N)
Initialize X, with space for N-bit numbers, and set its value to 0.
Calling this function instead of `mpz_init' or `mpz_inits' is never
necessary; reallocation is handled automatically by GMP when
needed.
- While N defines the initial space, X will grow automatically in the
+ N is only the initial space, X will grow automatically in the
normal way, if necessary, for subsequent values stored.
`mpz_init2' makes it possible to avoid such reallocations if a
maximum size is known in advance.
- In preparation for an operation, GMP often allocates one limb more
- than ultimately needed. To make sure GMP will not perform
- reallocation for X, you need to add the number of bits in
- `mp_limb_t' to N.
-
-- Function: void mpz_clear (mpz_t X)
Free the space occupied by X. Call this function for all `mpz_t'
variables when you are done with them.
- -- Function: void mpz_clears (mpz_t X, ...)
- Free the space occupied by a NULL-terminated list of `mpz_t'
- variables.
-
- -- Function: void mpz_realloc2 (mpz_t X, mp_bitcnt_t N)
+ -- Function: void mpz_realloc2 (mpz_t X, unsigned long N)
Change the space allocated for X to N bits. The value in X is
preserved if it fits, or is set to 0 if not.
@@ -2241,18 +2195,18 @@ File: gmp.info, Node: Assigning Integers, Next: Simultaneous Integer Init & As
These functions assign new values to already initialized integers
(*note Initializing Integers::).
- -- Function: void mpz_set (mpz_t ROP, const mpz_t OP)
+ -- Function: void mpz_set (mpz_t ROP, mpz_t OP)
-- Function: void mpz_set_ui (mpz_t ROP, unsigned long int OP)
-- Function: void mpz_set_si (mpz_t ROP, signed long int OP)
-- Function: void mpz_set_d (mpz_t ROP, double OP)
- -- Function: void mpz_set_q (mpz_t ROP, const mpq_t OP)
- -- Function: void mpz_set_f (mpz_t ROP, const mpf_t OP)
+ -- Function: void mpz_set_q (mpz_t ROP, mpq_t OP)
+ -- Function: void mpz_set_f (mpz_t ROP, mpf_t OP)
Set the value of ROP from OP.
`mpz_set_d', `mpz_set_q' and `mpz_set_f' truncate OP to make it an
integer.
- -- Function: int mpz_set_str (mpz_t ROP, const char *STR, int BASE)
+ -- Function: int mpz_set_str (mpz_t ROP, char *STR, int BASE)
Set the value of ROP from STR, a null-terminated C string in base
BASE. White space is allowed in the string, and is simply ignored.
@@ -2297,15 +2251,14 @@ functions, it can be used as the source or destination operand for the
ordinary integer functions. Don't use an initialize-and-set function
on a variable already initialized!
- -- Function: void mpz_init_set (mpz_t ROP, const mpz_t OP)
+ -- Function: void mpz_init_set (mpz_t ROP, mpz_t OP)
-- Function: void mpz_init_set_ui (mpz_t ROP, unsigned long int OP)
-- Function: void mpz_init_set_si (mpz_t ROP, signed long int OP)
-- Function: void mpz_init_set_d (mpz_t ROP, double OP)
Initialize ROP with limb space and set the initial numeric value
from OP.
- -- Function: int mpz_init_set_str (mpz_t ROP, const char *STR, int
- BASE)
+ -- Function: int mpz_init_set_str (mpz_t ROP, char *STR, int BASE)
Initialize ROP and set its value like `mpz_set_str' (see its
documentation above for details).
@@ -2321,16 +2274,16 @@ File: gmp.info, Node: Converting Integers, Next: Integer Arithmetic, Prev: Si
This section describes functions for converting GMP integers to
standard C types. Functions for converting _to_ GMP integers are
-described in *note Assigning Integers:: and *note I/O of Integers::.
+described in *Note Assigning Integers:: and *Note I/O of Integers::.
- -- Function: unsigned long int mpz_get_ui (const mpz_t OP)
+ -- Function: unsigned long int mpz_get_ui (mpz_t OP)
Return the value of OP as an `unsigned long'.
If OP is too big to fit an `unsigned long' then just the least
significant bits that do fit are returned. The sign of OP is
ignored, only the absolute value is used.
- -- Function: signed long int mpz_get_si (const mpz_t OP)
+ -- Function: signed long int mpz_get_si (mpz_t OP)
If OP fits into a `signed long int' return the value of OP.
Otherwise return the least significant part of OP, with the same
sign as OP.
@@ -2339,17 +2292,16 @@ described in *note Assigning Integers:: and *note I/O of Integers::.
result is probably not very useful. To find out if the value will
fit, use the function `mpz_fits_slong_p'.
- -- Function: double mpz_get_d (const mpz_t OP)
- Convert OP to a `double', truncating if necessary (i.e. rounding
+ -- Function: double mpz_get_d (mpz_t OP)
+ Convert OP to a `double', truncating if necessary (ie. rounding
towards zero).
If the exponent from the conversion is too big, the result is
system dependent. An infinity is returned where available. A
hardware overflow trap may or may not occur.
- -- Function: double mpz_get_d_2exp (signed long int *EXP, const mpz_t
- OP)
- Convert OP to a `double', truncating if necessary (i.e. rounding
+ -- Function: double mpz_get_d_2exp (signed long int *EXP, mpz_t OP)
+ Convert OP to a `double', truncating if necessary (ie. rounding
towards zero), and returning the exponent separately.
The return value is in the range 0.5<=abs(D)<1 and the exponent is
@@ -2359,7 +2311,7 @@ described in *note Assigning Integers:: and *note I/O of Integers::.
This is similar to the standard C `frexp' function (*note
Normalization Functions: (libc)Normalization Functions.).
- -- Function: char * mpz_get_str (char *STR, int BASE, const mpz_t OP)
+ -- Function: char * mpz_get_str (char *STR, int BASE, mpz_t OP)
Convert OP to a string of digits in base BASE. The base argument
may vary from 2 to 62 or from -2 to -36.
@@ -2387,45 +2339,43 @@ File: gmp.info, Node: Integer Arithmetic, Next: Integer Division, Prev: Conve
5.5 Arithmetic Functions
========================
- -- Function: void mpz_add (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
- -- Function: void mpz_add_ui (mpz_t ROP, const mpz_t OP1, unsigned
- long int OP2)
+ -- Function: void mpz_add (mpz_t ROP, mpz_t OP1, mpz_t OP2)
+ -- Function: void mpz_add_ui (mpz_t ROP, mpz_t OP1, unsigned long int
+ OP2)
Set ROP to OP1 + OP2.
- -- Function: void mpz_sub (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
- -- Function: void mpz_sub_ui (mpz_t ROP, const mpz_t OP1, unsigned
- long int OP2)
- -- Function: void mpz_ui_sub (mpz_t ROP, unsigned long int OP1, const
- mpz_t OP2)
+ -- Function: void mpz_sub (mpz_t ROP, mpz_t OP1, mpz_t OP2)
+ -- Function: void mpz_sub_ui (mpz_t ROP, mpz_t OP1, unsigned long int
+ OP2)
+ -- Function: void mpz_ui_sub (mpz_t ROP, unsigned long int OP1, mpz_t
+ OP2)
Set ROP to OP1 - OP2.
- -- Function: void mpz_mul (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
- -- Function: void mpz_mul_si (mpz_t ROP, const mpz_t OP1, long int OP2)
- -- Function: void mpz_mul_ui (mpz_t ROP, const mpz_t OP1, unsigned
- long int OP2)
+ -- Function: void mpz_mul (mpz_t ROP, mpz_t OP1, mpz_t OP2)
+ -- Function: void mpz_mul_si (mpz_t ROP, mpz_t OP1, long int OP2)
+ -- Function: void mpz_mul_ui (mpz_t ROP, mpz_t OP1, unsigned long int
+ OP2)
Set ROP to OP1 times OP2.
- -- Function: void mpz_addmul (mpz_t ROP, const mpz_t OP1, const mpz_t
- OP2)
- -- Function: void mpz_addmul_ui (mpz_t ROP, const mpz_t OP1, unsigned
- long int OP2)
+ -- Function: void mpz_addmul (mpz_t ROP, mpz_t OP1, mpz_t OP2)
+ -- Function: void mpz_addmul_ui (mpz_t ROP, mpz_t OP1, unsigned long
+ int OP2)
Set ROP to ROP + OP1 times OP2.
- -- Function: void mpz_submul (mpz_t ROP, const mpz_t OP1, const mpz_t
- OP2)
- -- Function: void mpz_submul_ui (mpz_t ROP, const mpz_t OP1, unsigned
- long int OP2)
+ -- Function: void mpz_submul (mpz_t ROP, mpz_t OP1, mpz_t OP2)
+ -- Function: void mpz_submul_ui (mpz_t ROP, mpz_t OP1, unsigned long
+ int OP2)
Set ROP to ROP - OP1 times OP2.
- -- Function: void mpz_mul_2exp (mpz_t ROP, const mpz_t OP1,
- mp_bitcnt_t OP2)
+ -- Function: void mpz_mul_2exp (mpz_t ROP, mpz_t OP1, unsigned long
+ int OP2)
Set ROP to OP1 times 2 raised to OP2. This operation can also be
defined as a left shift by OP2 bits.
- -- Function: void mpz_neg (mpz_t ROP, const mpz_t OP)
+ -- Function: void mpz_neg (mpz_t ROP, mpz_t OP)
Set ROP to -OP.
- -- Function: void mpz_abs (mpz_t ROP, const mpz_t OP)
+ -- Function: void mpz_abs (mpz_t ROP, mpz_t OP)
Set ROP to the absolute value of OP.

@@ -2440,56 +2390,53 @@ functions `mpz_powm' and `mpz_powm_ui'), will cause an intentional
division by zero. This lets a program handle arithmetic exceptions in
these functions the same way as for normal C `int' arithmetic.
- -- Function: void mpz_cdiv_q (mpz_t Q, const mpz_t N, const mpz_t D)
- -- Function: void mpz_cdiv_r (mpz_t R, const mpz_t N, const mpz_t D)
- -- Function: void mpz_cdiv_qr (mpz_t Q, mpz_t R, const mpz_t N, const
- mpz_t D)
- -- Function: unsigned long int mpz_cdiv_q_ui (mpz_t Q, const mpz_t N,
+ -- Function: void mpz_cdiv_q (mpz_t Q, mpz_t N, mpz_t D)
+ -- Function: void mpz_cdiv_r (mpz_t R, mpz_t N, mpz_t D)
+ -- Function: void mpz_cdiv_qr (mpz_t Q, mpz_t R, mpz_t N, mpz_t D)
+ -- Function: unsigned long int mpz_cdiv_q_ui (mpz_t Q, mpz_t N,
unsigned long int D)
- -- Function: unsigned long int mpz_cdiv_r_ui (mpz_t R, const mpz_t N,
+ -- Function: unsigned long int mpz_cdiv_r_ui (mpz_t R, mpz_t N,
unsigned long int D)
-- Function: unsigned long int mpz_cdiv_qr_ui (mpz_t Q, mpz_t R,
- const mpz_t N, unsigned long int D)
- -- Function: unsigned long int mpz_cdiv_ui (const mpz_t N,
+ mpz_t N, unsigned long int D)
+ -- Function: unsigned long int mpz_cdiv_ui (mpz_t N,
unsigned long int D)
- -- Function: void mpz_cdiv_q_2exp (mpz_t Q, const mpz_t N,
- mp_bitcnt_t B)
- -- Function: void mpz_cdiv_r_2exp (mpz_t R, const mpz_t N,
- mp_bitcnt_t B)
-
- -- Function: void mpz_fdiv_q (mpz_t Q, const mpz_t N, const mpz_t D)
- -- Function: void mpz_fdiv_r (mpz_t R, const mpz_t N, const mpz_t D)
- -- Function: void mpz_fdiv_qr (mpz_t Q, mpz_t R, const mpz_t N, const
- mpz_t D)
- -- Function: unsigned long int mpz_fdiv_q_ui (mpz_t Q, const mpz_t N,
+ -- Function: void mpz_cdiv_q_2exp (mpz_t Q, mpz_t N,
+ unsigned long int B)
+ -- Function: void mpz_cdiv_r_2exp (mpz_t R, mpz_t N,
+ unsigned long int B)
+
+ -- Function: void mpz_fdiv_q (mpz_t Q, mpz_t N, mpz_t D)
+ -- Function: void mpz_fdiv_r (mpz_t R, mpz_t N, mpz_t D)
+ -- Function: void mpz_fdiv_qr (mpz_t Q, mpz_t R, mpz_t N, mpz_t D)
+ -- Function: unsigned long int mpz_fdiv_q_ui (mpz_t Q, mpz_t N,
unsigned long int D)
- -- Function: unsigned long int mpz_fdiv_r_ui (mpz_t R, const mpz_t N,
+ -- Function: unsigned long int mpz_fdiv_r_ui (mpz_t R, mpz_t N,
unsigned long int D)
-- Function: unsigned long int mpz_fdiv_qr_ui (mpz_t Q, mpz_t R,
- const mpz_t N, unsigned long int D)
- -- Function: unsigned long int mpz_fdiv_ui (const mpz_t N,
+ mpz_t N, unsigned long int D)
+ -- Function: unsigned long int mpz_fdiv_ui (mpz_t N,
unsigned long int D)
- -- Function: void mpz_fdiv_q_2exp (mpz_t Q, const mpz_t N,
- mp_bitcnt_t B)
- -- Function: void mpz_fdiv_r_2exp (mpz_t R, const mpz_t N,
- mp_bitcnt_t B)
-
- -- Function: void mpz_tdiv_q (mpz_t Q, const mpz_t N, const mpz_t D)
- -- Function: void mpz_tdiv_r (mpz_t R, const mpz_t N, const mpz_t D)
- -- Function: void mpz_tdiv_qr (mpz_t Q, mpz_t R, const mpz_t N, const
- mpz_t D)
- -- Function: unsigned long int mpz_tdiv_q_ui (mpz_t Q, const mpz_t N,
+ -- Function: void mpz_fdiv_q_2exp (mpz_t Q, mpz_t N,
+ unsigned long int B)
+ -- Function: void mpz_fdiv_r_2exp (mpz_t R, mpz_t N,
+ unsigned long int B)
+
+ -- Function: void mpz_tdiv_q (mpz_t Q, mpz_t N, mpz_t D)
+ -- Function: void mpz_tdiv_r (mpz_t R, mpz_t N, mpz_t D)
+ -- Function: void mpz_tdiv_qr (mpz_t Q, mpz_t R, mpz_t N, mpz_t D)
+ -- Function: unsigned long int mpz_tdiv_q_ui (mpz_t Q, mpz_t N,
unsigned long int D)
- -- Function: unsigned long int mpz_tdiv_r_ui (mpz_t R, const mpz_t N,
+ -- Function: unsigned long int mpz_tdiv_r_ui (mpz_t R, mpz_t N,
unsigned long int D)
-- Function: unsigned long int mpz_tdiv_qr_ui (mpz_t Q, mpz_t R,
- const mpz_t N, unsigned long int D)
- -- Function: unsigned long int mpz_tdiv_ui (const mpz_t N,
+ mpz_t N, unsigned long int D)
+ -- Function: unsigned long int mpz_tdiv_ui (mpz_t N,
unsigned long int D)
- -- Function: void mpz_tdiv_q_2exp (mpz_t Q, const mpz_t N,
- mp_bitcnt_t B)
- -- Function: void mpz_tdiv_r_2exp (mpz_t R, const mpz_t N,
- mp_bitcnt_t B)
+ -- Function: void mpz_tdiv_q_2exp (mpz_t Q, mpz_t N,
+ unsigned long int B)
+ -- Function: void mpz_tdiv_r_2exp (mpz_t R, mpz_t N,
+ unsigned long int B)
Divide N by D, forming a quotient Q and/or remainder R. For the
`2exp' functions, D=2^B. The rounding is in three styles, each
@@ -2527,8 +2474,8 @@ these functions the same way as for normal C `int' arithmetic.
the same as the bitwise logical functions do, whereas
`mpz_tdiv_q_2exp' effectively treats N as sign and magnitude.
- -- Function: void mpz_mod (mpz_t R, const mpz_t N, const mpz_t D)
- -- Function: unsigned long int mpz_mod_ui (mpz_t R, const mpz_t N,
+ -- Function: void mpz_mod (mpz_t R, mpz_t N, mpz_t D)
+ -- Function: unsigned long int mpz_mod_ui (mpz_t R, mpz_t N,
unsigned long int D)
Set R to N `mod' D. The sign of the divisor is ignored; the
result is always non-negative.
@@ -2537,9 +2484,8 @@ these functions the same way as for normal C `int' arithmetic.
remainder as well as setting R. See `mpz_fdiv_ui' above if only
the return value is wanted.
- -- Function: void mpz_divexact (mpz_t Q, const mpz_t N, const mpz_t D)
- -- Function: void mpz_divexact_ui (mpz_t Q, const mpz_t N, unsigned
- long D)
+ -- Function: void mpz_divexact (mpz_t Q, mpz_t N, mpz_t D)
+ -- Function: void mpz_divexact_ui (mpz_t Q, mpz_t N, unsigned long D)
Set Q to N/D. These functions produce correct results only when
it is known in advance that D divides N.
@@ -2547,10 +2493,9 @@ these functions the same way as for normal C `int' arithmetic.
and are the best choice when exact division is known to occur, for
example reducing a rational to lowest terms.
- -- Function: int mpz_divisible_p (const mpz_t N, const mpz_t D)
- -- Function: int mpz_divisible_ui_p (const mpz_t N, unsigned long int
- D)
- -- Function: int mpz_divisible_2exp_p (const mpz_t N, mp_bitcnt_t B)
+ -- Function: int mpz_divisible_p (mpz_t N, mpz_t D)
+ -- Function: int mpz_divisible_ui_p (mpz_t N, unsigned long int D)
+ -- Function: int mpz_divisible_2exp_p (mpz_t N, unsigned long int B)
Return non-zero if N is exactly divisible by D, or in the case of
`mpz_divisible_2exp_p' by 2^B.
@@ -2559,12 +2504,11 @@ these functions the same way as for normal C `int' arithmetic.
following the rule it can be seen that only 0 is considered
divisible by 0.
- -- Function: int mpz_congruent_p (const mpz_t N, const mpz_t C, const
- mpz_t D)
- -- Function: int mpz_congruent_ui_p (const mpz_t N, unsigned long int
- C, unsigned long int D)
- -- Function: int mpz_congruent_2exp_p (const mpz_t N, const mpz_t C,
- mp_bitcnt_t B)
+ -- Function: int mpz_congruent_p (mpz_t N, mpz_t C, mpz_t D)
+ -- Function: int mpz_congruent_ui_p (mpz_t N, unsigned long int C,
+ unsigned long int D)
+ -- Function: int mpz_congruent_2exp_p (mpz_t N, mpz_t C, unsigned long
+ int B)
Return non-zero if N is congruent to C modulo D, or in the case of
`mpz_congruent_2exp_p' modulo 2^B.
@@ -2579,31 +2523,18 @@ File: gmp.info, Node: Integer Exponentiation, Next: Integer Roots, Prev: Inte
5.7 Exponentiation Functions
============================
- -- Function: void mpz_powm (mpz_t ROP, const mpz_t BASE, const mpz_t
- EXP, const mpz_t MOD)
- -- Function: void mpz_powm_ui (mpz_t ROP, const mpz_t BASE, unsigned
- long int EXP, const mpz_t MOD)
+ -- Function: void mpz_powm (mpz_t ROP, mpz_t BASE, mpz_t EXP, mpz_t
+ MOD)
+ -- Function: void mpz_powm_ui (mpz_t ROP, mpz_t BASE, unsigned long
+ int EXP, mpz_t MOD)
Set ROP to (BASE raised to EXP) modulo MOD.
Negative EXP is supported if an inverse BASE^-1 mod MOD exists
- (see `mpz_invert' in *note Number Theoretic Functions::). If an
+ (see `mpz_invert' in *Note Number Theoretic Functions::). If an
inverse doesn't exist then a divide by zero is raised.
- -- Function: void mpz_powm_sec (mpz_t ROP, const mpz_t BASE, const
- mpz_t EXP, const mpz_t MOD)
- Set ROP to (BASE raised to EXP) modulo MOD.
-
- It is required that EXP > 0 and that MOD is odd.
-
- This function is designed to take the same time and have the same
- cache access patterns for any two same-size arguments, assuming
- that function arguments are placed at the same position and that
- the machine state is identical upon function entry. This function
- is intended for cryptographic purposes, where resilience to
- side-channel attacks is desired.
-
- -- Function: void mpz_pow_ui (mpz_t ROP, const mpz_t BASE, unsigned
- long int EXP)
+ -- Function: void mpz_pow_ui (mpz_t ROP, mpz_t BASE, unsigned long int
+ EXP)
-- Function: void mpz_ui_pow_ui (mpz_t ROP, unsigned long int BASE,
unsigned long int EXP)
Set ROP to BASE raised to EXP. The case 0^0 yields 1.
@@ -2614,28 +2545,27 @@ File: gmp.info, Node: Integer Roots, Next: Number Theoretic Functions, Prev:
5.8 Root Extraction Functions
=============================
- -- Function: int mpz_root (mpz_t ROP, const mpz_t OP, unsigned long
- int N)
+ -- Function: int mpz_root (mpz_t ROP, mpz_t OP, unsigned long int N)
Set ROP to the truncated integer part of the Nth root of OP.
Return non-zero if the computation was exact, i.e., if OP is ROP
to the Nth power.
- -- Function: void mpz_rootrem (mpz_t ROOT, mpz_t REM, const mpz_t U,
+ -- Function: void mpz_rootrem (mpz_t ROOT, mpz_t REM, mpz_t U,
unsigned long int N)
Set ROOT to the truncated integer part of the Nth root of U. Set
REM to the remainder, U-ROOT**N.
- -- Function: void mpz_sqrt (mpz_t ROP, const mpz_t OP)
+ -- Function: void mpz_sqrt (mpz_t ROP, mpz_t OP)
Set ROP to the truncated integer part of the square root of OP.
- -- Function: void mpz_sqrtrem (mpz_t ROP1, mpz_t ROP2, const mpz_t OP)
+ -- Function: void mpz_sqrtrem (mpz_t ROP1, mpz_t ROP2, mpz_t OP)
Set ROP1 to the truncated integer part of the square root of OP,
like `mpz_sqrt'. Set ROP2 to the remainder OP-ROP1*ROP1, which
will be zero if OP is a perfect square.
If ROP1 and ROP2 are the same variable, the results are undefined.
- -- Function: int mpz_perfect_power_p (const mpz_t OP)
+ -- Function: int mpz_perfect_power_p (mpz_t OP)
Return non-zero if OP is a perfect power, i.e., if there exist
integers A and B, with B>1, such that OP equals A raised to the
power B.
@@ -2644,7 +2574,7 @@ File: gmp.info, Node: Integer Roots, Next: Number Theoretic Functions, Prev:
powers. Negative values of OP are accepted, but of course can
only be odd perfect powers.
- -- Function: int mpz_perfect_square_p (const mpz_t OP)
+ -- Function: int mpz_perfect_square_p (mpz_t OP)
Return non-zero if OP is a perfect square, i.e., if the square
root of OP is an integer. Under this definition both 0 and 1 are
considered to be perfect squares.
@@ -2655,17 +2585,15 @@ File: gmp.info, Node: Number Theoretic Functions, Next: Integer Comparisons,
5.9 Number Theoretic Functions
==============================
- -- Function: int mpz_probab_prime_p (const mpz_t N, int REPS)
+ -- Function: int mpz_probab_prime_p (mpz_t N, int REPS)
Determine whether N is prime. Return 2 if N is definitely prime,
return 1 if N is probably prime (without being certain), or return
0 if N is definitely composite.
This function does some trial divisions, then some Miller-Rabin
- probabilistic primality tests. The argument REPS controls how
- many such tests are done; a higher value will reduce the chances
- of a composite being returned as "probably prime". 25 is a
- reasonable number; a composite number will then be identified as a
- prime with a probability of less than 2^(-50).
+ probabilistic primality tests. REPS controls how many such tests
+ are done, 5 to 10 is a reasonable number, more will reduce the
+ chances of a composite being returned as "probably prime".
Miller-Rabin and similar tests can be more properly called
compositeness tests. Numbers which fail are known to be composite
@@ -2673,20 +2601,18 @@ File: gmp.info, Node: Number Theoretic Functions, Next: Integer Comparisons,
few composites pass, hence those which pass are considered
probably prime.
- -- Function: void mpz_nextprime (mpz_t ROP, const mpz_t OP)
+ -- Function: void mpz_nextprime (mpz_t ROP, mpz_t OP)
Set ROP to the next prime greater than OP.
This function uses a probabilistic algorithm to identify primes.
For practical purposes it's adequate, the chance of a composite
passing will be extremely small.
- -- Function: void mpz_gcd (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
+ -- Function: void mpz_gcd (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Set ROP to the greatest common divisor of OP1 and OP2. The result
is always positive even if one or both input operands are negative.
- Except if both inputs are zero; then this function defines
- gcd(0,0) = 0.
- -- Function: unsigned long int mpz_gcd_ui (mpz_t ROP, const mpz_t OP1,
+ -- Function: unsigned long int mpz_gcd_ui (mpz_t ROP, mpz_t OP1,
unsigned long int OP2)
Compute the greatest common divisor of OP1 and OP2. If ROP is not
`NULL', store the result there.
@@ -2696,54 +2622,41 @@ File: gmp.info, Node: Number Theoretic Functions, Next: Integer Comparisons,
result is equal to the argument OP1. Note that the result will
always fit if OP2 is non-zero.
- -- Function: void mpz_gcdext (mpz_t G, mpz_t S, mpz_t T, const mpz_t
- A, const mpz_t B)
+ -- Function: void mpz_gcdext (mpz_t G, mpz_t S, mpz_t T, mpz_t A,
+ mpz_t B)
Set G to the greatest common divisor of A and B, and in addition
set S and T to coefficients satisfying A*S + B*T = G. The value
in G is always positive, even if one or both of A and B are
- negative (or zero if both inputs are zero). The values in S and T
- are chosen such that normally, abs(S) < abs(B) / (2 G) and abs(T)
- < abs(A) / (2 G), and these relations define S and T uniquely.
- There are a few exceptional cases:
-
- If abs(A) = abs(B), then S = 0, T = sgn(B).
-
- Otherwise, S = sgn(A) if B = 0 or abs(B) = 2 G, and T = sgn(B) if
- A = 0 or abs(A) = 2 G.
-
- In all cases, S = 0 if and only if G = abs(B), i.e., if B divides
- A or A = B = 0.
+ negative. The values in S and T are chosen such that abs(S) <=
+ abs(B) and abs(T) <= abs(A).
If T is `NULL' then that value is not computed.
- -- Function: void mpz_lcm (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
- -- Function: void mpz_lcm_ui (mpz_t ROP, const mpz_t OP1, unsigned
- long OP2)
+ -- Function: void mpz_lcm (mpz_t ROP, mpz_t OP1, mpz_t OP2)
+ -- Function: void mpz_lcm_ui (mpz_t ROP, mpz_t OP1, unsigned long OP2)
Set ROP to the least common multiple of OP1 and OP2. ROP is
always positive, irrespective of the signs of OP1 and OP2. ROP
will be zero if either OP1 or OP2 is zero.
- -- Function: int mpz_invert (mpz_t ROP, const mpz_t OP1, const mpz_t
- OP2)
+ -- Function: int mpz_invert (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Compute the inverse of OP1 modulo OP2 and put the result in ROP.
If the inverse exists, the return value is non-zero and ROP will
- satisfy 0 < ROP < abs(OP2). If an inverse doesn't exist the
- return value is zero and ROP is undefined. The behaviour of this
- function is undefined when OP2 is zero.
+ satisfy 0 <= ROP < OP2. If an inverse doesn't exist the return
+ value is zero and ROP is undefined.
- -- Function: int mpz_jacobi (const mpz_t A, const mpz_t B)
+ -- Function: int mpz_jacobi (mpz_t A, mpz_t B)
Calculate the Jacobi symbol (A/B). This is defined only for B odd.
- -- Function: int mpz_legendre (const mpz_t A, const mpz_t P)
+ -- Function: int mpz_legendre (mpz_t A, mpz_t P)
Calculate the Legendre symbol (A/P). This is defined only for P
an odd positive prime, and for such P it's identical to the Jacobi
symbol.
- -- Function: int mpz_kronecker (const mpz_t A, const mpz_t B)
- -- Function: int mpz_kronecker_si (const mpz_t A, long B)
- -- Function: int mpz_kronecker_ui (const mpz_t A, unsigned long B)
- -- Function: int mpz_si_kronecker (long A, const mpz_t B)
- -- Function: int mpz_ui_kronecker (unsigned long A, const mpz_t B)
+ -- Function: int mpz_kronecker (mpz_t A, mpz_t B)
+ -- Function: int mpz_kronecker_si (mpz_t A, long B)
+ -- Function: int mpz_kronecker_ui (mpz_t A, unsigned long B)
+ -- Function: int mpz_si_kronecker (long A, mpz_t B)
+ -- Function: int mpz_ui_kronecker (unsigned long A, mpz_t B)
Calculate the Jacobi symbol (A/B) with the Kronecker extension
(a/2)=(2/a) when a odd, or (a/2)=0 when a even.
@@ -2755,26 +2668,16 @@ File: gmp.info, Node: Number Theoretic Functions, Next: Integer Comparisons,
References::), or any number theory textbook. See also the
example program `demos/qcn.c' which uses `mpz_kronecker_ui'.
- -- Function: mp_bitcnt_t mpz_remove (mpz_t ROP, const mpz_t OP, const
- mpz_t F)
+ -- Function: unsigned long int mpz_remove (mpz_t ROP, mpz_t OP, mpz_t
+ F)
Remove all occurrences of the factor F from OP and store the
result in ROP. The return value is how many such occurrences were
removed.
- -- Function: void mpz_fac_ui (mpz_t ROP, unsigned long int N)
- -- Function: void mpz_2fac_ui (mpz_t ROP, unsigned long int N)
- -- Function: void mpz_mfac_uiui (mpz_t ROP, unsigned long int N,
- unsigned long int M)
- Set ROP to the factorial of N: `mpz_fac_ui' computes the plain
- factorial N!, `mpz_2fac_ui' computes the double-factorial N!!, and
- `mpz_mfac_uiui' the M-multi-factorial N!^(M).
-
- -- Function: void mpz_primorial_ui (mpz_t ROP, unsigned long int N)
- Set ROP to the primorial of N, i.e. the product of all positive
- prime numbers <=N.
+ -- Function: void mpz_fac_ui (mpz_t ROP, unsigned long int OP)
+ Set ROP to OP!, the factorial of OP.
- -- Function: void mpz_bin_ui (mpz_t ROP, const mpz_t N, unsigned long
- int K)
+ -- Function: void mpz_bin_ui (mpz_t ROP, mpz_t N, unsigned long int K)
-- Function: void mpz_bin_uiui (mpz_t ROP, unsigned long int N,
unsigned long int K)
Compute the binomial coefficient N over K and store the result in
@@ -2807,7 +2710,7 @@ File: gmp.info, Node: Number Theoretic Functions, Next: Integer Comparisons,
The Fibonacci numbers and Lucas numbers are related sequences, so
it's never necessary to call both `mpz_fib2_ui' and
`mpz_lucnum2_ui'. The formulas for going from Fibonacci to Lucas
- can be found in *note Lucas Numbers Algorithm::, the reverse is
+ can be found in *Note Lucas Numbers Algorithm::, the reverse is
straightforward too.

@@ -2816,10 +2719,10 @@ File: gmp.info, Node: Integer Comparisons, Next: Integer Logic and Bit Fiddlin
5.10 Comparison Functions
=========================
- -- Function: int mpz_cmp (const mpz_t OP1, const mpz_t OP2)
- -- Function: int mpz_cmp_d (const mpz_t OP1, double OP2)
- -- Macro: int mpz_cmp_si (const mpz_t OP1, signed long int OP2)
- -- Macro: int mpz_cmp_ui (const mpz_t OP1, unsigned long int OP2)
+ -- Function: int mpz_cmp (mpz_t OP1, mpz_t OP2)
+ -- Function: int mpz_cmp_d (mpz_t OP1, double OP2)
+ -- Macro: int mpz_cmp_si (mpz_t OP1, signed long int OP2)
+ -- Macro: int mpz_cmp_ui (mpz_t OP1, unsigned long int OP2)
Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero
if OP1 = OP2, or a negative value if OP1 < OP2.
@@ -2827,9 +2730,9 @@ File: gmp.info, Node: Integer Comparisons, Next: Integer Logic and Bit Fiddlin
arguments more than once. `mpz_cmp_d' can be called with an
infinity, but results are undefined for a NaN.
- -- Function: int mpz_cmpabs (const mpz_t OP1, const mpz_t OP2)
- -- Function: int mpz_cmpabs_d (const mpz_t OP1, double OP2)
- -- Function: int mpz_cmpabs_ui (const mpz_t OP1, unsigned long int OP2)
+ -- Function: int mpz_cmpabs (mpz_t OP1, mpz_t OP2)
+ -- Function: int mpz_cmpabs_d (mpz_t OP1, double OP2)
+ -- Function: int mpz_cmpabs_ui (mpz_t OP1, unsigned long int OP2)
Compare the absolute values of OP1 and OP2. Return a positive
value if abs(OP1) > abs(OP2), zero if abs(OP1) = abs(OP2), or a
negative value if abs(OP1) < abs(OP2).
@@ -2837,7 +2740,7 @@ File: gmp.info, Node: Integer Comparisons, Next: Integer Logic and Bit Fiddlin
`mpz_cmpabs_d' can be called with an infinity, but results are
undefined for a NaN.
- -- Macro: int mpz_sgn (const mpz_t OP)
+ -- Macro: int mpz_sgn (mpz_t OP)
Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.
This function is actually implemented as a macro. It evaluates
@@ -2853,35 +2756,35 @@ These functions behave as if twos complement arithmetic were used
(although sign-magnitude is the actual implementation). The least
significant bit is number 0.
- -- Function: void mpz_and (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
+ -- Function: void mpz_and (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Set ROP to OP1 bitwise-and OP2.
- -- Function: void mpz_ior (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
+ -- Function: void mpz_ior (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Set ROP to OP1 bitwise inclusive-or OP2.
- -- Function: void mpz_xor (mpz_t ROP, const mpz_t OP1, const mpz_t OP2)
+ -- Function: void mpz_xor (mpz_t ROP, mpz_t OP1, mpz_t OP2)
Set ROP to OP1 bitwise exclusive-or OP2.
- -- Function: void mpz_com (mpz_t ROP, const mpz_t OP)
+ -- Function: void mpz_com (mpz_t ROP, mpz_t OP)
Set ROP to the one's complement of OP.
- -- Function: mp_bitcnt_t mpz_popcount (const mpz_t OP)
+ -- Function: unsigned long int mpz_popcount (mpz_t OP)
If OP>=0, return the population count of OP, which is the number
of 1 bits in the binary representation. If OP<0, the number of 1s
- is infinite, and the return value is the largest possible
- `mp_bitcnt_t'.
+ is infinite, and the return value is ULONG_MAX, the largest
+ possible `unsigned long'.
- -- Function: mp_bitcnt_t mpz_hamdist (const mpz_t OP1, const mpz_t OP2)
+ -- Function: unsigned long int mpz_hamdist (mpz_t OP1, mpz_t OP2)
If OP1 and OP2 are both >=0 or both <0, return the hamming
distance between the two operands, which is the number of bit
positions where OP1 and OP2 have different bit values. If one
operand is >=0 and the other <0 then the number of bits different
- is infinite, and the return value is the largest possible
- `mp_bitcnt_t'.
+ is infinite, and the return value is ULONG_MAX, the largest
+ possible `unsigned long'.
- -- Function: mp_bitcnt_t mpz_scan0 (const mpz_t OP, mp_bitcnt_t
+ -- Function: unsigned long int mpz_scan0 (mpz_t OP, unsigned long int
STARTING_BIT)
- -- Function: mp_bitcnt_t mpz_scan1 (const mpz_t OP, mp_bitcnt_t
+ -- Function: unsigned long int mpz_scan1 (mpz_t OP, unsigned long int
STARTING_BIT)
Scan OP, starting from bit STARTING_BIT, towards more significant
bits, until the first 0 or 1 bit (respectively) is found. Return
@@ -2890,21 +2793,20 @@ significant bit is number 0.
If the bit at STARTING_BIT is already what's sought, then
STARTING_BIT is returned.
- If there's no bit found, then the largest possible `mp_bitcnt_t' is
- returned. This will happen in `mpz_scan0' past the end of a
- negative number, or `mpz_scan1' past the end of a nonnegative
- number.
+ If there's no bit found, then ULONG_MAX is returned. This will
+ happen in `mpz_scan0' past the end of a negative number, or
+ `mpz_scan1' past the end of a nonnegative number.
- -- Function: void mpz_setbit (mpz_t ROP, mp_bitcnt_t BIT_INDEX)
+ -- Function: void mpz_setbit (mpz_t ROP, unsigned long int BIT_INDEX)
Set bit BIT_INDEX in ROP.
- -- Function: void mpz_clrbit (mpz_t ROP, mp_bitcnt_t BIT_INDEX)
+ -- Function: void mpz_clrbit (mpz_t ROP, unsigned long int BIT_INDEX)
Clear bit BIT_INDEX in ROP.
- -- Function: void mpz_combit (mpz_t ROP, mp_bitcnt_t BIT_INDEX)
+ -- Function: void mpz_combit (mpz_t ROP, unsigned long int BIT_INDEX)
Complement bit BIT_INDEX in ROP.
- -- Function: int mpz_tstbit (const mpz_t OP, mp_bitcnt_t BIT_INDEX)
+ -- Function: int mpz_tstbit (mpz_t OP, unsigned long int BIT_INDEX)
Test bit BIT_INDEX in OP and return 0 or 1 accordingly.

@@ -2914,18 +2816,15 @@ File: gmp.info, Node: I/O of Integers, Next: Integer Random Numbers, Prev: In
===============================
Functions that perform input from a stdio stream, and functions that
-output to a stdio stream, of `mpz' numbers. Passing a `NULL' pointer
-for a STREAM argument to any of these functions will make them read from
-`stdin' and write to `stdout', respectively.
+output to a stdio stream. Passing a `NULL' pointer for a STREAM
+argument to any of these functions will make them read from `stdin' and
+write to `stdout', respectively.
When using any of these functions, it is a good idea to include
`stdio.h' before `gmp.h', since that will allow `gmp.h' to define
prototypes for these functions.
- See also *note Formatted Output:: and *note Formatted Input::.
-
- -- Function: size_t mpz_out_str (FILE *STREAM, int BASE, const mpz_t
- OP)
+ -- Function: size_t mpz_out_str (FILE *STREAM, int BASE, mpz_t OP)
Output OP on stdio stream STREAM, as a string of digits in base
BASE. The base argument may vary from 2 to 62 or from -2 to -36.
@@ -2952,7 +2851,7 @@ prototypes for these functions.
Return the number of bytes read, or if an error occurred, return 0.
- -- Function: size_t mpz_out_raw (FILE *STREAM, const mpz_t OP)
+ -- Function: size_t mpz_out_raw (FILE *STREAM, mpz_t OP)
Output OP on stdio stream STREAM, in raw binary format. The
integer is written in a portable format, with 4 bytes of size
information, and that many bytes of limbs. Both the size and the
@@ -2985,29 +2884,29 @@ File: gmp.info, Node: Integer Random Numbers, Next: Integer Import and Export,
The random number functions of GMP come in two groups; older function
that rely on a global state, and newer functions that accept a state
-parameter that is read and modified. Please see the *note Random
+parameter that is read and modified. Please see the *Note Random
Number Functions:: for more information on how to use and not to use
random number functions.
-- Function: void mpz_urandomb (mpz_t ROP, gmp_randstate_t STATE,
- mp_bitcnt_t N)
+ unsigned long int N)
Generate a uniformly distributed random integer in the range 0 to
2^N-1, inclusive.
The variable STATE must be initialized by calling one of the
- `gmp_randinit' functions (*note Random State Initialization::)
+ `gmp_randinit' functions (*Note Random State Initialization::)
before invoking this function.
-- Function: void mpz_urandomm (mpz_t ROP, gmp_randstate_t STATE,
- const mpz_t N)
+ mpz_t N)
Generate a uniform random integer in the range 0 to N-1, inclusive.
The variable STATE must be initialized by calling one of the
- `gmp_randinit' functions (*note Random State Initialization::)
+ `gmp_randinit' functions (*Note Random State Initialization::)
before invoking this function.
-- Function: void mpz_rrandomb (mpz_t ROP, gmp_randstate_t STATE,
- mp_bitcnt_t N)
+ unsigned long int N)
Generate a random integer with long strings of zeros and ones in
the binary representation. Useful for testing functions and
algorithms, since this kind of random numbers have proven to be
@@ -3015,7 +2914,7 @@ random number functions.
be in the range 0 to 2^N-1, inclusive.
The variable STATE must be initialized by calling one of the
- `gmp_randinit' functions (*note Random State Initialization::)
+ `gmp_randinit' functions (*Note Random State Initialization::)
before invoking this function.
-- Function: void mpz_random (mpz_t ROP, mp_size_t MAX_SIZE)
@@ -3054,8 +2953,8 @@ data with the following functions.
word first or -1 for least significant first. Within each word
ENDIAN can be 1 for most significant byte first, -1 for least
significant first, or 0 for the native endianness of the host CPU.
- The most significant NAILS bits of each word are skipped, this can
- be 0 to use the full words.
+ The most significant NAILS bits of each word are skipped, this
+ can be 0 to use the full words.
There is no sign taken from the data, ROP will simply be a positive
integer. An application can handle any sign itself, and apply it
@@ -3080,7 +2979,7 @@ data with the following functions.
instance `8*sizeof(int)-INT_BIT'.
-- Function: void * mpz_export (void *ROP, size_t *COUNTP, int ORDER,
- size_t SIZE, int ENDIAN, size_t NAILS, const mpz_t OP)
+ size_t SIZE, int ENDIAN, size_t NAILS, mpz_t OP)
Fill ROP with word data from OP.
The parameters specify the format of the data produced. Each word
@@ -3127,23 +3026,23 @@ File: gmp.info, Node: Miscellaneous Integer Functions, Next: Integer Special F
5.15 Miscellaneous Functions
============================
- -- Function: int mpz_fits_ulong_p (const mpz_t OP)
- -- Function: int mpz_fits_slong_p (const mpz_t OP)
- -- Function: int mpz_fits_uint_p (const mpz_t OP)
- -- Function: int mpz_fits_sint_p (const mpz_t OP)
- -- Function: int mpz_fits_ushort_p (const mpz_t OP)
- -- Function: int mpz_fits_sshort_p (const mpz_t OP)
+ -- Function: int mpz_fits_ulong_p (mpz_t OP)
+ -- Function: int mpz_fits_slong_p (mpz_t OP)
+ -- Function: int mpz_fits_uint_p (mpz_t OP)
+ -- Function: int mpz_fits_sint_p (mpz_t OP)
+ -- Function: int mpz_fits_ushort_p (mpz_t OP)
+ -- Function: int mpz_fits_sshort_p (mpz_t OP)
Return non-zero iff the value of OP fits in an `unsigned long int',
`signed long int', `unsigned int', `signed int', `unsigned short
int', or `signed short int', respectively. Otherwise, return zero.
- -- Macro: int mpz_odd_p (const mpz_t OP)
- -- Macro: int mpz_even_p (const mpz_t OP)
+ -- Macro: int mpz_odd_p (mpz_t OP)
+ -- Macro: int mpz_even_p (mpz_t OP)
Determine whether OP is odd or even, respectively. Return
non-zero if yes, zero if no. These macros evaluate their argument
more than once.
- -- Function: size_t mpz_sizeinbase (const mpz_t OP, int BASE)
+ -- Function: size_t mpz_sizeinbase (mpz_t OP, int BASE)
Return the size of OP measured in number of digits in the given
BASE. BASE can vary from 2 to 62. The sign of OP is ignored,
just the absolute value is used. The result will be either exact
@@ -3171,7 +3070,44 @@ applications will not need them.
-- Function: void mpz_array_init (mpz_t INTEGER_ARRAY, mp_size_t
ARRAY_SIZE, mp_size_t FIXED_NUM_BITS)
- *This is an obsolete function. Do not use it.*
+ This is a special type of initialization. *Fixed* space of
+ FIXED_NUM_BITS is allocated to each of the ARRAY_SIZE integers in
+ INTEGER_ARRAY. There is no way to free the storage allocated by
+ this function. Don't call `mpz_clear'!
+
+ The INTEGER_ARRAY parameter is the first `mpz_t' in the array. For
+ example,
+
+ mpz_t arr[20000];
+ mpz_array_init (arr[0], 20000, 512);
+
+ This function is only intended for programs that create a large
+ number of integers and need to reduce memory usage by avoiding the
+ overheads of allocating and reallocating lots of small blocks. In
+ normal programs this function is not recommended.
+
+ The space allocated to each integer by this function will not be
+ automatically increased, unlike the normal `mpz_init', so an
+ application must ensure it is sufficient for any value stored.
+ The following space requirements apply to various routines,
+
+ * `mpz_abs', `mpz_neg', `mpz_set', `mpz_set_si' and
+ `mpz_set_ui' need room for the value they store.
+
+ * `mpz_add', `mpz_add_ui', `mpz_sub' and `mpz_sub_ui' need room
+ for the larger of the two operands, plus an extra
+ `mp_bits_per_limb'.
+
+ * `mpz_mul', `mpz_mul_ui' and `mpz_mul_ui' need room for the sum
+ of the number of bits in their operands, but each rounded up
+ to a multiple of `mp_bits_per_limb'.
+
+ * `mpz_swap' can be used between two array variables, but not
+ between an array and a normal variable.
+
+ For other functions, or if in doubt, the suggestion is to
+ calculate in a regular `mpz_init' variable and copy the result to
+ an array variable with `mpz_set'.
-- Function: void * _mpz_realloc (mpz_t INTEGER, mp_size_t NEW_ALLOC)
Change the space for INTEGER to NEW_ALLOC limbs. The value in
@@ -3182,7 +3118,7 @@ applications will not need them.
changes like this. `mpz_realloc2' and `_mpz_realloc' are the same
except that `_mpz_realloc' takes its size in limbs.
- -- Function: mp_limb_t mpz_getlimbn (const mpz_t OP, mp_size_t N)
+ -- Function: mp_limb_t mpz_getlimbn (mpz_t OP, mp_size_t N)
Return limb number N from OP. The sign of OP is ignored, just the
absolute value is used. The least significant limb is number 0.
@@ -3190,75 +3126,10 @@ applications will not need them.
`mpz_getlimbn' returns zero if N is outside the range 0 to
`mpz_size(OP)-1'.
- -- Function: size_t mpz_size (const mpz_t OP)
+ -- Function: size_t mpz_size (mpz_t OP)
Return the size of OP measured in number of limbs. If OP is zero,
the returned value will be zero.
- -- Function: const mp_limb_t * mpz_limbs_read (const mpz_t X)
- Return a pointer to the limb array representing the absolute value
- of X. The size of the array is `mpz_size(X)'. Intended for read
- access only.
-
- -- Function: mp_limb_t * mpz_limbs_write (mpz_t X, mp_size_t N)
- -- Function: mp_limb_t * mpz_limbs_modify (mpz_t X, mp_size_t N)
- Return a pointer to the limb array, intended for write access. The
- array is reallocated as needed, to make room for N limbs. Requires
- N > 0. The `mpz_limbs_modify' function returns an array that holds
- the old absolute value of X, while `mpz_limbs_write' may destroy
- the old value and return an array with unspecified contents.
-
- -- Function: void mpz_limbs_finish (mpz_t X, mp_size_t S)
- Updates the internal size field of X. Used after writing to the
- limb array pointer returned by `mpz_limbs_write' or
- `mpz_limbs_modify' is completed. The array should contain abs(S)
- valid limbs, representing the new absolute value for X, and the
- sign of X is taken from the sign of S. This function never
- reallocates X, so the limb pointer remains valid.
-
- void foo (mpz_t x)
- {
- mp_size_t n, i;
- mp_limb_t *xp;
-
- n = mpz_size (x);
- xp = mpz_limbs_modify(x, 2*n);
- for (i = 0; i < n; i++)
- xp[n+i] = xp[n-1-i];
- mpz_limbs_finish (x, mpz_sgn (x) < 0 ? - 2*n : 2*n);
- }
-
- -- Function: mpz_srcptr mpz_roinit_n (mpz_t X, const mp_limb_t *XP,
- mp_size_t XS)
- Special initialization of X, using the given limb array and size.
- X should be treated as read-only: it can be passed safely as input
- to any mpz function, but not as an output. The array XP must point
- to at least a readable limb, its size is abs(XS), and the sign of
- X is the sign of XS. For convenience, the function returns X, but
- cast to a const pointer type.
-
- void foo (mpz_t x)
- {
- static const mp_limb_t y[3] = { 0x1, 0x2, 0x3 };
- mpz_t tmp;
- mpz_add (x, x, mpz_roinit_n (tmp, y, 3));
- }
-
- -- Macro: mpz_t MPZ_ROINIT_N (mp_limb_t *XP, mp_size_t XS)
- This macro expands to an initializer which can be assigned to an
- mpz_t variable. The limb array XP must point to at least a
- readable limb, moreover, unlike the `mpz_roinit_n' function, the
- array must be normalized: if XS is non-zero, then `XP[abs(XS)-1]'
- must be non-zero. Intended primarily for constant values. Using it
- for non-constant values requires a C compiler supporting C99.
-
- void foo (mpz_t x)
- {
- static const mp_limb_t ya[3] = { 0x1, 0x2, 0x3 };
- static const mpz_t y = MPZ_ROINIT_N ((mp_limb_t *) ya, 3);
-
- mpz_add (x, x, y);
- }
-

File: gmp.info, Node: Rational Number Functions, Next: Floating-point Functions, Prev: Integer Functions, Up: Top
@@ -3304,20 +3175,12 @@ File: gmp.info, Node: Initializing Rationals, Next: Rational Conversions, Pre
only be initialized once, or at least cleared out (using the
function `mpq_clear') between each initialization.
- -- Function: void mpq_inits (mpq_t X, ...)
- Initialize a NULL-terminated list of `mpq_t' variables, and set
- their values to 0/1.
-
-- Function: void mpq_clear (mpq_t X)
Free the space occupied by X. Make sure to call this function for
all `mpq_t' variables when you are done with them.
- -- Function: void mpq_clears (mpq_t X, ...)
- Free the space occupied by a NULL-terminated list of `mpq_t'
- variables.
-
- -- Function: void mpq_set (mpq_t ROP, const mpq_t OP)
- -- Function: void mpq_set_z (mpq_t ROP, const mpz_t OP)
+ -- Function: void mpq_set (mpq_t ROP, mpq_t OP)
+ -- Function: void mpq_set_z (mpq_t ROP, mpz_t OP)
Assign ROP from OP.
-- Function: void mpq_set_ui (mpq_t ROP, unsigned long int OP1,
@@ -3328,7 +3191,7 @@ File: gmp.info, Node: Initializing Rationals, Next: Rational Conversions, Pre
common factors, ROP has to be passed to `mpq_canonicalize' before
any operations are performed on ROP.
- -- Function: int mpq_set_str (mpq_t ROP, const char *STR, int BASE)
+ -- Function: int mpq_set_str (mpq_t ROP, char *STR, int BASE)
Set ROP from a null-terminated string STR in the given BASE.
The string can be an integer like "41" or a fraction like
@@ -3357,8 +3220,8 @@ File: gmp.info, Node: Rational Conversions, Next: Rational Arithmetic, Prev:
6.2 Conversion Functions
========================
- -- Function: double mpq_get_d (const mpq_t OP)
- Convert OP to a `double', truncating if necessary (i.e. rounding
+ -- Function: double mpq_get_d (mpq_t OP)
+ Convert OP to a `double', truncating if necessary (ie. rounding
towards zero).
If the exponent from the conversion is too big or too small to fit
@@ -3368,11 +3231,11 @@ File: gmp.info, Node: Rational Conversions, Next: Rational Arithmetic, Prev:
may or may not occur.
-- Function: void mpq_set_d (mpq_t ROP, double OP)
- -- Function: void mpq_set_f (mpq_t ROP, const mpf_t OP)
+ -- Function: void mpq_set_f (mpq_t ROP, mpf_t OP)
Set ROP to the value of OP. There is no rounding, this conversion
is exact.
- -- Function: char * mpq_get_str (char *STR, int BASE, const mpq_t OP)
+ -- Function: char * mpq_get_str (char *STR, int BASE, mpq_t OP)
Convert OP to a string of digits in base BASE. The base may vary
from 2 to 36. The string will be of the form `num/den', or if the
denominator is 1 then just `num'.
@@ -3400,37 +3263,36 @@ File: gmp.info, Node: Rational Arithmetic, Next: Comparing Rationals, Prev: R
6.3 Arithmetic Functions
========================
- -- Function: void mpq_add (mpq_t SUM, const mpq_t ADDEND1, const mpq_t
- ADDEND2)
+ -- Function: void mpq_add (mpq_t SUM, mpq_t ADDEND1, mpq_t ADDEND2)
Set SUM to ADDEND1 + ADDEND2.
- -- Function: void mpq_sub (mpq_t DIFFERENCE, const mpq_t MINUEND,
- const mpq_t SUBTRAHEND)
+ -- Function: void mpq_sub (mpq_t DIFFERENCE, mpq_t MINUEND, mpq_t
+ SUBTRAHEND)
Set DIFFERENCE to MINUEND - SUBTRAHEND.
- -- Function: void mpq_mul (mpq_t PRODUCT, const mpq_t MULTIPLIER,
- const mpq_t MULTIPLICAND)
+ -- Function: void mpq_mul (mpq_t PRODUCT, mpq_t MULTIPLIER, mpq_t
+ MULTIPLICAND)
Set PRODUCT to MULTIPLIER times MULTIPLICAND.
- -- Function: void mpq_mul_2exp (mpq_t ROP, const mpq_t OP1,
- mp_bitcnt_t OP2)
+ -- Function: void mpq_mul_2exp (mpq_t ROP, mpq_t OP1, unsigned long
+ int OP2)
Set ROP to OP1 times 2 raised to OP2.
- -- Function: void mpq_div (mpq_t QUOTIENT, const mpq_t DIVIDEND, const
- mpq_t DIVISOR)
+ -- Function: void mpq_div (mpq_t QUOTIENT, mpq_t DIVIDEND, mpq_t
+ DIVISOR)
Set QUOTIENT to DIVIDEND/DIVISOR.
- -- Function: void mpq_div_2exp (mpq_t ROP, const mpq_t OP1,
- mp_bitcnt_t OP2)
+ -- Function: void mpq_div_2exp (mpq_t ROP, mpq_t OP1, unsigned long
+ int OP2)
Set ROP to OP1 divided by 2 raised to OP2.
- -- Function: void mpq_neg (mpq_t NEGATED_OPERAND, const mpq_t OPERAND)
+ -- Function: void mpq_neg (mpq_t NEGATED_OPERAND, mpq_t OPERAND)
Set NEGATED_OPERAND to -OPERAND.
- -- Function: void mpq_abs (mpq_t ROP, const mpq_t OP)
+ -- Function: void mpq_abs (mpq_t ROP, mpq_t OP)
Set ROP to the absolute value of OP.
- -- Function: void mpq_inv (mpq_t INVERTED_NUMBER, const mpq_t NUMBER)
+ -- Function: void mpq_inv (mpq_t INVERTED_NUMBER, mpq_t NUMBER)
Set INVERTED_NUMBER to 1/NUMBER. If the new denominator is zero,
this routine will divide by zero.
@@ -3440,17 +3302,17 @@ File: gmp.info, Node: Comparing Rationals, Next: Applying Integer Functions,
6.4 Comparison Functions
========================
- -- Function: int mpq_cmp (const mpq_t OP1, const mpq_t OP2)
+ -- Function: int mpq_cmp (mpq_t OP1, mpq_t OP2)
Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero
if OP1 = OP2, and a negative value if OP1 < OP2.
To determine if two rationals are equal, `mpq_equal' is faster than
`mpq_cmp'.
- -- Macro: int mpq_cmp_ui (const mpq_t OP1, unsigned long int NUM2,
- unsigned long int DEN2)
- -- Macro: int mpq_cmp_si (const mpq_t OP1, long int NUM2, unsigned
+ -- Macro: int mpq_cmp_ui (mpq_t OP1, unsigned long int NUM2, unsigned
long int DEN2)
+ -- Macro: int mpq_cmp_si (mpq_t OP1, long int NUM2, unsigned long int
+ DEN2)
Compare OP1 and NUM2/DEN2. Return a positive value if OP1 >
NUM2/DEN2, zero if OP1 = NUM2/DEN2, and a negative value if OP1 <
NUM2/DEN2.
@@ -3460,13 +3322,13 @@ File: gmp.info, Node: Comparing Rationals, Next: Applying Integer Functions,
These functions are implemented as a macros and evaluate their
arguments multiple times.
- -- Macro: int mpq_sgn (const mpq_t OP)
+ -- Macro: int mpq_sgn (mpq_t OP)
Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.
This function is actually implemented as a macro. It evaluates its
- argument multiple times.
+ arguments multiple times.
- -- Function: int mpq_equal (const mpq_t OP1, const mpq_t OP2)
+ -- Function: int mpq_equal (mpq_t OP1, mpq_t OP2)
Return non-zero if OP1 and OP2 are equal, zero if they are
non-equal. Although `mpq_cmp' can be used for the same purpose,
this function is much faster.
@@ -3487,16 +3349,16 @@ this chapter (*note Rational Number Functions::) then
`mpq_canonicalize' must be called before any other `mpq' functions are
applied to that `mpq_t'.
- -- Macro: mpz_t mpq_numref (const mpq_t OP)
- -- Macro: mpz_t mpq_denref (const mpq_t OP)
+ -- Macro: mpz_t mpq_numref (mpq_t OP)
+ -- Macro: mpz_t mpq_denref (mpq_t OP)
Return a reference to the numerator and denominator of OP,
respectively. The `mpz' functions can be used on the result of
these macros.
- -- Function: void mpq_get_num (mpz_t NUMERATOR, const mpq_t RATIONAL)
- -- Function: void mpq_get_den (mpz_t DENOMINATOR, const mpq_t RATIONAL)
- -- Function: void mpq_set_num (mpq_t RATIONAL, const mpz_t NUMERATOR)
- -- Function: void mpq_set_den (mpq_t RATIONAL, const mpz_t DENOMINATOR)
+ -- Function: void mpq_get_num (mpz_t NUMERATOR, mpq_t RATIONAL)
+ -- Function: void mpq_get_den (mpz_t DENOMINATOR, mpq_t RATIONAL)
+ -- Function: void mpq_set_num (mpq_t RATIONAL, mpz_t NUMERATOR)
+ -- Function: void mpq_set_den (mpq_t RATIONAL, mpz_t DENOMINATOR)
Get or set the numerator or denominator of a rational. These
functions are equivalent to calling `mpz_set' with an appropriate
`mpq_numref' or `mpq_denref'. Direct use of `mpq_numref' or
@@ -3508,19 +3370,15 @@ File: gmp.info, Node: I/O of Rationals, Prev: Applying Integer Functions, Up:
6.6 Input and Output Functions
==============================
-Functions that perform input from a stdio stream, and functions that
-output to a stdio stream, of `mpq' numbers. Passing a `NULL' pointer
-for a STREAM argument to any of these functions will make them read from
-`stdin' and write to `stdout', respectively.
+When using any of these functions, it's a good idea to include `stdio.h'
+before `gmp.h', since that will allow `gmp.h' to define prototypes for
+these functions.
- When using any of these functions, it is a good idea to include
-`stdio.h' before `gmp.h', since that will allow `gmp.h' to define
-prototypes for these functions.
+ Passing a `NULL' pointer for a STREAM argument to any of these
+functions will make them read from `stdin' and write to `stdout',
+respectively.
- See also *note Formatted Output:: and *note Formatted Input::.
-
- -- Function: size_t mpq_out_str (FILE *STREAM, int BASE, const mpq_t
- OP)
+ -- Function: size_t mpq_out_str (FILE *STREAM, int BASE, mpq_t OP)
Output OP on stdio stream STREAM, as a string of digits in base
BASE. The base may vary from 2 to 36. Output is in the form
`num/den' or if the denominator is 1 then just `num'.
@@ -3564,9 +3422,9 @@ that can be increased or decreased at any time.
most systems. In the current implementation the exponent is a count of
limbs, so for example on a 32-bit system this means a range of roughly
2^-68719476768 to 2^68719476736, or on a 64-bit system this will be
-greater. Note however that `mpf_get_str' can only return an exponent
-which fits an `mp_exp_t' and currently `mpf_set_str' doesn't accept
-exponents bigger than a `long'.
+greater. Note however `mpf_get_str' can only return an exponent which
+fits an `mp_exp_t' and currently `mpf_set_str' doesn't accept exponents
+bigger than a `long'.
Each variable keeps a size for the mantissa data actually in use.
This means that if a float is exactly represented in only a few bits
@@ -3579,21 +3437,22 @@ precision" followed by a truncation to the destination precision, but
of course the work done is only what's needed to determine a result
under that definition.
- The precision selected by the user for a variable is a minimum
-value, GMP may increase it to facilitate efficient calculation.
-Currently this means rounding up to a whole limb, and then sometimes
-having a further partial limb, depending on the high limb of the
-mantissa.
+ The precision selected for a variable is a minimum value, GMP may
+increase it a little to facilitate efficient calculation. Currently
+this means rounding up to a whole limb, and then sometimes having a
+further partial limb, depending on the high limb of the mantissa. But
+applications shouldn't be concerned by such details.
- The mantissa is stored in binary. One consequence of this is that
+ The mantissa in stored in binary, as might be imagined from the fact
+precisions are expressed in bits. One consequence of this is that
decimal fractions like 0.1 cannot be represented exactly. The same is
true of plain IEEE `double' floats. This makes both highly unsuitable
for calculations involving money or other values that should be exact
decimal fractions. (Suitably scaled integers, or perhaps rationals,
are better choices.)
- The `mpf' functions and variables have no special notion of infinity
-or not-a-number, and applications must take care not to overflow the
+ `mpf' functions and variables have no special notion of infinity or
+not-a-number, and applications must take care not to overflow the
exponent or results will be unpredictable. This might change in a
future release.
@@ -3602,10 +3461,6 @@ extension to IEEE P754 arithmetic. In particular results obtained on
one computer often differ from the results on a computer with a
different word size.
- The GMP extension library MPFR (`http://mpfr.org') is an alternative
-to GMP's `mpf' functions. MPFR provides well-defined precision and
-accurate rounding, and thereby naturally extends IEEE P754.
-
* Menu:
* Initializing Floats::
@@ -3623,12 +3478,12 @@ File: gmp.info, Node: Initializing Floats, Next: Assigning Floats, Prev: Floa
7.1 Initialization Functions
============================
- -- Function: void mpf_set_default_prec (mp_bitcnt_t PREC)
+ -- Function: void mpf_set_default_prec (unsigned long int PREC)
Set the default precision to be *at least* PREC bits. All
subsequent calls to `mpf_init' will use this precision, but
previously initialized variables are unaffected.
- -- Function: mp_bitcnt_t mpf_get_default_prec (void)
+ -- Function: unsigned long int mpf_get_default_prec (void)
Return the default precision actually used.
An `mpf_t' object must be initialized before storing the first value
@@ -3642,25 +3497,15 @@ purpose.
precision has already been established by a call to
`mpf_set_default_prec'.
- -- Function: void mpf_init2 (mpf_t X, mp_bitcnt_t PREC)
+ -- Function: void mpf_init2 (mpf_t X, unsigned long int PREC)
Initialize X to 0 and set its precision to be *at least* PREC
bits. Normally, a variable should be initialized once only or at
least be cleared, using `mpf_clear', between initializations.
- -- Function: void mpf_inits (mpf_t X, ...)
- Initialize a NULL-terminated list of `mpf_t' variables, and set
- their values to 0. The precision of the initialized variables is
- undefined unless a default precision has already been established
- by a call to `mpf_set_default_prec'.
-
-- Function: void mpf_clear (mpf_t X)
Free the space occupied by X. Make sure to call this function for
all `mpf_t' variables when you are done with them.
- -- Function: void mpf_clears (mpf_t X, ...)
- Free the space occupied by a NULL-terminated list of `mpf_t'
- variables.
-
Here is an example on how to initialize floating-point variables:
{
mpf_t x, y;
@@ -3678,17 +3523,17 @@ precision gradually in iterative algorithms like Newton-Raphson, making
the computation precision closely match the actual accurate part of the
numbers.
- -- Function: mp_bitcnt_t mpf_get_prec (const mpf_t OP)
+ -- Function: unsigned long int mpf_get_prec (mpf_t OP)
Return the current precision of OP, in bits.
- -- Function: void mpf_set_prec (mpf_t ROP, mp_bitcnt_t PREC)
+ -- Function: void mpf_set_prec (mpf_t ROP, unsigned long int PREC)
Set the precision of ROP to be *at least* PREC bits. The value in
ROP will be truncated to the new precision.
This function requires a call to `realloc', and so should not be
used in a tight loop.
- -- Function: void mpf_set_prec_raw (mpf_t ROP, mp_bitcnt_t PREC)
+ -- Function: void mpf_set_prec_raw (mpf_t ROP, unsigned long int PREC)
Set the precision of ROP to be *at least* PREC bits, without
changing the memory allocated.
@@ -3723,15 +3568,15 @@ File: gmp.info, Node: Assigning Floats, Next: Simultaneous Float Init & Assign
These functions assign new values to already initialized floats (*note
Initializing Floats::).
- -- Function: void mpf_set (mpf_t ROP, const mpf_t OP)
+ -- Function: void mpf_set (mpf_t ROP, mpf_t OP)
-- Function: void mpf_set_ui (mpf_t ROP, unsigned long int OP)
-- Function: void mpf_set_si (mpf_t ROP, signed long int OP)
-- Function: void mpf_set_d (mpf_t ROP, double OP)
- -- Function: void mpf_set_z (mpf_t ROP, const mpz_t OP)
- -- Function: void mpf_set_q (mpf_t ROP, const mpq_t OP)
+ -- Function: void mpf_set_z (mpf_t ROP, mpz_t OP)
+ -- Function: void mpf_set_q (mpf_t ROP, mpq_t OP)
Set the value of ROP from OP.
- -- Function: int mpf_set_str (mpf_t ROP, const char *STR, int BASE)
+ -- Function: int mpf_set_str (mpf_t ROP, char *STR, int BASE)
Set the value of ROP from the string in STR. The string is of the
form `M@N' or, if the base is 10 or less, alternatively `MeN'.
`M' is the mantissa and `N' is the exponent. The mantissa is
@@ -3784,7 +3629,7 @@ functions, it can be used as the source or destination operand for the
ordinary float functions. Don't use an initialize-and-set function on
a variable already initialized!
- -- Function: void mpf_init_set (mpf_t ROP, const mpf_t OP)
+ -- Function: void mpf_init_set (mpf_t ROP, mpf_t OP)
-- Function: void mpf_init_set_ui (mpf_t ROP, unsigned long int OP)
-- Function: void mpf_init_set_si (mpf_t ROP, signed long int OP)
-- Function: void mpf_init_set_d (mpf_t ROP, double OP)
@@ -3793,8 +3638,7 @@ a variable already initialized!
The precision of ROP will be taken from the active default
precision, as set by `mpf_set_default_prec'.
- -- Function: int mpf_init_set_str (mpf_t ROP, const char *STR, int
- BASE)
+ -- Function: int mpf_init_set_str (mpf_t ROP, char *STR, int BASE)
Initialize ROP and set its value from the string in STR. See
`mpf_set_str' above for details on the assignment operation.
@@ -3810,8 +3654,8 @@ File: gmp.info, Node: Converting Floats, Next: Float Arithmetic, Prev: Simult
7.4 Conversion Functions
========================
- -- Function: double mpf_get_d (const mpf_t OP)
- Convert OP to a `double', truncating if necessary (i.e. rounding
+ -- Function: double mpf_get_d (mpf_t OP)
+ Convert OP to a `double', truncating if necessary (ie. rounding
towards zero).
If the exponent in OP is too big or too small to fit a `double'
@@ -3819,9 +3663,8 @@ File: gmp.info, Node: Converting Floats, Next: Float Arithmetic, Prev: Simult
returned when available. For too small 0.0 is normally returned.
Hardware overflow, underflow and denorm traps may or may not occur.
- -- Function: double mpf_get_d_2exp (signed long int *EXP, const mpf_t
- OP)
- Convert OP to a `double', truncating if necessary (i.e. rounding
+ -- Function: double mpf_get_d_2exp (signed long int *EXP, mpf_t OP)
+ Convert OP to a `double', truncating if necessary (ie. rounding
towards zero), and with an exponent returned separately.
The return value is in the range 0.5<=abs(D)<1 and the exponent is
@@ -3831,8 +3674,8 @@ File: gmp.info, Node: Converting Floats, Next: Float Arithmetic, Prev: Simult
This is similar to the standard C `frexp' function (*note
Normalization Functions: (libc)Normalization Functions.).
- -- Function: long mpf_get_si (const mpf_t OP)
- -- Function: unsigned long mpf_get_ui (const mpf_t OP)
+ -- Function: long mpf_get_si (mpf_t OP)
+ -- Function: unsigned long mpf_get_ui (mpf_t OP)
Convert OP to a `long' or `unsigned long', truncating any fraction
part. If OP is too big for the return type, the result is
undefined.
@@ -3841,7 +3684,7 @@ File: gmp.info, Node: Converting Floats, Next: Float Arithmetic, Prev: Simult
Miscellaneous Float Functions::).
-- Function: char * mpf_get_str (char *STR, mp_exp_t *EXPPTR, int
- BASE, size_t N_DIGITS, const mpf_t OP)
+ BASE, size_t N_DIGITS, mpf_t OP)
Convert OP to a string of digits in base BASE. The base argument
may vary from 2 to 62 or from -2 to -36. Up to N_DIGITS digits
will be generated. Trailing zeros are not returned. No more
@@ -3882,21 +3725,21 @@ File: gmp.info, Node: Float Arithmetic, Next: Float Comparison, Prev: Convert
7.5 Arithmetic Functions
========================
- -- Function: void mpf_add (mpf_t ROP, const mpf_t OP1, const mpf_t OP2)
- -- Function: void mpf_add_ui (mpf_t ROP, const mpf_t OP1, unsigned
- long int OP2)
+ -- Function: void mpf_add (mpf_t ROP, mpf_t OP1, mpf_t OP2)
+ -- Function: void mpf_add_ui (mpf_t ROP, mpf_t OP1, unsigned long int
+ OP2)
Set ROP to OP1 + OP2.
- -- Function: void mpf_sub (mpf_t ROP, const mpf_t OP1, const mpf_t OP2)
- -- Function: void mpf_ui_sub (mpf_t ROP, unsigned long int OP1, const
- mpf_t OP2)
- -- Function: void mpf_sub_ui (mpf_t ROP, const mpf_t OP1, unsigned
- long int OP2)
+ -- Function: void mpf_sub (mpf_t ROP, mpf_t OP1, mpf_t OP2)
+ -- Function: void mpf_ui_sub (mpf_t ROP, unsigned long int OP1, mpf_t
+ OP2)
+ -- Function: void mpf_sub_ui (mpf_t ROP, mpf_t OP1, unsigned long int
+ OP2)
Set ROP to OP1 - OP2.
- -- Function: void mpf_mul (mpf_t ROP, const mpf_t OP1, const mpf_t OP2)
- -- Function: void mpf_mul_ui (mpf_t ROP, const mpf_t OP1, unsigned
- long int OP2)
+ -- Function: void mpf_mul (mpf_t ROP, mpf_t OP1, mpf_t OP2)
+ -- Function: void mpf_mul_ui (mpf_t ROP, mpf_t OP1, unsigned long int
+ OP2)
Set ROP to OP1 times OP2.
Division is undefined if the divisor is zero, and passing a zero
@@ -3904,33 +3747,33 @@ divisor to the divide functions will make these functions intentionally
divide by zero. This lets the user handle arithmetic exceptions in
these functions in the same manner as other arithmetic exceptions.
- -- Function: void mpf_div (mpf_t ROP, const mpf_t OP1, const mpf_t OP2)
- -- Function: void mpf_ui_div (mpf_t ROP, unsigned long int OP1, const
- mpf_t OP2)
- -- Function: void mpf_div_ui (mpf_t ROP, const mpf_t OP1, unsigned
- long int OP2)
+ -- Function: void mpf_div (mpf_t ROP, mpf_t OP1, mpf_t OP2)
+ -- Function: void mpf_ui_div (mpf_t ROP, unsigned long int OP1, mpf_t
+ OP2)
+ -- Function: void mpf_div_ui (mpf_t ROP, mpf_t OP1, unsigned long int
+ OP2)
Set ROP to OP1/OP2.
- -- Function: void mpf_sqrt (mpf_t ROP, const mpf_t OP)
+ -- Function: void mpf_sqrt (mpf_t ROP, mpf_t OP)
-- Function: void mpf_sqrt_ui (mpf_t ROP, unsigned long int OP)
Set ROP to the square root of OP.
- -- Function: void mpf_pow_ui (mpf_t ROP, const mpf_t OP1, unsigned
- long int OP2)
+ -- Function: void mpf_pow_ui (mpf_t ROP, mpf_t OP1, unsigned long int
+ OP2)
Set ROP to OP1 raised to the power OP2.
- -- Function: void mpf_neg (mpf_t ROP, const mpf_t OP)
+ -- Function: void mpf_neg (mpf_t ROP, mpf_t OP)
Set ROP to -OP.
- -- Function: void mpf_abs (mpf_t ROP, const mpf_t OP)
+ -- Function: void mpf_abs (mpf_t ROP, mpf_t OP)
Set ROP to the absolute value of OP.
- -- Function: void mpf_mul_2exp (mpf_t ROP, const mpf_t OP1,
- mp_bitcnt_t OP2)
+ -- Function: void mpf_mul_2exp (mpf_t ROP, mpf_t OP1, unsigned long
+ int OP2)
Set ROP to OP1 times 2 raised to OP2.
- -- Function: void mpf_div_2exp (mpf_t ROP, const mpf_t OP1,
- mp_bitcnt_t OP2)
+ -- Function: void mpf_div_2exp (mpf_t ROP, mpf_t OP1, unsigned long
+ int OP2)
Set ROP to OP1 divided by 2 raised to OP2.

@@ -3939,18 +3782,17 @@ File: gmp.info, Node: Float Comparison, Next: I/O of Floats, Prev: Float Arit
7.6 Comparison Functions
========================
- -- Function: int mpf_cmp (const mpf_t OP1, const mpf_t OP2)
- -- Function: int mpf_cmp_d (const mpf_t OP1, double OP2)
- -- Function: int mpf_cmp_ui (const mpf_t OP1, unsigned long int OP2)
- -- Function: int mpf_cmp_si (const mpf_t OP1, signed long int OP2)
+ -- Function: int mpf_cmp (mpf_t OP1, mpf_t OP2)
+ -- Function: int mpf_cmp_d (mpf_t OP1, double OP2)
+ -- Function: int mpf_cmp_ui (mpf_t OP1, unsigned long int OP2)
+ -- Function: int mpf_cmp_si (mpf_t OP1, signed long int OP2)
Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero
if OP1 = OP2, and a negative value if OP1 < OP2.
`mpf_cmp_d' can be called with an infinity, but results are
undefined for a NaN.
- -- Function: int mpf_eq (const mpf_t OP1, const mpf_t OP2, mp_bitcnt_t
- op3)
+ -- Function: int mpf_eq (mpf_t OP1, mpf_t OP2, unsigned long int op3)
Return non-zero if the first OP3 bits of OP1 and OP2 are equal,
zero otherwise. I.e., test if OP1 and OP2 are approximately equal.
@@ -3962,16 +3804,15 @@ File: gmp.info, Node: Float Comparison, Next: I/O of Floats, Prev: Float Arit
bits. Such numbers are really just one ulp off, and should be
considered equal.
- -- Function: void mpf_reldiff (mpf_t ROP, const mpf_t OP1, const mpf_t
- OP2)
+ -- Function: void mpf_reldiff (mpf_t ROP, mpf_t OP1, mpf_t OP2)
Compute the relative difference between OP1 and OP2 and store the
result in ROP. This is abs(OP1-OP2)/OP1.
- -- Macro: int mpf_sgn (const mpf_t OP)
+ -- Macro: int mpf_sgn (mpf_t OP)
Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0.
This function is actually implemented as a macro. It evaluates
- its argument multiple times.
+ its arguments multiple times.

File: gmp.info, Node: I/O of Floats, Next: Miscellaneous Float Functions, Prev: Float Comparison, Up: Floating-point Functions
@@ -3980,18 +3821,16 @@ File: gmp.info, Node: I/O of Floats, Next: Miscellaneous Float Functions, Pre
==============================
Functions that perform input from a stdio stream, and functions that
-output to a stdio stream, of `mpf' numbers. Passing a `NULL' pointer
-for a STREAM argument to any of these functions will make them read from
-`stdin' and write to `stdout', respectively.
+output to a stdio stream. Passing a `NULL' pointer for a STREAM
+argument to any of these functions will make them read from `stdin' and
+write to `stdout', respectively.
When using any of these functions, it is a good idea to include
`stdio.h' before `gmp.h', since that will allow `gmp.h' to define
prototypes for these functions.
- See also *note Formatted Output:: and *note Formatted Input::.
-
-- Function: size_t mpf_out_str (FILE *STREAM, int BASE, size_t
- N_DIGITS, const mpf_t OP)
+ N_DIGITS, mpf_t OP)
Print OP to STREAM, as a string of digits. Return the number of
bytes written, or if an error occurred, return 0.
@@ -4036,33 +3875,32 @@ File: gmp.info, Node: Miscellaneous Float Functions, Prev: I/O of Floats, Up:
7.8 Miscellaneous Functions
===========================
- -- Function: void mpf_ceil (mpf_t ROP, const mpf_t OP)
- -- Function: void mpf_floor (mpf_t ROP, const mpf_t OP)
- -- Function: void mpf_trunc (mpf_t ROP, const mpf_t OP)
+ -- Function: void mpf_ceil (mpf_t ROP, mpf_t OP)
+ -- Function: void mpf_floor (mpf_t ROP, mpf_t OP)
+ -- Function: void mpf_trunc (mpf_t ROP, mpf_t OP)
Set ROP to OP rounded to an integer. `mpf_ceil' rounds to the
next higher integer, `mpf_floor' to the next lower, and `mpf_trunc'
to the integer towards zero.
- -- Function: int mpf_integer_p (const mpf_t OP)
+ -- Function: int mpf_integer_p (mpf_t OP)
Return non-zero if OP is an integer.
- -- Function: int mpf_fits_ulong_p (const mpf_t OP)
- -- Function: int mpf_fits_slong_p (const mpf_t OP)
- -- Function: int mpf_fits_uint_p (const mpf_t OP)
- -- Function: int mpf_fits_sint_p (const mpf_t OP)
- -- Function: int mpf_fits_ushort_p (const mpf_t OP)
- -- Function: int mpf_fits_sshort_p (const mpf_t OP)
+ -- Function: int mpf_fits_ulong_p (mpf_t OP)
+ -- Function: int mpf_fits_slong_p (mpf_t OP)
+ -- Function: int mpf_fits_uint_p (mpf_t OP)
+ -- Function: int mpf_fits_sint_p (mpf_t OP)
+ -- Function: int mpf_fits_ushort_p (mpf_t OP)
+ -- Function: int mpf_fits_sshort_p (mpf_t OP)
Return non-zero if OP would fit in the respective C data type, when
truncated to an integer.
-- Function: void mpf_urandomb (mpf_t ROP, gmp_randstate_t STATE,
- mp_bitcnt_t NBITS)
+ unsigned long int NBITS)
Generate a uniformly distributed random float in ROP, such that 0
- <= ROP < 1, with NBITS significant bits in the mantissa or less if
- the precision of ROP is smaller.
+ <= ROP < 1, with NBITS significant bits in the mantissa.
The variable STATE must be initialized by calling one of the
- `gmp_randinit' functions (*note Random State Initialization::)
+ `gmp_randinit' functions (*Note Random State Initialization::)
before invoking this function.
-- Function: void mpf_random2 (mpf_t ROP, mp_size_t MAX_SIZE, mp_exp_t
@@ -4171,13 +4009,6 @@ For example, {S1P, S1N}.
This function requires that S1N is greater than or equal to S2N.
- -- Function: mp_limb_t mpn_neg (mp_limb_t *RP, const mp_limb_t *SP,
- mp_size_t N)
- Perform the negation of {SP, N}, and write the result to {RP, N}.
- This is equivalent to calling `mpn_sub_n' with a N-limb zero
- minuend and passing {SP, N} as subtrahend. Return borrow, either
- 0 or 1.
-
-- Function: void mpn_mul_n (mp_limb_t *RP, const mp_limb_t *S1P,
const mp_limb_t *S2P, mp_size_t N)
Multiply {S1P, N} and {S2P, N}, and write the 2*N-limb result to
@@ -4187,7 +4018,7 @@ For example, {S1P, S1N}.
product's most significant limb is zero. No overlap is permitted
between the destination and either source.
- If the two input operands are the same, use `mpn_sqr'.
+ If the two input operands are the same, use `mpn_sqr_n'.
-- Function: mp_limb_t mpn_mul (mp_limb_t *RP, const mp_limb_t *S1P,
mp_size_t S1N, const mp_limb_t *S2P, mp_size_t S2N)
@@ -4200,11 +4031,11 @@ For example, {S1P, S1N}.
This function requires that S1N is greater than or equal to S2N.
- -- Function: void mpn_sqr (mp_limb_t *RP, const mp_limb_t *S1P,
+ -- Function: void mpn_sqr_n (mp_limb_t *RP, const mp_limb_t *S1P,
mp_size_t N)
Compute the square of {S1P, N} and write the 2*N-limb result to RP.
- The destination has to have space for 2N limbs, even if the
+ The destination has to have space for 2*N limbs, even if the
result's most significant limb is zero. No overlap is permitted
between the destination and the source.
@@ -4251,9 +4082,8 @@ For example, {S1P, S1N}.
Divide {NP, NN} by {DP, DN} and put the quotient at {QP, NN-DN+1}
and the remainder at {RP, DN}. The quotient is rounded towards 0.
- No overlap is permitted between arguments, except that NP might
- equal RP. The dividend size NN must be greater than or equal to
- divisor size DN. The most significant limb of the divisor must be
+ No overlap is permitted between arguments. NN must be greater
+ than or equal to DN. The most significant limb of DP must be
non-zero. The QXN operand must be zero.
-- Function: mp_limb_t mpn_divrem (mp_limb_t *R1P, mp_size_t QXN,
@@ -4326,15 +4156,33 @@ For example, {S1P, S1N}.
c satisfy c*b^n + a-i = 3*q, where b=2^GMP_NUMB_BITS. The return
c is always 0, 1 or 2, and the initial carry i must also be 0, 1
or 2 (these are both borrows really). When c=0 clearly q=(a-i)/3.
- When c!=0, the remainder (a-i) mod 3 is given by 3-c, because b ==
- 1 mod 3 (when `mp_bits_per_limb' is even, which is always so
+ When c!=0, the remainder (a-i) mod 3 is given by 3-c, because b
+ == 1 mod 3 (when `mp_bits_per_limb' is even, which is always so
currently).
- -- Function: mp_limb_t mpn_mod_1 (const mp_limb_t *S1P, mp_size_t S1N,
+ -- Function: mp_limb_t mpn_mod_1 (mp_limb_t *S1P, mp_size_t S1N,
mp_limb_t S2LIMB)
Divide {S1P, S1N} by S2LIMB, and return the remainder. S1N can be
zero.
+ -- Function: mp_limb_t mpn_bdivmod (mp_limb_t *RP, mp_limb_t *S1P,
+ mp_size_t S1N, const mp_limb_t *S2P, mp_size_t S2N, unsigned
+ long int D)
+ This function puts the low floor(D/mp_bits_per_limb) limbs of Q =
+ {S1P, S1N}/{S2P, S2N} mod 2^D at RP, and returns the high D mod
+ `mp_bits_per_limb' bits of Q.
+
+ {S1P, S1N} - Q * {S2P, S2N} mod 2^(S1N*mp_bits_per_limb) is placed
+ at S1P. Since the low floor(D/mp_bits_per_limb) limbs of this
+ difference are zero, it is possible to overwrite the low limbs at
+ S1P with this difference, provided RP <= S1P.
+
+ This function requires that S1N * mp_bits_per_limb >= D, and that
+ {S2P, S2N} is odd.
+
+ *This interface is preliminary. It might change incompatibly in
+ future revisions.*
+
-- Function: mp_limb_t mpn_lshift (mp_limb_t *RP, const mp_limb_t *SP,
mp_size_t N, unsigned int COUNT)
Shift {SP, N} left by COUNT bits, and write the result to {RP, N}.
@@ -4370,9 +4218,9 @@ For example, {S1P, S1N}.
{YP, YN}. The result can be up to YN limbs, the return value is
the actual number produced. Both source operands are destroyed.
- It is required that XN >= YN > 0, and the most significant limb of
- {YP, YN} must be non-zero. No overlap is permitted between {XP,
- XN} and {YP, YN}.
+ {XP, XN} must have at least as many bits as {YP, YN}. {YP, YN}
+ must be odd. Both operands must have non-zero most significant
+ limbs. No overlap is permitted between {XP, XN} and {YP, YN}.
-- Function: mp_limb_t mpn_gcd_1 (const mp_limb_t *XP, mp_size_t XN,
mp_limb_t YLIMB)
@@ -4380,34 +4228,28 @@ For example, {S1P, S1N}.
operands must be non-zero.
-- Function: mp_size_t mpn_gcdext (mp_limb_t *GP, mp_limb_t *SP,
- mp_size_t *SN, mp_limb_t *UP, mp_size_t UN, mp_limb_t *VP,
- mp_size_t VN)
- Let U be defined by {UP, UN} and let V be defined by {VP, VN}.
+ mp_size_t *SN, mp_limb_t *XP, mp_size_t XN, mp_limb_t *YP,
+ mp_size_t YN)
+ Let U be defined by {XP, XN} and let V be defined by {YP, YN}.
Compute the greatest common divisor G of U and V. Compute a
cofactor S such that G = US + VT. The second cofactor T is not
computed but can easily be obtained from (G - U*S) / V (the
- division will be exact). It is required that UN >= VN > 0, and
- the most significant limb of {VP, VN} must be non-zero.
+ division will be exact). It is required that U >= V > 0.
S satisfies S = 1 or abs(S) < V / (2 G). S = 0 if and only if V
divides U (i.e., G = V).
Store G at GP and let the return value define its limb count.
Store S at SP and let |*SN| define its limb count. S can be
- negative; when this happens *SN will be negative. The area at GP
- should have room for VN limbs and the area at SP should have room
- for VN+1 limbs.
+ negative; when this happens *SN will be negative. The areas at GP
+ and SP should each have room for XN+1 limbs.
- Both source operands are destroyed.
+ The areas {XP, XN+1} and {YP, YN+1} are destroyed (i.e. the input
+ operands plus an extra limb past the end of each).
- Compatibility notes: GMP 4.3.0 and 4.3.1 defined S less strictly.
+ Compatibility note: GMP 4.3.0 and 4.3.1 defined S less strictly.
Earlier as well as later GMP releases define S as described here.
- GMP releases before GMP 4.3.0 required additional space for both
- input and output areas. More precisely, the areas {UP, UN+1} and
- {VP, VN+1} were destroyed (i.e. the operands plus an extra limb
- past the end of each), and the areas pointed to by GP and SP
- should each have room for UN+1 limbs.
-- Function: mp_size_t mpn_sqrtrem (mp_limb_t *R1P, mp_limb_t *R2P,
const mp_limb_t *SP, mp_size_t N)
@@ -4425,14 +4267,7 @@ For example, {S1P, S1N}.
remainder would have been zero or non-zero.
A return value of zero indicates a perfect square. See also
- `mpn_perfect_square_p'.
-
- -- Function: size_t mpn_sizeinbase (const mp_limb_t *XP, mp_size_t N,
- int BASE)
- Return the size of {XP,N} measured in number of digits in the
- given BASE. BASE can vary from 2 to 62. Requires N > 0 and
- XP[N-1] > 0. The result will be either exact or 1 too big. If
- BASE is a power of 2, the result is always exact.
+ `mpz_perfect_square_p'.
-- Function: mp_size_t mpn_get_str (unsigned char *STR, int BASE,
mp_limb_t *S1P, mp_size_t S1N)
@@ -4453,32 +4288,31 @@ For example, {S1P, S1N}.
*STR, size_t STRSIZE, int BASE)
Convert bytes {STR,STRSIZE} in the given BASE to limbs at RP.
- STR[0] is the most significant input byte and STR[STRSIZE-1] is
- the least significant input byte. Each byte should be a value in
- the range 0 to BASE-1, not an ASCII character. BASE can vary from
- 2 to 256.
+ STR[0] is the most significant byte and STR[STRSIZE-1] is the
+ least significant. Each byte should be a value in the range 0 to
+ BASE-1, not an ASCII character. BASE can vary from 2 to 256.
- The converted value is {RP,RN} where RN is the return value. If
- the most significant input byte STR[0] is non-zero, then RP[RN-1]
- will be non-zero, else RP[RN-1] and some number of subsequent
- limbs may be zero.
+ The return value is the number of limbs written to RP. If the most
+ significant input byte is non-zero then the high limb at RP will be
+ non-zero, and only that exact number of limbs will be required
+ there.
- The area at RP has to have space for the largest possible number
- with STRSIZE digits in the chosen base, plus one extra limb.
+ If the most significant input byte is zero then there may be high
+ zero limbs written to RP and included in the return value.
- The input must have at least one byte, and no overlap is permitted
- between {STR,STRSIZE} and the result at RP.
+ STRSIZE must be at least 1, and no overlap is permitted between
+ {STR,STRSIZE} and the result at RP.
- -- Function: mp_bitcnt_t mpn_scan0 (const mp_limb_t *S1P, mp_bitcnt_t
- BIT)
+ -- Function: unsigned long int mpn_scan0 (const mp_limb_t *S1P,
+ unsigned long int BIT)
Scan S1P from bit position BIT for the next clear bit.
It is required that there be a clear bit within the area at S1P at
or beyond bit position BIT, so that the function has something to
return.
- -- Function: mp_bitcnt_t mpn_scan1 (const mp_limb_t *S1P, mp_bitcnt_t
- BIT)
+ -- Function: unsigned long int mpn_scan1 (const mp_limb_t *S1P,
+ unsigned long int BIT)
Scan S1P from bit position BIT for the next set bit.
It is required that there be a set bit within the area at S1P at or
@@ -4495,248 +4329,22 @@ For example, {S1P, S1N}.
`mpn_random2' is intended for testing the correctness of the `mpn'
routines.
- -- Function: mp_bitcnt_t mpn_popcount (const mp_limb_t *S1P, mp_size_t
- N)
+ -- Function: unsigned long int mpn_popcount (const mp_limb_t *S1P,
+ mp_size_t N)
Count the number of set bits in {S1P, N}.
- -- Function: mp_bitcnt_t mpn_hamdist (const mp_limb_t *S1P, const
- mp_limb_t *S2P, mp_size_t N)
+ -- Function: unsigned long int mpn_hamdist (const mp_limb_t *S1P,
+ const mp_limb_t *S2P, mp_size_t N)
Compute the hamming distance between {S1P, N} and {S2P, N}, which
is the number of bit positions where the two operands have
different bit values.
-- Function: int mpn_perfect_square_p (const mp_limb_t *S1P, mp_size_t
N)
- Return non-zero iff {S1P, N} is a perfect square. The most
- significant limb of the input {S1P, N} must be non-zero.
-
- -- Function: void mpn_and_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical and of {S1P, N} and {S2P, N}, and
- write the result to {RP, N}.
-
- -- Function: void mpn_ior_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical inclusive or of {S1P, N} and {S2P, N},
- and write the result to {RP, N}.
-
- -- Function: void mpn_xor_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical exclusive or of {S1P, N} and {S2P, N},
- and write the result to {RP, N}.
-
- -- Function: void mpn_andn_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical and of {S1P, N} and the bitwise
- complement of {S2P, N}, and write the result to {RP, N}.
-
- -- Function: void mpn_iorn_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical inclusive or of {S1P, N} and the
- bitwise complement of {S2P, N}, and write the result to {RP, N}.
-
- -- Function: void mpn_nand_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical and of {S1P, N} and {S2P, N}, and
- write the bitwise complement of the result to {RP, N}.
-
- -- Function: void mpn_nior_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical inclusive or of {S1P, N} and {S2P, N},
- and write the bitwise complement of the result to {RP, N}.
-
- -- Function: void mpn_xnor_n (mp_limb_t *RP, const mp_limb_t *S1P,
- const mp_limb_t *S2P, mp_size_t N)
- Perform the bitwise logical exclusive or of {S1P, N} and {S2P, N},
- and write the bitwise complement of the result to {RP, N}.
-
- -- Function: void mpn_com (mp_limb_t *RP, const mp_limb_t *SP,
- mp_size_t N)
- Perform the bitwise complement of {SP, N}, and write the result to
- {RP, N}.
-
- -- Function: void mpn_copyi (mp_limb_t *RP, const mp_limb_t *S1P,
- mp_size_t N)
- Copy from {S1P, N} to {RP, N}, increasingly.
-
- -- Function: void mpn_copyd (mp_limb_t *RP, const mp_limb_t *S1P,
- mp_size_t N)
- Copy from {S1P, N} to {RP, N}, decreasingly.
-
- -- Function: void mpn_zero (mp_limb_t *RP, mp_size_t N)
- Zero {RP, N}.
-
-
-8.1 Low-level functions for cryptography
-========================================
-
-The functions prefixed with `mpn_sec_' and `mpn_cnd_' are designed to
-perform the exact same low-level operations and have the same cache
-access patterns for any two same-size arguments, assuming that function
-arguments are placed at the same position and that the machine state is
-identical upon function entry. These functions are intended for
-cryptographic purposes, where resilience to side-channel attacks is
-desired.
-
- These functions are less efficient than their "leaky" counterparts;
-their performance for operands of the sizes typically used for
-cryptographic applications is between 15% and 100% worse. For larger
-operands, these functions might be inadequate, since they rely on
-asymptotically elementary algorithms.
-
- These functions do not make any explicit allocations. Those of
-these functions that need scratch space accept a scratch space operand.
-This convention allows callers to keep sensitive data in designated
-memory areas. Note however that compilers may choose to spill scalar
-values used within these functions to their stack frame and that such
-scalars may contain sensitive data.
-
- In addition to these specially crafted functions, the following `mpn'
-functions are naturally side-channel resistant: `mpn_add_n',
-`mpn_sub_n', `mpn_lshift', `mpn_rshift', `mpn_zero', `mpn_copyi',
-`mpn_copyd', `mpn_com', and the logical function (`mpn_and_n', etc).
-
- There are some exceptions from the side-channel resilience: (1) Some
-assembly implementations of `mpn_lshift' identify shift-by-one as a
-special case. This is a problem iff the shift count is a function of
-sensitive data. (2) Alpha ev6 and Pentium4 using 64-bit limbs have
-leaky `mpn_add_n' and `mpn_sub_n'. (3) Alpha ev6 has a leaky
-`mpn_mul_1' which also makes `mpn_sec_mul' on those systems unsafe.
-
- -- Function: mp_limb_t mpn_cnd_add_n (mp_limb_t CND, mp_limb_t *RP,
- const mp_limb_t *S1P, const mp_limb_t *S2P, mp_size_t N)
- -- Function: mp_limb_t mpn_cnd_sub_n (mp_limb_t CND, mp_limb_t *RP,
- const mp_limb_t *S1P, const mp_limb_t *S2P, mp_size_t N)
- These functions do conditional addition and subtraction. If CND is
- non-zero, they produce the same result as a regular `mpn_add_n' or
- `mpn_sub_n', and if CND is zero, they copy {S1P,N} to the result
- area and return zero. The functions are designed to have timing
- and memory access patterns depending only on size and location of
- the data areas, but independent of the condition CND. Like for
- `mpn_add_n' and `mpn_sub_n', on most machines, the timing will
- also be independent of the actual limb values.
-
- -- Function: mp_limb_t mpn_sec_add_1 (mp_limb_t *RP, const mp_limb_t
- *AP, mp_size_t N, mp_limb_t B, mp_limb_t *TP)
- -- Function: mp_limb_t mpn_sec_sub_1 (mp_limb_t *RP, const mp_limb_t
- *AP, mp_size_t N, mp_limb_t B, mp_limb_t *TP)
- Set R to A + B or A - B, respectively, where R = {RP,N}, A =
- {AP,N}, and B is a single limb. Returns carry.
-
- These functions take O(N) time, unlike the leaky functions
- `mpn_add_1' which are O(1) on average. They require scratch space
- of `mpn_sec_add_1_itch(N)' and `mpn_sec_sub_1_itch(N)' limbs,
- respectively, to be passed in the TP parameter. The scratch space
- requirements are guaranteed to increase monotonously in the
- operand size.
-
- -- Function: void mpn_sec_mul (mp_limb_t *RP, const mp_limb_t *AP,
- mp_size_t AN, const mp_limb_t *BP, mp_size_t BN, mp_limb_t
- *TP)
- -- Function: mp_size_t mpn_sec_mul_itch (mp_size_t AN, mp_size_t BN)
- Set R to A * B, where A = {AP,AN}, B = {BP,BN}, and R = {RP,AN+BN}.
-
- It is required that AN >= BN > 0.
-
- No overlapping between R and the input operands is allowed. For A
- = B, use `mpn_sec_sqr' for optimal performance.
-
- This function requires scratch space of `mpn_sec_mul_itch(AN, BN)'
- limbs to be passed in the TP parameter. The scratch space
- requirements are guaranteed to increase monotonously in the
- operand sizes.
-
- -- Function: void mpn_sec_sqr (mp_limb_t *RP, const mp_limb_t *AP,
- mp_size_t AN, mp_limb_t *TP)
- -- Function: mp_size_t mpn_sec_sqr_itch (mp_size_t AN)
- Set R to A^2, where A = {AP,AN}, and R = {RP,2AN}.
-
- It is required that AN > 0.
-
- No overlapping between R and the input operands is allowed.
-
- This function requires scratch space of `mpn_sec_sqr_itch(AN)'
- limbs to be passed in the TP parameter. The scratch space
- requirements are guaranteed to increase monotonously in the
- operand size.
-
- -- Function: void mpn_sec_powm (mp_limb_t *RP, const mp_limb_t *BP,
- mp_size_t BN, const mp_limb_t *EP, mp_bitcnt_t ENB, const
- mp_limb_t *MP, mp_size_t N, mp_limb_t *TP)
- -- Function: mp_size_t mpn_sec_powm_itch (mp_size_t BN, mp_bitcnt_t
- ENB, size_t N)
- Set R to (B raised to E) modulo M, where R = {RP,N}, M = {MP,N},
- and E = {EP,ceil(ENB / `GMP_NUMB_BITS')}.
-
- It is required that B > 0, that M > 0 is odd, and that E < 2^ENB.
-
- No overlapping between R and the input operands is allowed.
-
- This function requires scratch space of `mpn_sec_powm_itch(BN,
- ENB, N)' limbs to be passed in the TP parameter. The scratch
- space requirements are guaranteed to increase monotonously in the
- operand sizes.
-
- -- Function: void mpn_sec_tabselect (mp_limb_t *RP, const mp_limb_t
- *TAB, mp_size_t N, mp_size_t NENTS, mp_size_t WHICH)
- Select entry WHICH from table TAB, which has NENTS entries, each N
- limbs. Store the selected entry at RP.
-
- This function reads the entire table to avoid side-channel
- information leaks.
-
- -- Function: mp_limb_t mpn_sec_div_qr (mp_limb_t *QP, mp_limb_t *NP,
- mp_size_t NN, const mp_limb_t *DP, mp_size_t DN, mp_limb_t
- *TP)
- -- Function: mp_size_t mpn_sec_div_qr_itch (mp_size_t NN, mp_size_t DN)
- Set Q to the truncated quotient N / D and R to N modulo D, where N
- = {NP,NN}, D = {DP,DN}, Q's most significant limb is the function
- return value and the remaining limbs are {QP,NN-DN}, and R =
- {NP,DN}.
-
- It is required that NN >= DN >= 1, and that DP[DN-1] != 0. This
- does not imply that N >= D since N might be zero-padded.
-
- Note the overlapping between N and R. No other operand overlapping
- is allowed. The entire space occupied by N is overwritten.
-
- This function requires scratch space of `mpn_sec_div_qr_itch(NN,
- DN)' limbs to be passed in the TP parameter.
-
- -- Function: void mpn_sec_div_r (mp_limb_t *NP, mp_size_t NN, const
- mp_limb_t *DP, mp_size_t DN, mp_limb_t *TP)
- -- Function: mp_size_t mpn_sec_div_r_itch (mp_size_t NN, mp_size_t DN)
- Set R to N modulo D, where N = {NP,NN}, D = {DP,DN}, and R =
- {NP,DN}.
-
- It is required that NN >= DN >= 1, and that DP[DN-1] != 0. This
- does not imply that N >= D since N might be zero-padded.
-
- Note the overlapping between N and R. No other operand overlapping
- is allowed. The entire space occupied by N is overwritten.
-
- This function requires scratch space of `mpn_sec_div_r_itch(NN,
- DN)' limbs to be passed in the TP parameter.
-
- -- Function: int mpn_sec_invert (mp_limb_t *RP, mp_limb_t *AP, const
- mp_limb_t *MP, mp_size_t N, mp_bitcnt_t NBCNT, mp_limb_t *TP)
- -- Function: mp_size_t mpn_sec_invert_itch (mp_size_t N)
- Set R to the inverse of A modulo M, where R = {RP,N}, A = {AP,N},
- and M = {MP,N}. *This function's interface is preliminary.*
-
- If an inverse exists, return 1, otherwise return 0 and leave R
- undefined. In either case, the input A is destroyed.
-
- It is required that M is odd, and that NBCNT >= ceil(log(A+1)) +
- ceil(log(M+1)). A safe choice is NBCNT = 2 * N * GMP_NUMB_BITS,
- but a smaller value might improve performance if M or A are known
- to have leading zero bits.
-
- This function requires scratch space of `mpn_sec_invert_itch(N)'
- limbs to be passed in the TP parameter.
+ Return non-zero iff {S1P, N} is a perfect square.
-8.2 Nails
+8.1 Nails
=========
*Everything in this section is highly experimental and may disappear or
@@ -4813,7 +4421,7 @@ one of the `gmp_randinit' functions, and can be seeded with one of the
`gmp_randseed' functions.
The functions actually generating random numbers are described in
-*note Integer Random Numbers::, and *note Miscellaneous Float
+*Note Integer Random Numbers::, and *Note Miscellaneous Float
Functions::.
The older style random number functions don't accept a
@@ -4845,8 +4453,8 @@ File: gmp.info, Node: Random State Initialization, Next: Random State Seeding,
Initialize STATE for a Mersenne Twister algorithm. This algorithm
is fast and has good randomness properties.
- -- Function: void gmp_randinit_lc_2exp (gmp_randstate_t STATE, const
- mpz_t A, unsigned long C, mp_bitcnt_t M2EXP)
+ -- Function: void gmp_randinit_lc_2exp (gmp_randstate_t STATE, mpz_t
+ A, unsigned long C, unsigned long M2EXP)
Initialize STATE with a linear congruential algorithm X = (A*X +
C) mod 2^M2EXP.
@@ -4860,10 +4468,10 @@ File: gmp.info, Node: Random State Initialization, Next: Random State Seeding,
concatenated.
-- Function: int gmp_randinit_lc_2exp_size (gmp_randstate_t STATE,
- mp_bitcnt_t SIZE)
+ unsigned long SIZE)
Initialize STATE for a linear congruential algorithm as per
`gmp_randinit_lc_2exp'. A, C and M2EXP are selected from a table,
- chosen so that SIZE bits (or more) of each X will be used, i.e.
+ chosen so that SIZE bits (or more) of each X will be used, ie.
M2EXP/2 >= SIZE.
If successful the return value is non-zero. If SIZE is bigger
@@ -4899,8 +4507,7 @@ File: gmp.info, Node: Random State Seeding, Next: Random State Miscellaneous,
9.2 Random State Seeding
========================
- -- Function: void gmp_randseed (gmp_randstate_t STATE, const mpz_t
- SEED)
+ -- Function: void gmp_randseed (gmp_randstate_t STATE, mpz_t SEED)
-- Function: void gmp_randseed_ui (gmp_randstate_t STATE,
unsigned long int SEED)
Set an initial seed value into STATE.
@@ -4930,7 +4537,7 @@ File: gmp.info, Node: Random State Miscellaneous, Prev: Random State Seeding,
-- Function: unsigned long gmp_urandomb_ui (gmp_randstate_t STATE,
unsigned long N)
- Return a uniformly distributed random number of N bits, i.e. in the
+ Return a uniformly distributed random number of N bits, ie. in the
range 0 to 2^N-1 inclusive. N must be less than or equal to the
number of bits in an `unsigned long'.
@@ -5066,7 +4673,7 @@ instance extensions registered with GLIBC `register_printf_function'.
Also currently there's no support for POSIX `$' style numbered arguments
(perhaps this will be added in the future).
- The precision field has its usual meaning for integer `Z' and float
+ The precision field has it's usual meaning for integer `Z' and float
`F' types, but is currently undefined for `Q' and should not be used
with that.
@@ -5077,9 +4684,7 @@ happens even for an `f' conversion of an `mpf_t' which is an integer,
for instance 2^1024 in an `mpf_t' of 128 bits precision will only
produce about 40 digits, then pad with zeros to the decimal point. An
empty precision field like `%.Fe' or `%.Ff' can be used to specifically
-request just the significant digits. Without any dot and thus no
-precision field, a precision value of 6 will be used. Note that these
-rules mean that `%Ff', `%.Ff', and `%.0Ff' will all be different.
+request just the significant digits.
The decimal point character (or string) is taken from the current
locale settings on systems which provide `localeconv' (*note Locales
@@ -5097,7 +4702,7 @@ File: gmp.info, Node: Formatted Output Functions, Next: C++ Formatted Output,
Each of the following functions is similar to the corresponding C
library function. The basic `printf' forms take a variable argument
-list. The `vprintf' forms take an argument pointer, see *note Variadic
+list. The `vprintf' forms take an argument pointer, see *Note Variadic
Functions: (libc)Variadic Functions, or `man 3 va_start'.
It should be emphasised that if a format string is invalid, or the
@@ -5178,7 +4783,7 @@ shouldn't normally occur.
These functions are available only when the C library provides the
obstack feature, which probably means only on GNU systems, see
- *note Obstacks: (libc)Obstacks.
+ *Note Obstacks: (libc)Obstacks.

File: gmp.info, Node: C++ Formatted Output, Prev: Formatted Output Functions, Up: Formatted Output
@@ -5190,7 +4795,7 @@ The following functions are provided in `libgmpxx' (*note Headers and
Libraries::), which is built if C++ support is enabled (*note Build
Options::). Prototypes are available from `<gmp.h>'.
- -- Function: ostream& operator<< (ostream& STREAM, const mpz_t OP)
+ -- Function: ostream& operator<< (ostream& STREAM, mpz_t OP)
Print OP to STREAM, using its `ios' formatting settings.
`ios::width' is reset to 0 after output, the same as the standard
`ostream operator<<' routines do.
@@ -5199,7 +4804,7 @@ Options::). Prototypes are available from `<gmp.h>'.
decimal. This is unlike the standard `operator<<' routines on
`int' etc, which instead give twos complement.
- -- Function: ostream& operator<< (ostream& STREAM, const mpq_t OP)
+ -- Function: ostream& operator<< (ostream& STREAM, mpq_t OP)
Print OP to STREAM, using its `ios' formatting settings.
`ios::width' is reset to 0 after output, the same as the standard
`ostream operator<<' routines do.
@@ -5212,7 +4817,7 @@ Options::). Prototypes are available from `<gmp.h>'.
on both the numerator and denominator (if the denominator is
required).
- -- Function: ostream& operator<< (ostream& STREAM, const mpf_t OP)
+ -- Function: ostream& operator<< (ostream& STREAM, mpf_t OP)
Print OP to STREAM, using its `ios' formatting settings.
`ios::width' is reset to 0 after output, the same as the standard
`ostream operator<<' routines do.
@@ -5241,7 +4846,7 @@ way, for example,
But note that `ostream' output (and `istream' input, *note C++
Formatted Input::) is the only overloading available for the GMP types
and that for instance using `+' with an `mpz_t' will have unpredictable
-results. For classes with overloading, see *note C++ Class Interface::.
+results. For classes with overloading, see *Note C++ Class Interface::.

File: gmp.info, Node: Formatted Input, Next: C++ Class Interface, Prev: Formatted Output, Up: Top
@@ -5389,7 +4994,7 @@ File: gmp.info, Node: Formatted Input Functions, Next: C++ Formatted Input, P
Each of the following functions is similar to the corresponding C
library function. The plain `scanf' forms take a variable argument
-list. The `vscanf' forms take an argument pointer, see *note Variadic
+list. The `vscanf' forms take an argument pointer, see *Note Variadic
Functions: (libc)Variadic Functions, or `man 3 va_start'.
It should be emphasised that if a format string is invalid, or the
@@ -5489,10 +5094,10 @@ way, for example,
But note that `istream' input (and `ostream' output, *note C++
Formatted Output::) is the only overloading available for the GMP types
and that for instance using `+' with an `mpz_t' will have unpredictable
-results. For classes with overloading, see *note C++ Class Interface::.
+results. For classes with overloading, see *Note C++ Class Interface::.

-File: gmp.info, Node: C++ Class Interface, Next: Custom Allocation, Prev: Formatted Input, Up: Top
+File: gmp.info, Node: C++ Class Interface, Next: BSD Compatible Functions, Prev: Formatted Input, Up: Top
12 C++ Class Interface
**********************
@@ -5505,7 +5110,8 @@ offers overloaded functions and operators which may be more convenient.
Due to the implementation of this interface, a reasonably recent C++
compiler is required, one supporting namespaces, partial specialization
-of templates and member templates.
+of templates and member templates. For GCC this means version 2.91 or
+later.
*Everything described in this chapter is to be considered preliminary
and might be subject to incompatible changes if some unforeseen
@@ -5617,33 +5223,28 @@ File: gmp.info, Node: C++ Interface Integers, Next: C++ Interface Rationals,
12.2 C++ Interface Integers
===========================
- -- Function: mpz_class::mpz_class (type N)
+ -- Function: void mpz_class::mpz_class (type N)
Construct an `mpz_class'. All the standard C++ types may be used,
except `long long' and `long double', and all the GMP C++ classes
- can be used, although conversions from `mpq_class' and `mpf_class'
- are `explicit'. Any necessary conversion follows the
- corresponding C function, for example `double' follows `mpz_set_d'
- (*note Assigning Integers::).
+ can be used. Any necessary conversion follows the corresponding C
+ function, for example `double' follows `mpz_set_d' (*note
+ Assigning Integers::).
- -- Function: explicit mpz_class::mpz_class (const mpz_t Z)
+ -- Function: void mpz_class::mpz_class (mpz_t Z)
Construct an `mpz_class' from an `mpz_t'. The value in Z is
copied into the new `mpz_class', there won't be any permanent
association between it and Z.
- -- Function: explicit mpz_class::mpz_class (const char *S, int BASE =
- 0)
- -- Function: explicit mpz_class::mpz_class (const string& S, int BASE
- = 0)
+ -- Function: void mpz_class::mpz_class (const char *S)
+ -- Function: void mpz_class::mpz_class (const char *S, int BASE = 0)
+ -- Function: void mpz_class::mpz_class (const string& S)
+ -- Function: void mpz_class::mpz_class (const string& S, int BASE = 0)
Construct an `mpz_class' converted from a string using
`mpz_set_str' (*note Assigning Integers::).
If the string is not a valid integer, an `std::invalid_argument'
exception is thrown. The same applies to `operator='.
- -- Function: mpz_class operator"" _mpz (const char *STR)
- With C++11 compilers, integers can be constructed with the syntax
- `123_mpz' which is equivalent to `mpz_class("123")'.
-
-- Function: mpz_class operator/ (mpz_class A, mpz_class D)
-- Function: mpz_class operator% (mpz_class A, mpz_class D)
Divisions involving `mpz_class' round towards zero, as per the
@@ -5657,7 +5258,7 @@ File: gmp.info, Node: C++ Interface Integers, Next: C++ Interface Rationals,
...
mpz_fdiv_q (q.get_mpz_t(), a.get_mpz_t(), d.get_mpz_t());
- -- Function: mpz_class abs (mpz_class OP)
+ -- Function: mpz_class abs (mpz_class OP1)
-- Function: int cmp (mpz_class OP1, type OP2)
-- Function: int cmp (type OP1, mpz_class OP2)
-- Function: bool mpz_class::fits_sint_p (void)
@@ -5674,8 +5275,6 @@ File: gmp.info, Node: C++ Interface Integers, Next: C++ Interface Rationals,
-- Function: int mpz_class::set_str (const string& STR, int BASE)
-- Function: int sgn (mpz_class OP)
-- Function: mpz_class sqrt (mpz_class OP)
- -- Function: void mpz_class::swap (mpz_class& OP)
- -- Function: void swap (mpz_class& OP1, mpz_class& OP2)
These functions provide a C++ class interface to the corresponding
GMP C routines.
@@ -5704,40 +5303,34 @@ In all the following constructors, if a fraction is given then it
should be in canonical form, or if not then `mpq_class::canonicalize'
called.
- -- Function: mpq_class::mpq_class (type OP)
- -- Function: mpq_class::mpq_class (integer NUM, integer DEN)
+ -- Function: void mpq_class::mpq_class (type OP)
+ -- Function: void mpq_class::mpq_class (integer NUM, integer DEN)
Construct an `mpq_class'. The initial value can be a single value
- of any type (conversion from `mpf_class' is `explicit'), or a pair
- of integers (`mpz_class' or standard C++ integer types)
- representing a fraction, except that `long long' and `long double'
- are not supported. For example,
+ of any type, or a pair of integers (`mpz_class' or standard C++
+ integer types) representing a fraction, except that `long long'
+ and `long double' are not supported. For example,
mpq_class q (99);
mpq_class q (1.75);
mpq_class q (1, 3);
- -- Function: explicit mpq_class::mpq_class (const mpq_t Q)
+ -- Function: void mpq_class::mpq_class (mpq_t Q)
Construct an `mpq_class' from an `mpq_t'. The value in Q is
copied into the new `mpq_class', there won't be any permanent
association between it and Q.
- -- Function: explicit mpq_class::mpq_class (const char *S, int BASE =
- 0)
- -- Function: explicit mpq_class::mpq_class (const string& S, int BASE
- = 0)
+ -- Function: void mpq_class::mpq_class (const char *S)
+ -- Function: void mpq_class::mpq_class (const char *S, int BASE = 0)
+ -- Function: void mpq_class::mpq_class (const string& S)
+ -- Function: void mpq_class::mpq_class (const string& S, int BASE = 0)
Construct an `mpq_class' converted from a string using
`mpq_set_str' (*note Initializing Rationals::).
If the string is not a valid rational, an `std::invalid_argument'
exception is thrown. The same applies to `operator='.
- -- Function: mpq_class operator"" _mpq (const char *STR)
- With C++11 compilers, integral rationals can be constructed with
- the syntax `123_mpq' which is equivalent to `mpq_class(123_mpz)'.
- Other rationals can be built as `-1_mpq/2' or `0xb_mpq/123456_mpz'.
-
-- Function: void mpq_class::canonicalize ()
- Put an `mpq_class' into canonical form, as per *note Rational
+ Put an `mpq_class' into canonical form, as per *Note Rational
Number Functions::. All arithmetic operators require their
operands in canonical form, and will return results in canonical
form.
@@ -5750,8 +5343,6 @@ called.
-- Function: int mpq_class::set_str (const char *STR, int BASE)
-- Function: int mpq_class::set_str (const string& STR, int BASE)
-- Function: int sgn (mpq_class OP)
- -- Function: void mpq_class::swap (mpq_class& OP)
- -- Function: void swap (mpq_class& OP1, mpq_class& OP2)
These functions provide a C++ class interface to the corresponding
GMP C routines.
@@ -5797,7 +5388,7 @@ same precision as the destination `f'. Explicit constructors can be
used if this doesn't suit.
-- Function: mpf_class::mpf_class (type OP)
- -- Function: mpf_class::mpf_class (type OP, mp_bitcnt_t PREC)
+ -- Function: mpf_class::mpf_class (type OP, unsigned long PREC)
Construct an `mpf_class'. Any standard C++ type can be used,
except `long long' and `long double', and any of the GMP C++
classes can be used.
@@ -5817,21 +5408,12 @@ used if this doesn't suit.
mpf_class f(-g, 1000); // 1000 bits (at least)
mpf_class f(x+y); // greater of precisions of x and y
- -- Function: explicit mpf_class::mpf_class (const mpf_t F)
- -- Function: mpf_class::mpf_class (const mpf_t F, mp_bitcnt_t PREC)
- Construct an `mpf_class' from an `mpf_t'. The value in F is
- copied into the new `mpf_class', there won't be any permanent
- association between it and F.
-
- If PREC is given, the initial precision is that value, in bits. If
- PREC is not given, then the initial precision is that of F.
-
- -- Function: explicit mpf_class::mpf_class (const char *S)
- -- Function: mpf_class::mpf_class (const char *S, mp_bitcnt_t PREC,
- int BASE = 0)
- -- Function: explicit mpf_class::mpf_class (const string& S)
- -- Function: mpf_class::mpf_class (const string& S, mp_bitcnt_t PREC,
- int BASE = 0)
+ -- Function: void mpf_class::mpf_class (const char *S)
+ -- Function: void mpf_class::mpf_class (const char *S, unsigned long
+ PREC, int BASE = 0)
+ -- Function: void mpf_class::mpf_class (const string& S)
+ -- Function: void mpf_class::mpf_class (const string& S, unsigned long
+ PREC, int BASE = 0)
Construct an `mpf_class' converted from a string using
`mpf_set_str' (*note Assigning Floats::). If PREC is given, the
initial precision is that value, in bits. If not, the default
@@ -5840,10 +5422,6 @@ used if this doesn't suit.
If the string is not a valid float, an `std::invalid_argument'
exception is thrown. The same applies to `operator='.
- -- Function: mpf_class operator"" _mpf (const char *STR)
- With C++11 compilers, floats can be constructed with the syntax
- `1.23e-1_mpf' which is equivalent to `mpf_class("1.23e-1")'.
-
-- Function: mpf_class& mpf_class::operator= (type OP)
Convert and store the given OP value to an `mpf_class' object. The
same types are accepted as for the constructors above.
@@ -5888,8 +5466,6 @@ used if this doesn't suit.
-- Function: int mpf_class::set_str (const string& STR, int BASE)
-- Function: int sgn (mpf_class OP)
-- Function: mpf_class sqrt (mpf_class OP)
- -- Function: void mpf_class::swap (mpf_class& OP)
- -- Function: void swap (mpf_class& OP1, mpf_class& OP2)
-- Function: mpf_class trunc (mpf_class OP)
These functions provide a C++ class interface to the corresponding
GMP C routines.
@@ -5899,9 +5475,9 @@ used if this doesn't suit.
The accuracy provided by `hypot' is not currently guaranteed.
- -- Function: mp_bitcnt_t mpf_class::get_prec ()
- -- Function: void mpf_class::set_prec (mp_bitcnt_t PREC)
- -- Function: void mpf_class::set_prec_raw (mp_bitcnt_t PREC)
+ -- Function: unsigned long int mpf_class::get_prec ()
+ -- Function: void mpf_class::set_prec (unsigned long PREC)
+ -- Function: void mpf_class::set_prec_raw (unsigned long PREC)
Get or set the current precision of an `mpf_class'.
The restrictions described for `mpf_set_prec_raw' (*note
@@ -5947,7 +5523,7 @@ File: gmp.info, Node: C++ Interface Random Numbers, Next: C++ Interface Limita
Seed a random number generator. See *note Random Number
Functions::, for how to choose a good seed.
- -- Function: mpz_class gmp_randclass::get_z_bits (mp_bitcnt_t BITS)
+ -- Function: mpz_class gmp_randclass::get_z_bits (unsigned long BITS)
-- Function: mpz_class gmp_randclass::get_z_bits (mpz_class BITS)
Generate a random integer with a specified number of bits.
@@ -5955,7 +5531,7 @@ File: gmp.info, Node: C++ Interface Random Numbers, Next: C++ Interface Limita
Generate a random integer in the range 0 to N-1 inclusive.
-- Function: mpf_class gmp_randclass::get_f ()
- -- Function: mpf_class gmp_randclass::get_f (mp_bitcnt_t PREC)
+ -- Function: mpf_class gmp_randclass::get_f (unsigned long PREC)
Generate a random float F in the range 0 <= F < 1. F will be to
PREC bits precision, or if PREC is not given then to the precision
of the destination. For example,
@@ -6042,31 +5618,118 @@ Templated Expressions
fun2 (f, T(f+g)); // Good
}
-C++11
- C++11 provides several new ways in which types can be inferred:
- `auto', `decltype', etc. While they can be very convenient, they
- don't mix well with expression templates. In this example, the
- addition is performed twice, as if we had defined `sum' as a macro.
+
+File: gmp.info, Node: BSD Compatible Functions, Next: Custom Allocation, Prev: C++ Class Interface, Up: Top
+
+13 Berkeley MP Compatible Functions
+***********************************
+
+These functions are intended to be fully compatible with the Berkeley MP
+library which is available on many BSD derived U*ix systems. The
+`--enable-mpbsd' option must be used when building GNU MP to make these
+available (*note Installing GMP::).
+
+ The original Berkeley MP library has a usage restriction: you cannot
+use the same variable as both source and destination in a single
+function call. The compatible functions in GNU MP do not share this
+restriction--inputs and outputs may overlap.
+
+ It is not recommended that new programs are written using these
+functions. Apart from the incomplete set of functions, the interface
+for initializing `MINT' objects is more error prone, and the `pow'
+function collides with `pow' in `libm.a'.
+
+ Include the header `mp.h' to get the definition of the necessary
+types and functions. If you are on a BSD derived system, make sure to
+include GNU `mp.h' if you are going to link the GNU `libmp.a' to your
+program. This means that you probably need to give the `-I<dir>'
+option to the compiler, where `<dir>' is the directory where you have
+GNU `mp.h'.
+
+ -- Function: MINT * itom (signed short int INITIAL_VALUE)
+ Allocate an integer consisting of a `MINT' object and dynamic limb
+ space. Initialize the integer to INITIAL_VALUE. Return a pointer
+ to the `MINT' object.
+
+ -- Function: MINT * xtom (char *INITIAL_VALUE)
+ Allocate an integer consisting of a `MINT' object and dynamic limb
+ space. Initialize the integer from INITIAL_VALUE, a hexadecimal,
+ null-terminated C string. Return a pointer to the `MINT' object.
+
+ -- Function: void move (MINT *SRC, MINT *DEST)
+ Set DEST to SRC by copying. Both variables must be previously
+ initialized.
+
+ -- Function: void madd (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION)
+ Add SRC_1 and SRC_2 and put the sum in DESTINATION.
+
+ -- Function: void msub (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION)
+ Subtract SRC_2 from SRC_1 and put the difference in DESTINATION.
+
+ -- Function: void mult (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION)
+ Multiply SRC_1 and SRC_2 and put the product in DESTINATION.
+
+ -- Function: void mdiv (MINT *DIVIDEND, MINT *DIVISOR, MINT *QUOTIENT,
+ MINT *REMAINDER)
+ -- Function: void sdiv (MINT *DIVIDEND, signed short int DIVISOR, MINT
+ *QUOTIENT, signed short int *REMAINDER)
+ Set QUOTIENT to DIVIDEND/DIVISOR, and REMAINDER to DIVIDEND mod
+ DIVISOR. The quotient is rounded towards zero; the remainder has
+ the same sign as the dividend unless it is zero.
+
+ Some implementations of these functions work differently--or not
+ at all--for negative arguments.
+
+ -- Function: void msqrt (MINT *OP, MINT *ROOT, MINT *REMAINDER)
+ Set ROOT to the truncated integer part of the square root of OP,
+ like `mpz_sqrt'. Set REMAINDER to OP-ROOT*ROOT, i.e. zero if OP
+ is a perfect square.
+
+ If ROOT and REMAINDER are the same variable, the results are
+ undefined.
+
+ -- Function: void pow (MINT *BASE, MINT *EXP, MINT *MOD, MINT *DEST)
+ Set DEST to (BASE raised to EXP) modulo MOD.
+
+ Note that the name `pow' clashes with `pow' from the standard C
+ math library (*note Exponentiation and Logarithms: (libc)Exponents
+ and Logarithms.). An application will only be able to use one or
+ the other.
+
+ -- Function: void rpow (MINT *BASE, signed short int EXP, MINT *DEST)
+ Set DEST to BASE raised to EXP.
+
+ -- Function: void gcd (MINT *OP1, MINT *OP2, MINT *RES)
+ Set RES to the greatest common divisor of OP1 and OP2.
+
+ -- Function: int mcmp (MINT *OP1, MINT *OP2)
+ Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero
+ if OP1 = OP2, and a negative value if OP1 < OP2.
- mpz_class z = 33;
- auto sum = z + z;
- mpz_class prod = sum * sum;
+ -- Function: void min (MINT *DEST)
+ Input a decimal string from `stdin', and put the read integer in
+ DEST. SPC and TAB are allowed in the number string, and are
+ ignored.
- This other example may crash, though some compilers might make it
- look like it is working, because the expression `z+z' goes out of
- scope before it is evaluated.
+ -- Function: void mout (MINT *SRC)
+ Output SRC to `stdout', as a decimal string. Also output a
+ newline.
- mpz_class z = 33;
- auto sum = z + z + z;
- mpz_class prod = sum * 2;
+ -- Function: char * mtox (MINT *OP)
+ Convert OP to a hexadecimal string, and return a pointer to the
+ string. The returned string is allocated using the default memory
+ allocation function, `malloc' by default. It will be
+ `strlen(str)+1' bytes, that being exactly enough for the string
+ and null-terminator.
- It is thus strongly recommended to avoid `auto' anywhere a GMP C++
- expression may appear.
+ -- Function: void mfree (MINT *OP)
+ De-allocate, the space used by OP. *This function should only be
+ passed a value returned by `itom' or `xtom'.*

-File: gmp.info, Node: Custom Allocation, Next: Language Bindings, Prev: C++ Class Interface, Up: Top
+File: gmp.info, Node: Custom Allocation, Next: Language Bindings, Prev: BSD Compatible Functions, Up: Top
-13 Custom Allocation
+14 Custom Allocation
********************
By default GMP uses `malloc', `realloc' and `free' for memory
@@ -6077,6 +5740,9 @@ output and terminates the program.
different way or to have a different error action on running out of
memory.
+ This feature is available in the Berkeley compatibility library
+(*note BSD Compatible Functions::) as well as the main GMP library.
+
-- Function: void mp_set_memory_functions (
void *(*ALLOC_FUNC_PTR) (size_t),
void *(*REALLOC_FUNC_PTR) (void *, size_t, size_t),
@@ -6119,10 +5785,10 @@ memory.
A "byte" here means the unit used by the `sizeof' operator.
- The REALLOCATE_FUNCTION parameter OLD_SIZE and the FREE_FUNCTION
-parameter SIZE are passed for convenience, but of course they can be
-ignored if not needed by an implementation. The default functions
-using `malloc' and friends for instance don't use them.
+ The OLD_SIZE parameters to REALLOCATE_FUNCTION and FREE_FUNCTION are
+passed for convenience, but of course can be ignored if not needed.
+The default functions using `malloc' and friends for instance don't use
+them.
No error return is allowed from any of these functions, if they
return then they must have performed the specified operation. In
@@ -6166,7 +5832,7 @@ this is a problem.

File: gmp.info, Node: Language Bindings, Next: Algorithms, Prev: Custom Allocation, Up: Top
-14 Language Bindings
+15 Language Bindings
********************
The following packages and projects offer access to GMP from languages
@@ -6179,32 +5845,38 @@ C++
Straightforward interface, expression templates to eliminate
temporaries.
- * ALP `https://www-sop.inria.fr/saga/logiciels/ALP/'
+ * ALP `http://www-sop.inria.fr/saga/logiciels/ALP/'
Linear algebra and polynomials using templates.
- * Arithmos `http://cant.ua.ac.be/old/arithmos/'
+ * Arithmos `http://www.win.ua.ac.be/~cant/arithmos/'
Rationals with infinities and square roots.
* CLN `http://www.ginac.de/CLN/'
High level classes for arithmetic.
+ * LiDIA `http://www.cdc.informatik.tu-darmstadt.de/TI/LiDIA/'
+ A C++ library for computational number theory.
+
* Linbox `http://www.linalg.org/'
Sparse vectors and matrices.
* NTL `http://www.shoup.net/ntl/'
A C++ number theory library.
-Eiffel
- * Eiffelroom `http://www.eiffelroom.org/node/442'
+Fortran
+ * Omni F77 `http://phase.hpcc.jp/Omni/home.html'
+ Arbitrary precision floats.
Haskell
- * Glasgow Haskell Compiler `https://www.haskell.org/ghc/'
+ * Glasgow Haskell Compiler `http://www.haskell.org/ghc/'
Java
- * Kaffe `https://github.com/kaffe/kaffe'
+ * Kaffe `http://www.kaffe.org/'
+
+ * Kissme `http://kissme.sourceforge.net/'
Lisp
- * GNU Common Lisp `https://www.gnu.org/software/gcl/gcl.html'
+ * GNU Common Lisp `http://www.gnu.org/software/gcl/gcl.html'
* Librep `http://librep.sourceforge.net/'
@@ -6219,13 +5891,13 @@ ML
* MLton compiler `http://mlton.org/'
Objective Caml
- * MLGMP `http://opam.ocamlpro.com/pkg/mlgmp.20120224.html'
+ * MLGMP `http://www.di.ens.fr/~monniaux/programmes.html.en'
* Numerix `http://pauillac.inria.fr/~quercia/'
Optionally using GMP.
Oz
- * Mozart `http://mozart.github.io/'
+ * Mozart `http://www.mozart-oz.org/'
Pascal
* GNU Pascal Compiler `http://www.gnu-pascal.de/'
@@ -6254,24 +5926,25 @@ Prolog
Arbitrary precision floats.
Python
- * GMPY `https://code.google.com/p/gmpy/'
+ * mpz module in the standard distribution,
+ `http://www.python.org/'
-Ruby
- * http://rubygems.org/gems/gmp
+ * GMPY `http://gmpy.sourceforge.net/'
Scheme
- * GNU Guile `https://www.gnu.org/software/guile/guile.html'
+ * GNU Guile (upcoming 1.8)
+ `http://www.gnu.org/software/guile/guile.html'
* RScheme `http://www.rscheme.org/'
- * STklos `http://www.stklos.net/'
+ * STklos `http://www.stklos.org/'
Smalltalk
* GNU Smalltalk
`http://www.smalltalk.org/versions/GNUSmalltalk.html'
Other
- * Axiom `https://savannah.nongnu.org/projects/axiom'
+ * Axiom `http://savannah.nongnu.org/projects/axiom'
Computer algebra using GCL.
* DrGenius `http://drgenius.seul.org/'
@@ -6280,23 +5953,26 @@ Other
* GiNaC `http://www.ginac.de/'
C++ computer algebra using CLN.
- * GOO `https://www.eecs.berkeley.edu/~jrb/goo/'
+ * GOO `http://www.googoogaga.org/'
Dynamic object oriented language.
- * Maxima `https://www.ma.utexas.edu/users/wfs/maxima.html'
+ * Maxima `http://www.ma.utexas.edu/users/wfs/maxima.html'
Macsyma computer algebra using GCL.
+ * Q `http://q-lang.sourceforge.net/'
+ Equational programming system.
+
* Regina `http://regina.sourceforge.net/'
Topological calculator.
- * Yacas `http://yacas.sourceforge.net'
+ * Yacas `http://www.xs4all.nl/~apinkus/yacas.html'
Yet another computer algebra system.

File: gmp.info, Node: Algorithms, Next: Internals, Prev: Language Bindings, Up: Top
-15 Algorithms
+16 Algorithms
*************
This chapter is an introduction to some of the algorithms used for
@@ -6321,25 +5997,23 @@ documented functions.

File: gmp.info, Node: Multiplication Algorithms, Next: Division Algorithms, Prev: Algorithms, Up: Algorithms
-15.1 Multiplication
+16.1 Multiplication
===================
-NxN limb multiplications and squares are done using one of seven
+NxN limb multiplications and squares are done using one of five
algorithms, as the size N increases.
Algorithm Threshold
Basecase (none)
- Karatsuba `MUL_TOOM22_THRESHOLD'
+ Karatsuba `MUL_KARATSUBA_THRESHOLD'
Toom-3 `MUL_TOOM33_THRESHOLD'
Toom-4 `MUL_TOOM44_THRESHOLD'
- Toom-6.5 `MUL_TOOM6H_THRESHOLD'
- Toom-8.5 `MUL_TOOM8H_THRESHOLD'
FFT `MUL_FFT_THRESHOLD'
Similarly for squaring, with the `SQR' thresholds.
NxM multiplications of operands with different sizes above
-`MUL_TOOM22_THRESHOLD' are currently done by special Toom-inspired
+`MUL_KARATSUBA_THRESHOLD' are currently done by special Toom-inspired
algorithms or directly with FFT, depending on operand size (*note
Unbalanced Multiplication::).
@@ -6349,7 +6023,6 @@ Unbalanced Multiplication::).
* Karatsuba Multiplication::
* Toom 3-Way Multiplication::
* Toom 4-Way Multiplication::
-* Higher degree Toom'n'half::
* FFT Multiplication::
* Other Multiplication::
* Unbalanced Multiplication::
@@ -6357,7 +6030,7 @@ Unbalanced Multiplication::).

File: gmp.info, Node: Basecase Multiplication, Next: Karatsuba Multiplication, Prev: Multiplication Algorithms, Up: Multiplication Algorithms
-15.1.1 Basecase Multiplication
+16.1.1 Basecase Multiplication
------------------------------
Basecase NxM multiplication is a straightforward rectangular set of
@@ -6402,7 +6075,7 @@ routine should be used always.

File: gmp.info, Node: Karatsuba Multiplication, Next: Toom 3-Way Multiplication, Prev: Basecase Multiplication, Up: Multiplication Algorithms
-15.1.2 Karatsuba Multiplication
+16.1.2 Karatsuba Multiplication
-------------------------------
The Karatsuba multiplication algorithm is described in Knuth section
@@ -6421,9 +6094,9 @@ length (or the most significant part one limb shorter if N is odd).
| y1 | y0 |
+----------+----------+
- Let b be the power of 2 where the split occurs, i.e. if x0 is k
-limbs (y0 the same) then b=2^(k*mp_bits_per_limb). With that x=x1*b+x0
-and y=y1*b+y0, and the following holds,
+ Let b be the power of 2 where the split occurs, ie. if x0 is k limbs
+(y0 the same) then b=2^(k*mp_bits_per_limb). With that x=x1*b+x0 and
+y=y1*b+y0, and the following holds,
x*y = (b^2+b)*x1*y1 - b*(x1-x0)*(y1-y0) + (b+1)*x0*y0
@@ -6470,7 +6143,7 @@ form above.
the exponent being log(3)/log(2), representing 3 multiplies each 1/2
the size of the inputs. This is a big improvement over the basecase
multiply at O(N^2) and the advantage soon overcomes the extra additions
-Karatsuba performs. `MUL_TOOM22_THRESHOLD' can be as little as 10
+Karatsuba performs. `MUL_KARATSUBA_THRESHOLD' can be as little as 10
limbs. The `SQR' threshold is usually about twice the `MUL'.
The basecase algorithm will take a time of the form M(N) = a*N^2 +
@@ -6487,7 +6160,7 @@ that sense the algorithm thresholds are merely of academic interest.

File: gmp.info, Node: Toom 3-Way Multiplication, Next: Toom 4-Way Multiplication, Prev: Karatsuba Multiplication, Up: Multiplication Algorithms
-15.1.3 Toom 3-Way Multiplication
+16.1.3 Toom 3-Way Multiplication
--------------------------------
The Karatsuba formula is the simplest case of a general approach to
@@ -6514,7 +6187,7 @@ These parts are treated as the coefficients of two polynomials
Y(t) = y2*t^2 + y1*t + y0
Let b equal the power of 2 which is the size of the x0, x1, y0 and
-y1 pieces, i.e. if they're k limbs each then b=2^(k*mp_bits_per_limb).
+y1 pieces, ie. if they're k limbs each then b=2^(k*mp_bits_per_limb).
With this x=X(b) and y=Y(b).
Let a polynomial W(t)=X(t)*Y(t) and suppose its coefficients are
@@ -6590,8 +6263,8 @@ steps for quickly isolating the w[i].
Squaring follows the same procedure as multiplication, but there's
only one X(t) and it's evaluated at the 5 points, and those values
squared to give values of W(t). The interpolation is then identical,
-and in fact the same `toom_interpolate_5pts' subroutine is used for
-both squaring and multiplying.
+and in fact the same `toom3_interpolate' subroutine is used for both
+squaring and multiplying.
Toom-3 is asymptotically O(N^1.465), the exponent being
log(5)/log(3), representing 5 recursive multiplies of 1/3 the original
@@ -6628,9 +6301,9 @@ but again doesn't have to be implemented that way and for example with
a bit of rearrangement just one division by 6 can be done.

-File: gmp.info, Node: Toom 4-Way Multiplication, Next: Higher degree Toom'n'half, Prev: Toom 3-Way Multiplication, Up: Multiplication Algorithms
+File: gmp.info, Node: Toom 4-Way Multiplication, Next: FFT Multiplication, Prev: Toom 3-Way Multiplication, Up: Multiplication Algorithms
-15.1.4 Toom 4-Way Multiplication
+16.1.4 Toom 4-Way Multiplication
--------------------------------
Karatsuba and Toom-3 split the operands into 2 and 3 coefficients,
@@ -6662,41 +6335,14 @@ log(7)/log(4), representing 7 recursive multiplies of 1/4 the original
size each.

-File: gmp.info, Node: Higher degree Toom'n'half, Next: FFT Multiplication, Prev: Toom 4-Way Multiplication, Up: Multiplication Algorithms
-
-15.1.5 Higher degree Toom'n'half
---------------------------------
+File: gmp.info, Node: FFT Multiplication, Next: Other Multiplication, Prev: Toom 4-Way Multiplication, Up: Multiplication Algorithms
-The Toom algorithms described above (*note Toom 3-Way Multiplication::,
-*note Toom 4-Way Multiplication::) generalizes to split into an
-arbitrary number of pieces. In general a split of two equally long
-operands into r pieces leads to evaluations and pointwise
-multiplications done at 2*r-1 points. To fully exploit symmetries it
-would be better to have a multiple of 4 points, that's why for higher
-degree Toom'n'half is used.
-
- Toom'n'half means that the existence of one more piece is considered
-for a single operand. It can be virtual, i.e. zero, or real, when the
-two operand are not exactly balanced. By choosing an even r, Toom-r+1/2
-requires 2r points, a multiple of four.
-
- The four-plets of points include 0, inf, +1, -1 and +-2^i, +-2^-i .
-Each of them giving shortcuts for the evaluation phase and for some
-steps in the interpolation phase. Further tricks are used to reduce the
-memory footprint of the whole multiplication algorithm to a memory
-buffer equanl in size to the result of the product.
-
- Current GMP uses both Toom-6'n'half and Toom-8'n'half.
-
-
-File: gmp.info, Node: FFT Multiplication, Next: Other Multiplication, Prev: Higher degree Toom'n'half, Up: Multiplication Algorithms
-
-15.1.6 FFT Multiplication
+16.1.5 FFT Multiplication
-------------------------
At large to very large sizes a Fermat style FFT multiplication is used,
-following Schönhage and Strassen (*note References::). Descriptions of
-FFTs in various forms can be found in many textbooks, for instance
+following Scho"nhage and Strassen (*note References::). Descriptions
+of FFTs in various forms can be found in many textbooks, for instance
Knuth section 4.3.3 part C or Lipson chapter IX. A brief description
of the form used in GMP is given here.
@@ -6728,13 +6374,13 @@ choice of N' ensures these sums aren't truncated.
The points used for the evaluation are g^i for i=0 to 2^k-1 where
g=2^(2N'/2^k). g is a 2^k'th root of unity mod 2^N'+1, which produces
necessary cancellations at the interpolation stage, and it's also a
-power of 2 so the fast Fourier transforms used for the evaluation and
+power of 2 so the fast fourier transforms used for the evaluation and
interpolation do only shifts, adds and negations.
The pointwise multiplications are done modulo 2^N'+1 and either
recurse into a further FFT or use a plain multiplication (Toom-3,
Karatsuba or basecase), whichever is optimal at the size N'. The
-interpolation is an inverse fast Fourier transform. The resulting set
+interpolation is an inverse fast fourier transform. The resulting set
of sums of x[i]*y[j] are added at appropriate offsets to give the final
result.
@@ -6795,7 +6441,7 @@ will be needed.

File: gmp.info, Node: Other Multiplication, Next: Unbalanced Multiplication, Prev: FFT Multiplication, Up: Multiplication Algorithms
-15.1.7 Other Multiplication
+16.1.6 Other Multiplication
---------------------------
The Toom algorithms described above (*note Toom 3-Way Multiplication::,
@@ -6825,10 +6471,10 @@ multipliers at C8 become 2*t*j-j^2.
can be thought of as using -1 as a square root of unity. If a 4th root
of unity was available then a further split and speedup would be
possible, but no such root exists for plain integers. Going to complex
-integers with i=sqrt(-1) doesn't help, essentially because in Cartesian
+integers with i=sqrt(-1) doesn't help, essentially because in cartesian
form it takes three real multiplies to do a complex multiply. The
existence of 2^k'th roots of unity in a suitable ring or field lets the
-fast Fourier transform keep splitting and get to O(N*log(r)).
+fast fourier transform keep splitting and get to O(N*log(r)).
Floating point FFTs use complex numbers approximating Nth roots of
unity. Some processors have special support for such FFTs. But these
@@ -6840,11 +6486,11 @@ is of course of vital importance to GMP.

File: gmp.info, Node: Unbalanced Multiplication, Prev: Other Multiplication, Up: Multiplication Algorithms
-15.1.8 Unbalanced Multiplication
+16.1.7 Unbalanced Multiplication
--------------------------------
Multiplication of operands with different sizes, both below
-`MUL_TOOM22_THRESHOLD' are done with plain schoolbook multiplication
+`MUL_KARATSUBA_THRESHOLD' are done with plain schoolbook multiplication
(*note Basecase Multiplication::).
For really large operands, we invoke FFT directly.
@@ -6859,7 +6505,7 @@ coefficients, i.e., a polynomial of degree 1 to 3.

File: gmp.info, Node: Division Algorithms, Next: Greatest Common Divisor Algorithms, Prev: Multiplication Algorithms, Up: Algorithms
-15.2 Division Algorithms
+16.2 Division Algorithms
========================
* Menu:
@@ -6867,7 +6513,6 @@ File: gmp.info, Node: Division Algorithms, Next: Greatest Common Divisor Algor
* Single Limb Division::
* Basecase Division::
* Divide and Conquer Division::
-* Block-Wise Barrett Division::
* Exact Division::
* Exact Remainder::
* Small Quotient Division::
@@ -6875,7 +6520,7 @@ File: gmp.info, Node: Division Algorithms, Next: Greatest Common Divisor Algor

File: gmp.info, Node: Single Limb Division, Next: Basecase Division, Prev: Division Algorithms, Up: Division Algorithms
-15.2.1 Single Limb Division
+16.2.1 Single Limb Division
---------------------------
Nx1 division is implemented using repeated 2x1 divisions from high to
@@ -6883,7 +6528,7 @@ low, either with a hardware divide instruction or a multiplication by
inverse, whichever is best on a given CPU.
The multiply by inverse follows "Improved division by invariant
-integers" by Möller and Granlund (*note References::) and is
+integers" by Mo"ller and Granlund (*note References::) and is
implemented as `udiv_qrnnd_preinv' in `gmp-impl.h'. The idea is to
have a fixed-point approximation to 1/d (see `invert_limb') and then
multiply by the high limb (plus one bit) of the dividend to get a
@@ -6929,7 +6574,7 @@ pipelined.

File: gmp.info, Node: Basecase Division, Next: Divide and Conquer Division, Prev: Single Limb Division, Up: Division Algorithms
-15.2.2 Basecase Division
+16.2.2 Basecase Division
------------------------
Basecase NxM division is like long division done by hand, but in base
@@ -6942,7 +6587,7 @@ the top end of the dividend. With a normalized divisor (most
significant bit set), each quotient limb can be formed with a 2x1
division and a 1x1 multiplication plus some subtractions. The 2x1
division is by the high limb of the divisor and is done either with a
-hardware divide or a multiply by inverse (the same as in *note Single
+hardware divide or a multiply by inverse (the same as in *Note Single
Limb Division::) whichever is faster. Such a quotient is sometimes one
too big, requiring an addback of the divisor, but that happens rarely.
@@ -6952,12 +6597,12 @@ multiplication, differing in fact only in the extra multiply and divide
for each of the Q quotient limbs.

-File: gmp.info, Node: Divide and Conquer Division, Next: Block-Wise Barrett Division, Prev: Basecase Division, Up: Division Algorithms
+File: gmp.info, Node: Divide and Conquer Division, Next: Exact Division, Prev: Basecase Division, Up: Division Algorithms
-15.2.3 Divide and Conquer Division
+16.2.3 Divide and Conquer Division
----------------------------------
-For divisors larger than `DC_DIV_QR_THRESHOLD', division is done by
+For divisors larger than `DIV_DC_THRESHOLD', division is done by
dividing. Or to be precise by a recursive divide and conquer algorithm
based on work by Moenck and Borodin, Jebelean, and Burnikel and Ziegler
(*note References::).
@@ -6974,12 +6619,12 @@ formed by recursive Nx(N/2) divisions.
then the work is about the same as a basecase division, but with more
function call overheads and with some subtractions separated from the
multiplies. These overheads mean that it's only when N/2 is above
-`MUL_TOOM22_THRESHOLD' that divide and conquer is of use.
+`MUL_KARATSUBA_THRESHOLD' that divide and conquer is of use.
- `DC_DIV_QR_THRESHOLD' is based on the divisor size N, so it will be
-somewhere above twice `MUL_TOOM22_THRESHOLD', but how much above
+ `DIV_DC_THRESHOLD' is based on the divisor size N, so it will be
+somewhere above twice `MUL_KARATSUBA_THRESHOLD', but how much above
depends on the CPU. An optimized `mpn_mul_basecase' can lower
-`DC_DIV_QR_THRESHOLD' a little by offering a ready-made advantage over
+`DIV_DC_THRESHOLD' a little by offering a ready-made advantage over
repeated `mpn_submul_1' calls.
Divide and conquer is asymptotically O(M(N)*log(N)) where M(N) is
@@ -6991,26 +6636,14 @@ algorithms the M(N) term improves and the multiplier tends to log(N).
In practice, at moderate to large sizes, a 2NxN division is about 2 to
4 times slower than an NxN multiplication.
-
-File: gmp.info, Node: Block-Wise Barrett Division, Next: Exact Division, Prev: Divide and Conquer Division, Up: Division Algorithms
-
-15.2.4 Block-Wise Barrett Division
-----------------------------------
-
-For the largest divisions, a block-wise Barrett division algorithm is
-used. Here, the divisor is inverted to a precision determined by the
-relative size of the dividend and divisor. Blocks of quotient limbs
-are then generated by multiplying blocks from the dividend by the
-inverse.
-
- Our block-wise algorithm computes a smaller inverse than in the
-plain Barrett algorithm. For a 2n/n division, the inverse will be just
-ceil(n/2) limbs.
+ Newton's method used for division is asymptotically O(M(N)) and
+should therefore be superior to divide and conquer, but it's believed
+this would only be for large to very large N.

-File: gmp.info, Node: Exact Division, Next: Exact Remainder, Prev: Block-Wise Barrett Division, Up: Division Algorithms
+File: gmp.info, Node: Exact Division, Next: Exact Remainder, Prev: Divide and Conquer Division, Up: Division Algorithms
-15.2.5 Exact Division
+16.2.4 Exact Division
---------------------
A so-called exact division is when the dividend is known to be an exact
@@ -7043,10 +6676,11 @@ Q*M-M*(M+1)/2, or when Q<=M to Q*(Q-1)/2. Notice the savings are
complementary. If Q is big then many divisions are saved, or if Q is
small then the crossproducts reduce to a small number.
- The modular inverse used is calculated efficiently by `binvert_limb'
-in `gmp-impl.h'. This does four multiplies for a 32-bit limb, or six
-for a 64-bit limb. `tune/modlinv.c' has some alternate implementations
-that might suit processors better at bit twiddling than multiplying.
+ The modular inverse used is calculated efficiently by
+`modlimb_invert' in `gmp-impl.h'. This does four multiplies for a
+32-bit limb, or six for a 64-bit limb. `tune/modlinv.c' has some
+alternate implementations that might suit processors better at bit
+twiddling than multiplying.
The sub-quadratic exact division described by Jebelean in "Exact
Division with Karatsuba Complexity" is not currently implemented. It
@@ -7066,8 +6700,364 @@ limb. The multiplications don't need to be on the dependent chain, as
long as the effect of the borrows is applied, which can help chips with
pipelined multipliers.
+
+File: gmp.info, Node: Exact Remainder, Next: Small Quotient Division, Prev: Exact Division, Up: Division Algorithms
+
+16.2.5 Exact Remainder
+----------------------
+
+If the exact division algorithm is done with a full subtraction at each
+stage and the dividend isn't a multiple of the divisor, then low zero
+limbs are produced but with a remainder in the high limbs. For
+dividend a, divisor d, quotient q, and b = 2^mp_bits_per_limb, this
+remainder r is of the form
+
+ a = q*d + r*b^n
+
+ n represents the number of zero limbs produced by the subtractions,
+that being the number of limbs produced for q. r will be in the range
+0<=r<d and can be viewed as a remainder, but one shifted up by a factor
+of b^n.
+
+ Carrying out full subtractions at each stage means the same number
+of cross products must be done as a normal division, but there's still
+some single limb divisions saved. When d is a single limb some
+simplifications arise, providing good speedups on a number of
+processors.
+
+ `mpn_bdivmod', `mpn_divexact_by3', `mpn_modexact_1_odd' and the
+`redc' function in `mpz_powm' differ subtly in how they return r,
+leading to some negations in the above formula, but all are essentially
+the same.
+
+ Clearly r is zero when a is a multiple of d, and this leads to
+divisibility or congruence tests which are potentially more efficient
+than a normal division.
+
+ The factor of b^n on r can be ignored in a GCD when d is odd, hence
+the use of `mpn_bdivmod' in `mpn_gcd', and the use of
+`mpn_modexact_1_odd' by `mpn_gcd_1' and `mpz_kronecker_ui' etc (*note
+Greatest Common Divisor Algorithms::).
+
+ Montgomery's REDC method for modular multiplications uses operands
+of the form of x*b^-n and y*b^-n and on calculating (x*b^-n)*(y*b^-n)
+uses the factor of b^n in the exact remainder to reach a product in the
+same form (x*y)*b^-n (*note Modular Powering Algorithm::).
+
+ Notice that r generally gives no useful information about the
+ordinary remainder a mod d since b^n mod d could be anything. If
+however b^n == 1 mod d, then r is the negative of the ordinary
+remainder. This occurs whenever d is a factor of b^n-1, as for example
+with 3 in `mpn_divexact_by3'. For a 32 or 64 bit limb other such
+factors include 5, 17 and 257, but no particular use has been found for
+this.
+
+
+File: gmp.info, Node: Small Quotient Division, Prev: Exact Remainder, Up: Division Algorithms
+
+16.2.6 Small Quotient Division
+------------------------------
+
+An NxM division where the number of quotient limbs Q=N-M is small can
+be optimized somewhat.
+
+ An ordinary basecase division normalizes the divisor by shifting it
+to make the high bit set, shifting the dividend accordingly, and
+shifting the remainder back down at the end of the calculation. This
+is wasteful if only a few quotient limbs are to be formed. Instead a
+division of just the top 2*Q limbs of the dividend by the top Q limbs
+of the divisor can be used to form a trial quotient. This requires
+only those limbs normalized, not the whole of the divisor and dividend.
+
+ A multiply and subtract then applies the trial quotient to the M-Q
+unused limbs of the divisor and N-Q dividend limbs (which includes Q
+limbs remaining from the trial quotient division). The starting trial
+quotient can be 1 or 2 too big, but all cases of 2 too big and most
+cases of 1 too big are detected by first comparing the most significant
+limbs that will arise from the subtraction. An addback is done if the
+quotient still turns out to be 1 too big.
+
+ This whole procedure is essentially the same as one step of the
+basecase algorithm done in a Q limb base, though with the trial
+quotient test done only with the high limbs, not an entire Q limb
+"digit" product. The correctness of this weaker test can be
+established by following the argument of Knuth section 4.3.1 exercise
+20 but with the v2*q>b*r+u2 condition appropriately relaxed.
+
+
+File: gmp.info, Node: Greatest Common Divisor Algorithms, Next: Powering Algorithms, Prev: Division Algorithms, Up: Algorithms
+
+16.3 Greatest Common Divisor
+============================
+
+* Menu:
+
+* Binary GCD::
+* Lehmer's Algorithm::
+* Subquadratic GCD::
+* Extended GCD::
+* Jacobi Symbol::
+
+
+File: gmp.info, Node: Binary GCD, Next: Lehmer's Algorithm, Prev: Greatest Common Divisor Algorithms, Up: Greatest Common Divisor Algorithms
+
+16.3.1 Binary GCD
+-----------------
+
+At small sizes GMP uses an O(N^2) binary style GCD. This is described
+in many textbooks, for example Knuth section 4.5.2 algorithm B. It
+simply consists of successively reducing odd operands a and b using
+
+ a,b = abs(a-b),min(a,b)
+ strip factors of 2 from a
+
+ The Euclidean GCD algorithm, as per Knuth algorithms E and A,
+repeatedly computes the quotient q = floor(a/b) and replaces a,b by v,
+u - q v. The binary algorithm has so far been found to be faster than
+the Euclidean algorithm everywhere. One reason the binary method does
+well is that the implied quotient at each step is usually small, so
+often only one or two subtractions are needed to get the same effect as
+a division. Quotients 1, 2 and 3 for example occur 67.7% of the time,
+see Knuth section 4.5.3 Theorem E.
+
+ When the implied quotient is large, meaning b is much smaller than
+a, then a division is worthwhile. This is the basis for the initial a
+mod b reductions in `mpn_gcd' and `mpn_gcd_1' (the latter for both Nx1
+and 1x1 cases). But after that initial reduction, big quotients occur
+too rarely to make it worth checking for them.
+
+
+ The final 1x1 GCD in `mpn_gcd_1' is done in the generic C code as
+described above. For two N-bit operands, the algorithm takes about
+0.68 iterations per bit. For optimum performance some attention needs
+to be paid to the way the factors of 2 are stripped from a.
+
+ Firstly it may be noted that in twos complement the number of low
+zero bits on a-b is the same as b-a, so counting or testing can begin on
+a-b without waiting for abs(a-b) to be determined.
+
+ A loop stripping low zero bits tends not to branch predict well,
+since the condition is data dependent. But on average there's only a
+few low zeros, so an option is to strip one or two bits arithmetically
+then loop for more (as done for AMD K6). Or use a lookup table to get
+a count for several bits then loop for more (as done for AMD K7). An
+alternative approach is to keep just one of a or b odd and iterate
+
+ a,b = abs(a-b), min(a,b)
+ a = a/2 if even
+ b = b/2 if even
+
+ This requires about 1.25 iterations per bit, but stripping of a
+single bit at each step avoids any branching. Repeating the bit strip
+reduces to about 0.9 iterations per bit, which may be a worthwhile
+tradeoff.
+
+ Generally with the above approaches a speed of perhaps 6 cycles per
+bit can be achieved, which is still not terribly fast with for instance
+a 64-bit GCD taking nearly 400 cycles. It's this sort of time which
+means it's not usually advantageous to combine a set of divisibility
+tests into a GCD.
+
+ Currently, the binary algorithm is used for GCD only when N < 3.
+
+
+File: gmp.info, Node: Lehmer's Algorithm, Next: Subquadratic GCD, Prev: Binary GCD, Up: Greatest Common Divisor Algorithms
+
+16.3.2 Lehmer's algorithm
+-------------------------
+
+Lehmer's improvement of the Euclidean algorithms is based on the
+observation that the initial part of the quotient sequence depends only
+on the most significant parts of the inputs. The variant of Lehmer's
+algorithm used in GMP splits off the most significant two limbs, as
+suggested, e.g., in "A Double-Digit Lehmer-Euclid Algorithm" by
+Jebelean (*note References::). The quotients of two double-limb inputs
+are collected as a 2 by 2 matrix with single-limb elements. This is
+done by the function `mpn_hgcd2'. The resulting matrix is applied to
+the inputs using `mpn_mul_1' and `mpn_submul_1'. Each iteration usually
+reduces the inputs by almost one limb. In the rare case of a large
+quotient, no progress can be made by examining just the most
+significant two limbs, and the quotient is computing using plain
+division.
+
+ The resulting algorithm is asymptotically O(N^2), just as the
+Euclidean algorithm and the binary algorithm. The quadratic part of the
+work are the calls to `mpn_mul_1' and `mpn_submul_1'. For small sizes,
+the linear work is also significant. There are roughly N calls to the
+`mpn_hgcd2' function. This function uses a couple of important
+optimizations:
+
+ * It uses the same relaxed notion of correctness as `mpn_hgcd' (see
+ next section). This means that when called with the most
+ significant two limbs of two large numbers, the returned matrix
+ does not always correspond exactly to the initial quotient
+ sequence for the two large numbers; the final quotient may
+ sometimes be one off.
+
+ * It takes advantage of the fact the quotients are usually small.
+ The division operator is not used, since the corresponding
+ assembler instruction is very slow on most architectures. (This
+ code could probably be improved further, it uses many branches
+ that are unfriendly to prediction).
+
+ * It switches from double-limb calculations to single-limb
+ calculations half-way through, when the input numbers have been
+ reduced in size from two limbs to one and a half.
+
+
+
+File: gmp.info, Node: Subquadratic GCD, Next: Extended GCD, Prev: Lehmer's Algorithm, Up: Greatest Common Divisor Algorithms
+
+16.3.3 Subquadratic GCD
+-----------------------
+
+For inputs larger than `GCD_DC_THRESHOLD', GCD is computed via the HGCD
+(Half GCD) function, as a generalization to Lehmer's algorithm.
+
+ Let the inputs a,b be of size N limbs each. Put S = floor(N/2) + 1.
+Then HGCD(a,b) returns a transformation matrix T with non-negative
+elements, and reduced numbers (c;d) = T^-1 (a;b). The reduced numbers
+c,d must be larger than S limbs, while their difference abs(c-d) must
+fit in S limbs. The matrix elements will also be of size roughly N/2.
+
+ The HGCD base case uses Lehmer's algorithm, but with the above stop
+condition that returns reduced numbers and the corresponding
+transformation matrix half-way through. For inputs larger than
+`HGCD_THRESHOLD', HGCD is computed recursively, using the divide and
+conquer algorithm in "On Scho"nhage's algorithm and subquadratic
+integer GCD computation" by Mo"ller (*note References::). The recursive
+algorithm consists of these main steps.
+
+ * Call HGCD recursively, on the most significant N/2 limbs. Apply the
+ resulting matrix T_1 to the full numbers, reducing them to a size
+ just above 3N/2.
+
+ * Perform a small number of division or subtraction steps to reduce
+ the numbers to size below 3N/2. This is essential mainly for the
+ unlikely case of large quotients.
+
+ * Call HGCD recursively, on the most significant N/2 limbs of the
+ reduced numbers. Apply the resulting matrix T_2 to the full
+ numbers, reducing them to a size just above N/2.
+
+ * Compute T = T_1 T_2.
+
+ * Perform a small number of division and subtraction steps to
+ satisfy the requirements, and return.
+
+ GCD is then implemented as a loop around HGCD, similarly to Lehmer's
+algorithm. Where Lehmer repeatedly chops off the top two limbs, calls
+`mpn_hgcd2', and applies the resulting matrix to the full numbers, the
+subquadratic GCD chops off the most significant third of the limbs (the
+proportion is a tuning parameter, and 1/3 seems to be more efficient
+than, e.g, 1/2), calls `mpn_hgcd', and applies the resulting matrix.
+Once the input numbers are reduced to size below `GCD_DC_THRESHOLD',
+Lehmer's algorithm is used for the rest of the work.
+
+ The asymptotic running time of both HGCD and GCD is O(M(N)*log(N)),
+where M(N) is the time for multiplying two N-limb numbers.
+
+
+File: gmp.info, Node: Extended GCD, Next: Jacobi Symbol, Prev: Subquadratic GCD, Up: Greatest Common Divisor Algorithms
+
+16.3.4 Extended GCD
+-------------------
+
+The extended GCD function, or GCDEXT, calculates gcd(a,b) and also
+cofactors x and y satisfying a*x+b*y=gcd(a,b). All the algorithms used
+for plain GCD are extended to handle this case. The binary algorithm is
+used only for single-limb GCDEXT. Lehmer's algorithm is used for sizes
+up to `GCDEXT_DC_THRESHOLD'. Above this threshold, GCDEXT is
+implemented as a loop around HGCD, but with more book-keeping to keep
+track of the cofactors. This gives the same asymptotic running time as
+for GCD and HGCD, O(M(N)*log(N))
+
+ One difference to plain GCD is that while the inputs a and b are
+reduced as the algorithm proceeds, the cofactors x and y grow in size.
+This makes the tuning of the chopping-point more difficult. The current
+code chops off the most significant half of the inputs for the call to
+HGCD in the first iteration, and the most significant two thirds for
+the remaining calls. This strategy could surely be improved. Also the
+stop condition for the loop, where Lehmer's algorithm is invoked once
+the inputs are reduced below `GCDEXT_DC_THRESHOLD', could maybe be
+improved by taking into account the current size of the cofactors.

-Local Variables:
-coding: iso-8859-1
-End:
+File: gmp.info, Node: Jacobi Symbol, Prev: Extended GCD, Up: Greatest Common Divisor Algorithms
+
+16.3.5 Jacobi Symbol
+--------------------
+
+`mpz_jacobi' and `mpz_kronecker' are currently implemented with a
+simple binary algorithm similar to that described for the GCDs (*note
+Binary GCD::). They're not very fast when both inputs are large.
+Lehmer's multi-step improvement or a binary based multi-step algorithm
+is likely to be better.
+
+ When one operand fits a single limb, and that includes
+`mpz_kronecker_ui' and friends, an initial reduction is done with
+either `mpn_mod_1' or `mpn_modexact_1_odd', followed by the binary
+algorithm on a single limb. The binary algorithm is well suited to a
+single limb, and the whole calculation in this case is quite efficient.
+
+ In all the routines sign changes for the result are accumulated
+using some bit twiddling, avoiding table lookups or conditional jumps.
+
+
+File: gmp.info, Node: Powering Algorithms, Next: Root Extraction Algorithms, Prev: Greatest Common Divisor Algorithms, Up: Algorithms
+
+16.4 Powering Algorithms
+========================
+
+* Menu:
+
+* Normal Powering Algorithm::
+* Modular Powering Algorithm::
+
+
+File: gmp.info, Node: Normal Powering Algorithm, Next: Modular Powering Algorithm, Prev: Powering Algorithms, Up: Powering Algorithms
+
+16.4.1 Normal Powering
+----------------------
+
+Normal `mpz' or `mpf' powering uses a simple binary algorithm,
+successively squaring and then multiplying by the base when a 1 bit is
+seen in the exponent, as per Knuth section 4.6.3. The "left to right"
+variant described there is used rather than algorithm A, since it's
+just as easy and can be done with somewhat less temporary memory.
+
+
+File: gmp.info, Node: Modular Powering Algorithm, Prev: Normal Powering Algorithm, Up: Powering Algorithms
+
+16.4.2 Modular Powering
+-----------------------
+
+Modular powering is implemented using a 2^k-ary sliding window
+algorithm, as per "Handbook of Applied Cryptography" algorithm 14.85
+(*note References::). k is chosen according to the size of the
+exponent. Larger exponents use larger values of k, the choice being
+made to minimize the average number of multiplications that must
+supplement the squaring.
+
+ The modular multiplies and squares use either a simple division or
+the REDC method by Montgomery (*note References::). REDC is a little
+faster, essentially saving N single limb divisions in a fashion similar
+to an exact remainder (*note Exact Remainder::). The current REDC has
+some limitations. It's only O(N^2) so above `POWM_THRESHOLD' division
+becomes faster and is used. It doesn't attempt to detect small bases,
+but rather always uses a REDC form, which is usually a full size
+operand. And lastly it's only applied to odd moduli.
+
+
+File: gmp.info, Node: Root Extraction Algorithms, Next: Radix Conversion Algorithms, Prev: Powering Algorithms, Up: Algorithms
+
+16.5 Root Extraction Algorithms
+===============================
+
+* Menu:
+
+* Square Root Algorithm::
+* Nth Root Algorithm::
+* Perfect Square Algorithm::
+* Perfect Power Algorithm::
+
diff --git a/gmp/doc/gmp.info-2 b/gmp/doc/gmp.info-2
index 9dd7c34407..a92b89ff4c 100644
--- a/gmp/doc/gmp.info-2
+++ b/gmp/doc/gmp.info-2
@@ -1,10 +1,12 @@
-This is ../../gmp/doc/gmp.info, produced by makeinfo version 4.13 from
+This is ../../gmp/doc/gmp.info, produced by makeinfo version 4.8 from
../../gmp/doc/gmp.texi.
-This manual describes how to install and use the GNU multiple precision
-arithmetic library, version 6.0.0.
+ This manual describes how to install and use the GNU multiple
+precision arithmetic library, version 4.3.2.
- Copyright 1991, 1993-2014 Free Software Foundation, Inc.
+ Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
+Foundation, Inc.
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version
@@ -12,7 +14,7 @@ document under the terms of the GNU Free Documentation License, Version
with no Invariant Sections, with the Front-Cover Texts being "A GNU
Manual", and with the Back-Cover Texts being "You have freedom to copy
and modify this GNU Manual, like GNU software". A copy of the license
-is included in *note GNU Free Documentation License::.
+is included in *Note GNU Free Documentation License::.
INFO-DIR-SECTION GNU libraries
START-INFO-DIR-ENTRY
@@ -20,368 +22,9 @@ START-INFO-DIR-ENTRY
END-INFO-DIR-ENTRY

-File: gmp.info, Node: Exact Remainder, Next: Small Quotient Division, Prev: Exact Division, Up: Division Algorithms
-
-15.2.6 Exact Remainder
-----------------------
-
-If the exact division algorithm is done with a full subtraction at each
-stage and the dividend isn't a multiple of the divisor, then low zero
-limbs are produced but with a remainder in the high limbs. For
-dividend a, divisor d, quotient q, and b = 2^mp_bits_per_limb, this
-remainder r is of the form
-
- a = q*d + r*b^n
-
- n represents the number of zero limbs produced by the subtractions,
-that being the number of limbs produced for q. r will be in the range
-0<=r<d and can be viewed as a remainder, but one shifted up by a factor
-of b^n.
-
- Carrying out full subtractions at each stage means the same number
-of cross products must be done as a normal division, but there's still
-some single limb divisions saved. When d is a single limb some
-simplifications arise, providing good speedups on a number of
-processors.
-
- The functions `mpn_divexact_by3', `mpn_modexact_1_odd' and the
-internal `mpn_redc_X' functions differ subtly in how they return r,
-leading to some negations in the above formula, but all are essentially
-the same.
-
- Clearly r is zero when a is a multiple of d, and this leads to
-divisibility or congruence tests which are potentially more efficient
-than a normal division.
-
- The factor of b^n on r can be ignored in a GCD when d is odd, hence
-the use of `mpn_modexact_1_odd' by `mpn_gcd_1' and `mpz_kronecker_ui'
-etc (*note Greatest Common Divisor Algorithms::).
-
- Montgomery's REDC method for modular multiplications uses operands
-of the form of x*b^-n and y*b^-n and on calculating (x*b^-n)*(y*b^-n)
-uses the factor of b^n in the exact remainder to reach a product in the
-same form (x*y)*b^-n (*note Modular Powering Algorithm::).
-
- Notice that r generally gives no useful information about the
-ordinary remainder a mod d since b^n mod d could be anything. If
-however b^n == 1 mod d, then r is the negative of the ordinary
-remainder. This occurs whenever d is a factor of b^n-1, as for example
-with 3 in `mpn_divexact_by3'. For a 32 or 64 bit limb other such
-factors include 5, 17 and 257, but no particular use has been found for
-this.
-
-
-File: gmp.info, Node: Small Quotient Division, Prev: Exact Remainder, Up: Division Algorithms
-
-15.2.7 Small Quotient Division
-------------------------------
-
-An NxM division where the number of quotient limbs Q=N-M is small can
-be optimized somewhat.
-
- An ordinary basecase division normalizes the divisor by shifting it
-to make the high bit set, shifting the dividend accordingly, and
-shifting the remainder back down at the end of the calculation. This
-is wasteful if only a few quotient limbs are to be formed. Instead a
-division of just the top 2*Q limbs of the dividend by the top Q limbs
-of the divisor can be used to form a trial quotient. This requires
-only those limbs normalized, not the whole of the divisor and dividend.
-
- A multiply and subtract then applies the trial quotient to the M-Q
-unused limbs of the divisor and N-Q dividend limbs (which includes Q
-limbs remaining from the trial quotient division). The starting trial
-quotient can be 1 or 2 too big, but all cases of 2 too big and most
-cases of 1 too big are detected by first comparing the most significant
-limbs that will arise from the subtraction. An addback is done if the
-quotient still turns out to be 1 too big.
-
- This whole procedure is essentially the same as one step of the
-basecase algorithm done in a Q limb base, though with the trial
-quotient test done only with the high limbs, not an entire Q limb
-"digit" product. The correctness of this weaker test can be
-established by following the argument of Knuth section 4.3.1 exercise
-20 but with the v2*q>b*r+u2 condition appropriately relaxed.
-
-
-File: gmp.info, Node: Greatest Common Divisor Algorithms, Next: Powering Algorithms, Prev: Division Algorithms, Up: Algorithms
-
-15.3 Greatest Common Divisor
-============================
-
-* Menu:
-
-* Binary GCD::
-* Lehmer's Algorithm::
-* Subquadratic GCD::
-* Extended GCD::
-* Jacobi Symbol::
-
-
-File: gmp.info, Node: Binary GCD, Next: Lehmer's Algorithm, Prev: Greatest Common Divisor Algorithms, Up: Greatest Common Divisor Algorithms
-
-15.3.1 Binary GCD
------------------
-
-At small sizes GMP uses an O(N^2) binary style GCD. This is described
-in many textbooks, for example Knuth section 4.5.2 algorithm B. It
-simply consists of successively reducing odd operands a and b using
-
- a,b = abs(a-b),min(a,b)
- strip factors of 2 from a
-
- The Euclidean GCD algorithm, as per Knuth algorithms E and A,
-repeatedly computes the quotient q = floor(a/b) and replaces a,b by v,
-u - q v. The binary algorithm has so far been found to be faster than
-the Euclidean algorithm everywhere. One reason the binary method does
-well is that the implied quotient at each step is usually small, so
-often only one or two subtractions are needed to get the same effect as
-a division. Quotients 1, 2 and 3 for example occur 67.7% of the time,
-see Knuth section 4.5.3 Theorem E.
-
- When the implied quotient is large, meaning b is much smaller than
-a, then a division is worthwhile. This is the basis for the initial a
-mod b reductions in `mpn_gcd' and `mpn_gcd_1' (the latter for both Nx1
-and 1x1 cases). But after that initial reduction, big quotients occur
-too rarely to make it worth checking for them.
-
-
- The final 1x1 GCD in `mpn_gcd_1' is done in the generic C code as
-described above. For two N-bit operands, the algorithm takes about
-0.68 iterations per bit. For optimum performance some attention needs
-to be paid to the way the factors of 2 are stripped from a.
-
- Firstly it may be noted that in twos complement the number of low
-zero bits on a-b is the same as b-a, so counting or testing can begin on
-a-b without waiting for abs(a-b) to be determined.
-
- A loop stripping low zero bits tends not to branch predict well,
-since the condition is data dependent. But on average there's only a
-few low zeros, so an option is to strip one or two bits arithmetically
-then loop for more (as done for AMD K6). Or use a lookup table to get
-a count for several bits then loop for more (as done for AMD K7). An
-alternative approach is to keep just one of a or b odd and iterate
-
- a,b = abs(a-b), min(a,b)
- a = a/2 if even
- b = b/2 if even
-
- This requires about 1.25 iterations per bit, but stripping of a
-single bit at each step avoids any branching. Repeating the bit strip
-reduces to about 0.9 iterations per bit, which may be a worthwhile
-tradeoff.
-
- Generally with the above approaches a speed of perhaps 6 cycles per
-bit can be achieved, which is still not terribly fast with for instance
-a 64-bit GCD taking nearly 400 cycles. It's this sort of time which
-means it's not usually advantageous to combine a set of divisibility
-tests into a GCD.
-
- Currently, the binary algorithm is used for GCD only when N < 3.
-
-
-File: gmp.info, Node: Lehmer's Algorithm, Next: Subquadratic GCD, Prev: Binary GCD, Up: Greatest Common Divisor Algorithms
-
-15.3.2 Lehmer's algorithm
--------------------------
-
-Lehmer's improvement of the Euclidean algorithms is based on the
-observation that the initial part of the quotient sequence depends only
-on the most significant parts of the inputs. The variant of Lehmer's
-algorithm used in GMP splits off the most significant two limbs, as
-suggested, e.g., in "A Double-Digit Lehmer-Euclid Algorithm" by
-Jebelean (*note References::). The quotients of two double-limb inputs
-are collected as a 2 by 2 matrix with single-limb elements. This is
-done by the function `mpn_hgcd2'. The resulting matrix is applied to
-the inputs using `mpn_mul_1' and `mpn_submul_1'. Each iteration usually
-reduces the inputs by almost one limb. In the rare case of a large
-quotient, no progress can be made by examining just the most
-significant two limbs, and the quotient is computed using plain
-division.
-
- The resulting algorithm is asymptotically O(N^2), just as the
-Euclidean algorithm and the binary algorithm. The quadratic part of the
-work are the calls to `mpn_mul_1' and `mpn_submul_1'. For small sizes,
-the linear work is also significant. There are roughly N calls to the
-`mpn_hgcd2' function. This function uses a couple of important
-optimizations:
-
- * It uses the same relaxed notion of correctness as `mpn_hgcd' (see
- next section). This means that when called with the most
- significant two limbs of two large numbers, the returned matrix
- does not always correspond exactly to the initial quotient
- sequence for the two large numbers; the final quotient may
- sometimes be one off.
-
- * It takes advantage of the fact the quotients are usually small.
- The division operator is not used, since the corresponding
- assembler instruction is very slow on most architectures. (This
- code could probably be improved further, it uses many branches
- that are unfriendly to prediction).
-
- * It switches from double-limb calculations to single-limb
- calculations half-way through, when the input numbers have been
- reduced in size from two limbs to one and a half.
-
-
-
-File: gmp.info, Node: Subquadratic GCD, Next: Extended GCD, Prev: Lehmer's Algorithm, Up: Greatest Common Divisor Algorithms
-
-15.3.3 Subquadratic GCD
------------------------
-
-For inputs larger than `GCD_DC_THRESHOLD', GCD is computed via the HGCD
-(Half GCD) function, as a generalization to Lehmer's algorithm.
-
- Let the inputs a,b be of size N limbs each. Put S = floor(N/2) + 1.
-Then HGCD(a,b) returns a transformation matrix T with non-negative
-elements, and reduced numbers (c;d) = T^-1 (a;b). The reduced numbers
-c,d must be larger than S limbs, while their difference abs(c-d) must
-fit in S limbs. The matrix elements will also be of size roughly N/2.
-
- The HGCD base case uses Lehmer's algorithm, but with the above stop
-condition that returns reduced numbers and the corresponding
-transformation matrix half-way through. For inputs larger than
-`HGCD_THRESHOLD', HGCD is computed recursively, using the divide and
-conquer algorithm in "On Schönhage's algorithm and subquadratic integer
-GCD computation" by Möller (*note References::). The recursive
-algorithm consists of these main steps.
-
- * Call HGCD recursively, on the most significant N/2 limbs. Apply the
- resulting matrix T_1 to the full numbers, reducing them to a size
- just above 3N/2.
-
- * Perform a small number of division or subtraction steps to reduce
- the numbers to size below 3N/2. This is essential mainly for the
- unlikely case of large quotients.
-
- * Call HGCD recursively, on the most significant N/2 limbs of the
- reduced numbers. Apply the resulting matrix T_2 to the full
- numbers, reducing them to a size just above N/2.
-
- * Compute T = T_1 T_2.
-
- * Perform a small number of division and subtraction steps to
- satisfy the requirements, and return.
-
- GCD is then implemented as a loop around HGCD, similarly to Lehmer's
-algorithm. Where Lehmer repeatedly chops off the top two limbs, calls
-`mpn_hgcd2', and applies the resulting matrix to the full numbers, the
-subquadratic GCD chops off the most significant third of the limbs (the
-proportion is a tuning parameter, and 1/3 seems to be more efficient
-than, e.g, 1/2), calls `mpn_hgcd', and applies the resulting matrix.
-Once the input numbers are reduced to size below `GCD_DC_THRESHOLD',
-Lehmer's algorithm is used for the rest of the work.
-
- The asymptotic running time of both HGCD and GCD is O(M(N)*log(N)),
-where M(N) is the time for multiplying two N-limb numbers.
-
-
-File: gmp.info, Node: Extended GCD, Next: Jacobi Symbol, Prev: Subquadratic GCD, Up: Greatest Common Divisor Algorithms
-
-15.3.4 Extended GCD
--------------------
-
-The extended GCD function, or GCDEXT, calculates gcd(a,b) and also
-cofactors x and y satisfying a*x+b*y=gcd(a,b). All the algorithms used
-for plain GCD are extended to handle this case. The binary algorithm is
-used only for single-limb GCDEXT. Lehmer's algorithm is used for sizes
-up to `GCDEXT_DC_THRESHOLD'. Above this threshold, GCDEXT is
-implemented as a loop around HGCD, but with more book-keeping to keep
-track of the cofactors. This gives the same asymptotic running time as
-for GCD and HGCD, O(M(N)*log(N))
-
- One difference to plain GCD is that while the inputs a and b are
-reduced as the algorithm proceeds, the cofactors x and y grow in size.
-This makes the tuning of the chopping-point more difficult. The current
-code chops off the most significant half of the inputs for the call to
-HGCD in the first iteration, and the most significant two thirds for
-the remaining calls. This strategy could surely be improved. Also the
-stop condition for the loop, where Lehmer's algorithm is invoked once
-the inputs are reduced below `GCDEXT_DC_THRESHOLD', could maybe be
-improved by taking into account the current size of the cofactors.
-
-
-File: gmp.info, Node: Jacobi Symbol, Prev: Extended GCD, Up: Greatest Common Divisor Algorithms
-
-15.3.5 Jacobi Symbol
---------------------
-
-[This section is obsolete. The current Jacobi code actually uses a very
-efficient algorithm.]
-
- `mpz_jacobi' and `mpz_kronecker' are currently implemented with a
-simple binary algorithm similar to that described for the GCDs (*note
-Binary GCD::). They're not very fast when both inputs are large.
-Lehmer's multi-step improvement or a binary based multi-step algorithm
-is likely to be better.
-
- When one operand fits a single limb, and that includes
-`mpz_kronecker_ui' and friends, an initial reduction is done with
-either `mpn_mod_1' or `mpn_modexact_1_odd', followed by the binary
-algorithm on a single limb. The binary algorithm is well suited to a
-single limb, and the whole calculation in this case is quite efficient.
-
- In all the routines sign changes for the result are accumulated
-using some bit twiddling, avoiding table lookups or conditional jumps.
-
-
-File: gmp.info, Node: Powering Algorithms, Next: Root Extraction Algorithms, Prev: Greatest Common Divisor Algorithms, Up: Algorithms
-
-15.4 Powering Algorithms
-========================
-
-* Menu:
-
-* Normal Powering Algorithm::
-* Modular Powering Algorithm::
-
-
-File: gmp.info, Node: Normal Powering Algorithm, Next: Modular Powering Algorithm, Prev: Powering Algorithms, Up: Powering Algorithms
-
-15.4.1 Normal Powering
-----------------------
-
-Normal `mpz' or `mpf' powering uses a simple binary algorithm,
-successively squaring and then multiplying by the base when a 1 bit is
-seen in the exponent, as per Knuth section 4.6.3. The "left to right"
-variant described there is used rather than algorithm A, since it's
-just as easy and can be done with somewhat less temporary memory.
-
-
-File: gmp.info, Node: Modular Powering Algorithm, Prev: Normal Powering Algorithm, Up: Powering Algorithms
-
-15.4.2 Modular Powering
------------------------
-
-Modular powering is implemented using a 2^k-ary sliding window
-algorithm, as per "Handbook of Applied Cryptography" algorithm 14.85
-(*note References::). k is chosen according to the size of the
-exponent. Larger exponents use larger values of k, the choice being
-made to minimize the average number of multiplications that must
-supplement the squaring.
-
- The modular multiplies and squarings use either a simple division or
-the REDC method by Montgomery (*note References::). REDC is a little
-faster, essentially saving N single limb divisions in a fashion similar
-to an exact remainder (*note Exact Remainder::).
-
-
-File: gmp.info, Node: Root Extraction Algorithms, Next: Radix Conversion Algorithms, Prev: Powering Algorithms, Up: Algorithms
-
-15.5 Root Extraction Algorithms
-===============================
-
-* Menu:
-
-* Square Root Algorithm::
-* Nth Root Algorithm::
-* Perfect Square Algorithm::
-* Perfect Power Algorithm::
-
-
File: gmp.info, Node: Square Root Algorithm, Next: Nth Root Algorithm, Prev: Root Extraction Algorithms, Up: Root Extraction Algorithms
-15.5.1 Square Root
+16.5.1 Square Root
------------------
Square roots are taken using the "Karatsuba Square Root" algorithm by
@@ -435,7 +78,7 @@ precision given by `mpf_sqrt_ui' is obtained by padding with zero limbs.

File: gmp.info, Node: Nth Root Algorithm, Next: Perfect Square Algorithm, Prev: Square Root Algorithm, Up: Root Extraction Algorithms
-15.5.2 Nth Root
+16.5.2 Nth Root
---------------
Integer Nth roots are taken using Newton's method with the following
@@ -455,7 +98,7 @@ particularly well optimized.

File: gmp.info, Node: Perfect Square Algorithm, Next: Perfect Power Algorithm, Prev: Nth Root Algorithm, Up: Root Extraction Algorithms
-15.5.3 Perfect Square
+16.5.3 Perfect Square
---------------------
A significant fraction of non-squares can be quickly identified by
@@ -488,7 +131,7 @@ don't become too big. `gen-psqr.c' does all the pre-calculations.
A square root must still be taken for any value that passes these
tests, to verify it's really a square and not one of the small fraction
-of non-squares that get through (i.e. a pseudo-square to all the tested
+of non-squares that get through (ie. a pseudo-square to all the tested
bases).
Clearly more residue tests could be done, `mpz_perfect_square_p' only
@@ -500,7 +143,7 @@ would affect such considerations.

File: gmp.info, Node: Perfect Power Algorithm, Prev: Perfect Square Algorithm, Up: Root Extraction Algorithms
-15.5.4 Perfect Power
+16.5.4 Perfect Power
--------------------
Detecting perfect powers is required by some factorization algorithms.
@@ -516,7 +159,7 @@ checked.

File: gmp.info, Node: Radix Conversion Algorithms, Next: Other Algorithms, Prev: Root Extraction Algorithms, Up: Algorithms
-15.6 Radix Conversion
+16.6 Radix Conversion
=====================
Radix conversions are less important than other algorithms. A program
@@ -531,7 +174,7 @@ representation.

File: gmp.info, Node: Binary to Radix, Next: Radix to Binary, Prev: Radix Conversion Algorithms, Up: Radix Conversion Algorithms
-15.6.1 Binary to Radix
+16.6.1 Binary to Radix
----------------------
Conversions from binary to a power-of-2 radix use a simple and fast
@@ -598,7 +241,7 @@ radix power.
Another possible improvement for the sub-quadratic part would be to
arrange for radix powers that balanced the sizes of quotient and
-remainder produced, i.e. the highest power would be an b^(n*k)
+remainder produced, ie. the highest power would be an b^(n*k)
approximately equal to sqrt(t), not restricted to a 2^i factor. That
ought to smooth out a graph of times against sizes, but may or may not
be a net speedup.
@@ -606,7 +249,7 @@ be a net speedup.

File: gmp.info, Node: Radix to Binary, Prev: Binary to Radix, Up: Radix Conversion Algorithms
-15.6.2 Radix to Binary
+16.6.2 Radix to Binary
----------------------
*This section needs to be rewritten, it currently describes the
@@ -651,7 +294,7 @@ or more).

File: gmp.info, Node: Other Algorithms, Next: Assembly Coding, Prev: Radix Conversion Algorithms, Up: Algorithms
-15.7 Other Algorithms
+16.7 Other Algorithms
=====================
* Menu:
@@ -666,7 +309,7 @@ File: gmp.info, Node: Other Algorithms, Next: Assembly Coding, Prev: Radix Co

File: gmp.info, Node: Prime Testing Algorithm, Next: Factorial Algorithm, Prev: Other Algorithms, Up: Other Algorithms
-15.7.1 Prime Testing
+16.7.1 Prime Testing
--------------------
The primality testing in `mpz_probab_prime_p' (*note Number Theoretic
@@ -692,64 +335,43 @@ for an arbitrary n.

File: gmp.info, Node: Factorial Algorithm, Next: Binomial Coefficients Algorithm, Prev: Prime Testing Algorithm, Up: Other Algorithms
-15.7.2 Factorial
+16.7.2 Factorial
----------------
-Factorials are calculated by a combination of two algorithms. An idea is
-shared among them: to compute the odd part of the factorial; a final
-step takes account of the power of 2 term, by shifting.
-
- For small n, the odd factor of n! is computed with the simple
-observation that it is equal to the product of all positive odd numbers
-smaller than n times the odd factor of [n/2]!, where [x] is the integer
-part of x, and so on recursively. The procedure can be best illustrated
+Factorials are calculated by a combination of removal of twos,
+powering, and binary splitting. The procedure can be best illustrated
with an example,
- 23! = (23.21.19.17.15.13.11.9.7.5.3)(11.9.7.5.3)(5.3)2^19
-
- Current code collects all the factors in a single list, with a loop
-and no recursion, and compute the product, with no special care for
-repeated chunks.
-
- When n is larger, computation pass trough prime sieving. An helper
-function is used, as suggested by Peter Luschny:
+ 23! = 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23
- n
- -----
- n! | | L(p,n)
- msf(n) = -------------- = | | p
- [n/2]!^2.2^k p=3
+has factors of two removed,
- Where p ranges on odd prime numbers. The exponent k is chosen to
-obtain an odd integer number: k is the number of 1 bits in the binary
-representation of [n/2]. The function L(p,n) can be defined as zero
-when p is composite, and, for any prime p, it is computed with:
+ 23! = 2^19.1.1.3.1.5.3.7.1.9.5.11.3.13.7.15.1.17.9.19.5.21.11.23
- ---
- \ n
- L(p,n) = / [---] mod 2 <= log (n) .
- --- p^i p
- i>0
+and the resulting terms collected up according to their multiplicity,
- With this helper function, we are able to compute the odd part of n!
-using the recursion implied by n!=[n/2]!^2*msf(n)*2^k. The recursion
-stops using the small-n algorithm on some [n/2^i].
+ 23! = 2^19.(3.5)^3.(7.9.11)^2.(13.15.17.19.21.23)
- Both the above algorithms use binary splitting to compute the
-product of many small factors. At first as many products as possible
-are accumulated in a single register, generating a list of factors that
-fit in a machine word. This list is then split into halves, and the
-product is computed recursively.
+ Each sequence such as 13.15.17.19.21.23 is evaluated by splitting
+into every second term, as for instance (13.17.21).(15.19.23), and the
+same recursively on each half. This is implemented iteratively using
+some bit twiddling.
Such splitting is more efficient than repeated Nx1 multiplies since
it forms big multiplies, allowing Karatsuba and higher algorithms to be
used. And even below the Karatsuba threshold a big block of work can
be more efficient for the basecase algorithm.
+ Splitting into subsequences of every second term keeps the resulting
+products more nearly equal in size than would the simpler approach of
+say taking the first half and second half of the sequence. Nearly
+equal products are more efficient for the current multiply
+implementation.
+

File: gmp.info, Node: Binomial Coefficients Algorithm, Next: Fibonacci Numbers Algorithm, Prev: Factorial Algorithm, Up: Other Algorithms
-15.7.3 Binomial Coefficients
+16.7.3 Binomial Coefficients
----------------------------
Binomial coefficients C(n,k) are calculated by first arranging k <= n/2
@@ -771,7 +393,7 @@ and n-k+i in general won't fit in a limb at all.

File: gmp.info, Node: Fibonacci Numbers Algorithm, Next: Lucas Numbers Algorithm, Prev: Binomial Coefficients Algorithm, Up: Other Algorithms
-15.7.4 Fibonacci Numbers
+16.7.4 Fibonacci Numbers
------------------------
The Fibonacci functions `mpz_fib_ui' and `mpz_fib2_ui' are designed for
@@ -818,15 +440,15 @@ formulas is used, according as n is odd or even.
F[2k+1] = (2F[k]+F[k-1])*(2F[k]-F[k-1]) + 2*(-1)^k
F[2k+1] here is the same as above, just rearranged to be a multiply.
-For interest, the 2*(-1)^k term both here and above can be applied just
-to the low limb of the calculation, without a carry or borrow into
+For interest, the 2*(-1)^k term both here and above can be applied
+just to the low limb of the calculation, without a carry or borrow into
further limbs, which saves some code size. See comments with
`mpz_fib_ui' and the internal `mpn_fib2_ui' for how this is done.

File: gmp.info, Node: Lucas Numbers Algorithm, Next: Random Number Algorithms, Prev: Fibonacci Numbers Algorithm, Up: Other Algorithms
-15.7.5 Lucas Numbers
+16.7.5 Lucas Numbers
--------------------
`mpz_lucnum2_ui' derives a pair of Lucas numbers from a pair of
@@ -849,7 +471,7 @@ Fibonacci numbers, similar to what `mpz_fib_ui' does.

File: gmp.info, Node: Random Number Algorithms, Prev: Lucas Numbers Algorithm, Up: Other Algorithms
-15.7.6 Random Numbers
+16.7.6 Random Numbers
---------------------
For the `urandomb' functions, random numbers are generated simply by
@@ -873,7 +495,7 @@ GMP.
Linear congruential generators are described in many text books, for
instance Knuth volume 2 (*note References::). With a modulus M and
-parameters A and C, an integer state S is iterated by the formula S <-
+parameters A and C, a integer state S is iterated by the formula S <-
A*S+C mod M. At each step the new state is a linear function of the
previous, mod M, hence the name of the generator.
@@ -893,7 +515,7 @@ the like.

File: gmp.info, Node: Assembly Coding, Prev: Other Algorithms, Up: Algorithms
-15.8 Assembly Coding
+16.8 Assembly Coding
====================
The assembly subroutines in GMP are the most significant source of
@@ -922,7 +544,7 @@ offers a speedup over generic C by a factor of anything from 2 to 10.

File: gmp.info, Node: Assembly Code Organisation, Next: Assembly Basics, Prev: Assembly Coding, Up: Assembly Coding
-15.8.1 Code Organisation
+16.8.1 Code Organisation
------------------------
The various `mpn' subdirectories contain machine-dependent code, written
@@ -944,7 +566,7 @@ given CPU.

File: gmp.info, Node: Assembly Basics, Next: Assembly Carry Propagation, Prev: Assembly Code Organisation, Up: Assembly Coding
-15.8.2 Assembly Basics
+16.8.2 Assembly Basics
----------------------
`mpn_addmul_1' and `mpn_submul_1' are the most important routines for
@@ -968,7 +590,7 @@ vector processor, depending on the carry handling.

File: gmp.info, Node: Assembly Carry Propagation, Next: Assembly Cache Handling, Prev: Assembly Basics, Up: Assembly Coding
-15.8.3 Carry Propagation
+16.8.3 Carry Propagation
------------------------
The problem that presents most challenges in GMP is propagating carries
@@ -1005,7 +627,7 @@ results.

File: gmp.info, Node: Assembly Cache Handling, Next: Assembly Functional Units, Prev: Assembly Carry Propagation, Up: Assembly Coding
-15.8.4 Cache Handling
+16.8.4 Cache Handling
---------------------
GMP aims to perform well both on operands that fit entirely in L1 cache
@@ -1051,7 +673,7 @@ life easy.

File: gmp.info, Node: Assembly Functional Units, Next: Assembly Floating Point, Prev: Assembly Cache Handling, Up: Assembly Coding
-15.8.5 Functional Units
+16.8.5 Functional Units
-----------------------
When choosing an approach for an assembly loop, consideration is given
@@ -1087,7 +709,7 @@ using bit twiddling.

File: gmp.info, Node: Assembly Floating Point, Next: Assembly SIMD Instructions, Prev: Assembly Functional Units, Up: Assembly Coding
-15.8.6 Floating Point
+16.8.6 Floating Point
---------------------
Floating point arithmetic is used in GMP for multiplications on CPUs
@@ -1184,7 +806,7 @@ limb, generating a low 64-bit result limb and a high 33-bit carry limb

File: gmp.info, Node: Assembly SIMD Instructions, Next: Assembly Software Pipelining, Prev: Assembly Floating Point, Up: Assembly Coding
-15.8.7 SIMD Instructions
+16.8.7 SIMD Instructions
------------------------
The single-instruction multiple-data support in current microprocessors
@@ -1205,7 +827,7 @@ the P55 `mpn_mul_1'. SSE2 is used for Pentium 4 `mpn_mul_1',

File: gmp.info, Node: Assembly Software Pipelining, Next: Assembly Loop Unrolling, Prev: Assembly SIMD Instructions, Up: Assembly Coding
-15.8.8 Software Pipelining
+16.8.8 Software Pipelining
--------------------------
Software pipelining consists of scheduling instructions around the
@@ -1230,7 +852,7 @@ to use while another (or multiple others) are still in progress.

File: gmp.info, Node: Assembly Loop Unrolling, Next: Assembly Writing Guide, Prev: Assembly Software Pipelining, Up: Assembly Coding
-15.8.9 Loop Unrolling
+16.8.9 Loop Unrolling
---------------------
Loop unrolling consists of replicating code so that several limbs are
@@ -1277,7 +899,7 @@ ways, for example

File: gmp.info, Node: Assembly Writing Guide, Prev: Assembly Loop Unrolling, Up: Assembly Coding
-15.8.10 Writing Guide
+16.8.10 Writing Guide
---------------------
This is a guide to writing software pipelined loops for processing limb
@@ -1336,7 +958,7 @@ sizes.

File: gmp.info, Node: Internals, Next: Contributors, Prev: Algorithms, Up: Top
-16 Internals
+17 Internals
************
*This chapter is provided only for informational purposes and the
@@ -1355,7 +977,7 @@ only the documented interfaces described in previous chapters.*

File: gmp.info, Node: Integer Internals, Next: Rational Internals, Prev: Internals, Up: Internals
-16.1 Integer Internals
+17.1 Integer Internals
======================
`mpz_t' variables represent integers using sign and magnitude, in space
@@ -1405,7 +1027,7 @@ providing plenty of range.

File: gmp.info, Node: Rational Internals, Next: Float Internals, Prev: Integer Internals, Up: Internals
-16.2 Rational Internals
+17.2 Rational Internals
=======================
`mpq_t' variables represent rationals using an `mpz_t' numerator and
@@ -1424,7 +1046,7 @@ GCDs necessary, not four.
This general approach to common factors is badly sub-optimal in the
presence of simple factorizations or little prospect for cancellation,
-but GMP has no way to know when this will occur. As per *note
+but GMP has no way to know when this will occur. As per *Note
Efficiency::, that's left to applications. The `mpq_t' framework might
still suit, with `mpq_numref' and `mpq_denref' for direct access to the
numerator and denominator, or of course `mpz_t' variables can be used
@@ -1433,7 +1055,7 @@ directly.

File: gmp.info, Node: Float Internals, Next: Raw Output Internals, Prev: Rational Internals, Up: Internals
-16.3 Float Internals
+17.3 Float Internals
====================
Efficient calculation is the primary aim of GMP floats and the use of
@@ -1597,7 +1219,7 @@ Application Precisions

File: gmp.info, Node: Raw Output Internals, Next: C++ Interface Internals, Prev: Float Internals, Up: Internals
-16.4 Raw Output Internals
+17.4 Raw Output Internals
=========================
`mpz_out_raw' uses the following format.
@@ -1627,7 +1249,7 @@ can just read and write `_mp_d'.

File: gmp.info, Node: C++ Interface Internals, Prev: Raw Output Internals, Up: Internals
-16.5 C++ Interface Internals
+17.5 C++ Interface Internals
============================
A system of expression templates is used to ensure something like
@@ -1645,10 +1267,7 @@ object" evaluating it,
struct __gmp_binary_plus
{
- static void eval(mpf_t f, const mpf_t g, const mpf_t h)
- {
- mpf_add(f, g, h);
- }
+ static void eval(mpf_t f, mpf_t g, mpf_t h) { mpf_add(f, g, h); }
};
And an "additive expression" object,
@@ -1676,7 +1295,7 @@ type. In fact even `mpf_class' etc are `typedef' specializations of
template <class Op>
void __gmp_expr<__gmp_binary_expr<mpf_class, mpf_class, Op> >::eval
- (mpf_t f, mp_bitcnt_t precision)
+ (mpf_t f, unsigned long int precision)
{
Op::eval(f, expr.val1.get_mpf_t(), expr.val2.get_mpf_t());
}
@@ -1708,7 +1327,7 @@ subexpressions as their arguments, like this:
template <class T, class U, class Op>
void __gmp_expr
<__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, Op> >::eval
- (mpf_t f, mp_bitcnt_t precision)
+ (mpf_t f, unsigned long int precision)
{
// declare two temporaries
mpf_class temp1(expr.val1, precision), temp2(expr.val2, precision);
@@ -1724,12 +1343,12 @@ File: gmp.info, Node: Contributors, Next: References, Prev: Internals, Up: T
Appendix A Contributors
***********************
-Torbjörn Granlund wrote the original GMP library and is still the main
+Torbjo"rn Granlund wrote the original GMP library and is still the main
developer. Code not explicitly attributed to others, was contributed by
-Torbjörn. Several other individuals and organizations have contributed
+Torbjo"rn. Several other individuals and organizations have contributed
GMP. Here is a list in chronological order on first contribution:
- Gunnar Sjödin and Hans Riesel helped with mathematical problems in
+ Gunnar Sjo"din and Hans Riesel helped with mathematical problems in
early versions of the library.
Richard Stallman helped with the interface design and revised the
@@ -1742,17 +1361,16 @@ the library and made creative suggestions.
`mpz_probab_prime_p'.
Paul Zimmermann wrote the REDC-based mpz_powm code, the
-Schönhage-Strassen FFT multiply code, and the Karatsuba square root
+Scho"nhage-Strassen FFT multiply code, and the Karatsuba square root
code. He also improved the Toom3 code for GMP 4.2. Paul sparked the
development of GMP 2, with his comparisons between bignum packages.
The ECMNET project Paul is organizing was a driving force behind many
of the optimizations in GMP 3. Paul also wrote the new GMP 4.3 nth
-root code (with Torbjörn).
+root code (with Torbjo"rn).
Ken Weber (Kent State University, Universidade Federal do Rio Grande
-do Sul) contributed now defunct versions of `mpz_gcd', `mpz_divexact',
-`mpn_gcd', and `mpn_bdivmod', partially supported by CNPq (Brazil)
-grant 301314194-2.
+do Sul) contributed `mpz_gcd', `mpz_divexact', `mpn_gcd', and
+`mpn_bdivmod', partially supported by CNPq (Brazil) grant 301314194-2.
Per Bothner of Cygnus Support helped to set up GMP to use Cygnus'
configure. He has also made valuable suggestions and tested numerous
@@ -1800,48 +1418,20 @@ elsewhere.
Pedro Gimeno implemented the Mersenne Twister and made other random
number improvements.
- Niels Möller wrote the sub-quadratic GCD, extended GCD and jacobi
-code, the quadratic Hensel division code, and (with Torbjörn) the new
-divide and conquer division code for GMP 4.3. Niels also helped
-implement the new Toom multiply code for GMP 4.3 and implemented helper
-functions to simplify Toom evaluations for GMP 5.0. He wrote the
-original version of mpn_mulmod_bnm1, and he is the main author of the
-mini-gmp package used for gmp bootstrapping.
+ Niels Mo"ller wrote the sub-quadratic GCD and extended GCD code, the
+quadratic Hensel division code, and (with Torbjo"rn) the new divide and
+conquer division code for GMP 4.3. Niels also helped implement the new
+Toom multiply code for GMP 4.3.
Alberto Zanoni and Marco Bodrato suggested the unbalanced multiply
strategy, and found the optimal strategies for evaluation and
-interpolation in Toom multiplication.
-
- Marco Bodrato helped implement the new Toom multiply code for GMP
-4.3 and implemented most of the new Toom multiply and squaring code for
-5.0. He is the main author of the current mpn_mulmod_bnm1 and
-mpn_mullo_n. Marco also wrote the functions mpn_invert and
-mpn_invertappr. He is the author of the current combinatorial
-functions: binomial, factorial, multifactorial, primorial.
+interpolation in Toom multiplication. Marco also helped implement the
+new Toom multiply code for GMP 4.3.
David Harvey suggested the internal function `mpn_bdiv_dbm1',
implementing division relevant to Toom multiplication. He also worked
on fast assembly sequences, in particular on a fast AMD64
-`mpn_mul_basecase'. He wrote the internal middle product functions
-`mpn_mulmid_basecase', `mpn_toom42_mulmid', `mpn_mulmid_n' and related
-helper routines.
-
- Martin Boij wrote `mpn_perfect_power_p'.
-
- Marc Glisse improved `gmpxx.h': use fewer temporaries (faster),
-specializations of `numeric_limits' and `common_type', C++11 features
-(move constructors, explicit bool conversion, UDL), make the conversion
-from `mpq_class' to `mpz_class' explicit, optimize operations where one
-argument is a small compile-time constant, replace some heap
-allocations by stack allocations. He also fixed the eofbit handling of
-C++ streams, and removed one division from `mpq/aors.c'.
-
- David S Miller wrote assembly code for SPARC T3 and T4.
-
- Mark Sofroniou cleaned up the types of mul_fft.c, letting it work
-for huge operands.
-
- Ulrich Weigand ported GMP to the powerpc64le ABI.
+`mpn_mul_basecase'.
(This list is chronological, not ordered after significance. If you
have contributed to GMP but are not listed above, please tell
@@ -1851,11 +1441,8 @@ have contributed to GMP but are not listed above, please tell
supported in part by the ESPRIT-BRA (Basic Research Activities) 6846
project POSSO (POlynomial System SOlving).
- The development of GMP 2, 3, and 4.0 was supported in part by the
-IDA Center for Computing Sciences.
-
- The development of GMP 4.3, 5.0, and 5.1 was supported in part by
-the Swedish Foundation for Strategic Research.
+ The development of GMP 2, 3, and 4 was supported in part by the IDA
+Center for Computing Sciences.
Thanks go to Hans Thorsen for donating an SGI system for the GMP
test system environment.
@@ -1875,7 +1462,7 @@ B.1 Books
* Richard Crandall and Carl Pomerance, "Prime Numbers: A
Computational Perspective", 2nd edition, Springer-Verlag, 2005.
- `http://www.math.dartmouth.edu/~carlp/'
+ `http://math.dartmouth.edu/~carlp/'
* Henri Cohen, "A Course in Computational Algebraic Number Theory",
Graduate Texts in Mathematics number 138, Springer-Verlag, 1993.
@@ -1894,8 +1481,8 @@ B.1 Books
* Richard M. Stallman and the GCC Developer Community, "Using the
GNU Compiler Collection", Free Software Foundation, 2008,
- available online `https://gcc.gnu.org/onlinedocs/', and in the GCC
- package `https://ftp.gnu.org/gnu/gcc/'
+ available online `http://gcc.gnu.org/onlinedocs/', and in the GCC
+ package `ftp://ftp.gnu.org/gnu/gcc/'
B.2 Papers
==========
@@ -1903,23 +1490,22 @@ B.2 Papers
* Yves Bertot, Nicolas Magaud and Paul Zimmermann, "A Proof of GMP
Square Root", Journal of Automated Reasoning, volume 29, 2002, pp.
225-252. Also available online as INRIA Research Report 4475,
- June 2002, `http://hal.inria.fr/docs/00/07/21/13/PDF/RR-4475.pdf'
+ June 2001, `http://www.inria.fr/rrrt/rr-4475.html'
* Christoph Burnikel and Joachim Ziegler, "Fast Recursive Division",
Max-Planck-Institut fuer Informatik Research Report MPI-I-98-1-022,
`http://data.mpi-sb.mpg.de/internet/reports.nsf/NumberView/1998-1-022'
- * Torbjörn Granlund and Peter L. Montgomery, "Division by Invariant
+ * Torbjo"rn Granlund and Peter L. Montgomery, "Division by Invariant
Integers using Multiplication", in Proceedings of the SIGPLAN
PLDI'94 Conference, June 1994. Also available
- `https://gmplib.org/~tege/divcnst-pldi94.pdf'.
+ `ftp://ftp.cwi.nl/pub/pmontgom/divcnst.psa4.gz' (and .psl.gz).
- * Niels Möller and Torbjörn Granlund, "Improved division by invariant
- integers", IEEE Transactions on Computers, 11 June 2010.
- `https://gmplib.org/~tege/division-paper.pdf'
+ * Niels M"oller and Torbjo"rn Granlund, "Improved division by
+ invariant integers", to appear.
- * Torbjörn Granlund and Niels Möller, "Division of integers large and
- small", to appear.
+ * Torbjo"rn Granlund and Niels M"oller, "Division of integers large
+ and small", to appear.
* Tudor Jebelean, "An algorithm for exact division", Journal of
Symbolic Computation, volume 15, 1993, pp. 169-180. Research
@@ -1962,7 +1548,7 @@ B.2 Papers
Modular Transforms", Journal of Computer and System Sciences,
volume 8, number 3, June 1974, pp. 366-386.
- * Niels Möller, "On Schönhage's algorithm and subquadratic integer
+ * Niels Mo"ller, "On Scho"nhage's algorithm and subquadratic integer
GCD computation", in Mathematics of Computation, volume 77,
January 2008, pp. 589-607.
@@ -1970,7 +1556,7 @@ B.2 Papers
Division", in Mathematics of Computation, volume 44, number 170,
April 1985.
- * Arnold Schönhage and Volker Strassen, "Schnelle Multiplikation
+ * Arnold Scho"nhage and Volker Strassen, "Schnelle Multiplikation
grosser Zahlen", Computing 7, 1971, pp. 281-292.
* Kenneth Weber, "The accelerated integer GCD algorithm", ACM
@@ -1978,8 +1564,7 @@ B.2 Papers
1995, pp. 111-122.
* Paul Zimmermann, "Karatsuba Square Root", INRIA Research Report
- 3805, November 1999,
- `http://hal.inria.fr/inria-00072854/PDF/RR-3805.pdf'
+ 3805, November 1999, `http://www.inria.fr/rrrt/rr-3805.html'
* Paul Zimmermann, "A Proof of GMP Fast Division and Square Root
Implementations",
@@ -1999,7 +1584,7 @@ Appendix C GNU Free Documentation License
Version 1.3, 3 November 2008
- Copyright (C) 2000-2002, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
`http://fsf.org/'
Everyone is permitted to copy and distribute verbatim copies
@@ -2400,7 +1985,7 @@ Appendix C GNU Free Documentation License
the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
- `https://www.gnu.org/copyleft/'.
+ `http://www.gnu.org/copyleft/'.
Each version of the License is given a distinguishing version
number. If the Document specifies that a particular numbered
@@ -2489,40 +2074,42 @@ Concept Index
* #include: Headers and Libraries.
(line 6)
* --build: Build Options. (line 52)
-* --disable-fft: Build Options. (line 313)
+* --disable-fft: Build Options. (line 317)
* --disable-shared: Build Options. (line 45)
* --disable-static: Build Options. (line 45)
-* --enable-alloca: Build Options. (line 274)
-* --enable-assert: Build Options. (line 319)
-* --enable-cxx: Build Options. (line 226)
-* --enable-fat: Build Options. (line 161)
-* --enable-profiling <1>: Build Options. (line 323)
-* --enable-profiling: Profiling. (line 6)
+* --enable-alloca: Build Options. (line 278)
+* --enable-assert: Build Options. (line 327)
+* --enable-cxx: Build Options. (line 230)
+* --enable-fat: Build Options. (line 164)
+* --enable-mpbsd: Build Options. (line 322)
+* --enable-profiling <1>: Profiling. (line 6)
+* --enable-profiling: Build Options. (line 331)
* --exec-prefix: Build Options. (line 32)
* --host: Build Options. (line 66)
* --prefix: Build Options. (line 32)
* -finstrument-functions: Profiling. (line 66)
* 2exp functions: Efficiency. (line 43)
* 68000: Notes for Particular Systems.
- (line 94)
+ (line 85)
* 80x86: Notes for Particular Systems.
- (line 150)
-* ABI <1>: Build Options. (line 168)
+ (line 131)
+* ABI <1>: Build Options. (line 171)
* ABI: ABI and ISA. (line 6)
-* About this manual: Introduction to GMP. (line 57)
+* About this manual: Introduction to GMP. (line 58)
* AC_CHECK_LIB: Autoconf. (line 11)
-* AIX <1>: Notes for Particular Systems.
+* AIX <1>: ABI and ISA. (line 184)
+* AIX <2>: Notes for Particular Systems.
(line 7)
-* AIX: ABI and ISA. (line 178)
+* AIX: ABI and ISA. (line 169)
* Algorithms: Algorithms. (line 6)
-* alloca: Build Options. (line 274)
+* alloca: Build Options. (line 278)
* Allocation of memory: Custom Allocation. (line 6)
* AMD64: ABI and ISA. (line 44)
-* Anonymous FTP of latest version: Introduction to GMP. (line 37)
+* Anonymous FTP of latest version: Introduction to GMP. (line 38)
* Application Binary Interface: ABI and ISA. (line 6)
-* Arithmetic functions <1>: Rational Arithmetic. (line 6)
-* Arithmetic functions <2>: Float Arithmetic. (line 6)
-* Arithmetic functions: Integer Arithmetic. (line 6)
+* Arithmetic functions <1>: Float Arithmetic. (line 6)
+* Arithmetic functions <2>: Integer Arithmetic. (line 6)
+* Arithmetic functions: Rational Arithmetic. (line 6)
* ARM: Notes for Particular Systems.
(line 20)
* Assembly cache handling: Assembly Cache Handling.
@@ -2543,31 +2130,37 @@ Concept Index
* Assembly writing guide: Assembly Writing Guide.
(line 6)
* Assertion checking <1>: Debugging. (line 79)
-* Assertion checking: Build Options. (line 319)
-* Assignment functions <1>: Assigning Integers. (line 6)
+* Assertion checking: Build Options. (line 327)
+* Assignment functions <1>: Assigning Floats. (line 6)
* Assignment functions <2>: Initializing Rationals.
(line 6)
-* Assignment functions <3>: Simultaneous Float Init & Assign.
+* Assignment functions <3>: Simultaneous Integer Init & Assign.
(line 6)
-* Assignment functions <4>: Simultaneous Integer Init & Assign.
+* Assignment functions <4>: Simultaneous Float Init & Assign.
(line 6)
-* Assignment functions: Assigning Floats. (line 6)
+* Assignment functions: Assigning Integers. (line 6)
* Autoconf: Autoconf. (line 6)
* Basics: GMP Basics. (line 6)
+* Berkeley MP compatible functions <1>: Build Options. (line 322)
+* Berkeley MP compatible functions: BSD Compatible Functions.
+ (line 6)
* Binomial coefficient algorithm: Binomial Coefficients Algorithm.
(line 6)
* Binomial coefficient functions: Number Theoretic Functions.
- (line 128)
+ (line 101)
* Binutils strip: Known Build Problems.
(line 28)
* Bit manipulation functions: Integer Logic and Bit Fiddling.
(line 6)
* Bit scanning functions: Integer Logic and Bit Fiddling.
(line 40)
-* Bit shift left: Integer Arithmetic. (line 38)
-* Bit shift right: Integer Division. (line 62)
+* Bit shift left: Integer Arithmetic. (line 36)
+* Bit shift right: Integer Division. (line 59)
* Bits per limb: Useful Macros and Constants.
(line 7)
+* BSD MP compatible functions <1>: Build Options. (line 322)
+* BSD MP compatible functions: BSD Compatible Functions.
+ (line 6)
* Bug reporting: Reporting Bugs. (line 6)
* Build directory: Build Options. (line 19)
* Build notes for binary packaging: Notes for Package Builds.
@@ -2580,18 +2173,18 @@ Concept Index
* Build system: Build Options. (line 52)
* Building GMP: Installing GMP. (line 6)
* Bus error: Debugging. (line 7)
-* C compiler: Build Options. (line 179)
-* C++ compiler: Build Options. (line 250)
+* C compiler: Build Options. (line 182)
+* C++ compiler: Build Options. (line 254)
* C++ interface: C++ Class Interface. (line 6)
* C++ interface internals: C++ Interface Internals.
(line 6)
* C++ istream input: C++ Formatted Input. (line 6)
* C++ ostream output: C++ Formatted Output.
(line 6)
-* C++ support: Build Options. (line 226)
-* CC: Build Options. (line 179)
-* CC_FOR_BUILD: Build Options. (line 213)
-* CFLAGS: Build Options. (line 179)
+* C++ support: Build Options. (line 230)
+* CC: Build Options. (line 182)
+* CC_FOR_BUILD: Build Options. (line 217)
+* CFLAGS: Build Options. (line 182)
* Checker: Debugging. (line 115)
* checkergcc: Debugging. (line 122)
* Code organisation: Assembly Code Organisation.
@@ -2599,14 +2192,14 @@ Concept Index
* Compaq C++: Notes for Particular Systems.
(line 25)
* Comparison functions <1>: Integer Comparisons. (line 6)
-* Comparison functions <2>: Float Comparison. (line 6)
-* Comparison functions: Comparing Rationals. (line 6)
+* Comparison functions <2>: Comparing Rationals. (line 6)
+* Comparison functions: Float Comparison. (line 6)
* Compatibility with older versions: Compatibility with older versions.
(line 6)
* Conditions for copying GNU MP: Copying. (line 6)
* Configuring GMP: Installing GMP. (line 6)
* Congruence algorithm: Exact Remainder. (line 30)
-* Congruence functions: Integer Division. (line 137)
+* Congruence functions: Integer Division. (line 131)
* Constants: Useful Macros and Constants.
(line 6)
* Contributors: Contributors. (line 6)
@@ -2619,16 +2212,15 @@ Concept Index
* Conversion functions: Rational Conversions.
(line 6)
* Copying conditions: Copying. (line 6)
-* CPPFLAGS: Build Options. (line 205)
+* CPPFLAGS: Build Options. (line 208)
* CPU types <1>: Introduction to GMP. (line 24)
* CPU types: Build Options. (line 108)
* Cross compiling: Build Options. (line 66)
-* Cryptography functions, low-level: Low-level Functions. (line 495)
* Custom allocation: Custom Allocation. (line 6)
-* CXX: Build Options. (line 250)
-* CXXFLAGS: Build Options. (line 250)
+* CXX: Build Options. (line 254)
+* CXXFLAGS: Build Options. (line 254)
* Cygwin: Notes for Particular Systems.
- (line 57)
+ (line 48)
* Darwin: Known Build Problems.
(line 51)
* Debugging: Debugging. (line 6)
@@ -2637,56 +2229,56 @@ Concept Index
* Digits in an integer: Miscellaneous Integer Functions.
(line 23)
* Divisibility algorithm: Exact Remainder. (line 30)
-* Divisibility functions: Integer Division. (line 137)
+* Divisibility functions: Integer Division. (line 131)
* Divisibility testing: Efficiency. (line 91)
* Division algorithms: Division Algorithms. (line 6)
-* Division functions <1>: Rational Arithmetic. (line 24)
+* Division functions <1>: Rational Arithmetic. (line 23)
* Division functions <2>: Integer Division. (line 6)
* Division functions: Float Arithmetic. (line 33)
* DJGPP <1>: Notes for Particular Systems.
- (line 57)
+ (line 48)
* DJGPP: Known Build Problems.
(line 18)
* DLLs: Notes for Particular Systems.
- (line 70)
-* DocBook: Build Options. (line 346)
-* Documentation formats: Build Options. (line 339)
+ (line 61)
+* DocBook: Build Options. (line 354)
+* Documentation formats: Build Options. (line 347)
* Documentation license: GNU Free Documentation License.
(line 6)
-* DVI: Build Options. (line 342)
+* DVI: Build Options. (line 350)
* Efficiency: Efficiency. (line 6)
* Emacs: Emacs. (line 6)
-* Exact division functions: Integer Division. (line 112)
+* Exact division functions: Integer Division. (line 108)
* Exact remainder: Exact Remainder. (line 6)
* Example programs: Demonstration Programs.
(line 6)
* Exec prefix: Build Options. (line 32)
-* Execution profiling <1>: Build Options. (line 323)
-* Execution profiling: Profiling. (line 6)
+* Execution profiling <1>: Profiling. (line 6)
+* Execution profiling: Build Options. (line 331)
* Exponentiation functions <1>: Float Arithmetic. (line 41)
* Exponentiation functions: Integer Exponentiation.
(line 6)
* Export: Integer Import and Export.
(line 45)
* Expression parsing demo: Demonstration Programs.
- (line 15)
+ (line 21)
* Extended GCD: Number Theoretic Functions.
- (line 49)
+ (line 45)
* Factor removal functions: Number Theoretic Functions.
- (line 108)
+ (line 91)
* Factorial algorithm: Factorial Algorithm. (line 6)
* Factorial functions: Number Theoretic Functions.
- (line 116)
+ (line 96)
* Factorization demo: Demonstration Programs.
(line 25)
* Fast Fourier Transform: FFT Multiplication. (line 6)
-* Fat binary: Build Options. (line 161)
+* Fat binary: Build Options. (line 164)
* FFT multiplication <1>: FFT Multiplication. (line 6)
-* FFT multiplication: Build Options. (line 313)
+* FFT multiplication: Build Options. (line 317)
* Fibonacci number algorithm: Fibonacci Numbers Algorithm.
(line 6)
* Fibonacci sequence functions: Number Theoretic Functions.
- (line 136)
+ (line 109)
* Float arithmetic functions: Float Arithmetic. (line 6)
* Float assignment functions <1>: Simultaneous Float Init & Assign.
(line 6)
@@ -2695,9 +2287,9 @@ Concept Index
* Float conversion functions: Converting Floats. (line 6)
* Float functions: Floating-point Functions.
(line 6)
-* Float initialization functions <1>: Simultaneous Float Init & Assign.
+* Float initialization functions <1>: Initializing Floats. (line 6)
+* Float initialization functions: Simultaneous Float Init & Assign.
(line 6)
-* Float initialization functions: Initializing Floats. (line 6)
* Float input and output functions: I/O of Floats. (line 6)
* Float internals: Float Internals. (line 6)
* Float miscellaneous functions: Miscellaneous Float Functions.
@@ -2706,7 +2298,7 @@ Concept Index
(line 27)
* Float rounding functions: Miscellaneous Float Functions.
(line 9)
-* Float sign tests: Float Comparison. (line 35)
+* Float sign tests: Float Comparison. (line 33)
* Floating point mode: Notes for Particular Systems.
(line 34)
* Floating-point functions: Floating-point Functions.
@@ -2718,22 +2310,20 @@ Concept Index
* Formatted output: Formatted Output. (line 6)
* Free Documentation License: GNU Free Documentation License.
(line 6)
-* FreeBSD: Notes for Particular Systems.
- (line 43)
-* frexp <1>: Converting Integers. (line 43)
-* frexp: Converting Floats. (line 24)
-* FTP of latest version: Introduction to GMP. (line 37)
+* frexp <1>: Converting Integers. (line 42)
+* frexp: Converting Floats. (line 23)
+* FTP of latest version: Introduction to GMP. (line 38)
* Function classes: Function Classes. (line 6)
* FunctionCheck: Profiling. (line 77)
* GCC Checker: Debugging. (line 115)
* GCD algorithms: Greatest Common Divisor Algorithms.
(line 6)
* GCD extended: Number Theoretic Functions.
- (line 49)
+ (line 45)
* GCD functions: Number Theoretic Functions.
- (line 32)
+ (line 30)
* GDB: Debugging. (line 58)
-* Generic C: Build Options. (line 152)
+* Generic C: Build Options. (line 153)
* GMP Perl module: Demonstration Programs.
(line 35)
* GMP version number: Useful Macros and Constants.
@@ -2751,45 +2341,45 @@ Concept Index
* Greatest common divisor algorithms: Greatest Common Divisor Algorithms.
(line 6)
* Greatest common divisor functions: Number Theoretic Functions.
- (line 32)
+ (line 30)
* Hardware floating point mode: Notes for Particular Systems.
(line 34)
* Headers: Headers and Libraries.
(line 6)
* Heap problems: Debugging. (line 24)
-* Home page: Introduction to GMP. (line 33)
+* Home page: Introduction to GMP. (line 34)
* Host system: Build Options. (line 66)
-* HP-UX: ABI and ISA. (line 77)
-* HPPA: ABI and ISA. (line 77)
+* HP-UX: ABI and ISA. (line 68)
+* HPPA: ABI and ISA. (line 68)
* I/O functions <1>: I/O of Integers. (line 6)
* I/O functions <2>: I/O of Floats. (line 6)
* I/O functions: I/O of Rationals. (line 6)
* i386: Notes for Particular Systems.
- (line 150)
-* IA-64: ABI and ISA. (line 116)
+ (line 131)
+* IA-64: ABI and ISA. (line 107)
* Import: Integer Import and Export.
(line 11)
* In-place operations: Efficiency. (line 57)
* Include files: Headers and Libraries.
(line 6)
* info-lookup-symbol: Emacs. (line 6)
-* Initialization functions <1>: Initializing Floats. (line 6)
-* Initialization functions <2>: Random State Initialization.
+* Initialization functions <1>: Random State Initialization.
(line 6)
-* Initialization functions <3>: Simultaneous Float Init & Assign.
+* Initialization functions <2>: Initializing Rationals.
(line 6)
-* Initialization functions <4>: Simultaneous Integer Init & Assign.
+* Initialization functions <3>: Initializing Integers.
(line 6)
-* Initialization functions <5>: Initializing Rationals.
+* Initialization functions <4>: Simultaneous Float Init & Assign.
(line 6)
-* Initialization functions: Initializing Integers.
+* Initialization functions <5>: Initializing Floats. (line 6)
+* Initialization functions: Simultaneous Integer Init & Assign.
(line 6)
* Initializing and clearing: Efficiency. (line 21)
-* Input functions <1>: Formatted Input Functions.
+* Input functions <1>: I/O of Rationals. (line 6)
+* Input functions <2>: I/O of Floats. (line 6)
+* Input functions <3>: I/O of Integers. (line 6)
+* Input functions: Formatted Input Functions.
(line 6)
-* Input functions <2>: I/O of Rationals. (line 6)
-* Input functions <3>: I/O of Floats. (line 6)
-* Input functions: I/O of Integers. (line 6)
* Install prefix: Build Options. (line 32)
* Installing GMP: Installing GMP. (line 6)
* Instruction Set Architecture: ABI and ISA. (line 6)
@@ -2812,9 +2402,9 @@ Concept Index
* Integer functions: Integer Functions. (line 6)
* Integer import: Integer Import and Export.
(line 11)
-* Integer initialization functions <1>: Initializing Integers.
+* Integer initialization functions <1>: Simultaneous Integer Init & Assign.
(line 6)
-* Integer initialization functions: Simultaneous Integer Init & Assign.
+* Integer initialization functions: Initializing Integers.
(line 6)
* Integer input and output functions: I/O of Integers. (line 6)
* Integer internals: Integer Internals. (line 6)
@@ -2829,33 +2419,33 @@ Concept Index
* Integer special functions: Integer Special Functions.
(line 6)
* Interix: Notes for Particular Systems.
- (line 65)
+ (line 56)
* Internals: Internals. (line 6)
* Introduction: Introduction to GMP. (line 6)
* Inverse modulo functions: Number Theoretic Functions.
- (line 76)
-* IRIX <1>: ABI and ISA. (line 141)
+ (line 60)
+* IRIX <1>: ABI and ISA. (line 132)
* IRIX: Known Build Problems.
(line 38)
* ISA: ABI and ISA. (line 6)
* istream input: C++ Formatted Input. (line 6)
* Jacobi symbol algorithm: Jacobi Symbol. (line 6)
* Jacobi symbol functions: Number Theoretic Functions.
- (line 83)
+ (line 66)
* Karatsuba multiplication: Karatsuba Multiplication.
(line 6)
* Karatsuba square root algorithm: Square Root Algorithm.
(line 6)
* Kronecker symbol functions: Number Theoretic Functions.
- (line 95)
+ (line 78)
* Language bindings: Language Bindings. (line 6)
-* Latest version of GMP: Introduction to GMP. (line 37)
+* Latest version of GMP: Introduction to GMP. (line 38)
* LCM functions: Number Theoretic Functions.
- (line 70)
+ (line 55)
* Least common multiple functions: Number Theoretic Functions.
- (line 70)
+ (line 55)
* Legendre symbol functions: Number Theoretic Functions.
- (line 86)
+ (line 69)
* libgmp: Headers and Libraries.
(line 22)
* libgmpxx: Headers and Libraries.
@@ -2880,14 +2470,15 @@ Concept Index
* Logical functions: Integer Logic and Bit Fiddling.
(line 6)
* Low-level functions: Low-level Functions. (line 6)
-* Low-level functions for cryptography: Low-level Functions. (line 495)
* Lucas number algorithm: Lucas Numbers Algorithm.
(line 6)
* Lucas number functions: Number Theoretic Functions.
- (line 147)
+ (line 120)
+* MacOS 9: Notes for Particular Systems.
+ (line 43)
* MacOS X: Known Build Problems.
(line 51)
-* Mailing lists: Introduction to GMP. (line 44)
+* Mailing lists: Introduction to GMP. (line 45)
* Malloc debugger: Debugging. (line 30)
* Malloc problems: Debugging. (line 24)
* Memory allocation: Custom Allocation. (line 6)
@@ -2897,34 +2488,34 @@ Concept Index
* Mersenne twister random numbers: Random State Initialization.
(line 13)
* MINGW: Notes for Particular Systems.
- (line 57)
-* MIPS: ABI and ISA. (line 141)
+ (line 48)
+* MIPS: ABI and ISA. (line 132)
* Miscellaneous float functions: Miscellaneous Float Functions.
(line 6)
* Miscellaneous integer functions: Miscellaneous Integer Functions.
(line 6)
* MMX: Notes for Particular Systems.
- (line 156)
+ (line 137)
* Modular inverse functions: Number Theoretic Functions.
- (line 76)
+ (line 60)
* Most significant bit: Miscellaneous Integer Functions.
(line 34)
-* MPN_PATH: Build Options. (line 327)
+* mp.h: BSD Compatible Functions.
+ (line 21)
+* MPN_PATH: Build Options. (line 335)
* MS Windows: Notes for Particular Systems.
- (line 57)
+ (line 48)
* MS-DOS: Notes for Particular Systems.
- (line 57)
+ (line 48)
* Multi-threading: Reentrancy. (line 6)
* Multiplication algorithms: Multiplication Algorithms.
(line 6)
-* Nails: Low-level Functions. (line 664)
+* Nails: Low-level Functions. (line 434)
* Native compilation: Build Options. (line 52)
-* NetBSD: Notes for Particular Systems.
- (line 100)
* NeXT: Known Build Problems.
(line 57)
* Next prime function: Number Theoretic Functions.
- (line 25)
+ (line 23)
* Nomenclature: Nomenclature and Types.
(line 6)
* Non-Unix systems: Build Options. (line 11)
@@ -2937,17 +2528,17 @@ Concept Index
* obstack output: Formatted Output Functions.
(line 81)
* OpenBSD: Notes for Particular Systems.
- (line 109)
+ (line 91)
* Optimizing performance: Performance optimization.
(line 6)
* ostream output: C++ Formatted Output.
(line 6)
* Other languages: Language Bindings. (line 6)
-* Output functions <1>: Formatted Output Functions.
- (line 6)
-* Output functions <2>: I/O of Rationals. (line 6)
+* Output functions <1>: I/O of Rationals. (line 6)
+* Output functions <2>: I/O of Floats. (line 6)
* Output functions <3>: I/O of Integers. (line 6)
-* Output functions: I/O of Floats. (line 6)
+* Output functions: Formatted Output Functions.
+ (line 6)
* Packaged builds: Notes for Package Builds.
(line 6)
* Parameter conventions: Parameter Conventions.
@@ -2958,27 +2549,27 @@ Concept Index
(line 6)
* Past GMP versions: Compatibility with older versions.
(line 6)
-* PDF: Build Options. (line 342)
+* PDF: Build Options. (line 350)
* Perfect power algorithm: Perfect Power Algorithm.
(line 6)
-* Perfect power functions: Integer Roots. (line 28)
+* Perfect power functions: Integer Roots. (line 27)
* Perfect square algorithm: Perfect Square Algorithm.
(line 6)
-* Perfect square functions: Integer Roots. (line 37)
+* Perfect square functions: Integer Roots. (line 36)
* perl: Demonstration Programs.
(line 35)
* Perl module: Demonstration Programs.
(line 35)
-* Postscript: Build Options. (line 342)
-* Power/PowerPC <1>: Known Build Problems.
+* Postscript: Build Options. (line 350)
+* Power/PowerPC <1>: Notes for Particular Systems.
+ (line 97)
+* Power/PowerPC: Known Build Problems.
(line 63)
-* Power/PowerPC: Notes for Particular Systems.
- (line 115)
* Powering algorithms: Powering Algorithms. (line 6)
* Powering functions <1>: Float Arithmetic. (line 41)
* Powering functions: Integer Exponentiation.
(line 6)
-* PowerPC: ABI and ISA. (line 176)
+* PowerPC: ABI and ISA. (line 167)
* Precision of floats: Floating-point Functions.
(line 6)
* Precision of hardware floating point: Notes for Particular Systems.
@@ -2988,8 +2579,6 @@ Concept Index
(line 6)
* Prime testing functions: Number Theoretic Functions.
(line 7)
-* Primorial functions: Number Theoretic Functions.
- (line 121)
* printf formatted output: Formatted Output. (line 6)
* Probable prime testing functions: Number Theoretic Functions.
(line 7)
@@ -2999,18 +2588,18 @@ Concept Index
(line 6)
* Random number algorithms: Random Number Algorithms.
(line 6)
-* Random number functions <1>: Integer Random Numbers.
- (line 6)
+* Random number functions <1>: Miscellaneous Float Functions.
+ (line 27)
* Random number functions <2>: Random Number Functions.
(line 6)
-* Random number functions: Miscellaneous Float Functions.
- (line 27)
+* Random number functions: Integer Random Numbers.
+ (line 6)
* Random number seeding: Random State Seeding.
(line 6)
* Random number state: Random State Initialization.
(line 6)
* Random state: Nomenclature and Types.
- (line 46)
+ (line 41)
* Rational arithmetic: Efficiency. (line 113)
* Rational arithmetic functions: Rational Arithmetic. (line 6)
* Rational assignment functions: Initializing Rationals.
@@ -3035,14 +2624,14 @@ Concept Index
* Reentrancy: Reentrancy. (line 6)
* References: References. (line 6)
* Remove factor functions: Number Theoretic Functions.
- (line 108)
+ (line 91)
* Reporting bugs: Reporting Bugs. (line 6)
* Root extraction algorithm: Nth Root Algorithm. (line 6)
* Root extraction algorithms: Root Extraction Algorithms.
(line 6)
* Root extraction functions <1>: Float Arithmetic. (line 37)
* Root extraction functions: Integer Roots. (line 6)
-* Root testing functions: Integer Roots. (line 28)
+* Root testing functions: Integer Roots. (line 36)
* Rounding functions: Miscellaneous Float Functions.
(line 9)
* Sample programs: Demonstration Programs.
@@ -3058,30 +2647,32 @@ Concept Index
* Sequent Symmetry: Known Build Problems.
(line 68)
* Services for Unix: Notes for Particular Systems.
- (line 65)
+ (line 56)
* Shared library versioning: Notes for Package Builds.
(line 9)
-* Sign tests <1>: Comparing Rationals. (line 27)
-* Sign tests <2>: Float Comparison. (line 35)
-* Sign tests: Integer Comparisons. (line 28)
+* Sign tests <1>: Integer Comparisons. (line 28)
+* Sign tests <2>: Float Comparison. (line 33)
+* Sign tests: Comparing Rationals. (line 27)
* Size in digits: Miscellaneous Integer Functions.
(line 23)
* Small operands: Efficiency. (line 7)
-* Solaris <1>: ABI and ISA. (line 208)
+* Solaris <1>: Known Build Problems.
+ (line 78)
+* Solaris <2>: ABI and ISA. (line 201)
* Solaris: Known Build Problems.
(line 72)
* Sparc: Notes for Particular Systems.
- (line 127)
-* Sparc V9: ABI and ISA. (line 208)
+ (line 108)
+* Sparc V9: ABI and ISA. (line 201)
* Special integer functions: Integer Special Functions.
(line 6)
* Square root algorithm: Square Root Algorithm.
(line 6)
* SSE2: Notes for Particular Systems.
- (line 156)
+ (line 137)
* Stack backtrace: Debugging. (line 50)
* Stack overflow <1>: Debugging. (line 7)
-* Stack overflow: Build Options. (line 274)
+* Stack overflow: Build Options. (line 278)
* Static linking: Efficiency. (line 14)
* stdarg.h: Headers and Libraries.
(line 17)
@@ -3089,22 +2680,20 @@ Concept Index
(line 11)
* Stripped libraries: Known Build Problems.
(line 28)
-* Sun: ABI and ISA. (line 208)
+* Sun: ABI and ISA. (line 201)
* SunOS: Notes for Particular Systems.
- (line 144)
+ (line 125)
* Systems: Notes for Particular Systems.
(line 6)
-* Temporary memory: Build Options. (line 274)
-* Texinfo: Build Options. (line 339)
+* Temporary memory: Build Options. (line 278)
+* Texinfo: Build Options. (line 347)
* Text input/output: Efficiency. (line 153)
* Thread safety: Reentrancy. (line 6)
-* Toom multiplication <1>: Higher degree Toom'n'half.
- (line 6)
-* Toom multiplication <2>: Other Multiplication.
+* Toom multiplication <1>: Toom 4-Way Multiplication.
(line 6)
-* Toom multiplication <3>: Toom 4-Way Multiplication.
+* Toom multiplication <2>: Toom 3-Way Multiplication.
(line 6)
-* Toom multiplication: Toom 3-Way Multiplication.
+* Toom multiplication: Other Multiplication.
(line 6)
* Types: Nomenclature and Types.
(line 6)
@@ -3122,14 +2711,14 @@ Concept Index
(line 6)
* Version number: Useful Macros and Constants.
(line 12)
-* Web page: Introduction to GMP. (line 33)
+* Web page: Introduction to GMP. (line 34)
* Windows: Notes for Particular Systems.
- (line 70)
+ (line 61)
* x86: Notes for Particular Systems.
- (line 150)
+ (line 131)
* x87: Notes for Particular Systems.
(line 34)
-* XML: Build Options. (line 346)
+* XML: Build Options. (line 354)

File: gmp.info, Node: Function Index, Prev: Concept Index, Up: Top
@@ -3151,27 +2740,29 @@ Function and Type Index
* __GNU_MP_VERSION_PATCHLEVEL: Useful Macros and Constants.
(line 12)
* _mpz_realloc: Integer Special Functions.
- (line 14)
-* abs <1>: C++ Interface Rationals.
- (line 49)
-* abs <2>: C++ Interface Floats.
- (line 83)
-* abs: C++ Interface Integers.
- (line 47)
+ (line 51)
+* abs <1>: C++ Interface Floats.
+ (line 70)
+* abs <2>: C++ Interface Integers.
+ (line 42)
+* abs: C++ Interface Rationals.
+ (line 43)
* ceil: C++ Interface Floats.
- (line 84)
+ (line 71)
* cmp <1>: C++ Interface Floats.
- (line 86)
-* cmp <2>: C++ Interface Rationals.
- (line 51)
-* cmp <3>: C++ Interface Floats.
- (line 85)
-* cmp <4>: C++ Interface Rationals.
- (line 50)
-* cmp: C++ Interface Integers.
- (line 49)
+ (line 73)
+* cmp <2>: C++ Interface Integers.
+ (line 44)
+* cmp <3>: C++ Interface Rationals.
+ (line 45)
+* cmp <4>: C++ Interface Integers.
+ (line 43)
+* cmp: C++ Interface Floats.
+ (line 72)
* floor: C++ Interface Floats.
- (line 93)
+ (line 80)
+* gcd: BSD Compatible Functions.
+ (line 82)
* gmp_asprintf: Formatted Output Functions.
(line 65)
* gmp_errno: Random State Initialization.
@@ -3184,12 +2775,12 @@ Function and Type Index
(line 29)
* gmp_fscanf: Formatted Input Functions.
(line 25)
-* GMP_LIMB_BITS: Low-level Functions. (line 694)
-* GMP_NAIL_BITS: Low-level Functions. (line 692)
-* GMP_NAIL_MASK: Low-level Functions. (line 702)
-* GMP_NUMB_BITS: Low-level Functions. (line 693)
-* GMP_NUMB_MASK: Low-level Functions. (line 703)
-* GMP_NUMB_MAX: Low-level Functions. (line 711)
+* GMP_LIMB_BITS: Low-level Functions. (line 464)
+* GMP_NAIL_BITS: Low-level Functions. (line 462)
+* GMP_NAIL_MASK: Low-level Functions. (line 472)
+* GMP_NUMB_BITS: Low-level Functions. (line 463)
+* GMP_NUMB_MASK: Low-level Functions. (line 473)
+* GMP_NUMB_MAX: Low-level Functions. (line 481)
* gmp_obstack_printf: Formatted Output Functions.
(line 79)
* gmp_obstack_vprintf: Formatted Output Functions.
@@ -3205,13 +2796,13 @@ Function and Type Index
* gmp_randclass::get_f: C++ Interface Random Numbers.
(line 45)
* gmp_randclass::get_z_bits: C++ Interface Random Numbers.
- (line 38)
+ (line 39)
* gmp_randclass::get_z_range: C++ Interface Random Numbers.
(line 42)
* gmp_randclass::gmp_randclass: C++ Interface Random Numbers.
(line 27)
* gmp_randclass::seed: C++ Interface Random Numbers.
- (line 33)
+ (line 34)
* gmp_randclear: Random State Initialization.
(line 62)
* gmp_randinit: Random State Initialization.
@@ -3227,11 +2818,11 @@ Function and Type Index
* gmp_randinit_set: Random State Initialization.
(line 43)
* gmp_randseed: Random State Seeding.
- (line 8)
+ (line 7)
* gmp_randseed_ui: Random State Seeding.
- (line 10)
+ (line 9)
* gmp_randstate_t: Nomenclature and Types.
- (line 46)
+ (line 41)
* gmp_scanf: Formatted Input Functions.
(line 21)
* gmp_snprintf: Formatted Output Functions.
@@ -3263,17 +2854,33 @@ Function and Type Index
* gmp_vsscanf: Formatted Input Functions.
(line 31)
* hypot: C++ Interface Floats.
+ (line 81)
+* itom: BSD Compatible Functions.
+ (line 29)
+* madd: BSD Compatible Functions.
+ (line 43)
+* mcmp: BSD Compatible Functions.
+ (line 85)
+* mdiv: BSD Compatible Functions.
+ (line 53)
+* mfree: BSD Compatible Functions.
+ (line 105)
+* min: BSD Compatible Functions.
+ (line 89)
+* MINT: BSD Compatible Functions.
+ (line 21)
+* mout: BSD Compatible Functions.
(line 94)
-* mp_bitcnt_t: Nomenclature and Types.
- (line 42)
+* move: BSD Compatible Functions.
+ (line 39)
* mp_bits_per_limb: Useful Macros and Constants.
(line 7)
* mp_exp_t: Nomenclature and Types.
(line 27)
-* mp_get_memory_functions: Custom Allocation. (line 90)
+* mp_get_memory_functions: Custom Allocation. (line 93)
* mp_limb_t: Nomenclature and Types.
(line 31)
-* mp_set_memory_functions: Custom Allocation. (line 18)
+* mp_set_memory_functions: Custom Allocation. (line 21)
* mp_size_t: Nomenclature and Types.
(line 37)
* mpf_abs: Float Arithmetic. (line 47)
@@ -3284,43 +2891,40 @@ Function and Type Index
* mpf_class: C++ Interface General.
(line 20)
* mpf_class::fits_sint_p: C++ Interface Floats.
- (line 87)
+ (line 74)
* mpf_class::fits_slong_p: C++ Interface Floats.
- (line 88)
+ (line 75)
* mpf_class::fits_sshort_p: C++ Interface Floats.
- (line 89)
+ (line 76)
* mpf_class::fits_uint_p: C++ Interface Floats.
- (line 90)
+ (line 77)
* mpf_class::fits_ulong_p: C++ Interface Floats.
- (line 91)
+ (line 78)
* mpf_class::fits_ushort_p: C++ Interface Floats.
- (line 92)
+ (line 79)
* mpf_class::get_d: C++ Interface Floats.
- (line 95)
+ (line 82)
* mpf_class::get_mpf_t: C++ Interface General.
(line 66)
* mpf_class::get_prec: C++ Interface Floats.
- (line 115)
+ (line 100)
* mpf_class::get_si: C++ Interface Floats.
- (line 96)
+ (line 83)
* mpf_class::get_str: C++ Interface Floats.
- (line 98)
+ (line 85)
* mpf_class::get_ui: C++ Interface Floats.
- (line 99)
+ (line 86)
* mpf_class::mpf_class: C++ Interface Floats.
- (line 12)
+ (line 33)
* mpf_class::operator=: C++ Interface Floats.
- (line 60)
+ (line 47)
* mpf_class::set_prec: C++ Interface Floats.
- (line 116)
+ (line 101)
* mpf_class::set_prec_raw: C++ Interface Floats.
- (line 117)
+ (line 102)
* mpf_class::set_str: C++ Interface Floats.
- (line 100)
-* mpf_class::swap: C++ Interface Floats.
- (line 104)
-* mpf_clear: Initializing Floats. (line 37)
-* mpf_clears: Initializing Floats. (line 41)
+ (line 87)
+* mpf_clear: Initializing Floats. (line 31)
* mpf_cmp: Float Comparison. (line 7)
* mpf_cmp_d: Float Comparison. (line 8)
* mpf_cmp_si: Float Comparison. (line 10)
@@ -3328,7 +2932,7 @@ Function and Type Index
* mpf_div: Float Arithmetic. (line 29)
* mpf_div_2exp: Float Arithmetic. (line 55)
* mpf_div_ui: Float Arithmetic. (line 33)
-* mpf_eq: Float Comparison. (line 18)
+* mpf_eq: Float Comparison. (line 17)
* mpf_fits_sint_p: Miscellaneous Float Functions.
(line 20)
* mpf_fits_slong_p: Miscellaneous Float Functions.
@@ -3344,12 +2948,12 @@ Function and Type Index
* mpf_floor: Miscellaneous Float Functions.
(line 8)
* mpf_get_d: Converting Floats. (line 7)
-* mpf_get_d_2exp: Converting Floats. (line 17)
+* mpf_get_d_2exp: Converting Floats. (line 16)
* mpf_get_default_prec: Initializing Floats. (line 12)
-* mpf_get_prec: Initializing Floats. (line 62)
-* mpf_get_si: Converting Floats. (line 28)
-* mpf_get_str: Converting Floats. (line 38)
-* mpf_get_ui: Converting Floats. (line 29)
+* mpf_get_prec: Initializing Floats. (line 52)
+* mpf_get_si: Converting Floats. (line 27)
+* mpf_get_str: Converting Floats. (line 37)
+* mpf_get_ui: Converting Floats. (line 28)
* mpf_init: Initializing Floats. (line 19)
* mpf_init2: Initializing Floats. (line 26)
* mpf_init_set: Simultaneous Float Init & Assign.
@@ -3359,33 +2963,32 @@ Function and Type Index
* mpf_init_set_si: Simultaneous Float Init & Assign.
(line 18)
* mpf_init_set_str: Simultaneous Float Init & Assign.
- (line 26)
+ (line 25)
* mpf_init_set_ui: Simultaneous Float Init & Assign.
(line 17)
-* mpf_inits: Initializing Floats. (line 31)
-* mpf_inp_str: I/O of Floats. (line 39)
+* mpf_inp_str: I/O of Floats. (line 37)
* mpf_integer_p: Miscellaneous Float Functions.
(line 14)
* mpf_mul: Float Arithmetic. (line 19)
* mpf_mul_2exp: Float Arithmetic. (line 51)
* mpf_mul_ui: Float Arithmetic. (line 21)
* mpf_neg: Float Arithmetic. (line 44)
-* mpf_out_str: I/O of Floats. (line 19)
+* mpf_out_str: I/O of Floats. (line 17)
* mpf_pow_ui: Float Arithmetic. (line 41)
* mpf_random2: Miscellaneous Float Functions.
- (line 37)
-* mpf_reldiff: Float Comparison. (line 31)
+ (line 36)
+* mpf_reldiff: Float Comparison. (line 29)
* mpf_set: Assigning Floats. (line 10)
* mpf_set_d: Assigning Floats. (line 13)
* mpf_set_default_prec: Initializing Floats. (line 7)
-* mpf_set_prec: Initializing Floats. (line 65)
-* mpf_set_prec_raw: Initializing Floats. (line 72)
+* mpf_set_prec: Initializing Floats. (line 55)
+* mpf_set_prec_raw: Initializing Floats. (line 62)
* mpf_set_q: Assigning Floats. (line 15)
* mpf_set_si: Assigning Floats. (line 12)
* mpf_set_str: Assigning Floats. (line 18)
* mpf_set_ui: Assigning Floats. (line 11)
* mpf_set_z: Assigning Floats. (line 14)
-* mpf_sgn: Float Comparison. (line 35)
+* mpf_sgn: Float Comparison. (line 33)
* mpf_sqrt: Float Arithmetic. (line 36)
* mpf_sqrt_ui: Float Arithmetic. (line 37)
* mpf_sub: Float Arithmetic. (line 12)
@@ -3402,109 +3005,75 @@ Function and Type Index
* mpn_add: Low-level Functions. (line 69)
* mpn_add_1: Low-level Functions. (line 64)
* mpn_add_n: Low-level Functions. (line 54)
-* mpn_addmul_1: Low-level Functions. (line 150)
-* mpn_and_n: Low-level Functions. (line 437)
-* mpn_andn_n: Low-level Functions. (line 452)
-* mpn_cmp: Low-level Functions. (line 286)
-* mpn_cnd_add_n: Low-level Functions. (line 530)
-* mpn_cnd_sub_n: Low-level Functions. (line 532)
-* mpn_com: Low-level Functions. (line 477)
-* mpn_copyd: Low-level Functions. (line 486)
-* mpn_copyi: Low-level Functions. (line 482)
-* mpn_divexact_by3: Low-level Functions. (line 231)
-* mpn_divexact_by3c: Low-level Functions. (line 233)
-* mpn_divmod: Low-level Functions. (line 226)
-* mpn_divmod_1: Low-level Functions. (line 210)
-* mpn_divrem: Low-level Functions. (line 184)
-* mpn_divrem_1: Low-level Functions. (line 208)
-* mpn_gcd: Low-level Functions. (line 291)
-* mpn_gcd_1: Low-level Functions. (line 301)
-* mpn_gcdext: Low-level Functions. (line 307)
-* mpn_get_str: Low-level Functions. (line 361)
-* mpn_hamdist: Low-level Functions. (line 426)
-* mpn_ior_n: Low-level Functions. (line 442)
-* mpn_iorn_n: Low-level Functions. (line 457)
-* mpn_lshift: Low-level Functions. (line 262)
-* mpn_mod_1: Low-level Functions. (line 257)
-* mpn_mul: Low-level Functions. (line 116)
-* mpn_mul_1: Low-level Functions. (line 135)
-* mpn_mul_n: Low-level Functions. (line 105)
-* mpn_nand_n: Low-level Functions. (line 462)
-* mpn_neg: Low-level Functions. (line 98)
-* mpn_nior_n: Low-level Functions. (line 467)
-* mpn_perfect_square_p: Low-level Functions. (line 432)
-* mpn_popcount: Low-level Functions. (line 422)
-* mpn_random: Low-level Functions. (line 411)
-* mpn_random2: Low-level Functions. (line 412)
-* mpn_rshift: Low-level Functions. (line 274)
-* mpn_scan0: Low-level Functions. (line 396)
-* mpn_scan1: Low-level Functions. (line 404)
-* mpn_sec_add_1: Low-level Functions. (line 543)
-* mpn_sec_div_qr: Low-level Functions. (line 613)
-* mpn_sec_div_qr_itch: Low-level Functions. (line 614)
-* mpn_sec_div_r: Low-level Functions. (line 630)
-* mpn_sec_div_r_itch: Low-level Functions. (line 631)
-* mpn_sec_invert: Low-level Functions. (line 645)
-* mpn_sec_invert_itch: Low-level Functions. (line 646)
-* mpn_sec_mul: Low-level Functions. (line 558)
-* mpn_sec_mul_itch: Low-level Functions. (line 559)
-* mpn_sec_powm: Low-level Functions. (line 588)
-* mpn_sec_powm_itch: Low-level Functions. (line 590)
-* mpn_sec_sqr: Low-level Functions. (line 573)
-* mpn_sec_sqr_itch: Low-level Functions. (line 574)
-* mpn_sec_sub_1: Low-level Functions. (line 545)
-* mpn_sec_tabselect: Low-level Functions. (line 604)
-* mpn_set_str: Low-level Functions. (line 376)
-* mpn_sizeinbase: Low-level Functions. (line 354)
-* mpn_sqr: Low-level Functions. (line 127)
-* mpn_sqrtrem: Low-level Functions. (line 336)
+* mpn_addmul_1: Low-level Functions. (line 143)
+* mpn_bdivmod: Low-level Functions. (line 255)
+* mpn_cmp: Low-level Functions. (line 296)
+* mpn_divexact_by3: Low-level Functions. (line 223)
+* mpn_divexact_by3c: Low-level Functions. (line 225)
+* mpn_divmod: Low-level Functions. (line 218)
+* mpn_divmod_1: Low-level Functions. (line 202)
+* mpn_divrem: Low-level Functions. (line 176)
+* mpn_divrem_1: Low-level Functions. (line 200)
+* mpn_gcd: Low-level Functions. (line 301)
+* mpn_gcd_1: Low-level Functions. (line 311)
+* mpn_gcdext: Low-level Functions. (line 317)
+* mpn_get_str: Low-level Functions. (line 358)
+* mpn_hamdist: Low-level Functions. (line 422)
+* mpn_lshift: Low-level Functions. (line 272)
+* mpn_mod_1: Low-level Functions. (line 249)
+* mpn_mul: Low-level Functions. (line 109)
+* mpn_mul_1: Low-level Functions. (line 128)
+* mpn_mul_n: Low-level Functions. (line 98)
+* mpn_perfect_square_p: Low-level Functions. (line 428)
+* mpn_popcount: Low-level Functions. (line 418)
+* mpn_random: Low-level Functions. (line 407)
+* mpn_random2: Low-level Functions. (line 408)
+* mpn_rshift: Low-level Functions. (line 284)
+* mpn_scan0: Low-level Functions. (line 392)
+* mpn_scan1: Low-level Functions. (line 400)
+* mpn_set_str: Low-level Functions. (line 373)
+* mpn_sqr_n: Low-level Functions. (line 120)
+* mpn_sqrtrem: Low-level Functions. (line 340)
* mpn_sub: Low-level Functions. (line 90)
* mpn_sub_1: Low-level Functions. (line 85)
* mpn_sub_n: Low-level Functions. (line 76)
-* mpn_submul_1: Low-level Functions. (line 161)
-* mpn_tdiv_qr: Low-level Functions. (line 173)
-* mpn_xnor_n: Low-level Functions. (line 472)
-* mpn_xor_n: Low-level Functions. (line 447)
-* mpn_zero: Low-level Functions. (line 489)
-* mpq_abs: Rational Arithmetic. (line 34)
-* mpq_add: Rational Arithmetic. (line 8)
+* mpn_submul_1: Low-level Functions. (line 154)
+* mpn_tdiv_qr: Low-level Functions. (line 166)
+* mpq_abs: Rational Arithmetic. (line 33)
+* mpq_add: Rational Arithmetic. (line 7)
* mpq_canonicalize: Rational Number Functions.
(line 22)
* mpq_class: C++ Interface General.
(line 19)
* mpq_class::canonicalize: C++ Interface Rationals.
- (line 43)
+ (line 37)
* mpq_class::get_d: C++ Interface Rationals.
- (line 52)
+ (line 46)
* mpq_class::get_den: C++ Interface Rationals.
- (line 66)
+ (line 58)
* mpq_class::get_den_mpz_t: C++ Interface Rationals.
- (line 76)
+ (line 68)
* mpq_class::get_mpq_t: C++ Interface General.
(line 65)
* mpq_class::get_num: C++ Interface Rationals.
- (line 65)
+ (line 57)
* mpq_class::get_num_mpz_t: C++ Interface Rationals.
- (line 75)
+ (line 67)
* mpq_class::get_str: C++ Interface Rationals.
- (line 53)
+ (line 47)
* mpq_class::mpq_class: C++ Interface Rationals.
(line 12)
* mpq_class::set_str: C++ Interface Rationals.
- (line 55)
-* mpq_class::swap: C++ Interface Rationals.
- (line 57)
+ (line 48)
* mpq_clear: Initializing Rationals.
- (line 16)
-* mpq_clears: Initializing Rationals.
- (line 20)
+ (line 12)
* mpq_cmp: Comparing Rationals. (line 7)
* mpq_cmp_si: Comparing Rationals. (line 17)
* mpq_cmp_ui: Comparing Rationals. (line 15)
* mpq_denref: Applying Integer Functions.
(line 18)
-* mpq_div: Rational Arithmetic. (line 24)
-* mpq_div_2exp: Rational Arithmetic. (line 28)
+* mpq_div: Rational Arithmetic. (line 23)
+* mpq_div_2exp: Rational Arithmetic. (line 27)
* mpq_equal: Comparing Rationals. (line 33)
* mpq_get_d: Rational Conversions.
(line 7)
@@ -3516,18 +3085,16 @@ Function and Type Index
(line 22)
* mpq_init: Initializing Rationals.
(line 7)
-* mpq_inits: Initializing Rationals.
- (line 12)
-* mpq_inp_str: I/O of Rationals. (line 27)
-* mpq_inv: Rational Arithmetic. (line 37)
-* mpq_mul: Rational Arithmetic. (line 16)
-* mpq_mul_2exp: Rational Arithmetic. (line 20)
-* mpq_neg: Rational Arithmetic. (line 31)
+* mpq_inp_str: I/O of Rationals. (line 23)
+* mpq_inv: Rational Arithmetic. (line 36)
+* mpq_mul: Rational Arithmetic. (line 15)
+* mpq_mul_2exp: Rational Arithmetic. (line 19)
+* mpq_neg: Rational Arithmetic. (line 30)
* mpq_numref: Applying Integer Functions.
(line 17)
-* mpq_out_str: I/O of Rationals. (line 19)
+* mpq_out_str: I/O of Rationals. (line 15)
* mpq_set: Initializing Rationals.
- (line 24)
+ (line 16)
* mpq_set_d: Rational Conversions.
(line 17)
* mpq_set_den: Applying Integer Functions.
@@ -3537,79 +3104,73 @@ Function and Type Index
* mpq_set_num: Applying Integer Functions.
(line 25)
* mpq_set_si: Initializing Rationals.
- (line 31)
+ (line 23)
* mpq_set_str: Initializing Rationals.
- (line 36)
+ (line 28)
* mpq_set_ui: Initializing Rationals.
- (line 29)
+ (line 21)
* mpq_set_z: Initializing Rationals.
- (line 25)
+ (line 17)
* mpq_sgn: Comparing Rationals. (line 27)
-* mpq_sub: Rational Arithmetic. (line 12)
+* mpq_sub: Rational Arithmetic. (line 11)
* mpq_swap: Initializing Rationals.
- (line 56)
+ (line 48)
* mpq_t: Nomenclature and Types.
(line 16)
-* mpz_2fac_ui: Number Theoretic Functions.
- (line 114)
-* mpz_abs: Integer Arithmetic. (line 45)
+* mpz_abs: Integer Arithmetic. (line 43)
* mpz_add: Integer Arithmetic. (line 7)
* mpz_add_ui: Integer Arithmetic. (line 9)
-* mpz_addmul: Integer Arithmetic. (line 26)
-* mpz_addmul_ui: Integer Arithmetic. (line 28)
+* mpz_addmul: Integer Arithmetic. (line 25)
+* mpz_addmul_ui: Integer Arithmetic. (line 27)
* mpz_and: Integer Logic and Bit Fiddling.
(line 11)
* mpz_array_init: Integer Special Functions.
(line 11)
* mpz_bin_ui: Number Theoretic Functions.
- (line 126)
+ (line 99)
* mpz_bin_uiui: Number Theoretic Functions.
- (line 128)
+ (line 101)
* mpz_cdiv_q: Integer Division. (line 13)
-* mpz_cdiv_q_2exp: Integer Division. (line 26)
-* mpz_cdiv_q_ui: Integer Division. (line 18)
-* mpz_cdiv_qr: Integer Division. (line 16)
-* mpz_cdiv_qr_ui: Integer Division. (line 22)
+* mpz_cdiv_q_2exp: Integer Division. (line 25)
+* mpz_cdiv_q_ui: Integer Division. (line 17)
+* mpz_cdiv_qr: Integer Division. (line 15)
+* mpz_cdiv_qr_ui: Integer Division. (line 21)
* mpz_cdiv_r: Integer Division. (line 14)
-* mpz_cdiv_r_2exp: Integer Division. (line 28)
-* mpz_cdiv_r_ui: Integer Division. (line 20)
-* mpz_cdiv_ui: Integer Division. (line 24)
+* mpz_cdiv_r_2exp: Integer Division. (line 27)
+* mpz_cdiv_r_ui: Integer Division. (line 19)
+* mpz_cdiv_ui: Integer Division. (line 23)
* mpz_class: C++ Interface General.
(line 18)
* mpz_class::fits_sint_p: C++ Interface Integers.
- (line 50)
+ (line 45)
* mpz_class::fits_slong_p: C++ Interface Integers.
- (line 51)
+ (line 46)
* mpz_class::fits_sshort_p: C++ Interface Integers.
- (line 52)
+ (line 47)
* mpz_class::fits_uint_p: C++ Interface Integers.
- (line 53)
+ (line 48)
* mpz_class::fits_ulong_p: C++ Interface Integers.
- (line 54)
+ (line 49)
* mpz_class::fits_ushort_p: C++ Interface Integers.
- (line 55)
+ (line 50)
* mpz_class::get_d: C++ Interface Integers.
- (line 56)
+ (line 51)
* mpz_class::get_mpz_t: C++ Interface General.
(line 64)
* mpz_class::get_si: C++ Interface Integers.
- (line 57)
+ (line 52)
* mpz_class::get_str: C++ Interface Integers.
- (line 58)
+ (line 53)
* mpz_class::get_ui: C++ Interface Integers.
- (line 59)
+ (line 54)
* mpz_class::mpz_class: C++ Interface Integers.
- (line 21)
+ (line 7)
* mpz_class::set_str: C++ Interface Integers.
- (line 60)
-* mpz_class::swap: C++ Interface Integers.
- (line 64)
+ (line 56)
* mpz_clear: Initializing Integers.
- (line 49)
-* mpz_clears: Initializing Integers.
- (line 53)
+ (line 40)
* mpz_clrbit: Integer Logic and Bit Fiddling.
- (line 56)
+ (line 55)
* mpz_cmp: Integer Comparisons. (line 7)
* mpz_cmp_d: Integer Comparisons. (line 8)
* mpz_cmp_si: Integer Comparisons. (line 9)
@@ -3620,34 +3181,34 @@ Function and Type Index
* mpz_com: Integer Logic and Bit Fiddling.
(line 20)
* mpz_combit: Integer Logic and Bit Fiddling.
- (line 59)
-* mpz_congruent_2exp_p: Integer Division. (line 137)
-* mpz_congruent_p: Integer Division. (line 133)
-* mpz_congruent_ui_p: Integer Division. (line 135)
-* mpz_divexact: Integer Division. (line 110)
-* mpz_divexact_ui: Integer Division. (line 112)
-* mpz_divisible_2exp_p: Integer Division. (line 123)
-* mpz_divisible_p: Integer Division. (line 120)
-* mpz_divisible_ui_p: Integer Division. (line 122)
+ (line 58)
+* mpz_congruent_2exp_p: Integer Division. (line 131)
+* mpz_congruent_p: Integer Division. (line 127)
+* mpz_congruent_ui_p: Integer Division. (line 129)
+* mpz_divexact: Integer Division. (line 107)
+* mpz_divexact_ui: Integer Division. (line 108)
+* mpz_divisible_2exp_p: Integer Division. (line 118)
+* mpz_divisible_p: Integer Division. (line 116)
+* mpz_divisible_ui_p: Integer Division. (line 117)
* mpz_even_p: Miscellaneous Integer Functions.
(line 18)
* mpz_export: Integer Import and Export.
(line 45)
* mpz_fac_ui: Number Theoretic Functions.
- (line 113)
-* mpz_fdiv_q: Integer Division. (line 30)
-* mpz_fdiv_q_2exp: Integer Division. (line 43)
-* mpz_fdiv_q_ui: Integer Division. (line 35)
-* mpz_fdiv_qr: Integer Division. (line 33)
-* mpz_fdiv_qr_ui: Integer Division. (line 39)
-* mpz_fdiv_r: Integer Division. (line 31)
-* mpz_fdiv_r_2exp: Integer Division. (line 45)
-* mpz_fdiv_r_ui: Integer Division. (line 37)
-* mpz_fdiv_ui: Integer Division. (line 41)
+ (line 96)
+* mpz_fdiv_q: Integer Division. (line 29)
+* mpz_fdiv_q_2exp: Integer Division. (line 41)
+* mpz_fdiv_q_ui: Integer Division. (line 33)
+* mpz_fdiv_qr: Integer Division. (line 31)
+* mpz_fdiv_qr_ui: Integer Division. (line 37)
+* mpz_fdiv_r: Integer Division. (line 30)
+* mpz_fdiv_r_2exp: Integer Division. (line 43)
+* mpz_fdiv_r_ui: Integer Division. (line 35)
+* mpz_fdiv_ui: Integer Division. (line 39)
* mpz_fib2_ui: Number Theoretic Functions.
- (line 136)
+ (line 109)
* mpz_fib_ui: Number Theoretic Functions.
- (line 134)
+ (line 107)
* mpz_fits_sint_p: Miscellaneous Integer Functions.
(line 10)
* mpz_fits_slong_p: Miscellaneous Integer Functions.
@@ -3661,18 +3222,18 @@ Function and Type Index
* mpz_fits_ushort_p: Miscellaneous Integer Functions.
(line 11)
* mpz_gcd: Number Theoretic Functions.
- (line 32)
+ (line 30)
* mpz_gcd_ui: Number Theoretic Functions.
- (line 39)
+ (line 35)
* mpz_gcdext: Number Theoretic Functions.
- (line 49)
+ (line 45)
* mpz_get_d: Converting Integers. (line 27)
-* mpz_get_d_2exp: Converting Integers. (line 36)
+* mpz_get_d_2exp: Converting Integers. (line 35)
* mpz_get_si: Converting Integers. (line 18)
-* mpz_get_str: Converting Integers. (line 47)
+* mpz_get_str: Converting Integers. (line 46)
* mpz_get_ui: Converting Integers. (line 11)
* mpz_getlimbn: Integer Special Functions.
- (line 23)
+ (line 60)
* mpz_hamdist: Integer Logic and Bit Fiddling.
(line 29)
* mpz_import: Integer Import and Export.
@@ -3680,7 +3241,7 @@ Function and Type Index
* mpz_init: Initializing Integers.
(line 26)
* mpz_init2: Initializing Integers.
- (line 33)
+ (line 29)
* mpz_init_set: Simultaneous Integer Init & Assign.
(line 27)
* mpz_init_set_d: Simultaneous Integer Init & Assign.
@@ -3688,72 +3249,56 @@ Function and Type Index
* mpz_init_set_si: Simultaneous Integer Init & Assign.
(line 29)
* mpz_init_set_str: Simultaneous Integer Init & Assign.
- (line 35)
+ (line 34)
* mpz_init_set_ui: Simultaneous Integer Init & Assign.
(line 28)
-* mpz_inits: Initializing Integers.
- (line 29)
-* mpz_inp_raw: I/O of Integers. (line 62)
-* mpz_inp_str: I/O of Integers. (line 31)
+* mpz_inp_raw: I/O of Integers. (line 59)
+* mpz_inp_str: I/O of Integers. (line 28)
* mpz_invert: Number Theoretic Functions.
- (line 76)
+ (line 60)
* mpz_ior: Integer Logic and Bit Fiddling.
(line 14)
* mpz_jacobi: Number Theoretic Functions.
- (line 83)
+ (line 66)
* mpz_kronecker: Number Theoretic Functions.
- (line 91)
+ (line 74)
* mpz_kronecker_si: Number Theoretic Functions.
- (line 92)
+ (line 75)
* mpz_kronecker_ui: Number Theoretic Functions.
- (line 93)
+ (line 76)
* mpz_lcm: Number Theoretic Functions.
- (line 68)
+ (line 54)
* mpz_lcm_ui: Number Theoretic Functions.
- (line 70)
+ (line 55)
* mpz_legendre: Number Theoretic Functions.
- (line 86)
-* mpz_limbs_finish: Integer Special Functions.
- (line 48)
-* mpz_limbs_modify: Integer Special Functions.
- (line 41)
-* mpz_limbs_read: Integer Special Functions.
- (line 35)
-* mpz_limbs_write: Integer Special Functions.
- (line 40)
+ (line 69)
* mpz_lucnum2_ui: Number Theoretic Functions.
- (line 147)
+ (line 120)
* mpz_lucnum_ui: Number Theoretic Functions.
- (line 145)
-* mpz_mfac_uiui: Number Theoretic Functions.
- (line 116)
-* mpz_mod: Integer Division. (line 100)
-* mpz_mod_ui: Integer Division. (line 102)
+ (line 118)
+* mpz_mod: Integer Division. (line 97)
+* mpz_mod_ui: Integer Division. (line 99)
* mpz_mul: Integer Arithmetic. (line 19)
-* mpz_mul_2exp: Integer Arithmetic. (line 38)
+* mpz_mul_2exp: Integer Arithmetic. (line 36)
* mpz_mul_si: Integer Arithmetic. (line 20)
* mpz_mul_ui: Integer Arithmetic. (line 22)
-* mpz_neg: Integer Arithmetic. (line 42)
+* mpz_neg: Integer Arithmetic. (line 40)
* mpz_nextprime: Number Theoretic Functions.
- (line 25)
+ (line 23)
* mpz_odd_p: Miscellaneous Integer Functions.
(line 17)
-* mpz_out_raw: I/O of Integers. (line 46)
-* mpz_out_str: I/O of Integers. (line 19)
-* mpz_perfect_power_p: Integer Roots. (line 28)
-* mpz_perfect_square_p: Integer Roots. (line 37)
+* mpz_out_raw: I/O of Integers. (line 43)
+* mpz_out_str: I/O of Integers. (line 16)
+* mpz_perfect_power_p: Integer Roots. (line 27)
+* mpz_perfect_square_p: Integer Roots. (line 36)
* mpz_popcount: Integer Logic and Bit Fiddling.
(line 23)
* mpz_pow_ui: Integer Exponentiation.
- (line 31)
+ (line 18)
* mpz_powm: Integer Exponentiation.
(line 8)
-* mpz_powm_sec: Integer Exponentiation.
- (line 18)
* mpz_powm_ui: Integer Exponentiation.
(line 10)
-* mpz_primorial_ui: Number Theoretic Functions.
- (line 121)
* mpz_probab_prime_p: Number Theoretic Functions.
(line 7)
* mpz_random: Integer Random Numbers.
@@ -3761,15 +3306,11 @@ Function and Type Index
* mpz_random2: Integer Random Numbers.
(line 51)
* mpz_realloc2: Initializing Integers.
- (line 57)
+ (line 44)
* mpz_remove: Number Theoretic Functions.
- (line 108)
-* mpz_roinit_n: Integer Special Functions.
- (line 69)
-* MPZ_ROINIT_N: Integer Special Functions.
- (line 84)
-* mpz_root: Integer Roots. (line 8)
-* mpz_rootrem: Integer Roots. (line 14)
+ (line 91)
+* mpz_root: Integer Roots. (line 7)
+* mpz_rootrem: Integer Roots. (line 13)
* mpz_rrandomb: Integer Random Numbers.
(line 31)
* mpz_scan0: Integer Logic and Bit Fiddling.
@@ -3784,38 +3325,38 @@ Function and Type Index
* mpz_set_str: Assigning Integers. (line 21)
* mpz_set_ui: Assigning Integers. (line 11)
* mpz_setbit: Integer Logic and Bit Fiddling.
- (line 53)
+ (line 52)
* mpz_sgn: Integer Comparisons. (line 28)
* mpz_si_kronecker: Number Theoretic Functions.
- (line 94)
+ (line 77)
* mpz_size: Integer Special Functions.
- (line 31)
+ (line 68)
* mpz_sizeinbase: Miscellaneous Integer Functions.
(line 23)
-* mpz_sqrt: Integer Roots. (line 18)
-* mpz_sqrtrem: Integer Roots. (line 21)
+* mpz_sqrt: Integer Roots. (line 17)
+* mpz_sqrtrem: Integer Roots. (line 20)
* mpz_sub: Integer Arithmetic. (line 12)
* mpz_sub_ui: Integer Arithmetic. (line 14)
-* mpz_submul: Integer Arithmetic. (line 32)
-* mpz_submul_ui: Integer Arithmetic. (line 34)
+* mpz_submul: Integer Arithmetic. (line 30)
+* mpz_submul_ui: Integer Arithmetic. (line 32)
* mpz_swap: Assigning Integers. (line 37)
* mpz_t: Nomenclature and Types.
(line 6)
-* mpz_tdiv_q: Integer Division. (line 47)
-* mpz_tdiv_q_2exp: Integer Division. (line 60)
-* mpz_tdiv_q_ui: Integer Division. (line 52)
-* mpz_tdiv_qr: Integer Division. (line 50)
-* mpz_tdiv_qr_ui: Integer Division. (line 56)
-* mpz_tdiv_r: Integer Division. (line 48)
-* mpz_tdiv_r_2exp: Integer Division. (line 62)
-* mpz_tdiv_r_ui: Integer Division. (line 54)
-* mpz_tdiv_ui: Integer Division. (line 58)
+* mpz_tdiv_q: Integer Division. (line 45)
+* mpz_tdiv_q_2exp: Integer Division. (line 57)
+* mpz_tdiv_q_ui: Integer Division. (line 49)
+* mpz_tdiv_qr: Integer Division. (line 47)
+* mpz_tdiv_qr_ui: Integer Division. (line 53)
+* mpz_tdiv_r: Integer Division. (line 46)
+* mpz_tdiv_r_2exp: Integer Division. (line 59)
+* mpz_tdiv_r_ui: Integer Division. (line 51)
+* mpz_tdiv_ui: Integer Division. (line 55)
* mpz_tstbit: Integer Logic and Bit Fiddling.
- (line 62)
+ (line 61)
* mpz_ui_kronecker: Number Theoretic Functions.
- (line 95)
+ (line 78)
* mpz_ui_pow_ui: Integer Exponentiation.
- (line 33)
+ (line 20)
* mpz_ui_sub: Integer Arithmetic. (line 16)
* mpz_urandomb: Integer Random Numbers.
(line 14)
@@ -3823,43 +3364,43 @@ Function and Type Index
(line 23)
* mpz_xor: Integer Logic and Bit Fiddling.
(line 17)
-* operator"" <1>: C++ Interface Floats.
- (line 56)
-* operator"" <2>: C++ Interface Integers.
- (line 30)
-* operator"": C++ Interface Rationals.
- (line 38)
+* msqrt: BSD Compatible Functions.
+ (line 63)
+* msub: BSD Compatible Functions.
+ (line 46)
+* mtox: BSD Compatible Functions.
+ (line 98)
+* mult: BSD Compatible Functions.
+ (line 49)
* operator%: C++ Interface Integers.
- (line 35)
+ (line 30)
* operator/: C++ Interface Integers.
- (line 34)
+ (line 29)
* operator<<: C++ Formatted Output.
- (line 20)
+ (line 33)
* operator>> <1>: C++ Formatted Input. (line 14)
-* operator>>: C++ Interface Rationals.
- (line 85)
-* sgn <1>: C++ Interface Floats.
- (line 102)
-* sgn <2>: C++ Interface Integers.
- (line 62)
-* sgn: C++ Interface Rationals.
- (line 56)
-* sqrt <1>: C++ Interface Integers.
- (line 63)
-* sqrt: C++ Interface Floats.
- (line 103)
-* swap <1>: C++ Interface Floats.
- (line 105)
-* swap <2>: C++ Interface Integers.
- (line 65)
-* swap: C++ Interface Rationals.
+* operator>> <2>: C++ Interface Rationals.
+ (line 77)
+* operator>>: C++ Formatted Input. (line 25)
+* pow: BSD Compatible Functions.
+ (line 71)
+* rpow: BSD Compatible Functions.
+ (line 79)
+* sdiv: BSD Compatible Functions.
+ (line 55)
+* sgn <1>: C++ Interface Rationals.
+ (line 50)
+* sgn <2>: C++ Interface Floats.
+ (line 89)
+* sgn: C++ Interface Integers.
+ (line 57)
+* sqrt <1>: C++ Interface Floats.
+ (line 90)
+* sqrt: C++ Interface Integers.
(line 58)
* trunc: C++ Interface Floats.
- (line 106)
-
+ (line 91)
+* xtom: BSD Compatible Functions.
+ (line 34)
-
-Local Variables:
-coding: iso-8859-1
-End:
diff --git a/gmp/doc/gmp.texi b/gmp/doc/gmp.texi
index 86d033101a..704faed27f 100644
--- a/gmp/doc/gmp.texi
+++ b/gmp/doc/gmp.texi
@@ -14,7 +14,8 @@
This manual describes how to install and use the GNU multiple precision
arithmetic library, version @value{VERSION}.
-Copyright 1991, 1993-2014 Free Software Foundation, Inc.
+Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.3 or any later
@@ -90,8 +91,8 @@ How to install and use the GNU multiple precision arithmetic library, version @v
@subtitle Edition @value{EDITION}
@subtitle @value{UPDATED}
-@author by Torbj@"orn Granlund and the GMP development team
-@c @email{tg@@gmplib.org}
+@author by the GMP developers
+@c @email{tege@@gmplib.org}
@c Include the Distribution inside the titlepage so
@c that headings are turned off.
@@ -135,6 +136,7 @@ How to install and use the GNU multiple precision arithmetic library, version @v
* Formatted Output:: @code{printf} style output.
* Formatted Input:: @code{scanf} style input.
* C++ Class Interface:: Class wrappers around GMP types.
+* BSD Compatible Functions:: All functions found in BSD MP.
* Custom Allocation:: How to customize the internal allocation.
* Language Bindings:: Using GMP from other languages.
* Algorithms:: What happens behind the scenes.
@@ -443,19 +445,10 @@ someone else and passed on, we want their recipients to know that what they
have is not what we distributed, so that any problems introduced by others
will not reflect on our reputation.@refill
-More precisely, the GNU MP library is dual licensed, under the conditions of
-the GNU Lesser General Public License version 3 (see
-@file{COPYING.LESSERv3}), or the GNU General Public License version 2 (see
-@file{COPYINGv2}). This is the recipient's choice, and the recipient also has
-the additional option of applying later versions of these licenses. (The
-reason for this dual licensing is to make it possible to use the library with
-programs which are licensed under GPL version 2, but which for historical or
-other reasons do not allow use under later versions of the GPL).
-
-Programs which are not part of the library itself, such as demonstration
-programs and the GMP testsuite, are licensed under the terms of the GNU
-General Public License version 3 (see @file{COPYINGv3}), or any later
-version.
+The precise conditions of the license for the GNU MP library are found in the
+Lesser General Public License version 3 that accompanies the source code,
+see @file{COPYING.LIB}. Certain demonstration programs are provided under the
+terms of the plain General Public License version 3, see @file{COPYING}.
@node Introduction to GMP, Installing GMP, Copying, Top
@@ -480,17 +473,29 @@ emphasis on speed (as opposed to simplicity or elegance).
There is assembly code for these CPUs:
@cindex CPU types
-ARM Cortex-A9, Cortex-A15, and generic ARM,
+ARM,
DEC Alpha 21064, 21164, and 21264,
-AMD K8 and K10 (sold under many brands, e.g. Athlon64, Phenom, Opteron)
-Bulldozer, and Bobcat,
-Intel Pentium, Pentium Pro/II/III, Pentium 4, Core2, Nehalem, Sandy bridge, Haswell, generic x86,
-Intel IA-64,
-Motorola/IBM PowerPC 32 and 64 such as POWER970, POWER5, POWER6, and POWER7,
-MIPS 32-bit and 64-bit,
-SPARC 32-bit ad 64-bit with special support for all UltraSPARC models.
-There is also assembly code for many obsolete CPUs.
-
+AMD 29000,
+AMD K6, K6-2, Athlon, and Athlon64,
+Hitachi SuperH and SH-2,
+HPPA 1.0, 1.1 and 2.0,
+Intel Pentium, Pentium Pro/II/III, Pentium 4, generic x86,
+Intel IA-64, i960,
+Motorola MC68000, MC68020, MC88100, and MC88110,
+Motorola/IBM PowerPC 32 and 64,
+National NS32000,
+IBM POWER,
+MIPS R3000, R4000,
+SPARCv7, SuperSPARC, generic SPARCv8, UltraSPARC,
+DEC VAX,
+and
+Zilog Z8000.
+Some optimizations also for
+Cray vector systems,
+Clipper,
+IBM ROMP (RT),
+and
+Pyramid AP/XP.
@cindex Home page
@cindex Web page
@@ -498,7 +503,7 @@ There is also assembly code for many obsolete CPUs.
For up-to-date information on GMP, please see the GMP web pages at
@display
-@uref{https://gmplib.org/}
+@uref{http://gmplib.org/}
@end display
@cindex Latest version of GMP
@@ -508,11 +513,11 @@ For up-to-date information on GMP, please see the GMP web pages at
The latest version of the library is available at
@display
-@uref{https://ftp.gnu.org/gnu/gmp/}
+@uref{ftp://ftp.gnu.org/gnu/gmp/}
@end display
Many sites around the world mirror @samp{ftp.gnu.org}, please use a mirror
-near you, see @uref{https://www.gnu.org/order/ftp.html} for a full list.
+near you, see @uref{http://www.gnu.org/order/ftp.html} for a full list.
@cindex Mailing lists
There are three public mailing lists of interest. One for release
@@ -520,7 +525,7 @@ announcements, one for general questions and discussions about usage of the GMP
library and one for bug reports. For more information, see
@display
-@uref{https://gmplib.org/mailman/listinfo/}.
+@uref{http://gmplib.org/mailman/listinfo/}.
@end display
The proper place for bug reports is @email{gmp-bugs@@gmplib.org}. See
@@ -708,7 +713,7 @@ the binaries won't run on older members of the family, and might run slower on
other members, older or newer. The best idea is always to build GMP for the
exact machine type you intend to run it on.
-The following CPUs have specific support. See @file{configure.ac} for details
+The following CPUs have specific support. See @file{configure.in} for details
of what code and compiler options they select.
@itemize @bullet
@@ -837,10 +842,16 @@ x86 family:
@item
Other:
+@nisamp{a29k},
@nisamp{arm},
+@nisamp{clipper},
+@nisamp{i960},
+@nisamp{ns32k},
+@nisamp{pyramid},
@nisamp{sh},
@nisamp{sh2},
@nisamp{vax},
+@nisamp{z8k}
@end itemize
CPUs not listed will use generic C code.
@@ -848,14 +859,18 @@ CPUs not listed will use generic C code.
@item Generic C Build
@cindex Generic C
If some of the assembly code causes problems, or if otherwise desired, the
-generic C code can be selected with the configure @option{--disable-assembly}.
+generic C code can be selected with CPU @samp{none}. For example,
+
+@example
+./configure --host=none-unknown-freebsd3.5
+@end example
Note that this will run quite slowly, but it should be portable and should at
least make it possible to get something running if all else fails.
@item Fat binary, @option{--enable-fat}
@cindex Fat binary
-@cindex @code{--enable-fat}
+@cindex @option{--enable-fat}
Using @option{--enable-fat} selects a ``fat binary'' build on x86, where
optimized low level subroutines are chosen at runtime according to the CPU
detected. This means more code, but gives good performance on all x86 chips.
@@ -908,7 +923,8 @@ preprocessor should be set in @samp{CPPFLAGS} rather than @samp{CFLAGS}.
Compiling is done with both @samp{CPPFLAGS} and @samp{CFLAGS}, but
preprocessing uses just @samp{CPPFLAGS}. This distinction is because most
preprocessors won't accept all the flags the compiler does. Preprocessing is
-done separately in some configure tests.
+done separately in some configure tests, and in the @samp{ansi2knr} support
+for K&R compilers.
@item @option{CC_FOR_BUILD}
@cindex @code{CC_FOR_BUILD}
@@ -1023,9 +1039,17 @@ debugging memory related problems (@pxref{Debugging}).
@item FFT Multiplication, @option{--disable-fft}
@cindex FFT multiplication
@cindex @code{--disable-fft}
-By default multiplications are done using Karatsuba, 3-way Toom, higher degree
-Toom, and Fermat FFT@. The FFT is only used on large to very large operands
-and can be disabled to save code size if desired.
+By default multiplications are done using Karatsuba, 3-way Toom, and
+Fermat FFT@. The FFT is only used on large to very large operands and can be
+disabled to save code size if desired.
+
+@item Berkeley MP, @option{--enable-mpbsd}
+@cindex Berkeley MP compatible functions
+@cindex BSD MP compatible functions
+@cindex @code{--enable-mpbsd}
+The Berkeley MP compatibility library (@file{libmp}) and header file
+(@file{mp.h}) are built and installed only if @option{--enable-mpbsd} is used.
+@xref{BSD Compatible Functions}.
@item Assertion Checking, @option{--enable-assert}
@cindex Assertion checking
@@ -1149,16 +1173,6 @@ gcc -m32
@end example
(In GCC 2.95 and earlier there's no @samp{-m32} option, it's the only mode.)
-
-@item @samp{ABI=x32}
-The x32 ABI uses 64-bit limbs but 32-bit pointers. Like the 64-bit ABI, it
-makes full use of the chip's arithmetic capabilities. This ABI is not
-supported by all operating systems.
-
-@example
-gcc -mx32
-@end example
-
@end table
@sp 1
@@ -1284,7 +1298,7 @@ support for n32 or 64 and so only gets a 32-bit limb and the MIPS 2 code.
@item PowerPC 64 (@samp{powerpc64}, @samp{powerpc620}, @samp{powerpc630}, @samp{powerpc970}, @samp{power4}, @samp{power5})
@cindex PowerPC
@table @asis
-@item @samp{ABI=mode64}
+@item @samp{ABI=aix64}
@cindex AIX
The AIX 64 ABI uses 64-bit limbs and pointers and is the default on PowerPC 64
@samp{*-*-aix*} systems. Applications must be compiled with
@@ -1294,28 +1308,31 @@ gcc -maix64
xlc -q64
@end example
-On 64-bit GNU/Linux, BSD, and Mac OS X/Darwin systems, the applications must
-be compiled with
+@item @samp{ABI=mode64}
+The @samp{mode64} ABI uses 64-bit limbs and pointers, and is the default on
+64-bit GNU/Linux, BSD, and Mac OS X/Darwin systems. Applications must be
+compiled with
@example
gcc -m64
@end example
@item @samp{ABI=mode32}
+@cindex AIX
The @samp{mode32} ABI uses a 64-bit @code{long long} limb but with the chip
still in 32-bit mode and using 32-bit calling conventions. This is the default
-for systems where the true 64-bit ABI is unavailable. No special compiler
-options are typically needed for applications. This ABI is not available under
-AIX.
+on for systems where the true 64-bit ABIs are unavailable. No special compiler
+options are needed for applications.
@item @samp{ABI=32}
This is the basic 32-bit PowerPC ABI, with a 32-bit limb. No special compiler
options are needed for applications.
@end table
-GMP's speed is greatest for the @samp{mode64} ABI, the @samp{mode32} ABI is 2nd
-best. In @samp{ABI=32} only the 32-bit ISA is used and this doesn't make full
-use of a 64-bit chip.
+GMP speed is greatest in @samp{aix64} and @samp{mode32}. In @samp{ABI=32}
+only the 32-bit ISA is used and this doesn't make full use of a 64-bit chip.
+On a suitable system we could perhaps use more of the ISA, but there are no
+plans to do so.
@sp 1
@need 1000
@@ -1511,20 +1528,11 @@ involving a @code{double} cannot be expected to operate to their full
precision when the hardware is in single precision mode. Of course this
affects all code, including application code, not just GMP.
-@item FreeBSD 7.x, 8.x, 9.0, 9.1, 9.2
-@cindex FreeBSD
-@command{m4} in these releases of FreeBSD has an eval function which ignores
-its 2nd and 3rd arguments, which makes it unsuitable for @file{.asm} file
-processing. @samp{./configure} will detect the problem and either abort or
-choose another m4 in the @env{PATH}. The bug is fixed in FreeBSD 9.3 and 10.0,
-so either upgrade or use GNU m4. Note that the FreeBSD package system installs
-GNU m4 under the name @samp{gm4}, which GMP cannot guess.
-
-@item FreeBSD 7.x, 8.x, 9.x
-@cindex FreeBSD
-GMP releases starting with 6.0 do not support @samp{ABI=32} on FreeBSD/amd64
-prior to release 10.0 of the system. The cause is a broken @code{limits.h},
-which GMP no longer works around.
+@item MacOS 9
+@cindex MacOS 9
+The @file{macos} directory contains an unsupported port to MacOS 9 on Power
+Macintosh, see @file{macos/README}. Note that MacOS X ``Darwin'' should use
+the normal Unix-style @samp{./configure}.
@item MS-DOS and MS Windows
@cindex MS-DOS
@@ -1586,15 +1594,6 @@ performance boost on applicable CPUs. @samp{m68360} can be used for CPU32
series chips. @samp{m68302} can be used for ``Dragonball'' series chips,
though this is merely a synonym for @samp{m68000}.
-@item NetBSD 5.x
-@cindex NetBSD
-@command{m4} in these releases of NetBSD has an eval function which ignores its
-2nd and 3rd arguments, which makes it unsuitable for @file{.asm} file
-processing. @samp{./configure} will detect the problem and either abort or
-choose another m4 in the @env{PATH}. The bug is fixed in NetBSD 6, so either
-upgrade or use GNU m4. Note that the NetBSD package system installs GNU m4
-under the name @samp{gm4}, which GMP cannot guess.
-
@item OpenBSD 2.6
@cindex OpenBSD
@command{m4} in this release of OpenBSD has a bug in @code{eval} that makes it
@@ -1608,11 +1607,11 @@ In GMP, CPU types @samp{power*} and @samp{powerpc*} will each use instructions
not available on the other, so it's important to choose the right one for the
CPU that will be used. Currently GMP has no assembly code support for using
just the common instruction subset. To get executables that run on both, the
-current suggestion is to use the generic C code (@option{--disable-assembly}),
-possibly with appropriate compiler options (like @samp{-mcpu=common} for
+current suggestion is to use the generic C code (CPU @samp{none}), possibly
+with appropriate compiler options (like @samp{-mcpu=common} for
@command{gcc}). CPU @samp{rs6000} (which is not a CPU but a family of
workstations) is accepted by @file{config.sub}, but is currently equivalent to
-@option{--disable-assembly}.
+@samp{none}.
@item Sparc CPU Types
@cindex Sparc
@@ -1628,10 +1627,10 @@ that the GCC default @samp{-mapp-regs} does (@pxref{SPARC Options,, SPARC
Options, gcc, Using the GNU Compiler Collection (GCC)}).
This makes that code unsuitable for use with the special V9
-@samp{-mcmodel=embmedany} (which uses @code{g4} as a data segment pointer), and
-for applications wanting to use those registers for special purposes. In these
-cases the only suggestion currently is to build GMP with
-@option{--disable-assembly} to avoid the assembly code.
+@samp{-mcmodel=embmedany} (which uses @code{g4} as a data segment pointer),
+and for applications wanting to use those registers for special purposes. In
+these cases the only suggestion currently is to build GMP with CPU @samp{none}
+to avoid the assembly code.
@item SunOS 4
@cindex SunOS
@@ -1675,7 +1674,7 @@ Install a recent @command{gas} if MMX code is wanted on these systems.
@c This section is more or less meant for known build problems that are not
@c otherwise worked around and require some sort of manual intervention.
-You might find more up-to-date information at @uref{https://gmplib.org/}.
+You might find more up-to-date information at @uref{http://gmplib.org/}.
@table @asis
@item Compiler link options
@@ -1796,7 +1795,7 @@ make tuneup
will generate better contents for the @file{gmp-mparam.h} parameter file.
-To use the results, put the output in the file indicated in the
+To use the results, put the output in the file file indicated in the
@samp{Parameters for ...} header. Then recompile from scratch.
The @code{tuneup} program takes one useful parameter, @samp{-f NNN}, which
@@ -1856,10 +1855,10 @@ are only provided if @code{<stdio.h>} is included too.
@end example
@cindex @code{stdarg.h}
-Likewise @code{<stdarg.h>} is required for prototypes with @code{va_list}
-parameters, such as @code{gmp_vprintf}. And @code{<obstack.h>} for prototypes
-with @code{struct obstack} parameters, such as @code{gmp_obstack_printf}, when
-available.
+Likewise @code{<stdarg.h>} (or @code{<varargs.h>}) is required for prototypes
+with @code{va_list} parameters, such as @code{gmp_vprintf}. And
+@code{<obstack.h>} for prototypes with @code{struct obstack} parameters, such
+as @code{gmp_obstack_printf}, when available.
@cindex Libraries
@cindex Linking
@@ -1940,15 +1939,9 @@ analogous to a digit, only larger, and containing several digits.) Normally a
limb is 32 or 64 bits. The C data type for a limb is @code{mp_limb_t}.
@tindex @code{mp_size_t}
-Counts of limbs of a multi-precision number represented in the C type
-@code{mp_size_t}. Currently this is normally a @code{long}, but on some
-systems it's an @code{int} for efficiency, and on some systems it will be
-@code{long long} in the future.
-
-@tindex @code{mp_bitcnt_t}
-Counts of bits of a multi-precision number are represented in the C type
-@code{mp_bitcnt_t}. Currently this is always an @code{unsigned long}, but on
-some systems it will be an @code{unsigned long long} in the future.
+Counts of limbs are represented in the C type @code{mp_size_t}. Currently
+this is normally a @code{long}, but on some systems it's an @code{int} for
+efficiency.
@cindex Random state
@tindex @code{gmp_randstate_t}
@@ -1959,7 +1952,7 @@ data type for such objects is @code{gmp_randstate_t}. For example:
gmp_randstate_t rstate;
@end example
-Also, in general @code{mp_bitcnt_t} is used for bit counts and ranges, and
+Also, in general @code{unsigned long} is used for bit counts and ranges, and
@code{size_t} is used for byte or character counts.
@@ -1977,22 +1970,27 @@ functions in this class. (@pxref{Integer Functions})
@item
Functions for rational number arithmetic, with names beginning with
-@code{mpq_}. The associated type is @code{mpq_t}. There are about 35
+@code{mpq_}. The associated type is @code{mpq_t}. There are about 40
functions in this class, but the integer functions can be used for arithmetic
on the numerator and denominator separately. (@pxref{Rational Number
Functions})
@item
Functions for floating-point arithmetic, with names beginning with
-@code{mpf_}. The associated type is @code{mpf_t}. There are about 70
+@code{mpf_}. The associated type is @code{mpf_t}. There are about 60
functions is this class. (@pxref{Floating-point Functions})
@item
+Functions compatible with Berkeley MP, such as @code{itom}, @code{madd}, and
+@code{mult}. The associated type is @code{MINT}. (@pxref{BSD Compatible
+Functions})
+
+@item
Fast low-level functions that operate on natural numbers. These are used by
the functions in the preceding groups, and you can also call them directly
from very time-critical user programs. These functions' names begin with
@code{mpn_}. The associated type is array of @code{mp_limb_t}. There are
-about 60 (hard-to-use) functions in this class. (@pxref{Low-level Functions})
+about 30 (hard-to-use) functions in this class. (@pxref{Low-level Functions})
@item
Miscellaneous functions. Functions for setting up custom allocation and
@@ -2176,7 +2174,7 @@ GMP I/O functions using them will not be reentrant either.
@item
It's safe for two threads to read from the same GMP variable simultaneously,
-but it's not safe for one to read while another might be writing, nor for
+but it's not safe for one to read while the another might be writing, nor for
two threads to write simultaneously. It's not safe for two threads to
generate a random number from the same @code{gmp_randstate_t} simultaneously,
since this involves an update of that variable.
@@ -2210,7 +2208,7 @@ For GMP i.j.k, these numbers will be i, j, and k, respectively.
@findex gmp_version
The GMP version number, as a null-terminated string, in the form ``i.j.k''.
This release is @nicode{"@value{VERSION}"}. Note that the format ``i.j'' was
-used, before version 4.3.0, when k was zero.
+used when k was zero was used before version 4.3.0.
@end deftypevr
@defmac __GMP_CC
@@ -2226,7 +2224,7 @@ strings.
@cindex Past GMP versions
@cindex Upward compatibility
-This version of GMP is upwardly binary compatible with all 5.x, 4.x, and 3.x
+This version of GMP is upwardly binary compatible with all 4.x and 3.x
versions, and upwardly compatible at the source level with all 2.x versions,
with the following exceptions.
@@ -2238,15 +2236,16 @@ with other @code{mpn} functions.
@item
@code{mpf_get_prec} counted precision slightly differently in GMP 3.0 and
3.0.1, but in 3.1 reverted to the 2.x style.
-
-@item
-@code{mpn_bdivmod}, documented as preliminary in GMP 4, has been removed.
@end itemize
There are a number of compatibility issues between GMP 1 and GMP 2 that of
-course also apply when porting applications from GMP 1 to GMP 5. Please
+course also apply when porting applications from GMP 1 to GMP 4. Please
see the GMP 2 manual for details.
+The Berkeley MP compatibility library (@pxref{BSD Compatible Functions}) is
+source and binary compatible with the standard @file{libmp}.
+
+@c @enumerate
@c @item Integer division functions round the result differently. The obsolete
@c functions (@code{mpz_div}, @code{mpz_divmod}, @code{mpz_mdiv},
@c @code{mpz_mdivmod}, etc) now all use floor rounding (i.e., they round the
@@ -2625,7 +2624,7 @@ Applications using the low-level @code{mpn} functions, however, will benefit
from @option{--enable-assert} since it adds checks on the parameters of most
such functions, many of which have subtle restrictions on their usage. Note
however that only the generic C code has checks, not the assembly code, so
-@option{--disable-assembly} should be used for maximum checking.
+CPU @samp{none} should be used for maximum checking.
@item Temporary Memory Checking
The build option @option{--enable-alloca=debug} arranges that each block of
@@ -2643,7 +2642,7 @@ To summarize the above, a GMP build for maximum debuggability would be
@example
./configure --disable-shared --enable-assert \
- --enable-alloca=debug --disable-assembly CFLAGS=-g
+ --enable-alloca=debug --host=none CFLAGS=-g
@end example
For C++, add @samp{--enable-cxx CXXFLAGS=-g}.
@@ -2651,7 +2650,7 @@ For C++, add @samp{--enable-cxx CXXFLAGS=-g}.
@item Checker
@cindex Checker
@cindex GCC Checker
-The GCC checker (@uref{https://savannah.nongnu.org/projects/checker/}) can be
+The GCC checker (@uref{http://savannah.nongnu.org/projects/checker/}) can be
used with GMP@. It contains a stub library which means GMP applications
compiled with checker can use a normal GMP build.
@@ -2660,30 +2659,23 @@ very very slowly. On GNU/Linux for example,
@cindex @command{checkergcc}
@example
-./configure --disable-assembly CC=checkergcc
+./configure --host=none-pc-linux-gnu CC=checkergcc
@end example
-@option{--disable-assembly} must be used, since the GMP assembly code doesn't
-support the checking scheme. The GMP C++ features cannot be used, since
-current versions of checker (0.9.9.1) don't yet support the standard C++
-library.
+@samp{--host=none} must be used, since the GMP assembly code doesn't support
+the checking scheme. The GMP C++ features cannot be used, since current
+versions of checker (0.9.9.1) don't yet support the standard C++ library.
@item Valgrind
@cindex Valgrind
-Valgrind (@uref{http://valgrind.org/}) is a memory checker for x86, ARM, MIPS,
-PowerPC, and S/390. It translates and emulates machine instructions to do
+The valgrind program (@uref{http://valgrind.org/}) is a memory
+checker for x86s. It translates and emulates machine instructions to do
strong checks for uninitialized data (at the level of individual bits), memory
accesses through bad pointers, and memory leaks.
-Valgrind does not always support every possible instruction, in particular
-ones recently added to an ISA. Valgrind might therefore be incompatible with
-a recent GMP or even a less recent GMP which is compiled using a recent GCC.
-
-GMP's assembly code sometimes promotes a read of the limbs to some larger size,
-for efficiency. GMP will do this even at the start and end of a multilimb
-operand, using naturally aligned operations on the larger type. This may lead
-to benign reads outside of allocated areas, triggering complaints from
-Valgrind. Valgrind's option @samp{--partial-loads-ok=yes} should help.
+Recent versions of Valgrind are getting support for MMX and SSE/SSE2
+instructions, for past versions GMP will need to be configured not to use
+those, ie.@: for an x86 without them (for instance plain @samp{i486}).
@item Other Problems
Any suspected bug in GMP itself should be isolated to make sure it's not an
@@ -2812,7 +2804,7 @@ found. For example,
@example
AC_CHECK_LIB(gmp, __gmpz_init, ,
- [AC_MSG_ERROR([GNU MP not found, see https://gmplib.org/])])
+ [AC_MSG_ERROR([GNU MP not found, see http://gmplib.org/])])
@end example
If functions added in some particular version of GMP are required, then one of
@@ -2822,7 +2814,7 @@ GMP 3.1,
@example
AC_CHECK_LIB(gmp, __gmpz_mul_si, ,
[AC_MSG_ERROR(
- [GNU MP not found, or not 3.1 or up, see https://gmplib.org/])])
+ [GNU MP not found, or not 3.1 or up, see http://gmplib.org/])])
@end example
An alternative would be to test the version number in @file{gmp.h} using say
@@ -2882,7 +2874,7 @@ much to ask you to report the bugs you find.
Before you report a bug, check it's not already addressed in @ref{Known Build
Problems}, or perhaps @ref{Notes for Particular Systems}. You may also want
-to check @uref{https://gmplib.org/} for patches for this release.
+to check @uref{http://gmplib.org/} for patches for this release.
Please include the following in any report,
@@ -2906,10 +2898,7 @@ informative (@samp{where} in @command{gdb}, or @samp{$C} in @command{adb}).
Please do not send core dumps, executables or @command{strace}s.
@item
-The @samp{configure} options you used when building GMP, if any.
-
-@item
-The output from @samp{configure}, as printed to stdout, with any options used.
+The configuration options you used when building GMP, if any.
@item
The name of the compiler and its version. For @command{gcc}, get the version
@@ -3009,23 +2998,15 @@ object is initialized.
Initialize @var{x}, and set its value to 0.
@end deftypefun
-@deftypefun void mpz_inits (mpz_t @var{x}, ...)
-Initialize a NULL-terminated list of @code{mpz_t} variables, and set their
-values to 0.
-@end deftypefun
-
-@deftypefun void mpz_init2 (mpz_t @var{x}, mp_bitcnt_t @var{n})
+@deftypefun void mpz_init2 (mpz_t @var{x}, unsigned long @var{n})
Initialize @var{x}, with space for @var{n}-bit numbers, and set its value to 0.
Calling this function instead of @code{mpz_init} or @code{mpz_inits} is never
necessary; reallocation is handled automatically by GMP when needed.
-While @var{n} defines the initial space, @var{x} will grow automatically in the
-normal way, if necessary, for subsequent values stored. @code{mpz_init2} makes
-it possible to avoid such reallocations if a maximum size is known in advance.
-
-In preparation for an operation, GMP often allocates one limb more than
-ultimately needed. To make sure GMP will not perform reallocation for
-@var{x}, you need to add the number of bits in @code{mp_limb_t} to @var{n}.
+@var{n} is only the initial space, @var{x} will grow automatically in
+the normal way, if necessary, for subsequent values stored. @code{mpz_init2}
+makes it possible to avoid such reallocations if a maximum size is known in
+advance.
@end deftypefun
@deftypefun void mpz_clear (mpz_t @var{x})
@@ -3033,11 +3014,7 @@ Free the space occupied by @var{x}. Call this function for all @code{mpz_t}
variables when you are done with them.
@end deftypefun
-@deftypefun void mpz_clears (mpz_t @var{x}, ...)
-Free the space occupied by a NULL-terminated list of @code{mpz_t} variables.
-@end deftypefun
-
-@deftypefun void mpz_realloc2 (mpz_t @var{x}, mp_bitcnt_t @var{n})
+@deftypefun void mpz_realloc2 (mpz_t @var{x}, unsigned long @var{n})
Change the space allocated for @var{x} to @var{n} bits. The value in @var{x}
is preserved if it fits, or is set to 0 if not.
@@ -3057,19 +3034,19 @@ to give memory back to the heap.
These functions assign new values to already initialized integers
(@pxref{Initializing Integers}).
-@deftypefun void mpz_set (mpz_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpz_set (mpz_t @var{rop}, mpz_t @var{op})
@deftypefunx void mpz_set_ui (mpz_t @var{rop}, unsigned long int @var{op})
@deftypefunx void mpz_set_si (mpz_t @var{rop}, signed long int @var{op})
@deftypefunx void mpz_set_d (mpz_t @var{rop}, double @var{op})
-@deftypefunx void mpz_set_q (mpz_t @var{rop}, const mpq_t @var{op})
-@deftypefunx void mpz_set_f (mpz_t @var{rop}, const mpf_t @var{op})
+@deftypefunx void mpz_set_q (mpz_t @var{rop}, mpq_t @var{op})
+@deftypefunx void mpz_set_f (mpz_t @var{rop}, mpf_t @var{op})
Set the value of @var{rop} from @var{op}.
@code{mpz_set_d}, @code{mpz_set_q} and @code{mpz_set_f} truncate @var{op} to
make it an integer.
@end deftypefun
-@deftypefun int mpz_set_str (mpz_t @var{rop}, const char *@var{str}, int @var{base})
+@deftypefun int mpz_set_str (mpz_t @var{rop}, char *@var{str}, int @var{base})
Set the value of @var{rop} from @var{str}, a null-terminated C string in base
@var{base}. White space is allowed in the string, and is simply ignored.
@@ -3128,7 +3105,7 @@ functions, it can be used as the source or destination operand for the ordinary
integer functions. Don't use an initialize-and-set function on a variable
already initialized!
-@deftypefun void mpz_init_set (mpz_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpz_init_set (mpz_t @var{rop}, mpz_t @var{op})
@deftypefunx void mpz_init_set_ui (mpz_t @var{rop}, unsigned long int @var{op})
@deftypefunx void mpz_init_set_si (mpz_t @var{rop}, signed long int @var{op})
@deftypefunx void mpz_init_set_d (mpz_t @var{rop}, double @var{op})
@@ -3136,7 +3113,7 @@ Initialize @var{rop} with limb space and set the initial numeric value from
@var{op}.
@end deftypefun
-@deftypefun int mpz_init_set_str (mpz_t @var{rop}, const char *@var{str}, int @var{base})
+@deftypefun int mpz_init_set_str (mpz_t @var{rop}, char *@var{str}, int @var{base})
Initialize @var{rop} and set its value like @code{mpz_set_str} (see its
documentation above for details).
@@ -3156,7 +3133,7 @@ This section describes functions for converting GMP integers to standard C
types. Functions for converting @emph{to} GMP integers are described in
@ref{Assigning Integers} and @ref{I/O of Integers}.
-@deftypefun {unsigned long int} mpz_get_ui (const mpz_t @var{op})
+@deftypefun {unsigned long int} mpz_get_ui (mpz_t @var{op})
Return the value of @var{op} as an @code{unsigned long}.
If @var{op} is too big to fit an @code{unsigned long} then just the least
@@ -3164,7 +3141,7 @@ significant bits that do fit are returned. The sign of @var{op} is ignored,
only the absolute value is used.
@end deftypefun
-@deftypefun {signed long int} mpz_get_si (const mpz_t @var{op})
+@deftypefun {signed long int} mpz_get_si (mpz_t @var{op})
If @var{op} fits into a @code{signed long int} return the value of @var{op}.
Otherwise return the least significant part of @var{op}, with the same sign
as @var{op}.
@@ -3174,8 +3151,8 @@ result is probably not very useful. To find out if the value will fit, use
the function @code{mpz_fits_slong_p}.
@end deftypefun
-@deftypefun double mpz_get_d (const mpz_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
+@deftypefun double mpz_get_d (mpz_t @var{op})
+Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
towards zero).
If the exponent from the conversion is too big, the result is system
@@ -3183,8 +3160,8 @@ dependent. An infinity is returned where available. A hardware overflow trap
may or may not occur.
@end deftypefun
-@deftypefun double mpz_get_d_2exp (signed long int *@var{exp}, const mpz_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
+@deftypefun double mpz_get_d_2exp (signed long int *@var{exp}, mpz_t @var{op})
+Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
towards zero), and returning the exponent separately.
The return value is in the range @math{0.5@le{}@GMPabs{@var{d}}<1} and the
@@ -3197,7 +3174,7 @@ This is similar to the standard C @code{frexp} function (@pxref{Normalization
Functions,,, libc, The GNU C Library Reference Manual}).
@end deftypefun
-@deftypefun {char *} mpz_get_str (char *@var{str}, int @var{base}, const mpz_t @var{op})
+@deftypefun {char *} mpz_get_str (char *@var{str}, int @var{base}, mpz_t @var{op})
Convert @var{op} to a string of digits in base @var{base}. The base argument
may vary from 2 to 62 or from @minus{}2 to @minus{}36.
@@ -3228,45 +3205,45 @@ or the given @var{str}.
@cindex Integer arithmetic functions
@cindex Arithmetic functions
-@deftypefun void mpz_add (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefunx void mpz_add_ui (mpz_t @var{rop}, const mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpz_add (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefunx void mpz_add_ui (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @math{@var{op1} + @var{op2}}.
@end deftypefun
-@deftypefun void mpz_sub (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefunx void mpz_sub_ui (mpz_t @var{rop}, const mpz_t @var{op1}, unsigned long int @var{op2})
-@deftypefunx void mpz_ui_sub (mpz_t @var{rop}, unsigned long int @var{op1}, const mpz_t @var{op2})
+@deftypefun void mpz_sub (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefunx void mpz_sub_ui (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefunx void mpz_ui_sub (mpz_t @var{rop}, unsigned long int @var{op1}, mpz_t @var{op2})
Set @var{rop} to @var{op1} @minus{} @var{op2}.
@end deftypefun
-@deftypefun void mpz_mul (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefunx void mpz_mul_si (mpz_t @var{rop}, const mpz_t @var{op1}, long int @var{op2})
-@deftypefunx void mpz_mul_ui (mpz_t @var{rop}, const mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpz_mul (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefunx void mpz_mul_si (mpz_t @var{rop}, mpz_t @var{op1}, long int @var{op2})
+@deftypefunx void mpz_mul_ui (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @math{@var{op1} @GMPtimes{} @var{op2}}.
@end deftypefun
-@deftypefun void mpz_addmul (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefunx void mpz_addmul_ui (mpz_t @var{rop}, const mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpz_addmul (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefunx void mpz_addmul_ui (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @math{@var{rop} + @var{op1} @GMPtimes{} @var{op2}}.
@end deftypefun
-@deftypefun void mpz_submul (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefunx void mpz_submul_ui (mpz_t @var{rop}, const mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpz_submul (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefunx void mpz_submul_ui (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @math{@var{rop} - @var{op1} @GMPtimes{} @var{op2}}.
@end deftypefun
-@deftypefun void mpz_mul_2exp (mpz_t @var{rop}, const mpz_t @var{op1}, mp_bitcnt_t @var{op2})
+@deftypefun void mpz_mul_2exp (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
@cindex Bit shift left
Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
@var{op2}}. This operation can also be defined as a left shift by @var{op2}
bits.
@end deftypefun
-@deftypefun void mpz_neg (mpz_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpz_neg (mpz_t @var{rop}, mpz_t @var{op})
Set @var{rop} to @minus{}@var{op}.
@end deftypefun
-@deftypefun void mpz_abs (mpz_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpz_abs (mpz_t @var{rop}, mpz_t @var{op})
Set @var{rop} to the absolute value of @var{op}.
@end deftypefun
@@ -3287,43 +3264,43 @@ same way as for normal C @code{int} arithmetic.
@c between each, and seem to let tex do a better job of page breaks than an
@c @sp 1 in the middle of one big set.
-@deftypefun void mpz_cdiv_q (mpz_t @var{q}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx void mpz_cdiv_r (mpz_t @var{r}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx void mpz_cdiv_qr (mpz_t @var{q}, mpz_t @var{r}, const mpz_t @var{n}, const mpz_t @var{d})
+@deftypefun void mpz_cdiv_q (mpz_t @var{q}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx void mpz_cdiv_r (mpz_t @var{r}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx void mpz_cdiv_qr (mpz_t @var{q}, mpz_t @var{r}, mpz_t @var{n}, mpz_t @var{d})
@maybepagebreak
-@deftypefunx {unsigned long int} mpz_cdiv_q_ui (mpz_t @var{q}, const mpz_t @var{n}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_cdiv_r_ui (mpz_t @var{r}, const mpz_t @var{n}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_cdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{const mpz_t @var{n}}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_cdiv_ui (const mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_cdiv_q_ui (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_cdiv_r_ui (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_cdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{mpz_t @var{n}}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_cdiv_ui (mpz_t @var{n}, @w{unsigned long int @var{d}})
@maybepagebreak
-@deftypefunx void mpz_cdiv_q_2exp (mpz_t @var{q}, const mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
-@deftypefunx void mpz_cdiv_r_2exp (mpz_t @var{r}, const mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
+@deftypefunx void mpz_cdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{b}})
+@deftypefunx void mpz_cdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{b}})
@end deftypefun
-@deftypefun void mpz_fdiv_q (mpz_t @var{q}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx void mpz_fdiv_r (mpz_t @var{r}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx void mpz_fdiv_qr (mpz_t @var{q}, mpz_t @var{r}, const mpz_t @var{n}, const mpz_t @var{d})
+@deftypefun void mpz_fdiv_q (mpz_t @var{q}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx void mpz_fdiv_r (mpz_t @var{r}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx void mpz_fdiv_qr (mpz_t @var{q}, mpz_t @var{r}, mpz_t @var{n}, mpz_t @var{d})
@maybepagebreak
-@deftypefunx {unsigned long int} mpz_fdiv_q_ui (mpz_t @var{q}, const mpz_t @var{n}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_fdiv_r_ui (mpz_t @var{r}, const mpz_t @var{n}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_fdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{const mpz_t @var{n}}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_fdiv_ui (const mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_fdiv_q_ui (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_fdiv_r_ui (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_fdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{mpz_t @var{n}}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_fdiv_ui (mpz_t @var{n}, @w{unsigned long int @var{d}})
@maybepagebreak
-@deftypefunx void mpz_fdiv_q_2exp (mpz_t @var{q}, const mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
-@deftypefunx void mpz_fdiv_r_2exp (mpz_t @var{r}, const mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
+@deftypefunx void mpz_fdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{b}})
+@deftypefunx void mpz_fdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{b}})
@end deftypefun
-@deftypefun void mpz_tdiv_q (mpz_t @var{q}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx void mpz_tdiv_r (mpz_t @var{r}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx void mpz_tdiv_qr (mpz_t @var{q}, mpz_t @var{r}, const mpz_t @var{n}, const mpz_t @var{d})
+@deftypefun void mpz_tdiv_q (mpz_t @var{q}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx void mpz_tdiv_r (mpz_t @var{r}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx void mpz_tdiv_qr (mpz_t @var{q}, mpz_t @var{r}, mpz_t @var{n}, mpz_t @var{d})
@maybepagebreak
-@deftypefunx {unsigned long int} mpz_tdiv_q_ui (mpz_t @var{q}, const mpz_t @var{n}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_tdiv_r_ui (mpz_t @var{r}, const mpz_t @var{n}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_tdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{const mpz_t @var{n}}, @w{unsigned long int @var{d}})
-@deftypefunx {unsigned long int} mpz_tdiv_ui (const mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_tdiv_q_ui (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_tdiv_r_ui (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_tdiv_qr_ui (mpz_t @var{q}, mpz_t @var{r}, @w{mpz_t @var{n}}, @w{unsigned long int @var{d}})
+@deftypefunx {unsigned long int} mpz_tdiv_ui (mpz_t @var{n}, @w{unsigned long int @var{d}})
@maybepagebreak
-@deftypefunx void mpz_tdiv_q_2exp (mpz_t @var{q}, const mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
-@deftypefunx void mpz_tdiv_r_2exp (mpz_t @var{r}, const mpz_t @var{n}, @w{mp_bitcnt_t @var{b}})
+@deftypefunx void mpz_tdiv_q_2exp (mpz_t @var{q}, mpz_t @var{n}, @w{unsigned long int @var{b}})
+@deftypefunx void mpz_tdiv_r_2exp (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{b}})
@cindex Bit shift right
@sp 1
@@ -3371,8 +3348,8 @@ the same as the bitwise logical functions do, whereas @code{mpz_tdiv_q_2exp}
effectively treats @var{n} as sign and magnitude.
@end deftypefun
-@deftypefun void mpz_mod (mpz_t @var{r}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx {unsigned long int} mpz_mod_ui (mpz_t @var{r}, const mpz_t @var{n}, @w{unsigned long int @var{d}})
+@deftypefun void mpz_mod (mpz_t @var{r}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx {unsigned long int} mpz_mod_ui (mpz_t @var{r}, mpz_t @var{n}, @w{unsigned long int @var{d}})
Set @var{r} to @var{n} @code{mod} @var{d}. The sign of the divisor is
ignored; the result is always non-negative.
@@ -3381,8 +3358,8 @@ remainder as well as setting @var{r}. See @code{mpz_fdiv_ui} above if only
the return value is wanted.
@end deftypefun
-@deftypefun void mpz_divexact (mpz_t @var{q}, const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx void mpz_divexact_ui (mpz_t @var{q}, const mpz_t @var{n}, unsigned long @var{d})
+@deftypefun void mpz_divexact (mpz_t @var{q}, mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx void mpz_divexact_ui (mpz_t @var{q}, mpz_t @var{n}, unsigned long @var{d})
@cindex Exact division functions
Set @var{q} to @var{n}/@var{d}. These functions produce correct results only
when it is known in advance that @var{d} divides @var{n}.
@@ -3392,9 +3369,9 @@ best choice when exact division is known to occur, for example reducing a
rational to lowest terms.
@end deftypefun
-@deftypefun int mpz_divisible_p (const mpz_t @var{n}, const mpz_t @var{d})
-@deftypefunx int mpz_divisible_ui_p (const mpz_t @var{n}, unsigned long int @var{d})
-@deftypefunx int mpz_divisible_2exp_p (const mpz_t @var{n}, mp_bitcnt_t @var{b})
+@deftypefun int mpz_divisible_p (mpz_t @var{n}, mpz_t @var{d})
+@deftypefunx int mpz_divisible_ui_p (mpz_t @var{n}, unsigned long int @var{d})
+@deftypefunx int mpz_divisible_2exp_p (mpz_t @var{n}, unsigned long int @var{b})
@cindex Divisibility functions
Return non-zero if @var{n} is exactly divisible by @var{d}, or in the case of
@code{mpz_divisible_2exp_p} by @m{2^b,2^@var{b}}.
@@ -3405,9 +3382,9 @@ functions, @math{@var{d}=0} is accepted and following the rule it can be seen
that only 0 is considered divisible by 0.
@end deftypefun
-@deftypefun int mpz_congruent_p (const mpz_t @var{n}, const mpz_t @var{c}, const mpz_t @var{d})
-@deftypefunx int mpz_congruent_ui_p (const mpz_t @var{n}, unsigned long int @var{c}, unsigned long int @var{d})
-@deftypefunx int mpz_congruent_2exp_p (const mpz_t @var{n}, const mpz_t @var{c}, mp_bitcnt_t @var{b})
+@deftypefun int mpz_congruent_p (mpz_t @var{n}, mpz_t @var{c}, mpz_t @var{d})
+@deftypefunx int mpz_congruent_ui_p (mpz_t @var{n}, unsigned long int @var{c}, unsigned long int @var{d})
+@deftypefunx int mpz_congruent_2exp_p (mpz_t @var{n}, mpz_t @var{c}, unsigned long int @var{b})
@cindex Divisibility functions
@cindex Congruence functions
Return non-zero if @var{n} is congruent to @var{c} modulo @var{d}, or in the
@@ -3428,8 +3405,8 @@ only when exactly equal.
@cindex Exponentiation functions
@cindex Powering functions
-@deftypefun void mpz_powm (mpz_t @var{rop}, const mpz_t @var{base}, const mpz_t @var{exp}, const mpz_t @var{mod})
-@deftypefunx void mpz_powm_ui (mpz_t @var{rop}, const mpz_t @var{base}, unsigned long int @var{exp}, const mpz_t @var{mod})
+@deftypefun void mpz_powm (mpz_t @var{rop}, mpz_t @var{base}, mpz_t @var{exp}, mpz_t @var{mod})
+@deftypefunx void mpz_powm_ui (mpz_t @var{rop}, mpz_t @var{base}, unsigned long int @var{exp}, mpz_t @var{mod})
Set @var{rop} to @m{base^{exp} \bmod mod, (@var{base} raised to @var{exp})
modulo @var{mod}}.
@@ -3438,20 +3415,7 @@ Negative @var{exp} is supported if an inverse @math{@var{base}^@W{-1} @bmod
If an inverse doesn't exist then a divide by zero is raised.
@end deftypefun
-@deftypefun void mpz_powm_sec (mpz_t @var{rop}, const mpz_t @var{base}, const mpz_t @var{exp}, const mpz_t @var{mod})
-Set @var{rop} to @m{base^{exp} \bmod @var{mod}, (@var{base} raised to @var{exp})
-modulo @var{mod}}.
-
-It is required that @math{@var{exp} > 0} and that @var{mod} is odd.
-
-This function is designed to take the same time and have the same cache access
-patterns for any two same-size arguments, assuming that function arguments are
-placed at the same position and that the machine state is identical upon
-function entry. This function is intended for cryptographic purposes, where
-resilience to side-channel attacks is desired.
-@end deftypefun
-
-@deftypefun void mpz_pow_ui (mpz_t @var{rop}, const mpz_t @var{base}, unsigned long int @var{exp})
+@deftypefun void mpz_pow_ui (mpz_t @var{rop}, mpz_t @var{base}, unsigned long int @var{exp})
@deftypefunx void mpz_ui_pow_ui (mpz_t @var{rop}, unsigned long int @var{base}, unsigned long int @var{exp})
Set @var{rop} to @m{base^{exp}, @var{base} raised to @var{exp}}. The case
@math{0^0} yields 1.
@@ -3464,25 +3428,25 @@ Set @var{rop} to @m{base^{exp}, @var{base} raised to @var{exp}}. The case
@cindex Integer root functions
@cindex Root extraction functions
-@deftypefun int mpz_root (mpz_t @var{rop}, const mpz_t @var{op}, unsigned long int @var{n})
+@deftypefun int mpz_root (mpz_t @var{rop}, mpz_t @var{op}, unsigned long int @var{n})
Set @var{rop} to @m{\lfloor\root n \of {op}\rfloor@C{},} the truncated integer
part of the @var{n}th root of @var{op}. Return non-zero if the computation
was exact, i.e., if @var{op} is @var{rop} to the @var{n}th power.
@end deftypefun
-@deftypefun void mpz_rootrem (mpz_t @var{root}, mpz_t @var{rem}, const mpz_t @var{u}, unsigned long int @var{n})
+@deftypefun void mpz_rootrem (mpz_t @var{root}, mpz_t @var{rem}, mpz_t @var{u}, unsigned long int @var{n})
Set @var{root} to @m{\lfloor\root n \of {u}\rfloor@C{},} the truncated
integer part of the @var{n}th root of @var{u}. Set @var{rem} to the
remainder, @m{(@var{u} - @var{root}^n),
@var{u}@minus{}@var{root}**@var{n}}.
@end deftypefun
-@deftypefun void mpz_sqrt (mpz_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpz_sqrt (mpz_t @var{rop}, mpz_t @var{op})
Set @var{rop} to @m{\lfloor\sqrt{@var{op}}\rfloor@C{},} the truncated
integer part of the square root of @var{op}.
@end deftypefun
-@deftypefun void mpz_sqrtrem (mpz_t @var{rop1}, mpz_t @var{rop2}, const mpz_t @var{op})
+@deftypefun void mpz_sqrtrem (mpz_t @var{rop1}, mpz_t @var{rop2}, mpz_t @var{op})
Set @var{rop1} to @m{\lfloor\sqrt{@var{op}}\rfloor, the truncated integer part
of the square root of @var{op}}, like @code{mpz_sqrt}. Set @var{rop2} to the
remainder @m{(@var{op} - @var{rop1}^2),
@@ -3493,7 +3457,7 @@ If @var{rop1} and @var{rop2} are the same variable, the results are
undefined.
@end deftypefun
-@deftypefun int mpz_perfect_power_p (const mpz_t @var{op})
+@deftypefun int mpz_perfect_power_p (mpz_t @var{op})
@cindex Perfect power functions
@cindex Root testing functions
Return non-zero if @var{op} is a perfect power, i.e., if there exist integers
@@ -3505,7 +3469,7 @@ Negative values of @var{op} are accepted, but of course can only be odd
perfect powers.
@end deftypefun
-@deftypefun int mpz_perfect_square_p (const mpz_t @var{op})
+@deftypefun int mpz_perfect_square_p (mpz_t @var{op})
@cindex Perfect square functions
@cindex Root testing functions
Return non-zero if @var{op} is a perfect square, i.e., if the square root of
@@ -3519,7 +3483,7 @@ be perfect squares.
@section Number Theoretic Functions
@cindex Number theoretic functions
-@deftypefun int mpz_probab_prime_p (const mpz_t @var{n}, int @var{reps})
+@deftypefun int mpz_probab_prime_p (mpz_t @var{n}, int @var{reps})
@cindex Prime testing functions
@cindex Probable prime testing functions
Determine whether @var{n} is prime. Return 2 if @var{n} is definitely prime,
@@ -3527,10 +3491,9 @@ return 1 if @var{n} is probably prime (without being certain), or return 0 if
@var{n} is definitely composite.
This function does some trial divisions, then some Miller-Rabin probabilistic
-primality tests. The argument @var{reps} controls how many such tests are
-done; a higher value will reduce the chances of a composite being returned as
-``probably prime''. 25 is a reasonable number; a composite number will then be
-identified as a prime with a probability of less than @m{2^{-50},2^(-50)}.
+primality tests. @var{reps} controls how many such tests are done, 5 to 10 is
+a reasonable number, more will reduce the chances of a composite being
+returned as ``probably prime''.
Miller-Rabin and similar tests can be more properly called compositeness
tests. Numbers which fail are known to be composite but those which pass
@@ -3538,7 +3501,7 @@ might be prime or might be composite. Only a few composites pass, hence those
which pass are considered probably prime.
@end deftypefun
-@deftypefun void mpz_nextprime (mpz_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpz_nextprime (mpz_t @var{rop}, mpz_t @var{op})
@cindex Next prime function
Set @var{rop} to the next prime greater than @var{op}.
@@ -3549,7 +3512,7 @@ extremely small.
@c mpz_prime_p not implemented as of gmp 3.0.
-@c @deftypefun int mpz_prime_p (const mpz_t @var{n})
+@c @deftypefun int mpz_prime_p (mpz_t @var{n})
@c Return non-zero if @var{n} is prime and zero if @var{n} is a non-prime.
@c This function is far slower than @code{mpz_probab_prime_p}, but then it
@c never returns non-zero for composite numbers.
@@ -3560,15 +3523,15 @@ extremely small.
@c prime, if the @var{reps} argument is in the suggested range.)
@c @end deftypefun
-@deftypefun void mpz_gcd (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
+@deftypefun void mpz_gcd (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
@cindex Greatest common divisor functions
@cindex GCD functions
-Set @var{rop} to the greatest common divisor of @var{op1} and @var{op2}. The
-result is always positive even if one or both input operands are negative.
-Except if both inputs are zero; then this function defines @math{gcd(0,0) = 0}.
+Set @var{rop} to the greatest common divisor of @var{op1} and @var{op2}.
+The result is always positive even if one or both input operands
+are negative.
@end deftypefun
-@deftypefun {unsigned long int} mpz_gcd_ui (mpz_t @var{rop}, const mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefun {unsigned long int} mpz_gcd_ui (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long int @var{op2})
Compute the greatest common divisor of @var{op1} and @var{op2}. If
@var{rop} is not @code{NULL}, store the result there.
@@ -3578,35 +3541,22 @@ to the argument @var{op1}. Note that the result will always fit if @var{op2}
is non-zero.
@end deftypefun
-@deftypefun void mpz_gcdext (mpz_t @var{g}, mpz_t @var{s}, mpz_t @var{t}, const mpz_t @var{a}, const mpz_t @var{b})
+@deftypefun void mpz_gcdext (mpz_t @var{g}, mpz_t @var{s}, mpz_t @var{t}, mpz_t @var{a}, mpz_t @var{b})
@cindex Extended GCD
@cindex GCD extended
Set @var{g} to the greatest common divisor of @var{a} and @var{b}, and in
addition set @var{s} and @var{t} to coefficients satisfying
@math{@var{a}@GMPmultiply{}@var{s} + @var{b}@GMPmultiply{}@var{t} = @var{g}}.
The value in @var{g} is always positive, even if one or both of @var{a} and
-@var{b} are negative (or zero if both inputs are zero). The values in @var{s}
-and @var{t} are chosen such that normally, @math{@GMPabs{@var{s}} <
-@GMPabs{@var{b}} / (2 @var{g})} and @math{@GMPabs{@var{t}} < @GMPabs{@var{a}}
-/ (2 @var{g})}, and these relations define @var{s} and @var{t} uniquely. There
-are a few exceptional cases:
-
-If @math{@GMPabs{@var{a}} = @GMPabs{@var{b}}}, then @math{@var{s} = 0},
-@math{@var{t} = sgn(@var{b})}.
-
-Otherwise, @math{@var{s} = sgn(@var{a})} if @math{@var{b} = 0} or
-@math{@GMPabs{@var{b}} = 2 @var{g}}, and @math{@var{t} = sgn(@var{b})} if
-@math{@var{a} = 0} or @math{@GMPabs{@var{a}} = 2 @var{g}}.
-
-In all cases, @math{@var{s} = 0} if and only if @math{@var{g} =
-@GMPabs{@var{b}}}, i.e., if @var{b} divides @var{a} or @math{@var{a} = @var{b}
-= 0}.
+@var{b} are negative. The values in @var{s} and @var{t} are chosen such that
+@math{@GMPabs{@var{s}} @le{} @GMPabs{@var{b}}} and @math{@GMPabs{@var{t}}
+@le{} @GMPabs{@var{a}}}.
If @var{t} is @code{NULL} then that value is not computed.
@end deftypefun
-@deftypefun void mpz_lcm (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefunx void mpz_lcm_ui (mpz_t @var{rop}, const mpz_t @var{op1}, unsigned long @var{op2})
+@deftypefun void mpz_lcm (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefunx void mpz_lcm_ui (mpz_t @var{rop}, mpz_t @var{op1}, unsigned long @var{op2})
@cindex Least common multiple functions
@cindex LCM functions
Set @var{rop} to the least common multiple of @var{op1} and @var{op2}.
@@ -3614,34 +3564,33 @@ Set @var{rop} to the least common multiple of @var{op1} and @var{op2}.
@var{op2}. @var{rop} will be zero if either @var{op1} or @var{op2} is zero.
@end deftypefun
-@deftypefun int mpz_invert (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
+@deftypefun int mpz_invert (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
@cindex Modular inverse functions
@cindex Inverse modulo functions
Compute the inverse of @var{op1} modulo @var{op2} and put the result in
@var{rop}. If the inverse exists, the return value is non-zero and @var{rop}
-will satisfy @math{0 < @var{rop} < @GMPabs{@var{op2}}}. If an inverse doesn't
-exist the return value is zero and @var{rop} is undefined. The behaviour of
-this function is undefined when @var{op2} is zero.
+will satisfy @math{0 @le{} @var{rop} < @var{op2}}. If an inverse doesn't exist
+the return value is zero and @var{rop} is undefined.
@end deftypefun
-@deftypefun int mpz_jacobi (const mpz_t @var{a}, const mpz_t @var{b})
+@deftypefun int mpz_jacobi (mpz_t @var{a}, mpz_t @var{b})
@cindex Jacobi symbol functions
Calculate the Jacobi symbol @m{\left(a \over b\right),
(@var{a}/@var{b})}. This is defined only for @var{b} odd.
@end deftypefun
-@deftypefun int mpz_legendre (const mpz_t @var{a}, const mpz_t @var{p})
+@deftypefun int mpz_legendre (mpz_t @var{a}, mpz_t @var{p})
@cindex Legendre symbol functions
Calculate the Legendre symbol @m{\left(a \over p\right),
(@var{a}/@var{p})}. This is defined only for @var{p} an odd positive
prime, and for such @var{p} it's identical to the Jacobi symbol.
@end deftypefun
-@deftypefun int mpz_kronecker (const mpz_t @var{a}, const mpz_t @var{b})
-@deftypefunx int mpz_kronecker_si (const mpz_t @var{a}, long @var{b})
-@deftypefunx int mpz_kronecker_ui (const mpz_t @var{a}, unsigned long @var{b})
-@deftypefunx int mpz_si_kronecker (long @var{a}, const mpz_t @var{b})
-@deftypefunx int mpz_ui_kronecker (unsigned long @var{a}, const mpz_t @var{b})
+@deftypefun int mpz_kronecker (mpz_t @var{a}, mpz_t @var{b})
+@deftypefunx int mpz_kronecker_si (mpz_t @var{a}, long @var{b})
+@deftypefunx int mpz_kronecker_ui (mpz_t @var{a}, unsigned long @var{b})
+@deftypefunx int mpz_si_kronecker (long @var{a}, mpz_t @var{b})
+@deftypefunx int mpz_ui_kronecker (unsigned long @var{a}, mpz_t @var{b})
@cindex Kronecker symbol functions
Calculate the Jacobi symbol @m{\left(a \over b\right),
(@var{a}/@var{b})} with the Kronecker extension @m{\left(a \over
@@ -3657,7 +3606,7 @@ or any number theory textbook. See also the example program
@file{demos/qcn.c} which uses @code{mpz_kronecker_ui}.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpz_remove (mpz_t @var{rop}, const mpz_t @var{op}, const mpz_t @var{f})
+@deftypefun {unsigned long int} mpz_remove (mpz_t @var{rop}, mpz_t @var{op}, mpz_t @var{f})
@cindex Remove factor functions
@cindex Factor removal functions
Remove all occurrences of the factor @var{f} from @var{op} and store the
@@ -3665,22 +3614,12 @@ result in @var{rop}. The return value is how many such occurrences were
removed.
@end deftypefun
-@deftypefun void mpz_fac_ui (mpz_t @var{rop}, unsigned long int @var{n})
-@deftypefunx void mpz_2fac_ui (mpz_t @var{rop}, unsigned long int @var{n})
-@deftypefunx void mpz_mfac_uiui (mpz_t @var{rop}, unsigned long int @var{n}, unsigned long int @var{m})
+@deftypefun void mpz_fac_ui (mpz_t @var{rop}, unsigned long int @var{op})
@cindex Factorial functions
-Set @var{rop} to the factorial of @var{n}: @code{mpz_fac_ui} computes the plain factorial @var{n}!,
-@code{mpz_2fac_ui} computes the double-factorial @var{n}!!, and @code{mpz_mfac_uiui} the
-@var{m}-multi-factorial @m{n!^{(m)}, @var{n}!^(@var{m})}.
+Set @var{rop} to @var{op}!, the factorial of @var{op}.
@end deftypefun
-@deftypefun void mpz_primorial_ui (mpz_t @var{rop}, unsigned long int @var{n})
-@cindex Primorial functions
-Set @var{rop} to the primorial of @var{n}, i.e. the product of all positive
-prime numbers @math{@le{}@var{n}}.
-@end deftypefun
-
-@deftypefun void mpz_bin_ui (mpz_t @var{rop}, const mpz_t @var{n}, unsigned long int @var{k})
+@deftypefun void mpz_bin_ui (mpz_t @var{rop}, mpz_t @var{n}, unsigned long int @var{k})
@deftypefunx void mpz_bin_uiui (mpz_t @var{rop}, unsigned long int @var{n}, @w{unsigned long int @var{k}})
@cindex Binomial coefficient functions
Compute the binomial coefficient @m{\left({n}\atop{k}\right), @var{n} over
@@ -3729,10 +3668,10 @@ Algorithm}, the reverse is straightforward too.
@cindex Integer comparison functions
@cindex Comparison functions
-@deftypefn Function int mpz_cmp (const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefnx Function int mpz_cmp_d (const mpz_t @var{op1}, double @var{op2})
-@deftypefnx Macro int mpz_cmp_si (const mpz_t @var{op1}, signed long int @var{op2})
-@deftypefnx Macro int mpz_cmp_ui (const mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefn Function int mpz_cmp (mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefnx Function int mpz_cmp_d (mpz_t @var{op1}, double @var{op2})
+@deftypefnx Macro int mpz_cmp_si (mpz_t @var{op1}, signed long int @var{op2})
+@deftypefnx Macro int mpz_cmp_ui (mpz_t @var{op1}, unsigned long int @var{op2})
Compare @var{op1} and @var{op2}. Return a positive value if @math{@var{op1} >
@var{op2}}, zero if @math{@var{op1} = @var{op2}}, or a negative value if
@math{@var{op1} < @var{op2}}.
@@ -3742,9 +3681,9 @@ arguments more than once. @code{mpz_cmp_d} can be called with an infinity,
but results are undefined for a NaN.
@end deftypefn
-@deftypefn Function int mpz_cmpabs (const mpz_t @var{op1}, const mpz_t @var{op2})
-@deftypefnx Function int mpz_cmpabs_d (const mpz_t @var{op1}, double @var{op2})
-@deftypefnx Function int mpz_cmpabs_ui (const mpz_t @var{op1}, unsigned long int @var{op2})
+@deftypefn Function int mpz_cmpabs (mpz_t @var{op1}, mpz_t @var{op2})
+@deftypefnx Function int mpz_cmpabs_d (mpz_t @var{op1}, double @var{op2})
+@deftypefnx Function int mpz_cmpabs_ui (mpz_t @var{op1}, unsigned long int @var{op2})
Compare the absolute values of @var{op1} and @var{op2}. Return a positive
value if @math{@GMPabs{@var{op1}} > @GMPabs{@var{op2}}}, zero if
@math{@GMPabs{@var{op1}} = @GMPabs{@var{op2}}}, or a negative value if
@@ -3754,7 +3693,7 @@ value if @math{@GMPabs{@var{op1}} > @GMPabs{@var{op2}}}, zero if
for a NaN.
@end deftypefn
-@deftypefn Macro int mpz_sgn (const mpz_t @var{op})
+@deftypefn Macro int mpz_sgn (mpz_t @var{op})
@cindex Sign tests
@cindex Integer sign tests
Return @math{+1} if @math{@var{op} > 0}, 0 if @math{@var{op} = 0}, and
@@ -3777,39 +3716,40 @@ These functions behave as if twos complement arithmetic were used (although
sign-magnitude is the actual implementation). The least significant bit is
number 0.
-@deftypefun void mpz_and (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
+@deftypefun void mpz_and (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
Set @var{rop} to @var{op1} bitwise-and @var{op2}.
@end deftypefun
-@deftypefun void mpz_ior (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
+@deftypefun void mpz_ior (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
Set @var{rop} to @var{op1} bitwise inclusive-or @var{op2}.
@end deftypefun
-@deftypefun void mpz_xor (mpz_t @var{rop}, const mpz_t @var{op1}, const mpz_t @var{op2})
+@deftypefun void mpz_xor (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2})
Set @var{rop} to @var{op1} bitwise exclusive-or @var{op2}.
@end deftypefun
-@deftypefun void mpz_com (mpz_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpz_com (mpz_t @var{rop}, mpz_t @var{op})
Set @var{rop} to the one's complement of @var{op}.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpz_popcount (const mpz_t @var{op})
-If @math{@var{op}@ge{}0}, return the population count of @var{op}, which is the
-number of 1 bits in the binary representation. If @math{@var{op}<0}, the
-number of 1s is infinite, and the return value is the largest possible
-@code{mp_bitcnt_t}.
+@deftypefun {unsigned long int} mpz_popcount (mpz_t @var{op})
+If @math{@var{op}@ge{}0}, return the population count of @var{op}, which is
+the number of 1 bits in the binary representation. If @math{@var{op}<0}, the
+number of 1s is infinite, and the return value is @var{ULONG_MAX}, the largest
+possible @code{unsigned long}.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpz_hamdist (const mpz_t @var{op1}, const mpz_t @var{op2})
-If @var{op1} and @var{op2} are both @math{@ge{}0} or both @math{<0}, return the
-hamming distance between the two operands, which is the number of bit positions
-where @var{op1} and @var{op2} have different bit values. If one operand is
-@math{@ge{}0} and the other @math{<0} then the number of bits different is
-infinite, and the return value is the largest possible @code{mp_bitcnt_t}.
+@deftypefun {unsigned long int} mpz_hamdist (mpz_t @var{op1}, mpz_t @var{op2})
+If @var{op1} and @var{op2} are both @math{@ge{}0} or both @math{<0}, return
+the hamming distance between the two operands, which is the number of bit
+positions where @var{op1} and @var{op2} have different bit values. If one
+operand is @math{@ge{}0} and the other @math{<0} then the number of bits
+different is infinite, and the return value is @var{ULONG_MAX}, the largest
+possible @code{unsigned long}.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpz_scan0 (const mpz_t @var{op}, mp_bitcnt_t @var{starting_bit})
-@deftypefunx {mp_bitcnt_t} mpz_scan1 (const mpz_t @var{op}, mp_bitcnt_t @var{starting_bit})
+@deftypefun {unsigned long int} mpz_scan0 (mpz_t @var{op}, unsigned long int @var{starting_bit})
+@deftypefunx {unsigned long int} mpz_scan1 (mpz_t @var{op}, unsigned long int @var{starting_bit})
@cindex Bit scanning functions
@cindex Scan bit functions
Scan @var{op}, starting from bit @var{starting_bit}, towards more significant
@@ -3819,24 +3759,24 @@ the found bit.
If the bit at @var{starting_bit} is already what's sought, then
@var{starting_bit} is returned.
-If there's no bit found, then the largest possible @code{mp_bitcnt_t} is
-returned. This will happen in @code{mpz_scan0} past the end of a negative
-number, or @code{mpz_scan1} past the end of a nonnegative number.
+If there's no bit found, then @var{ULONG_MAX} is returned. This will happen
+in @code{mpz_scan0} past the end of a negative number, or @code{mpz_scan1}
+past the end of a nonnegative number.
@end deftypefun
-@deftypefun void mpz_setbit (mpz_t @var{rop}, mp_bitcnt_t @var{bit_index})
+@deftypefun void mpz_setbit (mpz_t @var{rop}, unsigned long int @var{bit_index})
Set bit @var{bit_index} in @var{rop}.
@end deftypefun
-@deftypefun void mpz_clrbit (mpz_t @var{rop}, mp_bitcnt_t @var{bit_index})
+@deftypefun void mpz_clrbit (mpz_t @var{rop}, unsigned long int @var{bit_index})
Clear bit @var{bit_index} in @var{rop}.
@end deftypefun
-@deftypefun void mpz_combit (mpz_t @var{rop}, mp_bitcnt_t @var{bit_index})
+@deftypefun void mpz_combit (mpz_t @var{rop}, unsigned long int @var{bit_index})
Complement bit @var{bit_index} in @var{rop}.
@end deftypefun
-@deftypefun int mpz_tstbit (const mpz_t @var{op}, mp_bitcnt_t @var{bit_index})
+@deftypefun int mpz_tstbit (mpz_t @var{op}, unsigned long int @var{bit_index})
Test bit @var{bit_index} in @var{op} and return 0 or 1 accordingly.
@end deftypefun
@@ -3849,17 +3789,15 @@ Test bit @var{bit_index} in @var{op} and return 0 or 1 accordingly.
@cindex I/O functions
Functions that perform input from a stdio stream, and functions that output to
-a stdio stream, of @code{mpz} numbers. Passing a @code{NULL} pointer for a
-@var{stream} argument to any of these functions will make them read from
-@code{stdin} and write to @code{stdout}, respectively.
+a stdio stream. Passing a @code{NULL} pointer for a @var{stream} argument to any of
+these functions will make them read from @code{stdin} and write to
+@code{stdout}, respectively.
When using any of these functions, it is a good idea to include @file{stdio.h}
before @file{gmp.h}, since that will allow @file{gmp.h} to define prototypes
for these functions.
-See also @ref{Formatted Output} and @ref{Formatted Input}.
-
-@deftypefun size_t mpz_out_str (FILE *@var{stream}, int @var{base}, const mpz_t @var{op})
+@deftypefun size_t mpz_out_str (FILE *@var{stream}, int @var{base}, mpz_t @var{op})
Output @var{op} on stdio stream @var{stream}, as a string of digits in base
@var{base}. The base argument may vary from 2 to 62 or from @minus{}2 to
@minus{}36.
@@ -3887,7 +3825,7 @@ the same value. For bases 37 to 62, upper-case letter represent the usual
Return the number of bytes read, or if an error occurred, return 0.
@end deftypefun
-@deftypefun size_t mpz_out_raw (FILE *@var{stream}, const mpz_t @var{op})
+@deftypefun size_t mpz_out_raw (FILE *@var{stream}, mpz_t @var{op})
Output @var{op} on stdio stream @var{stream}, in raw binary format. The
integer is written in a portable format, with 4 bytes of size information, and
that many bytes of limbs. Both the size and the limbs are written in
@@ -3925,7 +3863,7 @@ parameter that is read and modified. Please see the @ref{Random Number
Functions} for more information on how to use and not to use random
number functions.
-@deftypefun void mpz_urandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, mp_bitcnt_t @var{n})
+@deftypefun void mpz_urandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, unsigned long int @var{n})
Generate a uniformly distributed random integer in the range 0 to @m{2^n-1,
2^@var{n}@minus{}1}, inclusive.
@@ -3934,7 +3872,7 @@ The variable @var{state} must be initialized by calling one of the
invoking this function.
@end deftypefun
-@deftypefun void mpz_urandomm (mpz_t @var{rop}, gmp_randstate_t @var{state}, const mpz_t @var{n})
+@deftypefun void mpz_urandomm (mpz_t @var{rop}, gmp_randstate_t @var{state}, mpz_t @var{n})
Generate a uniform random integer in the range 0 to @math{@var{n}-1},
inclusive.
@@ -3943,7 +3881,7 @@ The variable @var{state} must be initialized by calling one of the
before invoking this function.
@end deftypefun
-@deftypefun void mpz_rrandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, mp_bitcnt_t @var{n})
+@deftypefun void mpz_rrandomb (mpz_t @var{rop}, gmp_randstate_t @var{state}, unsigned long int @var{n})
Generate a random integer with long strings of zeros and ones in the
binary representation. Useful for testing functions and algorithms,
since this kind of random numbers have proven to be more likely to
@@ -4017,7 +3955,7 @@ feature can account for this, by passing for instance
@code{8*sizeof(int)-INT_BIT}.
@end deftypefun
-@deftypefun {void *} mpz_export (void *@var{rop}, size_t *@var{countp}, int @var{order}, size_t @var{size}, int @var{endian}, size_t @var{nails}, const mpz_t @var{op})
+@deftypefun {void *} mpz_export (void *@var{rop}, size_t *@var{countp}, int @var{order}, size_t @var{size}, int @var{endian}, size_t @var{nails}, mpz_t @var{op})
@cindex Integer export
@cindex Export
Fill @var{rop} with word data from @var{op}.
@@ -4068,24 +4006,24 @@ p = malloc (count * size);
@cindex Miscellaneous integer functions
@cindex Integer miscellaneous functions
-@deftypefun int mpz_fits_ulong_p (const mpz_t @var{op})
-@deftypefunx int mpz_fits_slong_p (const mpz_t @var{op})
-@deftypefunx int mpz_fits_uint_p (const mpz_t @var{op})
-@deftypefunx int mpz_fits_sint_p (const mpz_t @var{op})
-@deftypefunx int mpz_fits_ushort_p (const mpz_t @var{op})
-@deftypefunx int mpz_fits_sshort_p (const mpz_t @var{op})
+@deftypefun int mpz_fits_ulong_p (mpz_t @var{op})
+@deftypefunx int mpz_fits_slong_p (mpz_t @var{op})
+@deftypefunx int mpz_fits_uint_p (mpz_t @var{op})
+@deftypefunx int mpz_fits_sint_p (mpz_t @var{op})
+@deftypefunx int mpz_fits_ushort_p (mpz_t @var{op})
+@deftypefunx int mpz_fits_sshort_p (mpz_t @var{op})
Return non-zero iff the value of @var{op} fits in an @code{unsigned long int},
@code{signed long int}, @code{unsigned int}, @code{signed int}, @code{unsigned
short int}, or @code{signed short int}, respectively. Otherwise, return zero.
@end deftypefun
-@deftypefn Macro int mpz_odd_p (const mpz_t @var{op})
-@deftypefnx Macro int mpz_even_p (const mpz_t @var{op})
+@deftypefn Macro int mpz_odd_p (mpz_t @var{op})
+@deftypefnx Macro int mpz_even_p (mpz_t @var{op})
Determine whether @var{op} is odd or even, respectively. Return non-zero if
yes, zero if no. These macros evaluate their argument more than once.
@end deftypefn
-@deftypefun size_t mpz_sizeinbase (const mpz_t @var{op}, int @var{base})
+@deftypefun size_t mpz_sizeinbase (mpz_t @var{op}, int @var{base})
@cindex Size in digits
@cindex Digits in an integer
Return the size of @var{op} measured in number of digits in the given
@@ -4116,7 +4054,57 @@ The functions in this section are for various special purposes. Most
applications will not need them.
@deftypefun void mpz_array_init (mpz_t @var{integer_array}, mp_size_t @var{array_size}, @w{mp_size_t @var{fixed_num_bits}})
-@strong{This is an obsolete function. Do not use it.}
+This is a special type of initialization. @strong{Fixed} space of
+@var{fixed_num_bits} is allocated to each of the @var{array_size} integers in
+@var{integer_array}. There is no way to free the storage allocated by this
+function. Don't call @code{mpz_clear}!
+
+The @var{integer_array} parameter is the first @code{mpz_t} in the array. For
+example,
+
+@example
+mpz_t arr[20000];
+mpz_array_init (arr[0], 20000, 512);
+@end example
+
+@c In case anyone's wondering, yes this parameter style is a bit anomalous,
+@c it'd probably be nicer if it was "arr" instead of "arr[0]". Obviously the
+@c two differ only in the declaration, not the pointer value, but changing is
+@c not possible since it'd provoke warnings or errors in existing sources.
+
+This function is only intended for programs that create a large number
+of integers and need to reduce memory usage by avoiding the overheads of
+allocating and reallocating lots of small blocks. In normal programs this
+function is not recommended.
+
+The space allocated to each integer by this function will not be automatically
+increased, unlike the normal @code{mpz_init}, so an application must ensure it
+is sufficient for any value stored. The following space requirements apply to
+various routines,
+
+@itemize @bullet
+@item
+@code{mpz_abs}, @code{mpz_neg}, @code{mpz_set}, @code{mpz_set_si} and
+@code{mpz_set_ui} need room for the value they store.
+
+@item
+@code{mpz_add}, @code{mpz_add_ui}, @code{mpz_sub} and @code{mpz_sub_ui} need
+room for the larger of the two operands, plus an extra
+@code{mp_bits_per_limb}.
+
+@item
+@code{mpz_mul}, @code{mpz_mul_ui} and @code{mpz_mul_ui} need room for the sum
+of the number of bits in their operands, but each rounded up to a multiple of
+@code{mp_bits_per_limb}.
+
+@item
+@code{mpz_swap} can be used between two array variables, but not between an
+array and a normal variable.
+@end itemize
+
+For other functions, or if in doubt, the suggestion is to calculate in a
+regular @code{mpz_init} variable and copy the result to an array variable with
+@code{mpz_set}.
@end deftypefun
@deftypefun {void *} _mpz_realloc (mpz_t @var{integer}, mp_size_t @var{new_alloc})
@@ -4129,7 +4117,7 @@ this. @code{mpz_realloc2} and @code{_mpz_realloc} are the same except that
@code{_mpz_realloc} takes its size in limbs.
@end deftypefun
-@deftypefun mp_limb_t mpz_getlimbn (const mpz_t @var{op}, mp_size_t @var{n})
+@deftypefun mp_limb_t mpz_getlimbn (mpz_t @var{op}, mp_size_t @var{n})
Return limb number @var{n} from @var{op}. The sign of @var{op} is ignored,
just the absolute value is used. The least significant limb is number 0.
@@ -4138,88 +4126,12 @@ just the absolute value is used. The least significant limb is number 0.
@code{mpz_size(@var{op})-1}.
@end deftypefun
-@deftypefun size_t mpz_size (const mpz_t @var{op})
+@deftypefun size_t mpz_size (mpz_t @var{op})
Return the size of @var{op} measured in number of limbs. If @var{op} is zero,
the returned value will be zero.
@c (@xref{Nomenclature}, for an explanation of the concept @dfn{limb}.)
@end deftypefun
-@deftypefun {const mp_limb_t *} mpz_limbs_read (const mpz_t @var{x})
-Return a pointer to the limb array representing the absolute value of @var{x}.
-The size of the array is @code{mpz_size(@var{x})}. Intended for read access
-only.
-@end deftypefun
-
-@deftypefun {mp_limb_t *} mpz_limbs_write (mpz_t @var{x}, mp_size_t @var{n})
-@deftypefunx {mp_limb_t *} mpz_limbs_modify (mpz_t @var{x}, mp_size_t @var{n})
-Return a pointer to the limb array, intended for write access. The array is
-reallocated as needed, to make room for @var{n} limbs. Requires @math{@var{n}
-> 0}. The @code{mpz_limbs_modify} function returns an array that holds the old
-absolute value of @var{x}, while @code{mpz_limbs_write} may destroy the old
-value and return an array with unspecified contents.
-@end deftypefun
-
-@deftypefun void mpz_limbs_finish (mpz_t @var{x}, mp_size_t @var{s})
-Updates the internal size field of @var{x}. Used after writing to the limb
-array pointer returned by @code{mpz_limbs_write} or @code{mpz_limbs_modify} is
-completed. The array should contain @math{@GMPabs{@var{s}}} valid limbs,
-representing the new absolute value for @var{x}, and the sign of @var{x} is
-taken from the sign of @var{s}. This function never reallocates @var{x}, so
-the limb pointer remains valid.
-@end deftypefun
-
-@c FIXME: Some more useful and less silly example?
-@example
-void foo (mpz_t x)
-@{
- mp_size_t n, i;
- mp_limb_t *xp;
-
- n = mpz_size (x);
- xp = mpz_limbs_modify(x, 2*n);
- for (i = 0; i < n; i++)
- xp[n+i] = xp[n-1-i];
- mpz_limbs_finish (x, mpz_sgn (x) < 0 ? - 2*n : 2*n);
-@}
-@end example
-
-@deftypefun mpz_srcptr mpz_roinit_n (mpz_t @var{x}, const mp_limb_t *@var{xp}, mp_size_t @var{xs})
-Special initialization of @var{x}, using the given limb array and size.
-@var{x} should be treated as read-only: it can be passed safely as input to
-any mpz function, but not as an output. The array @var{xp} must point to at
-least a readable limb, its size is
-@math{@GMPabs{@var{xs}}}, and the sign of @var{x} is the sign of @var{xs}. For
-convenience, the function returns @var{x}, but cast to a const pointer type.
-@end deftypefun
-
-@example
-void foo (mpz_t x)
-@{
- static const mp_limb_t y[3] = @{ 0x1, 0x2, 0x3 @};
- mpz_t tmp;
- mpz_add (x, x, mpz_roinit_n (tmp, y, 3));
-@}
-@end example
-
-@deftypefn Macro mpz_t MPZ_ROINIT_N (mp_limb_t *@var{xp}, mp_size_t @var{xs})
-This macro expands to an initializer which can be assigned to an mpz_t
-variable. The limb array @var{xp} must point to at least a readable limb,
-moreover, unlike the @code{mpz_roinit_n} function, the array must be
-normalized: if @var{xs} is non-zero, then
-@code{@var{xp}[@math{@GMPabs{@var{xs}}-1}]} must be non-zero. Intended
-primarily for constant values. Using it for non-constant values requires a C
-compiler supporting C99.
-@end deftypefn
-
-@example
-void foo (mpz_t x)
-@{
- static const mp_limb_t ya[3] = @{ 0x1, 0x2, 0x3 @};
- static const mpz_t y = MPZ_ROINIT_N ((mp_limb_t *) ya, 3);
-
- mpz_add (x, x, y);
-@}
-@end example
@node Rational Number Functions, Floating-point Functions, Integer Functions, Top
@@ -4269,22 +4181,13 @@ initialized once, or at least cleared out (using the function @code{mpq_clear})
between each initialization.
@end deftypefun
-@deftypefun void mpq_inits (mpq_t @var{x}, ...)
-Initialize a NULL-terminated list of @code{mpq_t} variables, and set their
-values to 0/1.
-@end deftypefun
-
@deftypefun void mpq_clear (mpq_t @var{x})
Free the space occupied by @var{x}. Make sure to call this function for all
@code{mpq_t} variables when you are done with them.
@end deftypefun
-@deftypefun void mpq_clears (mpq_t @var{x}, ...)
-Free the space occupied by a NULL-terminated list of @code{mpq_t} variables.
-@end deftypefun
-
-@deftypefun void mpq_set (mpq_t @var{rop}, const mpq_t @var{op})
-@deftypefunx void mpq_set_z (mpq_t @var{rop}, const mpz_t @var{op})
+@deftypefun void mpq_set (mpq_t @var{rop}, mpq_t @var{op})
+@deftypefunx void mpq_set_z (mpq_t @var{rop}, mpz_t @var{op})
Assign @var{rop} from @var{op}.
@end deftypefun
@@ -4295,7 +4198,7 @@ Set the value of @var{rop} to @var{op1}/@var{op2}. Note that if @var{op1} and
@code{mpq_canonicalize} before any operations are performed on @var{rop}.
@end deftypefun
-@deftypefun int mpq_set_str (mpq_t @var{rop}, const char *@var{str}, int @var{base})
+@deftypefun int mpq_set_str (mpq_t @var{rop}, char *@var{str}, int @var{base})
Set @var{rop} from a null-terminated string @var{str} in the given @var{base}.
The string can be an integer like ``41'' or a fraction like ``41/152''. The
@@ -4327,8 +4230,8 @@ Swap the values @var{rop1} and @var{rop2} efficiently.
@cindex Rational conversion functions
@cindex Conversion functions
-@deftypefun double mpq_get_d (const mpq_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
+@deftypefun double mpq_get_d (mpq_t @var{op})
+Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
towards zero).
If the exponent from the conversion is too big or too small to fit a
@@ -4338,12 +4241,12 @@ Hardware overflow, underflow and denorm traps may or may not occur.
@end deftypefun
@deftypefun void mpq_set_d (mpq_t @var{rop}, double @var{op})
-@deftypefunx void mpq_set_f (mpq_t @var{rop}, const mpf_t @var{op})
+@deftypefunx void mpq_set_f (mpq_t @var{rop}, mpf_t @var{op})
Set @var{rop} to the value of @var{op}. There is no rounding, this conversion
is exact.
@end deftypefun
-@deftypefun {char *} mpq_get_str (char *@var{str}, int @var{base}, const mpq_t @var{op})
+@deftypefun {char *} mpq_get_str (char *@var{str}, int @var{base}, mpq_t @var{op})
Convert @var{op} to a string of digits in base @var{base}. The base may vary
from 2 to 36. The string will be of the form @samp{num/den}, or if the
denominator is 1 then just @samp{num}.
@@ -4375,42 +4278,42 @@ or the given @var{str}.
@cindex Rational arithmetic functions
@cindex Arithmetic functions
-@deftypefun void mpq_add (mpq_t @var{sum}, const mpq_t @var{addend1}, const mpq_t @var{addend2})
+@deftypefun void mpq_add (mpq_t @var{sum}, mpq_t @var{addend1}, mpq_t @var{addend2})
Set @var{sum} to @var{addend1} + @var{addend2}.
@end deftypefun
-@deftypefun void mpq_sub (mpq_t @var{difference}, const mpq_t @var{minuend}, const mpq_t @var{subtrahend})
+@deftypefun void mpq_sub (mpq_t @var{difference}, mpq_t @var{minuend}, mpq_t @var{subtrahend})
Set @var{difference} to @var{minuend} @minus{} @var{subtrahend}.
@end deftypefun
-@deftypefun void mpq_mul (mpq_t @var{product}, const mpq_t @var{multiplier}, const mpq_t @var{multiplicand})
+@deftypefun void mpq_mul (mpq_t @var{product}, mpq_t @var{multiplier}, mpq_t @var{multiplicand})
Set @var{product} to @math{@var{multiplier} @GMPtimes{} @var{multiplicand}}.
@end deftypefun
-@deftypefun void mpq_mul_2exp (mpq_t @var{rop}, const mpq_t @var{op1}, mp_bitcnt_t @var{op2})
+@deftypefun void mpq_mul_2exp (mpq_t @var{rop}, mpq_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
@var{op2}}.
@end deftypefun
-@deftypefun void mpq_div (mpq_t @var{quotient}, const mpq_t @var{dividend}, const mpq_t @var{divisor})
+@deftypefun void mpq_div (mpq_t @var{quotient}, mpq_t @var{dividend}, mpq_t @var{divisor})
@cindex Division functions
Set @var{quotient} to @var{dividend}/@var{divisor}.
@end deftypefun
-@deftypefun void mpq_div_2exp (mpq_t @var{rop}, const mpq_t @var{op1}, mp_bitcnt_t @var{op2})
+@deftypefun void mpq_div_2exp (mpq_t @var{rop}, mpq_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @m{@var{op1}/2^{op2}, @var{op1} divided by 2 raised to
@var{op2}}.
@end deftypefun
-@deftypefun void mpq_neg (mpq_t @var{negated_operand}, const mpq_t @var{operand})
+@deftypefun void mpq_neg (mpq_t @var{negated_operand}, mpq_t @var{operand})
Set @var{negated_operand} to @minus{}@var{operand}.
@end deftypefun
-@deftypefun void mpq_abs (mpq_t @var{rop}, const mpq_t @var{op})
+@deftypefun void mpq_abs (mpq_t @var{rop}, mpq_t @var{op})
Set @var{rop} to the absolute value of @var{op}.
@end deftypefun
-@deftypefun void mpq_inv (mpq_t @var{inverted_number}, const mpq_t @var{number})
+@deftypefun void mpq_inv (mpq_t @var{inverted_number}, mpq_t @var{number})
Set @var{inverted_number} to 1/@var{number}. If the new denominator is
zero, this routine will divide by zero.
@end deftypefun
@@ -4421,7 +4324,7 @@ zero, this routine will divide by zero.
@cindex Rational comparison functions
@cindex Comparison functions
-@deftypefun int mpq_cmp (const mpq_t @var{op1}, const mpq_t @var{op2})
+@deftypefun int mpq_cmp (mpq_t @var{op1}, mpq_t @var{op2})
Compare @var{op1} and @var{op2}. Return a positive value if @math{@var{op1} >
@var{op2}}, zero if @math{@var{op1} = @var{op2}}, and a negative value if
@math{@var{op1} < @var{op2}}.
@@ -4430,8 +4333,8 @@ To determine if two rationals are equal, @code{mpq_equal} is faster than
@code{mpq_cmp}.
@end deftypefun
-@deftypefn Macro int mpq_cmp_ui (const mpq_t @var{op1}, unsigned long int @var{num2}, unsigned long int @var{den2})
-@deftypefnx Macro int mpq_cmp_si (const mpq_t @var{op1}, long int @var{num2}, unsigned long int @var{den2})
+@deftypefn Macro int mpq_cmp_ui (mpq_t @var{op1}, unsigned long int @var{num2}, unsigned long int @var{den2})
+@deftypefnx Macro int mpq_cmp_si (mpq_t @var{op1}, long int @var{num2}, unsigned long int @var{den2})
Compare @var{op1} and @var{num2}/@var{den2}. Return a positive value if
@math{@var{op1} > @var{num2}/@var{den2}}, zero if @math{@var{op1} =
@var{num2}/@var{den2}}, and a negative value if @math{@var{op1} <
@@ -4443,17 +4346,17 @@ These functions are implemented as a macros and evaluate their arguments
multiple times.
@end deftypefn
-@deftypefn Macro int mpq_sgn (const mpq_t @var{op})
+@deftypefn Macro int mpq_sgn (mpq_t @var{op})
@cindex Sign tests
@cindex Rational sign tests
Return @math{+1} if @math{@var{op} > 0}, 0 if @math{@var{op} = 0}, and
@math{-1} if @math{@var{op} < 0}.
This function is actually implemented as a macro. It evaluates its
-argument multiple times.
+arguments multiple times.
@end deftypefn
-@deftypefun int mpq_equal (const mpq_t @var{op1}, const mpq_t @var{op2})
+@deftypefun int mpq_equal (mpq_t @var{op1}, mpq_t @var{op2})
Return non-zero if @var{op1} and @var{op2} are equal, zero if they are
non-equal. Although @code{mpq_cmp} can be used for the same purpose, this
function is much faster.
@@ -4474,16 +4377,16 @@ Note that if an assignment to the numerator and/or denominator could take an
(@pxref{Rational Number Functions}) then @code{mpq_canonicalize} must be
called before any other @code{mpq} functions are applied to that @code{mpq_t}.
-@deftypefn Macro mpz_t mpq_numref (const mpq_t @var{op})
-@deftypefnx Macro mpz_t mpq_denref (const mpq_t @var{op})
+@deftypefn Macro mpz_t mpq_numref (mpq_t @var{op})
+@deftypefnx Macro mpz_t mpq_denref (mpq_t @var{op})
Return a reference to the numerator and denominator of @var{op}, respectively.
The @code{mpz} functions can be used on the result of these macros.
@end deftypefn
-@deftypefun void mpq_get_num (mpz_t @var{numerator}, const mpq_t @var{rational})
-@deftypefunx void mpq_get_den (mpz_t @var{denominator}, const mpq_t @var{rational})
-@deftypefunx void mpq_set_num (mpq_t @var{rational}, const mpz_t @var{numerator})
-@deftypefunx void mpq_set_den (mpq_t @var{rational}, const mpz_t @var{denominator})
+@deftypefun void mpq_get_num (mpz_t @var{numerator}, mpq_t @var{rational})
+@deftypefunx void mpq_get_den (mpz_t @var{denominator}, mpq_t @var{rational})
+@deftypefunx void mpq_set_num (mpq_t @var{rational}, mpz_t @var{numerator})
+@deftypefunx void mpq_set_den (mpq_t @var{rational}, mpz_t @var{denominator})
Get or set the numerator or denominator of a rational. These functions are
equivalent to calling @code{mpz_set} with an appropriate @code{mpq_numref} or
@code{mpq_denref}. Direct use of @code{mpq_numref} or @code{mpq_denref} is
@@ -4500,18 +4403,15 @@ recommended instead of these functions.
@cindex Output functions
@cindex I/O functions
-Functions that perform input from a stdio stream, and functions that output to
-a stdio stream, of @code{mpq} numbers. Passing a @code{NULL} pointer for a
-@var{stream} argument to any of these functions will make them read from
-@code{stdin} and write to @code{stdout}, respectively.
-
-When using any of these functions, it is a good idea to include @file{stdio.h}
+When using any of these functions, it's a good idea to include @file{stdio.h}
before @file{gmp.h}, since that will allow @file{gmp.h} to define prototypes
for these functions.
-See also @ref{Formatted Output} and @ref{Formatted Input}.
+Passing a @code{NULL} pointer for a @var{stream} argument to any of these
+functions will make them read from @code{stdin} and write to @code{stdout},
+respectively.
-@deftypefun size_t mpq_out_str (FILE *@var{stream}, int @var{base}, const mpq_t @var{op})
+@deftypefun size_t mpq_out_str (FILE *@var{stream}, int @var{base}, mpq_t @var{op})
Output @var{op} on stdio stream @var{stream}, as a string of digits in base
@var{base}. The base may vary from 2 to 36. Output is in the form
@samp{num/den} or if the denominator is 1 then just @samp{num}.
@@ -4559,7 +4459,7 @@ The exponent of each float is a fixed precision, one machine word on most
systems. In the current implementation the exponent is a count of limbs, so
for example on a 32-bit system this means a range of roughly
@math{2^@W{-68719476768}} to @math{2^@W{68719476736}}, or on a 64-bit system
-this will be greater. Note however that @code{mpf_get_str} can only return an
+this will be greater. Note however @code{mpf_get_str} can only return an
exponent which fits an @code{mp_exp_t} and currently @code{mpf_set_str}
doesn't accept exponents bigger than a @code{long}.
@@ -4572,19 +4472,21 @@ Each function is defined to calculate with ``infinite precision'' followed by
a truncation to the destination precision, but of course the work done is only
what's needed to determine a result under that definition.
-The precision selected by the user for a variable is a minimum value, GMP may
-increase it to facilitate efficient calculation. Currently this means
-rounding up to a whole limb, and then sometimes having a further partial limb,
-depending on the high limb of the mantissa.
+The precision selected for a variable is a minimum value, GMP may increase it
+a little to facilitate efficient calculation. Currently this means rounding
+up to a whole limb, and then sometimes having a further partial limb,
+depending on the high limb of the mantissa. But applications shouldn't be
+concerned by such details.
-The mantissa is stored in binary. One consequence of this is that decimal
+The mantissa in stored in binary, as might be imagined from the fact
+precisions are expressed in bits. One consequence of this is that decimal
fractions like @math{0.1} cannot be represented exactly. The same is true of
plain IEEE @code{double} floats. This makes both highly unsuitable for
calculations involving money or other values that should be exact decimal
fractions. (Suitably scaled integers, or perhaps rationals, are better
choices.)
-The @code{mpf} functions and variables have no special notion of infinity or
+@code{mpf} functions and variables have no special notion of infinity or
not-a-number, and applications must take care not to overflow the exponent or
results will be unpredictable. This might change in a future release.
@@ -4593,10 +4495,6 @@ extension to IEEE P754 arithmetic. In particular results obtained on one
computer often differ from the results on a computer with a different word
size.
-The GMP extension library MPFR (@url{http://mpfr.org}) is an alternative to
-GMP's @code{mpf} functions. MPFR provides well-defined precision and accurate
-rounding, and thereby naturally extends IEEE P754.
-
@menu
* Initializing Floats::
* Assigning Floats::
@@ -4614,13 +4512,13 @@ rounding, and thereby naturally extends IEEE P754.
@cindex Float initialization functions
@cindex Initialization functions
-@deftypefun void mpf_set_default_prec (mp_bitcnt_t @var{prec})
+@deftypefun void mpf_set_default_prec (unsigned long int @var{prec})
Set the default precision to be @strong{at least} @var{prec} bits. All
subsequent calls to @code{mpf_init} will use this precision, but previously
initialized variables are unaffected.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpf_get_default_prec (void)
+@deftypefun {unsigned long int} mpf_get_default_prec (void)
Return the default precision actually used.
@end deftypefun
@@ -4635,28 +4533,17 @@ precision of @var{x} is undefined unless a default precision has already been
established by a call to @code{mpf_set_default_prec}.
@end deftypefun
-@deftypefun void mpf_init2 (mpf_t @var{x}, mp_bitcnt_t @var{prec})
+@deftypefun void mpf_init2 (mpf_t @var{x}, unsigned long int @var{prec})
Initialize @var{x} to 0 and set its precision to be @strong{at least}
@var{prec} bits. Normally, a variable should be initialized once only or at
least be cleared, using @code{mpf_clear}, between initializations.
@end deftypefun
-@deftypefun void mpf_inits (mpf_t @var{x}, ...)
-Initialize a NULL-terminated list of @code{mpf_t} variables, and set their
-values to 0. The precision of the initialized variables is undefined unless a
-default precision has already been established by a call to
-@code{mpf_set_default_prec}.
-@end deftypefun
-
@deftypefun void mpf_clear (mpf_t @var{x})
Free the space occupied by @var{x}. Make sure to call this function for all
@code{mpf_t} variables when you are done with them.
@end deftypefun
-@deftypefun void mpf_clears (mpf_t @var{x}, ...)
-Free the space occupied by a NULL-terminated list of @code{mpf_t} variables.
-@end deftypefun
-
@need 2000
Here is an example on how to initialize floating-point variables:
@example
@@ -4676,11 +4563,11 @@ calculation. A typical use would be for adjusting the precision gradually in
iterative algorithms like Newton-Raphson, making the computation precision
closely match the actual accurate part of the numbers.
-@deftypefun {mp_bitcnt_t} mpf_get_prec (const mpf_t @var{op})
+@deftypefun {unsigned long int} mpf_get_prec (mpf_t @var{op})
Return the current precision of @var{op}, in bits.
@end deftypefun
-@deftypefun void mpf_set_prec (mpf_t @var{rop}, mp_bitcnt_t @var{prec})
+@deftypefun void mpf_set_prec (mpf_t @var{rop}, unsigned long int @var{prec})
Set the precision of @var{rop} to be @strong{at least} @var{prec} bits. The
value in @var{rop} will be truncated to the new precision.
@@ -4688,7 +4575,7 @@ This function requires a call to @code{realloc}, and so should not be used in
a tight loop.
@end deftypefun
-@deftypefun void mpf_set_prec_raw (mpf_t @var{rop}, mp_bitcnt_t @var{prec})
+@deftypefun void mpf_set_prec_raw (mpf_t @var{rop}, unsigned long int @var{prec})
Set the precision of @var{rop} to be @strong{at least} @var{prec} bits,
without changing the memory allocated.
@@ -4725,16 +4612,16 @@ different purposes during a calculation.
These functions assign new values to already initialized floats
(@pxref{Initializing Floats}).
-@deftypefun void mpf_set (mpf_t @var{rop}, const mpf_t @var{op})
+@deftypefun void mpf_set (mpf_t @var{rop}, mpf_t @var{op})
@deftypefunx void mpf_set_ui (mpf_t @var{rop}, unsigned long int @var{op})
@deftypefunx void mpf_set_si (mpf_t @var{rop}, signed long int @var{op})
@deftypefunx void mpf_set_d (mpf_t @var{rop}, double @var{op})
-@deftypefunx void mpf_set_z (mpf_t @var{rop}, const mpz_t @var{op})
-@deftypefunx void mpf_set_q (mpf_t @var{rop}, const mpq_t @var{op})
+@deftypefunx void mpf_set_z (mpf_t @var{rop}, mpz_t @var{op})
+@deftypefunx void mpf_set_q (mpf_t @var{rop}, mpq_t @var{op})
Set the value of @var{rop} from @var{op}.
@end deftypefun
-@deftypefun int mpf_set_str (mpf_t @var{rop}, const char *@var{str}, int @var{base})
+@deftypefun int mpf_set_str (mpf_t @var{rop}, char *@var{str}, int @var{base})
Set the value of @var{rop} from the string in @var{str}. The string is of the
form @samp{M@@N} or, if the base is 10 or less, alternatively @samp{MeN}.
@samp{M} is the mantissa and @samp{N} is the exponent. The mantissa is always
@@ -4789,7 +4676,7 @@ functions, it can be used as the source or destination operand for the ordinary
float functions. Don't use an initialize-and-set function on a variable
already initialized!
-@deftypefun void mpf_init_set (mpf_t @var{rop}, const mpf_t @var{op})
+@deftypefun void mpf_init_set (mpf_t @var{rop}, mpf_t @var{op})
@deftypefunx void mpf_init_set_ui (mpf_t @var{rop}, unsigned long int @var{op})
@deftypefunx void mpf_init_set_si (mpf_t @var{rop}, signed long int @var{op})
@deftypefunx void mpf_init_set_d (mpf_t @var{rop}, double @var{op})
@@ -4799,7 +4686,7 @@ The precision of @var{rop} will be taken from the active default precision, as
set by @code{mpf_set_default_prec}.
@end deftypefun
-@deftypefun int mpf_init_set_str (mpf_t @var{rop}, const char *@var{str}, int @var{base})
+@deftypefun int mpf_init_set_str (mpf_t @var{rop}, char *@var{str}, int @var{base})
Initialize @var{rop} and set its value from the string in @var{str}. See
@code{mpf_set_str} above for details on the assignment operation.
@@ -4817,8 +4704,8 @@ set by @code{mpf_set_default_prec}.
@cindex Float conversion functions
@cindex Conversion functions
-@deftypefun double mpf_get_d (const mpf_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
+@deftypefun double mpf_get_d (mpf_t @var{op})
+Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
towards zero).
If the exponent in @var{op} is too big or too small to fit a @code{double}
@@ -4827,22 +4714,22 @@ available. For too small @math{0.0} is normally returned. Hardware overflow,
underflow and denorm traps may or may not occur.
@end deftypefun
-@deftypefun double mpf_get_d_2exp (signed long int *@var{exp}, const mpf_t @var{op})
-Convert @var{op} to a @code{double}, truncating if necessary (i.e.@: rounding
+@deftypefun double mpf_get_d_2exp (signed long int *@var{exp}, mpf_t @var{op})
+Convert @var{op} to a @code{double}, truncating if necessary (ie.@: rounding
towards zero), and with an exponent returned separately.
The return value is in the range @math{0.5@le{}@GMPabs{@var{d}}<1} and the
-exponent is stored to @code{*@var{exp}}. @m{@var{d} \times 2^{exp},
-@var{d} * 2^@var{exp}} is the (truncated) @var{op} value. If @var{op} is zero,
-the return is @math{0.0} and 0 is stored to @code{*@var{exp}}.
+exponent is stored to @code{*@var{exp}}. @m{@var{d} * 2^{exp}, @var{d} *
+2^@var{exp}} is the (truncated) @var{op} value. If @var{op} is zero, the
+return is @math{0.0} and 0 is stored to @code{*@var{exp}}.
@cindex @code{frexp}
This is similar to the standard C @code{frexp} function (@pxref{Normalization
Functions,,, libc, The GNU C Library Reference Manual}).
@end deftypefun
-@deftypefun long mpf_get_si (const mpf_t @var{op})
-@deftypefunx {unsigned long} mpf_get_ui (const mpf_t @var{op})
+@deftypefun long mpf_get_si (mpf_t @var{op})
+@deftypefunx {unsigned long} mpf_get_ui (mpf_t @var{op})
Convert @var{op} to a @code{long} or @code{unsigned long}, truncating any
fraction part. If @var{op} is too big for the return type, the result is
undefined.
@@ -4851,7 +4738,7 @@ See also @code{mpf_fits_slong_p} and @code{mpf_fits_ulong_p}
(@pxref{Miscellaneous Float Functions}).
@end deftypefun
-@deftypefun {char *} mpf_get_str (char *@var{str}, mp_exp_t *@var{expptr}, int @var{base}, size_t @var{n_digits}, const mpf_t @var{op})
+@deftypefun {char *} mpf_get_str (char *@var{str}, mp_exp_t *@var{expptr}, int @var{base}, size_t @var{n_digits}, mpf_t @var{op})
Convert @var{op} to a string of digits in base @var{base}. The base argument
may vary from 2 to 62 or from @minus{}2 to @minus{}36. Up to @var{n_digits}
digits will be generated. Trailing zeros are not returned. No more digits
@@ -4893,19 +4780,19 @@ or the given @var{str}.
@cindex Float arithmetic functions
@cindex Arithmetic functions
-@deftypefun void mpf_add (mpf_t @var{rop}, const mpf_t @var{op1}, const mpf_t @var{op2})
-@deftypefunx void mpf_add_ui (mpf_t @var{rop}, const mpf_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpf_add (mpf_t @var{rop}, mpf_t @var{op1}, mpf_t @var{op2})
+@deftypefunx void mpf_add_ui (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @math{@var{op1} + @var{op2}}.
@end deftypefun
-@deftypefun void mpf_sub (mpf_t @var{rop}, const mpf_t @var{op1}, const mpf_t @var{op2})
-@deftypefunx void mpf_ui_sub (mpf_t @var{rop}, unsigned long int @var{op1}, const mpf_t @var{op2})
-@deftypefunx void mpf_sub_ui (mpf_t @var{rop}, const mpf_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpf_sub (mpf_t @var{rop}, mpf_t @var{op1}, mpf_t @var{op2})
+@deftypefunx void mpf_ui_sub (mpf_t @var{rop}, unsigned long int @var{op1}, mpf_t @var{op2})
+@deftypefunx void mpf_sub_ui (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @var{op1} @minus{} @var{op2}.
@end deftypefun
-@deftypefun void mpf_mul (mpf_t @var{rop}, const mpf_t @var{op1}, const mpf_t @var{op2})
-@deftypefunx void mpf_mul_ui (mpf_t @var{rop}, const mpf_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpf_mul (mpf_t @var{rop}, mpf_t @var{op1}, mpf_t @var{op2})
+@deftypefunx void mpf_mul_ui (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @math{@var{op1} @GMPtimes{} @var{op2}}.
@end deftypefun
@@ -4914,39 +4801,39 @@ divide functions will make these functions intentionally divide by zero. This
lets the user handle arithmetic exceptions in these functions in the same
manner as other arithmetic exceptions.
-@deftypefun void mpf_div (mpf_t @var{rop}, const mpf_t @var{op1}, const mpf_t @var{op2})
-@deftypefunx void mpf_ui_div (mpf_t @var{rop}, unsigned long int @var{op1}, const mpf_t @var{op2})
-@deftypefunx void mpf_div_ui (mpf_t @var{rop}, const mpf_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpf_div (mpf_t @var{rop}, mpf_t @var{op1}, mpf_t @var{op2})
+@deftypefunx void mpf_ui_div (mpf_t @var{rop}, unsigned long int @var{op1}, mpf_t @var{op2})
+@deftypefunx void mpf_div_ui (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
@cindex Division functions
Set @var{rop} to @var{op1}/@var{op2}.
@end deftypefun
-@deftypefun void mpf_sqrt (mpf_t @var{rop}, const mpf_t @var{op})
+@deftypefun void mpf_sqrt (mpf_t @var{rop}, mpf_t @var{op})
@deftypefunx void mpf_sqrt_ui (mpf_t @var{rop}, unsigned long int @var{op})
@cindex Root extraction functions
Set @var{rop} to @m{\sqrt{@var{op}}, the square root of @var{op}}.
@end deftypefun
-@deftypefun void mpf_pow_ui (mpf_t @var{rop}, const mpf_t @var{op1}, unsigned long int @var{op2})
+@deftypefun void mpf_pow_ui (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
@cindex Exponentiation functions
@cindex Powering functions
Set @var{rop} to @m{@var{op1}^{op2}, @var{op1} raised to the power @var{op2}}.
@end deftypefun
-@deftypefun void mpf_neg (mpf_t @var{rop}, const mpf_t @var{op})
+@deftypefun void mpf_neg (mpf_t @var{rop}, mpf_t @var{op})
Set @var{rop} to @minus{}@var{op}.
@end deftypefun
-@deftypefun void mpf_abs (mpf_t @var{rop}, const mpf_t @var{op})
+@deftypefun void mpf_abs (mpf_t @var{rop}, mpf_t @var{op})
Set @var{rop} to the absolute value of @var{op}.
@end deftypefun
-@deftypefun void mpf_mul_2exp (mpf_t @var{rop}, const mpf_t @var{op1}, mp_bitcnt_t @var{op2})
+@deftypefun void mpf_mul_2exp (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @m{@var{op1} \times 2^{op2}, @var{op1} times 2 raised to
@var{op2}}.
@end deftypefun
-@deftypefun void mpf_div_2exp (mpf_t @var{rop}, const mpf_t @var{op1}, mp_bitcnt_t @var{op2})
+@deftypefun void mpf_div_2exp (mpf_t @var{rop}, mpf_t @var{op1}, unsigned long int @var{op2})
Set @var{rop} to @m{@var{op1}/2^{op2}, @var{op1} divided by 2 raised to
@var{op2}}.
@end deftypefun
@@ -4957,10 +4844,10 @@ Set @var{rop} to @m{@var{op1}/2^{op2}, @var{op1} divided by 2 raised to
@cindex Float comparison functions
@cindex Comparison functions
-@deftypefun int mpf_cmp (const mpf_t @var{op1}, const mpf_t @var{op2})
-@deftypefunx int mpf_cmp_d (const mpf_t @var{op1}, double @var{op2})
-@deftypefunx int mpf_cmp_ui (const mpf_t @var{op1}, unsigned long int @var{op2})
-@deftypefunx int mpf_cmp_si (const mpf_t @var{op1}, signed long int @var{op2})
+@deftypefun int mpf_cmp (mpf_t @var{op1}, mpf_t @var{op2})
+@deftypefunx int mpf_cmp_d (mpf_t @var{op1}, double @var{op2})
+@deftypefunx int mpf_cmp_ui (mpf_t @var{op1}, unsigned long int @var{op2})
+@deftypefunx int mpf_cmp_si (mpf_t @var{op1}, signed long int @var{op2})
Compare @var{op1} and @var{op2}. Return a positive value if @math{@var{op1} >
@var{op2}}, zero if @math{@var{op1} = @var{op2}}, and a negative value if
@math{@var{op1} < @var{op2}}.
@@ -4969,7 +4856,7 @@ Compare @var{op1} and @var{op2}. Return a positive value if @math{@var{op1} >
a NaN.
@end deftypefun
-@deftypefun int mpf_eq (const mpf_t @var{op1}, const mpf_t @var{op2}, mp_bitcnt_t op3)
+@deftypefun int mpf_eq (mpf_t @var{op1}, mpf_t @var{op2}, unsigned long int op3)
Return non-zero if the first @var{op3} bits of @var{op1} and @var{op2} are
equal, zero otherwise. I.e., test if @var{op1} and @var{op2} are approximately
equal.
@@ -4982,18 +4869,18 @@ even if ... is replaced by a semi-infinite number of bits. Such numbers are
really just one ulp off, and should be considered equal.
@end deftypefun
-@deftypefun void mpf_reldiff (mpf_t @var{rop}, const mpf_t @var{op1}, const mpf_t @var{op2})
+@deftypefun void mpf_reldiff (mpf_t @var{rop}, mpf_t @var{op1}, mpf_t @var{op2})
Compute the relative difference between @var{op1} and @var{op2} and store the
result in @var{rop}. This is @math{@GMPabs{@var{op1}-@var{op2}}/@var{op1}}.
@end deftypefun
-@deftypefn Macro int mpf_sgn (const mpf_t @var{op})
+@deftypefn Macro int mpf_sgn (mpf_t @var{op})
@cindex Sign tests
@cindex Float sign tests
Return @math{+1} if @math{@var{op} > 0}, 0 if @math{@var{op} = 0}, and
@math{-1} if @math{@var{op} < 0}.
-This function is actually implemented as a macro. It evaluates its argument
+This function is actually implemented as a macro. It evaluates its arguments
multiple times.
@end deftypefn
@@ -5006,17 +4893,15 @@ multiple times.
@cindex I/O functions
Functions that perform input from a stdio stream, and functions that output to
-a stdio stream, of @code{mpf} numbers. Passing a @code{NULL} pointer for a
-@var{stream} argument to any of these functions will make them read from
-@code{stdin} and write to @code{stdout}, respectively.
+a stdio stream. Passing a @code{NULL} pointer for a @var{stream} argument to
+any of these functions will make them read from @code{stdin} and write to
+@code{stdout}, respectively.
When using any of these functions, it is a good idea to include @file{stdio.h}
before @file{gmp.h}, since that will allow @file{gmp.h} to define prototypes
for these functions.
-See also @ref{Formatted Output} and @ref{Formatted Input}.
-
-@deftypefun size_t mpf_out_str (FILE *@var{stream}, int @var{base}, size_t @var{n_digits}, const mpf_t @var{op})
+@deftypefun size_t mpf_out_str (FILE *@var{stream}, int @var{base}, size_t @var{n_digits}, mpf_t @var{op})
Print @var{op} to @var{stream}, as a string of digits. Return the number of
bytes written, or if an error occurred, return 0.
@@ -5056,7 +4941,7 @@ numbers like @samp{0.23} are not interpreted as octal.
Return the number of bytes read, or if an error occurred, return 0.
@end deftypefun
-@c @deftypefun void mpf_out_raw (FILE *@var{stream}, const mpf_t @var{float})
+@c @deftypefun void mpf_out_raw (FILE *@var{stream}, mpf_t @var{float})
@c Output @var{float} on stdio stream @var{stream}, in raw binary
@c format. The float is written in a portable format, with 4 bytes of
@c size information, and that many bytes of limbs. Both the size and the
@@ -5075,9 +4960,9 @@ Return the number of bytes read, or if an error occurred, return 0.
@cindex Miscellaneous float functions
@cindex Float miscellaneous functions
-@deftypefun void mpf_ceil (mpf_t @var{rop}, const mpf_t @var{op})
-@deftypefunx void mpf_floor (mpf_t @var{rop}, const mpf_t @var{op})
-@deftypefunx void mpf_trunc (mpf_t @var{rop}, const mpf_t @var{op})
+@deftypefun void mpf_ceil (mpf_t @var{rop}, mpf_t @var{op})
+@deftypefunx void mpf_floor (mpf_t @var{rop}, mpf_t @var{op})
+@deftypefunx void mpf_trunc (mpf_t @var{rop}, mpf_t @var{op})
@cindex Rounding functions
@cindex Float rounding functions
Set @var{rop} to @var{op} rounded to an integer. @code{mpf_ceil} rounds to the
@@ -5085,26 +4970,25 @@ next higher integer, @code{mpf_floor} to the next lower, and @code{mpf_trunc}
to the integer towards zero.
@end deftypefun
-@deftypefun int mpf_integer_p (const mpf_t @var{op})
+@deftypefun int mpf_integer_p (mpf_t @var{op})
Return non-zero if @var{op} is an integer.
@end deftypefun
-@deftypefun int mpf_fits_ulong_p (const mpf_t @var{op})
-@deftypefunx int mpf_fits_slong_p (const mpf_t @var{op})
-@deftypefunx int mpf_fits_uint_p (const mpf_t @var{op})
-@deftypefunx int mpf_fits_sint_p (const mpf_t @var{op})
-@deftypefunx int mpf_fits_ushort_p (const mpf_t @var{op})
-@deftypefunx int mpf_fits_sshort_p (const mpf_t @var{op})
+@deftypefun int mpf_fits_ulong_p (mpf_t @var{op})
+@deftypefunx int mpf_fits_slong_p (mpf_t @var{op})
+@deftypefunx int mpf_fits_uint_p (mpf_t @var{op})
+@deftypefunx int mpf_fits_sint_p (mpf_t @var{op})
+@deftypefunx int mpf_fits_ushort_p (mpf_t @var{op})
+@deftypefunx int mpf_fits_sshort_p (mpf_t @var{op})
Return non-zero if @var{op} would fit in the respective C data type, when
truncated to an integer.
@end deftypefun
-@deftypefun void mpf_urandomb (mpf_t @var{rop}, gmp_randstate_t @var{state}, mp_bitcnt_t @var{nbits})
+@deftypefun void mpf_urandomb (mpf_t @var{rop}, gmp_randstate_t @var{state}, unsigned long int @var{nbits})
@cindex Random number functions
@cindex Float random number functions
Generate a uniformly distributed random float in @var{rop}, such that @math{0
-@le{} @var{rop} < 1}, with @var{nbits} significant bits in the mantissa or
-less if the precision of @var{rop} is smaller.
+@le{} @var{rop} < 1}, with @var{nbits} significant bits in the mantissa.
The variable @var{state} must be initialized by calling one of the
@code{gmp_randinit} functions (@ref{Random State Initialization}) before
@@ -5120,7 +5004,7 @@ numbers have proven to be more likely to trigger corner-case bugs. Negative
random numbers are generated when @var{max_size} is negative.
@end deftypefun
-@c @deftypefun size_t mpf_size (const mpf_t @var{op})
+@c @deftypefun size_t mpf_size (mpf_t @var{op})
@c Return the size of @var{op} measured in number of limbs. If @var{op} is
@c zero, the returned value will be zero. (@xref{Nomenclature}, for an
@c explanation of the concept @dfn{limb}.)
@@ -5242,13 +5126,6 @@ This function requires that @var{s1n} is greater than or equal to
@var{s2n}.
@end deftypefun
-@deftypefun mp_limb_t mpn_neg (mp_limb_t *@var{rp}, const mp_limb_t *@var{sp}, mp_size_t @var{n})
-Perform the negation of @{@var{sp}, @var{n}@}, and write the result to
-@{@var{rp}, @var{n}@}. This is equivalent to calling @code{mpn_sub_n} with a
-@var{n}-limb zero minuend and passing @{@var{sp}, @var{n}@} as subtrahend.
-Return borrow, either 0 or 1.
-@end deftypefun
-
@deftypefun void mpn_mul_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
Multiply @{@var{s1p}, @var{n}@} and @{@var{s2p}, @var{n}@}, and write the
2*@var{n}-limb result to @var{rp}.
@@ -5257,7 +5134,7 @@ The destination has to have space for 2*@var{n} limbs, even if the product's
most significant limb is zero. No overlap is permitted between the
destination and either source.
-If the two input operands are the same, use @code{mpn_sqr}.
+If the two input operands are the same, use @code{mpn_sqr_n}.
@end deftypefun
@deftypefun mp_limb_t mpn_mul (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, mp_size_t @var{s1n}, const mp_limb_t *@var{s2p}, mp_size_t @var{s2n})
@@ -5272,11 +5149,11 @@ destination and either source.
This function requires that @var{s1n} is greater than or equal to @var{s2n}.
@end deftypefun
-@deftypefun void mpn_sqr (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, mp_size_t @var{n})
+@deftypefun void mpn_sqr_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, mp_size_t @var{n})
Compute the square of @{@var{s1p}, @var{n}@} and write the 2*@var{n}-limb
result to @var{rp}.
-The destination has to have space for 2@var{n} limbs, even if the result's
+The destination has to have space for 2*@var{n} limbs, even if the result's
most significant limb is zero. No overlap is permitted between the
destination and the source.
@end deftypefun
@@ -5322,10 +5199,10 @@ Divide @{@var{np}, @var{nn}@} by @{@var{dp}, @var{dn}@} and put the quotient
at @{@var{qp}, @var{nn}@minus{}@var{dn}+1@} and the remainder at @{@var{rp},
@var{dn}@}. The quotient is rounded towards 0.
-No overlap is permitted between arguments, except that @var{np} might equal
-@var{rp}. The dividend size @var{nn} must be greater than or equal to divisor
-size @var{dn}. The most significant limb of the divisor must be non-zero. The
-@var{qxn} operand must be zero.
+No overlap is permitted between arguments. @var{nn} must be greater than or
+equal to @var{dn}. The most significant limb of @var{dp} must be non-zero.
+The @var{qxn} operand must be zero.
+@comment FIXME: Relax overlap requirements!
@end deftypefun
@deftypefun mp_limb_t mpn_divrem (mp_limb_t *@var{r1p}, mp_size_t @var{qxn}, mp_limb_t *@var{rs2p}, mp_size_t @var{rs2n}, const mp_limb_t *@var{s3p}, mp_size_t @var{s3n})
@@ -5399,11 +5276,32 @@ be 0, 1 or 2 (these are both borrows really). When @math{c=0} clearly
@code{mp_bits_per_limb} is even, which is always so currently).
@end deftypefn
-@deftypefun mp_limb_t mpn_mod_1 (const mp_limb_t *@var{s1p}, mp_size_t @var{s1n}, mp_limb_t @var{s2limb})
+@deftypefun mp_limb_t mpn_mod_1 (mp_limb_t *@var{s1p}, mp_size_t @var{s1n}, mp_limb_t @var{s2limb})
Divide @{@var{s1p}, @var{s1n}@} by @var{s2limb}, and return the remainder.
@var{s1n} can be zero.
@end deftypefun
+@deftypefun mp_limb_t mpn_bdivmod (mp_limb_t *@var{rp}, mp_limb_t *@var{s1p}, mp_size_t @var{s1n}, const mp_limb_t *@var{s2p}, mp_size_t @var{s2n}, unsigned long int @var{d})
+This function puts the low
+@math{@GMPfloor{@var{d}/@nicode{mp\_bits\_per\_limb}}} limbs of @var{q} =
+@{@var{s1p}, @var{s1n}@}/@{@var{s2p}, @var{s2n}@} mod @m{2^d,2^@var{d}} at
+@var{rp}, and returns the high @var{d} mod @code{mp_bits_per_limb} bits of
+@var{q}.
+
+@{@var{s1p}, @var{s1n}@} - @var{q} * @{@var{s2p}, @var{s2n}@} mod @m{2
+\GMPraise{@var{s1n}*@code{mp\_bits\_per\_limb}},
+2^(@var{s1n}*@nicode{mp\_bits\_per\_limb})} is placed at @var{s1p}. Since the
+low @math{@GMPfloor{@var{d}/@nicode{mp\_bits\_per\_limb}}} limbs of this
+difference are zero, it is possible to overwrite the low limbs at @var{s1p}
+with this difference, provided @math{@var{rp} @le{} @var{s1p}}.
+
+This function requires that @math{@var{s1n} * @nicode{mp\_bits\_per\_limb}
+@ge{} @var{D}}, and that @{@var{s2p}, @var{s2n}@} is odd.
+
+@strong{This interface is preliminary. It might change incompatibly in future
+revisions.}
+@end deftypefun
+
@deftypefun mp_limb_t mpn_lshift (mp_limb_t *@var{rp}, const mp_limb_t *@var{sp}, mp_size_t @var{n}, unsigned int @var{count})
Shift @{@var{sp}, @var{n}@} left by @var{count} bits, and write the result to
@{@var{rp}, @var{n}@}. The bits shifted out at the left are returned in the
@@ -5442,9 +5340,10 @@ Set @{@var{rp}, @var{retval}@} to the greatest common divisor of @{@var{xp},
the return value is the actual number produced. Both source operands are
destroyed.
-It is required that @math{@var{xn} @ge @var{yn} > 0}, and the most significant
-limb of @{@var{yp}, @var{yn}@} must be non-zero. No overlap is permitted
-between @{@var{xp}, @var{xn}@} and @{@var{yp}, @var{yn}@}.
+@{@var{xp}, @var{xn}@} must have at least as many bits as @{@var{yp},
+@var{yn}@}. @{@var{yp}, @var{yn}@} must be odd. Both operands must have
+non-zero most significant limbs. No overlap is permitted between @{@var{xp},
+@var{xn}@} and @{@var{yp}, @var{yn}@}.
@end deftypefun
@deftypefun mp_limb_t mpn_gcd_1 (const mp_limb_t *@var{xp}, mp_size_t @var{xn}, mp_limb_t @var{ylimb})
@@ -5452,35 +5351,30 @@ Return the greatest common divisor of @{@var{xp}, @var{xn}@} and @var{ylimb}.
Both operands must be non-zero.
@end deftypefun
-@deftypefun mp_size_t mpn_gcdext (mp_limb_t *@var{gp}, mp_limb_t *@var{sp}, mp_size_t *@var{sn}, mp_limb_t *@var{up}, mp_size_t @var{un}, mp_limb_t *@var{vp}, mp_size_t @var{vn})
-Let @m{U,@var{U}} be defined by @{@var{up}, @var{un}@} and let @m{V,@var{V}} be
-defined by @{@var{vp}, @var{vn}@}.
+@deftypefun mp_size_t mpn_gcdext (mp_limb_t *@var{gp}, mp_limb_t *@var{sp}, mp_size_t *@var{sn}, mp_limb_t *@var{xp}, mp_size_t @var{xn}, mp_limb_t *@var{yp}, mp_size_t @var{yn})
+Let @m{U,@var{U}} be defined by @{@var{xp}, @var{xn}@} and let @m{V,@var{V}} be
+defined by @{@var{yp}, @var{yn}@}.
Compute the greatest common divisor @math{G} of @math{U} and @math{V}. Compute
a cofactor @math{S} such that @math{G = US + VT}. The second cofactor @var{T}
is not computed but can easily be obtained from @m{(G - US) / V, (@var{G} -
@var{U}*@var{S}) / @var{V}} (the division will be exact). It is required that
-@math{@var{un} @ge @var{vn} > 0}, and the most significant
-limb of @{@var{vp}, @var{vn}@} must be non-zero.
+@math{U @ge V > 0}.
@math{S} satisfies @math{S = 1} or @math{@GMPabs{S} < V / (2 G)}. @math{S =
0} if and only if @math{V} divides @math{U} (i.e., @math{G = V}).
Store @math{G} at @var{gp} and let the return value define its limb count.
Store @math{S} at @var{sp} and let |*@var{sn}| define its limb count. @math{S}
-can be negative; when this happens *@var{sn} will be negative. The area at
-@var{gp} should have room for @var{vn} limbs and the area at @var{sp} should
-have room for @math{@var{vn}+1} limbs.
+can be negative; when this happens *@var{sn} will be negative. The areas at
+@var{gp} and @var{sp} should each have room for @math{@var{xn}+1} limbs.
-Both source operands are destroyed.
+The areas @{@var{xp}, @math{@var{xn}+1}@} and @{@var{yp}, @math{@var{yn}+1}@}
+are destroyed (i.e.@: the input operands plus an extra limb past the end of
+each).
-Compatibility notes: GMP 4.3.0 and 4.3.1 defined @math{S} less strictly.
+Compatibility note: GMP 4.3.0 and 4.3.1 defined @math{S} less strictly.
Earlier as well as later GMP releases define @math{S} as described here.
-GMP releases before GMP 4.3.0 required additional space for both input and output
-areas. More precisely, the areas @{@var{up}, @math{@var{un}+1}@} and
-@{@var{vp}, @math{@var{vn}+1}@} were destroyed (i.e.@: the operands plus an
-extra limb past the end of each), and the areas pointed to by @var{gp} and
-@var{sp} should each have room for @math{@var{un}+1} limbs.
@end deftypefun
@deftypefun mp_size_t mpn_sqrtrem (mp_limb_t *@var{r1p}, mp_limb_t *@var{r2p}, const mp_limb_t *@var{sp}, mp_size_t @var{n})
@@ -5499,14 +5393,7 @@ case the return value is zero or non-zero according to whether the remainder
would have been zero or non-zero.
A return value of zero indicates a perfect square. See also
-@code{mpn_perfect_square_p}.
-@end deftypefun
-
-@deftypefun size_t mpn_sizeinbase (const mp_limb_t *@var{xp}, mp_size_t @var{n}, int @var{base})
-Return the size of @{@var{xp},@var{n}@} measured in number of digits in the
-given @var{base}. @var{base} can vary from 2 to 62. Requires @math{@var{n} > 0}
-and @math{@var{xp}[@var{n}-1] > 0}. The result will be either exact or
-1 too big. If @var{base} is a power of 2, the result is always exact.
+@code{mpz_perfect_square_p}.
@end deftypefun
@deftypefun mp_size_t mpn_get_str (unsigned char *@var{str}, int @var{base}, mp_limb_t *@var{s1p}, mp_size_t @var{s1n})
@@ -5528,31 +5415,30 @@ represented by a @var{s1n} long limb array, plus one extra character.
Convert bytes @{@var{str},@var{strsize}@} in the given @var{base} to limbs at
@var{rp}.
-@math{@var{str}[0]} is the most significant input byte and
-@math{@var{str}[@var{strsize}-1]} is the least significant input byte. Each
-byte should be a value in the range 0 to @math{@var{base}-1}, not an ASCII
-character. @var{base} can vary from 2 to 256.
+@math{@var{str}[0]} is the most significant byte and
+@math{@var{str}[@var{strsize}-1]} is the least significant. Each byte should
+be a value in the range 0 to @math{@var{base}-1}, not an ASCII character.
+@var{base} can vary from 2 to 256.
-The converted value is @{@var{rp},@var{rn}@} where @var{rn} is the return
-value. If the most significant input byte @math{@var{str}[0]} is non-zero,
-then @math{@var{rp}[@var{rn}-1]} will be non-zero, else
-@math{@var{rp}[@var{rn}-1]} and some number of subsequent limbs may be zero.
+The return value is the number of limbs written to @var{rp}. If the most
+significant input byte is non-zero then the high limb at @var{rp} will be
+non-zero, and only that exact number of limbs will be required there.
-The area at @var{rp} has to have space for the largest possible number with
-@var{strsize} digits in the chosen base, plus one extra limb.
+If the most significant input byte is zero then there may be high zero limbs
+written to @var{rp} and included in the return value.
-The input must have at least one byte, and no overlap is permitted between
+@var{strsize} must be at least 1, and no overlap is permitted between
@{@var{str},@var{strsize}@} and the result at @var{rp}.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpn_scan0 (const mp_limb_t *@var{s1p}, mp_bitcnt_t @var{bit})
+@deftypefun {unsigned long int} mpn_scan0 (const mp_limb_t *@var{s1p}, unsigned long int @var{bit})
Scan @var{s1p} from bit position @var{bit} for the next clear bit.
It is required that there be a clear bit within the area at @var{s1p} at or
beyond bit position @var{bit}, so that the function has something to return.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpn_scan1 (const mp_limb_t *@var{s1p}, mp_bitcnt_t @var{bit})
+@deftypefun {unsigned long int} mpn_scan1 (const mp_limb_t *@var{s1p}, unsigned long int @var{bit})
Scan @var{s1p} from bit position @var{bit} for the next set bit.
It is required that there be a set bit within the area at @var{s1p} at or
@@ -5570,11 +5456,11 @@ zeros and ones in the binary representation.
routines.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpn_popcount (const mp_limb_t *@var{s1p}, mp_size_t @var{n})
+@deftypefun {unsigned long int} mpn_popcount (const mp_limb_t *@var{s1p}, mp_size_t @var{n})
Count the number of set bits in @{@var{s1p}, @var{n}@}.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpn_hamdist (const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
+@deftypefun {unsigned long int} mpn_hamdist (const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
Compute the hamming distance between @{@var{s1p}, @var{n}@} and @{@var{s2p},
@var{n}@}, which is the number of bit positions where the two operands have
different bit values.
@@ -5582,245 +5468,6 @@ different bit values.
@deftypefun int mpn_perfect_square_p (const mp_limb_t *@var{s1p}, mp_size_t @var{n})
Return non-zero iff @{@var{s1p}, @var{n}@} is a perfect square.
-The most significant limb of the input @{@var{s1p}, @var{n}@} must be
-non-zero.
-@end deftypefun
-
-@deftypefun void mpn_and_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical and of @{@var{s1p}, @var{n}@} and @{@var{s2p},
-@var{n}@}, and write the result to @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_ior_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical inclusive or of @{@var{s1p}, @var{n}@} and
-@{@var{s2p}, @var{n}@}, and write the result to @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_xor_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical exclusive or of @{@var{s1p}, @var{n}@} and
-@{@var{s2p}, @var{n}@}, and write the result to @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_andn_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical and of @{@var{s1p}, @var{n}@} and the bitwise
-complement of @{@var{s2p}, @var{n}@}, and write the result to @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_iorn_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical inclusive or of @{@var{s1p}, @var{n}@} and the bitwise
-complement of @{@var{s2p}, @var{n}@}, and write the result to @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_nand_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical and of @{@var{s1p}, @var{n}@} and @{@var{s2p},
-@var{n}@}, and write the bitwise complement of the result to @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_nior_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical inclusive or of @{@var{s1p}, @var{n}@} and
-@{@var{s2p}, @var{n}@}, and write the bitwise complement of the result to
-@{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_xnor_n (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-Perform the bitwise logical exclusive or of @{@var{s1p}, @var{n}@} and
-@{@var{s2p}, @var{n}@}, and write the bitwise complement of the result to
-@{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_com (mp_limb_t *@var{rp}, const mp_limb_t *@var{sp}, mp_size_t @var{n})
-Perform the bitwise complement of @{@var{sp}, @var{n}@}, and write the result
-to @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@deftypefun void mpn_copyi (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, mp_size_t @var{n})
-Copy from @{@var{s1p}, @var{n}@} to @{@var{rp}, @var{n}@}, increasingly.
-@end deftypefun
-
-@deftypefun void mpn_copyd (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, mp_size_t @var{n})
-Copy from @{@var{s1p}, @var{n}@} to @{@var{rp}, @var{n}@}, decreasingly.
-@end deftypefun
-
-@deftypefun void mpn_zero (mp_limb_t *@var{rp}, mp_size_t @var{n})
-Zero @{@var{rp}, @var{n}@}.
-@end deftypefun
-
-@sp 1
-@section Low-level functions for cryptography
-@cindex Low-level functions for cryptography
-@cindex Cryptography functions, low-level
-
-The functions prefixed with @code{mpn_sec_} and @code{mpn_cnd_} are designed to
-perform the exact same low-level operations and have the same cache access
-patterns for any two same-size arguments, assuming that function arguments are
-placed at the same position and that the machine state is identical upon
-function entry. These functions are intended for cryptographic purposes, where
-resilience to side-channel attacks is desired.
-
-These functions are less efficient than their ``leaky'' counterparts; their
-performance for operands of the sizes typically used for cryptographic
-applications is between 15% and 100% worse. For larger operands, these
-functions might be inadequate, since they rely on asymptotically elementary
-algorithms.
-
-These functions do not make any explicit allocations. Those of these functions
-that need scratch space accept a scratch space operand. This convention allows
-callers to keep sensitive data in designated memory areas. Note however that
-compilers may choose to spill scalar values used within these functions to
-their stack frame and that such scalars may contain sensitive data.
-
-In addition to these specially crafted functions, the following @code{mpn}
-functions are naturally side-channel resistant: @code{mpn_add_n},
-@code{mpn_sub_n}, @code{mpn_lshift}, @code{mpn_rshift}, @code{mpn_zero},
-@code{mpn_copyi}, @code{mpn_copyd}, @code{mpn_com}, and the logical function
-(@code{mpn_and_n}, etc).
-
-There are some exceptions from the side-channel resilience: (1) Some assembly
-implementations of @code{mpn_lshift} identify shift-by-one as a special case.
-This is a problem iff the shift count is a function of sensitive data. (2)
-Alpha ev6 and Pentium4 using 64-bit limbs have leaky @code{mpn_add_n} and
-@code{mpn_sub_n}. (3) Alpha ev6 has a leaky @code{mpn_mul_1} which also makes
-@code{mpn_sec_mul} on those systems unsafe.
-
-@deftypefun mp_limb_t mpn_cnd_add_n (mp_limb_t @var{cnd}, mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-@deftypefunx mp_limb_t mpn_cnd_sub_n (mp_limb_t @var{cnd}, mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n})
-These functions do conditional addition and subtraction. If @var{cnd} is
-non-zero, they produce the same result as a regular @code{mpn_add_n} or
-@code{mpn_sub_n}, and if @var{cnd} is zero, they copy @{@var{s1p},@var{n}@} to
-the result area and return zero. The functions are designed to have timing and
-memory access patterns depending only on size and location of the data areas,
-but independent of the condition @var{cnd}. Like for @code{mpn_add_n} and
-@code{mpn_sub_n}, on most machines, the timing will also be independent of the
-actual limb values.
-@end deftypefun
-
-@deftypefun mp_limb_t mpn_sec_add_1 (mp_limb_t *@var{rp}, const mp_limb_t *@var{ap}, mp_size_t @var{n}, mp_limb_t @var{b}, mp_limb_t *@var{tp})
-@deftypefunx mp_limb_t mpn_sec_sub_1 (mp_limb_t *@var{rp}, const mp_limb_t *@var{ap}, mp_size_t @var{n}, mp_limb_t @var{b}, mp_limb_t *@var{tp})
-Set @var{R} to @var{A} + @var{b} or @var{A} - @var{b}, respectively, where
-@var{R} = @{@var{rp},@var{n}@}, @var{A} = @{@var{ap},@var{n}@}, and @var{b} is
-a single limb. Returns carry.
-
-These functions take @math{O(N)} time, unlike the leaky functions
-@code{mpn_add_1} which are @math{O(1)} on average. They require scratch space
-of @code{mpn_sec_add_1_itch(@var{n})} and @code{mpn_sec_sub_1_itch(@var{n})}
-limbs, respectively, to be passed in the @var{tp} parameter. The scratch space
-requirements are guaranteed to increase monotonously in the operand size.
-@end deftypefun
-
-@deftypefun void mpn_sec_mul (mp_limb_t *@var{rp}, const mp_limb_t *@var{ap}, mp_size_t @var{an}, const mp_limb_t *@var{bp}, mp_size_t @var{bn}, mp_limb_t *@var{tp})
-@deftypefunx mp_size_t mpn_sec_mul_itch (mp_size_t @var{an}, mp_size_t @var{bn})
-Set @var{R} to @math{A @times{} B}, where @var{A} = @{@var{ap},@var{an}@},
-@var{B} = @{@var{bp},@var{bn}@}, and @var{R} =
-@{@var{rp},@math{@var{an}+@var{bn}}@}.
-
-It is required that @math{@var{an} @ge @var{bn} > 0}.
-
-No overlapping between @var{R} and the input operands is allowed. For
-@math{@var{A} = @var{B}}, use @code{mpn_sec_sqr} for optimal performance.
-
-This function requires scratch space of @code{mpn_sec_mul_itch(@var{an},
-@var{bn})} limbs to be passed in the @var{tp} parameter. The scratch space
-requirements are guaranteed to increase monotonously in the operand sizes.
-@end deftypefun
-
-
-@deftypefun void mpn_sec_sqr (mp_limb_t *@var{rp}, const mp_limb_t *@var{ap}, mp_size_t @var{an}, mp_limb_t *@var{tp})
-@deftypefunx mp_size_t mpn_sec_sqr_itch (mp_size_t @var{an})
-Set @var{R} to @math{A^2}, where @var{A} = @{@var{ap},@var{an}@}, and @var{R} =
-@{@var{rp},@math{2@var{an}}@}.
-
-It is required that @math{@var{an} > 0}.
-
-No overlapping between @var{R} and the input operands is allowed.
-
-This function requires scratch space of @code{mpn_sec_sqr_itch(@var{an})} limbs
-to be passed in the @var{tp} parameter. The scratch space requirements are
-guaranteed to increase monotonously in the operand size.
-@end deftypefun
-
-
-@deftypefun void mpn_sec_powm (mp_limb_t *@var{rp}, const mp_limb_t *@var{bp}, mp_size_t @var{bn}, const mp_limb_t *@var{ep}, mp_bitcnt_t @var{enb}, const mp_limb_t *@var{mp}, mp_size_t @var{n}, mp_limb_t *@var{tp})
-@deftypefunx mp_size_t mpn_sec_powm_itch (mp_size_t @var{bn}, mp_bitcnt_t @var{enb}, size_t @var{n})
-Set @var{R} to @m{B^E \bmod @var{M}, (@var{B} raised to @var{E}) modulo
-@var{M}}, where @var{R} = @{@var{rp},@var{n}@}, @var{M} = @{@var{mp},@var{n}@},
-and @var{E} = @{@var{ep},@math{@GMPceil{@var{enb} /
-@code{GMP\_NUMB\_BITS}}}@}.
-
-It is required that @math{@var{B} > 0}, that @math{@var{M} > 0} is odd, and
-that @m{@var{E} < 2@GMPraise{@var{enb}}, @var{E} < 2^@var{enb}}.
-
-No overlapping between @var{R} and the input operands is allowed.
-
-This function requires scratch space of @code{mpn_sec_powm_itch(@var{bn},
-@var{enb}, @var{n})} limbs to be passed in the @var{tp} parameter. The scratch
-space requirements are guaranteed to increase monotonously in the operand
-sizes.
-@end deftypefun
-
-@deftypefun void mpn_sec_tabselect (mp_limb_t *@var{rp}, const mp_limb_t *@var{tab}, mp_size_t @var{n}, mp_size_t @var{nents}, mp_size_t @var{which})
-Select entry @var{which} from table @var{tab}, which has @var{nents} entries, each @var{n}
-limbs. Store the selected entry at @var{rp}.
-
-This function reads the entire table to avoid side-channel information leaks.
-@end deftypefun
-
-@deftypefun mp_limb_t mpn_sec_div_qr (mp_limb_t *@var{qp}, mp_limb_t *@var{np}, mp_size_t @var{nn}, const mp_limb_t *@var{dp}, mp_size_t @var{dn}, mp_limb_t *@var{tp})
-@deftypefunx mp_size_t mpn_sec_div_qr_itch (mp_size_t @var{nn}, mp_size_t @var{dn})
-
-Set @var{Q} to @m{\lfloor @var{N} / @var{D}\rfloor, the truncated quotient
-@var{N} / @var{D}} and @var{R} to @m{@var{N} \bmod @var{D}, @var{N} modulo
-@var{D}}, where @var{N} = @{@var{np},@var{nn}@}, @var{D} =
-@{@var{dp},@var{dn}@}, @var{Q}'s most significant limb is the function return
-value and the remaining limbs are @{@var{qp},@var{nn-dn}@}, and @var{R} =
-@{@var{np},@var{dn}@}.
-
-It is required that @math{@var{nn} @ge @var{dn} @ge 1}, and that
-@m{@var{dp}[@var{dn}-1] @neq 0, @var{dp}[@var{dn}-1] != 0}. This does not
-imply that @math{@var{N} @ge @var{D}} since @var{N} might be zero-padded.
-
-Note the overlapping between @var{N} and @var{R}. No other operand overlapping
-is allowed. The entire space occupied by @var{N} is overwritten.
-
-This function requires scratch space of @code{mpn_sec_div_qr_itch(@var{nn},
-@var{dn})} limbs to be passed in the @var{tp} parameter.
-@end deftypefun
-
-@deftypefun void mpn_sec_div_r (mp_limb_t *@var{np}, mp_size_t @var{nn}, const mp_limb_t *@var{dp}, mp_size_t @var{dn}, mp_limb_t *@var{tp})
-@deftypefunx mp_size_t mpn_sec_div_r_itch (mp_size_t @var{nn}, mp_size_t @var{dn})
-
-Set @var{R} to @m{@var{N} \bmod @var{D}, @var{N} modulo @var{D}}, where @var{N}
-= @{@var{np},@var{nn}@}, @var{D} = @{@var{dp},@var{dn}@}, and @var{R} =
-@{@var{np},@var{dn}@}.
-
-It is required that @math{@var{nn} @ge @var{dn} @ge 1}, and that
-@m{@var{dp}[@var{dn}-1] @neq 0, @var{dp}[@var{dn}-1] != 0}. This does not
-imply that @math{@var{N} @ge @var{D}} since @var{N} might be zero-padded.
-
-Note the overlapping between @var{N} and @var{R}. No other operand overlapping
-is allowed. The entire space occupied by @var{N} is overwritten.
-
-This function requires scratch space of @code{mpn_sec_div_r_itch(@var{nn},
-@var{dn})} limbs to be passed in the @var{tp} parameter.
-@end deftypefun
-
-@deftypefun int mpn_sec_invert (mp_limb_t *@var{rp}, mp_limb_t *@var{ap}, const mp_limb_t *@var{mp}, mp_size_t @var{n}, mp_bitcnt_t @var{nbcnt}, mp_limb_t *@var{tp})
-@deftypefunx mp_size_t mpn_sec_invert_itch (mp_size_t @var{n})
-Set @var{R} to @m{@var{A}^{-1} \bmod @var{M}, the inverse of @var{A} modulo
-@var{M}}, where @var{R} = @{@var{rp},@var{n}@}, @var{A} = @{@var{ap},@var{n}@},
-and @var{M} = @{@var{mp},@var{n}@}. @strong{This function's interface is
-preliminary.}
-
-If an inverse exists, return 1, otherwise return 0 and leave @var{R}
-undefined. In either case, the input @var{A} is destroyed.
-
-It is required that @var{M} is odd, and that @math{@var{nbcnt} @ge
-@GMPceil{\log(@var{A}+1)} + @GMPceil{\log(@var{M}+1)}}. A safe choice is
-@m{@var{nbcnt} = 2@var{n} @times{} @code{GMP\_NUMB\_BITS}, @var{nbcnt} = 2
-@times{} @var{n} @times{} GMP_NUMB_BITS}, but a smaller value might improve
-performance if @var{M} or @var{A} are known to have leading zero bits.
-
-This function requires scratch space of @code{mpn_sec_invert_itch(@var{n})}
-limbs to be passed in the @var{tp} parameter.
@end deftypefun
@@ -5934,7 +5581,7 @@ Initialize @var{state} for a Mersenne Twister algorithm. This algorithm is
fast and has good randomness properties.
@end deftypefun
-@deftypefun void gmp_randinit_lc_2exp (gmp_randstate_t @var{state}, const mpz_t @var{a}, @w{unsigned long @var{c}}, @w{mp_bitcnt_t @var{m2exp}})
+@deftypefun void gmp_randinit_lc_2exp (gmp_randstate_t @var{state}, mpz_t @var{a}, @w{unsigned long @var{c}}, @w{unsigned long @var{m2exp}})
@cindex Linear congruential random numbers
Initialize @var{state} with a linear congruential algorithm @m{X = (@var{a}X +
@var{c}) @bmod 2^{m2exp}, X = (@var{a}*X + @var{c}) mod 2^@var{m2exp}}.
@@ -5949,12 +5596,12 @@ generated, multiple iterations of the recurrence are used and the results
concatenated.
@end deftypefun
-@deftypefun int gmp_randinit_lc_2exp_size (gmp_randstate_t @var{state}, mp_bitcnt_t @var{size})
+@deftypefun int gmp_randinit_lc_2exp_size (gmp_randstate_t @var{state}, unsigned long @var{size})
@cindex Linear congruential random numbers
Initialize @var{state} for a linear congruential algorithm as per
@code{gmp_randinit_lc_2exp}. @var{a}, @var{c} and @var{m2exp} are selected
from a table, chosen so that @var{size} bits (or more) of each @math{X} will
-be used, i.e.@: @math{@var{m2exp}/2 @ge{} @var{size}}.
+be used, ie.@: @math{@var{m2exp}/2 @ge{} @var{size}}.
If successful the return value is non-zero. If @var{size} is bigger than the
table data provides then the return value is zero. The maximum @var{size}
@@ -6002,7 +5649,7 @@ Free all memory occupied by @var{state}.
@cindex Random number seeding
@cindex Seeding random numbers
-@deftypefun void gmp_randseed (gmp_randstate_t @var{state}, const mpz_t @var{seed})
+@deftypefun void gmp_randseed (gmp_randstate_t @var{state}, mpz_t @var{seed})
@deftypefunx void gmp_randseed_ui (gmp_randstate_t @var{state}, @w{unsigned long int @var{seed}})
Set an initial seed value into @var{state}.
@@ -6027,7 +5674,7 @@ random data better suited for use as a seed.
@section Random State Miscellaneous
@deftypefun {unsigned long} gmp_urandomb_ui (gmp_randstate_t @var{state}, unsigned long @var{n})
-Return a uniformly distributed random number of @var{n} bits, i.e.@: in the
+Return a uniformly distributed random number of @var{n} bits, ie.@: in the
range 0 to @m{2^n-1,2^@var{n}-1} inclusive. @var{n} must be less than or
equal to the number of bits in an @code{unsigned long}.
@end deftypefun
@@ -6182,7 +5829,7 @@ instance extensions registered with GLIBC @code{register_printf_function}.
Also currently there's no support for POSIX @samp{$} style numbered arguments
(perhaps this will be added in the future).
-The precision field has its usual meaning for integer @samp{Z} and float
+The precision field has it's usual meaning for integer @samp{Z} and float
@samp{F} types, but is currently undefined for @samp{Q} and should not be used
with that.
@@ -6193,10 +5840,7 @@ happens even for an @samp{f} conversion of an @code{mpf_t} which is an
integer, for instance @math{2^@W{1024}} in an @code{mpf_t} of 128 bits
precision will only produce about 40 digits, then pad with zeros to the
decimal point. An empty precision field like @samp{%.Fe} or @samp{%.Ff} can
-be used to specifically request just the significant digits. Without any dot
-and thus no precision field, a precision value of 6 will be used. Note that
-these rules mean that @samp{%Ff}, @samp{%.Ff}, and @samp{%.0Ff} will all be
-different.
+be used to specifically request just the significant digits.
The decimal point character (or string) is taken from the current locale
settings on systems which provide @code{localeconv} (@pxref{Locales,, Locales
@@ -6307,7 +5951,7 @@ The following functions are provided in @file{libgmpxx} (@pxref{Headers and
Libraries}), which is built if C++ support is enabled (@pxref{Build Options}).
Prototypes are available from @code{<gmp.h>}.
-@deftypefun ostream& operator<< (ostream& @var{stream}, const mpz_t @var{op})
+@deftypefun ostream& operator<< (ostream& @var{stream}, mpz_t @var{op})
Print @var{op} to @var{stream}, using its @code{ios} formatting settings.
@code{ios::width} is reset to 0 after output, the same as the standard
@code{ostream operator<<} routines do.
@@ -6317,7 +5961,7 @@ decimal. This is unlike the standard @code{operator<<} routines on @code{int}
etc, which instead give twos complement.
@end deftypefun
-@deftypefun ostream& operator<< (ostream& @var{stream}, const mpq_t @var{op})
+@deftypefun ostream& operator<< (ostream& @var{stream}, mpq_t @var{op})
Print @var{op} to @var{stream}, using its @code{ios} formatting settings.
@code{ios::width} is reset to 0 after output, the same as the standard
@code{ostream operator<<} routines do.
@@ -6330,7 +5974,7 @@ decimal. If @code{ios::showbase} is set then a base indicator is shown on
both the numerator and denominator (if the denominator is required).
@end deftypefun
-@deftypefun ostream& operator<< (ostream& @var{stream}, const mpf_t @var{op})
+@deftypefun ostream& operator<< (ostream& @var{stream}, mpf_t @var{op})
Print @var{op} to @var{stream}, using its @code{ios} formatting settings.
@code{ios::width} is reset to 0 after output, the same as the standard
@code{ostream operator<<} routines do.
@@ -6639,7 +6283,7 @@ results. For classes with overloading, see @ref{C++ Class Interface}.
-@node C++ Class Interface, Custom Allocation, Formatted Input, Top
+@node C++ Class Interface, BSD Compatible Functions, Formatted Input, Top
@chapter C++ Class Interface
@cindex C++ interface
@@ -6651,7 +6295,7 @@ overloaded functions and operators which may be more convenient.
Due to the implementation of this interface, a reasonably recent C++ compiler
is required, one supporting namespaces, partial specialization of templates
-and member templates.
+and member templates. For GCC this means version 2.91 or later.
@strong{Everything described in this chapter is to be considered preliminary
and might be subject to incompatible changes if some unforeseen difficulty
@@ -6774,23 +6418,23 @@ anything.
@node C++ Interface Integers, C++ Interface Rationals, C++ Interface General, C++ Class Interface
@section C++ Interface Integers
-@deftypefun {} mpz_class::mpz_class (type @var{n})
+@deftypefun void mpz_class::mpz_class (type @var{n})
Construct an @code{mpz_class}. All the standard C++ types may be used, except
@code{long long} and @code{long double}, and all the GMP C++ classes can be
-used, although conversions from @code{mpq_class} and @code{mpf_class} are
-@code{explicit}. Any necessary conversion follows the corresponding C
-function, for example @code{double} follows @code{mpz_set_d}
-(@pxref{Assigning Integers}).
+used. Any necessary conversion follows the corresponding C function, for
+example @code{double} follows @code{mpz_set_d} (@pxref{Assigning Integers}).
@end deftypefun
-@deftypefun explicit mpz_class::mpz_class (const mpz_t @var{z})
+@deftypefun void mpz_class::mpz_class (mpz_t @var{z})
Construct an @code{mpz_class} from an @code{mpz_t}. The value in @var{z} is
copied into the new @code{mpz_class}, there won't be any permanent association
between it and @var{z}.
@end deftypefun
-@deftypefun explicit mpz_class::mpz_class (const char *@var{s}, int @var{base} = 0)
-@deftypefunx explicit mpz_class::mpz_class (const string& @var{s}, int @var{base} = 0)
+@deftypefun void mpz_class::mpz_class (const char *@var{s})
+@deftypefunx void mpz_class::mpz_class (const char *@var{s}, int @var{base} = 0)
+@deftypefunx void mpz_class::mpz_class (const string& @var{s})
+@deftypefunx void mpz_class::mpz_class (const string& @var{s}, int @var{base} = 0)
Construct an @code{mpz_class} converted from a string using @code{mpz_set_str}
(@pxref{Assigning Integers}).
@@ -6798,11 +6442,6 @@ If the string is not a valid integer, an @code{std::invalid_argument}
exception is thrown. The same applies to @code{operator=}.
@end deftypefun
-@deftypefun mpz_class operator"" _mpz (const char *@var{str})
-With C++11 compilers, integers can be constructed with the syntax
-@code{123_mpz} which is equivalent to @code{mpz_class("123")}.
-@end deftypefun
-
@deftypefun mpz_class operator/ (mpz_class @var{a}, mpz_class @var{d})
@deftypefunx mpz_class operator% (mpz_class @var{a}, mpz_class @var{d})
Divisions involving @code{mpz_class} round towards zero, as per the
@@ -6819,7 +6458,7 @@ mpz_fdiv_q (q.get_mpz_t(), a.get_mpz_t(), d.get_mpz_t());
@end example
@end deftypefun
-@deftypefun mpz_class abs (mpz_class @var{op})
+@deftypefun mpz_class abs (mpz_class @var{op1})
@deftypefunx int cmp (mpz_class @var{op1}, type @var{op2})
@deftypefunx int cmp (type @var{op1}, mpz_class @var{op2})
@maybepagebreak
@@ -6840,9 +6479,6 @@ mpz_fdiv_q (q.get_mpz_t(), a.get_mpz_t(), d.get_mpz_t());
@deftypefunx int mpz_class::set_str (const string& @var{str}, int @var{base})
@deftypefunx int sgn (mpz_class @var{op})
@deftypefunx mpz_class sqrt (mpz_class @var{op})
-@maybepagebreak
-@deftypefunx void mpz_class::swap (mpz_class& @var{op})
-@deftypefunx void swap (mpz_class& @var{op1}, mpz_class& @var{op2})
These functions provide a C++ class interface to the corresponding GMP C
routines.
@@ -6868,13 +6504,12 @@ And comparisons are always made exactly, as per @code{mpz_cmp_d}.
In all the following constructors, if a fraction is given then it should be in
canonical form, or if not then @code{mpq_class::canonicalize} called.
-@deftypefun {} mpq_class::mpq_class (type @var{op})
-@deftypefunx {} mpq_class::mpq_class (integer @var{num}, integer @var{den})
+@deftypefun void mpq_class::mpq_class (type @var{op})
+@deftypefunx void mpq_class::mpq_class (integer @var{num}, integer @var{den})
Construct an @code{mpq_class}. The initial value can be a single value of any
-type (conversion from @code{mpf_class} is @code{explicit}), or a pair of
-integers (@code{mpz_class} or standard C++ integer types) representing a
-fraction, except that @code{long long} and @code{long double} are not
-supported. For example,
+type, or a pair of integers (@code{mpz_class} or standard C++ integer types)
+representing a fraction, except that @code{long long} and @code{long double}
+are not supported. For example,
@example
mpq_class q (99);
@@ -6883,14 +6518,16 @@ mpq_class q (1, 3);
@end example
@end deftypefun
-@deftypefun explicit mpq_class::mpq_class (const mpq_t @var{q})
+@deftypefun void mpq_class::mpq_class (mpq_t @var{q})
Construct an @code{mpq_class} from an @code{mpq_t}. The value in @var{q} is
copied into the new @code{mpq_class}, there won't be any permanent association
between it and @var{q}.
@end deftypefun
-@deftypefun explicit mpq_class::mpq_class (const char *@var{s}, int @var{base} = 0)
-@deftypefunx explicit mpq_class::mpq_class (const string& @var{s}, int @var{base} = 0)
+@deftypefun void mpq_class::mpq_class (const char *@var{s})
+@deftypefunx void mpq_class::mpq_class (const char *@var{s}, int @var{base} = 0)
+@deftypefunx void mpq_class::mpq_class (const string& @var{s})
+@deftypefunx void mpq_class::mpq_class (const string& @var{s}, int @var{base} = 0)
Construct an @code{mpq_class} converted from a string using @code{mpq_set_str}
(@pxref{Initializing Rationals}).
@@ -6898,12 +6535,6 @@ If the string is not a valid rational, an @code{std::invalid_argument}
exception is thrown. The same applies to @code{operator=}.
@end deftypefun
-@deftypefun mpq_class operator"" _mpq (const char *@var{str})
-With C++11 compilers, integral rationals can be constructed with the syntax
-@code{123_mpq} which is equivalent to @code{mpq_class(123_mpz)}. Other
-rationals can be built as @code{-1_mpq/2} or @code{0xb_mpq/123456_mpz}.
-@end deftypefun
-
@deftypefun void mpq_class::canonicalize ()
Put an @code{mpq_class} into canonical form, as per @ref{Rational Number
Functions}. All arithmetic operators require their operands in canonical
@@ -6920,9 +6551,6 @@ form, and will return results in canonical form.
@deftypefunx int mpq_class::set_str (const char *@var{str}, int @var{base})
@deftypefunx int mpq_class::set_str (const string& @var{str}, int @var{base})
@deftypefunx int sgn (mpq_class @var{op})
-@maybepagebreak
-@deftypefunx void mpq_class::swap (mpq_class& @var{op})
-@deftypefunx void swap (mpq_class& @var{op1}, mpq_class& @var{op2})
These functions provide a C++ class interface to the corresponding GMP C
routines.
@@ -6969,7 +6597,7 @@ as the destination @code{f}. Explicit constructors can be used if this
doesn't suit.
@deftypefun {} mpf_class::mpf_class (type @var{op})
-@deftypefunx {} mpf_class::mpf_class (type @var{op}, mp_bitcnt_t @var{prec})
+@deftypefunx {} mpf_class::mpf_class (type @var{op}, unsigned long @var{prec})
Construct an @code{mpf_class}. Any standard C++ type can be used, except
@code{long long} and @code{long double}, and any of the GMP C++ classes can be
used.
@@ -6992,20 +6620,10 @@ mpf_class f(x+y); // greater of precisions of x and y
@end example
@end deftypefun
-@deftypefun explicit mpf_class::mpf_class (const mpf_t @var{f})
-@deftypefunx {} mpf_class::mpf_class (const mpf_t @var{f}, mp_bitcnt_t @var{prec})
-Construct an @code{mpf_class} from an @code{mpf_t}. The value in @var{f} is
-copied into the new @code{mpf_class}, there won't be any permanent association
-between it and @var{f}.
-
-If @var{prec} is given, the initial precision is that value, in bits. If
-@var{prec} is not given, then the initial precision is that of @var{f}.
-@end deftypefun
-
-@deftypefun explicit mpf_class::mpf_class (const char *@var{s})
-@deftypefunx {} mpf_class::mpf_class (const char *@var{s}, mp_bitcnt_t @var{prec}, int @var{base} = 0)
-@deftypefunx explicit mpf_class::mpf_class (const string& @var{s})
-@deftypefunx {} mpf_class::mpf_class (const string& @var{s}, mp_bitcnt_t @var{prec}, int @var{base} = 0)
+@deftypefun void mpf_class::mpf_class (const char *@var{s})
+@deftypefunx void mpf_class::mpf_class (const char *@var{s}, unsigned long @var{prec}, int @var{base} = 0)
+@deftypefunx void mpf_class::mpf_class (const string& @var{s})
+@deftypefunx void mpf_class::mpf_class (const string& @var{s}, unsigned long @var{prec}, int @var{base} = 0)
Construct an @code{mpf_class} converted from a string using @code{mpf_set_str}
(@pxref{Assigning Floats}). If @var{prec} is given, the initial precision is
that value, in bits. If not, the default @code{mpf} precision
@@ -7015,11 +6633,6 @@ If the string is not a valid float, an @code{std::invalid_argument} exception
is thrown. The same applies to @code{operator=}.
@end deftypefun
-@deftypefun mpf_class operator"" _mpf (const char *@var{str})
-With C++11 compilers, floats can be constructed with the syntax
-@code{1.23e-1_mpf} which is equivalent to @code{mpf_class("1.23e-1")}.
-@end deftypefun
-
@deftypefun {mpf_class&} mpf_class::operator= (type @var{op})
Convert and store the given @var{op} value to an @code{mpf_class} object. The
same types are accepted as for the constructors above.
@@ -7070,9 +6683,6 @@ with the builtin float types.
@deftypefunx int mpf_class::set_str (const string& @var{str}, int @var{base})
@deftypefunx int sgn (mpf_class @var{op})
@deftypefunx mpf_class sqrt (mpf_class @var{op})
-@maybepagebreak
-@deftypefunx void mpf_class::swap (mpf_class& @var{op})
-@deftypefunx void swap (mpf_class& @var{op1}, mpf_class& @var{op2})
@deftypefunx mpf_class trunc (mpf_class @var{op})
These functions provide a C++ class interface to the corresponding GMP C
routines.
@@ -7083,9 +6693,9 @@ except @code{long long} and @code{long double}.
The accuracy provided by @code{hypot} is not currently guaranteed.
@end deftypefun
-@deftypefun {mp_bitcnt_t} mpf_class::get_prec ()
-@deftypefunx void mpf_class::set_prec (mp_bitcnt_t @var{prec})
-@deftypefunx void mpf_class::set_prec_raw (mp_bitcnt_t @var{prec})
+@deftypefun {unsigned long int} mpf_class::get_prec ()
+@deftypefunx void mpf_class::set_prec (unsigned long @var{prec})
+@deftypefunx void mpf_class::set_prec_raw (unsigned long @var{prec})
Get or set the current precision of an @code{mpf_class}.
The restrictions described for @code{mpf_set_prec_raw} (@pxref{Initializing
@@ -7134,7 +6744,7 @@ Seed a random number generator. See @pxref{Random Number Functions}, for how
to choose a good seed.
@end deftypefun
-@deftypefun mpz_class gmp_randclass::get_z_bits (mp_bitcnt_t @var{bits})
+@deftypefun mpz_class gmp_randclass::get_z_bits (unsigned long @var{bits})
@deftypefunx mpz_class gmp_randclass::get_z_bits (mpz_class @var{bits})
Generate a random integer with a specified number of bits.
@end deftypefun
@@ -7144,7 +6754,7 @@ Generate a random integer in the range 0 to @math{@var{n}-1} inclusive.
@end deftypefun
@deftypefun mpf_class gmp_randclass::get_f ()
-@deftypefunx mpf_class gmp_randclass::get_f (mp_bitcnt_t @var{prec})
+@deftypefunx mpf_class gmp_randclass::get_f (unsigned long @var{prec})
Generate a random float @var{f} in the range @math{0 <= @var{f} < 1}. @var{f}
will be to @var{prec} bits precision, or if @var{prec} is not given then to
the precision of the destination. For example,
@@ -7241,35 +6851,134 @@ void fun (T f, T g)
fun2 (f, T(f+g)); // Good
@}
@end example
+@end table
-@item C++11
-C++11 provides several new ways in which types can be inferred: @code{auto},
-@code{decltype}, etc. While they can be very convenient, they don't mix well
-with expression templates. In this example, the addition is performed twice,
-as if we had defined @code{sum} as a macro.
-@example
-mpz_class z = 33;
-auto sum = z + z;
-mpz_class prod = sum * sum;
-@end example
+@node BSD Compatible Functions, Custom Allocation, C++ Class Interface, Top
+@comment node-name, next, previous, up
+@chapter Berkeley MP Compatible Functions
+@cindex Berkeley MP compatible functions
+@cindex BSD MP compatible functions
-This other example may crash, though some compilers might make it look like
-it is working, because the expression @code{z+z} goes out of scope before it
-is evaluated.
+These functions are intended to be fully compatible with the Berkeley MP
+library which is available on many BSD derived U*ix systems. The
+@samp{--enable-mpbsd} option must be used when building GNU MP to make these
+available (@pxref{Installing GMP}).
-@example
-mpz_class z = 33;
-auto sum = z + z + z;
-mpz_class prod = sum * 2;
-@end example
+The original Berkeley MP library has a usage restriction: you cannot use the
+same variable as both source and destination in a single function call. The
+compatible functions in GNU MP do not share this restriction---inputs and
+outputs may overlap.
-It is thus strongly recommended to avoid @code{auto} anywhere a GMP C++
-expression may appear.
-@end table
+It is not recommended that new programs are written using these functions.
+Apart from the incomplete set of functions, the interface for initializing
+@code{MINT} objects is more error prone, and the @code{pow} function collides
+with @code{pow} in @file{libm.a}.
+
+@cindex @code{mp.h}
+@tindex MINT
+Include the header @file{mp.h} to get the definition of the necessary types and
+functions. If you are on a BSD derived system, make sure to include GNU
+@file{mp.h} if you are going to link the GNU @file{libmp.a} to your program.
+This means that you probably need to give the @samp{-I<dir>} option to the
+compiler, where @samp{<dir>} is the directory where you have GNU @file{mp.h}.
+
+@deftypefun {MINT *} itom (signed short int @var{initial_value})
+Allocate an integer consisting of a @code{MINT} object and dynamic limb space.
+Initialize the integer to @var{initial_value}. Return a pointer to the
+@code{MINT} object.
+@end deftypefun
+
+@deftypefun {MINT *} xtom (char *@var{initial_value})
+Allocate an integer consisting of a @code{MINT} object and dynamic limb space.
+Initialize the integer from @var{initial_value}, a hexadecimal,
+null-terminated C string. Return a pointer to the @code{MINT} object.
+@end deftypefun
+
+@deftypefun void move (MINT *@var{src}, MINT *@var{dest})
+Set @var{dest} to @var{src} by copying. Both variables must be previously
+initialized.
+@end deftypefun
+
+@deftypefun void madd (MINT *@var{src_1}, MINT *@var{src_2}, MINT *@var{destination})
+Add @var{src_1} and @var{src_2} and put the sum in @var{destination}.
+@end deftypefun
+
+@deftypefun void msub (MINT *@var{src_1}, MINT *@var{src_2}, MINT *@var{destination})
+Subtract @var{src_2} from @var{src_1} and put the difference in
+@var{destination}.
+@end deftypefun
+
+@deftypefun void mult (MINT *@var{src_1}, MINT *@var{src_2}, MINT *@var{destination})
+Multiply @var{src_1} and @var{src_2} and put the product in @var{destination}.
+@end deftypefun
+
+@deftypefun void mdiv (MINT *@var{dividend}, MINT *@var{divisor}, MINT *@var{quotient}, MINT *@var{remainder})
+@deftypefunx void sdiv (MINT *@var{dividend}, signed short int @var{divisor}, MINT *@var{quotient}, signed short int *@var{remainder})
+Set @var{quotient} to @var{dividend}/@var{divisor}, and @var{remainder} to
+@var{dividend} mod @var{divisor}. The quotient is rounded towards zero; the
+remainder has the same sign as the dividend unless it is zero.
+
+Some implementations of these functions work differently---or not at all---for
+negative arguments.
+@end deftypefun
+
+@deftypefun void msqrt (MINT *@var{op}, MINT *@var{root}, MINT *@var{remainder})
+Set @var{root} to @m{\lfloor\sqrt{@var{op}}\rfloor, the truncated integer part
+of the square root of @var{op}}, like @code{mpz_sqrt}. Set @var{remainder} to
+@m{(@var{op} - @var{root}^2), @var{op}@minus{}@var{root}*@var{root}}, i.e.
+zero if @var{op} is a perfect square.
+
+If @var{root} and @var{remainder} are the same variable, the results are
+undefined.
+@end deftypefun
+
+@deftypefun void pow (MINT *@var{base}, MINT *@var{exp}, MINT *@var{mod}, MINT *@var{dest})
+Set @var{dest} to (@var{base} raised to @var{exp}) modulo @var{mod}.
+
+Note that the name @code{pow} clashes with @code{pow} from the standard C math
+library (@pxref{Exponents and Logarithms,, Exponentiation and Logarithms,
+libc, The GNU C Library Reference Manual}). An application will only be able
+to use one or the other.
+@end deftypefun
+
+@deftypefun void rpow (MINT *@var{base}, signed short int @var{exp}, MINT *@var{dest})
+Set @var{dest} to @var{base} raised to @var{exp}.
+@end deftypefun
+@deftypefun void gcd (MINT *@var{op1}, MINT *@var{op2}, MINT *@var{res})
+Set @var{res} to the greatest common divisor of @var{op1} and @var{op2}.
+@end deftypefun
-@node Custom Allocation, Language Bindings, C++ Class Interface, Top
+@deftypefun int mcmp (MINT *@var{op1}, MINT *@var{op2})
+Compare @var{op1} and @var{op2}. Return a positive value if @var{op1} >
+@var{op2}, zero if @var{op1} = @var{op2}, and a negative value if @var{op1} <
+@var{op2}.
+@end deftypefun
+
+@deftypefun void min (MINT *@var{dest})
+Input a decimal string from @code{stdin}, and put the read integer in
+@var{dest}. SPC and TAB are allowed in the number string, and are ignored.
+@end deftypefun
+
+@deftypefun void mout (MINT *@var{src})
+Output @var{src} to @code{stdout}, as a decimal string. Also output a newline.
+@end deftypefun
+
+@deftypefun {char *} mtox (MINT *@var{op})
+Convert @var{op} to a hexadecimal string, and return a pointer to the string.
+The returned string is allocated using the default memory allocation function,
+@code{malloc} by default. It will be @code{strlen(str)+1} bytes, that being
+exactly enough for the string and null-terminator.
+@end deftypefun
+
+@deftypefun void mfree (MINT *@var{op})
+De-allocate, the space used by @var{op}. @strong{This function should only be
+passed a value returned by @code{itom} or @code{xtom}.}
+@end deftypefun
+
+
+@node Custom Allocation, Language Bindings, BSD Compatible Functions, Top
@comment node-name, next, previous, up
@chapter Custom Allocation
@cindex Custom allocation
@@ -7283,6 +6992,9 @@ and terminates the program.
Alternate functions can be specified, to allocate memory in a different way or
to have a different error action on running out of memory.
+This feature is available in the Berkeley compatibility library (@pxref{BSD
+Compatible Functions}) as well as the main GMP library.
+
@deftypefun void mp_set_memory_functions (@* void *(*@var{alloc_func_ptr}) (size_t), @* void *(*@var{realloc_func_ptr}) (void *, size_t, size_t), @* void (*@var{free_func_ptr}) (void *, size_t))
Replace the current allocation functions from the arguments. If an argument
is @code{NULL}, the corresponding default function is used.
@@ -7325,10 +7037,10 @@ De-allocate the space pointed to by @var{ptr}.
A @dfn{byte} here means the unit used by the @code{sizeof} operator.
-The @var{reallocate_function} parameter @var{old_size} and the
-@var{free_function} parameter @var{size} are passed for convenience, but of
-course they can be ignored if not needed by an implementation. The default
-functions using @code{malloc} and friends for instance don't use them.
+The @var{old_size} parameters to @var{reallocate_function} and
+@var{free_function} are passed for convenience, but of course can be ignored
+if not needed. The default functions using @code{malloc} and friends for
+instance don't use them.
No error return is allowed from any of these functions, if they return then
they must have performed the specified operation. In particular note that
@@ -7398,14 +7110,17 @@ than C, though perhaps with varying levels of functionality and efficiency.
GMP C++ class interface, @pxref{C++ Class Interface} @* Straightforward
interface, expression templates to eliminate temporaries.
@item
-ALP @spaceuref{https://www-sop.inria.fr/saga/logiciels/ALP/} @* Linear algebra and
+ALP @spaceuref{http://www-sop.inria.fr/saga/logiciels/ALP/} @* Linear algebra and
polynomials using templates.
@item
-Arithmos @spaceuref{http://cant.ua.ac.be/old/arithmos/} @* Rationals
+Arithmos @spaceuref{http://www.win.ua.ac.be/~cant/arithmos/} @* Rationals
with infinities and square roots.
@item
CLN @spaceuref{http://www.ginac.de/CLN/} @* High level classes for arithmetic.
@item
+LiDIA @spaceuref{http://www.cdc.informatik.tu-darmstadt.de/TI/LiDIA/} @* A C++
+library for computational number theory.
+@item
Linbox @spaceuref{http://www.linalg.org/} @* Sparse vectors and matrices.
@item
NTL @spaceuref{http://www.shoup.net/ntl/} @* A C++ number theory library.
@@ -7417,35 +7132,31 @@ NTL @spaceuref{http://www.shoup.net/ntl/} @* A C++ number theory library.
@c gmp-d @spaceuref{http://home.comcast.net/~benhinkle/gmp-d/}
@c @end itemize
-@item Eiffel
+@item Fortran
@itemize @bullet
@item
-Eiffelroom @spaceuref{http://www.eiffelroom.org/node/442}
+Omni F77 @spaceuref{http://phase.hpcc.jp/Omni/home.html} @* Arbitrary
+precision floats.
@end itemize
-@c @item Fortran
-@c @itemize @bullet
-@c @item
-@c Omni F77 @spaceuref{http://phase.hpcc.jp/Omni/home.html} @* Arbitrary
-@c precision floats.
-@c @end itemize
-
@item Haskell
@itemize @bullet
@item
-Glasgow Haskell Compiler @spaceuref{https://www.haskell.org/ghc/}
+Glasgow Haskell Compiler @spaceuref{http://www.haskell.org/ghc/}
@end itemize
@item Java
@itemize @bullet
@item
-Kaffe @spaceuref{https://github.com/kaffe/kaffe}
+Kaffe @spaceuref{http://www.kaffe.org/}
+@item
+Kissme @spaceuref{http://kissme.sourceforge.net/}
@end itemize
@item Lisp
@itemize @bullet
@item
-GNU Common Lisp @spaceuref{https://www.gnu.org/software/gcl/gcl.html}
+GNU Common Lisp @spaceuref{http://www.gnu.org/software/gcl/gcl.html}
@item
Librep @spaceuref{http://librep.sourceforge.net/}
@item
@@ -7473,7 +7184,7 @@ MLton compiler @spaceuref{http://mlton.org/}
@item Objective Caml
@itemize @bullet
@item
-MLGMP @spaceuref{http://opam.ocamlpro.com/pkg/mlgmp.20120224.html}
+MLGMP @spaceuref{http://www.di.ens.fr/~monniaux/programmes.html.en}
@item
Numerix @spaceuref{http://pauillac.inria.fr/~quercia/} @* Optionally using
GMP.
@@ -7482,7 +7193,7 @@ GMP.
@item Oz
@itemize @bullet
@item
-Mozart @spaceuref{http://mozart.github.io/}
+Mozart @spaceuref{http://www.mozart-oz.org/}
@end itemize
@item Pascal
@@ -7525,23 +7236,19 @@ Arbitrary precision floats.
@item Python
@itemize @bullet
@item
-GMPY @uref{https://code.google.com/p/gmpy/}
-@end itemize
-
-@item Ruby
-@itemize @bullet
+mpz module in the standard distribution, @uref{http://www.python.org/}
@item
-http://rubygems.org/gems/gmp
+GMPY @uref{http://gmpy.sourceforge.net/}
@end itemize
@item Scheme
@itemize @bullet
@item
-GNU Guile @spaceuref{https://www.gnu.org/software/guile/guile.html}
+GNU Guile (upcoming 1.8) @spaceuref{http://www.gnu.org/software/guile/guile.html}
@item
RScheme @spaceuref{http://www.rscheme.org/}
@item
-STklos @spaceuref{http://www.stklos.net/}
+STklos @spaceuref{http://www.stklos.org/}
@c
@c For reference, MzScheme uses some of gmp, but (as of version 205) it only
@c has copies of some of the generic C code, and we don't consider that a
@@ -7558,7 +7265,7 @@ GNU Smalltalk @spaceuref{http://www.smalltalk.org/versions/GNUSmalltalk.html}
@item Other
@itemize @bullet
@item
-Axiom @uref{https://savannah.nongnu.org/projects/axiom} @* Computer algebra
+Axiom @uref{http://savannah.nongnu.org/projects/axiom} @* Computer algebra
using GCL.
@item
DrGenius @spaceuref{http://drgenius.seul.org/} @* Geometry system and
@@ -7566,17 +7273,18 @@ mathematical programming language.
@item
GiNaC @spaceuref{http://www.ginac.de/} @* C++ computer algebra using CLN.
@item
-GOO @spaceuref{https://www.eecs.berkeley.edu/~jrb/goo/} @* Dynamic object oriented
+GOO @spaceuref{http://www.googoogaga.org/} @* Dynamic object oriented
language.
@item
-Maxima @uref{https://www.ma.utexas.edu/users/wfs/maxima.html} @* Macsyma
+Maxima @uref{http://www.ma.utexas.edu/users/wfs/maxima.html} @* Macsyma
computer algebra using GCL.
-@c @item
-@c Q @spaceuref{http://q-lang.sourceforge.net/} @* Equational programming system.
+@item
+Q @spaceuref{http://q-lang.sourceforge.net/} @* Equational programming system.
@item
Regina @spaceuref{http://regina.sourceforge.net/} @* Topological calculator.
@item
-Yacas @spaceuref{http://yacas.sourceforge.net} @* Yet another computer algebra system.
+Yacas @spaceuref{http://www.xs4all.nl/~apinkus/yacas.html} @* Yet another
+computer algebra system.
@end itemize
@end table
@@ -7610,18 +7318,16 @@ documented functions.
@section Multiplication
@cindex Multiplication algorithms
-N@cross{}N limb multiplications and squares are done using one of seven
+N@cross{}N limb multiplications and squares are done using one of five
algorithms, as the size N increases.
@quotation
@multitable {KaratsubaMMM} {MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM}
@item Algorithm @tab Threshold
@item Basecase @tab (none)
-@item Karatsuba @tab @code{MUL_TOOM22_THRESHOLD}
+@item Karatsuba @tab @code{MUL_KARATSUBA_THRESHOLD}
@item Toom-3 @tab @code{MUL_TOOM33_THRESHOLD}
@item Toom-4 @tab @code{MUL_TOOM44_THRESHOLD}
-@item Toom-6.5 @tab @code{MUL_TOOM6H_THRESHOLD}
-@item Toom-8.5 @tab @code{MUL_TOOM8H_THRESHOLD}
@item FFT @tab @code{MUL_FFT_THRESHOLD}
@end multitable
@end quotation
@@ -7629,7 +7335,7 @@ algorithms, as the size N increases.
Similarly for squaring, with the @code{SQR} thresholds.
N@cross{}M multiplications of operands with different sizes above
-@code{MUL_TOOM22_THRESHOLD} are currently done by special Toom-inspired
+@code{MUL_KARATSUBA_THRESHOLD} are currently done by special Toom-inspired
algorithms or directly with FFT, depending on operand size (@pxref{Unbalanced
Multiplication}).
@@ -7638,7 +7344,6 @@ Multiplication}).
* Karatsuba Multiplication::
* Toom 3-Way Multiplication::
* Toom 4-Way Multiplication::
-* Higher degree Toom'n'half::
* FFT Multiplication::
* Other Multiplication::
* Unbalanced Multiplication::
@@ -7781,7 +7486,7 @@ equal length (or the most significant part one limb shorter if N is odd).
@end example
@end ifnottex
-Let @math{b} be the power of 2 where the split occurs, i.e.@: if @ms{x,0} is
+Let @math{b} be the power of 2 where the split occurs, ie.@: if @ms{x,0} is
@math{k} limbs (@ms{y,0} the same) then
@m{b=2\GMPraise{$k*$@code{mp\_bits\_per\_limb}}, b=2^(k*mp_bits_per_limb)}.
With that @m{x=x_1b+x_0,x=x1*b+x0} and @m{y=y_1b+y_0,y=y1*b+y0}, and the
@@ -7879,7 +7584,7 @@ Karatsuba multiplication is asymptotically an @math{O(N^@W{1.585})} algorithm,
the exponent being @m{\log3/\log2,log(3)/log(2)}, representing 3 multiplies
each @math{1/2} the size of the inputs. This is a big improvement over the
basecase multiply at @math{O(N^2)} and the advantage soon overcomes the extra
-additions Karatsuba performs. @code{MUL_TOOM22_THRESHOLD} can be as little
+additions Karatsuba performs. @code{MUL_KARATSUBA_THRESHOLD} can be as little
as 10 limbs. The @code{SQR} threshold is usually about twice the @code{MUL}.
The basecase algorithm will take a time of the form @m{M(N) = aN^2 + bN + c,
@@ -7960,7 +7665,7 @@ These parts are treated as the coefficients of two polynomials
@end display
Let @math{b} equal the power of 2 which is the size of the @ms{x,0}, @ms{x,1},
-@ms{y,0} and @ms{y,1} pieces, i.e.@: if they're @math{k} limbs each then
+@ms{y,0} and @ms{y,1} pieces, ie.@: if they're @math{k} limbs each then
@m{b=2\GMPraise{$k*$@code{mp\_bits\_per\_limb}}, b=2^(k*mp_bits_per_limb)}.
With this @math{x=X(b)} and @math{y=Y(b)}.
@@ -8095,7 +7800,7 @@ the @m{w_i,w[i]}.
Squaring follows the same procedure as multiplication, but there's only one
@math{X(t)} and it's evaluated at the 5 points, and those values squared to
give values of @math{W(t)}. The interpolation is then identical, and in fact
-the same @code{toom_interpolate_5pts} subroutine is used for both squaring and
+the same @code{toom3_interpolate} subroutine is used for both squaring and
multiplying.
Toom-3 is asymptotically @math{O(N^@W{1.465})}, the exponent being
@@ -8133,7 +7838,7 @@ and for example with a bit of rearrangement just one division by 6 can be
done.
-@node Toom 4-Way Multiplication, Higher degree Toom'n'half, Toom 3-Way Multiplication, Multiplication Algorithms
+@node Toom 4-Way Multiplication, FFT Multiplication, Toom 3-Way Multiplication, Multiplication Algorithms
@subsection Toom 4-Way Multiplication
@cindex Toom multiplication
@@ -8176,32 +7881,7 @@ Toom-4 is asymptotically @math{O(N^@W{1.404})}, the exponent being
original size each.
-@node Higher degree Toom'n'half, FFT Multiplication, Toom 4-Way Multiplication, Multiplication Algorithms
-@subsection Higher degree Toom'n'half
-@cindex Toom multiplication
-
-The Toom algorithms described above (@pxref{Toom 3-Way Multiplication},
-@pxref{Toom 4-Way Multiplication}) generalizes to split into an arbitrary
-number of pieces. In general a split of two equally long operands into
-@math{r} pieces leads to evaluations and pointwise multiplications done at
-@m{2r-1,2*r-1} points. To fully exploit symmetries it would be better to have
-a multiple of 4 points, that's why for higher degree Toom'n'half is used.
-
-Toom'n'half means that the existence of one more piece is considered for a
-single operand. It can be virtual, i.e. zero, or real, when the two operand
-are not exactly balanced. By choosing an even @math{r},
-Toom-@m{r{1\over2},r+1/2} requires @math{2r} points, a multiple of four.
-
-The four-plets of points include 0, @m{\infty,inf}, +1, -1 and
-@m{\pm2^i,+-2^i}, @m{\pm2^{-i},+-2^-i} . Each of them giving shortcuts for the
-evaluation phase and for some steps in the interpolation phase. Further tricks
-are used to reduce the memory footprint of the whole multiplication algorithm
-to a memory buffer equanl in size to the result of the product.
-
-Current GMP uses both Toom-6'n'half and Toom-8'n'half.
-
-
-@node FFT Multiplication, Other Multiplication, Higher degree Toom'n'half, Multiplication Algorithms
+@node FFT Multiplication, Other Multiplication, Toom 4-Way Multiplication, Multiplication Algorithms
@subsection FFT Multiplication
@cindex FFT multiplication
@cindex Fast Fourier Transform
@@ -8250,13 +7930,13 @@ The points used for the evaluation are @math{g^i} for @math{i=0} to
@math{2^k-1} where @m{g=2^{2N'/2^k}, g=2^(2N'/2^k)}. @math{g} is a
@m{2^k,2^k'}th root of unity mod @m{2^{N'}+1,2^N'+1}, which produces necessary
cancellations at the interpolation stage, and it's also a power of 2 so the
-fast Fourier transforms used for the evaluation and interpolation do only
+fast fourier transforms used for the evaluation and interpolation do only
shifts, adds and negations.
The pointwise multiplications are done modulo @m{2^{N'}+1, 2^N'+1} and either
recurse into a further FFT or use a plain multiplication (Toom-3, Karatsuba or
basecase), whichever is optimal at the size @math{N'}. The interpolation is
-an inverse fast Fourier transform. The resulting set of sums of @m{x_iy_j,
+an inverse fast fourier transform. The resulting set of sums of @m{x_iy_j,
x[i]*y[j]} are added at appropriate offsets to give the final result.
Squaring is the same, but @math{x} is the only input so it's one transform at
@@ -8328,7 +8008,7 @@ currently used. The notes here are merely for interest.
In general a split into @math{r+1} pieces is made, and evaluations and
pointwise multiplications done at @m{2r+1,2*r+1} points. A 4-way split does 7
pointwise multiplies, 5-way does 9, etc. Asymptotically an @math{(r+1)}-way
-algorithm is @m{O(N^{log(2r+1)/log(r+1)}), O(N^(log(2*r+1)/log(r+1)))}. Only
+algorithm is @m{O(N^{log(2r+1)/log(r+1)}, O(N^(log(2*r+1)/log(r+1)))}. Only
the pointwise multiplications count towards big-@math{O} complexity, but the
time spent in the evaluate and interpolate stages grows with @math{r} and has
a significant practical impact, with the asymptotic advantage of each @math{r}
@@ -8348,10 +8028,10 @@ Splitting odd and even parts through positive and negative points can be
thought of as using @math{-1} as a square root of unity. If a 4th root of
unity was available then a further split and speedup would be possible, but no
such root exists for plain integers. Going to complex integers with
-@m{i=\sqrt{-1}, i=sqrt(-1)} doesn't help, essentially because in Cartesian
+@m{i=\sqrt{-1}, i=sqrt(-1)} doesn't help, essentially because in cartesian
form it takes three real multiplies to do a complex multiply. The existence
of @m{2^k,2^k'}th roots of unity in a suitable ring or field lets the fast
-Fourier transform keep splitting and get to @m{O(N \log r), O(N*log(r))}.
+fourier transform keep splitting and get to @m{O(N \log r), O(N*log(r))}.
Floating point FFTs use complex numbers approximating Nth roots of unity.
Some processors have special support for such FFTs. But these are not used in
@@ -8366,7 +8046,7 @@ GMP.
@cindex Unbalanced multiplication
Multiplication of operands with different sizes, both below
-@code{MUL_TOOM22_THRESHOLD} are done with plain schoolbook multiplication
+@code{MUL_KARATSUBA_THRESHOLD} are done with plain schoolbook multiplication
(@pxref{Basecase Multiplication}).
For really large operands, we invoke FFT directly.
@@ -8391,7 +8071,6 @@ can be split into 2, 3, or 4 coefficients, i.e., a polynomial of degree 1 to
* Single Limb Division::
* Basecase Division::
* Divide and Conquer Division::
-* Block-Wise Barrett Division::
* Exact Division::
* Exact Remainder::
* Small Quotient Division::
@@ -8472,10 +8151,10 @@ Q@cross{}M multiplication, differing in fact only in the extra multiply and
divide for each of the Q quotient limbs.
-@node Divide and Conquer Division, Block-Wise Barrett Division, Basecase Division, Division Algorithms
+@node Divide and Conquer Division, Exact Division, Basecase Division, Division Algorithms
@subsection Divide and Conquer Division
-For divisors larger than @code{DC_DIV_QR_THRESHOLD}, division is done by dividing.
+For divisors larger than @code{DIV_DC_THRESHOLD}, division is done by dividing.
Or to be precise by a recursive divide and conquer algorithm based on work by
Moenck and Borodin, Jebelean, and Burnikel and Ziegler (@pxref{References}).
@@ -8491,11 +8170,11 @@ If the (N/2)@cross{}(N/2) multiplies are done with a basecase multiplication
then the work is about the same as a basecase division, but with more function
call overheads and with some subtractions separated from the multiplies.
These overheads mean that it's only when N/2 is above
-@code{MUL_TOOM22_THRESHOLD} that divide and conquer is of use.
+@code{MUL_KARATSUBA_THRESHOLD} that divide and conquer is of use.
-@code{DC_DIV_QR_THRESHOLD} is based on the divisor size N, so it will be somewhere
-above twice @code{MUL_TOOM22_THRESHOLD}, but how much above depends on the
-CPU@. An optimized @code{mpn_mul_basecase} can lower @code{DC_DIV_QR_THRESHOLD} a
+@code{DIV_DC_THRESHOLD} is based on the divisor size N, so it will be somewhere
+above twice @code{MUL_KARATSUBA_THRESHOLD}, but how much above depends on the
+CPU@. An optimized @code{mpn_mul_basecase} can lower @code{DIV_DC_THRESHOLD} a
little by offering a ready-made advantage over repeated @code{mpn_submul_1}
calls.
@@ -8508,24 +8187,14 @@ algorithms the @math{M(N)} term improves and the multiplier tends to @m{\log
N, log(N)}. In practice, at moderate to large sizes, a 2N@cross{}N division
is about 2 to 4 times slower than an N@cross{}N multiplication.
+Newton's method used for division is asymptotically @math{O(M(N))} and should
+therefore be superior to divide and conquer, but it's believed this would only
+be for large to very large N.
-@node Block-Wise Barrett Division, Exact Division, Divide and Conquer Division, Division Algorithms
-@subsection Block-Wise Barrett Division
-
-For the largest divisions, a block-wise Barrett division algorithm is used.
-Here, the divisor is inverted to a precision determined by the relative size of
-the dividend and divisor. Blocks of quotient limbs are then generated by
-multiplying blocks from the dividend by the inverse.
-
-Our block-wise algorithm computes a smaller inverse than in the plain Barrett
-algorithm. For a @math{2n/n} division, the inverse will be just @m{\lceil n/2
-\rceil, ceil(n/2)} limbs.
-
-@node Exact Division, Exact Remainder, Block-Wise Barrett Division, Division Algorithms
+@node Exact Division, Exact Remainder, Divide and Conquer Division, Division Algorithms
@subsection Exact Division
-
A so-called exact division is when the dividend is known to be an exact
multiple of the divisor. Jebelean's exact division algorithm uses this
knowledge to make some significant optimizations (@pxref{References}).
@@ -8561,7 +8230,7 @@ Q*(Q-1)/2}. Notice the savings are complementary. If Q is big then many
divisions are saved, or if Q is small then the crossproducts reduce to a small
number.
-The modular inverse used is calculated efficiently by @code{binvert_limb} in
+The modular inverse used is calculated efficiently by @code{modlimb_invert} in
@file{gmp-impl.h}. This does four multiplies for a 32-bit limb, or six for a
64-bit limb. @file{tune/modlinv.c} has some alternate implementations that
might suit processors better at bit twiddling than multiplying.
@@ -8614,10 +8283,10 @@ products must be done as a normal division, but there's still some single limb
divisions saved. When @math{d} is a single limb some simplifications arise,
providing good speedups on a number of processors.
-The functions @code{mpn_divexact_by3}, @code{mpn_modexact_1_odd} and the
-internal @code{mpn_redc_X} functions differ subtly in how they return @math{r},
-leading to some negations in the above formula, but all are essentially the
-same.
+@code{mpn_bdivmod}, @code{mpn_divexact_by3}, @code{mpn_modexact_1_odd} and the
+@code{redc} function in @code{mpz_powm} differ subtly in how they return
+@math{r}, leading to some negations in the above formula, but all are
+essentially the same.
@cindex Divisibility algorithm
@cindex Congruence algorithm
@@ -8626,8 +8295,9 @@ leads to divisibility or congruence tests which are potentially more efficient
than a normal division.
The factor of @math{b^n} on @math{r} can be ignored in a GCD when @math{d} is
-odd, hence the use of @code{mpn_modexact_1_odd} by @code{mpn_gcd_1} and
-@code{mpz_kronecker_ui} etc (@pxref{Greatest Common Divisor Algorithms}).
+odd, hence the use of @code{mpn_bdivmod} in @code{mpn_gcd}, and the use of
+@code{mpn_modexact_1_odd} by @code{mpn_gcd_1} and @code{mpz_kronecker_ui} etc
+(@pxref{Greatest Common Divisor Algorithms}).
Montgomery's REDC method for modular multiplications uses operands of the form
of @m{xb^{-n}, x*b^-n} and @m{yb^{-n}, y*b^-n} and on calculating @m{(xb^{-n})
@@ -8764,7 +8434,7 @@ single-limb elements. This is done by the function @code{mpn_hgcd2}. The
resulting matrix is applied to the inputs using @code{mpn_mul_1} and
@code{mpn_submul_1}. Each iteration usually reduces the inputs by almost one
limb. In the rare case of a large quotient, no progress can be made by
-examining just the most significant two limbs, and the quotient is computed
+examining just the most significant two limbs, and the quotient is computing
using plain division.
The resulting algorithm is asymptotically @math{O(N^2)}, just as the Euclidean
@@ -8881,9 +8551,6 @@ current size of the cofactors.
@subsection Jacobi Symbol
@cindex Jacobi symbol algorithm
-[This section is obsolete. The current Jacobi code actually uses a very
-efficient algorithm.]
-
@code{mpz_jacobi} and @code{mpz_kronecker} are currently implemented with a
simple binary algorithm similar to that described for the GCDs (@pxref{Binary
GCD}). They're not very fast when both inputs are large. Lehmer's multi-step
@@ -8930,10 +8597,14 @@ exponent. Larger exponents use larger values of @math{k}, the choice being
made to minimize the average number of multiplications that must supplement
the squaring.
-The modular multiplies and squarings use either a simple division or the REDC
+The modular multiplies and squares use either a simple division or the REDC
method by Montgomery (@pxref{References}). REDC is a little faster,
essentially saving N single limb divisions in a fashion similar to an exact
-remainder (@pxref{Exact Remainder}).
+remainder (@pxref{Exact Remainder}). The current REDC has some limitations.
+It's only @math{O(N^2)} so above @code{POWM_THRESHOLD} division becomes faster
+and is used. It doesn't attempt to detect small bases, but rather always uses
+a REDC form, which is usually a full size operand. And lastly it's only
+applied to odd moduli.
@node Root Extraction Algorithms, Radix Conversion Algorithms, Powering Algorithms, Algorithms
@@ -9092,7 +8763,7 @@ to save operations, so long as the lookup tables don't become too big.
A square root must still be taken for any value that passes these tests, to
verify it's really a square and not one of the small fraction of non-squares
-that get through (i.e.@: a pseudo-square to all the tested bases).
+that get through (ie.@: a pseudo-square to all the tested bases).
Clearly more residue tests could be done, @code{mpz_perfect_square_p} only
uses a compact and efficient set. Big inputs would probably benefit from more
@@ -9194,7 +8865,7 @@ calculating a bigger radix power.
Another possible improvement for the sub-quadratic part would be to arrange
for radix powers that balanced the sizes of quotient and remainder produced,
-i.e.@: the highest power would be an @m{b^{nk},b^(n*k)} approximately equal to
+ie.@: the highest power would be an @m{b^{nk},b^(n*k)} approximately equal to
@m{\sqrt{t},sqrt(t)}, not restricted to a @math{2^i} factor. That ought to
smooth out a graph of times against sizes, but may or may not be a net
speedup.
@@ -9285,75 +8956,42 @@ for an arbitrary @math{n}.
@subsection Factorial
@cindex Factorial algorithm
-Factorials are calculated by a combination of two algorithms. An idea is
-shared among them: to compute the odd part of the factorial; a final step
-takes account of the power of @math{2} term, by shifting.
-
-For small @math{n}, the odd factor of @math{n!} is computed with the simple
-observation that it is equal to the product of all positive odd numbers
-smaller than @math{n} times the odd factor of @m{\lfloor n/2\rfloor!, [n/2]!},
-where @m{\lfloor x\rfloor, [x]} is the integer part of @math{x}, and so on
-recursively. The procedure can be best illustrated with an example,
+Factorials are calculated by a combination of removal of twos, powering, and
+binary splitting. The procedure can be best illustrated with an example,
@quotation
-@math{23! = (23.21.19.17.15.13.11.9.7.5.3)(11.9.7.5.3)(5.3)2^{19}}
+@math{23! = 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23}
@end quotation
-Current code collects all the factors in a single list, with a loop and no
-recursion, and compute the product, with no special care for repeated chunks.
-
-When @math{n} is larger, computation pass trough prime sieving. An helper
-function is used, as suggested by Peter Luschny:
-@tex
-$$\mathop{\rm msf}(n) = {n!\over\lfloor n/2\rfloor!^2\cdot2^k} = \prod_{p=3}^{n}
-p^{\mathop{\rm L}(p,n)} $$
-@end tex
-@ifnottex
-
-@example
- n
- -----
- n! | | L(p,n)
-msf(n) = -------------- = | | p
- [n/2]!^2.2^k p=3
-@end example
-@end ifnottex
+@noindent
+has factors of two removed,
-Where @math{p} ranges on odd prime numbers. The exponent @math{k} is chosen to
-obtain an odd integer number: @math{k} is the number of 1 bits in the binary
-representation of @m{\lfloor n/2\rfloor, [n/2]}. The function L@math{(p,n)}
-can be defined as zero when @math{p} is composite, and, for any prime
-@math{p}, it is computed with:
-@tex
-$$\mathop{\rm L}(p,n) = \sum_{i>0}\left\lfloor{n\over p^i}\right\rfloor\bmod2
-\leq\log_p(n)$$
-@end tex
-@ifnottex
+@quotation
+@math{23! = 2^{19}.1.1.3.1.5.3.7.1.9.5.11.3.13.7.15.1.17.9.19.5.21.11.23}
+@end quotation
-@example
- ---
- \ n
-L(p,n) = / [---] mod 2 <= log (n) .
- --- p^i p
- i>0
-@end example
-@end ifnottex
+@noindent
+and the resulting terms collected up according to their multiplicity,
-With this helper function, we are able to compute the odd part of @math{n!}
-using the recursion implied by @m{n!=\lfloor n/2\rfloor!^2\cdot\mathop{\rm
-msf}(n)\cdot2^k , n!=[n/2]!^2*msf(n)*2^k}. The recursion stops using the
-small-@math{n} algorithm on some @m{\lfloor n/2^i\rfloor, [n/2^i]}.
+@quotation
+@math{23! = 2^{19}.(3.5)^3.(7.9.11)^2.(13.15.17.19.21.23)}
+@end quotation
-Both the above algorithms use binary splitting to compute the product of many
-small factors. At first as many products as possible are accumulated in a
-single register, generating a list of factors that fit in a machine word. This
-list is then split into halves, and the product is computed recursively.
+Each sequence such as @math{13.15.17.19.21.23} is evaluated by splitting into
+every second term, as for instance @math{(13.17.21).(15.19.23)}, and the same
+recursively on each half. This is implemented iteratively using some bit
+twiddling.
Such splitting is more efficient than repeated N@cross{}1 multiplies since it
forms big multiplies, allowing Karatsuba and higher algorithms to be used.
And even below the Karatsuba threshold a big block of work can be more
efficient for the basecase algorithm.
+Splitting into subsequences of every second term keeps the resulting products
+more nearly equal in size than would the simpler approach of say taking the
+first half and second half of the sequence. Nearly equal products are more
+efficient for the current multiply implementation.
+
@node Binomial Coefficients Algorithm, Fibonacci Numbers Algorithm, Factorial Algorithm, Other Algorithms
@subsection Binomial Coefficients
@@ -9533,7 +9171,7 @@ are also very good and this is the default algorithm used by GMP.
@cindex Linear congruential algorithm
Linear congruential generators are described in many text books, for instance
Knuth volume 2 (@pxref{References}). With a modulus @math{M} and parameters
-@math{A} and @math{C}, an integer state @math{S} is iterated by the formula
+@math{A} and @math{C}, a integer state @math{S} is iterated by the formula
@math{S @leftarrow{} A@GMPmultiply{}S+C @bmod{} M}. At each step the new
state is a linear function of the previous, mod @math{M}, hence the name of
the generator.
@@ -10480,10 +10118,7 @@ evaluating it,
@example
struct __gmp_binary_plus
@{
- static void eval(mpf_t f, const mpf_t g, const mpf_t h)
- @{
- mpf_add(f, g, h);
- @}
+ static void eval(mpf_t f, mpf_t g, mpf_t h) @{ mpf_add(f, g, h); @}
@};
@end example
@@ -10516,7 +10151,7 @@ mpf_class & mpf_class::operator=(const __gmp_expr<T> &expr)
template <class Op>
void __gmp_expr<__gmp_binary_expr<mpf_class, mpf_class, Op> >::eval
-(mpf_t f, mp_bitcnt_t precision)
+(mpf_t f, unsigned long int precision)
@{
Op::eval(f, expr.val1.get_mpf_t(), expr.val2.get_mpf_t());
@}
@@ -10552,7 +10187,7 @@ And the corresponding specializations of @code{__gmp_expr::eval}:
template <class T, class U, class Op>
void __gmp_expr
<__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, Op> >::eval
-(mpf_t f, mp_bitcnt_t precision)
+(mpf_t f, unsigned long int precision)
@{
// declare two temporaries
mpf_class temp1(expr.val1, precision), temp2(expr.val2, precision);
@@ -10594,9 +10229,8 @@ was a driving force behind many of the optimizations in GMP 3. Paul also
wrote the new GMP 4.3 nth root code (with Torbj@"orn).
Ken Weber (Kent State University, Universidade Federal do Rio Grande do Sul)
-contributed now defunct versions of @code{mpz_gcd}, @code{mpz_divexact},
-@code{mpn_gcd}, and @code{mpn_bdivmod}, partially supported by CNPq (Brazil)
-grant 301314194-2.
+contributed @code{mpz_gcd}, @code{mpz_divexact}, @code{mpn_gcd}, and
+@code{mpn_bdivmod}, partially supported by CNPq (Brazil) grant 301314194-2.
Per Bothner of Cygnus Support helped to set up GMP to use Cygnus' configure.
He has also made valuable suggestions and tested numerous intermediary
@@ -10642,46 +10276,19 @@ Jason Moxham rewrote @code{mpz_fac_ui}.
Pedro Gimeno implemented the Mersenne Twister and made other random number
improvements.
-Niels M@"oller wrote the sub-quadratic GCD, extended GCD and jacobi code, the
+Niels M@"oller wrote the sub-quadratic GCD and extended GCD code, the
quadratic Hensel division code, and (with Torbj@"orn) the new divide and
conquer division code for GMP 4.3. Niels also helped implement the new Toom
-multiply code for GMP 4.3 and implemented helper functions to simplify Toom
-evaluations for GMP 5.0. He wrote the original version of mpn_mulmod_bnm1, and
-he is the main author of the mini-gmp package used for gmp bootstrapping.
+multiply code for GMP 4.3.
Alberto Zanoni and Marco Bodrato suggested the unbalanced multiply strategy,
and found the optimal strategies for evaluation and interpolation in Toom
-multiplication.
-
-Marco Bodrato helped implement the new Toom multiply code for GMP 4.3 and
-implemented most of the new Toom multiply and squaring code for 5.0.
-He is the main author of the current mpn_mulmod_bnm1 and mpn_mullo_n. Marco
-also wrote the functions mpn_invert and mpn_invertappr. He is the author of
-the current combinatorial functions: binomial, factorial, multifactorial,
-primorial.
+multiplication. Marco also helped implement the new Toom multiply code for
+GMP 4.3.
David Harvey suggested the internal function @code{mpn_bdiv_dbm1}, implementing
division relevant to Toom multiplication. He also worked on fast assembly
-sequences, in particular on a fast AMD64 @code{mpn_mul_basecase}. He wrote
-the internal middle product functions @code{mpn_mulmid_basecase},
-@code{mpn_toom42_mulmid}, @code{mpn_mulmid_n} and related helper routines.
-
-Martin Boij wrote @code{mpn_perfect_power_p}.
-
-Marc Glisse improved @file{gmpxx.h}: use fewer temporaries (faster),
-specializations of @code{numeric_limits} and @code{common_type}, C++11
-features (move constructors, explicit bool conversion, UDL), make the
-conversion from @code{mpq_class} to @code{mpz_class} explicit, optimize
-operations where one argument is a small compile-time constant, replace
-some heap allocations by stack allocations. He also fixed the eofbit
-handling of C++ streams, and removed one division from @file{mpq/aors.c}.
-
-David S Miller wrote assembly code for SPARC T3 and T4.
-
-Mark Sofroniou cleaned up the types of mul_fft.c, letting it work for huge
-operands.
-
-Ulrich Weigand ported GMP to the powerpc64le ABI.
+sequences, in particular on a fast AMD64 @code{mpn_mul_basecase}.
(This list is chronological, not ordered after significance. If you have
contributed to GMP but are not listed above, please tell
@@ -10691,11 +10298,8 @@ The development of floating point functions of GNU MP 2, were supported in part
by the ESPRIT-BRA (Basic Research Activities) 6846 project POSSO (POlynomial
System SOlving).
-The development of GMP 2, 3, and 4.0 was supported in part by the IDA Center
-for Computing Sciences.
-
-The development of GMP 4.3, 5.0, and 5.1 was supported in part by the Swedish
-Foundation for Strategic Research.
+The development of GMP 2, 3, and 4 was supported in part by the IDA Center for
+Computing Sciences.
Thanks go to Hans Thorsen for donating an SGI system for the GMP test system
environment.
@@ -10722,7 +10326,7 @@ Analytic Number Theory and Computational Complexity'', Wiley, 1998.
@item
Richard Crandall and Carl Pomerance, ``Prime Numbers: A Computational
Perspective'', 2nd edition, Springer-Verlag, 2005.
-@texlinebreak{} @uref{http://www.math.dartmouth.edu/~carlp/}
+@texlinebreak{} @uref{http://math.dartmouth.edu/~carlp/}
@item
Henri Cohen, ``A Course in Computational Algebraic Number Theory'', Graduate
@@ -10745,8 +10349,8 @@ Applied Cryptography'', @uref{http://www.cacr.math.uwaterloo.ca/hac/}
@item
Richard M. Stallman and the GCC Developer Community, ``Using the GNU Compiler
Collection'', Free Software Foundation, 2008, available online
-@uref{https://gcc.gnu.org/onlinedocs/}, and in the GCC package
-@uref{https://ftp.gnu.org/gnu/gcc/}
+@uref{http://gcc.gnu.org/onlinedocs/}, and in the GCC package
+@uref{ftp://ftp.gnu.org/gnu/gcc/}
@end itemize
@section Papers
@@ -10755,8 +10359,8 @@ Collection'', Free Software Foundation, 2008, available online
@item
Yves Bertot, Nicolas Magaud and Paul Zimmermann, ``A Proof of GMP Square
Root'', Journal of Automated Reasoning, volume 29, 2002, pp.@: 225-252. Also
-available online as INRIA Research Report 4475, June 2002,
-@uref{http://hal.inria.fr/docs/00/07/21/13/PDF/RR-4475.pdf}
+available online as INRIA Research Report 4475, June 2001,
+@uref{http://www.inria.fr/rrrt/rr-4475.html}
@item
Christoph Burnikel and Joachim Ziegler, ``Fast Recursive Division'',
@@ -10766,15 +10370,15 @@ Max-Planck-Institut fuer Informatik Research Report MPI-I-98-1-022,
@item
Torbj@"orn Granlund and Peter L. Montgomery, ``Division by Invariant Integers
using Multiplication'', in Proceedings of the SIGPLAN PLDI'94 Conference, June
-1994. Also available @uref{https://gmplib.org/~tege/divcnst-pldi94.pdf}.
+1994. Also available @uref{ftp://ftp.cwi.nl/pub/pmontgom/divcnst.psa4.gz}
+(and .psl.gz).
@item
-Niels M@"oller and Torbj@"orn Granlund, ``Improved division by invariant
-integers'', IEEE Transactions on Computers, 11 June 2010.
-@uref{https://gmplib.org/~tege/division-paper.pdf}
+Niels M"oller and Torbj@"orn Granlund, ``Improved division by invariant
+integers'', to appear.
@item
-Torbj@"orn Granlund and Niels M@"oller, ``Division of integers large and
+Torbj@"orn Granlund and Niels M"oller, ``Division of integers large and
small'', to appear.
@item
@@ -10846,7 +10450,7 @@ volume 21, number 1, March 1995, pp.@: 111-122.
@item
Paul Zimmermann, ``Karatsuba Square Root'', INRIA Research Report 3805,
-November 1999, @uref{http://hal.inria.fr/inria-00072854/PDF/RR-3805.pdf}
+November 1999, @uref{http://www.inria.fr/rrrt/rr-3805.html}
@item
Paul Zimmermann, ``A Proof of GMP Fast Division and Square Root
diff --git a/gmp/doc/isa_abi_headache b/gmp/doc/isa_abi_headache
index 7e1430d3d3..753589d9b5 100644
--- a/gmp/doc/isa_abi_headache
+++ b/gmp/doc/isa_abi_headache
@@ -3,28 +3,17 @@ 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 either:
-
- * the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
-or
-
- * the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any
- later version.
-
-or both in parallel, as here.
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 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 General Public License
-for more details.
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
-You should have received copies of the GNU General Public License and the
-GNU Lesser General Public License along with the GNU MP Library. If not,
-see https://www.gnu.org/licenses/.
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
diff --git a/gmp/doc/mdate-sh b/gmp/doc/mdate-sh
index 60dc485a37..8941738a4a 100755
--- a/gmp/doc/mdate-sh
+++ b/gmp/doc/mdate-sh
@@ -1,10 +1,9 @@
#!/bin/sh
# Get modification time of a file or directory and pretty-print it.
-scriptversion=2010-08-21.06; # UTC
+scriptversion=2003-11-09.00
-# Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005, 2007, 2009, 2010
-# Free Software Foundation, Inc.
+# Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
#
# This program is free software; you can redistribute it and/or modify
@@ -18,7 +17,8 @@ scriptversion=2010-08-21.06; # UTC
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -29,15 +29,6 @@ scriptversion=2010-08-21.06; # UTC
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
- setopt NO_GLOB_SUBST
-fi
-
case $1 in
'')
echo "$0: No file. Try \`$0 --help' for more information." 1>&2
@@ -47,26 +38,18 @@ case $1 in
cat <<\EOF
Usage: mdate-sh [--help] [--version] FILE
-Pretty-print the modification day of FILE, in the format:
-1 January 1970
+Pretty-print the modification time of FILE.
Report bugs to <bug-automake@gnu.org>.
EOF
- exit $?
+ exit 0
;;
-v | --v*)
echo "mdate-sh $scriptversion"
- exit $?
+ exit 0
;;
esac
-error ()
-{
- echo "$0: $1" >&2
- exit 1
-}
-
-
# Prevent date giving response in another language.
LANG=C
export LANG
@@ -75,15 +58,13 @@ export LC_ALL
LC_TIME=C
export LC_TIME
-# GNU ls changes its time format in response to the TIME_STYLE
-# variable. Since we cannot assume `unset' works, revert this
-# variable to its documented default.
-if test "${TIME_STYLE+set}" = set; then
- TIME_STYLE=posix-long-iso
- export TIME_STYLE
-fi
+# GNU ls changes its time format in response to the TIME_STYLE variable, but
+# we cannot unset it since the V7 shell did not have an "unset" command.
+# The documentation says that the default is "posix-long-iso".
+#
+test "${TIME_STYLE+set}" = set && TIME_STYLE=posix-long-iso
-save_arg1=$1
+save_arg1="$1"
# Find out how to get the extended ls output of a file or directory.
if ls -L /dev/null 1>/dev/null 2>&1; then
@@ -91,10 +72,6 @@ if ls -L /dev/null 1>/dev/null 2>&1; then
else
ls_command='ls -l -d'
fi
-# Avoid user/group names that might have spaces, when possible.
-if ls -n /dev/null 1>/dev/null 2>&1; then
- ls_command="$ls_command -n"
-fi
# A `ls -l' line looks as follows on OS/2.
# drwxrwx--- 0 Aug 11 2001 foo
@@ -109,14 +86,13 @@ fi
# words should be skipped to get the date.
# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
-set x`$ls_command /`
+set - x`$ls_command /`
# Find which argument is the month.
month=
command=
until test $month
do
- test $# -gt 0 || error "failed parsing \`$ls_command /' output"
shift
# Add another shift to the command.
command="$command shift;"
@@ -136,35 +112,14 @@ do
esac
done
-test -n "$month" || error "failed parsing \`$ls_command /' output"
-
# Get the extended ls output of the file or directory.
-set dummy x`eval "$ls_command \"\\\$save_arg1\""`
+set - x`eval "$ls_command \"\$save_arg1\""`
# Remove all preceding arguments
eval $command
-# Because of the dummy argument above, month is in $2.
-#
-# On a POSIX system, we should have
-#
-# $# = 5
-# $1 = file size
-# $2 = month
-# $3 = day
-# $4 = year or time
-# $5 = filename
-#
-# On Darwin 7.7.0 and 7.6.0, we have
-#
-# $# = 4
-# $1 = day
-# $2 = month
-# $3 = year or time
-# $4 = filename
-
-# Get the month.
-case $2 in
+# Get the month. Next argument is day, followed by the year or time.
+case $1 in
Jan) month=January; nummonth=1;;
Feb) month=February; nummonth=2;;
Mar) month=March; nummonth=3;;
@@ -179,10 +134,7 @@ case $2 in
Dec) month=December; nummonth=12;;
esac
-case $3 in
- ???*) day=$1;;
- *) day=$3; shift;;
-esac
+day=$2
# Here we have to deal with the problem that the ls output gives either
# the time of day or the year.
@@ -220,6 +172,5 @@ echo $day $month $year
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
+# time-stamp-end: "$"
# End:
diff --git a/gmp/doc/projects.html b/gmp/doc/projects.html
index 4a105142b0..39a82074d6 100644
--- a/gmp/doc/projects.html
+++ b/gmp/doc/projects.html
@@ -4,7 +4,7 @@
<title>GMP Development Projects</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="gmp.css">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<center>
@@ -15,40 +15,30 @@
<font size=-1>
<pre>
-Copyright 2000-2006, 2008-2011 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 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 either:
-
- * the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
-or
-
- * the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any
- later version.
-
-or both in parallel, as here.
+it under the terms of the GNU Lesser General Public License as published
+by the Free Software Foundation; either version 3 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 General Public License
-for more details.
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
-You should have received copies of the GNU General Public License and the
-GNU Lesser General Public License along with the GNU MP Library. If not,
-see https://www.gnu.org/licenses/.
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
</pre>
</font>
<hr>
<!-- NB. timestamp updated automatically by emacs -->
- This file current as of 29 Jan 2014. An up-to-date version is available at
- <a href="https://gmplib.org/projects.html">https://gmplib.org/projects.html</a>.
+ This file current as of 1 May 2009. An up-to-date version is available at
+ <a href="http://gmplib.org/projects.html">http://gmplib.org/projects.html</a>.
Please send comments about this page to gmp-devel<font>@</font>gmplib.org.
<p> This file lists projects suitable for volunteers. Please see the
@@ -63,9 +53,27 @@ see https://www.gnu.org/licenses/.
<ul>
<li> <strong>Faster multiplication</strong>
+ <p> The current multiplication code uses Karatsuba, 3-way and 4-way Toom, and
+ Fermat FFT. Several new developments are desirable:
+
<ol>
- <li> Work on the algorithm selection code for unbalanced multiplication.
+ <li> Write more toom multiply functions for unbalanced operands. We now have
+ toom22, toom32, toom42, toom62, toom33, toom53, and toom44. Most
+ desirable is toom43, which will require a new toom_interpolate_6pts
+ function. Writing toom52 will then be straightforward. See also
+ <a href="http://bodrato.it/software/toom.html">Marco Bodrato's
+ site</a>
+
+ <li> Perhaps consider N-way Toom, N > 4. See Knuth's Seminumerical
+ Algorithms for details on the method, as well as Bodrato's site. Code
+ implementing it exists. This is asymptotically inferior to FFTs, but
+ is finer grained.
+
+ <li> The mpn_mul call now (from GMP 4.3) uses toom22, toom32, and toom42
+ for unbalanced operations. We don't use any of the other new toom
+ functions currently. Write new clever code for choosing the best toom
+ function from an m-limb and an n-limb operand.
<li> Implement an FFT variant computing the coefficients mod m different
limb size primes of the form l*2^k+1. i.e., compute m separate FFTs.
@@ -82,10 +90,18 @@ see https://www.gnu.org/licenses/.
lose in more expensive CRT. <br><br>
<p> [We now have two implementations of this algorithm, one by Tommy
- Färnqvist and one by Niels Möller.]
-
- <li> Work on short products. Our mullo and mulmid are probably K, but we
- lack mulhi.
+ Färnqvist and one by Niels Möller.]
+
+ <li> Add support for short products, either a given number of low limbs, a
+ given number of high limbs, or perhaps the middle limbs of the result.
+ High short product can be used by <code>mpf_mul</code>, by
+ left-to-right Newton approximations, and for quotient approximation.
+ Low half short product can be of use in sub-quadratic REDC and for
+ right-to-left Newton approximations. On small sizes a short product
+ will be faster simply through fewer cross-products, similar to the way
+ squaring is faster. But work by Thom Mulders shows that for Karatsuba
+ and higher order algorithms the advantage is progressively lost, so
+ for large sizes shows products turn out to be no faster.
</ol>
@@ -105,8 +121,8 @@ see https://www.gnu.org/licenses/.
<p> Please make sure your new routines are fast for these three situations:
<ol>
+ <li> Operands that fit into the cache.
<li> Small operands of less than, say, 10 limbs.
- <li> Medium size operands, that fit into the cache.
<li> Huge operands that does not fit into the cache.
</ol>
@@ -116,24 +132,32 @@ see https://www.gnu.org/licenses/.
<p> Standard techniques for these routines are unrolling, software
pipelining, and specialization for common operand values. For machines
- with poor integer multiplication, it is sometimes possible to remedy the
- situation using floating-point operations or SIMD operations such as MMX
- (x86) (x86), SSE (x86), VMX (PowerPC), VIS (Sparc).
+ with poor integer multiplication, it is often possible to improve the
+ performance using floating-point operations, or SIMD operations such as
+ MMX or Sun's VIS.
<p> Using floating-point operations is interesting but somewhat tricky.
Since IEEE double has 53 bit of mantissa, one has to split the operands
- in small pieces, so that no intermediates are greater than 2^53. For
- 32-bit computers, splitting one operand into 16-bit pieces works. For
- 64-bit machines, one operand can be split into 21-bit pieces and the
- other into 32-bit pieces. (A 64-bit operand can be split into just three
- 21-bit pieces if one allows the split operands to be negative!)
+ in small pieces, so that no result is greater than 2^53. For 32-bit
+ computers, splitting one operand into 16-bit pieces works. For 64-bit
+ machines, one operand can be split into 21-bit pieces and the other into
+ 32-bit pieces. (A 64-bit operand can be split into just three 21-bit
+ pieces if one allows the split operands to be negative!)
+
+
+<li> <strong>Math functions for the mpf layer</strong>
+
+ <p> Implement the functions of math.h for the GMP mpf layer! Check the book
+ "Pi and the AGM" by Borwein and Borwein for ideas how to do this. These
+ functions are desirable: acos, acosh, asin, asinh, atan, atanh, atan2,
+ cos, cosh, exp, log, log10, pow, sin, sinh, tan, tanh.
<li> <strong>Faster sqrt</strong>
<p> The current code uses divisions, which are reasonably fast, but it'd be
possible to use only multiplications by computing 1/sqrt(A) using this
- iteration:
+ formula:
<pre>
2
x = x (3 &minus; A x )/2
@@ -147,29 +171,14 @@ see https://www.gnu.org/licenses/.
overall.
<p> We should probably allow a special exponent-like parameter, to speed
- computations of a precise square root of a small number in mpf and mpfr.
+ computations of a precise square root of a small number in mpf.
<li> <strong>Nth root</strong>
- <p> Improve mpn_rootrem. The current code is not too bad, but its time
- complexity is a function of the input, while it is possible to make
- the <i>average</i> complexity a function of the output.
-
-
-<li> <strong>Fat binaries</strong>
-
- <p> Add more functions to the set of fat functions.
-
- <p> The speed of multiplication is today highly dependent on combination
- functions like <code>addlsh1_n</code>. A fat binary will never use any such
- functions, since they are classified as optional. Ideally, we should use
- them, but making the current compile-time selections of optional functions
- become run-time selections for fat binaries.
-
- <p> If we make fat binaries work really well, we should move away frm tehe
- current configure scheme (at least by default) and instead include all code
- always.
+ <p> Improve mpn_rootrem. The current code is not to bad, but its average
+ time complexity is a function of the input, while it is possible to
+ make it a function of the output.
<li> <strong>Exceptions</strong>
@@ -330,6 +339,133 @@ see https://www.gnu.org/licenses/.
<code>gmp_restrict</code>.
+<li> <strong>Nx1 Division</strong>
+
+ <p> The limb-by-limb dependencies in the existing Nx1 division (and
+ remainder) code means that chips with multiple execution units or
+ pipelined multipliers are not fully utilized.
+
+ <p> One possibility is to follow the current preinv method but taking two
+ limbs at a time. That means a 2x2-&gt;4 and a 2x1-&gt;2 multiply for
+ each two limbs processed, and because the 2x2 and 2x1 can each be done in
+ parallel the latency will be not much more than 2 multiplies for two
+ limbs, whereas the single limb method has a 2 multiply latency for just
+ one limb. A version of <code>mpn_divrem_1</code> doing this has been
+ written in C, but not yet tested on likely chips. Clearly this scheme
+ would extend to 3x3-&gt;9 and 3x1-&gt;3 etc, though with diminishing
+ returns.
+
+ <p> For <code>mpn_mod_1</code>, Peter L. Montgomery proposes the following
+ scheme. For a limb R=2^<code>bits_per_mp_limb</code>, pre-calculate
+ values R mod N, R^2 mod N, R^3 mod N, R^4 mod N. Then take dividend
+ limbs and multiply them by those values, thereby reducing them (moving
+ them down) by the corresponding factor. The products can be added to
+ produce an intermediate remainder of 2 or 3 limbs to be similarly
+ included in the next step. The point is that such multiplies can be done
+ in parallel, meaning as little as 1 multiply worth of latency for 4
+ limbs. If the modulus N is less than R/4 (or is it R/5?) the summed
+ products will fit in 2 limbs, otherwise 3 will be required, but with the
+ high only being small. Clearly this extends to as many factors of R as a
+ chip can efficiently apply.
+
+ <p> The logical conclusion for powers R^i is a whole array "p[i] = R^i mod N"
+ for i up to k, the size of the dividend. This could then be applied at
+ multiplier throughput speed like an inner product. If the powers took
+ roughly k divide steps to calculate then there'd be an advantage any time
+ the same N was used three or more times. Suggested by Victor Shoup in
+ connection with chinese-remainder style decompositions, but perhaps with
+ other uses.
+
+ <p> <code>mpn_modexact_1_odd</code> calculates an x in the range 0&lt;=x&lt;d
+ satisfying a = q*d + x*b^n, where b=2^bits_per_limb. The factor b^n
+ needed to get the true remainder r could be calculated by a powering
+ algorithm, allowing <code>mpn_modexact_1_odd</code> to be pressed into
+ service for an <code>mpn_mod_1</code>. <code>modexact_1</code> is
+ simpler and on some chips can run noticeably faster than plain
+ <code>mod_1</code>, on Athlon for instance 11 cycles/limb instead of 17.
+ Such a difference could soon overcome the time to calculate b^n. The
+ requirement for an odd divisor in <code>modexact</code> can be handled by
+ some shifting on-the-fly, or perhaps by an extra partial-limb step at the
+ end.
+
+
+<li> <strong>Factorial</strong>
+
+ <p> The removal of twos in the current code could be extended to factors of 3
+ or 5. Taking this to its logical conclusion would be a complete
+ decomposition into powers of primes. The power for a prime p is of
+ course floor(n/p)+floor(n/p^2)+... Conrad Curry found this is quite fast
+ (using simultaneous powering as per Handbook of Applied Cryptography
+ algorithm 14.88).
+
+ <p> A difficulty with using all primes is that quite large n can be
+ calculated on a system with enough memory, larger than we'd probably want
+ for a table of primes, so some sort of sieving would be wanted. Perhaps
+ just taking out the factors of 3 and 5 would give most of the speedup
+ that a prime decomposition can offer.
+
+
+<li> <strong>Binomial Coefficients</strong>
+
+ <p> An obvious improvement to the current code would be to strip factors of 2
+ from each multiplier and divisor and count them separately, to be applied
+ with a bit shift at the end. Factors of 3 and perhaps 5 could even be
+ handled similarly.
+
+ <p> Conrad Curry reports a big speedup for binomial coefficients using a
+ prime powering scheme, at least for k near n/2. Of course this is only
+ practical for moderate size n since again it requires primes up to n.
+
+ <p> When k is small the current (n-k+1)...n/1...k will be fastest. Some sort
+ of rule would be needed for when to use this or when to use prime
+ powering. Such a rule will be a function of both n and k. Some
+ investigation is needed to see what sort of shape the crossover line will
+ have, the usual parameter tuning can of course find machine dependent
+ constants to fill in where necessary.
+
+ <p> An easier possibility also reported by Conrad Curry is that it may be
+ faster not to divide out the denominator (1...k) one-limb at a time, but
+ do one big division at the end. Is this because a big divisor in
+ <code>mpn_bdivmod</code> trades the latency of
+ <code>mpn_divexact_1</code> for the throughput of
+ <code>mpn_submul_1</code>? Overheads must hurt though.
+
+ <p> Another reason a big divisor might help is that
+ <code>mpn_divexact_1</code> won't be getting a full limb in
+ <code>mpz_bin_uiui</code>. It's called when the n accumulator is full
+ but the k may be far from full. Perhaps the two could be decoupled so k
+ is applied when full. It'd be necessary to delay consideration of k
+ terms until the corresponding n terms had been applied though, since
+ otherwise the division won't be exact.
+
+
+<li> <strong>Perfect Power Testing</strong>
+
+ <p> <code>mpz_perfect_power_p</code> could be improved in a number of ways,
+ for instance p-adic arithmetic to find possible roots.
+
+ <p> Non-powers can be quickly identified by checking for Nth power residues
+ modulo small primes, like <code>mpn_perfect_square_p</code> does for
+ squares. The residues to each power N for a given remainder could be
+ grouped into a bit mask, the masks for the remainders to each divisor
+ would then be "and"ed together to hopefully leave only a few candidate
+ powers. Need to think about how wide to make such masks, ie. how many
+ powers to examine in this way.
+
+ <p> Any zero remainders found in residue testing reveal factors which can be
+ divided out, with the multiplicity restricting the powers that need to be
+ considered, as per the current code. Further prime dividing should be
+ grouped into limbs like <code>PP</code>. Need to think about how much
+ dividing to do like that, probably more for bigger inputs, less for
+ smaller inputs.
+
+ <p> <code>mpn_gcd_1</code> would probably be better than the current private
+ GCD routine. The use it's put to isn't time-critical, and it might help
+ ensure correctness to just use the main GCD routine.
+
+ <p> [There is work-in-progress with a very fast function.]
+
+
<li> <strong>Prime Testing</strong>
<p> GMP is not really a number theory library and probably shouldn't have
@@ -449,16 +585,6 @@ see https://www.gnu.org/licenses/.
selecting public symbols (used now for libmp).
-<li> <strong>Math functions for the mpf layer</strong>
-
- <p> Implement the functions of math.h for the GMP mpf layer! Check the book
- "Pi and the AGM" by Borwein and Borwein for ideas how to do this. These
- functions are desirable: acos, acosh, asin, asinh, atan, atanh, atan2,
- cos, cosh, exp, log, log10, pow, sin, sinh, tan, tanh.
-
- <p> Note that the <a href="http://mpfr.org">mpfr</a> functions already
- provide these functions, and that we usually recommend new programs to use
- mpfr instead of mpf.
</ul>
<hr>
diff --git a/gmp/doc/stamp-vti b/gmp/doc/stamp-vti
index 08f09e7e86..227ebb6db5 100644
--- a/gmp/doc/stamp-vti
+++ b/gmp/doc/stamp-vti
@@ -1,4 +1,4 @@
-@set UPDATED 25 March 2014
-@set UPDATED-MONTH March 2014
-@set EDITION 6.0.0
-@set VERSION 6.0.0
+@set UPDATED 7 January 2010
+@set UPDATED-MONTH January 2010
+@set EDITION 4.3.2
+@set VERSION 4.3.2
diff --git a/gmp/doc/tasks.html b/gmp/doc/tasks.html
index 9a25bef1a3..1c3a12b29a 100644
--- a/gmp/doc/tasks.html
+++ b/gmp/doc/tasks.html
@@ -4,7 +4,7 @@
<title>GMP Itemized Development Tasks</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="gmp.css">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<center>
@@ -15,40 +15,30 @@
<font size=-1>
<pre>
-Copyright 2000-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
+Copyright 2000, 2001, 2002, 2003, 2004, 2006, 2008, 2009 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 either:
-
- * the GNU Lesser General Public License as published by the Free
- Software Foundation; either version 3 of the License, or (at your
- option) any later version.
-
-or
-
- * the GNU General Public License as published by the Free Software
- Foundation; either version 2 of the License, or (at your option) any
- later version.
-
-or both in parallel, as here.
+it under the terms of the GNU Lesser General Public License as published
+by the Free Software Foundation; either version 3 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 General Public License
-for more details.
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+License for more details.
-You should have received copies of the GNU General Public License and the
-GNU Lesser General Public License along with the GNU MP Library. If not,
-see https://www.gnu.org/licenses/.
+You should have received a copy of the GNU Lesser General Public License
+along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
</pre>
</font>
<hr>
<!-- NB. timestamp updated automatically by emacs -->
- This file current as of 29 Jan 2014. An up-to-date version is available at
- <a href="https://gmplib.org/tasks.html">https://gmplib.org/tasks.html</a>.
+ This file current as of 1 May 2009. An up-to-date version is available at
+ <a href="http://gmplib.org/tasks.html">http://gmplib.org/tasks.html</a>.
Please send comments about this page to gmp-devel<font>@</font>gmplib.org.
<p> These are itemized GMP development tasks. Not all the tasks
@@ -72,6 +62,13 @@ either already been taken care of, or have become irrelevant.
<code>_mpz_realloc</code> with a small (1 limb) size.
<li> One reuse case is missing from mpX/tests/reuse.c:
<code>mpz_XXX(a,a,a)</code>.
+<li> When printing <code>mpf_t</code> numbers with exponents &gt;2^53 on
+ machines with 64-bit <code>mp_exp_t</code>, the precision of
+ <code>__mp_bases[base].chars_per_bit_exactly</code> is insufficient and
+ <code>mpf_get_str</code> aborts. Detect and compensate. Alternately,
+ think seriously about using some sort of fixed-point integer value.
+ Avoiding unnecessary floating point is probably a good thing in general,
+ and it might be faster on some CPUs.
<li> Make the string reading functions allow the `0x' prefix when the base is
explicitly 16. They currently only allow that prefix when the base is
unspecified (zero).
@@ -125,6 +122,9 @@ either already been taken care of, or have become irrelevant.
subsequent operations, especially if the value is otherwise only small.
If low bits of the low limb are zero, use <code>mpn_rshift</code> so as
to not increase the size.
+<li> <code>mpn_dc_sqrtrem</code>: Don't use <code>mpn_addmul_1</code> with
+ multiplier==2, instead either <code>mpn_addlsh1_n</code> when available,
+ or <code>mpn_lshift</code>+<code>mpn_add_n</code> if not.
<li> <code>mpn_dc_sqrtrem</code>, <code>mpn_sqrtrem2</code>: Don't use
<code>mpn_add_1</code> and <code>mpn_sub_1</code> for 1 limb operations,
instead <code>ADDC_LIMB</code> and <code>SUBC_LIMB</code>.
@@ -133,12 +133,20 @@ either already been taken care of, or have become irrelevant.
aliasing between <code>sp</code> and <code>rp</code>.
<li> <code>mpn_sqrtrem</code>: Some work can be saved in the last step when
the remainder is not required, as noted in Paul's paper.
+<li> <code>mpq_add</code>, <code>mpq_add</code>: The division "op1.den / gcd"
+ is done twice, where of course only once is necessary. Reported by Larry
+ Lambe.
<li> <code>mpq_add</code>, <code>mpq_sub</code>: The gcd fits a single limb
- with high probability and in this case <code>binvert_limb</code> could
+ with high probability and in this case <code>modlimb_invert</code> could
be used to calculate the inverse just once for the two exact divisions
"op1.den / gcd" and "op2.den / gcd", rather than letting
- <code>mpn_bdiv_q_1</code> do it each time. This would require calling
- <code>mpn_pi1_bdiv_q_1</code>.
+ <code>mpn_divexact_1</code> do it each time. This would require a new
+ <code>mpn_preinv_divexact_1</code> interface. Not sure if it'd be worth
+ the trouble.
+<li> <code>mpq_add</code>, <code>mpq_sub</code>: The use of
+ <code>mpz_mul(x,y,x)</code> causes temp allocation or copying in
+ <code>mpz_mul</code> which can probably be avoided. A rewrite using
+ <code>mpn</code> might be best.
<li> <code>mpn_gcdext</code>: Don't test <code>count_leading_zeros</code> for
zero, instead check the high bit of the operand and avoid invoking
<code>count_leading_zeros</code>. This is an optimization on all
@@ -146,7 +154,7 @@ either already been taken care of, or have become irrelevant.
<code>count_leading_zeros</code>, though it's possible an already
normalized operand might not be encountered very often.
<li> Rewrite <code>umul_ppmm</code> to use floating-point for generating the
- most significant limb (if <code>GMP_LIMB_BITS</code> &lt= 52 bits).
+ most significant limb (if <code>BITS_PER_MP_LIMB</code> &lt= 52 bits).
(Peter Montgomery has some ideas on this subject.)
<li> Improve the default <code>umul_ppmm</code> code in longlong.h: Add partial
products with fewer operations.
@@ -165,20 +173,26 @@ either already been taken care of, or have become irrelevant.
since there's no apparent way to get <code>SHRT_MAX</code> with an
expression (since <code>short</code> and <code>unsigned short</code> can
be different sizes).
-<li> <code>mpz_powm</code> and <code>mpz_powm_ui</code> aren't very fast on one
- or two limb moduli, due to a lot of function call overheads. These could
- perhaps be handled as special cases.
-<li> Make sure <code>mpz_powm_ui</code> is never slower than the corresponding
- computation using <code>mpz_powm</code>.
+<li> <code>mpz_powm</code> and <code>mpz_powm_ui</code> aren't very
+ fast on one or two limb moduli, due to a lot of function call
+ overheads. These could perhaps be handled as special cases.
+<li> <code>mpz_powm</code> and <code>mpz_powm_ui</code> want better
+ algorithm selection, and the latter should use REDC. Both could
+ change to use an <code>mpn_powm</code> and <code>mpn_redc</code>.
<li> <code>mpz_powm</code> REDC should do multiplications by <code>g[]</code>
using the division method when they're small, since the REDC form of a
small multiplier is normally a full size product. Probably would need a
new tuned parameter to say what size multiplier is "small", as a function
of the size of the modulus.
-<li> <code>mpn_gcd</code> might be able to be sped up on small to moderate
- sizes by improving <code>find_a</code>, possibly just by providing an
- alternate implementation for CPUs with slowish
+<li> <code>mpz_powm</code> REDC should handle even moduli if possible. Maybe
+ this would mean for m=n*2^k doing mod n using REDC and an auxiliary
+ calculation mod 2^k, then putting them together at the end.
+<li> <code>mpn_gcd</code> might be able to be sped up on small to
+ moderate sizes by improving <code>find_a</code>, possibly just by
+ providing an alternate implementation for CPUs with slowish
<code>count_leading_zeros</code>.
+<li> Toom3 could use a low to high cache localized evaluate and interpolate.
+ The necessary <code>mpn_divexact_by3c</code> exists.
<li> <code>mpf_set_str</code> produces low zero limbs when a string has a
fraction but is exactly representable, eg. 0.5 in decimal. These could be
stripped to save work in later operations.
@@ -203,7 +217,7 @@ either already been taken care of, or have become irrelevant.
an in-place there.
<li> <code>mpf_div_ui</code>: Whether the high quotient limb is zero can be
determined by testing the dividend for high&lt;divisor. When non-zero, the
- division can be done on prec dividend limbs instead of prec+1. The result
+ divison can be done on prec dividend limbs instead of prec+1. The result
size is also known before the division, so that can be a tail call (once
the <code>TMP_ALLOC</code> is eliminated).
<li> <code>mpn_divrem_2</code> could usefully accept unnormalized divisors and
@@ -309,7 +323,7 @@ either already been taken care of, or have become irrelevant.
<code>__builtin_clzl</code> and <code>__builtin_popcountl</code> using
the corresponding CIX <code>ct</code> instructions, and
<code>__builtin_alpha_cmpbge</code>. These should give GCC more
- information about scheduling etc than the <code>asm</code> blocks
+ information about sheduling etc than the <code>asm</code> blocks
currently used in longlong.h and gmp-impl.h.
<li> Alpha Unicos: Apparently there's no <code>alloca</code> on this system,
making <code>configure</code> choose the slower
@@ -357,7 +371,7 @@ either already been taken care of, or have become irrelevant.
<li> UltraSPARC/32: <code>mpn_divexact_by3c</code> can work 64-bits at a time
using <code>mulx</code>, in assembler. This would be the same as for
sparc64.
-<li> UltraSPARC: <code>binvert_limb</code> might save a few cycles from
+<li> UltraSPARC: <code>modlimb_invert</code> might save a few cycles from
masking down to just the useful bits at each point in the calculation,
since <code>mulx</code> speed depends on the highest bit set. Either
explicit masks or small types like <code>short</code> and
@@ -422,7 +436,7 @@ either already been taken care of, or have become irrelevant.
<code>mpn_rshift</code> already provided.
<li> Cray T3E: Experiment with optimization options. In particular,
-hpipeline3 seems promising. We should at least up -O to -O2 or -O3.
-<li> Cray: <code>mpn_com</code> and <code>mpn_and_n</code> etc very probably
+<li> Cray: <code>mpn_com_n</code> and <code>mpn_and_n</code> etc very probably
wants a pragma like <code>MPN_COPY_INCR</code>.
<li> Cray vector systems: <code>mpn_lshift</code>, <code>mpn_rshift</code>,
<code>mpn_popcount</code> and <code>mpn_hamdist</code> are nice and small
@@ -487,7 +501,7 @@ either already been taken care of, or have become irrelevant.
Set <code>ALLOC(var)</code> to 0 to indicate nothing allocated, and let
<code>_mpz_realloc</code> do the initial alloc. Set
<code>z-&gt;_mp_d</code> to a dummy that <code>mpz_get_ui</code> and
- similar can unconditionally fetch from. Niels Möller has had a go at
+ similar can unconditionally fetch from. Niels Möller has had a go at
this.
<br>
The advantages of the lazy scheme would be:
@@ -524,7 +538,7 @@ either already been taken care of, or have become irrelevant.
if they could share code with the current such functions (which should be
possible).
<li> <code>mpz_and_ui</code> etc might be of use sometimes. Suggested by
- Niels Möller.
+ Niels Möller.
<li> <code>mpf_set_str</code> and <code>mpf_inp_str</code> could usefully
accept 0x, 0b etc when base==0. Perhaps the exponent could default to
decimal in this case, with a further 0x, 0b etc allowed there.
@@ -714,7 +728,7 @@ either already been taken care of, or have become irrelevant.
Consider making these variant <code>mpz_set_str</code> etc forms
available for <code>mpz_t</code> too, not just <code>mpz_class</code>
etc.
-<li> <code>mpq_class operator+=</code>: Don't emit an unnecessary
+<li> <code>mpq_class operator+=</code>: Don't emit an unnecssary
<code>mpq_set(q,q)</code> before <code>mpz_addmul</code> etc.
<li> Put various bits of gmpxx.h into libgmpxx, to avoid excessive inlining.
Candidates for this would be,
diff --git a/gmp/doc/texinfo.tex b/gmp/doc/texinfo.tex
index 85f184cc4c..bac0726023 100644
--- a/gmp/doc/texinfo.tex
+++ b/gmp/doc/texinfo.tex
@@ -1,13 +1,13 @@
% texinfo.tex -- TeX macros to handle Texinfo files.
-%
+%
% Load plain if necessary, i.e., if running under initex.
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
%
-\def\texinfoversion{2013-02-01.11}
+\def\texinfoversion{2008-04-18.10}
%
-% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
+% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-% 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+% 2007, 2008 Free Software Foundation, Inc.
%
% This texinfo.tex file is free software: you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
@@ -24,14 +24,13 @@
%
% As a special exception, when this file is read by TeX when processing
% a Texinfo source document, you may use the result without
-% restriction. This Exception is an additional permission under section 7
-% of the GNU General Public License, version 3 ("GPLv3").
+% restriction. (This has been our intent since Texinfo was invented.)
%
% Please try the latest version of texinfo.tex before submitting bug
% reports; you can get the latest version from:
-% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
-% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
-% http://www.gnu.org/software/texinfo/ (the Texinfo home page)
+% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
+% ftp://tug.org/tex/texinfo.tex
+% (and all CTAN mirrors, see http://www.ctan.org).
% The texinfo.tex in any given distribution could well be out
% of date, so if that's what you're using, please check.
%
@@ -66,6 +65,7 @@
\everyjob{\message{[Texinfo version \texinfoversion]}%
\catcode`+=\active \catcode`\_=\active}
+
\chardef\other=12
% We never want plain's \outer definition of \+ in Texinfo.
@@ -93,13 +93,11 @@
\let\ptexnewwrite\newwrite
\let\ptexnoindent=\noindent
\let\ptexplus=+
-\let\ptexraggedright=\raggedright
\let\ptexrbrace=\}
\let\ptexslash=\/
\let\ptexstar=\*
\let\ptext=\t
\let\ptextop=\top
-{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
% If this character appears in an error message or help string, it
% starts a new line in the output.
@@ -117,11 +115,10 @@
% Set up fixed words for English if not already set.
\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
-\ifx\putworderror\undefined \gdef\putworderror{error}\fi
\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
\ifx\putwordin\undefined \gdef\putwordin{in}\fi
-\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
-\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
+\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
+\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
@@ -160,18 +157,15 @@
\def\spaceisspace{\catcode`\ =\spacecat}
% sometimes characters are active, so we need control sequences.
-\chardef\ampChar = `\&
\chardef\colonChar = `\:
\chardef\commaChar = `\,
\chardef\dashChar = `\-
\chardef\dotChar = `\.
\chardef\exclamChar= `\!
-\chardef\hashChar = `\#
\chardef\lquoteChar= `\`
\chardef\questChar = `\?
\chardef\rquoteChar= `\'
\chardef\semiChar = `\;
-\chardef\slashChar = `\/
\chardef\underChar = `\_
% Ignore a token.
@@ -202,7 +196,36 @@
% that mark overfull boxes (in case you have decided
% that the text looks ok even though it passes the margin).
%
-\def\finalout{\overfullrule=0pt }
+\def\finalout{\overfullrule=0pt}
+
+% @| inserts a changebar to the left of the current line. It should
+% surround any changed text. This approach does *not* work if the
+% change spans more than two lines of output. To handle that, we would
+% have adopt a much more difficult approach (putting marks into the main
+% vertical list for the beginning and end of each change).
+%
+\def\|{%
+ % \vadjust can only be used in horizontal mode.
+ \leavevmode
+ %
+ % Append this vertical mode material after the current line in the output.
+ \vadjust{%
+ % We want to insert a rule with the height and depth of the current
+ % leading; that is exactly what \strutbox is supposed to record.
+ \vskip-\baselineskip
+ %
+ % \vadjust-items are inserted at the left edge of the type. So
+ % the \llap here moves out into the left-hand margin.
+ \llap{%
+ %
+ % For a thicker or thinner bar, change the `1pt'.
+ \vrule height\baselineskip width1pt
+ %
+ % This is the space between the bar and the text.
+ \hskip 12pt
+ }%
+ }%
+}
% Sometimes it is convenient to have everything in the transcript file
% and nothing on the terminal. We don't just call \tracingall here,
@@ -220,7 +243,7 @@
\tracingmacros2
\tracingrestores1
\showboxbreadth\maxdimen \showboxdepth\maxdimen
- \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
+ \ifx\eTeXversion\undefined\else % etex gives us more logging
\tracingscantokens1
\tracingifs1
\tracinggroups1
@@ -231,13 +254,6 @@
\errorcontextlines16
}%
-% @errormsg{MSG}. Do the index-like expansions on MSG, but if things
-% aren't perfect, it's not the end of the world, being an error message,
-% after all.
-%
-\def\errormsg{\begingroup \indexnofonts \doerrormsg}
-\def\doerrormsg#1{\errmessage{#1}}
-
% add check for \lastpenalty to plain's definitions. If the last thing
% we did was a \nobreak, we don't want to insert more space.
%
@@ -248,6 +264,7 @@
\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
\removelastskip\penalty-200\bigskip\fi\fi}
+% For @cropmarks command.
% Do @cropmarks to get crop marks.
%
\newif\ifcropmarks
@@ -338,7 +355,7 @@
% We don't want .vr (or whatever) entries like this:
% \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
% "\acronym" won't work when it's read back in;
- % it needs to be
+ % it needs to be
% {\code {{\tt \backslashcurfont }acronym}
\shipout\vbox{%
% Do this early so pdf references go to the beginning of the page.
@@ -557,7 +574,7 @@
}
\def\inenvironment#1{%
\ifx#1\empty
- outside of any environment%
+ out of any environment%
\else
in environment \expandafter\string#1%
\fi
@@ -569,7 +586,7 @@
\parseargdef\end{%
\if 1\csname iscond.#1\endcsname
\else
- % The general wording of \badenverr may not be ideal.
+ % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
\expandafter\checkenv\csname#1\endcsname
\csname E#1\endcsname
\endgroup
@@ -579,6 +596,85 @@
\newhelp\EMsimple{Press RETURN to continue.}
+%% Simple single-character @ commands
+
+% @@ prints an @
+% Kludge this until the fonts are right (grr).
+\def\@{{\tt\char64}}
+
+% This is turned off because it was never documented
+% and you can use @w{...} around a quote to suppress ligatures.
+%% Define @` and @' to be the same as ` and '
+%% but suppressing ligatures.
+%\def\`{{`}}
+%\def\'{{'}}
+
+% Used to generate quoted braces.
+\def\mylbrace {{\tt\char123}}
+\def\myrbrace {{\tt\char125}}
+\let\{=\mylbrace
+\let\}=\myrbrace
+\begingroup
+ % Definitions to produce \{ and \} commands for indices,
+ % and @{ and @} for the aux/toc files.
+ \catcode`\{ = \other \catcode`\} = \other
+ \catcode`\[ = 1 \catcode`\] = 2
+ \catcode`\! = 0 \catcode`\\ = \other
+ !gdef!lbracecmd[\{]%
+ !gdef!rbracecmd[\}]%
+ !gdef!lbraceatcmd[@{]%
+ !gdef!rbraceatcmd[@}]%
+!endgroup
+
+% @comma{} to avoid , parsing problems.
+\let\comma = ,
+
+% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
+% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
+\let\, = \c
+\let\dotaccent = \.
+\def\ringaccent#1{{\accent23 #1}}
+\let\tieaccent = \t
+\let\ubaraccent = \b
+\let\udotaccent = \d
+
+% Other special characters: @questiondown @exclamdown @ordf @ordm
+% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
+\def\questiondown{?`}
+\def\exclamdown{!`}
+\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
+\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
+
+% Dotless i and dotless j, used for accents.
+\def\imacro{i}
+\def\jmacro{j}
+\def\dotless#1{%
+ \def\temp{#1}%
+ \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
+ \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
+ \else \errmessage{@dotless can be used only with i or j}%
+ \fi\fi
+}
+
+% The \TeX{} logo, as in plain, but resetting the spacing so that a
+% period following counts as ending a sentence. (Idea found in latex.)
+%
+\edef\TeX{\TeX \spacefactor=1000 }
+
+% @LaTeX{} logo. Not quite the same results as the definition in
+% latex.ltx, since we use a different font for the raised A; it's most
+% convenient for us to use an explicitly smaller font, rather than using
+% the \scriptstyle font (since we don't reset \scriptstyle and
+% \scriptscriptstyle).
+%
+\def\LaTeX{%
+ L\kern-.36em
+ {\setbox0=\hbox{T}%
+ \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}%
+ \kern-.15em
+ \TeX
+}
+
% Be sure we're in horizontal mode when doing a tie, since we make space
% equivalent to this in @example-like environments. Otherwise, a space
% at the beginning of a line will start with \penalty -- and
@@ -595,7 +691,7 @@
\def\:{\spacefactor=1000 }
% @* forces a line break.
-\def\*{\unskip\hfil\break\hbox{}\ignorespaces}
+\def\*{\hfil\break\hbox{}\ignorespaces}
% @/ allows a line break.
\let\/=\allowbreak
@@ -610,7 +706,7 @@
\def\?{?\spacefactor=\endofsentencespacefactor\space}
% @frenchspacing on|off says whether to put extra space after punctuation.
-%
+%
\def\onword{on}
\def\offword{off}
%
@@ -620,7 +716,7 @@
\else\ifx\temp\offword \plainnonfrenchspacing
\else
\errhelp = \EMsimple
- \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
+ \errmessage{Unknown @frenchspacing option `\temp', must be on/off}%
\fi\fi
}
@@ -702,6 +798,15 @@ where each line of input produces a line of output.}
\newdimen\mil \mil=0.001in
+% Old definition--didn't work.
+%\parseargdef\need{\par %
+%% This method tries to make TeX break the page naturally
+%% if the depth of the box does not fit.
+%{\baselineskip=0pt%
+%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
+%\prevdepth=-1000pt
+%}}
+
\parseargdef\need{%
% Ensure vertical mode, so we don't make a big box in the middle of a
% paragraph.
@@ -765,7 +870,7 @@ where each line of input produces a line of output.}
% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
% paragraph. For more general purposes, use the \margin insertion
-% class. WHICH is `l' or `r'. Not documented, written for gawk manual.
+% class. WHICH is `l' or `r'.
%
\newskip\inmarginspacing \inmarginspacing=1cm
\def\strutdepth{\dp\strutbox}
@@ -812,36 +917,6 @@ where each line of input produces a line of output.}
\temp
}
-% @| inserts a changebar to the left of the current line. It should
-% surround any changed text. This approach does *not* work if the
-% change spans more than two lines of output. To handle that, we would
-% have adopt a much more difficult approach (putting marks into the main
-% vertical list for the beginning and end of each change). This command
-% is not documented, not supported, and doesn't work.
-%
-\def\|{%
- % \vadjust can only be used in horizontal mode.
- \leavevmode
- %
- % Append this vertical mode material after the current line in the output.
- \vadjust{%
- % We want to insert a rule with the height and depth of the current
- % leading; that is exactly what \strutbox is supposed to record.
- \vskip-\baselineskip
- %
- % \vadjust-items are inserted at the left edge of the type. So
- % the \llap here moves out into the left-hand margin.
- \llap{%
- %
- % For a thicker or thinner bar, change the `1pt'.
- \vrule height\baselineskip width1pt
- %
- % This is the space between the bar and the text.
- \hskip 12pt
- }%
- }%
-}
-
% @include FILE -- \input text of FILE.
%
\def\include{\parseargusing\filenamecatcodes\includezzz}
@@ -851,8 +926,6 @@ where each line of input produces a line of output.}
{%
\makevalueexpandable % we want to expand any @value in FILE.
\turnoffactive % and allow special characters in the expansion
- \indexnofonts % Allow `@@' and other weird things in file names.
- \wlog{texinfo.tex: doing @include of #1^^J}%
\edef\temp{\noexpand\input #1 }%
%
% This trickery is to read FILE outside of a group, in case it makes
@@ -871,8 +944,6 @@ where each line of input produces a line of output.}
\catcode`>=\other
\catcode`+=\other
\catcode`-=\other
- \catcode`\`=\other
- \catcode`\'=\other
}
\def\pushthisfilestack{%
@@ -888,7 +959,7 @@ where each line of input produces a line of output.}
\def\popthisfilestack{\errthisfilestackempty}
\def\errthisfilestackempty{\errmessage{Internal error:
the stack of filenames is empty.}}
-%
+
\def\thisfile{}
% @center line
@@ -896,46 +967,36 @@ where each line of input produces a line of output.}
%
\parseargdef\center{%
\ifhmode
- \let\centersub\centerH
+ \let\next\centerH
\else
- \let\centersub\centerV
+ \let\next\centerV
\fi
- \centersub{\hfil \ignorespaces#1\unskip \hfil}%
- \let\centersub\relax % don't let the definition persist, just in case
+ \next{\hfil \ignorespaces#1\unskip \hfil}%
}
-\def\centerH#1{{%
- \hfil\break
- \advance\hsize by -\leftskip
- \advance\hsize by -\rightskip
- \line{#1}%
- \break
-}}
-%
-\newcount\centerpenalty
-\def\centerV#1{%
- % The idea here is the same as in \startdefun, \cartouche, etc.: if
- % @center is the first thing after a section heading, we need to wipe
- % out the negative parskip inserted by \sectionheading, but still
- % prevent a page break here.
- \centerpenalty = \lastpenalty
- \ifnum\centerpenalty>10000 \vskip\parskip \fi
- \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
- \line{\kern\leftskip #1\kern\rightskip}%
+\def\centerH#1{%
+ {%
+ \hfil\break
+ \advance\hsize by -\leftskip
+ \advance\hsize by -\rightskip
+ \line{#1}%
+ \break
+ }%
}
+\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
% @sp n outputs n lines of vertical space
-%
+
\parseargdef\sp{\vskip #1\baselineskip}
% @comment ...line which is ignored...
% @c is the same as @comment
% @ignore ... @end ignore is another way to write a comment
-%
+
\def\comment{\begingroup \catcode`\^^M=\other%
\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
\commentxxx}
{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
-%
+
\let\c=\comment
% @paragraphindent NCHARS
@@ -1028,6 +1089,107 @@ where each line of input produces a line of output.}
}
+% @asis just yields its argument. Used with @table, for example.
+%
+\def\asis#1{#1}
+
+% @math outputs its argument in math mode.
+%
+% One complication: _ usually means subscripts, but it could also mean
+% an actual _ character, as in @math{@var{some_variable} + 1}. So make
+% _ active, and distinguish by seeing if the current family is \slfam,
+% which is what @var uses.
+{
+ \catcode`\_ = \active
+ \gdef\mathunderscore{%
+ \catcode`\_=\active
+ \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
+ }
+}
+% Another complication: we want \\ (and @\) to output a \ character.
+% FYI, plain.tex uses \\ as a temporary control sequence (why?), but
+% this is not advertised and we don't care. Texinfo does not
+% otherwise define @\.
+%
+% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
+\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
+%
+\def\math{%
+ \tex
+ \mathunderscore
+ \let\\ = \mathbackslash
+ \mathactive
+ % make the texinfo accent commands work in math mode
+ \let\"=\ddot
+ \let\'=\acute
+ \let\==\bar
+ \let\^=\hat
+ \let\`=\grave
+ \let\u=\breve
+ \let\v=\check
+ \let\~=\tilde
+ \let\dotaccent=\dot
+ $\finishmath
+}
+\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
+
+% Some active characters (such as <) are spaced differently in math.
+% We have to reset their definitions in case the @math was an argument
+% to a command which sets the catcodes (such as @item or @section).
+%
+{
+ \catcode`^ = \active
+ \catcode`< = \active
+ \catcode`> = \active
+ \catcode`+ = \active
+ \gdef\mathactive{%
+ \let^ = \ptexhat
+ \let< = \ptexless
+ \let> = \ptexgtr
+ \let+ = \ptexplus
+ }
+}
+
+% Some math mode symbols.
+\def\bullet{$\ptexbullet$}
+\def\geq{\ifmmode \ge\else $\ge$\fi}
+\def\leq{\ifmmode \le\else $\le$\fi}
+\def\minus{\ifmmode -\else $-$\fi}
+
+% @dots{} outputs an ellipsis using the current font.
+% We do .5em per period so that it has the same spacing in the cm
+% typewriter fonts as three actual period characters; on the other hand,
+% in other typewriter fonts three periods are wider than 1.5em. So do
+% whichever is larger.
+%
+\def\dots{%
+ \leavevmode
+ \setbox0=\hbox{...}% get width of three periods
+ \ifdim\wd0 > 1.5em
+ \dimen0 = \wd0
+ \else
+ \dimen0 = 1.5em
+ \fi
+ \hbox to \dimen0{%
+ \hskip 0pt plus.25fil
+ .\hskip 0pt plus1fil
+ .\hskip 0pt plus1fil
+ .\hskip 0pt plus.5fil
+ }%
+}
+
+% @enddots{} is an end-of-sentence ellipsis.
+%
+\def\enddots{%
+ \dots
+ \spacefactor=\endofsentencespacefactor
+}
+
+% @comma{} is so commas can be inserted into text without messing up
+% Texinfo's parsing.
+%
+\let\comma = ,
+
% @refill is a no-op.
\let\refill=\relax
@@ -1092,8 +1254,9 @@ where each line of input produces a line of output.}
\newif\ifpdfmakepagedest
% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
-% can be set). So we test for \relax and 0 as well as being undefined.
-\ifx\pdfoutput\thisisundefined
+% can be set). So we test for \relax and 0 as well as \undefined,
+% borrowed from ifpdf.sty.
+\ifx\pdfoutput\undefined
\else
\ifx\pdfoutput\relax
\else
@@ -1108,24 +1271,50 @@ where each line of input produces a line of output.}
% for display in the outlines, and in other places. Thus, we have to
% double any backslashes. Otherwise, a name like "\node" will be
% interpreted as a newline (\n), followed by o, d, e. Not good.
+% http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html
+% (and related messages, the final outcome is that it is up to the TeX
+% user to double the backslashes and otherwise make the string valid, so
+% that's what we do).
+
+% double active backslashes.
%
-% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
-% related messages. The final outcome is that it is up to the TeX user
-% to double the backslashes and otherwise make the string valid, so
-% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
-% do this reliably, so we use it.
-
-% #1 is a control sequence in which to do the replacements,
-% which we \xdef.
-\def\txiescapepdf#1{%
- \ifx\pdfescapestring\thisisundefined
- % No primitive available; should we give a warning or log?
- % Many times it won't matter.
- \else
- % The expandable \pdfescapestring primitive escapes parentheses,
- % backslashes, and other special chars.
- \xdef#1{\pdfescapestring{#1}}%
- \fi
+{\catcode`\@=0 \catcode`\\=\active
+ @gdef@activebackslashdouble{%
+ @catcode`@\=@active
+ @let\=@doublebackslash}
+}
+
+% To handle parens, we must adopt a different approach, since parens are
+% not active characters. hyperref.dtx (which has the same problem as
+% us) handles it with this amazing macro to replace tokens, with minor
+% changes for Texinfo. It is included here under the GPL by permission
+% from the author, Heiko Oberdiek.
+%
+% #1 is the tokens to replace.
+% #2 is the replacement.
+% #3 is the control sequence with the string.
+%
+\def\HyPsdSubst#1#2#3{%
+ \def\HyPsdReplace##1#1##2\END{%
+ ##1%
+ \ifx\\##2\\%
+ \else
+ #2%
+ \HyReturnAfterFi{%
+ \HyPsdReplace##2\END
+ }%
+ \fi
+ }%
+ \xdef#3{\expandafter\HyPsdReplace#3#1\END}%
+}
+\long\def\HyReturnAfterFi#1\fi{\fi#1}
+
+% #1 is a control sequence in which to do the replacements.
+\def\backslashparens#1{%
+ \xdef#1{#1}% redefine it as its expansion; the definition is simply
+ % \lastnode when called from \setref -> \pdfmkdest.
+ \HyPsdSubst{(}{\realbackslash(}{#1}%
+ \HyPsdSubst{)}{\realbackslash)}{#1}%
}
\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
@@ -1135,17 +1324,11 @@ output) for that.)}
\ifpdf
%
- % Color manipulation macros based on pdfcolor.tex,
- % except using rgb instead of cmyk; the latter is said to render as a
- % very dark gray on-screen and a very dark halftone in print, instead
- % of actual black.
- \def\rgbDarkRed{0.50 0.09 0.12}
- \def\rgbBlack{0 0 0}
- %
- % k sets the color for filling (usual text, etc.);
- % K sets the color for stroking (thin rules, e.g., normal _'s).
- \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
+ % Color manipulation macros based on pdfcolor.tex.
+ \def\cmykDarkRed{0.28 1 1 0.35}
+ \def\cmykBlack{0 0 0 1}
%
+ \def\pdfsetcolor#1{\pdfliteral{#1 k}}
% Set color, and create a mark which defines \thiscolor accordingly,
% so that \makeheadline knows which color to restore.
\def\setcolor#1{%
@@ -1154,7 +1337,7 @@ output) for that.)}
\pdfsetcolor{#1}%
}
%
- \def\maincolor{\rgbBlack}
+ \def\maincolor{\cmykBlack}
\pdfsetcolor{\maincolor}
\edef\thiscolor{\maincolor}
\def\lastcolordefs{}
@@ -1184,34 +1367,32 @@ output) for that.)}
%
% #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
\def\dopdfimage#1#2#3{%
- \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
- \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
+ \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
+ \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
%
- % pdftex (and the PDF format) support .pdf, .png, .jpg (among
- % others). Let's try in that order, PDF first since if
- % someone has a scalable image, presumably better to use that than a
- % bitmap.
+ % pdftex (and the PDF format) support .png, .jpg, .pdf (among
+ % others). Let's try in that order.
\let\pdfimgext=\empty
\begingroup
- \openin 1 #1.pdf \ifeof 1
- \openin 1 #1.PDF \ifeof 1
- \openin 1 #1.png \ifeof 1
- \openin 1 #1.jpg \ifeof 1
- \openin 1 #1.jpeg \ifeof 1
- \openin 1 #1.JPG \ifeof 1
+ \openin 1 #1.png \ifeof 1
+ \openin 1 #1.jpg \ifeof 1
+ \openin 1 #1.jpeg \ifeof 1
+ \openin 1 #1.JPG \ifeof 1
+ \openin 1 #1.pdf \ifeof 1
+ \openin 1 #1.PDF \ifeof 1
\errhelp = \nopdfimagehelp
\errmessage{Could not find image file #1 for pdf}%
- \else \gdef\pdfimgext{JPG}%
+ \else \gdef\pdfimgext{PDF}%
\fi
- \else \gdef\pdfimgext{jpeg}%
+ \else \gdef\pdfimgext{pdf}%
\fi
- \else \gdef\pdfimgext{jpg}%
+ \else \gdef\pdfimgext{JPG}%
\fi
- \else \gdef\pdfimgext{png}%
+ \else \gdef\pdfimgext{jpeg}%
\fi
- \else \gdef\pdfimgext{PDF}%
+ \else \gdef\pdfimgext{jpg}%
\fi
- \else \gdef\pdfimgext{pdf}%
+ \else \gdef\pdfimgext{png}%
\fi
\closein 1
\endgroup
@@ -1223,8 +1404,8 @@ output) for that.)}
\else
\immediate\pdfximage
\fi
- \ifdim \wd0 >0pt width \pdfimagewidth \fi
- \ifdim \wd2 >0pt height \pdfimageheight \fi
+ \ifdim \wd0 >0pt width \imagewidth \fi
+ \ifdim \wd2 >0pt height \imageheight \fi
\ifnum\pdftexversion<13
#1.\pdfimgext
\else
@@ -1239,9 +1420,10 @@ output) for that.)}
% such as \, aren't expanded when present in a section title.
\indexnofonts
\turnoffactive
+ \activebackslashdouble
\makevalueexpandable
\def\pdfdestname{#1}%
- \txiescapepdf\pdfdestname
+ \backslashparens\pdfdestname
\safewhatsit{\pdfdest name{\pdfdestname} xyz}%
}}
%
@@ -1250,8 +1432,8 @@ output) for that.)}
%
% by default, use a color that is dark enough to print on paper as
% nearly black, but still distinguishable for online viewing.
- \def\urlcolor{\rgbDarkRed}
- \def\linkcolor{\rgbDarkRed}
+ \def\urlcolor{\cmykDarkRed}
+ \def\linkcolor{\cmykDarkRed}
\def\endlink{\setcolor{\maincolor}\pdfendlink}
%
% Adding outlines to PDF; macros for calculating structure of outlines
@@ -1273,24 +1455,29 @@ output) for that.)}
% page number. We could generate a destination for the section
% text in the case where a section has no node, but it doesn't
% seem worth the trouble, since most documents are normally structured.
- \edef\pdfoutlinedest{#3}%
+ \def\pdfoutlinedest{#3}%
\ifx\pdfoutlinedest\empty
\def\pdfoutlinedest{#4}%
\else
- \txiescapepdf\pdfoutlinedest
+ % Doubled backslashes in the name.
+ {\activebackslashdouble \xdef\pdfoutlinedest{#3}%
+ \backslashparens\pdfoutlinedest}%
\fi
%
- % Also escape PDF chars in the display string.
- \edef\pdfoutlinetext{#1}%
- \txiescapepdf\pdfoutlinetext
+ % Also double the backslashes in the display string.
+ {\activebackslashdouble \xdef\pdfoutlinetext{#1}%
+ \backslashparens\pdfoutlinetext}%
%
\pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
}
%
\def\pdfmakeoutlines{%
\begingroup
+ % Thanh's hack / proper braces in bookmarks
+ \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
+ \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
+ %
% Read toc silently, to get counts of subentries for \pdfoutline.
- \def\partentry##1##2##3##4{}% ignore parts in the outlines
\def\numchapentry##1##2##3##4{%
\def\thischapnum{##2}%
\def\thissecnum{0}%
@@ -1344,41 +1531,25 @@ output) for that.)}
% Latin 2 (0xea) gets translated to a | character. Info from
% Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
%
- % TODO this right, we have to translate 8-bit characters to
- % their "best" equivalent, based on the @documentencoding. Too
- % much work for too little return. Just use the ASCII equivalents
- % we use for the index sort strings.
- %
+ % xx to do this right, we have to translate 8-bit characters to
+ % their "best" equivalent, based on the @documentencoding. Right
+ % now, I guess we'll just let the pdf reader have its way.
\indexnofonts
\setupdatafile
- % We can have normal brace characters in the PDF outlines, unlike
- % Texinfo index files. So set that up.
- \def\{{\lbracecharliteral}%
- \def\}{\rbracecharliteral}%
\catcode`\\=\active \otherbackslash
\input \tocreadfilename
\endgroup
}
- {\catcode`[=1 \catcode`]=2
- \catcode`{=\other \catcode`}=\other
- \gdef\lbracecharliteral[{]%
- \gdef\rbracecharliteral[}]%
- ]
%
\def\skipspaces#1{\def\PP{#1}\def\D{|}%
\ifx\PP\D\let\nextsp\relax
\else\let\nextsp\skipspaces
- \addtokens{\filename}{\PP}%
- \advance\filenamelength by 1
+ \ifx\p\space\else\addtokens{\filename}{\PP}%
+ \advance\filenamelength by 1
+ \fi
\fi
\nextsp}
- \def\getfilename#1{%
- \filenamelength=0
- % If we don't expand the argument now, \skipspaces will get
- % snagged on things like "@value{foo}".
- \edef\temp{#1}%
- \expandafter\skipspaces\temp|\relax
- }
+ \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
\ifnum\pdftexversion < 14
\let \startlink \pdfannotlink
\else
@@ -1391,15 +1562,11 @@ output) for that.)}
% tried to figure out what each command should do in the context
% of @url. for now, just make @/ a no-op, that's the only one
% people have actually reported a problem with.
- %
+ %
\normalturnoffactive
\def\@{@}%
\let\/=\empty
\makevalueexpandable
- % do we want to go so far as to use \indexnofonts instead of just
- % special-casing \var here?
- \def\var##1{##1}%
- %
\leavevmode\setcolor{\urlcolor}%
\startlink attr{/Border [0 0 0]}%
user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
@@ -1430,7 +1597,6 @@ output) for that.)}
\setcolor{\linkcolor}#1\endlink}
\def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
\else
- % non-pdf mode
\let\pdfmkdest = \gobble
\let\pdfurl = \gobble
\let\endlink = \relax
@@ -1461,10 +1627,6 @@ output) for that.)}
\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
\def\tt{\fam=\ttfam \setfontstyle{tt}}
-% Unfortunately, we have to override this for titles and the like, since
-% in those cases "rm" is bold. Sigh.
-\def\rmisbold{\rm\def\curfontstyle{bf}}
-
% Texinfo sort of supports the sans serif font style, which plain TeX does not.
% So we set up a \sf.
\newfam\sffam
@@ -1475,6 +1637,9 @@ output) for that.)}
\def\ttsl{\setfontstyle{ttsl}}
+% Default leading.
+\newdimen\textleading \textleading = 13.2pt
+
% Set the baselineskip to #1, and the lineskip and strut size
% correspondingly. There is no deep meaning behind these magic numbers
% used as factors; they just match (closely enough) what Knuth defined.
@@ -1486,7 +1651,6 @@ output) for that.)}
% can get a sort of poor man's double spacing by redefining this.
\def\baselinefactor{1}
%
-\newdimen\textleading
\def\setleading#1{%
\dimen0 = #1\relax
\normalbaselineskip = \baselinefactor\dimen0
@@ -1508,7 +1672,7 @@ output) for that.)}
% if we are producing pdf, and we have \pdffontattr, then define cmaps.
% (\pdffontattr was introduced many years ago, but people still run
% older pdftex's; it's easy to conditionalize, so we do.)
-\ifpdf \ifx\pdffontattr\thisisundefined \else
+\ifpdf \ifx\pdffontattr\undefined \else
\begingroup
\catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
\catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
@@ -1759,34 +1923,28 @@ end
\fi\fi
-% Set the font macro #1 to the font named \fontprefix#2.
+% Set the font macro #1 to the font named #2, adding on the
+% specified font prefix (normally `cm').
% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
-% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
-% Example:
-% #1 = \textrm
-% #2 = \rmshape
-% #3 = 10
-% #4 = \mainmagstep
-% #5 = OT1
-%
+% encoding (currently only OT1, OT1IT and OT1TT are allowed, pass
+% empty to omit).
\def\setfont#1#2#3#4#5{%
\font#1=\fontprefix#2#3 scaled #4
\csname cmap#5\endcsname#1%
}
% This is what gets called when #5 of \setfont is empty.
\let\cmap\gobble
-%
-% (end of cmaps)
+% emacs-page end of cmaps
% Use cm as the default font prefix.
% To specify the font prefix, you must define \fontprefix
% before you read in texinfo.tex.
-\ifx\fontprefix\thisisundefined
+\ifx\fontprefix\undefined
\def\fontprefix{cm}
\fi
% Support font families that don't use the same naming scheme as CM.
\def\rmshape{r}
-\def\rmbshape{bx} % where the normal face is bold
+\def\rmbshape{bx} %where the normal face is bold
\def\bfshape{b}
\def\bxshape{bx}
\def\ttshape{tt}
@@ -1801,8 +1959,9 @@ end
\def\scshape{csc}
\def\scbshape{csc}
-% Definitions for a main text size of 11pt. (The default in Texinfo.)
-%
+% Definitions for a main text size of 11pt. This is the default in
+% Texinfo.
+%
\def\definetextfontsizexi{%
% Text fonts (11.2pt, magstep1).
\def\textnominalsize{11pt}
@@ -1865,6 +2024,8 @@ end
\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
\font\titlei=cmmi12 scaled \magstep3
\font\titlesy=cmsy10 scaled \magstep4
+\def\authorrm{\secrm}
+\def\authortt{\sectt}
\def\titleecsize{2074}
% Chapter (and unnumbered) fonts (17.28pt).
@@ -1923,17 +2084,17 @@ end
\font\reducedsy=cmsy10
\def\reducedecsize{1000}
-\textleading = 13.2pt % line spacing for 11pt CM
-\textfonts % reset the current fonts
+% reset the current fonts
+\textfonts
\rm
-} % end of 11pt text font size definitions, \definetextfontsizexi
+} % end of 11pt text font size definitions
% Definitions to make the main text be 10pt Computer Modern, with
% section, chapter, etc., sizes following suit. This is for the GNU
% Press printing of the Emacs 22 manual. Maybe other manuals in the
% future. Used with @smallbook, which sets the leading to 12pt.
-%
+%
\def\definetextfontsizex{%
% Text fonts (10pt).
\def\textnominalsize{10pt}
@@ -1996,6 +2157,8 @@ end
\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
\font\titlei=cmmi12 scaled \magstep3
\font\titlesy=cmsy10 scaled \magstep4
+\def\authorrm{\secrm}
+\def\authortt{\sectt}
\def\titleecsize{2074}
% Chapter fonts (14.4pt).
@@ -2022,7 +2185,7 @@ end
\setfont\secsf\sfbshape{12}{1000}{OT1}
\let\secbf\secrm
\setfont\secsc\scbshape{10}{\magstep1}{OT1}
-\font\seci=cmmi12
+\font\seci=cmmi12
\font\secsy=cmsy10 scaled \magstep1
\def\sececsize{1200}
@@ -2054,28 +2217,29 @@ end
\font\reducedsy=cmsy9
\def\reducedecsize{0900}
-\divide\parskip by 2 % reduce space between paragraphs
-\textleading = 12pt % line spacing for 10pt CM
-\textfonts % reset the current fonts
+% reduce space between paragraphs
+\divide\parskip by 2
+
+% reset the current fonts
+\textfonts
\rm
-} % end of 10pt text font size definitions, \definetextfontsizex
+} % end of 10pt text font size definitions
% We provide the user-level command
% @fonttextsize 10
% (or 11) to redefine the text font size. pt is assumed.
-%
-\def\xiword{11}
+%
\def\xword{10}
-\def\xwordpt{10pt}
+\def\xiword{11}
%
\parseargdef\fonttextsize{%
\def\textsizearg{#1}%
- %\wlog{doing @fonttextsize \textsizearg}%
+ \wlog{doing @fonttextsize \textsizearg}%
%
% Set \globaldefs so that documents can use this inside @tex, since
% makeinfo 4.8 does not support it, but we need it nonetheless.
- %
+ %
\begingroup \globaldefs=1
\ifx\textsizearg\xword \definetextfontsizex
\else \ifx\textsizearg\xiword \definetextfontsizexi
@@ -2125,8 +2289,8 @@ end
\let\tenttsl=\titlettsl
\def\curfontsize{title}%
\def\lsize{chap}\def\lllsize{subsec}%
- \resetmathfonts \setleading{27pt}}
-\def\titlefont#1{{\titlefonts\rmisbold #1}}
+ \resetmathfonts \setleading{25pt}}
+\def\titlefont#1{{\titlefonts\rm #1}}
\def\chapfonts{%
\let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
\let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
@@ -2177,16 +2341,6 @@ end
\def\lsize{smaller}\def\lllsize{smaller}%
\resetmathfonts \setleading{9.5pt}}
-% Fonts for short table of contents.
-\setfont\shortcontrm\rmshape{12}{1000}{OT1}
-\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
-\setfont\shortcontsl\slshape{12}{1000}{OT1}
-\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
-
-% Define these just so they can be easily changed for other fonts.
-\def\angleleft{$\langle$}
-\def\angleright{$\rangle$}
-
% Set the fonts to use with the @small... environments.
\let\smallexamplefonts = \smallfonts
@@ -2200,213 +2354,53 @@ end
%
% By the way, for comparison, here's what fits with @example (10pt):
% 8.5x11=71 smallbook=60 a4=75 a5=58
+%
+% I wish the USA used A4 paper.
% --karl, 24jan03.
+
% Set up the default fonts, so we can use them for creating boxes.
%
\definetextfontsizexi
-
-\message{markup,}
-
-% Check if we are currently using a typewriter font. Since all the
-% Computer Modern typewriter fonts have zero interword stretch (and
-% shrink), and it is reasonable to expect all typewriter fonts to have
-% this property, we can check that font parameter.
-%
-\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
-
-% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
-% define and register \INITMACRO to be called on markup style changes.
-% \INITMACRO can check \currentmarkupstyle for the innermost
-% style and the set of \ifmarkupSTYLE switches for all styles
-% currently in effect.
-\newif\ifmarkupvar
-\newif\ifmarkupsamp
-\newif\ifmarkupkey
-%\newif\ifmarkupfile % @file == @samp.
-%\newif\ifmarkupoption % @option == @samp.
-\newif\ifmarkupcode
-\newif\ifmarkupkbd
-%\newif\ifmarkupenv % @env == @code.
-%\newif\ifmarkupcommand % @command == @code.
-\newif\ifmarkuptex % @tex (and part of @math, for now).
-\newif\ifmarkupexample
-\newif\ifmarkupverb
-\newif\ifmarkupverbatim
-
-\let\currentmarkupstyle\empty
-
-\def\setupmarkupstyle#1{%
- \csname markup#1true\endcsname
- \def\currentmarkupstyle{#1}%
- \markupstylesetup
-}
-
-\let\markupstylesetup\empty
-
-\def\defmarkupstylesetup#1{%
- \expandafter\def\expandafter\markupstylesetup
- \expandafter{\markupstylesetup #1}%
- \def#1%
-}
-
-% Markup style setup for left and right quotes.
-\defmarkupstylesetup\markupsetuplq{%
- \expandafter\let\expandafter \temp
- \csname markupsetuplq\currentmarkupstyle\endcsname
- \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
-}
-
-\defmarkupstylesetup\markupsetuprq{%
- \expandafter\let\expandafter \temp
- \csname markupsetuprq\currentmarkupstyle\endcsname
- \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
-}
-
-{
-\catcode`\'=\active
-\catcode`\`=\active
-
-\gdef\markupsetuplqdefault{\let`\lq}
-\gdef\markupsetuprqdefault{\let'\rq}
-
-\gdef\markupsetcodequoteleft{\let`\codequoteleft}
-\gdef\markupsetcodequoteright{\let'\codequoteright}
-}
-
-\let\markupsetuplqcode \markupsetcodequoteleft
-\let\markupsetuprqcode \markupsetcodequoteright
-%
-\let\markupsetuplqexample \markupsetcodequoteleft
-\let\markupsetuprqexample \markupsetcodequoteright
-%
-\let\markupsetuplqkbd \markupsetcodequoteleft
-\let\markupsetuprqkbd \markupsetcodequoteright
-%
-\let\markupsetuplqsamp \markupsetcodequoteleft
-\let\markupsetuprqsamp \markupsetcodequoteright
-%
-\let\markupsetuplqverb \markupsetcodequoteleft
-\let\markupsetuprqverb \markupsetcodequoteright
-%
-\let\markupsetuplqverbatim \markupsetcodequoteleft
-\let\markupsetuprqverbatim \markupsetcodequoteright
-
-% Allow an option to not use regular directed right quote/apostrophe
-% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
-% The undirected quote is ugly, so don't make it the default, but it
-% works for pasting with more pdf viewers (at least evince), the
-% lilypond developers report. xpdf does work with the regular 0x27.
-%
-\def\codequoteright{%
- \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
- \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
- '%
- \else \char'15 \fi
- \else \char'15 \fi
-}
-%
-% and a similar option for the left quote char vs. a grave accent.
-% Modern fonts display ASCII 0x60 as a grave accent, so some people like
-% the code environments to do likewise.
-%
-\def\codequoteleft{%
- \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
- \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
- % [Knuth] pp. 380,381,391
- % \relax disables Spanish ligatures ?` and !` of \tt font.
- \relax`%
- \else \char'22 \fi
- \else \char'22 \fi
-}
-
-% Commands to set the quote options.
-%
-\parseargdef\codequoteundirected{%
- \def\temp{#1}%
- \ifx\temp\onword
- \expandafter\let\csname SETtxicodequoteundirected\endcsname
- = t%
- \else\ifx\temp\offword
- \expandafter\let\csname SETtxicodequoteundirected\endcsname
- = \relax
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
- \fi\fi
-}
-%
-\parseargdef\codequotebacktick{%
- \def\temp{#1}%
- \ifx\temp\onword
- \expandafter\let\csname SETtxicodequotebacktick\endcsname
- = t%
- \else\ifx\temp\offword
- \expandafter\let\csname SETtxicodequotebacktick\endcsname
- = \relax
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
- \fi\fi
-}
-
-% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
-\def\noligaturesquoteleft{\relax\lq}
+% Define these so they can be easily changed for other fonts.
+\def\angleleft{$\langle$}
+\def\angleright{$\rangle$}
% Count depth in font-changes, for error checks
\newcount\fontdepth \fontdepth=0
-% Font commands.
+% Fonts for short table of contents.
+\setfont\shortcontrm\rmshape{12}{1000}{OT1}
+\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
+\setfont\shortcontsl\slshape{12}{1000}{OT1}
+\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
-% #1 is the font command (\sl or \it), #2 is the text to slant.
-% If we are in a monospaced environment, however, 1) always use \ttsl,
-% and 2) do not add an italic correction.
-\def\dosmartslant#1#2{%
- \ifusingtt
- {{\ttsl #2}\let\next=\relax}%
- {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
- \next
-}
-\def\smartslanted{\dosmartslant\sl}
-\def\smartitalic{\dosmartslant\it}
+%% Add scribe-like font environments, plus @l for inline lisp (usually sans
+%% serif) and @ii for TeX italic
-% Output an italic correction unless \next (presumed to be the following
-% character) is such as not to need one.
-\def\smartitaliccorrection{%
- \ifx\next,%
- \else\ifx\next-%
- \else\ifx\next.%
- \else\ptexslash
- \fi\fi\fi
- \aftersmartic
-}
+% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
+% unless the following character is such as not to need one.
+\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else
+ \ptexslash\fi\fi\fi}
+\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx}
+\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx}
-% Unconditional use \ttsl, and no ic. @var is set to this for defuns.
-\def\ttslanted#1{{\ttsl #1}}
+% like \smartslanted except unconditionally uses \ttsl.
+% @var is set to this for defun arguments.
+\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx}
-% @cite is like \smartslanted except unconditionally use \sl. We never want
+% like \smartslanted except unconditionally use \sl. We never want
% ttsl for book titles, do we?
-\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
-
-\def\aftersmartic{}
-\def\var#1{%
- \let\saveaftersmartic = \aftersmartic
- \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
- \smartslanted{#1}%
-}
+\def\cite#1{{\sl #1}\futurelet\next\smartitalicx}
\let\i=\smartitalic
\let\slanted=\smartslanted
+\let\var=\smartslanted
\let\dfn=\smartslanted
\let\emph=\smartitalic
-% Explicit font changes: @r, @sc, undocumented @ii.
-\def\r#1{{\rm #1}} % roman font
-\def\sc#1{{\smallcaps#1}} % smallcaps font
-\def\ii#1{{\it #1}} % italic font
-
-% @b, explicit bold. Also @strong.
+% @b, explicit bold.
\def\b#1{{\bf #1}}
\let\strong=\b
@@ -2438,21 +2432,30 @@ end
\catcode`@=\other
\def\endofsentencespacefactor{3000}% default
-% @t, explicit typewriter.
\def\t#1{%
{\tt \rawbackslash \plainfrenchspacing #1}%
\null
}
+\def\samp#1{`\tclose{#1}'\null}
+\setfont\keyrm\rmshape{8}{1000}{OT1}
+\font\keysy=cmsy9
+\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
+ \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
+ \vbox{\hrule\kern-0.4pt
+ \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
+ \kern-0.4pt\hrule}%
+ \kern-.06em\raise0.4pt\hbox{\angleright}}}}
+\def\key #1{{\nohyphenation \uppercase{#1}}\null}
+% The old definition, with no lozenge:
+%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
+\def\ctrl #1{{\tt \rawbackslash \hat}#1}
-% @samp.
-\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
-
-% @indicateurl is \samp, that is, with quotes.
-\let\indicateurl=\samp
+% @file, @option are the same as @samp.
+\let\file=\samp
+\let\option=\samp
-% @code (and similar) prints in typewriter, but with spaces the same
-% size as normal in the surrounding text, without hyphenation, etc.
-% This is a subroutine for that.
+% @code is a modification of @t,
+% which makes spaces the same size as normal in the surrounding text.
\def\tclose#1{%
{%
% Change normal interword space to be same as for the current font.
@@ -2471,13 +2474,13 @@ end
\plainfrenchspacing
#1%
}%
- \null % reset spacefactor to 1000
+ \null
}
% We *must* turn on hyphenation at `-' and `_' in @code.
% Otherwise, it is too hard to avoid overfull hboxes
% in the Emacs manual, the Library manual, etc.
-%
+
% Unfortunately, TeX uses one parameter (\hyphenchar) to control
% both hyphenation at - and hyphenation within words.
% We must therefore turn them both off (\tclose does that)
@@ -2486,26 +2489,24 @@ end
{
\catcode`\-=\active \catcode`\_=\active
\catcode`\'=\active \catcode`\`=\active
- \global\let'=\rq \global\let`=\lq % default definitions
%
\global\def\code{\begingroup
- \setupmarkupstyle{code}%
- % The following should really be moved into \setupmarkupstyle handlers.
+ \catcode\rquoteChar=\active \catcode\lquoteChar=\active
+ \let'\codequoteright \let`\codequoteleft
+ %
\catcode\dashChar=\active \catcode\underChar=\active
\ifallowcodebreaks
\let-\codedash
\let_\codeunder
\else
- \let-\normaldash
+ \let-\realdash
\let_\realunder
\fi
\codex
}
}
-\def\codex #1{\tclose{#1}\endgroup}
-
-\def\normaldash{-}
+\def\realdash{-}
\def\codedash{-\discretionary{}{}{}}
\def\codeunder{%
% this is all so @math{@code{var_name}+1} can work. In math mode, _
@@ -2518,12 +2519,13 @@ end
\discretionary{}{}{}}%
{\_}%
}
+\def\codex #1{\tclose{#1}\endgroup}
% An additional complication: the above will allow breaks after, e.g.,
-% each of the four underscores in __typeof__. This is bad.
-% @allowcodebreaks provides a document-level way to turn breaking at -
-% and _ on and off.
-%
+% each of the four underscores in __typeof__. This is undesirable in
+% some manuals, especially if they don't have long identifiers in
+% general. @allowcodebreaks provides a way to control this.
+%
\newif\ifallowcodebreaks \allowcodebreakstrue
\def\keywordtrue{true}
@@ -2537,25 +2539,62 @@ end
\allowcodebreaksfalse
\else
\errhelp = \EMsimple
- \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
+ \errmessage{Unknown @allowcodebreaks option `\txiarg'}%
\fi\fi
}
-% For @command, @env, @file, @option quotes seem unnecessary,
-% so use \code rather than \samp.
-\let\command=\code
+% @kbd is like @code, except that if the argument is just one @key command,
+% then @kbd has no effect.
+
+% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
+% `example' (@kbd uses ttsl only inside of @example and friends),
+% or `code' (@kbd uses normal tty font always).
+\parseargdef\kbdinputstyle{%
+ \def\txiarg{#1}%
+ \ifx\txiarg\worddistinct
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
+ \else\ifx\txiarg\wordexample
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
+ \else\ifx\txiarg\wordcode
+ \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @kbdinputstyle option `\txiarg'}%
+ \fi\fi\fi
+}
+\def\worddistinct{distinct}
+\def\wordexample{example}
+\def\wordcode{code}
+
+% Default is `distinct.'
+\kbdinputstyle distinct
+
+\def\xkey{\key}
+\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
+\ifx\one\xkey\ifx\threex\three \key{#2}%
+\else{\tclose{\kbdfont\look}}\fi
+\else{\tclose{\kbdfont\look}}\fi}
+
+% For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
+\let\indicateurl=\code
\let\env=\code
-\let\file=\code
-\let\option=\code
+\let\command=\code
+
+% @clicksequence{File @click{} Open ...}
+\def\clicksequence#1{\begingroup #1\endgroup}
+
+% @clickstyle @arrow (by default)
+\parseargdef\clickstyle{\def\click{#1}}
+\def\click{\arrow}
% @uref (abbreviation for `urlref') takes an optional (comma-separated)
% second argument specifying the text to display and an optional third
% arg as text to display instead of (rather than in addition to) the url
-% itself. First (mandatory) arg is the url.
-% (This \urefnobreak definition isn't used now, leaving it for a while
-% for comparison.)
-\def\urefnobreak#1{\dourefnobreak #1,,,\finish}
-\def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
+% itself. First (mandatory) arg is the url. Perhaps eventually put in
+% a hypertex \special here.
+%
+\def\uref#1{\douref #1,,,\finish}
+\def\douref#1,#2,#3,#4\finish{\begingroup
\unsepspaces
\pdfurl{#1}%
\setbox0 = \hbox{\ignorespaces #3}%
@@ -2576,103 +2615,6 @@ end
\endlink
\endgroup}
-% This \urefbreak definition is the active one.
-\def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
-\let\uref=\urefbreak
-\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
-\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
- \unsepspaces
- \pdfurl{#1}%
- \setbox0 = \hbox{\ignorespaces #3}%
- \ifdim\wd0 > 0pt
- \unhbox0 % third arg given, show only that
- \else
- \setbox0 = \hbox{\ignorespaces #2}%
- \ifdim\wd0 > 0pt
- \ifpdf
- \unhbox0 % PDF: 2nd arg given, show only it
- \else
- \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
- \fi
- \else
- \urefcode{#1}% only url given, so show it
- \fi
- \fi
- \endlink
-\endgroup}
-
-% Allow line breaks around only a few characters (only).
-\def\urefcatcodes{%
- \catcode\ampChar=\active \catcode\dotChar=\active
- \catcode\hashChar=\active \catcode\questChar=\active
- \catcode\slashChar=\active
-}
-{
- \urefcatcodes
- %
- \global\def\urefcode{\begingroup
- \setupmarkupstyle{code}%
- \urefcatcodes
- \let&\urefcodeamp
- \let.\urefcodedot
- \let#\urefcodehash
- \let?\urefcodequest
- \let/\urefcodeslash
- \codex
- }
- %
- % By default, they are just regular characters.
- \global\def&{\normalamp}
- \global\def.{\normaldot}
- \global\def#{\normalhash}
- \global\def?{\normalquest}
- \global\def/{\normalslash}
-}
-
-% we put a little stretch before and after the breakable chars, to help
-% line breaking of long url's. The unequal skips make look better in
-% cmtt at least, especially for dots.
-\def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
-\def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
-%
-\def\urefcodeamp{\urefprestretch \&\urefpoststretch}
-\def\urefcodedot{\urefprestretch .\urefpoststretch}
-\def\urefcodehash{\urefprestretch \#\urefpoststretch}
-\def\urefcodequest{\urefprestretch ?\urefpoststretch}
-\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
-{
- \catcode`\/=\active
- \global\def\urefcodeslashfinish{%
- \urefprestretch \slashChar
- % Allow line break only after the final / in a sequence of
- % slashes, to avoid line break between the slashes in http://.
- \ifx\next/\else \urefpoststretch \fi
- }
-}
-
-% One more complication: by default we'll break after the special
-% characters, but some people like to break before the special chars, so
-% allow that. Also allow no breaking at all, for manual control.
-%
-\parseargdef\urefbreakstyle{%
- \def\txiarg{#1}%
- \ifx\txiarg\wordnone
- \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
- \else\ifx\txiarg\wordbefore
- \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
- \else\ifx\txiarg\wordafter
- \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
- \fi\fi\fi
-}
-\def\wordafter{after}
-\def\wordbefore{before}
-\def\wordnone{none}
-
-\urefbreakstyle after
-
% @url synonym for @uref, since that's how everyone uses it.
%
\let\url=\uref
@@ -2694,81 +2636,34 @@ end
\let\email=\uref
\fi
-% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
-% `example' (@kbd uses ttsl only inside of @example and friends),
-% or `code' (@kbd uses normal tty font always).
-\parseargdef\kbdinputstyle{%
- \def\txiarg{#1}%
- \ifx\txiarg\worddistinct
- \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
- \else\ifx\txiarg\wordexample
- \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
- \else\ifx\txiarg\wordcode
- \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
- \fi\fi\fi
-}
-\def\worddistinct{distinct}
-\def\wordexample{example}
-\def\wordcode{code}
-
-% Default is `distinct'.
-\kbdinputstyle distinct
-
-% @kbd is like @code, except that if the argument is just one @key command,
-% then @kbd has no effect.
-\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
-
-\def\xkey{\key}
-\def\kbdsub#1#2#3\par{%
- \def\one{#1}\def\three{#3}\def\threex{??}%
- \ifx\one\xkey\ifx\threex\three \key{#2}%
- \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
- \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
-}
-
-% definition of @key that produces a lozenge. Doesn't adjust to text size.
-%\setfont\keyrm\rmshape{8}{1000}{OT1}
-%\font\keysy=cmsy9
-%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
-% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
-% \vbox{\hrule\kern-0.4pt
-% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
-% \kern-0.4pt\hrule}%
-% \kern-.06em\raise0.4pt\hbox{\angleright}}}}
-
-% definition of @key with no lozenge. If the current font is already
-% monospace, don't change it; that way, we respect @kbdinputstyle. But
-% if it isn't monospace, then use \tt.
-%
-\def\key#1{{\setupmarkupstyle{key}%
- \nohyphenation
- \ifmonospace\else\tt\fi
- #1}\null}
-
-% @clicksequence{File @click{} Open ...}
-\def\clicksequence#1{\begingroup #1\endgroup}
-
-% @clickstyle @arrow (by default)
-\parseargdef\clickstyle{\def\click{#1}}
-\def\click{\arrow}
+% Check if we are currently using a typewriter font. Since all the
+% Computer Modern typewriter fonts have zero interword stretch (and
+% shrink), and it is reasonable to expect all typewriter fonts to have
+% this property, we can check that font parameter.
+%
+\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
%
\def\dmn#1{\thinspace #1}
+\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
+
% @l was never documented to mean ``switch to the Lisp font'',
% and it is not used as such in any manual I can find. We need it for
% Polish suppressed-l. --karl, 22sep96.
%\def\l#1{{\li #1}\null}
+% Explicit font changes: @r, @sc, undocumented @ii.
+\def\r#1{{\rm #1}} % roman font
+\def\sc#1{{\smallcaps#1}} % smallcaps font
+\def\ii#1{{\it #1}} % italic font
+
% @acronym for "FBI", "NATO", and the like.
% We print this one point size smaller, since it's intended for
% all-uppercase.
-%
+%
\def\acronym#1{\doacronym #1,,\finish}
\def\doacronym#1,#2,#3\finish{%
{\selectfonts\lsize #1}%
@@ -2776,12 +2671,11 @@ end
\ifx\temp\empty \else
\space ({\unsepspaces \ignorespaces \temp \unskip})%
\fi
- \null % reset \spacefactor=1000
}
% @abbr for "Comput. J." and the like.
% No font change, but don't do end-of-sentence spacing.
-%
+%
\def\abbr#1{\doabbr #1,,\finish}
\def\doabbr#1,#2,#3\finish{%
{\plainfrenchspacing #1}%
@@ -2789,258 +2683,8 @@ end
\ifx\temp\empty \else
\space ({\unsepspaces \ignorespaces \temp \unskip})%
\fi
- \null % reset \spacefactor=1000
-}
-
-% @asis just yields its argument. Used with @table, for example.
-%
-\def\asis#1{#1}
-
-% @math outputs its argument in math mode.
-%
-% One complication: _ usually means subscripts, but it could also mean
-% an actual _ character, as in @math{@var{some_variable} + 1}. So make
-% _ active, and distinguish by seeing if the current family is \slfam,
-% which is what @var uses.
-{
- \catcode`\_ = \active
- \gdef\mathunderscore{%
- \catcode`\_=\active
- \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
- }
-}
-% Another complication: we want \\ (and @\) to output a math (or tt) \.
-% FYI, plain.tex uses \\ as a temporary control sequence (for no
-% particular reason), but this is not advertised and we don't care.
-%
-% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
-\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
-%
-\def\math{%
- \tex
- \mathunderscore
- \let\\ = \mathbackslash
- \mathactive
- % make the texinfo accent commands work in math mode
- \let\"=\ddot
- \let\'=\acute
- \let\==\bar
- \let\^=\hat
- \let\`=\grave
- \let\u=\breve
- \let\v=\check
- \let\~=\tilde
- \let\dotaccent=\dot
- $\finishmath
-}
-\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
-
-% Some active characters (such as <) are spaced differently in math.
-% We have to reset their definitions in case the @math was an argument
-% to a command which sets the catcodes (such as @item or @section).
-%
-{
- \catcode`^ = \active
- \catcode`< = \active
- \catcode`> = \active
- \catcode`+ = \active
- \catcode`' = \active
- \gdef\mathactive{%
- \let^ = \ptexhat
- \let< = \ptexless
- \let> = \ptexgtr
- \let+ = \ptexplus
- \let' = \ptexquoteright
- }
-}
-
-% ctrl is no longer a Texinfo command, but leave this definition for fun.
-\def\ctrl #1{{\tt \rawbackslash \hat}#1}
-
-% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
-% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
-% except specified as a normal braced arg, so no newlines to worry about.
-%
-\def\outfmtnametex{tex}
-%
-\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
-\long\def\doinlinefmt#1,#2,\finish{%
- \def\inlinefmtname{#1}%
- \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
-}
-% For raw, must switch into @tex before parsing the argument, to avoid
-% setting catcodes prematurely. Doing it this way means that, for
-% example, @inlineraw{html, foo{bar} gets a parse error instead of being
-% ignored. But this isn't important because if people want a literal
-% *right* brace they would have to use a command anyway, so they may as
-% well use a command to get a left brace too. We could re-use the
-% delimiter character idea from \verb, but it seems like overkill.
-%
-\long\def\inlineraw{\tex \doinlineraw}
-\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
-\def\doinlinerawtwo#1,#2,\finish{%
- \def\inlinerawname{#1}%
- \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
- \endgroup % close group opened by \tex.
-}
-
-
-\message{glyphs,}
-% and logos.
-
-% @@ prints an @, as does @atchar{}.
-\def\@{\char64 }
-\let\atchar=\@
-
-% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
-% Unless we're in typewriter, use \ecfont because the CM text fonts do
-% not have braces, and we don't want to switch into math.
-\def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
-\def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
-\let\{=\mylbrace \let\lbracechar=\{
-\let\}=\myrbrace \let\rbracechar=\}
-\begingroup
- % Definitions to produce \{ and \} commands for indices,
- % and @{ and @} for the aux/toc files.
- \catcode`\{ = \other \catcode`\} = \other
- \catcode`\[ = 1 \catcode`\] = 2
- \catcode`\! = 0 \catcode`\\ = \other
- !gdef!lbracecmd[\{]%
- !gdef!rbracecmd[\}]%
- !gdef!lbraceatcmd[@{]%
- !gdef!rbraceatcmd[@}]%
-!endgroup
-
-% @comma{} to avoid , parsing problems.
-\let\comma = ,
-
-% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
-% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
-\let\, = \ptexc
-\let\dotaccent = \ptexdot
-\def\ringaccent#1{{\accent23 #1}}
-\let\tieaccent = \ptext
-\let\ubaraccent = \ptexb
-\let\udotaccent = \d
-
-% Other special characters: @questiondown @exclamdown @ordf @ordm
-% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
-\def\questiondown{?`}
-\def\exclamdown{!`}
-\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
-\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
-
-% Dotless i and dotless j, used for accents.
-\def\imacro{i}
-\def\jmacro{j}
-\def\dotless#1{%
- \def\temp{#1}%
- \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
- \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
- \else \errmessage{@dotless can be used only with i or j}%
- \fi\fi
-}
-
-% The \TeX{} logo, as in plain, but resetting the spacing so that a
-% period following counts as ending a sentence. (Idea found in latex.)
-%
-\edef\TeX{\TeX \spacefactor=1000 }
-
-% @LaTeX{} logo. Not quite the same results as the definition in
-% latex.ltx, since we use a different font for the raised A; it's most
-% convenient for us to use an explicitly smaller font, rather than using
-% the \scriptstyle font (since we don't reset \scriptstyle and
-% \scriptscriptstyle).
-%
-\def\LaTeX{%
- L\kern-.36em
- {\setbox0=\hbox{T}%
- \vbox to \ht0{\hbox{%
- \ifx\textnominalsize\xwordpt
- % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
- % Revert to plain's \scriptsize, which is 7pt.
- \count255=\the\fam $\fam\count255 \scriptstyle A$%
- \else
- % For 11pt, we can use our lllsize.
- \selectfonts\lllsize A%
- \fi
- }%
- \vss
- }}%
- \kern-.15em
- \TeX
-}
-
-% Some math mode symbols.
-\def\bullet{$\ptexbullet$}
-\def\geq{\ifmmode \ge\else $\ge$\fi}
-\def\leq{\ifmmode \le\else $\le$\fi}
-\def\minus{\ifmmode -\else $-$\fi}
-
-% @dots{} outputs an ellipsis using the current font.
-% We do .5em per period so that it has the same spacing in the cm
-% typewriter fonts as three actual period characters; on the other hand,
-% in other typewriter fonts three periods are wider than 1.5em. So do
-% whichever is larger.
-%
-\def\dots{%
- \leavevmode
- \setbox0=\hbox{...}% get width of three periods
- \ifdim\wd0 > 1.5em
- \dimen0 = \wd0
- \else
- \dimen0 = 1.5em
- \fi
- \hbox to \dimen0{%
- \hskip 0pt plus.25fil
- .\hskip 0pt plus1fil
- .\hskip 0pt plus1fil
- .\hskip 0pt plus.5fil
- }%
}
-% @enddots{} is an end-of-sentence ellipsis.
-%
-\def\enddots{%
- \dots
- \spacefactor=\endofsentencespacefactor
-}
-
-% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
-%
-% Since these characters are used in examples, they should be an even number of
-% \tt widths. Each \tt character is 1en, so two makes it 1em.
-%
-\def\point{$\star$}
-\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
-\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
-\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
-\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
-\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
-
-% The @error{} command.
-% Adapted from the TeXbook's \boxit.
-%
-\newbox\errorbox
-%
-{\tentt \global\dimen0 = 3em}% Width of the box.
-\dimen2 = .55pt % Thickness of rules
-% The text. (`r' is open on the right, `e' somewhat less so on the left.)
-\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
-%
-\setbox\errorbox=\hbox to \dimen0{\hfil
- \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
- \advance\hsize by -2\dimen2 % Rules.
- \vbox{%
- \hrule height\dimen2
- \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
- \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
- \kern3pt\vrule width\dimen2}% Space to right.
- \hrule height\dimen2}
- \hfil}
-%
-\def\error{\leavevmode\lower.7ex\copy\errorbox}
-
% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
%
\def\pounds{{\it\$}}
@@ -3050,59 +2694,52 @@ end
% Theiling, which support regular, slanted, bold and bold slanted (and
% "outlined" (blackboard board, sort of) versions, which we don't need).
% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
-%
+%
% Although only regular is the truly official Euro symbol, we ignore
% that. The Euro is designed to be slightly taller than the regular
% font height.
-%
+%
% feymr - regular
% feymo - slanted
% feybr - bold
% feybo - bold slanted
-%
+%
% There is no good (free) typewriter version, to my knowledge.
% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
% Hmm.
-%
+%
% Also doesn't work in math. Do we need to do math with euro symbols?
% Hope not.
-%
-%
+%
+%
\def\euro{{\eurofont e}}
\def\eurofont{%
% We set the font at each command, rather than predefining it in
% \textfonts and the other font-switching commands, so that
% installations which never need the symbol don't have to have the
% font installed.
- %
+ %
% There is only one designed size (nominal 10pt), so we always scale
% that to the current nominal size.
- %
+ %
% By the way, simply using "at 1em" works for cmr10 and the like, but
% does not work for cmbx10 and other extended/shrunken fonts.
- %
+ %
\def\eurosize{\csname\curfontsize nominalsize\endcsname}%
%
- \ifx\curfontstyle\bfstylename
+ \ifx\curfontstyle\bfstylename
% bold:
\font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
- \else
+ \else
% regular:
\font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
\fi
\thiseurofont
}
-% Glyphs from the EC fonts. We don't use \let for the aliases, because
-% sometimes we redefine the original macro, and the alias should reflect
-% the redefinition.
-%
-% Use LaTeX names for the Icelandic letters.
-\def\DH{{\ecfont \char"D0}} % Eth
-\def\dh{{\ecfont \char"F0}} % eth
-\def\TH{{\ecfont \char"DE}} % Thorn
-\def\th{{\ecfont \char"FE}} % thorn
-%
+% Hacks for glyphs from the EC fonts similar to \euro. We don't
+% use \let for the aliases, because sometimes we redefine the original
+% macro, and the alias should reflect the redefinition.
\def\guillemetleft{{\ecfont \char"13}}
\def\guillemotleft{\guillemetleft}
\def\guillemetright{{\ecfont \char"14}}
@@ -3112,52 +2749,19 @@ end
\def\quotedblbase{{\ecfont \char"12}}
\def\quotesinglbase{{\ecfont \char"0D}}
%
-% This positioning is not perfect (see the ogonek LaTeX package), but
-% we have the precomposed glyphs for the most common cases. We put the
-% tests to use those glyphs in the single \ogonek macro so we have fewer
-% dummy definitions to worry about for index entries, etc.
-%
-% ogonek is also used with other letters in Lithuanian (IOU), but using
-% the precomposed glyphs for those is not so easy since they aren't in
-% the same EC font.
-\def\ogonek#1{{%
- \def\temp{#1}%
- \ifx\temp\macrocharA\Aogonek
- \else\ifx\temp\macrochara\aogonek
- \else\ifx\temp\macrocharE\Eogonek
- \else\ifx\temp\macrochare\eogonek
- \else
- \ecfont \setbox0=\hbox{#1}%
- \ifdim\ht0=1ex\accent"0C #1%
- \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
- \fi
- \fi\fi\fi\fi
- }%
-}
-\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
-\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
-\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
-\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
-%
-% Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
\def\ecfont{%
- % We can't distinguish serif/sans and italic/slanted, but this
+ % We can't distinguish serif/sanserif and italic/slanted, but this
% is used for crude hacks anyway (like adding French and German
% quotes to documents typeset with CM, where we lose kerning), so
% hopefully nobody will notice/care.
\edef\ecsize{\csname\curfontsize ecsize\endcsname}%
\edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
- \ifmonospace
- % typewriter:
- \font\thisecfont = ectt\ecsize \space at \nominalsize
+ \ifx\curfontstyle\bfstylename
+ % bold:
+ \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
\else
- \ifx\curfontstyle\bfstylename
- % bold:
- \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
- \else
- % regular:
- \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
- \fi
+ % regular:
+ \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
\fi
\thisecfont
}
@@ -3179,8 +2783,8 @@ end
% Laurent Siebenmann reports \Orb undefined with:
% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
% so we'll define it if necessary.
-%
-\ifx\Orb\thisisundefined
+%
+\ifx\Orb\undefined
\def\Orb{\mathhexbox20D}
\fi
@@ -3208,9 +2812,8 @@ end
\newif\ifsetshortcontentsaftertitlepage
\let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
-\parseargdef\shorttitlepage{%
- \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
- \endgroup\page\hbox{}\page}
+\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
+ \endgroup\page\hbox{}\page}
\envdef\titlepage{%
% Open one extra group, as we want to close it in the middle of \Etitlepage.
@@ -3270,28 +2873,17 @@ end
\finishedtitlepagetrue
}
-% Settings used for typesetting titles: no hyphenation, no indentation,
-% don't worry much about spacing, ragged right. This should be used
-% inside a \vbox, and fonts need to be set appropriately first. Because
-% it is always used for titles, nothing else, we call \rmisbold. \par
-% should be specified before the end of the \vbox, since a vbox is a group.
-%
-\def\raggedtitlesettings{%
- \rmisbold
- \hyphenpenalty=10000
- \parindent=0pt
- \tolerance=5000
- \ptexraggedright
-}
-
-% Macros to be used within @titlepage:
+%%% Macros to be used within @titlepage:
\let\subtitlerm=\tenrm
\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
+\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines
+ \let\tt=\authortt}
+
\parseargdef\title{%
\checkenv\titlepage
- \vbox{\titlefonts \raggedtitlesettings #1\par}%
+ \leftline{\titlefonts\rm #1}
% print a rule at the page bottom also.
\finishedtitlepagefalse
\vskip4pt \hrule height 4pt width \hsize \vskip4pt
@@ -3312,12 +2904,12 @@ end
\else
\checkenv\titlepage
\ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
- {\secfonts\rmisbold \leftline{#1}}%
+ {\authorfont \leftline{#1}}%
\fi
}
-% Set up page headings and footings.
+%%% Set up page headings and footings.
\let\thispage=\folio
@@ -3411,14 +3003,10 @@ end
\def\headings #1 {\csname HEADINGS#1\endcsname}
-\def\headingsoff{% non-global headings elimination
- \evenheadline={\hfil}\evenfootline={\hfil}%
- \oddheadline={\hfil}\oddfootline={\hfil}%
-}
-
-\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
-\HEADINGSoff % it's the default
-
+\def\HEADINGSoff{%
+\global\evenheadline={\hfil} \global\evenfootline={\hfil}
+\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
+\HEADINGSoff
% When we turn headings on, set the page number to 1.
% For double-sided printing, put current file name in lower left corner,
% chapter name on inside top of right hand pages, document
@@ -3469,7 +3057,7 @@ end
% This produces Day Month Year style of output.
% Only define if not already defined, in case a txi-??.tex file has set
% up a different format (e.g., txi-cs.tex does this).
-\ifx\today\thisisundefined
+\ifx\today\undefined
\def\today{%
\number\day\space
\ifcase\month
@@ -3530,7 +3118,7 @@ end
\begingroup
\advance\leftskip by-\tableindent
\advance\hsize by\tableindent
- \advance\rightskip by0pt plus1fil\relax
+ \advance\rightskip by0pt plus1fil
\leavevmode\unhbox0\par
\endgroup
%
@@ -3544,7 +3132,7 @@ end
% cause the example and the item to crash together. So we use this
% bizarre value of 10001 as a signal to \aboveenvbreak to insert
% \parskip glue after all. Section titles are handled this way also.
- %
+ %
\penalty 10001
\endgroup
\itemxneedsnegativevskipfalse
@@ -3638,18 +3226,9 @@ end
\parindent=0pt
\parskip=\smallskipamount
\ifdim\parskip=0pt \parskip=2pt \fi
- %
- % Try typesetting the item mark that if the document erroneously says
- % something like @itemize @samp (intending @table), there's an error
- % right away at the @itemize. It's not the best error message in the
- % world, but it's better than leaving it to the @item. This means if
- % the user wants an empty mark, they have to say @w{} not just @w.
\def\itemcontents{#1}%
- \setbox0 = \hbox{\itemcontents}%
- %
% @itemize with no arg is equivalent to @itemize @bullet.
\ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
- %
\let\item=\itemizeitem
}
@@ -3670,7 +3249,6 @@ end
\ifnum\lastpenalty<10000 \parskip=0in \fi
\noindent
\hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
- %
\vadjust{\penalty 1200}}% not good to break after first line of item.
\flushcr
}
@@ -3892,19 +3470,12 @@ end
%
% @headitem starts a heading row, which we typeset in bold.
% Assignments have to be global since we are inside the implicit group
-% of an alignment entry. \everycr resets \everytab so we don't have to
-% undo it ourselves.
-\def\headitemfont{\b}% for people to use in the template row; not changeable
-\def\headitem{%
- \checkenv\multitable
- \crcr
- \global\everytab={\bf}% can't use \headitemfont since the parsing differs
- \the\everytab % for the first item
-}%
+% of an alignment entry. Note that \everycr resets \everytab.
+\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}%
%
% A \tab used to include \hskip1sp. But then the space in a template
% line is not enough. That is bad. So let's go back to just `&' until
-% we again encounter the problem the 1sp was intended to solve.
+% we encounter the problem it was intended to solve again.
% --karl, nathan@acm.org, 20apr99.
\def\tab{\checkenv\multitable &\the\everytab}%
@@ -4016,18 +3587,18 @@ end
\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
\global\advance\multitablelinespace by-\ht0
\fi
-% Test to see if parskip is larger than space between lines of
-% table. If not, do nothing.
-% If so, set to same dimension as multitablelinespace.
+%% Test to see if parskip is larger than space between lines of
+%% table. If not, do nothing.
+%% If so, set to same dimension as multitablelinespace.
\ifdim\multitableparskip>\multitablelinespace
\global\multitableparskip=\multitablelinespace
-\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
- % than skip between lines in the table.
+\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
+ %% than skip between lines in the table.
\fi%
\ifdim\multitableparskip=0pt
\global\multitableparskip=\multitablelinespace
-\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
- % than skip between lines in the table.
+\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
+ %% than skip between lines in the table.
\fi}
@@ -4188,7 +3759,7 @@ end
% ..., but we might end up with active ones in the argument if
% we're called from @code, as @code{@value{foo-bar_}}, though.
% So \let them to their normal equivalents.
- \let-\normaldash \let_\normalunderscore
+ \let-\realdash \let_\normalunderscore
}
}
@@ -4228,7 +3799,7 @@ end
}
\def\ifsetfail{\doignore{ifset}}
-% @ifclear VAR ... @end executes the `...' iff VAR has never been
+% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
% defined with @set, or has been undefined with @clear.
%
% The `\else' inside the `\doifset' parameter is a trick to reuse the
@@ -4239,35 +3810,6 @@ end
\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
\def\ifclearfail{\doignore{ifclear}}
-% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
-% without the @) is in fact defined. We can only feasibly check at the
-% TeX level, so something like `mathcode' is going to considered
-% defined even though it is not a Texinfo command.
-%
-\makecond{ifcommanddefined}
-\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
-%
-\def\doifcmddefined#1#2{{%
- \makevalueexpandable
- \let\next=\empty
- \expandafter\ifx\csname #2\endcsname\relax
- #1% If not defined, \let\next as above.
- \fi
- \expandafter
- }\next
-}
-\def\ifcmddefinedfail{\doignore{ifcommanddefined}}
-
-% @ifcommandnotdefined CMD ... handled similar to @ifclear above.
-\makecond{ifcommandnotdefined}
-\def\ifcommandnotdefined{%
- \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
-\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
-
-% Set the `txicommandconditionals' variable, so documents have a way to
-% test if the @ifcommand...defined conditionals are available.
-\set txicommandconditionals
-
% @dircategory CATEGORY -- specify a category of the dir file
% which this file should belong to. Ignore this in TeX.
\let\dircategory=\comment
@@ -4332,11 +3874,11 @@ end
\def\dosynindex#1#2#3{%
% Only do \closeout if we haven't already done it, else we'll end up
% closing the target index.
- \expandafter \ifx\csname donesynindex#2\endcsname \relax
+ \expandafter \ifx\csname donesynindex#2\endcsname \undefined
% The \closeout helps reduce unnecessary open files; the limit on the
% Acorn RISC OS is a mere 16 files.
\expandafter\closeout\csname#2indfile\endcsname
- \expandafter\let\csname donesynindex#2\endcsname = 1
+ \expandafter\let\csname\donesynindex#2\endcsname = 1
\fi
% redefine \fooindfile:
\expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
@@ -4371,14 +3913,11 @@ end
\def\@{@}% change to @@ when we switch to @ as escape char in index files.
\def\ {\realbackslash\space }%
%
- % Need these unexpandable (because we define \tt as a dummy)
- % definitions when @{ or @} appear in index entry text. Also, more
- % complicated, when \tex is in effect and \{ is a \delimiter again.
- % We can't use \lbracecmd and \rbracecmd because texindex assumes
- % braces and backslashes are used only as delimiters. Perhaps we
- % should define @lbrace and @rbrace commands a la @comma.
- \def\{{{\tt\char123}}%
- \def\}{{\tt\char125}}%
+ % Need these in case \tex is in effect and \{ is a \delimiter again.
+ % But can't use \lbracecmd and \rbracecmd because texindex assumes
+ % braces and backslashes are used only as delimiters.
+ \let\{ = \mylbrace
+ \let\} = \myrbrace
%
% I don't entirely understand this, but when an index entry is
% generated from a macro call, the \endinput which \scanmacro inserts
@@ -4389,7 +3928,7 @@ end
% processing continues to some further point. On the other hand, it
% seems \endinput does not hurt in the printed index arg, since that
% is still getting written without apparent harm.
- %
+ %
% Sample source (mac-idx3.tex, reported by Graham Percival to
% help-texinfo, 22may06):
% @macro funindex {WORD}
@@ -4397,12 +3936,12 @@ end
% @end macro
% ...
% @funindex commtest
- %
+ %
% The above is not enough to reproduce the bug, but it gives the flavor.
- %
+ %
% Sample whatsit resulting:
% .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
- %
+ %
% So:
\let\endinput = \empty
%
@@ -4431,7 +3970,7 @@ end
\def\commondummies{%
%
% \definedummyword defines \#1 as \string\#1\space, thus effectively
- % preventing its expansion. This is used only for control words,
+ % preventing its expansion. This is used only for control% words,
% not control letters, because the \space would be incorrect for
% control characters, but is needed to separate the control word
% from whatever follows.
@@ -4450,28 +3989,23 @@ end
\commondummiesnofonts
%
\definedummyletter\_%
- \definedummyletter\-%
%
% Non-English letters.
\definedummyword\AA
\definedummyword\AE
- \definedummyword\DH
\definedummyword\L
- \definedummyword\O
\definedummyword\OE
- \definedummyword\TH
+ \definedummyword\O
\definedummyword\aa
\definedummyword\ae
- \definedummyword\dh
- \definedummyword\exclamdown
\definedummyword\l
- \definedummyword\o
\definedummyword\oe
+ \definedummyword\o
+ \definedummyword\ss
+ \definedummyword\exclamdown
+ \definedummyword\questiondown
\definedummyword\ordf
\definedummyword\ordm
- \definedummyword\questiondown
- \definedummyword\ss
- \definedummyword\th
%
% Although these internal commands shouldn't show up, sometimes they do.
\definedummyword\bf
@@ -4487,27 +4021,21 @@ end
\definedummyword\TeX
%
% Assorted special characters.
- \definedummyword\arrow
\definedummyword\bullet
\definedummyword\comma
\definedummyword\copyright
\definedummyword\registeredsymbol
\definedummyword\dots
\definedummyword\enddots
- \definedummyword\entrybreak
\definedummyword\equiv
\definedummyword\error
\definedummyword\euro
- \definedummyword\expansion
- \definedummyword\geq
\definedummyword\guillemetleft
\definedummyword\guillemetright
\definedummyword\guilsinglleft
\definedummyword\guilsinglright
- \definedummyword\lbracechar
- \definedummyword\leq
+ \definedummyword\expansion
\definedummyword\minus
- \definedummyword\ogonek
\definedummyword\pounds
\definedummyword\point
\definedummyword\print
@@ -4517,7 +4045,6 @@ end
\definedummyword\quoteleft
\definedummyword\quoteright
\definedummyword\quotesinglbase
- \definedummyword\rbracechar
\definedummyword\result
\definedummyword\textdegree
%
@@ -4552,7 +4079,6 @@ end
\definedummyword\v
\definedummyword\H
\definedummyword\dotaccent
- \definedummyword\ogonek
\definedummyword\ringaccent
\definedummyword\tieaccent
\definedummyword\ubaraccent
@@ -4563,27 +4089,18 @@ end
\definedummyword\b
\definedummyword\i
\definedummyword\r
- \definedummyword\sansserif
\definedummyword\sc
- \definedummyword\slanted
\definedummyword\t
%
% Commands that take arguments.
- \definedummyword\abbr
\definedummyword\acronym
- \definedummyword\anchor
\definedummyword\cite
\definedummyword\code
\definedummyword\command
\definedummyword\dfn
- \definedummyword\dmn
- \definedummyword\email
\definedummyword\emph
\definedummyword\env
\definedummyword\file
- \definedummyword\image
- \definedummyword\indicateurl
- \definedummyword\inforef
\definedummyword\kbd
\definedummyword\key
\definedummyword\math
@@ -4611,7 +4128,7 @@ end
\def\definedummyaccent##1{\let##1\asis}%
% We can just ignore other control letters.
\def\definedummyletter##1{\let##1\empty}%
- % All control words become @asis by default; overrides below.
+ % Hopefully, all control words can become @asis.
\let\definedummyword\definedummyaccent
%
\commondummiesnofonts
@@ -4623,63 +4140,48 @@ end
%
\def\ { }%
\def\@{@}%
+ % how to handle braces?
\def\_{\normalunderscore}%
- \def\-{}% @- shouldn't affect sorting
- %
- % Unfortunately, texindex is not prepared to handle braces in the
- % content at all. So for index sorting, we map @{ and @} to strings
- % starting with |, since that ASCII character is between ASCII { and }.
- \def\{{|a}%
- \def\lbracechar{|a}%
- %
- \def\}{|b}%
- \def\rbracechar{|b}%
%
% Non-English letters.
\def\AA{AA}%
\def\AE{AE}%
- \def\DH{DZZ}%
\def\L{L}%
\def\OE{OE}%
\def\O{O}%
- \def\TH{ZZZ}%
\def\aa{aa}%
\def\ae{ae}%
- \def\dh{dzz}%
- \def\exclamdown{!}%
\def\l{l}%
\def\oe{oe}%
- \def\ordf{a}%
- \def\ordm{o}%
\def\o{o}%
- \def\questiondown{?}%
\def\ss{ss}%
- \def\th{zzz}%
+ \def\exclamdown{!}%
+ \def\questiondown{?}%
+ \def\ordf{a}%
+ \def\ordm{o}%
%
\def\LaTeX{LaTeX}%
\def\TeX{TeX}%
%
% Assorted special characters.
% (The following {} will end up in the sort string, but that's ok.)
- \def\arrow{->}%
\def\bullet{bullet}%
\def\comma{,}%
\def\copyright{copyright}%
+ \def\registeredsymbol{R}%
\def\dots{...}%
\def\enddots{...}%
\def\equiv{==}%
\def\error{error}%
\def\euro{euro}%
- \def\expansion{==>}%
- \def\geq{>=}%
\def\guillemetleft{<<}%
\def\guillemetright{>>}%
\def\guilsinglleft{<}%
\def\guilsinglright{>}%
- \def\leq{<=}%
+ \def\expansion{==>}%
\def\minus{-}%
- \def\point{.}%
\def\pounds{pounds}%
+ \def\point{.}%
\def\print{-|}%
\def\quotedblbase{"}%
\def\quotedblleft{"}%
@@ -4687,31 +4189,22 @@ end
\def\quoteleft{`}%
\def\quoteright{'}%
\def\quotesinglbase{,}%
- \def\registeredsymbol{R}%
\def\result{=>}%
- \def\textdegree{o}%
- %
- \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
- \else \indexlquoteignore \fi
+ \def\textdegree{degrees}%
%
% We need to get rid of all macros, leaving only the arguments (if present).
% Of course this is not nearly correct, but it is the best we can do for now.
% makeinfo does not expand macros in the argument to @deffn, which ends up
% writing an index entry, and texindex isn't prepared for an index sort entry
% that starts with \.
- %
+ %
% Since macro invocations are followed by braces, we can just redefine them
% to take a single TeX argument. The case of a macro invocation that
% goes to end-of-line is not handled.
- %
+ %
\macrolist
}
-% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
-% ignore left quotes in the sort term.
-{\catcode`\`=\active
- \gdef\indexlquoteignore{\let`=\empty}}
-
\let\indexbackslash=0 %overridden during \printindex.
\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
@@ -4809,9 +4302,10 @@ end
%
% ..., ready, GO:
%
-\def\safewhatsit#1{\ifhmode
+\def\safewhatsit#1{%
+\ifhmode
#1%
- \else
+\else
% \lastskip and \lastpenalty cannot both be nonzero simultaneously.
\whatsitskip = \lastskip
\edef\lastskipmacro{\the\lastskip}%
@@ -4835,6 +4329,7 @@ end
% to re-insert the same penalty (values >10000 are used for various
% signals); since we just inserted a non-discardable item, any
% following glue (such as a \parskip) would be a breakpoint. For example:
+ %
% @deffn deffn-whatever
% @vindex index-whatever
% Description.
@@ -4847,7 +4342,8 @@ end
% (the whatsit from the \write), so we must insert a \nobreak.
\nobreak\vskip\whatsitskip
\fi
-\fi}
+\fi
+}
% The index entry written in the file actually looks like
% \entry {sortstring}{page}{topic}
@@ -4966,6 +4462,7 @@ end
% But this freezes the catcodes in the argument, and can cause problems to
% @code, which sets - active. This problem was fixed by a kludge---
% ``-'' was active throughout whole index, but this isn't really right.
+%
% The right solution is to prevent \entry from swallowing the whole text.
% --kasal, 21nov03
\def\entry{%
@@ -5002,17 +4499,10 @@ end
% columns.
\vskip 0pt plus1pt
%
- % When reading the text of entry, convert explicit line breaks
- % from @* into spaces. The user might give these in long section
- % titles, for instance.
- \def\*{\unskip\space\ignorespaces}%
- \def\entrybreak{\hfil\break}%
- %
% Swallow the left brace of the text (first parameter):
\afterassignment\doentry
\let\temp =
}
-\def\entrybreak{\unskip\space\ignorespaces}%
\def\doentry{%
\bgroup % Instead of the swallowed brace.
\noindent
@@ -5245,22 +4735,7 @@ end
\message{sectioning,}
% Chapters, sections, etc.
-% Let's start with @part.
-\outer\parseargdef\part{\partzzz{#1}}
-\def\partzzz#1{%
- \chapoddpage
- \null
- \vskip.3\vsize % move it down on the page a bit
- \begingroup
- \noindent \titlefonts\rmisbold #1\par % the text
- \let\lastnode=\empty % no node to associate with
- \writetocentry{part}{#1}{}% but put it in the toc
- \headingsoff % no headline or footline on the part page
- \chapoddpage
- \endgroup
-}
-
-% \unnumberedno is an oxymoron. But we count the unnumbered
+% \unnumberedno is an oxymoron, of course. But we count the unnumbered
% sections so that we can refer to them unambiguously in the pdf
% outlines by their "section number". We avoid collisions with chapter
% numbers by starting them at 10000. (If a document ever has 10000
@@ -5339,8 +4814,8 @@ end
\chardef\maxseclevel = 3
%
% A numbered section within an unnumbered changes to unnumbered too.
-% To achieve this, remember the "biggest" unnum. sec. we are currently in:
-\chardef\unnlevel = \maxseclevel
+% To achive this, remember the "biggest" unnum. sec. we are currently in:
+\chardef\unmlevel = \maxseclevel
%
% Trace whether the current chapter is an appendix or not:
% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
@@ -5365,8 +4840,8 @@ end
% The heading type:
\def\headtype{#1}%
\if \headtype U%
- \ifnum \absseclevel < \unnlevel
- \chardef\unnlevel = \absseclevel
+ \ifnum \absseclevel < \unmlevel
+ \chardef\unmlevel = \absseclevel
\fi
\else
% Check for appendix sections:
@@ -5378,10 +4853,10 @@ end
\fi\fi
\fi
% Check for numbered within unnumbered:
- \ifnum \absseclevel > \unnlevel
+ \ifnum \absseclevel > \unmlevel
\def\headtype{U}%
\else
- \chardef\unnlevel = 3
+ \chardef\unmlevel = 3
\fi
\fi
% Now print the heading:
@@ -5435,9 +4910,7 @@ end
\gdef\chaplevelprefix{\the\chapno.}%
\resetallfloatnos
%
- % \putwordChapter can contain complex things in translations.
- \toks0=\expandafter{\putwordChapter}%
- \message{\the\toks0 \space \the\chapno}%
+ \message{\putwordChapter\space \the\chapno}%
%
% Write the actual heading.
\chapmacro{#1}{Ynumbered}{\the\chapno}%
@@ -5448,17 +4921,15 @@ end
\global\let\subsubsection = \numberedsubsubsec
}
-\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
-%
+\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
\def\appendixzzz#1{%
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
\global\advance\appendixno by 1
\gdef\chaplevelprefix{\appendixletter.}%
\resetallfloatnos
%
- % \putwordAppendix can contain complex things in translations.
- \toks0=\expandafter{\putwordAppendix}%
- \message{\the\toks0 \space \appendixletter}%
+ \def\appendixnum{\putwordAppendix\space \appendixletter}%
+ \message{\appendixnum}%
%
\chapmacro{#1}{Yappendix}{\appendixletter}%
%
@@ -5467,8 +4938,7 @@ end
\global\let\subsubsection = \appendixsubsubsec
}
-% normally unnmhead0 calls unnumberedzzz:
-\outer\parseargdef\unnumbered{\unnmhead0{#1}}
+\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
\def\unnumberedzzz#1{%
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
\global\advance\unnumberedno by 1
@@ -5512,47 +4982,40 @@ end
\let\top\unnumbered
% Sections.
-%
\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
\def\seczzz#1{%
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
\sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
}
-% normally calls appendixsectionzzz:
-\outer\parseargdef\appendixsection{\apphead1{#1}}
+\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
\def\appendixsectionzzz#1{%
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
\sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
}
\let\appendixsec\appendixsection
-% normally calls unnumberedseczzz:
-\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
+\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
\def\unnumberedseczzz#1{%
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
\sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
}
% Subsections.
-%
-% normally calls numberedsubseczzz:
-\outer\parseargdef\numberedsubsec{\numhead2{#1}}
+\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
\def\numberedsubseczzz#1{%
\global\subsubsecno=0 \global\advance\subsecno by 1
\sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
}
-% normally calls appendixsubseczzz:
-\outer\parseargdef\appendixsubsec{\apphead2{#1}}
+\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
\def\appendixsubseczzz#1{%
\global\subsubsecno=0 \global\advance\subsecno by 1
\sectionheading{#1}{subsec}{Yappendix}%
{\appendixletter.\the\secno.\the\subsecno}%
}
-% normally calls unnumberedsubseczzz:
-\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
+\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
\def\unnumberedsubseczzz#1{%
\global\subsubsecno=0 \global\advance\subsecno by 1
\sectionheading{#1}{subsec}{Ynothing}%
@@ -5560,25 +5023,21 @@ end
}
% Subsubsections.
-%
-% normally numberedsubsubseczzz:
-\outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
+\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
\def\numberedsubsubseczzz#1{%
\global\advance\subsubsecno by 1
\sectionheading{#1}{subsubsec}{Ynumbered}%
{\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
}
-% normally appendixsubsubseczzz:
-\outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
+\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
\def\appendixsubsubseczzz#1{%
\global\advance\subsubsecno by 1
\sectionheading{#1}{subsubsec}{Yappendix}%
{\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
}
-% normally unnumberedsubsubseczzz:
-\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
+\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
\def\unnumberedsubsubseczzz#1{%
\global\advance\subsubsecno by 1
\sectionheading{#1}{subsubsec}{Ynothing}%
@@ -5594,6 +5053,15 @@ end
% Define @majorheading, @heading and @subheading
+% NOTE on use of \vbox for chapter headings, section headings, and such:
+% 1) We use \vbox rather than the earlier \line to permit
+% overlong headings to fold.
+% 2) \hyphenpenalty is set to 10000 because hyphenation in a
+% heading is obnoxious; this forbids it.
+% 3) Likewise, headings look best if no \parindent is used, and
+% if justification is not attempted. Hence \raggedright.
+
+
\def\majorheading{%
{\advance\chapheadingskip by 10pt \chapbreak }%
\parsearg\chapheadingzzz
@@ -5601,8 +5069,10 @@ end
\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
\def\chapheadingzzz#1{%
- \vbox{\chapfonts \raggedtitlesettings #1\par}%
- \nobreak\bigskip \nobreak
+ {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt\raggedright
+ \rm #1\hfill}}%
+ \bigskip \par\penalty 200\relax
\suppressfirstparagraphindent
}
@@ -5618,13 +5088,14 @@ end
% (including whitespace, linebreaking, etc. around it),
% given all the information in convenient, parsed form.
-% Args are the skip and penalty (usually negative)
+%%% Args are the skip and penalty (usually negative)
\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
+%%% Define plain chapter starts, and page on/off switching for it
% Parameter controlling skip before chapter headings (if needed)
+
\newskip\chapheadingskip
-% Define plain chapter starts, and page on/off switching for it.
\def\chapbreak{\dobreak \chapheadingskip {-4000}}
\def\chappager{\par\vfill\supereject}
% Because \domark is called before \chapoddpage, the filler page will
@@ -5634,8 +5105,9 @@ end
\chappager
\ifodd\pageno \else
\begingroup
- \headingsoff
- \null
+ \evenheadline={\hfil}\evenfootline={\hfil}%
+ \oddheadline={\hfil}\oddfootline={\hfil}%
+ \hbox to 0pt{}%
\chappager
\endgroup
\fi
@@ -5691,10 +5163,7 @@ end
\xdef\lastchapterdefs{%
\gdef\noexpand\thischaptername{\the\toks0}%
\gdef\noexpand\thischapternum{\appendixletter}%
- % \noexpand\putwordAppendix avoids expanding indigestible
- % commands in some of the translations.
- \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
- \noexpand\thischapternum:
+ \gdef\noexpand\thischapter{\putwordAppendix{} \noexpand\thischapternum:
\noexpand\thischaptername}%
}%
\else
@@ -5702,10 +5171,7 @@ end
\xdef\lastchapterdefs{%
\gdef\noexpand\thischaptername{\the\toks0}%
\gdef\noexpand\thischapternum{\the\chapno}%
- % \noexpand\putwordChapter avoids expanding indigestible
- % commands in some of the translations.
- \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
- \noexpand\thischapternum:
+ \gdef\noexpand\thischapter{\putwordChapter{} \noexpand\thischapternum:
\noexpand\thischaptername}%
}%
\fi\fi\fi
@@ -5724,7 +5190,7 @@ end
\domark
%
{%
- \chapfonts \rmisbold
+ \chapfonts \rm
%
% Have to define \lastsection before calling \donoderef, because the
% xref code eventually uses it. On the other hand, it has to be called
@@ -5761,7 +5227,8 @@ end
%
% Typeset the actual heading.
\nobreak % Avoid page breaks at the interline glue.
- \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
+ \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
+ \hangindent=\wd0 \centerparametersmaybe
\unhbox0 #1\par}%
}%
\nobreak\bigskip % no page break after a chapter title
@@ -5783,18 +5250,18 @@ end
\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
%
\def\unnchfopen #1{%
- \chapoddpage
- \vbox{\chapfonts \raggedtitlesettings #1\par}%
- \nobreak\bigskip\nobreak
+\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt\raggedright
+ \rm #1\hfill}}\bigskip \par\nobreak
}
\def\chfopen #1#2{\chapoddpage {\chapfonts
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
\par\penalty 5000 %
}
\def\centerchfopen #1{%
- \chapoddpage
- \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}%
- \nobreak\bigskip \nobreak
+\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
+ \parindent=0pt
+ \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
}
\def\CHAPFopen{%
\global\let\chapmacro=\chfopen
@@ -5826,10 +5293,8 @@ end
%
\def\sectionheading#1#2#3#4{%
{%
- \checkenv{}% should not be in an environment.
- %
% Switch to the right set of fonts.
- \csname #2fonts\endcsname \rmisbold
+ \csname #2fonts\endcsname \rm
%
\def\sectionlevel{#2}%
\def\temptype{#3}%
@@ -5849,10 +5314,7 @@ end
\xdef\lastsectiondefs{%
\gdef\noexpand\thissectionname{\the\toks0}%
\gdef\noexpand\thissectionnum{#4}%
- % \noexpand\putwordSection avoids expanding indigestible
- % commands in some of the translations.
- \gdef\noexpand\thissection{\noexpand\putwordSection{}
- \noexpand\thissectionnum:
+ \gdef\noexpand\thissection{\putwordSection{} \noexpand\thissectionnum:
\noexpand\thissectionname}%
}%
\fi
@@ -5862,20 +5324,12 @@ end
\xdef\lastsectiondefs{%
\gdef\noexpand\thissectionname{\the\toks0}%
\gdef\noexpand\thissectionnum{#4}%
- % \noexpand\putwordSection avoids expanding indigestible
- % commands in some of the translations.
- \gdef\noexpand\thissection{\noexpand\putwordSection{}
- \noexpand\thissectionnum:
+ \gdef\noexpand\thissection{\putwordSection{} \noexpand\thissectionnum:
\noexpand\thissectionname}%
}%
\fi
\fi\fi\fi
%
- % Go into vertical mode. Usually we'll already be there, but we
- % don't want the following whatsit to end up in a preceding paragraph
- % if the document didn't happen to have a blank line.
- \par
- %
% Output the mark. Pass it through \safewhatsit, to take care of
% the preceding space.
\safewhatsit\domark
@@ -5925,7 +5379,7 @@ end
\nobreak
%
% Output the actual section heading.
- \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
+ \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
\hangindent=\wd0 % zero if no section number
\unhbox0 #1}%
}%
@@ -5939,15 +5393,15 @@ end
%
% We'll almost certainly start a paragraph next, so don't let that
% glue accumulate. (Not a breakpoint because it's preceded by a
- % discardable item.) However, when a paragraph is not started next
- % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
- % or the negative glue will cause weirdly wrong output, typically
- % obscuring the section heading with something else.
+ % discardable item.)
\vskip-\parskip
- %
- % This is so the last item on the main vertical list is a known
- % \penalty > 10000, so \startdefun, etc., can recognize the situation
- % and do the needful.
+ %
+ % This is purely so the last item on the list is a known \penalty >
+ % 10000. This is so \startdefun can avoid allowing breakpoints after
+ % section headings. Otherwise, it would insert a valid breakpoint between:
+ %
+ % @section sec-whatever
+ % @deffn def-whatever
\penalty 10001
}
@@ -6003,7 +5457,7 @@ end
% These characters do not print properly in the Computer Modern roman
% fonts, so we must take special care. This is more or less redundant
% with the Texinfo input format setup at the end of this file.
-%
+%
\def\activecatcodes{%
\catcode`\"=\active
\catcode`\$=\active
@@ -6053,7 +5507,7 @@ end
% redefined for the two-volume lispref. We always output on
% \jobname.toc even if this is redefined.
-%
+%
\def\tocreadfilename{\jobname.toc}
% Normal (long) toc.
@@ -6079,7 +5533,6 @@ end
\def\summarycontents{%
\startcontents{\putwordShortTOC}%
%
- \let\partentry = \shortpartentry
\let\numchapentry = \shortchapentry
\let\appentry = \shortchapentry
\let\unnchapentry = \shortunnchapentry
@@ -6135,19 +5588,6 @@ end
% The last argument is the page number.
% The arguments in between are the chapter number, section number, ...
-% Parts, in the main contents. Replace the part number, which doesn't
-% exist, with an empty box. Let's hope all the numbers have the same width.
-% Also ignore the page number, which is conventionally not printed.
-\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
-\def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
-%
-% Parts, in the short toc.
-\def\shortpartentry#1#2#3#4{%
- \penalty-300
- \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
- \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
-}
-
% Chapters, in the main contents.
\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
%
@@ -6237,12 +5677,46 @@ end
\message{environments,}
% @foo ... @end foo.
-% @tex ... @end tex escapes into raw TeX temporarily.
+% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
+%
+% Since these characters are used in examples, they should be an even number of
+% \tt widths. Each \tt character is 1en, so two makes it 1em.
+%
+\def\point{$\star$}
+\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
+\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
+\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
+\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
+\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
+
+% The @error{} command.
+% Adapted from the TeXbook's \boxit.
+%
+\newbox\errorbox
+%
+{\tentt \global\dimen0 = 3em}% Width of the box.
+\dimen2 = .55pt % Thickness of rules
+% The text. (`r' is open on the right, `e' somewhat less so on the left.)
+\setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt}
+%
+\setbox\errorbox=\hbox to \dimen0{\hfil
+ \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
+ \advance\hsize by -2\dimen2 % Rules.
+ \vbox{%
+ \hrule height\dimen2
+ \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
+ \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
+ \kern3pt\vrule width\dimen2}% Space to right.
+ \hrule height\dimen2}
+ \hfil}
+%
+\def\error{\leavevmode\lower.7ex\copy\errorbox}
+
+% @tex ... @end tex escapes into raw Tex temporarily.
% One exception: @ is still an escape character, so that @end tex works.
-% But \@ or @@ will get a plain @ character.
+% But \@ or @@ will get a plain tex @ character.
\envdef\tex{%
- \setupmarkupstyle{tex}%
\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
\catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
@@ -6252,14 +5726,8 @@ end
\catcode `\|=\other
\catcode `\<=\other
\catcode `\>=\other
- \catcode`\`=\other
- \catcode`\'=\other
\escapechar=`\\
%
- % ' is active in math mode (mathcode"8000). So reset it, and all our
- % other math active characters (just in case), to plain's definitions.
- \mathactive
- %
\let\b=\ptexb
\let\bullet=\ptexbullet
\let\c=\ptexc
@@ -6363,12 +5831,6 @@ end
\normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
% Flag to tell @lisp, etc., not to narrow margin.
\let\nonarrowing = t%
- %
- % If this cartouche directly follows a sectioning command, we need the
- % \parskip glue (backspaced over by default) or the cartouche can
- % collide with the section heading.
- \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
- %
\vbox\bgroup
\baselineskip=0pt\parskip=0pt\lineskip=0pt
\carttop
@@ -6382,7 +5844,7 @@ end
\lineskip=\normlskip
\parskip=\normpskip
\vskip -\parskip
- \comment % For explanation, see the end of def\group.
+ \comment % For explanation, see the end of \def\group.
}
\def\Ecartouche{%
\ifhmode\par\fi
@@ -6399,7 +5861,6 @@ end
% This macro is called at the beginning of all the @example variants,
% inside a group.
-\newdimen\nonfillparindent
\def\nonfillstart{%
\aboveenvbreak
\hfuzz = 12pt % Don't be fussy
@@ -6407,12 +5868,7 @@ end
\let\par = \lisppar % don't ignore blank lines
\obeylines % each line of input is a line of output
\parskip = 0pt
- % Turn off paragraph indentation but redefine \indent to emulate
- % the normal \indent.
- \nonfillparindent=\parindent
\parindent = 0pt
- \let\indent\nonfillindent
- %
\emergencystretch = 0pt % don't try to avoid overfull boxes
\ifx\nonarrowing\relax
\advance \leftskip by \lispnarrowing
@@ -6423,24 +5879,6 @@ end
\let\exdent=\nofillexdent
}
-\begingroup
-\obeyspaces
-% We want to swallow spaces (but not other tokens) after the fake
-% @indent in our nonfill-environments, where spaces are normally
-% active and set to @tie, resulting in them not being ignored after
-% @indent.
-\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
-\gdef\nonfillindentcheck{%
-\ifx\temp %
-\expandafter\nonfillindentgobble%
-\else%
-\leavevmode\nonfillindentbox%
-\fi%
-}%
-\endgroup
-\def\nonfillindentgobble#1{\nonfillindent}
-\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
-
% If you want all examples etc. small: @set dispenvsize small.
% If you want even small examples the full size: @set dispenvsize nosmall.
% This affects the following displayed environments:
@@ -6468,42 +5906,41 @@ end
}
% We often define two environments, @foo and @smallfoo.
-% Let's do it in one command. #1 is the env name, #2 the definition.
-\def\makedispenvdef#1#2{%
- \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
- \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
+% Let's do it by one command:
+\def\makedispenv #1#2{
+ \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}
+ \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}
\expandafter\let\csname E#1\endcsname \afterenvbreak
\expandafter\let\csname Esmall#1\endcsname \afterenvbreak
}
-% Define two environment synonyms (#1 and #2) for an environment.
-\def\maketwodispenvdef#1#2#3{%
- \makedispenvdef{#1}{#3}%
- \makedispenvdef{#2}{#3}%
+% Define two synonyms:
+\def\maketwodispenvs #1#2#3{
+ \makedispenv{#1}{#3}
+ \makedispenv{#2}{#3}
}
-%
-% @lisp: indented, narrowed, typewriter font;
-% @example: same as @lisp.
+
+% @lisp: indented, narrowed, typewriter font; @example: same as @lisp.
%
% @smallexample and @smalllisp: use smaller fonts.
% Originally contributed by Pavel@xerox.
%
-\maketwodispenvdef{lisp}{example}{%
+\maketwodispenvs {lisp}{example}{%
\nonfillstart
- \tt\setupmarkupstyle{example}%
+ \tt\quoteexpand
\let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
- \gobble % eat return
+ \gobble % eat return
}
% @display/@smalldisplay: same as @lisp except keep current font.
%
-\makedispenvdef{display}{%
+\makedispenv {display}{%
\nonfillstart
\gobble
}
% @format/@smallformat: same as @display except don't narrow margins.
%
-\makedispenvdef{format}{%
+\makedispenv{format}{%
\let\nonarrowing = t%
\nonfillstart
\gobble
@@ -6522,47 +5959,28 @@ end
\envdef\flushright{%
\let\nonarrowing = t%
\nonfillstart
- \advance\leftskip by 0pt plus 1fill\relax
+ \advance\leftskip by 0pt plus 1fill
\gobble
}
\let\Eflushright = \afterenvbreak
-% @raggedright does more-or-less normal line breaking but no right
-% justification. From plain.tex.
-\envdef\raggedright{%
- \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
-}
-\let\Eraggedright\par
-
-\envdef\raggedleft{%
- \parindent=0pt \leftskip0pt plus2em
- \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
- \hbadness=10000 % Last line will usually be underfull, so turn off
- % badness reporting.
-}
-\let\Eraggedleft\par
-
-\envdef\raggedcenter{%
- \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
- \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
- \hbadness=10000 % Last line will usually be underfull, so turn off
- % badness reporting.
-}
-\let\Eraggedcenter\par
-
-
% @quotation does normal linebreaking (hence we can't use \nonfillstart)
% and narrows the margins. We keep \parskip nonzero in general, since
% we're doing normal filling. So, when using \aboveenvbreak and
% \afterenvbreak, temporarily make \parskip 0.
%
-\makedispenvdef{quotation}{\quotationstart}
-%
-\def\quotationstart{%
- \indentedblockstart % same as \indentedblock, but increase right margin too.
+\envdef\quotation{%
+ {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
+ \parindent=0pt
+ %
+ % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
\ifx\nonarrowing\relax
+ \advance\leftskip by \lispnarrowing
\advance\rightskip by \lispnarrowing
+ \exdentamount = \lispnarrowing
+ \else
+ \let\nonarrowing = \relax
\fi
\parsearg\quotationlabel
}
@@ -6572,13 +5990,12 @@ end
%
\def\Equotation{%
\par
- \ifx\quotationauthor\thisisundefined\else
+ \ifx\quotationauthor\undefined\else
% indent a bit.
\leftline{\kern 2\leftskip \sl ---\quotationauthor}%
\fi
{\parskip=0pt \afterenvbreak}%
}
-\def\Esmallquotation{\Equotation}
% If we're given an argument, typeset it in bold with a colon after.
\def\quotationlabel#1{%
@@ -6588,32 +6005,6 @@ end
\fi
}
-% @indentedblock is like @quotation, but indents only on the left and
-% has no optional argument.
-%
-\makedispenvdef{indentedblock}{\indentedblockstart}
-%
-\def\indentedblockstart{%
- {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
- \parindent=0pt
- %
- % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
- \ifx\nonarrowing\relax
- \advance\leftskip by \lispnarrowing
- \exdentamount = \lispnarrowing
- \else
- \let\nonarrowing = \relax
- \fi
-}
-
-% Keep a nonzero parskip for the environment, since we're doing normal filling.
-%
-\def\Eindentedblock{%
- \par
- {\parskip=0pt \afterenvbreak}%
-}
-\def\Esmallindentedblock{\Eindentedblock}
-
% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
% If we want to allow any <char> as delimiter,
@@ -6629,16 +6020,18 @@ end
\do\ \do\\\do\{\do\}\do\$\do\&%
\do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
\do\<\do\>\do\|\do\@\do+\do\"%
- % Don't do the quotes -- if we do, @set txicodequoteundirected and
- % @set txicodequotebacktick will not have effect on @verb and
- % @verbatim, and ?` and !` ligatures won't get disabled.
- %\do\`\do\'%
}
%
% [Knuth] p. 380
\def\uncatcodespecials{%
\def\do##1{\catcode`##1=\other}\dospecials}
%
+% [Knuth] pp. 380,381,391
+% Disable Spanish ligatures ?` and !` of \tt font
+\begingroup
+ \catcode`\`=\active\gdef`{\relax\lq}
+\endgroup
+%
% Setup for the @verb command.
%
% Eight spaces for a tab
@@ -6650,7 +6043,7 @@ end
\def\setupverb{%
\tt % easiest (and conventionally used) font for verbatim
\def\par{\leavevmode\endgraf}%
- \setupmarkupstyle{verb}%
+ \catcode`\`=\active
\tabeightspaces
% Respect line breaks,
% print special symbols as themselves, and
@@ -6661,46 +6054,73 @@ end
% Setup for the @verbatim environment
%
-% Real tab expansion.
+% Real tab expansion
\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
%
-% We typeset each line of the verbatim in an \hbox, so we can handle
-% tabs. The \global is in case the verbatim line starts with an accent,
-% or some other command that starts with a begin-group. Otherwise, the
-% entire \verbbox would disappear at the corresponding end-group, before
-% it is typeset. Meanwhile, we can't have nested verbatim commands
-% (can we?), so the \global won't be overwriting itself.
-\newbox\verbbox
-\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
+\def\starttabbox{\setbox0=\hbox\bgroup}
+
+% Allow an option to not replace quotes with a regular directed right
+% quote/apostrophe (char 0x27), but instead use the undirected quote
+% from cmtt (char 0x0d). The undirected quote is ugly, so don't make it
+% the default, but it works for pasting with more pdf viewers (at least
+% evince), the lilypond developers report. xpdf does work with the
+% regular 0x27.
+%
+\def\codequoteright{%
+ \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
+ \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
+ '%
+ \else \char'15 \fi
+ \else \char'15 \fi
+}
+%
+% and a similar option for the left quote char vs. a grave accent.
+% Modern fonts display ASCII 0x60 as a grave accent, so some people like
+% the code environments to do likewise.
+%
+\def\codequoteleft{%
+ \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
+ \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
+ `%
+ \else \char'22 \fi
+ \else \char'22 \fi
+}
%
\begingroup
\catcode`\^^I=\active
\gdef\tabexpand{%
\catcode`\^^I=\active
\def^^I{\leavevmode\egroup
- \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
- \divide\dimen\verbbox by\tabw
- \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
- \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
- \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
+ \dimen0=\wd0 % the width so far, or since the previous tab
+ \divide\dimen0 by\tabw
+ \multiply\dimen0 by\tabw % compute previous multiple of \tabw
+ \advance\dimen0 by\tabw % advance to next multiple of \tabw
+ \wd0=\dimen0 \box0 \starttabbox
}%
}
+ \catcode`\'=\active
+ \gdef\rquoteexpand{\catcode\rquoteChar=\active \def'{\codequoteright}}%
+ %
+ \catcode`\`=\active
+ \gdef\lquoteexpand{\catcode\lquoteChar=\active \def`{\codequoteleft}}%
+ %
+ \gdef\quoteexpand{\rquoteexpand \lquoteexpand}%
\endgroup
% start the verbatim environment.
\def\setupverbatim{%
\let\nonarrowing = t%
\nonfillstart
- \tt % easiest (and conventionally used) font for verbatim
- % The \leavevmode here is for blank lines. Otherwise, we would
- % never \starttabox and the \egroup would end verbatim mode.
- \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
+ % Easiest (and conventionally used) font for verbatim
+ \tt
+ \def\par{\leavevmode\egroup\box0\endgraf}%
+ \catcode`\`=\active
\tabexpand
- \setupmarkupstyle{verbatim}%
+ \quoteexpand
% Respect line breaks,
% print special symbols as themselves, and
- % make each space count.
- % Must do in this order:
+ % make each space count
+ % must do in this order:
\obeylines \uncatcodespecials \sepspaces
\everypar{\starttabbox}%
}
@@ -6756,8 +6176,6 @@ end
{%
\makevalueexpandable
\setupverbatim
- \indexnofonts % Allow `@@' and other weird things in file names.
- \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
\input #1
\afterenvbreak
}%
@@ -6807,7 +6225,7 @@ end
% commands also insert a nobreak penalty, and we don't want to allow
% a break between a section heading and a defun.
%
- % As a further refinement, we avoid "club" headers by signalling
+ % As a minor refinement, we avoid "club" headers by signalling
% with penalty of 10003 after the very first @deffn in the
% sequence (see above), and penalty of 10002 after any following
% @def command.
@@ -6844,7 +6262,7 @@ end
#1#2 \endheader
% common ending:
\interlinepenalty = 10000
- \advance\rightskip by 0pt plus 1fil\relax
+ \advance\rightskip by 0pt plus 1fil
\endgraf
\nobreak\vskip -\parskip
\penalty\defunpenalty % signal to \startdefun and \dodefunx
@@ -6874,36 +6292,13 @@ end
\def\domakedefun#1#2#3{%
\envdef#1{%
\startdefun
- \doingtypefnfalse % distinguish typed functions from all else
\parseargusing\activeparens{\printdefunline#3}%
}%
\def#2{\dodefunx#1}%
\def#3%
}
-\newif\ifdoingtypefn % doing typed function?
-\newif\ifrettypeownline % typeset return type on its own line?
-
-% @deftypefnnewline on|off says whether the return type of typed functions
-% are printed on their own line. This affects @deftypefn, @deftypefun,
-% @deftypeop, and @deftypemethod.
-%
-\parseargdef\deftypefnnewline{%
- \def\temp{#1}%
- \ifx\temp\onword
- \expandafter\let\csname SETtxideftypefnnl\endcsname
- = \empty
- \else\ifx\temp\offword
- \expandafter\let\csname SETtxideftypefnnl\endcsname
- = \relax
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @txideftypefnnl value `\temp',
- must be on|off}%
- \fi\fi
-}
-
-% Untyped functions:
+%%% Untyped functions:
% @deffn category name args
\makedefun{deffn}{\deffngeneral{}}
@@ -6922,7 +6317,7 @@ end
\defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
}
-% Typed functions:
+%%% Typed functions:
% @deftypefn category type name args
\makedefun{deftypefn}{\deftypefngeneral{}}
@@ -6937,11 +6332,10 @@ end
%
\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
\dosubind{fn}{\code{#4}}{#1}%
- \doingtypefntrue
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
}
-% Typed variables:
+%%% Typed variables:
% @deftypevr category type var args
\makedefun{deftypevr}{\deftypecvgeneral{}}
@@ -6959,7 +6353,7 @@ end
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
}
-% Untyped variables:
+%%% Untyped variables:
% @defvr category var args
\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
@@ -6970,8 +6364,7 @@ end
% \defcvof {category of}class var args
\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
-% Types:
-
+%%% Type:
% @deftp category name args
\makedefun{deftp}#1 #2 #3\endheader{%
\doind{tp}{\code{#2}}%
@@ -6999,49 +6392,25 @@ end
% We are followed by (but not passed) the arguments, if any.
%
\def\defname#1#2#3{%
- \par
% Get the values of \leftskip and \rightskip as they were outside the @def...
\advance\leftskip by -\defbodyindent
%
- % Determine if we are typesetting the return type of a typed function
- % on a line by itself.
- \rettypeownlinefalse
- \ifdoingtypefn % doing a typed function specifically?
- % then check user option for putting return type on its own line:
- \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
- \rettypeownlinetrue
- \fi
- \fi
- %
- % How we'll format the category name. Putting it in brackets helps
+ % How we'll format the type name. Putting it in brackets helps
% distinguish it from the body text that may end up on the next line
% just below it.
\def\temp{#1}%
\setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
%
- % Figure out line sizes for the paragraph shape. We'll always have at
- % least two.
- \tempnum = 2
- %
+ % Figure out line sizes for the paragraph shape.
% The first line needs space for \box0; but if \rightskip is nonzero,
% we need only space for the part of \box0 which exceeds it:
\dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
- %
- % If doing a return type on its own line, we'll have another line.
- \ifrettypeownline
- \advance\tempnum by 1
- \def\maybeshapeline{0in \hsize}%
- \else
- \def\maybeshapeline{}%
- \fi
- %
% The continuations:
\dimen2=\hsize \advance\dimen2 by -\defargsindent
+ % (plain.tex says that \dimen1 should be used only as global.)
+ \parshape 2 0in \dimen0 \defargsindent \dimen2
%
- % The final paragraph shape:
- \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
- %
- % Put the category name at the right margin.
+ % Put the type name to the right margin.
\noindent
\hbox to 0pt{%
\hfil\box0 \kern-\hsize
@@ -7063,16 +6432,8 @@ end
% . this still does not fix the ?` and !` ligatures, but so far no
% one has made identifiers using them :).
\df \tt
- \def\temp{#2}% text of the return type
- \ifx\temp\empty\else
- \tclose{\temp}% typeset the return type
- \ifrettypeownline
- % put return type on its own line; prohibit line break following:
- \hfil\vadjust{\nobreak}\break
- \else
- \space % type on same line, so just followed by a space
- \fi
- \fi % no return type
+ \def\temp{#2}% return value type
+ \ifx\temp\empty\else \tclose{\temp} \fi
#3% output function name
}%
{\rm\enskip}% hskip 0.5 em of \tenrm
@@ -7092,11 +6453,8 @@ end
\df \sl \hyphenchar\font=0
%
% On the other hand, if an argument has two dashes (for instance), we
- % want a way to get ttsl. We used to recommend @var for that, so
- % leave the code in, but it's strange for @var to lead to typewriter.
- % Nowadays we recommend @code, since the difference between a ttsl hyphen
- % and a tt hyphen is pretty tiny. @code also disables ?` !`.
- \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
+ % want a way to get ttsl. Let's try @var for that.
+ \let\var=\ttslanted
#1%
\sl\hyphenchar\font=45
}
@@ -7193,7 +6551,7 @@ end
% To do this right we need a feature of e-TeX, \scantokens,
% which we arrange to emulate with a temporary file in ordinary TeX.
-\ifx\eTeXversion\thisisundefined
+\ifx\eTeXversion\undefined
\newwrite\macscribble
\def\scantokens#1{%
\toks0={#1}%
@@ -7204,30 +6562,25 @@ end
}
\fi
-\def\scanmacro#1{\begingroup
- \newlinechar`\^^M
- \let\xeatspaces\eatspaces
- %
- % Undo catcode changes of \startcontents and \doprintindex
- % When called from @insertcopying or (short)caption, we need active
- % backslash to get it printed correctly. Previously, we had
- % \catcode`\\=\other instead. We'll see whether a problem appears
- % with macro expansion. --kasal, 19aug04
- \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
- %
- % ... and for \example:
- \spaceisspace
- %
- % The \empty here causes a following catcode 5 newline to be eaten as
- % part of reading whitespace after a control sequence. It does not
- % eat a catcode 13 newline. There's no good way to handle the two
- % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
- % would then have different behavior). See the Macro Details node in
- % the manual for the workaround we recommend for macros and
- % line-oriented commands.
- %
- \scantokens{#1\empty}%
-\endgroup}
+\def\scanmacro#1{%
+ \begingroup
+ \newlinechar`\^^M
+ \let\xeatspaces\eatspaces
+ % Undo catcode changes of \startcontents and \doprintindex
+ % When called from @insertcopying or (short)caption, we need active
+ % backslash to get it printed correctly. Previously, we had
+ % \catcode`\\=\other instead. We'll see whether a problem appears
+ % with macro expansion. --kasal, 19aug04
+ \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
+ % ... and \example
+ \spaceisspace
+ %
+ % Append \endinput to make sure that TeX does not see the ending newline.
+ % I've verified that it is necessary both for e-TeX and for ordinary TeX
+ % --kasal, 29nov03
+ \scantokens{#1\endinput}%
+ \endgroup
+}
\def\scanexp#1{%
\edef\temp{\noexpand\scanmacro{#1}}%
@@ -7255,7 +6608,7 @@ end
% This does \let #1 = #2, with \csnames; that is,
% \let \csname#1\endcsname = \csname#2\endcsname
% (except of course we have to play expansion games).
-%
+%
\def\cslet#1#2{%
\expandafter\let
\csname#1\expandafter\endcsname
@@ -7281,18 +6634,17 @@ end
% Macro bodies are absorbed as an argument in a context where
% all characters are catcode 10, 11 or 12, except \ which is active
-% (as in normal texinfo). It is necessary to change the definition of \
-% to recognize macro arguments; this is the job of \mbodybackslash.
-%
+% (as in normal texinfo). It is necessary to change the definition of \.
+
% Non-ASCII encodings make 8-bit characters active, so un-activate
% them to avoid their expansion. Must do this non-globally, to
% confine the change to the current group.
-%
+
% It's necessary to have hard CRs when the macro is executed. This is
-% done by making ^^M (\endlinechar) catcode 12 when reading the macro
+% done by making ^^M (\endlinechar) catcode 12 when reading the macro
% body, and then making it the \newlinechar in \scanmacro.
-%
-\def\scanctxt{% used as subroutine
+
+\def\scanctxt{%
\catcode`\"=\other
\catcode`\+=\other
\catcode`\<=\other
@@ -7305,13 +6657,13 @@ end
\ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
}
-\def\scanargctxt{% used for copying and captions, not macros.
+\def\scanargctxt{%
\scanctxt
\catcode`\\=\other
\catcode`\^^M=\other
}
-\def\macrobodyctxt{% used for @macro definitions
+\def\macrobodyctxt{%
\scanctxt
\catcode`\{=\other
\catcode`\}=\other
@@ -7319,56 +6671,32 @@ end
\usembodybackslash
}
-\def\macroargctxt{% used when scanning invocations
+\def\macroargctxt{%
\scanctxt
- \catcode`\\=0
+ \catcode`\\=\other
}
-% why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes"
-% for the single characters \ { }. Thus, we end up with the "commands"
-% that would be written @\ @{ @} in a Texinfo document.
-%
-% We already have @{ and @}. For @\, we define it here, and only for
-% this purpose, to produce a typewriter backslash (so, the @\ that we
-% define for @math can't be used with @macro calls):
-%
-\def\\{\normalbackslash}%
-%
-% We would like to do this for \, too, since that is what makeinfo does.
-% But it is not possible, because Texinfo already has a command @, for a
-% cedilla accent. Documents must use @comma{} instead.
-%
-% \anythingelse will almost certainly be an error of some kind.
-
% \mbodybackslash is the definition of \ in @macro bodies.
% It maps \foo\ => \csname macarg.foo\endcsname => #N
% where N is the macro parameter number.
% We define \csname macarg.\endcsname to be \realbackslash, so
% \\ in macro replacement text gets you a backslash.
-%
+
{\catcode`@=0 @catcode`@\=@active
@gdef@usembodybackslash{@let\=@mbodybackslash}
@gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
}
\expandafter\def\csname macarg.\endcsname{\realbackslash}
-\def\margbackslash#1{\char`\#1 }
-
\def\macro{\recursivefalse\parsearg\macroxxx}
\def\rmacro{\recursivetrue\parsearg\macroxxx}
\def\macroxxx#1{%
- \getargs{#1}% now \macname is the macname and \argl the arglist
+ \getargs{#1}% now \macname is the macname and \argl the arglist
\ifx\argl\empty % no arguments
- \paramno=0\relax
+ \paramno=0%
\else
\expandafter\parsemargdef \argl;%
- \if\paramno>256\relax
- \ifx\eTeXversion\thisisundefined
- \errhelp = \EMsimple
- \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
- \fi
- \fi
\fi
\if1\csname ismacro.\the\macname\endcsname
\message{Warning: redefining \the\macname}%
@@ -7415,269 +6743,46 @@ end
% an opening brace, and that opening brace is not consumed.
\def\getargs#1{\getargsxxx#1{}}
\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
-\def\getmacname#1 #2\relax{\macname={#1}}
+\def\getmacname #1 #2\relax{\macname={#1}}
\def\getmacargs#1{\def\argl{#1}}
-% For macro processing make @ a letter so that we can make Texinfo private macro names.
-\edef\texiatcatcode{\the\catcode`\@}
-\catcode `@=11\relax
-
% Parse the optional {params} list. Set up \paramno and \paramlist
-% so \defmacro knows what to do. Define \macarg.BLAH for each BLAH
-% in the params list to some hook where the argument si to be expanded. If
-% there are less than 10 arguments that hook is to be replaced by ##N where N
-% is the position in that list, that is to say the macro arguments are to be
-% defined `a la TeX in the macro body.
-%
+% so \defmacro knows what to do. Define \macarg.blah for each blah
+% in the params list, to be ##N where N is the position in that list.
% That gets used by \mbodybackslash (above).
-%
+
% We need to get `macro parameter char #' into several definitions.
-% The technique used is stolen from LaTeX: let \hash be something
+% The technique used is stolen from LaTeX: let \hash be something
% unexpandable, insert that wherever you need a #, and then redefine
% it to # just before using the token list produced.
%
% The same technique is used to protect \eatspaces till just before
% the macro is used.
-%
-% If there are 10 or more arguments, a different technique is used, where the
-% hook remains in the body, and when macro is to be expanded the body is
-% processed again to replace the arguments.
-%
-% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
-% argument N value and then \edef the body (nothing else will expand because of
-% the catcode regime underwhich the body was input).
-%
-% If you compile with TeX (not eTeX), and you have macros with 10 or more
-% arguments, you need that no macro has more than 256 arguments, otherwise an
-% error is produced.
-\def\parsemargdef#1;{%
- \paramno=0\def\paramlist{}%
- \let\hash\relax
- \let\xeatspaces\relax
- \parsemargdefxxx#1,;,%
- % In case that there are 10 or more arguments we parse again the arguments
- % list to set new definitions for the \macarg.BLAH macros corresponding to
- % each BLAH argument. It was anyhow needed to parse already once this list
- % in order to count the arguments, and as macros with at most 9 arguments
- % are by far more frequent than macro with 10 or more arguments, defining
- % twice the \macarg.BLAH macros does not cost too much processing power.
- \ifnum\paramno<10\relax\else
- \paramno0\relax
- \parsemmanyargdef@@#1,;,% 10 or more arguments
- \fi
-}
+
+\def\parsemargdef#1;{\paramno=0\def\paramlist{}%
+ \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
\def\parsemargdefxxx#1,{%
\if#1;\let\next=\relax
\else \let\next=\parsemargdefxxx
- \advance\paramno by 1
+ \advance\paramno by 1%
\expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
{\xeatspaces{\hash\the\paramno}}%
\edef\paramlist{\paramlist\hash\the\paramno,}%
\fi\next}
-\def\parsemmanyargdef@@#1,{%
- \if#1;\let\next=\relax
- \else
- \let\next=\parsemmanyargdef@@
- \edef\tempb{\eatspaces{#1}}%
- \expandafter\def\expandafter\tempa
- \expandafter{\csname macarg.\tempb\endcsname}%
- % Note that we need some extra \noexpand\noexpand, this is because we
- % don't want \the to be expanded in the \parsermacbody as it uses an
- % \xdef .
- \expandafter\edef\tempa
- {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
- \advance\paramno by 1\relax
- \fi\next}
-
% These two commands read recursive and nonrecursive macro bodies.
% (They're different since rec and nonrec macros end differently.)
-%
-\catcode `\@\texiatcatcode
\long\def\parsemacbody#1@end macro%
{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
\long\def\parsermacbody#1@end rmacro%
{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
-\catcode `\@=11\relax
-
-\let\endargs@\relax
-\let\nil@\relax
-\def\nilm@{\nil@}%
-\long\def\nillm@{\nil@}%
-
-% This macro is expanded during the Texinfo macro expansion, not during its
-% definition. It gets all the arguments values and assigns them to macros
-% macarg.ARGNAME
-%
-% #1 is the macro name
-% #2 is the list of argument names
-% #3 is the list of argument values
-\def\getargvals@#1#2#3{%
- \def\macargdeflist@{}%
- \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
- \def\paramlist{#2,\nil@}%
- \def\macroname{#1}%
- \begingroup
- \macroargctxt
- \def\argvaluelist{#3,\nil@}%
- \def\@tempa{#3}%
- \ifx\@tempa\empty
- \setemptyargvalues@
- \else
- \getargvals@@
- \fi
-}
-
-%
-\def\getargvals@@{%
- \ifx\paramlist\nilm@
- % Some sanity check needed here that \argvaluelist is also empty.
- \ifx\argvaluelist\nillm@
- \else
- \errhelp = \EMsimple
- \errmessage{Too many arguments in macro `\macroname'!}%
- \fi
- \let\next\macargexpandinbody@
- \else
- \ifx\argvaluelist\nillm@
- % No more arguments values passed to macro. Set remaining named-arg
- % macros to empty.
- \let\next\setemptyargvalues@
- \else
- % pop current arg name into \@tempb
- \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
- \expandafter\@tempa\expandafter{\paramlist}%
- % pop current argument value into \@tempc
- \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
- \expandafter\@tempa\expandafter{\argvaluelist}%
- % Here \@tempb is the current arg name and \@tempc is the current arg value.
- % First place the new argument macro definition into \@tempd
- \expandafter\macname\expandafter{\@tempc}%
- \expandafter\let\csname macarg.\@tempb\endcsname\relax
- \expandafter\def\expandafter\@tempe\expandafter{%
- \csname macarg.\@tempb\endcsname}%
- \edef\@tempd{\long\def\@tempe{\the\macname}}%
- \push@\@tempd\macargdeflist@
- \let\next\getargvals@@
- \fi
- \fi
- \next
-}
-
-\def\push@#1#2{%
- \expandafter\expandafter\expandafter\def
- \expandafter\expandafter\expandafter#2%
- \expandafter\expandafter\expandafter{%
- \expandafter#1#2}%
-}
-
-% Replace arguments by their values in the macro body, and place the result
-% in macro \@tempa
-\def\macvalstoargs@{%
- % To do this we use the property that token registers that are \the'ed
- % within an \edef expand only once. So we are going to place all argument
- % values into respective token registers.
- %
- % First we save the token context, and initialize argument numbering.
- \begingroup
- \paramno0\relax
- % Then, for each argument number #N, we place the corresponding argument
- % value into a new token list register \toks#N
- \expandafter\putargsintokens@\saveparamlist@,;,%
- % Then, we expand the body so that argument are replaced by their
- % values. The trick for values not to be expanded themselves is that they
- % are within tokens and that tokens expand only once in an \edef .
- \edef\@tempc{\csname mac.\macroname .body\endcsname}%
- % Now we restore the token stack pointer to free the token list registers
- % which we have used, but we make sure that expanded body is saved after
- % group.
- \expandafter
- \endgroup
- \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
- }
-
-\def\macargexpandinbody@{%
- %% Define the named-macro outside of this group and then close this group.
- \expandafter
- \endgroup
- \macargdeflist@
- % First the replace in body the macro arguments by their values, the result
- % is in \@tempa .
- \macvalstoargs@
- % Then we point at the \norecurse or \gobble (for recursive) macro value
- % with \@tempb .
- \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
- % Depending on whether it is recursive or not, we need some tailing
- % \egroup .
- \ifx\@tempb\gobble
- \let\@tempc\relax
- \else
- \let\@tempc\egroup
- \fi
- % And now we do the real job:
- \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
- \@tempd
-}
-
-\def\putargsintokens@#1,{%
- \if#1;\let\next\relax
- \else
- \let\next\putargsintokens@
- % First we allocate the new token list register, and give it a temporary
- % alias \@tempb .
- \toksdef\@tempb\the\paramno
- % Then we place the argument value into that token list register.
- \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
- \expandafter\@tempb\expandafter{\@tempa}%
- \advance\paramno by 1\relax
- \fi
- \next
-}
-
-% Save the token stack pointer into macro #1
-\def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}}
-% Restore the token stack pointer from number in macro #1
-\def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax}
-% newtoks that can be used non \outer .
-\def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi}
-
-% Tailing missing arguments are set to empty
-\def\setemptyargvalues@{%
- \ifx\paramlist\nilm@
- \let\next\macargexpandinbody@
- \else
- \expandafter\setemptyargvaluesparser@\paramlist\endargs@
- \let\next\setemptyargvalues@
- \fi
- \next
-}
-\def\setemptyargvaluesparser@#1,#2\endargs@{%
- \expandafter\def\expandafter\@tempa\expandafter{%
- \expandafter\def\csname macarg.#1\endcsname{}}%
- \push@\@tempa\macargdeflist@
- \def\paramlist{#2}%
-}
-
-% #1 is the element target macro
-% #2 is the list macro
-% #3,#4\endargs@ is the list value
-\def\pop@#1#2#3,#4\endargs@{%
- \def#1{#3}%
- \def#2{#4}%
-}
-\long\def\longpop@#1#2#3,#4\endargs@{%
- \long\def#1{#3}%
- \long\def#2{#4}%
-}
-
-% This defines a Texinfo @macro. There are eight cases: recursive and
-% nonrecursive macros of zero, one, up to nine, and many arguments.
+% This defines the macro itself. There are six cases: recursive and
+% nonrecursive macros of zero, one, and many arguments.
% Much magic with \expandafter here.
% \xdef is used so that macro definitions will survive the file
% they're defined in; @include reads the file inside a group.
-%
\def\defmacro{%
\let\hash=##% convert placeholders to macro parameter chars
\ifrecursive
@@ -7692,25 +6797,17 @@ end
\expandafter\noexpand\csname\the\macname xxx\endcsname}%
\expandafter\xdef\csname\the\macname xxx\endcsname##1{%
\egroup\noexpand\scanmacro{\temp}}%
- \else
- \ifnum\paramno<10\relax % at most 9
- \expandafter\xdef\csname\the\macname\endcsname{%
- \bgroup\noexpand\macroargctxt
- \noexpand\csname\the\macname xx\endcsname}%
- \expandafter\xdef\csname\the\macname xx\endcsname##1{%
- \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
- \expandafter\expandafter
- \expandafter\xdef
- \expandafter\expandafter
- \csname\the\macname xxx\endcsname
- \paramlist{\egroup\noexpand\scanmacro{\temp}}%
- \else % 10 or more
- \expandafter\xdef\csname\the\macname\endcsname{%
- \noexpand\getargvals@{\the\macname}{\argl}%
- }%
- \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
- \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
- \fi
+ \else % many
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\csname\the\macname xx\endcsname}%
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{\egroup\noexpand\scanmacro{\temp}}%
\fi
\else
\ifcase\paramno
@@ -7727,40 +6824,29 @@ end
\egroup
\noexpand\norecurse{\the\macname}%
\noexpand\scanmacro{\temp}\egroup}%
- \else % at most 9
- \ifnum\paramno<10\relax
- \expandafter\xdef\csname\the\macname\endcsname{%
- \bgroup\noexpand\macroargctxt
- \expandafter\noexpand\csname\the\macname xx\endcsname}%
- \expandafter\xdef\csname\the\macname xx\endcsname##1{%
- \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
- \expandafter\expandafter
- \expandafter\xdef
- \expandafter\expandafter
- \csname\the\macname xxx\endcsname
- \paramlist{%
- \egroup
- \noexpand\norecurse{\the\macname}%
- \noexpand\scanmacro{\temp}\egroup}%
- \else % 10 or more:
- \expandafter\xdef\csname\the\macname\endcsname{%
- \noexpand\getargvals@{\the\macname}{\argl}%
- }%
- \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
- \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
- \fi
+ \else % many
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \expandafter\noexpand\csname\the\macname xx\endcsname}%
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{%
+ \egroup
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
\fi
\fi}
-\catcode `\@\texiatcatcode\relax
-
\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
% \braceorline decides whether the next nonwhitespace character is a
% {. If so it reads up to the closing }, if not, it reads the whole
% line. Whatever was read is then fed to the next control sequence
-% as an argument (by \parsebrace or \parsearg).
-%
+% as an argument (by \parsebrace or \parsearg)
\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
\def\braceorlinexxx{%
\ifx\nchar\bgroup\else
@@ -7770,8 +6856,7 @@ end
% @alias.
% We need some trickery to remove the optional spaces around the equal
-% sign. Make them active and then expand them all to nothing.
-%
+% sign. Just make them active and then expand them all to nothing.
\def\alias{\parseargusing\obeyspaces\aliasxxx}
\def\aliasxxx #1{\aliasyyy#1\relax}
\def\aliasyyy #1=#2\relax{%
@@ -7792,8 +6877,7 @@ end
% @inforef is relatively simple.
\def\inforef #1{\inforefzzz #1,,,,**}
-\def\inforefzzz #1,#2,#3,#4**{%
- \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
+\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
node \samp{\ignorespaces#1{}}}
% @node's only job in TeX is to define \lastnode, which is used in
@@ -7854,32 +6938,11 @@ end
\toks0 = \expandafter{\lastsection}%
\immediate \writexrdef{title}{\the\toks0 }%
\immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
- \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
+ \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, during \shipout
}%
\fi
}
-% @xrefautosectiontitle on|off says whether @section(ing) names are used
-% automatically in xrefs, if the third arg is not explicitly specified.
-% This was provided as a "secret" @set xref-automatic-section-title
-% variable, now it's official.
-%
-\parseargdef\xrefautomaticsectiontitle{%
- \def\temp{#1}%
- \ifx\temp\onword
- \expandafter\let\csname SETxref-automatic-section-title\endcsname
- = \empty
- \else\ifx\temp\offword
- \expandafter\let\csname SETxref-automatic-section-title\endcsname
- = \relax
- \else
- \errhelp = \EMsimple
- \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
- must be on|off}%
- \fi\fi
-}
-
-%
% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
% the node name, #2 the name of the Info cross-reference, #3 the printed
% node name, #4 the name of the Info file, #5 the name of the printed
@@ -7888,41 +6951,26 @@ end
\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
\def\ref#1{\xrefX[#1,,,,,,,]}
-%
-\newbox\toprefbox
-\newbox\printedrefnamebox
-\newbox\infofilenamebox
-\newbox\printedmanualbox
-%
\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
\unsepspaces
- %
- % Get args without leading/trailing spaces.
- \def\printedrefname{\ignorespaces #3}%
- \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
- %
- \def\infofilename{\ignorespaces #4}%
- \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
- %
\def\printedmanual{\ignorespaces #5}%
- \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
- %
- % If the printed reference name (arg #3) was not explicitly given in
- % the @xref, figure out what we want to use.
- \ifdim \wd\printedrefnamebox = 0pt
+ \def\printedrefname{\ignorespaces #3}%
+ \setbox1=\hbox{\printedmanual\unskip}%
+ \setbox0=\hbox{\printedrefname\unskip}%
+ \ifdim \wd0 = 0pt
% No printed node name was explicitly given.
- \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
- % Not auto section-title: use node name inside the square brackets.
+ \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
+ % Use the node name inside the square brackets.
\def\printedrefname{\ignorespaces #1}%
\else
- % Auto section-title: use chapter/section title inside
- % the square brackets if we have it.
- \ifdim \wd\printedmanualbox > 0pt
- % It is in another manual, so we don't have it; use node name.
+ % Use the actual chapter/section title appear inside
+ % the square brackets. Use the real section title if we have it.
+ \ifdim \wd1 > 0pt
+ % It is in another manual, so we don't have it.
\def\printedrefname{\ignorespaces #1}%
\else
\ifhavexrefs
- % We (should) know the real title if we have the xref values.
+ % We know the real title if we have the xref values.
\def\printedrefname{\refx{#1-title}{}}%
\else
% Otherwise just copy the Info node name.
@@ -7936,20 +6984,13 @@ end
\ifpdf
{\indexnofonts
\turnoffactive
- \makevalueexpandable
% This expands tokens, so do it after making catcode changes, so _
- % etc. don't get their TeX definitions. This ignores all spaces in
- % #4, including (wrongly) those in the middle of the filename.
+ % etc. don't get their TeX definitions.
\getfilename{#4}%
%
- % This (wrongly) does not take account of leading or trailing
- % spaces in #1, which should be ignored.
- \edef\pdfxrefdest{#1}%
- \ifx\pdfxrefdest\empty
- \def\pdfxrefdest{Top}% no empty targets
- \else
- \txiescapepdf\pdfxrefdest % escape PDF special chars
- \fi
+ % See comments at \activebackslashdouble.
+ {\activebackslashdouble \xdef\pdfxrefdest{#1}%
+ \backslashparens\pdfxrefdest}%
%
\leavevmode
\startlink attr{/Border [0 0 0]}%
@@ -7976,42 +7017,29 @@ end
\iffloat\Xthisreftitle
% If the user specified the print name (third arg) to the ref,
% print it instead of our usual "Figure 1.2".
- \ifdim\wd\printedrefnamebox = 0pt
+ \ifdim\wd0 = 0pt
\refx{#1-snt}{}%
\else
\printedrefname
\fi
%
- % If the user also gave the printed manual name (fifth arg), append
+ % if the user also gave the printed manual name (fifth arg), append
% "in MANUALNAME".
- \ifdim \wd\printedmanualbox > 0pt
+ \ifdim \wd1 > 0pt
\space \putwordin{} \cite{\printedmanual}%
\fi
\else
% node/anchor (non-float) references.
- %
- % If we use \unhbox to print the node names, TeX does not insert
- % empty discretionaries after hyphens, which means that it will not
- % find a line break at a hyphen in a node names. Since some manuals
- % are best written with fairly long node names, containing hyphens,
- % this is a loss. Therefore, we give the text of the node name
- % again, so it is as if TeX is seeing it for the first time.
- %
- \ifdim \wd\printedmanualbox > 0pt
- % Cross-manual reference with a printed manual name.
- %
- \crossmanualxref{\cite{\printedmanual\unskip}}%
- %
- \else\ifdim \wd\infofilenamebox > 0pt
- % Cross-manual reference with only an info filename (arg 4), no
- % printed manual name (arg 5). This is essentially the same as
- % the case above; we output the filename, since we have nothing else.
- %
- \crossmanualxref{\code{\infofilename\unskip}}%
%
+ % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
+ % insert empty discretionaries after hyphens, which means that it will
+ % not find a line break at a hyphen in a node names. Since some manuals
+ % are best written with fairly long node names, containing hyphens, this
+ % is a loss. Therefore, we give the text of the node name again, so it
+ % is as if TeX is seeing it for the first time.
+ \ifdim \wd1 > 0pt
+ \putwordSection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
\else
- % Reference within this manual.
- %
% _ (for example) has to be the character _ for the purposes of the
% control sequence corresponding to the node, but it has to expand
% into the usual \leavevmode...\vrule stuff for purposes of
@@ -8023,7 +7051,7 @@ end
\setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
\ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
}%
- % output the `[mynode]' via the macro below so it can be overridden.
+ % output the `[mynode]' via a macro so it can be overridden.
\xrefprintnodename\printedrefname
%
% But we always want a comma and a space:
@@ -8031,37 +7059,11 @@ end
%
% output the `page 3'.
\turnoffactive \putwordpage\tie\refx{#1-pg}{}%
- \fi\fi
+ \fi
\fi
\endlink
\endgroup}
-% Output a cross-manual xref to #1. Used just above (twice).
-%
-% Only include the text "Section ``foo'' in" if the foo is neither
-% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
-% "see The Foo Manual", the idea being to refer to the whole manual.
-%
-% But, this being TeX, we can't easily compare our node name against the
-% string "Top" while ignoring the possible spaces before and after in
-% the input. By adding the arbitrary 7sp below, we make it much less
-% likely that a real node name would have the same width as "Top" (e.g.,
-% in a monospaced font). Hopefully it will never happen in practice.
-%
-% For the same basic reason, we retypeset the "Top" at every
-% reference, since the current font is indeterminate.
-%
-\def\crossmanualxref#1{%
- \setbox\toprefbox = \hbox{Top\kern7sp}%
- \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
- \ifdim \wd2 > 7sp % nonempty?
- \ifdim \wd2 = \wd\toprefbox \else % same as Top?
- \putwordSection{} ``\printedrefname'' \putwordin{}\space
- \fi
- \fi
- #1%
-}
-
% This macro is called from \xrefX for the `[nodename]' part of xref
% output. It's a separate macro only so it can be changed more easily,
% since square brackets don't work well in some documents. Particularly
@@ -8112,8 +7114,7 @@ end
\angleleft un\-de\-fined\angleright
\iflinks
\ifhavexrefs
- {\toks0 = {#1}% avoid expansion of possibly-complex value
- \message{\linenumber Undefined cross reference `\the\toks0'.}}%
+ \message{\linenumber Undefined cross reference `#1'.}%
\else
\ifwarnedxrefs\else
\global\warnedxrefstrue
@@ -8277,7 +7278,7 @@ end
% space to prevent strange expansion errors.)
\def\supereject{\par\penalty -20000\footnoteno =0 }
-% @footnotestyle is meaningful for Info output only.
+% @footnotestyle is meaningful for info output only.
\let\footnotestyle=\comment
{\catcode `\@=11
@@ -8340,8 +7341,6 @@ end
% expands into a box, it must come within the paragraph, lest it
% provide a place where TeX can split the footnote.
\footstrut
- %
- % Invoke rest of plain TeX footnote routine.
\futurelet\next\fo@t
}
}%end \catcode `\@=11
@@ -8429,7 +7428,7 @@ end
it from ftp://tug.org/tex/epsf.tex.}
%
\def\image#1{%
- \ifx\epsfbox\thisisundefined
+ \ifx\epsfbox\undefined
\ifwarnednoepsf \else
\errhelp = \noepsfhelp
\errmessage{epsf.tex not found, images will be ignored}%
@@ -8445,7 +7444,7 @@ end
% #2 is (optional) width, #3 is (optional) height.
% #4 is (ignored optional) html alt text.
% #5 is (ignored optional) extension.
-% #6 is just the usual extra ignored arg for parsing stuff.
+% #6 is just the usual extra ignored arg for parsing this stuff.
\newif\ifimagevmode
\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
\catcode`\^^M = 5 % in case we're inside an example
@@ -8453,13 +7452,6 @@ end
% If the image is by itself, center it.
\ifvmode
\imagevmodetrue
- \else \ifx\centersub\centerV
- % for @center @image, we need a vbox so we can have our vertical space
- \imagevmodetrue
- \vbox\bgroup % vbox has better behavior than vtop herev
- \fi\fi
- %
- \ifimagevmode
\nobreak\medskip
% Usually we'll have text after the image which will insert
% \parskip glue, so insert it here too to equalize the space
@@ -8469,13 +7461,9 @@ end
\fi
%
% Leave vertical mode so that indentation from an enclosing
- % environment such as @quotation is respected.
- % However, if we're at the top level, we don't want the
- % normal paragraph indentation.
- % On the other hand, if we are in the case of @center @image, we don't
- % want to start a paragraph, which will create a hsize-width box and
- % eradicate the centering.
- \ifx\centersub\centerV\else \noindent \fi
+ % environment such as @quotation is respected. On the other hand, if
+ % it's at the top level, we don't want the normal paragraph indentation.
+ \noindent
%
% Output the image.
\ifpdf
@@ -8487,10 +7475,7 @@ end
\epsfbox{#1.eps}%
\fi
%
- \ifimagevmode
- \medskip % space after a standalone image
- \fi
- \ifx\centersub\centerV \egroup \fi
+ \ifimagevmode \medskip \fi % space after the standalone image
\endgroup}
@@ -8762,9 +7747,10 @@ end
\message{localization,}
-% For single-language documents, @documentlanguage is usually given very
-% early, just after @documentencoding. Single argument is the language
-% (de) or locale (de_DE) abbreviation.
+% @documentlanguage is usually given very early, just after
+% @setfilename. If done too late, it may not override everything
+% properly. Single argument is the language (de) or locale (de_DE)
+% abbreviation. It would be nice if we could set up a hyphenation file.
%
{
\catcode`\_ = \active
@@ -8777,60 +7763,31 @@ end
\ifeof 1
\documentlanguagetrywithoutunderscore{#1_\finish}%
\else
- \globaldefs = 1 % everything in the txi-LL files needs to persist
\input txi-#1.tex
\fi
\closein 1
- \endgroup % end raw TeX
+ \endgroup
\endgroup}
+}
%
% If they passed de_DE, and txi-de_DE.tex doesn't exist,
% try txi-de.tex.
-%
-\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
+%
+\def\documentlanguagetrywithoutunderscore#1_#2\finish{%
\openin 1 txi-#1.tex
\ifeof 1
\errhelp = \nolanghelp
\errmessage{Cannot read language file txi-#1.tex}%
\else
- \globaldefs = 1 % everything in the txi-LL files needs to persist
\input txi-#1.tex
\fi
\closein 1
}
-}% end of special _ catcode
%
\newhelp\nolanghelp{The given language definition file cannot be found or
-is empty. Maybe you need to install it? Putting it in the current
-directory should work if nowhere else does.}
+is empty. Maybe you need to install it? In the current directory
+should work if nowhere else does.}
-% This macro is called from txi-??.tex files; the first argument is the
-% \language name to set (without the "\lang@" prefix), the second and
-% third args are \{left,right}hyphenmin.
-%
-% The language names to pass are determined when the format is built.
-% See the etex.log file created at that time, e.g.,
-% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
-%
-% With TeX Live 2008, etex now includes hyphenation patterns for all
-% available languages. This means we can support hyphenation in
-% Texinfo, at least to some extent. (This still doesn't solve the
-% accented characters problem.)
-%
-\catcode`@=11
-\def\txisetlanguage#1#2#3{%
- % do not set the language if the name is undefined in the current TeX.
- \expandafter\ifx\csname lang@#1\endcsname \relax
- \message{no patterns for #1}%
- \else
- \global\language = \csname lang@#1\endcsname
- \fi
- % but there is no harm in adjusting the hyphenmin values regardless.
- \global\lefthyphenmin = #2\relax
- \global\righthyphenmin = #3\relax
-}
-
-% Helpers for encodings.
% Set the catcode of characters 128 through 255 to the specified number.
%
\def\setnonasciicharscatcode#1{%
@@ -8871,7 +7828,7 @@ directory should work if nowhere else does.}
\setnonasciicharscatcode\active
\lattwochardefs
%
- \else \ifx \declaredencoding \latone
+ \else \ifx \declaredencoding \latone
\setnonasciicharscatcode\active
\latonechardefs
%
@@ -8883,7 +7840,7 @@ directory should work if nowhere else does.}
\setnonasciicharscatcode\active
\utfeightchardefs
%
- \else
+ \else
\message{Unknown document encoding #1, ignoring.}%
%
\fi % utfeight
@@ -8895,7 +7852,7 @@ directory should work if nowhere else does.}
% A message to be logged when using a character that isn't available
% the default font encoding (OT1).
-%
+%
\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
% Take account of \c (plain) vs. \, (Texinfo) difference.
@@ -8908,21 +7865,21 @@ directory should work if nowhere else does.}
%
% Latin1 (ISO-8859-1) character definitions.
\def\latonechardefs{%
- \gdef^^a0{\tie}
+ \gdef^^a0{~}
\gdef^^a1{\exclamdown}
- \gdef^^a2{\missingcharmsg{CENT SIGN}}
+ \gdef^^a2{\missingcharmsg{CENT SIGN}}
\gdef^^a3{{\pounds}}
\gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
\gdef^^a5{\missingcharmsg{YEN SIGN}}
- \gdef^^a6{\missingcharmsg{BROKEN BAR}}
+ \gdef^^a6{\missingcharmsg{BROKEN BAR}}
\gdef^^a7{\S}
- \gdef^^a8{\"{}}
- \gdef^^a9{\copyright}
+ \gdef^^a8{\"{}}
+ \gdef^^a9{\copyright}
\gdef^^aa{\ordf}
- \gdef^^ab{\guillemetleft}
+ \gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}}
\gdef^^ac{$\lnot$}
- \gdef^^ad{\-}
- \gdef^^ae{\registeredsymbol}
+ \gdef^^ad{\-}
+ \gdef^^ae{\registeredsymbol}
\gdef^^af{\={}}
%
\gdef^^b0{\textdegree}
@@ -8938,7 +7895,7 @@ directory should work if nowhere else does.}
\gdef^^b9{$^1$}
\gdef^^ba{\ordm}
%
- \gdef^^bb{\guillemetright}
+ \gdef^^bb{\missingcharmsg{RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK}}
\gdef^^bc{$1\over4$}
\gdef^^bd{$1\over2$}
\gdef^^be{$3\over4$}
@@ -8949,7 +7906,7 @@ directory should work if nowhere else does.}
\gdef^^c2{\^A}
\gdef^^c3{\~A}
\gdef^^c4{\"A}
- \gdef^^c5{\ringaccent A}
+ \gdef^^c5{\ringaccent A}
\gdef^^c6{\AE}
\gdef^^c7{\cedilla C}
\gdef^^c8{\`E}
@@ -8961,7 +7918,7 @@ directory should work if nowhere else does.}
\gdef^^ce{\^I}
\gdef^^cf{\"I}
%
- \gdef^^d0{\DH}
+ \gdef^^d0{\missingcharmsg{LATIN CAPITAL LETTER ETH}}
\gdef^^d1{\~N}
\gdef^^d2{\`O}
\gdef^^d3{\'O}
@@ -8975,7 +7932,7 @@ directory should work if nowhere else does.}
\gdef^^db{\^U}
\gdef^^dc{\"U}
\gdef^^dd{\'Y}
- \gdef^^de{\TH}
+ \gdef^^de{\missingcharmsg{LATIN CAPITAL LETTER THORN}}
\gdef^^df{\ss}
%
\gdef^^e0{\`a}
@@ -8995,7 +7952,7 @@ directory should work if nowhere else does.}
\gdef^^ee{\^{\dotless i}}
\gdef^^ef{\"{\dotless i}}
%
- \gdef^^f0{\dh}
+ \gdef^^f0{\missingcharmsg{LATIN SMALL LETTER ETH}}
\gdef^^f1{\~n}
\gdef^^f2{\`o}
\gdef^^f3{\'o}
@@ -9009,7 +7966,7 @@ directory should work if nowhere else does.}
\gdef^^fb{\^u}
\gdef^^fc{\"u}
\gdef^^fd{\'y}
- \gdef^^fe{\th}
+ \gdef^^fe{\missingcharmsg{LATIN SMALL LETTER THORN}}
\gdef^^ff{\"y}
}
@@ -9030,8 +7987,8 @@ directory should work if nowhere else does.}
% Latin2 (ISO-8859-2) character definitions.
\def\lattwochardefs{%
- \gdef^^a0{\tie}
- \gdef^^a1{\ogonek{A}}
+ \gdef^^a0{~}
+ \gdef^^a1{\missingcharmsg{LATIN CAPITAL LETTER A WITH OGONEK}}
\gdef^^a2{\u{}}
\gdef^^a3{\L}
\gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
@@ -9048,8 +8005,8 @@ directory should work if nowhere else does.}
\gdef^^af{\dotaccent Z}
%
\gdef^^b0{\textdegree}
- \gdef^^b1{\ogonek{a}}
- \gdef^^b2{\ogonek{ }}
+ \gdef^^b1{\missingcharmsg{LATIN SMALL LETTER A WITH OGONEK}}
+ \gdef^^b2{\missingcharmsg{OGONEK}}
\gdef^^b3{\l}
\gdef^^b4{\'{}}
\gdef^^b5{\v l}
@@ -9074,14 +8031,14 @@ directory should work if nowhere else does.}
\gdef^^c7{\cedilla C}
\gdef^^c8{\v C}
\gdef^^c9{\'E}
- \gdef^^ca{\ogonek{E}}
+ \gdef^^ca{\missingcharmsg{LATIN CAPITAL LETTER E WITH OGONEK}}
\gdef^^cb{\"E}
\gdef^^cc{\v E}
\gdef^^cd{\'I}
\gdef^^ce{\^I}
\gdef^^cf{\v D}
%
- \gdef^^d0{\DH}
+ \gdef^^d0{\missingcharmsg{LATIN CAPITAL LETTER D WITH STROKE}}
\gdef^^d1{\'N}
\gdef^^d2{\v N}
\gdef^^d3{\'O}
@@ -9090,7 +8047,7 @@ directory should work if nowhere else does.}
\gdef^^d6{\"O}
\gdef^^d7{$\times$}
\gdef^^d8{\v R}
- \gdef^^d9{\ringaccent U}
+ \gdef^^d9{\ringaccent U}
\gdef^^da{\'U}
\gdef^^db{\H U}
\gdef^^dc{\"U}
@@ -9108,14 +8065,14 @@ directory should work if nowhere else does.}
\gdef^^e7{\cedilla c}
\gdef^^e8{\v c}
\gdef^^e9{\'e}
- \gdef^^ea{\ogonek{e}}
+ \gdef^^ea{\missingcharmsg{LATIN SMALL LETTER E WITH OGONEK}}
\gdef^^eb{\"e}
\gdef^^ec{\v e}
- \gdef^^ed{\'{\dotless{i}}}
- \gdef^^ee{\^{\dotless{i}}}
+ \gdef^^ed{\'\i}
+ \gdef^^ee{\^\i}
\gdef^^ef{\v d}
%
- \gdef^^f0{\dh}
+ \gdef^^f0{\missingcharmsg{LATIN SMALL LETTER D WITH STROKE}}
\gdef^^f1{\'n}
\gdef^^f2{\v n}
\gdef^^f3{\'o}
@@ -9134,11 +8091,11 @@ directory should work if nowhere else does.}
}
% UTF-8 character definitions.
-%
+%
% This code to support UTF-8 is based on LaTeX's utf8.def, with some
% changes for Texinfo conventions. It is included here under the GPL by
% permission from Frank Mittelbach and the LaTeX team.
-%
+%
\newcount\countUTFx
\newcount\countUTFy
\newcount\countUTFz
@@ -9203,7 +8160,7 @@ directory should work if nowhere else does.}
\gdef\DeclareUnicodeCharacter#1#2{%
\countUTFz = "#1\relax
- %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
+ \wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
\begingroup
\parseXMLCharref
\def\UTFviiiTwoOctets##1##2{%
@@ -9288,7 +8245,6 @@ directory should work if nowhere else does.}
\DeclareUnicodeCharacter{00CE}{\^I}
\DeclareUnicodeCharacter{00CF}{\"I}
- \DeclareUnicodeCharacter{00D0}{\DH}
\DeclareUnicodeCharacter{00D1}{\~N}
\DeclareUnicodeCharacter{00D2}{\`O}
\DeclareUnicodeCharacter{00D3}{\'O}
@@ -9301,7 +8257,6 @@ directory should work if nowhere else does.}
\DeclareUnicodeCharacter{00DB}{\^U}
\DeclareUnicodeCharacter{00DC}{\"U}
\DeclareUnicodeCharacter{00DD}{\'Y}
- \DeclareUnicodeCharacter{00DE}{\TH}
\DeclareUnicodeCharacter{00DF}{\ss}
\DeclareUnicodeCharacter{00E0}{\`a}
@@ -9321,7 +8276,6 @@ directory should work if nowhere else does.}
\DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
\DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
- \DeclareUnicodeCharacter{00F0}{\dh}
\DeclareUnicodeCharacter{00F1}{\~n}
\DeclareUnicodeCharacter{00F2}{\`o}
\DeclareUnicodeCharacter{00F3}{\'o}
@@ -9334,21 +8288,16 @@ directory should work if nowhere else does.}
\DeclareUnicodeCharacter{00FB}{\^u}
\DeclareUnicodeCharacter{00FC}{\"u}
\DeclareUnicodeCharacter{00FD}{\'y}
- \DeclareUnicodeCharacter{00FE}{\th}
\DeclareUnicodeCharacter{00FF}{\"y}
\DeclareUnicodeCharacter{0100}{\=A}
\DeclareUnicodeCharacter{0101}{\=a}
\DeclareUnicodeCharacter{0102}{\u{A}}
\DeclareUnicodeCharacter{0103}{\u{a}}
- \DeclareUnicodeCharacter{0104}{\ogonek{A}}
- \DeclareUnicodeCharacter{0105}{\ogonek{a}}
\DeclareUnicodeCharacter{0106}{\'C}
\DeclareUnicodeCharacter{0107}{\'c}
\DeclareUnicodeCharacter{0108}{\^C}
\DeclareUnicodeCharacter{0109}{\^c}
- \DeclareUnicodeCharacter{0118}{\ogonek{E}}
- \DeclareUnicodeCharacter{0119}{\ogonek{e}}
\DeclareUnicodeCharacter{010A}{\dotaccent{C}}
\DeclareUnicodeCharacter{010B}{\dotaccent{c}}
\DeclareUnicodeCharacter{010C}{\v{C}}
@@ -9496,8 +8445,6 @@ directory should work if nowhere else does.}
\DeclareUnicodeCharacter{0233}{\=y}
\DeclareUnicodeCharacter{0237}{\dotless{j}}
- \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
-
\DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
\DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
\DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
@@ -9671,8 +8618,8 @@ directory should work if nowhere else does.}
% Prevent underfull vbox error messages.
\vbadness = 10000
-% Don't be very finicky about underfull hboxes, either.
-\hbadness = 6666
+% Don't be so finicky about underfull hboxes, either.
+\hbadness = 2000
% Following George Bush, get rid of widows and orphans.
\widowpenalty=10000
@@ -9879,21 +8826,25 @@ directory should work if nowhere else does.}
\message{and turning on texinfo input format.}
-\def^^L{\par} % remove \outer, so ^L can appear in an @comment
-
-% DEL is a comment character, in case @c does not suffice.
-\catcode`\^^? = 14
-
% Define macros to output various characters with catcode for normal text.
-\catcode`\"=\other \def\normaldoublequote{"}
-\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
-\catcode`\+=\other \def\normalplus{+}
-\catcode`\<=\other \def\normalless{<}
-\catcode`\>=\other \def\normalgreater{>}
-\catcode`\^=\other \def\normalcaret{^}
-\catcode`\_=\other \def\normalunderscore{_}
-\catcode`\|=\other \def\normalverticalbar{|}
-\catcode`\~=\other \def\normaltilde{~}
+\catcode`\"=\other
+\catcode`\~=\other
+\catcode`\^=\other
+\catcode`\_=\other
+\catcode`\|=\other
+\catcode`\<=\other
+\catcode`\>=\other
+\catcode`\+=\other
+\catcode`\$=\other
+\def\normaldoublequote{"}
+\def\normaltilde{~}
+\def\normalcaret{^}
+\def\normalunderscore{_}
+\def\normalverticalbar{|}
+\def\normalless{<}
+\def\normalgreater{>}
+\def\normalplus{+}
+\def\normaldollar{$}%$ font-lock fix
% This macro is used to make a character print one way in \tt
% (where it can probably be output as-is), and another way in other fonts,
@@ -9971,48 +8922,32 @@ directory should work if nowhere else does.}
% In texinfo, backslash is an active character; it prints the backslash
% in fixed width font.
-\catcode`\\=\active % @ for escape char from now on.
-
-% The story here is that in math mode, the \char of \backslashcurfont
-% ends up printing the roman \ from the math symbol font (because \char
-% in math mode uses the \mathcode, and plain.tex sets
-% \mathcode`\\="026E). It seems better for @backslashchar{} to always
-% print a typewriter backslash, hence we use an explicit \mathchar,
-% which is the decimal equivalent of "715c (class 7, e.g., use \fam;
-% ignored family value; char position "5C). We can't use " for the
-% usual hex value because it has already been made active.
-@def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
-@let@backslashchar = @normalbackslash % @backslashchar{} is for user documents.
-
+\catcode`\\=\active
+@def@normalbackslash{{@tt@backslashcurfont}}
% On startup, @fixbackslash assigns:
% @let \ = @normalbackslash
+
% \rawbackslash defines an active \ to do \backslashcurfont.
% \otherbackslash defines an active \ to be a literal `\' character with
-% catcode other. We switch back and forth between these.
+% catcode other.
@gdef@rawbackslash{@let\=@backslashcurfont}
@gdef@otherbackslash{@let\=@realbackslash}
% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
-% the literal character `\'. Also revert - to its normal character, in
-% case the active - from code has slipped in.
-%
-{@catcode`- = @active
- @gdef@normalturnoffactive{%
- @let-=@normaldash
- @let"=@normaldoublequote
- @let$=@normaldollar %$ font-lock fix
- @let+=@normalplus
- @let<=@normalless
- @let>=@normalgreater
- @let\=@normalbackslash
- @let^=@normalcaret
- @let_=@normalunderscore
- @let|=@normalverticalbar
- @let~=@normaltilde
- @markupsetuplqdefault
- @markupsetuprqdefault
- @unsepspaces
- }
+% the literal character `\'.
+%
+@def@normalturnoffactive{%
+ @let\=@normalbackslash
+ @let"=@normaldoublequote
+ @let~=@normaltilde
+ @let^=@normalcaret
+ @let_=@normalunderscore
+ @let|=@normalverticalbar
+ @let<=@normalless
+ @let>=@normalgreater
+ @let+=@normalplus
+ @let$=@normaldollar %$ font-lock fix
+ @unsepspaces
}
% Make _ and + \other characters, temporarily.
@@ -10041,28 +8976,11 @@ directory should work if nowhere else does.}
% Say @foo, not \foo, in error messages.
@escapechar = `@@
-% These (along with & and #) are made active for url-breaking, so need
-% active definitions as the normal characters.
-@def@normaldot{.}
-@def@normalquest{?}
-@def@normalslash{/}
-
% These look ok in all fonts, so just make them not special.
-% @hashchar{} gets its own user-level command, because of #line.
-@catcode`@& = @other @def@normalamp{&}
-@catcode`@# = @other @def@normalhash{#}
-@catcode`@% = @other @def@normalpercent{%}
-
-@let @hashchar = @normalhash
-
-@c Finally, make ` and ' active, so that txicodequoteundirected and
-@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
-@c don't make ` and ' active, @code will not get them as active chars.
-@c Do this last of all since we use ` in the previous @catcode assignments.
-@catcode`@'=@active
-@catcode`@`=@active
-@markupsetuplqdefault
-@markupsetuprqdefault
+@catcode`@& = @other
+@catcode`@# = @other
+@catcode`@% = @other
+
@c Local variables:
@c eval: (add-hook 'write-file-hooks 'time-stamp)
diff --git a/gmp/doc/version.texi b/gmp/doc/version.texi
index 08f09e7e86..227ebb6db5 100644
--- a/gmp/doc/version.texi
+++ b/gmp/doc/version.texi
@@ -1,4 +1,4 @@
-@set UPDATED 25 March 2014
-@set UPDATED-MONTH March 2014
-@set EDITION 6.0.0
-@set VERSION 6.0.0
+@set UPDATED 7 January 2010
+@set UPDATED-MONTH January 2010
+@set EDITION 4.3.2
+@set VERSION 4.3.2