diff options
author | Karl Berry <karl@freefriends.org> | 2024-02-01 22:56:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-02-01 22:56:12 +0000 |
commit | 5fa7e249b027ce94b1e2f1064c2c884c9ed538c2 (patch) | |
tree | 5529cfb6bf5cdc187ab27b3f05052a5014299830 /Build/source/texk/web2c | |
parent | b0c8faa4c10a27dbc74e13639c9e9e926a7695a2 (diff) |
mpfi integration into mpost from luigi
git-svn-id: svn://tug.org/texlive/trunk@69664 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
25 files changed, 2682 insertions, 132 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog index 5b4e15fa9e3..00ea21b98e6 100644 --- a/Build/source/texk/web2c/ChangeLog +++ b/Build/source/texk/web2c/ChangeLog @@ -1,3 +1,11 @@ +2024-02-01 Luigi Scarso <luigi.scarso@gmail.com> + + * ac/web2c.ac (mp, pmp, upmp): depend on mpfi. + * Makefile.am (MPFI_RULE): add. + * configure.ac (KPSE_MPFI_FLAGS): add. + * mplibdir: pervasive changes to support mpfi. + * luatexdir/lua/mplibstuff.c: mpfi bindings. + 2024-02-01 TANAKA Takuji <ttk@t-lab.opal.ne.jp> * tests/enc-utf8.bib, tests/enc-{,e,s}[pu].bbl: diff --git a/Build/source/texk/web2c/Makefile.am b/Build/source/texk/web2c/Makefile.am index e698046b671..843aeefe445 100644 --- a/Build/source/texk/web2c/Makefile.am +++ b/Build/source/texk/web2c/Makefile.am @@ -1,7 +1,7 @@ ## $Id$ ## Makefile.am for the TeX Live subdirectory texk/web2c/. ## -## Copyright 2017-2022 Karl Berry <tex-live@tug.org> +## Copyright 2017-2024 Karl Berry <tex-live@tug.org> ## Copyright 2009-2015 Peter Breitenlohner <tex-live@tug.org> ## You may freely use, modify and/or distribute this file. ## @@ -131,6 +131,8 @@ $(proglib): $(proglib_sources) @GMP_RULE@ ## Rebuild libmpfr @MPFR_RULE@ +## Rebuild libmpfi +@MPFI_RULE@ ## Rebuild libxpdf @XPDF_RULE@ ## Rebuild pplib diff --git a/Build/source/texk/web2c/Makefile.in b/Build/source/texk/web2c/Makefile.in index 3fed02e74e0..326822d6c16 100644 --- a/Build/source/texk/web2c/Makefile.in +++ b/Build/source/texk/web2c/Makefile.in @@ -367,6 +367,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -1120,7 +1121,9 @@ libmplibcore_a_OBJECTS = $(nodist_libmplibcore_a_OBJECTS) libmplibextramath_a_AR = $(AR) $(ARFLAGS) libmplibextramath_a_LIBADD = am__objects_25 = libmplibextramath_a-mpmathbinary.$(OBJEXT) -nodist_libmplibextramath_a_OBJECTS = $(am__objects_25) +am__objects_26 = libmplibextramath_a-mpmathinterval.$(OBJEXT) +nodist_libmplibextramath_a_OBJECTS = $(am__objects_25) \ + $(am__objects_26) libmplibextramath_a_OBJECTS = $(nodist_libmplibextramath_a_OBJECTS) libmputil_a_AR = $(AR) $(ARFLAGS) libmputil_a_LIBADD = @@ -1142,7 +1145,7 @@ am__libpdftex_a_SOURCES_DIST = pdftexdir/avl.c pdftexdir/avl.h \ pdftexdir/writepng.c pdftexdir/writet1.c pdftexdir/writet3.c \ pdftexdir/writettf.c pdftexdir/writettf.h pdftexdir/writezip.c \ pdftexdir/regex/regex.c pdftexdir/regex/regex.h -@MINGW32_TRUE@am__objects_26 = \ +@MINGW32_TRUE@am__objects_27 = \ @MINGW32_TRUE@ pdftexdir/regex/libpdftex_a-regex.$(OBJEXT) am_libpdftex_a_OBJECTS = pdftexdir/libpdftex_a-avl.$(OBJEXT) \ pdftexdir/libpdftex_a-avlstuff.$(OBJEXT) \ @@ -1163,13 +1166,13 @@ am_libpdftex_a_OBJECTS = pdftexdir/libpdftex_a-avl.$(OBJEXT) \ pdftexdir/libpdftex_a-writet1.$(OBJEXT) \ pdftexdir/libpdftex_a-writet3.$(OBJEXT) \ pdftexdir/libpdftex_a-writettf.$(OBJEXT) \ - pdftexdir/libpdftex_a-writezip.$(OBJEXT) $(am__objects_26) + pdftexdir/libpdftex_a-writezip.$(OBJEXT) $(am__objects_27) libpdftex_a_OBJECTS = $(am_libpdftex_a_OBJECTS) libsynctex_a_AR = $(AR) $(ARFLAGS) libsynctex_a_LIBADD = -am__objects_27 = synctexdir/libsynctex_a-synctex_parser.$(OBJEXT) \ +am__objects_28 = synctexdir/libsynctex_a-synctex_parser.$(OBJEXT) \ synctexdir/libsynctex_a-synctex_parser_utils.$(OBJEXT) -nodist_libsynctex_a_OBJECTS = $(am__objects_27) +nodist_libsynctex_a_OBJECTS = $(am__objects_28) libsynctex_a_OBJECTS = $(nodist_libsynctex_a_OBJECTS) libukanji_a_AR = $(AR) $(ARFLAGS) libukanji_a_LIBADD = @@ -1209,10 +1212,10 @@ am__libxetex_a_SOURCES_DIST = xetexdir/XeTeXFontInst.cpp \ xetexdir/XeTeXFontInst_Mac.h xetexdir/XeTeXFontMgr_Mac.mm \ xetexdir/XeTeXFontMgr_Mac.h xetexdir/XeTeX_mac.c \ xetexdir/XeTeXFontMgr_FC.cpp xetexdir/XeTeXFontMgr_FC.h -@XETEX_MACOSX_TRUE@am__objects_28 = xetexdir/libxetex_a-XeTeXFontInst_Mac.$(OBJEXT) \ +@XETEX_MACOSX_TRUE@am__objects_29 = xetexdir/libxetex_a-XeTeXFontInst_Mac.$(OBJEXT) \ @XETEX_MACOSX_TRUE@ xetexdir/libxetex_a-XeTeXFontMgr_Mac.$(OBJEXT) \ @XETEX_MACOSX_TRUE@ xetexdir/libxetex_a-XeTeX_mac.$(OBJEXT) -@XETEX_MACOSX_FALSE@am__objects_29 = xetexdir/libxetex_a-XeTeXFontMgr_FC.$(OBJEXT) +@XETEX_MACOSX_FALSE@am__objects_30 = xetexdir/libxetex_a-XeTeXFontMgr_FC.$(OBJEXT) am_libxetex_a_OBJECTS = xetexdir/libxetex_a-XeTeXFontInst.$(OBJEXT) \ xetexdir/libxetex_a-XeTeXFontMgr.$(OBJEXT) \ xetexdir/libxetex_a-XeTeXLayoutInterface.$(OBJEXT) \ @@ -1226,8 +1229,8 @@ am_libxetex_a_OBJECTS = xetexdir/libxetex_a-XeTeXFontInst.$(OBJEXT) \ xetexdir/image/libxetex_a-jpegimage.$(OBJEXT) \ xetexdir/image/libxetex_a-mfileio.$(OBJEXT) \ xetexdir/image/libxetex_a-numbers.$(OBJEXT) \ - xetexdir/image/libxetex_a-pngimage.$(OBJEXT) $(am__objects_28) \ - $(am__objects_29) + xetexdir/image/libxetex_a-pngimage.$(OBJEXT) $(am__objects_29) \ + $(am__objects_30) libxetex_a_OBJECTS = $(am_libxetex_a_OBJECTS) am__DEPENDENCIES_1 = libsynctex_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ @@ -1245,8 +1248,8 @@ libsynctex_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ dist_aleph_OBJECTS = alephdir/aleph-aleph.$(OBJEXT) \ alephdir/aleph-alephbis.$(OBJEXT) \ alephdir/aleph-alephextra.$(OBJEXT) -am__objects_30 = aleph-alephini.$(OBJEXT) aleph-aleph0.$(OBJEXT) -nodist_aleph_OBJECTS = $(am__objects_30) aleph-aleph-pool.$(OBJEXT) +am__objects_31 = aleph-alephini.$(OBJEXT) aleph-aleph0.$(OBJEXT) +nodist_aleph_OBJECTS = $(am__objects_31) aleph-aleph-pool.$(OBJEXT) aleph_OBJECTS = $(dist_aleph_OBJECTS) $(nodist_aleph_OBJECTS) am__DEPENDENCIES_2 = $(proglib) $(am__DEPENDENCIES_1) aleph_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -1323,34 +1326,34 @@ am__dist_eptex_SOURCES_DIST = eptexdir/eptexextra.c \ eptexdir/eptexextra.h eptexdir/eptex_version.h \ synctexdir/synctex.c synctexdir/synctex.h \ synctexdir/synctex-common.h synctexdir/synctex-eptex.h -@EPTEX_SYNCTEX_TRUE@am__objects_31 = \ +@EPTEX_SYNCTEX_TRUE@am__objects_32 = \ @EPTEX_SYNCTEX_TRUE@ synctexdir/eptex-synctex.$(OBJEXT) dist_eptex_OBJECTS = eptexdir/eptex-eptexextra.$(OBJEXT) \ - $(am__objects_31) -am__objects_32 = eptex-eptexini.$(OBJEXT) eptex-eptex0.$(OBJEXT) -nodist_eptex_OBJECTS = $(am__objects_32) eptex-eptex-pool.$(OBJEXT) + $(am__objects_32) +am__objects_33 = eptex-eptexini.$(OBJEXT) eptex-eptex0.$(OBJEXT) +nodist_eptex_OBJECTS = $(am__objects_33) eptex-eptex-pool.$(OBJEXT) eptex_OBJECTS = $(dist_eptex_OBJECTS) $(nodist_eptex_OBJECTS) @EPTEX_SYNCTEX_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) am__dist_etex_SOURCES_DIST = etexdir/etexextra.c etexdir/etexextra.h \ etexdir/etex_version.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-etex.h -@ETEX_SYNCTEX_TRUE@am__objects_33 = synctexdir/etex-synctex.$(OBJEXT) -dist_etex_OBJECTS = etexdir/etex-etexextra.$(OBJEXT) $(am__objects_33) -am__objects_34 = etex-etexini.$(OBJEXT) etex-etex0.$(OBJEXT) -nodist_etex_OBJECTS = $(am__objects_34) etex-etex-pool.$(OBJEXT) +@ETEX_SYNCTEX_TRUE@am__objects_34 = synctexdir/etex-synctex.$(OBJEXT) +dist_etex_OBJECTS = etexdir/etex-etexextra.$(OBJEXT) $(am__objects_34) +am__objects_35 = etex-etexini.$(OBJEXT) etex-etex0.$(OBJEXT) +nodist_etex_OBJECTS = $(am__objects_35) etex-etex-pool.$(OBJEXT) etex_OBJECTS = $(dist_etex_OBJECTS) $(nodist_etex_OBJECTS) @ETEX_SYNCTEX_TRUE@am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) am__dist_euptex_SOURCES_DIST = euptexdir/euptexextra.c \ euptexdir/euptexextra.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-euptex.h -@EUPTEX_SYNCTEX_TRUE@am__objects_35 = \ +@EUPTEX_SYNCTEX_TRUE@am__objects_36 = \ @EUPTEX_SYNCTEX_TRUE@ synctexdir/euptex-synctex.$(OBJEXT) dist_euptex_OBJECTS = euptexdir/euptex-euptexextra.$(OBJEXT) \ - $(am__objects_35) -am__objects_36 = euptex-euptexini.$(OBJEXT) euptex-euptex0.$(OBJEXT) -nodist_euptex_OBJECTS = $(am__objects_36) euptex-euptex-pool.$(OBJEXT) + $(am__objects_36) +am__objects_37 = euptex-euptexini.$(OBJEXT) euptex-euptex0.$(OBJEXT) +nodist_euptex_OBJECTS = $(am__objects_37) euptex-euptex-pool.$(OBJEXT) euptex_OBJECTS = $(dist_euptex_OBJECTS) $(nodist_euptex_OBJECTS) @EUPTEX_SYNCTEX_TRUE@am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1) am_gftodvi_OBJECTS = @@ -1378,16 +1381,16 @@ hishrink_OBJECTS = $(nodist_hishrink_OBJECTS) nodist_histretch_OBJECTS = histretch-hitables.$(OBJEXT) \ histretch-histretch.$(OBJEXT) histretch_OBJECTS = $(nodist_histretch_OBJECTS) -am__objects_37 = hitex-hitex.$(OBJEXT) +am__objects_38 = hitex-hitex.$(OBJEXT) nodist_hitex_OBJECTS = hitex-hitables.$(OBJEXT) hitex-hiput.$(OBJEXT) \ - $(am__objects_37) + $(am__objects_38) hitex_OBJECTS = $(nodist_hitex_OBJECTS) nodist_initex_OBJECTS = initex-callexe.$(OBJEXT) initex_OBJECTS = $(nodist_initex_OBJECTS) initex_DEPENDENCIES = -am__objects_38 = luatexdir/luahbtex-luatex.$(OBJEXT) \ +am__objects_39 = luatexdir/luahbtex-luatex.$(OBJEXT) \ mplibdir/luahbtex-lmplib.$(OBJEXT) -nodist_luahbtex_OBJECTS = $(am__objects_38) +nodist_luahbtex_OBJECTS = $(am__objects_39) luahbtex_OBJECTS = $(nodist_luahbtex_OBJECTS) am__DEPENDENCIES_6 = $(am__DEPENDENCIES_1) am__DEPENDENCIES_7 = libmplibcore.a $(am__DEPENDENCIES_1) \ @@ -1398,16 +1401,16 @@ am__DEPENDENCIES_7 = libmplibcore.a $(am__DEPENDENCIES_1) \ luahbtex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(luahbtex_CXXFLAGS) \ $(CXXFLAGS) $(luahbtex_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_39 = luatexdir/luajithbtex-luatex.$(OBJEXT) \ +am__objects_40 = luatexdir/luajithbtex-luatex.$(OBJEXT) \ mplibdir/luajithbtex-lmplib.$(OBJEXT) -nodist_luajithbtex_OBJECTS = $(am__objects_39) +nodist_luajithbtex_OBJECTS = $(am__objects_40) luajithbtex_OBJECTS = $(nodist_luajithbtex_OBJECTS) luajithbtex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(luajithbtex_CXXFLAGS) \ $(CXXFLAGS) $(luajithbtex_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_40 = luatexdir/luajittex-luatex.$(OBJEXT) \ +am__objects_41 = luatexdir/luajittex-luatex.$(OBJEXT) \ mplibdir/luajittex-lmplib.$(OBJEXT) -nodist_luajittex_OBJECTS = $(am__objects_40) +nodist_luajittex_OBJECTS = $(am__objects_41) luajittex_OBJECTS = $(nodist_luajittex_OBJECTS) am__DEPENDENCIES_8 = libmplibcore.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -1416,9 +1419,9 @@ am__DEPENDENCIES_8 = libmplibcore.a $(am__DEPENDENCIES_1) \ luajittex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(luajittex_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_41 = luatexdir/luatex-luatex.$(OBJEXT) \ +am__objects_42 = luatexdir/luatex-luatex.$(OBJEXT) \ mplibdir/luatex-lmplib.$(OBJEXT) -nodist_luatex_OBJECTS = $(am__objects_41) +nodist_luatex_OBJECTS = $(am__objects_42) luatex_OBJECTS = $(nodist_luatex_OBJECTS) luatex_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -1446,8 +1449,8 @@ mflua_DEPENDENCIES = libmflua.a libmfluaotfcc.a libmfluapotrace.a \ mflua_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(mflua_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_42 = mfluadir/mflua_nowin-mfluaextra.$(OBJEXT) -nodist_mflua_nowin_OBJECTS = $(am__objects_42) +am__objects_43 = mfluadir/mflua_nowin-mfluaextra.$(OBJEXT) +nodist_mflua_nowin_OBJECTS = $(am__objects_43) mflua_nowin_OBJECTS = $(nodist_mflua_nowin_OBJECTS) mflua_nowin_DEPENDENCIES = libmflua.a libmfluaotfcc.a \ libmfluapotrace.a libmflualpeg.a $(am__DEPENDENCIES_2) \ @@ -1464,8 +1467,8 @@ mfluajit_DEPENDENCIES = libmfluajit.a libmfluaotfcc.a \ mfluajit_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(mfluajit_LDFLAGS) $(LDFLAGS) -o $@ -am__objects_43 = mfluajitdir/mfluajit_nowin-mfluajitextra.$(OBJEXT) -nodist_mfluajit_nowin_OBJECTS = $(am__objects_43) +am__objects_44 = mfluajitdir/mfluajit_nowin-mfluajitextra.$(OBJEXT) +nodist_mfluajit_nowin_OBJECTS = $(am__objects_44) mfluajit_nowin_OBJECTS = $(nodist_mfluajit_nowin_OBJECTS) mfluajit_nowin_DEPENDENCIES = libmfluajit.a libmfluaotfcc.a \ libmfluapotrace.a libmfluajitlpeg.a $(am__DEPENDENCIES_2) \ @@ -1478,14 +1481,14 @@ nodist_mft_OBJECTS = mft.$(OBJEXT) mft_OBJECTS = $(nodist_mft_OBJECTS) mft_LDADD = $(LDADD) mft_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -am__objects_44 = mpost-mpxout.$(OBJEXT) -nodist_mpost_OBJECTS = mpost-mpost.$(OBJEXT) $(am__objects_44) +am__objects_45 = mpost-mpxout.$(OBJEXT) +nodist_mpost_OBJECTS = mpost-mpost.$(OBJEXT) $(am__objects_45) mpost_OBJECTS = $(nodist_mpost_OBJECTS) mpost_DEPENDENCIES = libmplibcore.a libmplibextramath.a \ libmplibbackends.a $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) libmputil.a + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) libmputil.a nodist_odvicopy_OBJECTS = odvicopy.$(OBJEXT) odvicopy_OBJECTS = $(nodist_odvicopy_OBJECTS) odvicopy_LDADD = $(LDADD) @@ -1507,12 +1510,12 @@ am__dist_pdftex_SOURCES_DIST = pdftexdir/pdftexextra.c \ pdftexdir/etex_version.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-pdftex.h -@PDFTEX_SYNCTEX_TRUE@am__objects_45 = \ +@PDFTEX_SYNCTEX_TRUE@am__objects_46 = \ @PDFTEX_SYNCTEX_TRUE@ synctexdir/pdftex-synctex.$(OBJEXT) dist_pdftex_OBJECTS = pdftexdir/pdftex-pdftexextra.$(OBJEXT) \ - $(am__objects_45) -am__objects_46 = pdftex-pdftexini.$(OBJEXT) pdftex-pdftex0.$(OBJEXT) -nodist_pdftex_OBJECTS = $(am__objects_46) pdftex-pdftex-pool.$(OBJEXT) + $(am__objects_46) +am__objects_47 = pdftex-pdftexini.$(OBJEXT) pdftex-pdftex0.$(OBJEXT) +nodist_pdftex_OBJECTS = $(am__objects_47) pdftex-pdftex-pool.$(OBJEXT) pdftex_OBJECTS = $(dist_pdftex_OBJECTS) $(nodist_pdftex_OBJECTS) am__DEPENDENCIES_10 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) libmd5.a @@ -1536,33 +1539,35 @@ nodist_pltotf_OBJECTS = pltotf.$(OBJEXT) pltotf_OBJECTS = $(nodist_pltotf_OBJECTS) pltotf_LDADD = $(LDADD) pltotf_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) -am__objects_47 = pmpost-pmp.$(OBJEXT) -am__objects_48 = pmpost-pmpmath.$(OBJEXT) -am__objects_49 = pmpost-pmpmathbinary.$(OBJEXT) -am__objects_50 = pmpost-pmpmathdecimal.$(OBJEXT) -am__objects_51 = pmpost-pmpmathdouble.$(OBJEXT) -am__objects_52 = pmpost-pmpstrings.$(OBJEXT) -am__objects_53 = pmpost-pmpxout.$(OBJEXT) -am__objects_54 = pmpost-ppngout.$(OBJEXT) -am__objects_55 = pmpost-ppsout.$(OBJEXT) -am__objects_56 = pmpost-psvgout.$(OBJEXT) -nodist_pmpost_OBJECTS = $(am__objects_47) $(am__objects_48) \ - $(am__objects_49) $(am__objects_50) $(am__objects_51) \ - pmpost-pmpost.$(OBJEXT) $(am__objects_52) $(am__objects_53) \ - $(am__objects_54) $(am__objects_55) $(am__objects_56) \ - pmpost-ptfmin.$(OBJEXT) +am__objects_48 = pmpost-pmp.$(OBJEXT) +am__objects_49 = pmpost-pmpmath.$(OBJEXT) +am__objects_50 = pmpost-pmpmathinterval.$(OBJEXT) +am__objects_51 = pmpost-pmpmathbinary.$(OBJEXT) +am__objects_52 = pmpost-pmpmathdecimal.$(OBJEXT) +am__objects_53 = pmpost-pmpmathdouble.$(OBJEXT) +am__objects_54 = pmpost-pmpstrings.$(OBJEXT) +am__objects_55 = pmpost-pmpxout.$(OBJEXT) +am__objects_56 = pmpost-ppngout.$(OBJEXT) +am__objects_57 = pmpost-ppsout.$(OBJEXT) +am__objects_58 = pmpost-psvgout.$(OBJEXT) +nodist_pmpost_OBJECTS = $(am__objects_48) $(am__objects_49) \ + $(am__objects_50) $(am__objects_51) $(am__objects_52) \ + $(am__objects_53) pmpost-pmpost.$(OBJEXT) $(am__objects_54) \ + $(am__objects_55) $(am__objects_56) $(am__objects_57) \ + $(am__objects_58) pmpost-ptfmin.$(OBJEXT) pmpost_OBJECTS = $(nodist_pmpost_OBJECTS) pmpost_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) libmputil.a + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) libmputil.a nodist_pooltype_OBJECTS = pooltype.$(OBJEXT) pooltype_OBJECTS = $(nodist_pooltype_OBJECTS) pooltype_LDADD = $(LDADD) pooltype_DEPENDENCIES = $(proglib) $(am__DEPENDENCIES_1) dist_ptex_OBJECTS = ptexdir/ptex-ptexextra.$(OBJEXT) -am__objects_57 = ptex-ptexini.$(OBJEXT) ptex-ptex0.$(OBJEXT) -nodist_ptex_OBJECTS = $(am__objects_57) ptex-ptex-pool.$(OBJEXT) +am__objects_59 = ptex-ptexini.$(OBJEXT) ptex-ptex0.$(OBJEXT) +nodist_ptex_OBJECTS = $(am__objects_59) ptex-ptex-pool.$(OBJEXT) ptex_OBJECTS = $(dist_ptex_OBJECTS) $(nodist_ptex_OBJECTS) am__DEPENDENCIES_11 = libkanji.a $(pproglib) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) @@ -1582,10 +1587,10 @@ tangleboot_LDADD = $(LDADD) am__dist_tex_SOURCES_DIST = texextra.c synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-tex.h -@TEX_SYNCTEX_TRUE@am__objects_58 = synctexdir/tex-synctex.$(OBJEXT) -dist_tex_OBJECTS = tex-texextra.$(OBJEXT) $(am__objects_58) -am__objects_59 = tex-texini.$(OBJEXT) tex-tex0.$(OBJEXT) -nodist_tex_OBJECTS = $(am__objects_59) tex-tex-pool.$(OBJEXT) +@TEX_SYNCTEX_TRUE@am__objects_60 = synctexdir/tex-synctex.$(OBJEXT) +dist_tex_OBJECTS = tex-texextra.$(OBJEXT) $(am__objects_60) +am__objects_61 = tex-texini.$(OBJEXT) tex-tex0.$(OBJEXT) +nodist_tex_OBJECTS = $(am__objects_61) tex-tex-pool.$(OBJEXT) tex_OBJECTS = $(dist_tex_OBJECTS) $(nodist_tex_OBJECTS) @TEX_SYNCTEX_TRUE@am__DEPENDENCIES_14 = $(am__DEPENDENCIES_1) tex_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ @@ -1614,33 +1619,36 @@ am_updvitype_OBJECTS = nodist_updvitype_OBJECTS = updvitype-updvitype.$(OBJEXT) updvitype_OBJECTS = $(am_updvitype_OBJECTS) \ $(nodist_updvitype_OBJECTS) -am__objects_60 = upmpost-pmp.$(OBJEXT) -am__objects_61 = upmpost-pmpmath.$(OBJEXT) -am__objects_62 = upmpost-pmpmathbinary.$(OBJEXT) -am__objects_63 = upmpost-pmpmathdecimal.$(OBJEXT) -am__objects_64 = upmpost-pmpmathdouble.$(OBJEXT) -am__objects_65 = upmpost-pmpstrings.$(OBJEXT) -am__objects_66 = upmpost-pmpxout.$(OBJEXT) -am__objects_67 = upmpost-ppngout.$(OBJEXT) -am__objects_68 = upmpost-ppsout.$(OBJEXT) -am__objects_69 = upmpost-psvgout.$(OBJEXT) -am__objects_70 = $(am__objects_60) $(am__objects_61) $(am__objects_62) \ - $(am__objects_63) $(am__objects_64) upmpost-pmpost.$(OBJEXT) \ +am__objects_62 = upmpost-pmp.$(OBJEXT) +am__objects_63 = upmpost-pmpmath.$(OBJEXT) +am__objects_64 = upmpost-pmpmathinterval.$(OBJEXT) +am__objects_65 = upmpost-pmpmathbinary.$(OBJEXT) +am__objects_66 = upmpost-pmpmathdecimal.$(OBJEXT) +am__objects_67 = upmpost-pmpmathdouble.$(OBJEXT) +am__objects_68 = upmpost-pmpstrings.$(OBJEXT) +am__objects_69 = upmpost-pmpxout.$(OBJEXT) +am__objects_70 = upmpost-ppngout.$(OBJEXT) +am__objects_71 = upmpost-ppsout.$(OBJEXT) +am__objects_72 = upmpost-psvgout.$(OBJEXT) +am__objects_73 = $(am__objects_62) $(am__objects_63) $(am__objects_64) \ $(am__objects_65) $(am__objects_66) $(am__objects_67) \ - $(am__objects_68) $(am__objects_69) upmpost-ptfmin.$(OBJEXT) -nodist_upmpost_OBJECTS = $(am__objects_70) + upmpost-pmpost.$(OBJEXT) $(am__objects_68) $(am__objects_69) \ + $(am__objects_70) $(am__objects_71) $(am__objects_72) \ + upmpost-ptfmin.$(OBJEXT) +nodist_upmpost_OBJECTS = $(am__objects_73) upmpost_OBJECTS = $(nodist_upmpost_OBJECTS) am__DEPENDENCIES_16 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) libmputil.a + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) libmputil.a upmpost_DEPENDENCIES = $(am__DEPENDENCIES_16) am_uppltotf_OBJECTS = nodist_uppltotf_OBJECTS = uppltotf-uppltotf.$(OBJEXT) uppltotf_OBJECTS = $(am_uppltotf_OBJECTS) $(nodist_uppltotf_OBJECTS) dist_uptex_OBJECTS = uptexdir/uptex-uptexextra.$(OBJEXT) -am__objects_71 = uptex-uptexini.$(OBJEXT) uptex-uptex0.$(OBJEXT) -nodist_uptex_OBJECTS = $(am__objects_71) uptex-uptex-pool.$(OBJEXT) +am__objects_74 = uptex-uptexini.$(OBJEXT) uptex-uptex0.$(OBJEXT) +nodist_uptex_OBJECTS = $(am__objects_74) uptex-uptex-pool.$(OBJEXT) uptex_OBJECTS = $(dist_uptex_OBJECTS) $(nodist_uptex_OBJECTS) am_uptftopl_OBJECTS = nodist_uptftopl_OBJECTS = uptftopl-uptftopl.$(OBJEXT) @@ -1678,12 +1686,12 @@ am__dist_xetex_SOURCES_DIST = xetexdir/xetexextra.c \ xetexdir/xetex_version.h synctexdir/synctex.c \ synctexdir/synctex.h synctexdir/synctex-common.h \ synctexdir/synctex-xetex.h -@XETEX_SYNCTEX_TRUE@am__objects_72 = \ +@XETEX_SYNCTEX_TRUE@am__objects_75 = \ @XETEX_SYNCTEX_TRUE@ synctexdir/xetex-synctex.$(OBJEXT) dist_xetex_OBJECTS = xetexdir/xetex-xetexextra.$(OBJEXT) \ - $(am__objects_72) -am__objects_73 = xetex-xetexini.$(OBJEXT) xetex-xetex0.$(OBJEXT) -nodist_xetex_OBJECTS = $(am__objects_73) xetex-xetex-pool.$(OBJEXT) + $(am__objects_75) +am__objects_76 = xetex-xetexini.$(OBJEXT) xetex-xetex0.$(OBJEXT) +nodist_xetex_OBJECTS = $(am__objects_76) xetex-xetex-pool.$(OBJEXT) xetex_OBJECTS = $(dist_xetex_OBJECTS) $(nodist_xetex_OBJECTS) @XETEX_MACOSX_FALSE@am__DEPENDENCIES_17 = $(am__DEPENDENCIES_1) am__DEPENDENCIES_18 = $(libxetex) $(am__DEPENDENCIES_1) \ @@ -1766,6 +1774,7 @@ am__depfiles_remade = ./$(DEPDIR)/aleph-aleph-pool.Po \ ./$(DEPDIR)/libmplibcore_a-psout.Po \ ./$(DEPDIR)/libmplibcore_a-tfmin.Po \ ./$(DEPDIR)/libmplibextramath_a-mpmathbinary.Po \ + ./$(DEPDIR)/libmplibextramath_a-mpmathinterval.Po \ ./$(DEPDIR)/luahbtex-dummy.Po ./$(DEPDIR)/luajithbtex-dummy.Po \ ./$(DEPDIR)/mf-mfextra.Po ./$(DEPDIR)/mf-pool.Po \ ./$(DEPDIR)/mf0.Po ./$(DEPDIR)/mf_nowin-mfextra.Po \ @@ -1783,6 +1792,7 @@ am__depfiles_remade = ./$(DEPDIR)/aleph-aleph-pool.Po \ ./$(DEPDIR)/pmpost-pmpmathbinary.Po \ ./$(DEPDIR)/pmpost-pmpmathdecimal.Po \ ./$(DEPDIR)/pmpost-pmpmathdouble.Po \ + ./$(DEPDIR)/pmpost-pmpmathinterval.Po \ ./$(DEPDIR)/pmpost-pmpost.Po ./$(DEPDIR)/pmpost-pmpstrings.Po \ ./$(DEPDIR)/pmpost-pmpxout.Po ./$(DEPDIR)/pmpost-ppngout.Po \ ./$(DEPDIR)/pmpost-ppsout.Po ./$(DEPDIR)/pmpost-psvgout.Po \ @@ -1799,6 +1809,7 @@ am__depfiles_remade = ./$(DEPDIR)/aleph-aleph-pool.Po \ ./$(DEPDIR)/upmpost-pmpmathbinary.Po \ ./$(DEPDIR)/upmpost-pmpmathdecimal.Po \ ./$(DEPDIR)/upmpost-pmpmathdouble.Po \ + ./$(DEPDIR)/upmpost-pmpmathinterval.Po \ ./$(DEPDIR)/upmpost-pmpost.Po \ ./$(DEPDIR)/upmpost-pmpstrings.Po \ ./$(DEPDIR)/upmpost-pmpxout.Po ./$(DEPDIR)/upmpost-ppngout.Po \ @@ -2976,6 +2987,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ @@ -4248,7 +4262,7 @@ libmfluajitlpeg_a_SOURCES = \ mfluadir/luapeg/lpeg.h mpost_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) -I$(srcdir)/mplibdir -mpost_LDADD = libmplibcore.a libmplibextramath.a libmplibbackends.a $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ +mpost_LDADD = libmplibcore.a libmplibextramath.a libmplibbackends.a $(KPATHSEA_LIBS) $(MPFI_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a call_mpost_CPPFLAGS = -DEXEPROG=\"mpost.exe\" @@ -4269,10 +4283,10 @@ call_pmpost_LDADD = call_upmpost_CPPFLAGS = -DEXEPROG=\"upmpost.exe\" nodist_call_upmpost_SOURCES = callexe.c call_upmpost_LDADD = -pmpost_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ +pmpost_CPPFLAGS = $(MPFI_INCLUDES) $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir -pmpost_LDADD = $(PTEXENC_LIBS) $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ +pmpost_LDADD = $(PTEXENC_LIBS) $(KPATHSEA_LIBS) $(MPFI_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a upmpost_CPPFLAGS = -DUPMP $(pmpost_CPPFLAGS) @@ -4282,7 +4296,7 @@ upmpost_LDADD = $(pmpost_LDADD) pmp_ctangle = $(ctangle_silent)CWEBINPUTS=.:$(srcdir)/pmpostdir $(ctangle) # Creating several files: need stamp file and two rules with identical recipes pmp_ctangle_sh = CWEBINPUTS=.:$(srcdir)/pmpostdir AM_V_P=$(AM_V_P) $(SHELL) ./tangle-sh $@ $(CTANGLE) -nodist_pmpost_SOURCES = $(pmp_c_h) $(pmpmath_c_h) $(pmpmathbinary_c_h) \ +nodist_pmpost_SOURCES = $(pmp_c_h) $(pmpmath_c_h) $(pmpmathinterval_c_h) $(pmpmathbinary_c_h) \ $(pmpmathdecimal_c_h) \ $(pmpmathdouble_c_h) pmpost.c $(pmpstrings_c_h) $(pmpxout_c_h) \ $(ppngout_c_h) $(ppsout_c_h) $(psvgout_c_h) ptfmin.c @@ -4290,6 +4304,7 @@ nodist_pmpost_SOURCES = $(pmp_c_h) $(pmpmath_c_h) $(pmpmathbinary_c_h) \ # pmp_c_h = pmp.c pmplib.h pmpmp.h pmpmath_c_h = pmpmath.c pmpmath.h +pmpmathinterval_c_h = pmpmathinterval.c pmpmathinterval.h pmpmathbinary_c_h = pmpmathbinary.c pmpmathbinary.h pmpmathdecimal_c_h = pmpmathdecimal.c pmpmathdecimal.h pmpmathdouble_c_h = pmpmathdouble.c pmpmathdouble.h @@ -4317,28 +4332,29 @@ libmputil_a_SOURCES = mplibdir/avl.h mplibdir/avl.c mplibdir/decNumber.c mplibdi mplibdir/decNumberLocal.h mplibdir/decContext.h mplibdir/decContext.c libmplibcore_a_CPPFLAGS = $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir -libmplibextramath_a_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) -I${top_builddir}/../../libs $(AM_CPPFLAGS) -I$(srcdir)/mplibdir -libmplibbackends_a_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ +libmplibextramath_a_CPPFLAGS = $(MPFI_INCLUDES) $(MPFR_INCLUDES) $(GMP_INCLUDES) -I${top_builddir}/../../libs $(AM_CPPFLAGS) -I$(srcdir)/mplibdir +libmplibbackends_a_CPPFLAGS = $(MPFI_INCLUDES) $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir nodist_libmplibcore_a_SOURCES = tfmin.c $(mp_c_h) $(mpmath_c_h) $(mpmathdecimal_c_h) \ $(mpmathdouble_c_h) $(mpstrings_c_h) $(psout_c_h) -nodist_libmplibextramath_a_SOURCES = $(mpmathbinary_c_h) +nodist_libmplibextramath_a_SOURCES = $(mpmathbinary_c_h) $(mpmathinterval_c_h) nodist_libmplibbackends_a_SOURCES = $(pngout_c_h) $(svgout_c_h) mp_c_h = mp.c mplib.h mpmp.h mpmath_c_h = mpmath.h mpmath.c mpmathbinary_c_h = mpmathbinary.h mpmathbinary.c mpmathdecimal_c_h = mpmathdecimal.h mpmathdecimal.c mpmathdouble_c_h = mpmathdouble.h mpmathdouble.c +mpmathinterval_c_h = mpmathinterval.h mpmathinterval.c mpstrings_c_h = mpstrings.h mpstrings.c psout_c_h = mplibps.h mppsout.h psout.c svgout_c_h = mplibsvg.h mpsvgout.h svgout.c pngout_c_h = mplibpng.h mppngout.h pngout.c libmplib_web = mplibdir/mp.w mplibdir/psout.w mplibdir/svgout.w \ mplibdir/pngout.w mplibdir/mpmath.w mplibdir/mpmathbinary.w \ - mplibdir/mpmathdecimal.w mplibdir/mpmathdouble.w \ - mplibdir/mpstrings.w mplibdir/tfmin.w + mplibdir/mpmathinterval.w mplibdir/mpmathdecimal.w \ + mplibdir/mpmathdouble.w mplibdir/mpstrings.w mplibdir/tfmin.w etex_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(am__append_136) # With --enable-ipc, e-TeX may need to link with -lsocket. @@ -8564,6 +8580,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmplibcore_a-psout.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmplibcore_a-tfmin.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmplibextramath_a-mpmathbinary.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmplibextramath_a-mpmathinterval.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luahbtex-dummy.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/luajithbtex-dummy.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mf-mfextra.Po@am__quote@ # am--include-marker @@ -8595,6 +8612,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmpost-pmpmathbinary.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmpost-pmpmathdecimal.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmpost-pmpmathdouble.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmpost-pmpmathinterval.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmpost-pmpost.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmpost-pmpstrings.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmpost-pmpxout.Po@am__quote@ # am--include-marker @@ -8622,6 +8640,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upmpost-pmpmathbinary.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upmpost-pmpmathdecimal.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upmpost-pmpmathdouble.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upmpost-pmpmathinterval.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upmpost-pmpost.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upmpost-pmpstrings.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/upmpost-pmpxout.Po@am__quote@ # am--include-marker @@ -16365,6 +16384,20 @@ libmplibextramath_a-mpmathbinary.obj: mpmathbinary.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmplibextramath_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmplibextramath_a-mpmathbinary.obj `if test -f 'mpmathbinary.c'; then $(CYGPATH_W) 'mpmathbinary.c'; else $(CYGPATH_W) '$(srcdir)/mpmathbinary.c'; fi` +libmplibextramath_a-mpmathinterval.o: mpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmplibextramath_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmplibextramath_a-mpmathinterval.o -MD -MP -MF $(DEPDIR)/libmplibextramath_a-mpmathinterval.Tpo -c -o libmplibextramath_a-mpmathinterval.o `test -f 'mpmathinterval.c' || echo '$(srcdir)/'`mpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmplibextramath_a-mpmathinterval.Tpo $(DEPDIR)/libmplibextramath_a-mpmathinterval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mpmathinterval.c' object='libmplibextramath_a-mpmathinterval.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmplibextramath_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmplibextramath_a-mpmathinterval.o `test -f 'mpmathinterval.c' || echo '$(srcdir)/'`mpmathinterval.c + +libmplibextramath_a-mpmathinterval.obj: mpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmplibextramath_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmplibextramath_a-mpmathinterval.obj -MD -MP -MF $(DEPDIR)/libmplibextramath_a-mpmathinterval.Tpo -c -o libmplibextramath_a-mpmathinterval.obj `if test -f 'mpmathinterval.c'; then $(CYGPATH_W) 'mpmathinterval.c'; else $(CYGPATH_W) '$(srcdir)/mpmathinterval.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmplibextramath_a-mpmathinterval.Tpo $(DEPDIR)/libmplibextramath_a-mpmathinterval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mpmathinterval.c' object='libmplibextramath_a-mpmathinterval.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmplibextramath_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmplibextramath_a-mpmathinterval.obj `if test -f 'mpmathinterval.c'; then $(CYGPATH_W) 'mpmathinterval.c'; else $(CYGPATH_W) '$(srcdir)/mpmathinterval.c'; fi` + mplibdir/libmputil_a-avl.o: mplibdir/avl.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmputil_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mplibdir/libmputil_a-avl.o -MD -MP -MF mplibdir/$(DEPDIR)/libmputil_a-avl.Tpo -c -o mplibdir/libmputil_a-avl.o `test -f 'mplibdir/avl.c' || echo '$(srcdir)/'`mplibdir/avl.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) mplibdir/$(DEPDIR)/libmputil_a-avl.Tpo mplibdir/$(DEPDIR)/libmputil_a-avl.Po @@ -17989,6 +18022,20 @@ pmpost-pmpmath.obj: pmpmath.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pmpost-pmpmath.obj `if test -f 'pmpmath.c'; then $(CYGPATH_W) 'pmpmath.c'; else $(CYGPATH_W) '$(srcdir)/pmpmath.c'; fi` +pmpost-pmpmathinterval.o: pmpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pmpost-pmpmathinterval.o -MD -MP -MF $(DEPDIR)/pmpost-pmpmathinterval.Tpo -c -o pmpost-pmpmathinterval.o `test -f 'pmpmathinterval.c' || echo '$(srcdir)/'`pmpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pmpost-pmpmathinterval.Tpo $(DEPDIR)/pmpost-pmpmathinterval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pmpmathinterval.c' object='pmpost-pmpmathinterval.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pmpost-pmpmathinterval.o `test -f 'pmpmathinterval.c' || echo '$(srcdir)/'`pmpmathinterval.c + +pmpost-pmpmathinterval.obj: pmpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pmpost-pmpmathinterval.obj -MD -MP -MF $(DEPDIR)/pmpost-pmpmathinterval.Tpo -c -o pmpost-pmpmathinterval.obj `if test -f 'pmpmathinterval.c'; then $(CYGPATH_W) 'pmpmathinterval.c'; else $(CYGPATH_W) '$(srcdir)/pmpmathinterval.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pmpost-pmpmathinterval.Tpo $(DEPDIR)/pmpost-pmpmathinterval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pmpmathinterval.c' object='pmpost-pmpmathinterval.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pmpost-pmpmathinterval.obj `if test -f 'pmpmathinterval.c'; then $(CYGPATH_W) 'pmpmathinterval.c'; else $(CYGPATH_W) '$(srcdir)/pmpmathinterval.c'; fi` + pmpost-pmpmathbinary.o: pmpmathbinary.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pmpost-pmpmathbinary.o -MD -MP -MF $(DEPDIR)/pmpost-pmpmathbinary.Tpo -c -o pmpost-pmpmathbinary.o `test -f 'pmpmathbinary.c' || echo '$(srcdir)/'`pmpmathbinary.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pmpost-pmpmathbinary.Tpo $(DEPDIR)/pmpost-pmpmathbinary.Po @@ -18367,6 +18414,20 @@ upmpost-pmpmath.obj: pmpmath.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(upmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o upmpost-pmpmath.obj `if test -f 'pmpmath.c'; then $(CYGPATH_W) 'pmpmath.c'; else $(CYGPATH_W) '$(srcdir)/pmpmath.c'; fi` +upmpost-pmpmathinterval.o: pmpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(upmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT upmpost-pmpmathinterval.o -MD -MP -MF $(DEPDIR)/upmpost-pmpmathinterval.Tpo -c -o upmpost-pmpmathinterval.o `test -f 'pmpmathinterval.c' || echo '$(srcdir)/'`pmpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/upmpost-pmpmathinterval.Tpo $(DEPDIR)/upmpost-pmpmathinterval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pmpmathinterval.c' object='upmpost-pmpmathinterval.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(upmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o upmpost-pmpmathinterval.o `test -f 'pmpmathinterval.c' || echo '$(srcdir)/'`pmpmathinterval.c + +upmpost-pmpmathinterval.obj: pmpmathinterval.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(upmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT upmpost-pmpmathinterval.obj -MD -MP -MF $(DEPDIR)/upmpost-pmpmathinterval.Tpo -c -o upmpost-pmpmathinterval.obj `if test -f 'pmpmathinterval.c'; then $(CYGPATH_W) 'pmpmathinterval.c'; else $(CYGPATH_W) '$(srcdir)/pmpmathinterval.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/upmpost-pmpmathinterval.Tpo $(DEPDIR)/upmpost-pmpmathinterval.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pmpmathinterval.c' object='upmpost-pmpmathinterval.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(upmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o upmpost-pmpmathinterval.obj `if test -f 'pmpmathinterval.c'; then $(CYGPATH_W) 'pmpmathinterval.c'; else $(CYGPATH_W) '$(srcdir)/pmpmathinterval.c'; fi` + upmpost-pmpmathbinary.o: pmpmathbinary.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(upmpost_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT upmpost-pmpmathbinary.o -MD -MP -MF $(DEPDIR)/upmpost-pmpmathbinary.Tpo -c -o upmpost-pmpmathbinary.o `test -f 'pmpmathbinary.c' || echo '$(srcdir)/'`pmpmathbinary.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/upmpost-pmpmathbinary.Tpo $(DEPDIR)/upmpost-pmpmathbinary.Po @@ -19861,6 +19922,7 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/libmplibcore_a-psout.Po -rm -f ./$(DEPDIR)/libmplibcore_a-tfmin.Po -rm -f ./$(DEPDIR)/libmplibextramath_a-mpmathbinary.Po + -rm -f ./$(DEPDIR)/libmplibextramath_a-mpmathinterval.Po -rm -f ./$(DEPDIR)/luahbtex-dummy.Po -rm -f ./$(DEPDIR)/luajithbtex-dummy.Po -rm -f ./$(DEPDIR)/mf-mfextra.Po @@ -19892,6 +19954,7 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/pmpost-pmpmathbinary.Po -rm -f ./$(DEPDIR)/pmpost-pmpmathdecimal.Po -rm -f ./$(DEPDIR)/pmpost-pmpmathdouble.Po + -rm -f ./$(DEPDIR)/pmpost-pmpmathinterval.Po -rm -f ./$(DEPDIR)/pmpost-pmpost.Po -rm -f ./$(DEPDIR)/pmpost-pmpstrings.Po -rm -f ./$(DEPDIR)/pmpost-pmpxout.Po @@ -19919,6 +19982,7 @@ distclean: distclean-recursive -rm -f ./$(DEPDIR)/upmpost-pmpmathbinary.Po -rm -f ./$(DEPDIR)/upmpost-pmpmathdecimal.Po -rm -f ./$(DEPDIR)/upmpost-pmpmathdouble.Po + -rm -f ./$(DEPDIR)/upmpost-pmpmathinterval.Po -rm -f ./$(DEPDIR)/upmpost-pmpost.Po -rm -f ./$(DEPDIR)/upmpost-pmpstrings.Po -rm -f ./$(DEPDIR)/upmpost-pmpxout.Po @@ -20639,6 +20703,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/libmplibcore_a-psout.Po -rm -f ./$(DEPDIR)/libmplibcore_a-tfmin.Po -rm -f ./$(DEPDIR)/libmplibextramath_a-mpmathbinary.Po + -rm -f ./$(DEPDIR)/libmplibextramath_a-mpmathinterval.Po -rm -f ./$(DEPDIR)/luahbtex-dummy.Po -rm -f ./$(DEPDIR)/luajithbtex-dummy.Po -rm -f ./$(DEPDIR)/mf-mfextra.Po @@ -20670,6 +20735,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/pmpost-pmpmathbinary.Po -rm -f ./$(DEPDIR)/pmpost-pmpmathdecimal.Po -rm -f ./$(DEPDIR)/pmpost-pmpmathdouble.Po + -rm -f ./$(DEPDIR)/pmpost-pmpmathinterval.Po -rm -f ./$(DEPDIR)/pmpost-pmpost.Po -rm -f ./$(DEPDIR)/pmpost-pmpstrings.Po -rm -f ./$(DEPDIR)/pmpost-pmpxout.Po @@ -20697,6 +20763,7 @@ maintainer-clean: maintainer-clean-recursive -rm -f ./$(DEPDIR)/upmpost-pmpmathbinary.Po -rm -f ./$(DEPDIR)/upmpost-pmpmathdecimal.Po -rm -f ./$(DEPDIR)/upmpost-pmpmathdouble.Po + -rm -f ./$(DEPDIR)/upmpost-pmpmathinterval.Po -rm -f ./$(DEPDIR)/upmpost-pmpost.Po -rm -f ./$(DEPDIR)/upmpost-pmpstrings.Po -rm -f ./$(DEPDIR)/upmpost-pmpxout.Po @@ -21383,6 +21450,7 @@ $(proglib): $(proglib_sources) @POTRACE_RULE@ @GMP_RULE@ @MPFR_RULE@ +@MPFI_RULE@ @XPDF_RULE@ @PPLIB_RULE@ @ZZIPLIB_RULE@ @@ -21799,6 +21867,10 @@ pmpmath.c: mpmath.c $(AM_V_GEN)$(pmp_sed) mpmath.c >$@ pmpmath.h: mpmath.h $(AM_V_GEN)$(pmp_sed) mpmath.h >$@ +pmpmathinterval.c: mpmathinterval.c + $(AM_V_GEN)$(pmp_sed) mpmathinterval.c >$@ +pmpmathinterval.h: mpmathinterval.h + $(AM_V_GEN)$(pmp_sed) mpmathinterval.h >$@ pmpmathbinary.c: mpmathbinary.c $(AM_V_GEN)$(pmp_sed) mpmathbinary.c >$@ pmpmathbinary.h: mpmathbinary.h @@ -21860,7 +21932,7 @@ psvgout-tangle: ctangle$(EXEEXT) psvgout.w pmpostdir/psvgout.ch tangle-sh $(pmp_ctangle_sh) psvgout psvgout $(pmpost_OBJECTS) $(upmpost_OBJECTS): $(nodist_pmpost_SOURCES) $(PTEXENC_DEPEND) \ - $(LIBPNG_DEPEND) $(CAIRO_DEPEND) $(MPFR_DEPEND) + $(LIBPNG_DEPEND) $(CAIRO_DEPEND) $(MPFI_DEPEND) $(MPFR_DEPEND) pmpostdir/pmpost.log pmpostdir/pmpsamp.log: pmpost$(EXEEXT) pmpostdir/upmpost.log pmpostdir/upmpsamp.log: upmpost$(EXEEXT) @@ -21886,6 +21958,11 @@ $(mpmathbinary_c_h): mpmathbinary-tangle mp-tangle mpmathbinary-tangle: ctangle$(EXEEXT) mplibdir/mpmathbinary.w tangle-sh $(mp_ctangle_sh) mpmathbinary +$(mpmathinterval_c_h): mpmathinterval-tangle mp-tangle + $(mp_ctangle_sh) mpmathinterval +mpmathinterval-tangle: ctangle$(EXEEXT) mplibdir/mpmathinterval.w tangle-sh + $(mp_ctangle_sh) mpmathinterval + $(mpmathdecimal_c_h): mpmathdecimal-tangle mp-tangle $(mp_ctangle_sh) mpmathdecimal mpmathdecimal-tangle: ctangle$(EXEEXT) mplibdir/mpmathdecimal.w tangle-sh @@ -21916,11 +21993,11 @@ $(svgout_c_h): svgout-tangle svgout-tangle: ctangle$(EXEEXT) mplibdir/svgout.w tangle-sh $(mp_ctangle_sh) svgout -$(nodist_libmplibcore_a_SOURCES): $(mpmathbinary_c_h) $(svgout_c_h) $(pngout_c_h) +$(nodist_libmplibcore_a_SOURCES): $(mpmathbinary_c_h) $(mpmathinterval_c_h) $(svgout_c_h) $(pngout_c_h) $(libmplibcore_a_OBJECTS): $(nodist_libmplibcore_a_SOURCES) $(KPATHSEA_DEPEND) -$(libmplibextramath_a_OBJECTS): $(nodist_libmplibextramath_a_SOURCES) $(KPATHSEA_DEPEND) $(MPFR_DEPEND) -$(libmplibbackends_a_OBJECTS): $(nodist_libmplibbackends_a_SOURCES) $(KPATHSEA_DEPEND) $(CAIRO_DEPEND) $(MPFR_DEPEND) +$(libmplibextramath_a_OBJECTS): $(nodist_libmplibextramath_a_SOURCES) $(KPATHSEA_DEPEND) $(MPFI_DEPEND) $(MPFR_DEPEND) +$(libmplibbackends_a_OBJECTS): $(nodist_libmplibbackends_a_SOURCES) $(KPATHSEA_DEPEND) $(CAIRO_DEPEND) $(MPFI_DEPEND) $(MPFR_DEPEND) # (end of libmplib.am) $(etex_OBJECTS): $(etex_prereq) diff --git a/Build/source/texk/web2c/NEWS b/Build/source/texk/web2c/NEWS index f011e0c2a7f..c73ffa65097 100644 --- a/Build/source/texk/web2c/NEWS +++ b/Build/source/texk/web2c/NEWS @@ -11,6 +11,9 @@ See also */NEWS, */ChangeLog, etc. --output-directory option. More details: https://tug.org/texinfohtml/web2c.html#Output-file-location +* mpost: new option --numbersystem=interval to support interval + arithmetic, via the mpfi library. + 2023 (for TeX Live 2023, 9 March 2023) diff --git a/Build/source/texk/web2c/ac/web2c.ac b/Build/source/texk/web2c/ac/web2c.ac index 762ce004faf..50849efab79 100644 --- a/Build/source/texk/web2c/ac/web2c.ac +++ b/Build/source/texk/web2c/ac/web2c.ac @@ -1,7 +1,7 @@ dnl $Id$ # texk/web2c/ac/web2c.ac: configure.ac fragment for TL subdir dnl -dnl Copyright 2015-2021 Karl Berry <tex-live@tug.org> +dnl Copyright 2015-2024 Karl Berry <tex-live@tug.org> dnl Copyright 2009-2015 Peter Breitenlohner <tex-live@tug.org> dnl You may freely use, modify and/or distribute this file. dnl @@ -42,9 +42,9 @@ m4_define([kpse_tex_progs], [dnl [[luajittex], [yes], [], [LuaJITTeX], [pplib libpng zziplib luajit]], [[luahbtex], [yes], [], [LuaHBTeX], [pplib libpng zziplib lua53 harfbuzz]], [[luajithbtex], [yes], [], [LuaHBJITTeX], [pplib libpng zziplib luajit harfbuzz]], -[[mp], [yes], [], [MetaPost], [mpfr cairo libpng]], -[[pmp], [yes], [], [pMetaPost], [mpfr cairo libpng ptexenc]], -[[upmp], [yes], [], [upMetaPost], [mpfr cairo libpng ptexenc]], +[[mp], [yes], [], [MetaPost], [mpfi mpfr cairo libpng]], +[[pmp], [yes], [], [pMetaPost], [mpfi mpfr cairo libpng ptexenc]], +[[upmp], [yes], [], [upMetaPost], [mpfi mpfr cairo libpng ptexenc]], [[xetex], [yes], [yes], [XeTeX], [pplib libpng freetype2 teckit harfbuzz]], ])[]dnl m4_foreach([Kpse_Prog], [kpse_tex_progs], diff --git a/Build/source/texk/web2c/aclocal.m4 b/Build/source/texk/web2c/aclocal.m4 index 867acc26d75..daa8e104eeb 100644 --- a/Build/source/texk/web2c/aclocal.m4 +++ b/Build/source/texk/web2c/aclocal.m4 @@ -1303,6 +1303,7 @@ m4_include([../../m4/kpse-lua52-flags.m4]) m4_include([../../m4/kpse-lua53-flags.m4]) m4_include([../../m4/kpse-luajit-flags.m4]) m4_include([../../m4/kpse-macos-framework.m4]) +m4_include([../../m4/kpse-mpfi-flags.m4]) m4_include([../../m4/kpse-mpfr-flags.m4]) m4_include([../../m4/kpse-pixman-flags.m4]) m4_include([../../m4/kpse-potrace-flags.m4]) diff --git a/Build/source/texk/web2c/configure b/Build/source/texk/web2c/configure index ecc1d4cb77f..682ae7fe378 100755 --- a/Build/source/texk/web2c/configure +++ b/Build/source/texk/web2c/configure @@ -697,6 +697,10 @@ XPDF_RULE XPDF_DEPEND XPDF_LIBS XPDF_INCLUDES +MPFI_RULE +MPFI_DEPEND +MPFI_LIBS +MPFI_INCLUDES MPFR_RULE MPFR_DEPEND MPFR_LIBS @@ -1089,6 +1093,9 @@ with_gmp_libdir with_system_mpfr with_mpfr_includes with_mpfr_libdir +with_system_mpfi +with_mpfi_includes +with_mpfi_libdir with_system_zziplib with_system_teckit with_system_graphite2 @@ -1863,6 +1870,10 @@ Optional Packages: --with-mpfr-includes=DIR mpfr headers installed in DIR --with-mpfr-libdir=DIR mpfr library installed in DIR + --with-system-mpfi use installed mpfi headers and library + --with-mpfi-includes=DIR + mpfi headers installed in DIR + --with-mpfi-libdir=DIR mpfi library installed in DIR --with-system-zziplib use installed zziplib headers and library (requires pkg-config) --with-system-teckit use installed teckit headers and library (requires @@ -20485,6 +20496,7 @@ case $enable_mp in #( esac test "x$enable_web2c:$enable_mp" = xyes:yes && { + need_mpfi=yes need_mpfr=yes need_cairo=yes need_libpng=yes @@ -20502,6 +20514,7 @@ case $enable_pmp in #( esac test "x$enable_web2c:$enable_pmp" = xyes:yes && { + need_mpfi=yes need_mpfr=yes need_cairo=yes need_libpng=yes @@ -20520,6 +20533,7 @@ case $enable_upmp in #( esac test "x$enable_web2c:$enable_upmp" = xyes:yes && { + need_mpfi=yes need_mpfr=yes need_cairo=yes need_libpng=yes @@ -28033,6 +28047,47 @@ ${top_builddir}/../../libs/mpfr/include/mpfr.h: cd ${top_builddir}/../../libs/mpfr && $(MAKE) $(AM_MAKEFLAGS) rebuild' fi +##tldbg _KPSE_LIB_FLAGS: Setup mpfi (-lmpfi) flags. +echo 'tldbg:_KPSE_LIB_FLAGS called: libdir=mpfi, libname=mpfi, options=, tlincl=-IBLD/libs/mpfi/include, tllib=BLD/libs/mpfi/libmpfi.a, tlextra=, rebuildsrcdeps=, rebuildblddeps=${top_builddir}/../../libs/mpfi/include/mpfi.h.' >&5 +##tldbg _KPSE_LIB_FLAGS_TL: mpfi (mpfi) . + +# Check whether --with-system-mpfi was given. +if test ${with_system_mpfi+y} +then : + withval=$with_system_mpfi; +fi + +# Check whether --with-mpfi-includes was given. +if test ${with_mpfi_includes+y} +then : + withval=$with_mpfi_includes; +fi + +# Check whether --with-mpfi-libdir was given. +if test ${with_mpfi_libdir+y} +then : + withval=$with_mpfi_libdir; +fi +if test "x$with_system_mpfi" = xyes; then + ##tldbg _KPSE_LIB_FLAGS_SYSTEM: mpfi (mpfi). +if test "x$with_mpfi_includes" != x && test "x$with_mpfi_includes" != xyes; then + MPFI_INCLUDES="-I$with_mpfi_includes" +fi +MPFI_LIBS="-lmpfi" +if test "x$with_mpfi_libdir" != x && test "x$with_mpfi_libdir" != xyes; then + MPFI_LIBS="-L$with_mpfi_libdir $MPFI_LIBS" +fi +else + MPFI_INCLUDES="-I$kpse_BLD/libs/mpfi/include" + MPFI_LIBS="$kpse_BLD/libs/mpfi/libmpfi.a" + MPFI_DEPEND='${top_builddir}/../../libs/mpfi/libmpfi.a' + MPFI_RULE='# Rebuild libmpfi +$(MPFI_DEPEND): ${top_builddir}/../../libs/mpfi/include/mpfi.h + cd ${top_builddir}/../../libs/mpfi && $(MAKE) $(AM_MAKEFLAGS) rebuild +${top_builddir}/../../libs/mpfi/include/mpfi.h: + cd ${top_builddir}/../../libs/mpfi && $(MAKE) $(AM_MAKEFLAGS) rebuild' +fi + ##tldbg _KPSE_LIB_FLAGS: Setup xpdf (-lxpdf) flags. echo 'tldbg:_KPSE_LIB_FLAGS called: libdir=xpdf, libname=xpdf, options=, tlincl=-DPDF_PARSER_ONLY -IBLD/libs/xpdf -IBLD/libs/xpdf/goo -IBLD/libs/xpdf/xpdf, tllib=BLD/libs/xpdf/libxpdf.a, tlextra=, rebuildsrcdeps=, rebuildblddeps=${top_builddir}/../../libs/xpdf/xpdf/Stream.h.' >&5 ##tldbg _KPSE_LIB_FLAGS_TL: xpdf (xpdf) . diff --git a/Build/source/texk/web2c/configure.ac b/Build/source/texk/web2c/configure.ac index 1239dfa80c5..014da32b7d1 100644 --- a/Build/source/texk/web2c/configure.ac +++ b/Build/source/texk/web2c/configure.ac @@ -1,7 +1,7 @@ dnl $Id$ dnl Process this file with Autoconf to produce a configure script for Web2c. dnl -dnl Copyright 2015-2023 Karl Berry <tex-live@tug.org> +dnl Copyright 2015-2024 Karl Berry <tex-live@tug.org> dnl Copyright 2009-2015 Peter Breitenlohner <tex-live@tug.org> dnl dnl This file is free software; the copyright holder @@ -260,6 +260,7 @@ KPSE_CAIRO_FLAGS KPSE_POTRACE_FLAGS KPSE_GMP_FLAGS KPSE_MPFR_FLAGS +KPSE_MPFI_FLAGS KPSE_XPDF_FLAGS KPSE_ZZIPLIB_FLAGS KPSE_TECKIT_FLAGS diff --git a/Build/source/texk/web2c/doc/Makefile.in b/Build/source/texk/web2c/doc/Makefile.in index 489eae198ef..b9dc2c05b40 100644 --- a/Build/source/texk/web2c/doc/Makefile.in +++ b/Build/source/texk/web2c/doc/Makefile.in @@ -111,6 +111,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -339,6 +340,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ diff --git a/Build/source/texk/web2c/lib/Makefile.in b/Build/source/texk/web2c/lib/Makefile.in index ebd793b8c42..2ae2727f262 100644 --- a/Build/source/texk/web2c/lib/Makefile.in +++ b/Build/source/texk/web2c/lib/Makefile.in @@ -113,6 +113,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -343,6 +344,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ diff --git a/Build/source/texk/web2c/luatexdir/lua/mplibstuff.c b/Build/source/texk/web2c/luatexdir/lua/mplibstuff.c index f4845c0a4f4..3c65586541a 100644 --- a/Build/source/texk/web2c/luatexdir/lua/mplibstuff.c +++ b/Build/source/texk/web2c/luatexdir/lua/mplibstuff.c @@ -55,6 +55,7 @@ void mp_svg_backend_free (void *mp); int mp_svg_ship_out (void *hh, int prologues); int mp_svg_gr_ship_out (void *hh, int qprologues, int standalone); +void *mp_initialize_interval_math(void *mp); void *mp_initialize_binary_math(void *mp); @@ -69,9 +70,11 @@ int mp_svg_ship_out (void *hh, int prologues) { mplibstuff_m int mp_svg_gr_ship_out (void *hh, int qprologues, int standalone) { mplibstuff_message(svg backend); return 1; } +void *mp_initialize_interval_math(void *mp) {mplibstuff_message(math interval);return NULL; } void *mp_initialize_binary_math(void *mp) {mplibstuff_message(math binary);return NULL; } const char* cairo_version_string (void); +const char* mpfi_get_version(void); const char* mpfr_get_version(void); const char* pixman_version_string (void); @@ -82,6 +85,9 @@ const char *COMPILED_CAIRO_VERSION_STRING = CAIRO_VERSION_STRING; #define MPFR_VERSION_STRING "MPFR NOT AVAILABLE" const char *COMPILED_MPFR_VERSION_STRING = MPFR_VERSION_STRING; +#define MPFI_VERSION_STRING "MPFI NOT AVAILABLE" +const char *COMPILED_MPFI_VERSION_STRING = MPFI_VERSION_STRING; + #define __GNU_MP_VERSION -1 #define __GNU_MP_VERSION_MINOR -1 @@ -99,6 +105,11 @@ const char* cairo_version_string (void) return CAIRO_VERSION_STRING; } +const char* mpfi_get_version(void) +{ + return MPFI_VERSION_STRING; +} + const char* mpfr_get_version(void) { return MPFR_VERSION_STRING; diff --git a/Build/source/texk/web2c/man/Makefile.in b/Build/source/texk/web2c/man/Makefile.in index 4209ad5fb44..eb39de0fa8f 100644 --- a/Build/source/texk/web2c/man/Makefile.in +++ b/Build/source/texk/web2c/man/Makefile.in @@ -134,6 +134,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -323,6 +324,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog index 26e8f2fc59b..e9c1d2c7668 100644 --- a/Build/source/texk/web2c/mplibdir/ChangeLog +++ b/Build/source/texk/web2c/mplibdir/ChangeLog @@ -1,3 +1,28 @@ +2024-02-01 Luigi Scarso <luigi.scarso@gmail.com> + + * final integration and commit of mpfi into (u)(p)mpost. + * am/libmplib.am, + * am/mplib.am: link with mpfi. + * mplibdir/mp.w: support mpfi; version 2.10. + * mplibdir/mpmathinterval.w: new file. + * mplibdir/mpost.w: new option --numbersystem=interval. + +2024-01-26 Luigi Scarso <luigi.scarso@gmail.com> + * Added source/libs/mpfi/TLpatches and source/libs/mpfi/m4 + +2024-01-03 Luigi Scarso <luigi.scarso@gmail.com> + * Fixed "++" and "+-+" by replacing a*a with sqr(a). Better error message for square root of negative numbers. + +2024-01-02 Luigi Scarso <luigi.scarso@gmail.com> + * fixed negate for mpfi. + +2023-12-31 Luigi Scarso <luigi.scarso@gmail.com> + * fixed check interval for square root + +2023-12-30 Luigi Scarso <luigi.scarso@gmail.com> + * Fixed allocation of the buffer for the file extension. + * Fixed position of verbatim_written in mpxout.w + 2023-09-17 TANAKA Takuji <ttk@t-lab.opal.ne.jp> * mptraptest.test: diff --git a/Build/source/texk/web2c/mplibdir/am/libmplib.am b/Build/source/texk/web2c/mplibdir/am/libmplib.am index 9136bb10b3e..69d309b2a58 100644 --- a/Build/source/texk/web2c/mplibdir/am/libmplib.am +++ b/Build/source/texk/web2c/mplibdir/am/libmplib.am @@ -11,14 +11,14 @@ EXTRA_LIBRARIES += libmplibcore.a libmplibextramath.a libmplibbackends.a libmplibcore_a_CPPFLAGS = $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir -libmplibextramath_a_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) -I${top_builddir}/../../libs $(AM_CPPFLAGS) -I$(srcdir)/mplibdir -libmplibbackends_a_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ +libmplibextramath_a_CPPFLAGS = $(MPFI_INCLUDES) $(MPFR_INCLUDES) $(GMP_INCLUDES) -I${top_builddir}/../../libs $(AM_CPPFLAGS) -I$(srcdir)/mplibdir +libmplibbackends_a_CPPFLAGS = $(MPFI_INCLUDES) $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir ## libmplib C sources core + extramath + backends nodist_libmplibcore_a_SOURCES = tfmin.c $(mp_c_h) $(mpmath_c_h) $(mpmathdecimal_c_h) \ $(mpmathdouble_c_h) $(mpstrings_c_h) $(psout_c_h) -nodist_libmplibextramath_a_SOURCES = $(mpmathbinary_c_h) +nodist_libmplibextramath_a_SOURCES = $(mpmathbinary_c_h) $(mpmathinterval_c_h) nodist_libmplibbackends_a_SOURCES = $(pngout_c_h) $(svgout_c_h) @@ -28,6 +28,7 @@ mpmath_c_h = mpmath.h mpmath.c mpmathbinary_c_h = mpmathbinary.h mpmathbinary.c mpmathdecimal_c_h = mpmathdecimal.h mpmathdecimal.c mpmathdouble_c_h = mpmathdouble.h mpmathdouble.c +mpmathinterval_c_h = mpmathinterval.h mpmathinterval.c mpstrings_c_h = mpstrings.h mpstrings.c psout_c_h = mplibps.h mppsout.h psout.c svgout_c_h = mplibsvg.h mpsvgout.h svgout.c @@ -53,6 +54,11 @@ $(mpmathbinary_c_h): mpmathbinary-tangle mp-tangle mpmathbinary-tangle: ctangle$(EXEEXT) mplibdir/mpmathbinary.w tangle-sh $(mp_ctangle_sh) mpmathbinary +$(mpmathinterval_c_h): mpmathinterval-tangle mp-tangle + $(mp_ctangle_sh) mpmathinterval +mpmathinterval-tangle: ctangle$(EXEEXT) mplibdir/mpmathinterval.w tangle-sh + $(mp_ctangle_sh) mpmathinterval + $(mpmathdecimal_c_h): mpmathdecimal-tangle mp-tangle $(mp_ctangle_sh) mpmathdecimal mpmathdecimal-tangle: ctangle$(EXEEXT) mplibdir/mpmathdecimal.w tangle-sh @@ -85,15 +91,15 @@ svgout-tangle: ctangle$(EXEEXT) mplibdir/svgout.w tangle-sh ## libmplib CWeb sources libmplib_web = mplibdir/mp.w mplibdir/psout.w mplibdir/svgout.w mplibdir/pngout.w -libmplib_web += mplibdir/mpmath.w mplibdir/mpmathbinary.w mplibdir/mpmathdecimal.w +libmplib_web += mplibdir/mpmath.w mplibdir/mpmathbinary.w mplibdir/mpmathinterval.w mplibdir/mpmathdecimal.w libmplib_web += mplibdir/mpmathdouble.w mplibdir/mpstrings.w mplibdir/tfmin.w ## core need headers backends -$(nodist_libmplibcore_a_SOURCES): $(mpmathbinary_c_h) $(svgout_c_h) $(pngout_c_h) +$(nodist_libmplibcore_a_SOURCES): $(mpmathbinary_c_h) $(mpmathinterval_c_h) $(svgout_c_h) $(pngout_c_h) $(libmplibcore_a_OBJECTS): $(nodist_libmplibcore_a_SOURCES) $(KPATHSEA_DEPEND) -$(libmplibextramath_a_OBJECTS): $(nodist_libmplibextramath_a_SOURCES) $(KPATHSEA_DEPEND) $(MPFR_DEPEND) -$(libmplibbackends_a_OBJECTS): $(nodist_libmplibbackends_a_SOURCES) $(KPATHSEA_DEPEND) $(CAIRO_DEPEND) $(MPFR_DEPEND) +$(libmplibextramath_a_OBJECTS): $(nodist_libmplibextramath_a_SOURCES) $(KPATHSEA_DEPEND) $(MPFI_DEPEND) $(MPFR_DEPEND) +$(libmplibbackends_a_OBJECTS): $(nodist_libmplibbackends_a_SOURCES) $(KPATHSEA_DEPEND) $(CAIRO_DEPEND) $(MPFI_DEPEND) $(MPFR_DEPEND) EXTRA_DIST += $(libmplib_web) diff --git a/Build/source/texk/web2c/mplibdir/am/mplib.am b/Build/source/texk/web2c/mplibdir/am/mplib.am index 29a75557f18..bf1a835482e 100644 --- a/Build/source/texk/web2c/mplibdir/am/mplib.am +++ b/Build/source/texk/web2c/mplibdir/am/mplib.am @@ -21,7 +21,7 @@ endif MP EXTRA_PROGRAMS += mpost mpost_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) -I$(srcdir)/mplibdir -mpost_LDADD = libmplibcore.a libmplibextramath.a libmplibbackends.a $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ +mpost_LDADD = libmplibcore.a libmplibextramath.a libmplibbackends.a $(KPATHSEA_LIBS) $(MPFI_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w index df3d7f10f3c..25e9143f287 100644 --- a/Build/source/texk/web2c/mplibdir/mp.w +++ b/Build/source/texk/web2c/mplibdir/mp.w @@ -71,12 +71,12 @@ undergoes any modifications, so that it will be clear which version of @^extensions to \MP@> @^system dependencies@> -@d default_banner "This is MetaPost, Version 2.02" /* printed when \MP\ starts */ +@d default_banner "This is MetaPost, Version 2.10" /* printed when \MP\ starts */ @d true 1 @d false 0 @<Metapost version header@>= -#define metapost_version "2.02" +#define metapost_version "2.10" @ The external library header for \MP\ is |mplib.h|. It contains a few typedefs and the header defintions for the externally used @@ -205,6 +205,7 @@ static int DEBUGENVELOPECOUNTER=0; #include "mpmathdouble.h" /* internal header */ #include "mpmathdecimal.h" /* internal header */ /*|#include "mpmathbinary.h"|*/ /* internal header */ +/*|#include "mpmathinterval.h"|*/ /* internal header */ #include "mpstrings.h" /* internal header */ /* BEGIN PATCH */ mp_number dx_ap; /* approximation of dx */ @@ -223,7 +224,10 @@ extern const char *COMPILED_CAIRO_VERSION_STRING; extern const char* cairo_version_string (void); extern const char *COMPILED_MPFR_VERSION_STRING; extern const char* mpfr_get_version (void); +extern const char *COMPILED_MPFI_VERSION_STRING; +extern const char* mpfi_get_version (void); extern void * mp_initialize_binary_math (MP mp) ; +extern void * mp_initialize_interval_math(MP mp); extern int COMPILED__GNU_MP_VERSION; extern int COMPILED__GNU_MP_VERSION_MINOR; extern int COMPILED__GNU_MP_VERSION_PATCHLEVEL; @@ -325,6 +329,35 @@ MP_options *mp_options (void) { } +@ Here are the three primitives of the interval arithmetic adapted to the others number systems: +|left_point| and |right_point| of a number |a| simply return |a|, while +|interval_set| of the pair |(a,b)| returns the mid point. + +@<Declarations@>= +static void mp_stub_m_get_left_endpoint(MP mp, mp_number * r, mp_number a); +static void mp_stub_m_get_right_endpoint(MP mp, mp_number * r, mp_number a); +static void mp_stub_m_interval_set(MP mp, mp_number * r, mp_number a, mp_number b); + + +@ @c +static void mp_stub_m_get_left_endpoint(MP mp, mp_number * r, mp_number a){ + number_clone(*r,a); +} +static void mp_stub_m_get_right_endpoint(MP mp, mp_number * r, mp_number a){ + number_clone(*r,a); +} +static void mp_stub_m_interval_set(MP mp, mp_number * r, mp_number a, mp_number b){ + mp_number x; + new_number(x); + number_add(x,a);number_add(x,b);number_half(x); + number_clone(*r,x); + free_number(x); +} + + + + + @ @<Internal library declarations@>= @<Declare subroutines for parsing file names@> @@ -383,7 +416,8 @@ typedef enum { mp_angle_type, mp_double_type, mp_binary_type, - mp_decimal_type + mp_decimal_type, + mp_interval_type } mp_number_type; typedef union { void *num; @@ -459,6 +493,10 @@ typedef char * (*tostring_func) (MP mp, mp_number A); typedef void (*scan_func) (MP mp, int A); typedef void (*mp_free_func) (MP mp); typedef void (*set_precision_func) (MP mp); +/* math interval new primitives */ +typedef void (*m_get_left_endpoint_func) (MP mp, mp_number *r, mp_number a); +typedef void (*m_get_right_endpoint_func) (MP mp, mp_number *r, mp_number a); +typedef void (*m_interval_set_func) (MP mp, mp_number *r, mp_number a, mp_number b); typedef struct math_data { mp_number precision_default; @@ -564,6 +602,10 @@ typedef struct math_data { scan_func scan_fractional; mp_free_func free_math; set_precision_func set_precision; + /* math interval new primitives */ + m_get_left_endpoint_func m_get_left_endpoint; + m_get_right_endpoint_func m_get_right_endpoint; + m_interval_set_func m_interval_set; } math_data; @@ -615,9 +657,16 @@ MP mp_initialize (MP_options * opt) { mp->math = mp_initialize_decimal_math(mp); } else if (opt->math_mode == mp_math_binary_mode) { mp->math = mp_initialize_binary_math(mp); + } else if (opt->math_mode == mp_math_interval_mode) { + mp->math = mp_initialize_interval_math(mp); } else { mp->math = mp_initialize_double_math(mp); } + if (opt->math_mode != mp_math_interval_mode) { + ((math_data *)mp->math)->m_get_left_endpoint = mp_stub_m_get_left_endpoint; + ((math_data *)mp->math)->m_get_right_endpoint = mp_stub_m_get_right_endpoint; + ((math_data *)mp->math)->m_interval_set = mp_stub_m_interval_set ; + } @<Find and load preload file, if required@>; @<Allocate or initialize variables@>; mp_reallocate_paths (mp, 1000); @@ -640,6 +689,8 @@ MP mp_initialize (MP_options * opt) { set_internal_string (mp_number_system, mp_intern (mp, "decimal")); } else if (opt->math_mode == mp_math_binary_mode) { set_internal_string (mp_number_system, mp_intern (mp, "binary")); + } else if (opt->math_mode == mp_math_interval_mode) { + set_internal_string (mp_number_system, mp_intern (mp, "interval")); } else { set_internal_string (mp_number_system, mp_intern (mp, "double")); } @@ -2813,10 +2864,11 @@ the typedef for |mp_number| is here because it has to come very early. @<Exported types@>= typedef enum { - mp_math_scaled_mode = 0, - mp_math_double_mode = 1, - mp_math_binary_mode = 2, - mp_math_decimal_mode = 3 + mp_math_scaled_mode = 0, + mp_math_double_mode = 1, + mp_math_binary_mode = 2, + mp_math_decimal_mode = 3, + mp_math_interval_mode = 4 } mp_math_mode; @ @<Option variables@>= @@ -3704,7 +3756,11 @@ mp_version, /* operation code for \.{mpversion} */ mp_envelope_of, /* operation code for \.{envelope} */ mp_boundingpath_of, /* operation code for \.{boundingpath} */ mp_glyph_infont, /* operation code for \.{glyph} */ -mp_kern_flag /* operation code for \.{kern} */ +mp_kern_flag, /* operation code for \.{kern} */ +mp_m_get_left_endpoint_op, /* math interval new primitives operation code for \.{interval_get_left_endpoint} */ +mp_m_get_right_endpoint_op, /* math interval new primitives operation code for \.{interval_get_right_endpoint} */ +mp_interval_set_op, /* math interval new primitives operation code for \.{interval_set} */ + @ @c static void mp_print_op (MP mp, quarterword c) { @@ -4021,6 +4077,16 @@ static void mp_print_op (MP mp, quarterword c) { case mp_glyph_infont: mp_print (mp, "glyph"); break; + /* math interval new primitives */ + case mp_m_get_left_endpoint_op: + mp_print (mp, "interval_get_left_endpoint"); + break; + case mp_m_get_right_endpoint_op: + mp_print (mp, "interval_get_right_endpoint"); + break; + case mp_interval_set_op: + mp_print (mp, "interval_set"); + break; default: mp_print (mp, ".."); break; @@ -4369,6 +4435,7 @@ set_internal_name (mp_number_precision, xstrdup ("numberprecision")); set_internal_name (mp_hppp, xstrdup ("hppp")); set_internal_name (mp_vppp, xstrdup ("vppp")); + @ The following procedure, which is called just before \MP\ initializes its input and output, establishes the initial values of the date and time. @^system dependencies@> @@ -11161,6 +11228,9 @@ This first set goes into the header @d convert_angle_to_scaled(A) (((math_data *)(mp->math))->angle_to_scaled)(&(A)); @d convert_fraction_to_scaled(A) (((math_data *)(mp->math))->fraction_to_scaled)(&(A)); @d convert_scaled_to_fraction(A) (((math_data *)(mp->math))->scaled_to_fraction)(&(A)); +@d m_get_left_endpoint(R,A) (((math_data *)(mp->math))->m_get_left_endpoint)(mp,&(R),A) /* math interval new primitives */ +@d m_get_right_endpoint(R,A) (((math_data *)(mp->math))->m_get_right_endpoint)(mp,&(R),A) /* math interval new primitives */ +@d m_interval_set(R,A,B) (((math_data *)(mp->math))->m_interval_set)(mp,&(R),A,B) /* math interval new primitives */ @# @d number_zero(A) number_equal(A, zero_t) @d number_infinite(A) number_equal(A, inf_t) @@ -25346,7 +25416,13 @@ mp_primitive (mp, "envelope", mp_primary_binary, mp_envelope_of); mp_primitive (mp, "boundingpath", mp_primary_binary, mp_boundingpath_of); @:boundingpath_}{\&{boundingpath} primitive@>; mp_primitive (mp, "glyph", mp_primary_binary, mp_glyph_infont); -@:glyph_infont_}{\&{glyph} primitive@> +@:glyph_infont_}{\&{glyph} primitive@>; +mp_primitive (mp, "interval_get_left_endpoint", mp_unary, mp_m_get_left_endpoint_op); /* math interval new primitives */ +@:m_get_left_endpoint_}{\&{mget_left_endpoint} primitive@>; +mp_primitive (mp, "interval_get_right_endpoint", mp_unary, mp_m_get_right_endpoint_op); /* math interval new primitives */ +@:m_get_right_endpoint_}{\&{mget_right_endpoint} primitive@>; +mp_primitive (mp, "interval_set", mp_unary, mp_interval_set_op); /* math interval new primitives */ +@:interval_set}{\&{interval_set} primitive@>; @ @<Cases of |print_cmd...@>= @@ -25517,6 +25593,8 @@ static void mp_do_unary (MP mp, quarterword c) { case mp_uniform_deviate: case mp_odd_op: case mp_char_exists_op: + case mp_m_get_left_endpoint_op: /* math interval new primitives */ + case mp_m_get_right_endpoint_op:/* math interval new primitives */ if (mp->cur_exp.type != mp_known) { mp_bad_unary (mp, c); } else { @@ -25612,9 +25690,43 @@ static void mp_do_unary (MP mp, quarterword c) { boolean_reset (mp->char_exists[number_to_scaled(cur_exp_value_number ())]); mp->cur_exp.type = mp_boolean_type; break; + case mp_m_get_left_endpoint_op: /* math interval new primitives */ + { + mp_number r1; + new_number (r1); + m_get_left_endpoint (r1, cur_exp_value_number ()); + set_cur_exp_value_number (r1); + free_number (r1); + } + break; + case mp_m_get_right_endpoint_op: /* math interval new primitives */ + { + mp_number r1; + new_number (r1); + m_get_right_endpoint (r1, cur_exp_value_number ()); + set_cur_exp_value_number (r1); + free_number (r1); + } + break; + } /* there are no other cases */ } break; + case mp_interval_set_op: /* math interval new primitives */ + if (mp_nice_pair (mp, cur_exp_node (), mp->cur_exp.type)) { + mp_number ret_val; + memset(&new_expr,0,sizeof(mp_value)); + new_number(new_expr.data.n); + new_number(ret_val); + p = value_node (cur_exp_node ()); + m_interval_set(ret_val, value_number (x_part (p)), value_number (y_part (p))); + number_clone (new_expr.data.n, ret_val); + free_number (ret_val); + mp_flush_cur_exp (mp, new_expr); + } else { + mp_bad_unary (mp, mp_interval_set_op); + } + break; case mp_angle_op: if (mp_nice_pair (mp, cur_exp_node (), mp->cur_exp.type)) { mp_number narg; @@ -30924,6 +31036,7 @@ void mp_show_library_versions (void) { fprintf(stdout, "Compiled with libpng %s; using %s\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); fprintf(stdout, "Compiled with zlib %s; using %s\n", ZLIB_VERSION, zlibVersion()); fprintf(stdout, "Compiled with mpfr %s; using %s\n", COMPILED_MPFR_VERSION_STRING, mpfr_get_version()); + fprintf(stdout, "Compiled with mpfi %s; using %s\n", COMPILED_MPFI_VERSION_STRING, mpfi_get_version()); fprintf(stdout, "Compiled with gmp %d.%d.%d; using %s\n\n", COMPILED__GNU_MP_VERSION, COMPILED__GNU_MP_VERSION_MINOR, COMPILED__GNU_MP_VERSION_PATCHLEVEL, COMPILED_gmp_version); } diff --git a/Build/source/texk/web2c/mplibdir/mpmathinterval.w b/Build/source/texk/web2c/mplibdir/mpmathinterval.w new file mode 100644 index 00000000000..755e4dd328d --- /dev/null +++ b/Build/source/texk/web2c/mplibdir/mpmathinterval.w @@ -0,0 +1,2207 @@ +% $Id$ +% +% This file is part of MetaPost; +% the MetaPost program is in the public domain. +% See the <Show version...> code in mpost.w for more info. + +% Here is TeX material that gets inserted after \input webmac + +\font\tenlogo=logo10 % font used for the METAFONT logo +\font\logos=logosl10 +\def\MF{{\tenlogo META}\-{\tenlogo FONT}} +\def\MP{{\tenlogo META}\-{\tenlogo POST}} +\def\pct!{{\char`\%}} % percent sign in ordinary text +\def\psqrt#1{\sqrt{\mathstrut#1}} + + +\def\title{Math support functions for MPFI based math} +\pdfoutput=1 + +@ Introduction. + +@c +#include <w2c/config.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include "mpmathinterval.h" /* internal header */ +#define ROUND(a) floor((a)+0.5) +@h + +@ @c +@<Declarations@>; + +@ @(mpmathinterval.h@>= +#ifndef MPMATHINTERVAL_H +#define MPMATHINTERVAL_H 1 +#include "mplib.h" +#include "mpmp.h" /* internal header */ +#include <gmp.h> +#include <mpfr.h> +#include <mpfi.h> +#include <mpfi_io.h> + +#ifdef HAVE_CONFIG_H +#define MP_STR_HELPER(x) #x +#define MP_STR(x) MP_STR_HELPER(x) +//const char * const COMPILED_gmp_version = MP_STR(__GNU_MP_VERSION) "." MP_STR( __GNU_MP_VERSION_MINOR) "." MP_STR(__GNU_MP_VERSION_PATCHLEVEL); +//#else +//const char * const COMPILED_gmp_version = "unknown"; +#endif + +const char *COMPILED_MPFI_VERSION_STRING = MPFI_VERSION_STRING; +//int COMPILED__GNU_MP_VERSION = __GNU_MP_VERSION ; +//int COMPILED__GNU_MP_VERSION_MINOR = __GNU_MP_VERSION_MINOR ; +//int COMPILED__GNU_MP_VERSION_PATCHLEVEL = __GNU_MP_VERSION_PATCHLEVEL ; + +@<Internal library declarations@>; +#endif + +@* Math initialization. + +First, here are some very important constants. + +@d MPFI_ROUNDING MPFI_RNDN +@d MPFR_ROUNDING MPFR_RNDN +@d E_STRING "2.7182818284590452353602874713526624977572470936999595749669676277240766303535" +@d PI_STRING "3.1415926535897932384626433832795028841971693993751058209749445923078164062862" +@d fraction_multiplier 4096 +@d angle_multiplier 16 + +@ Here are the functions that are static as they are not used elsewhere + +@<Declarations@>= +#define DEBUG 0 +static void mp_interval_scan_fractional_token (MP mp, int n); +static void mp_interval_scan_numeric_token (MP mp, int n); +static void mp_interval_ab_vs_cd (MP mp, mp_number *ret, mp_number a, mp_number b, mp_number c, mp_number d); +static void mp_ab_vs_cd (MP mp, mp_number *ret, mp_number a, mp_number b, mp_number c, mp_number d); +static void mp_interval_crossing_point (MP mp, mp_number *ret, mp_number a, mp_number b, mp_number c); +static void mp_interval_number_modulo (mp_number *a, mp_number b); +static void mp_interval_print_number (MP mp, mp_number n); +static char * mp_interval_number_tostring (MP mp, mp_number n); +static void mp_interval_slow_add (MP mp, mp_number *ret, mp_number x_orig, mp_number y_orig); +static void mp_interval_square_rt (MP mp, mp_number *ret, mp_number x_orig); +static void mp_interval_sin_cos (MP mp, mp_number z_orig, mp_number *n_cos, mp_number *n_sin); +static void mp_init_randoms (MP mp, int seed); +static void mp_number_angle_to_scaled (mp_number *A); +static void mp_number_fraction_to_scaled (mp_number *A); +static void mp_number_scaled_to_fraction (mp_number *A); +static void mp_number_scaled_to_angle (mp_number *A); +static void mp_interval_m_unif_rand (MP mp, mp_number *ret, mp_number x_orig); +static void mp_interval_m_norm_rand (MP mp, mp_number *ret); +static void mp_interval_m_exp (MP mp, mp_number *ret, mp_number x_orig); +static void mp_interval_m_log (MP mp, mp_number *ret, mp_number x_orig); +static void mp_interval_pyth_sub (MP mp, mp_number *r, mp_number a, mp_number b); +static void mp_interval_pyth_add (MP mp, mp_number *r, mp_number a, mp_number b); +static void mp_interval_n_arg (MP mp, mp_number *ret, mp_number x, mp_number y); +static void mp_interval_velocity (MP mp, mp_number *ret, mp_number st, mp_number ct, mp_number sf, mp_number cf, mp_number t); +static void mp_set_interval_from_int(mp_number *A, int B); +static void mp_set_interval_from_boolean(mp_number *A, int B); +static void mp_set_interval_from_scaled(mp_number *A, int B); +static void mp_set_interval_from_addition(mp_number *A, mp_number B, mp_number C); +static void mp_set_interval_from_substraction (mp_number *A, mp_number B, mp_number C); +static void mp_set_interval_from_div(mp_number *A, mp_number B, mp_number C); +static void mp_set_interval_from_mul(mp_number *A, mp_number B, mp_number C); +static void mp_set_interval_from_int_div(mp_number *A, mp_number B, int C); +static void mp_set_interval_from_int_mul(mp_number *A, mp_number B, int C); +static void mp_set_interval_from_of_the_way(MP mp, mp_number *A, mp_number t, mp_number B, mp_number C); +static void mp_number_negate(mp_number *A); +static void mp_number_add(mp_number *A, mp_number B); +static void mp_number_substract(mp_number *A, mp_number B); +static void mp_number_half(mp_number *A); +static void mp_number_halfp(mp_number *A); +static void mp_number_double(mp_number *A); +static void mp_number_add_scaled(mp_number *A, int B); /* also for negative B */ +static void mp_number_multiply_int(mp_number *A, int B); +static void mp_number_divide_int(mp_number *A, int B); +static void mp_interval_abs(mp_number *A); +static void mp_number_clone(mp_number *A, mp_number B); +static void mp_number_swap(mp_number *A, mp_number *B); +static int mp_round_unscaled(mp_number x_orig); +static int mp_number_to_int(mp_number A); +static int mp_number_to_scaled(mp_number A); +static int mp_number_to_boolean(mp_number A); +static double mp_number_to_double(mp_number A); +static int mp_number_odd(mp_number A); +static int mp_number_equal(mp_number A, mp_number B); +static int mp_number_greater(mp_number A, mp_number B); +static int mp_number_less(mp_number A, mp_number B); +static int mp_number_nonequalabs(mp_number A, mp_number B); +static void mp_number_floor (mp_number *i); +static void mp_interval_fraction_to_round_scaled (mp_number *x); +static void mp_interval_number_make_scaled (MP mp, mp_number *r, mp_number p, mp_number q); +static void mp_interval_number_make_fraction (MP mp, mp_number *r, mp_number p, mp_number q); +static void mp_interval_number_take_fraction (MP mp, mp_number *r, mp_number p, mp_number q); +static void mp_interval_number_take_scaled (MP mp, mp_number *r, mp_number p, mp_number q); +static void mp_new_number (MP mp, mp_number *n, mp_number_type t) ; +static void mp_free_number (MP mp, mp_number *n) ; +static void mp_set_interval_from_double(mp_number *A, double B); +static void mp_free_interval_math (MP mp); +static void mp_interval_set_precision (MP mp); +static void mp_check_mpfi_t (MP mp, mpfi_t dec); +static int interval_number_check (mpfi_t dec); +static char * mp_intervalnumber_tostring (mpfi_t n); +static void init_interval_constants (void); +static void free_interval_constants (void); +static mpfr_prec_t precision_digits_to_bits(double i); +static double precision_bits_to_digits (mpfr_prec_t i); +/* math interval new primitives */ +static void mp_interval_m_get_left_endpoint (MP mp, mp_number *ret, mp_number x_orig); +static void mp_interval_m_get_right_endpoint (MP mp, mp_number *ret, mp_number x_orig); +static void mp_interval_m_interval_set (MP mp, mp_number *ret, mp_number a, mp_number b); + + +static int mpfi_remainder (mpfi_t ROP, mpfi_t OP1, mpfi_t OP2) ; +static int mpfi_remainder_1 (mpfi_t ROP, mpfi_t OP1, mpfr_t OP2) ; +static int mpfi_remainder_2 (mpfi_t ROP, mpfi_t OP1, mpfi_t OP2) ; + +@ We do not want special numbers as return values for functions, so: + +@d mpfi_negative_p(a) (mpfi_is_strictly_neg((a))>0) +@d mpfi_positive_p(a) (mpfi_is_strictly_pos((a))>0) +@d mpfi_overlaps_zero_p(a) (mpfi_cmp_ui(a,0)==0) +@d mpfi_nonnegative_p(a) (mpfi_is_nonneg((a))>0) +@d checkZero(dec) if (mpfi_has_zero(dec) ) { // CHECK or mpfi_is_zero ? + mpfi_set_d(dec,0.0); + } + +@d mpfi_zero_p(a) mpfi_has_zero(a) + +@c +int interval_number_check (mpfi_t dec) +{ + int test = false; + if (mpfi_nan_p(dec)!=0 || mpfi_is_empty(dec)!=0 ) { + test = true; + mpfi_set_d(dec,0.0); + /*if (mpfi_inf_p(dec)) { + int neg ; + neg = mpfi_is_neg(dec); + mpfi_set(dec, EL_GORDO_mpfi_t); + if (neg) { + mpfi_neg(dec, dec); + } + } else { // Nan + mpfi_set_d(dec,0.0); + }*/ + } + return test; +} +void mp_check_mpfi_t (MP mp, mpfi_t dec) +{ + mp->arith_error = interval_number_check (dec); +} + + + +@ Precision IO uses |double| because |MPFI_PREC_MAX| overflows int. + +@c +static double precision_bits; +mpfr_prec_t precision_digits_to_bits (double i) +{ + return i/log10(2); +} +double precision_bits_to_digits (mpfr_prec_t d) +{ + return d*log10(2); +} + + +@ Implement remainder for interval arithmetic. + +@c +/* https://stackoverflow.com/questions/31057473/calculating-the-modulo-of-two-intervals */ +/* +def mod1([a,b], m): + // (1): empty interval + if a > b || m == 0: + return [] + // (2): compute modulo with positive interval and negate + else if b < 0: + return -mod1([-b,-a], m) + // (3): split into negative and non-negative interval, compute and join + else if a < 0: + return mod1([a,-1], m) u mod1([0,b], m) + // (4): there is no k > 0 such that a < k*m <= b + else if b-a < |m| && a % m <= b % m: + return [a % m, b % m] + // (5): we can't do better than that + else + return [0,|m|-1] + + +def mod2([a,b], [m,n]): + // (1): empty interval + if a > b || m > n: + return [] + // (2): compute modulo with positive interval and negate + else if b < 0: + return -mod2([-b,-a], [m,n]) + // (3): split into negative and non-negative interval, compute, and join + else if a < 0: + return mod2([a,-1], [m,n]) u mod2([0,b], [m,n]) + // (4): use the simpler function from before + else if m == n: + return mod1([a,b], m) + // (5): use only non-negative m and n + else if n <= 0: + return mod2([a,b], [-n,-m]) + // (6): similar to (5), make modulus non-negative + else if m <= 0: + return mod2([a,b], [1, max(-m,n)]) + // (7): compare to (4) in mod1, check b-a < |modulus| + else if b-a >= n: + return [0,n-1] + // (8): similar to (7), split interval, compute, and join + else if b-a >= m: + return [0, b-a-1] u mod2([a,b], [b-a+1,n]) + // (9): modulo has no effect + else if m > b: + return [a,b] + // (10): there is some overlapping of [a,b] and [n,m] + else if n > b: + return [0,b] + // (11): either compute all possibilities and join, or be imprecise + else: + return [0,n-1] // imprecise +*/ +int mpfi_remainder (mpfi_t r, mpfi_t x, mpfi_t y) { + // CHECK + int test,ret_val; + mpfr_t m,yd; + mpfr_inits2(precision_bits, m, yd,(mpfr_ptr) 0); + test=mpfi_diam(yd, y); + if (test==0 && mpfr_zero_p(yd)>0){ + mpfi_get_fr(m, y); + ret_val = mpfi_remainder_1(r,x,m); + } else { + ret_val = mpfi_remainder_2(r,x,y); + } + mpfr_clears(m, yd, (mpfr_ptr) 0); + return ret_val; +} + +static int mpfi_remainder_1 (mpfi_t r, mpfi_t x, mpfr_t m) { + int ret_val; + ret_val=-1; + if (mpfi_is_strictly_neg(x)>0) { + /*return -mod1([-b,-a], m)*/ + mpfi_neg (x, x); + ret_val = mpfi_remainder_1(r,x,m); + mpfi_neg (r, r); + return ret_val; + } else { + mpfr_t a,b; + mpfr_inits2(precision_bits,a,b,(mpfr_ptr) 0); + mpfi_get_left(a,x); mpfi_get_right(b,x); + if (mpfr_sgn(a)<0) { + /*return mod1([a,-1], m) u mod1([0,b], m) */ + /* which is the same of mod1([1,-a], m) u mod1([0,b], m) */ + mpfi_t l1,l2,ret1, ret2 ; + mpfr_t one,zero ; + mpfi_inits2(precision_bits, ret1, ret2, l1, l2, (mpfi_ptr) 0); + mpfr_inits2(precision_bits, one, zero, (mpfr_ptr) 0); + mpfr_set_si(one, 1, MPFR_RNDN); mpfr_set_si(zero, 0, MPFR_RNDN); + mpfr_neg(a, a, MPFR_RNDN); + mpfi_interv_fr(l1, one, a); mpfi_interv_fr(l2, zero, b); + mpfi_remainder_1(ret1,l1,m); mpfi_remainder_1(ret2,l2,m); + ret_val = mpfi_union(r,ret1,ret2); + mpfi_clears(ret1, ret2, l1,l2,(mpfi_ptr)0); + mpfr_clears(one,zero,(mpfr_ptr)0); + } else { + /*if b-a < |m| && a % m <= b % m:*/ + mpfr_t d,abs_m, rem_a,rem_b,zero,one,abs_m_1; + mpfr_inits2(precision_bits, d, abs_m, rem_a, rem_b, zero, one, abs_m_1,(mpfr_ptr) 0); + mpfr_sub(d, b, a, MPFR_RNDN); + mpfr_abs(abs_m, m, MPFR_RNDN); + mpfr_remainder(rem_a, a, m, MPFR_RNDN); mpfr_remainder(rem_b, b, m, MPFR_RNDN); + if (mpfr_less_p(d,abs_m) && mpfr_lessequal_p(rem_a,rem_b)) { + /*return [a % m, b % m] */ + ret_val= mpfi_interv_fr(r, rem_a, rem_b); + } else { + /* return [0,|m|-1] */ + mpfr_set_si(one, 1, MPFR_RNDN); mpfr_set_si(zero, 0, MPFR_RNDN); mpfr_set_si(zero, 0, MPFR_RNDN); + mpfr_sub(abs_m_1, abs_m, one, MPFR_RNDN); + ret_val = mpfi_interv_fr(r, zero, abs_m_1); + } + mpfr_clears(d, abs_m, rem_a, rem_b, zero, one, abs_m_1, (mpfr_ptr)0); + } + mpfr_clears(a, b, (mpfr_ptr)0); + } + return ret_val; +} + +static int mpfi_remainder_2 (mpfi_t r, mpfi_t x, mpfi_t m) { + int ret_val; + if (mpfi_is_strictly_neg(x)>0) { + /*return -mod2([-b,-a], [m,n])*/ + mpfi_neg (x, x); + ret_val = mpfi_remainder_2(r,x,m); + mpfi_neg (r, r); + return ret_val; + } else { + mpfr_t a,b,n1,m1; + mpfr_t one, zero ; + mpfr_inits2(precision_bits, one, zero, (mpfr_ptr) 0); + mpfr_set_si(one, 1, MPFR_RNDN); mpfr_set_si(zero, 0, MPFR_RNDN); + mpfr_inits2(precision_bits,a,b,(mpfr_ptr) 0); + mpfi_get_left(a,x); mpfi_get_right(b,x); + mpfi_get_left(m1,m); mpfi_get_right(n1,m); + if (mpfr_sgn(a)<0) { + /* return mod2([a,-1], [m,n]) u mod2([0,b], [m,n]) */ + mpfi_t l1, l2, ret1, ret2 ; + mpfi_inits2(precision_bits, ret1, ret2, l1, l2, (mpfi_ptr) 0); + mpfr_neg(a,a,MPFR_RNDN); + mpfi_interv_fr(l1, one, a); mpfi_interv_fr(l2, zero, b); + mpfi_remainder_2(ret1,l1,m); mpfi_remainder_2(ret2,l2,m); + ret_val = mpfi_union(r,ret1,ret2); + mpfi_clears(ret1, ret2, l1,l2,(mpfi_ptr)0); + } else { + int test; + mpfr_t yd; + mpfr_inits2(precision_bits, yd, (mpfr_ptr) 0); + test=mpfi_diam(yd, m); + if(test==0 && mpfr_zero_p(yd)>0){ + /*return mod1([a,b], m)*/ + mpfr_t m2; + mpfr_inits2(precision_bits, m2,(mpfr_ptr) 0); + mpfi_get_fr(m2, m); + ret_val = mpfi_remainder_1(r,x,m2); + mpfr_clears(m2, (mpfi_ptr)0); + } else if (mpfr_sgn(n1)<=0) { + /*return mod2([a,b], [-n,-m]) */ + mpfi_neg(m, m); + ret_val = mpfi_remainder_2(r,x,m); + } else if(mpfr_sgn(m1)<=0) { + /* return mod2([a,b], [1, max(-m,n)]) */ + mpfr_t r1; + mpfi_t l1; + mpfi_inits2(precision_bits, l1, (mpfi_ptr) 0); + mpfr_inits2(precision_bits, r1, (mpfr_ptr) 0); + mpfr_neg(m1,m1,MPFR_RNDN); + /*mpfr_max (r1, m1, n1, MPFR_RNDN);*/ + if(mpfr_greater_p(m1,n1)){ + mpfr_set(r1,m1,MPFR_RNDN); + } else { + mpfr_set(r1,n1,MPFR_RNDN); + } + mpfi_interv_fr(l1, one, r1); + ret_val = mpfi_remainder_2(r,x,l1); + mpfr_clears(r1, (mpfr_ptr)0); + mpfi_clears(l1, (mpfi_ptr)0); + } else { + mpfr_t d; + mpfr_inits2(precision_bits, d, (mpfr_ptr) 0); + mpfr_sub(d, b, a, MPFR_RNDN); + if(mpfr_greaterequal_p(d, n1)!=0){ + /*return [0,n-1]*/ + mpfr_sub(n1,n1,one, MPFR_RNDN); + ret_val = mpfi_interv_fr(r, zero, n1); + } else if(mpfr_greaterequal_p(d, m1)!=0){ + /*return [0, b-a-1] u mod2([a,b], [b-a+1,n])*/ + mpfi_t r1,l1,l2; + mpfi_inits2(precision_bits, l1, l2,(mpfi_ptr) 0); + mpfr_sub(d, d, one, MPFR_RNDN); + mpfi_interv_fr(l1, zero, d);/* [0, b-a-1] */ + mpfi_interv_fr(l2, d, n1);/* [b-a+1,n] */ + mpfi_remainder_2(r1,x,l2);/* mod2([a,b], [b-a+1,n])*/ + ret_val = mpfi_union(r,l1,r1); /* [0, b-a-1] u mod2([a,b], [b-a+1,n])*/ + mpfi_clears(r1, l1, l2, (mpfi_ptr)0); + } else if(mpfr_greater_p(m1,b)!=0){ + /* return [a,b]*/ + ret_val = mpfi_set(r,x); + } else if (mpfr_greater_p(n1,b)!=0) { + /*return [0,b]*/ + mpfi_t l1; + mpfi_inits2(precision_bits, l1,(mpfi_ptr) 0); + mpfi_interv_fr(l1, zero, b); + ret_val = mpfi_set(r,l1); + mpfi_clears(l1, (mpfi_ptr)0); + } else { + /*return [0,n-1] // imprecise */ + mpfi_t l1; + mpfi_inits2(precision_bits, l1,(mpfi_ptr) 0); + mpfr_sub(n1, n1, one, MPFR_RNDN); + mpfi_interv_fr(l1, zero, n1); + ret_val = mpfi_set(r,l1); + mpfi_clears(l1, (mpfi_ptr)0); + } + mpfr_clears(d, (mpfr_ptr)0); + } + } + mpfr_clears(one,zero,(mpfr_ptr)0); + } + return ret_val; +} + + +@ And these are the ones that {\it are} used elsewhere + +@<Internal library declarations@>= +void * mp_initialize_interval_math (MP mp); + +@ + +@d unity 1 +@d two 2 +@d three 3 +@d four 4 +@d half_unit 0.5 +@d three_quarter_unit 0.75 +@d coef_bound ((7.0/3.0)*fraction_multiplier) /* |fraction| approximation to 7/3 */ +@d fraction_threshold 0.04096 /* a |fraction| coefficient less than this is zeroed */ +@d half_fraction_threshold (fraction_threshold/2) /* half of |fraction_threshold| */ +@d scaled_threshold 0.000122 /* a |scaled| coefficient less than this is zeroed */ +@d half_scaled_threshold (scaled_threshold/2) /* half of |scaled_threshold| */ +@d near_zero_angle (0.0256*angle_multiplier) /* an angle of about 0.0256 */ +@d p_over_v_threshold 0x80000 /* TODO */ +@d equation_threshold 0.001 +@d tfm_warn_threshold 0.0625 +@d warning_limit pow(2.0,52.0) /* this is a large value that can just be expressed without loss of precision */ +@d epsilon pow(2.0,-173.0) /* almost "1E-52" */ +@d epsilonf pow(2.0,-52.0) +@d EL_GORDO "1E1000000" /* the largest value that \MP\ likes. */ +@d one_third_EL_GORDO (EL_GORDO/3.0) + +@<Declarations@>= +static mpfi_t zero; +static mpfi_t one; +static mpfi_t minusone; +static mpfi_t two_mpfi_t; +static mpfi_t three_mpfi_t; +static mpfi_t four_mpfi_t; +static mpfi_t fraction_multiplier_mpfi_t; +static mpfi_t angle_multiplier_mpfi_t; +static mpfi_t fraction_one_mpfi_t; +static mpfi_t fraction_one_plus_mpfi_t; +static mpfi_t PI_mpfi_t; +static mpfi_t epsilon_mpfi_t; +static mpfi_t EL_GORDO_mpfi_t; +static boolean initialized = false; + + +@ @c +void init_interval_constants (void) { + if (!initialized) { + mpfi_inits2 (precision_bits, one, minusone, zero, two_mpfi_t, three_mpfi_t, four_mpfi_t, fraction_multiplier_mpfi_t, + fraction_one_mpfi_t, fraction_one_plus_mpfi_t, angle_multiplier_mpfi_t, PI_mpfi_t, + epsilon_mpfi_t, EL_GORDO_mpfi_t, (mpfi_ptr) 0); + mpfi_set_si (one, 1); + mpfi_set_si (minusone, -1); + mpfi_set_si (zero, 0); + mpfi_set_si (two_mpfi_t, two); + mpfi_set_si (three_mpfi_t, three); + mpfi_set_si (four_mpfi_t, four); + mpfi_set_si (fraction_multiplier_mpfi_t, fraction_multiplier); + mpfi_set_si (fraction_one_mpfi_t, fraction_one); + mpfi_set_si (fraction_one_plus_mpfi_t, (fraction_one+1)); + mpfi_set_si (angle_multiplier_mpfi_t, angle_multiplier); + mpfi_set_str (PI_mpfi_t, PI_STRING, 10); + mpfi_set_d(epsilon_mpfi_t, epsilon ); + mpfi_set_str (EL_GORDO_mpfi_t, EL_GORDO, 10); //); + initialized = true; + } +} +void free_interval_constants (void) { + /* For sake of speed, we accept this memory leak. */ + /*mpfi_clears (one, minusone, zero, two_mpfi_t, three_mpfi_t, four_mpfi_t, fraction_multiplier_mpfi_t,*/ + /* fraction_one_mpfi_t, fraction_one_plus_mpfi_t, angle_multiplier_mpfi_t, PI_mpfi_t, */ + /* epsilon_mpfi_t, EL_GORDO_mpfi_t, (mpfi_ptr) 0); */ + /*mpfi_free_cache ();*/ +} + +@ |precision_max| is limited to 1000, because the precision of already initialized +|mpfi_t| numbers cannot be raised, only lowered. The value of 1000.0 is a tradeoff +between precision and allocation size / processing speed. + +@d MAX_PRECISION 1000.0 +@d DEF_PRECISION 34.0 + +@c +void * mp_initialize_interval_math (MP mp) { + math_data *math = (math_data *)mp_xmalloc(mp,1,sizeof(math_data)); + precision_bits = precision_digits_to_bits(MAX_PRECISION); + init_interval_constants(); + /* alloc */ + math->allocate = mp_new_number; + math->free = mp_free_number; + mp_new_number (mp, &math->precision_default, mp_scaled_type); + mpfi_set_d(math->precision_default.data.num, DEF_PRECISION); + mp_new_number (mp, &math->precision_max, mp_scaled_type); + mpfi_set_d(math->precision_max.data.num, MAX_PRECISION); + mp_new_number (mp, &math->precision_min, mp_scaled_type); + /* really should be |precision_bits_to_digits(MPFI_PREC_MIN)| but that produces a horrible number */ + mpfi_set_d(math->precision_min.data.num, 2.0 ); + /* here are the constants for |scaled| objects */ + mp_new_number (mp, &math->epsilon_t, mp_scaled_type); + mpfi_set (math->epsilon_t.data.num, epsilon_mpfi_t); + mp_new_number (mp, &math->inf_t, mp_scaled_type); + mpfi_set (math->inf_t.data.num, EL_GORDO_mpfi_t); + mp_new_number (mp, &math->warning_limit_t, mp_scaled_type); + mpfi_set_d (math->warning_limit_t.data.num, warning_limit); + mp_new_number (mp, &math->one_third_inf_t, mp_scaled_type); + mpfi_div (math->one_third_inf_t.data.num, math->inf_t.data.num, three_mpfi_t); + mp_new_number (mp, &math->unity_t, mp_scaled_type); + mpfi_set (math->unity_t.data.num, one); + mp_new_number (mp, &math->two_t, mp_scaled_type); + mpfi_set_si(math->two_t.data.num, two); + mp_new_number (mp, &math->three_t, mp_scaled_type); + mpfi_set_si(math->three_t.data.num, three); + mp_new_number (mp, &math->half_unit_t, mp_scaled_type); + mpfi_set_d(math->half_unit_t.data.num, half_unit); + mp_new_number (mp, &math->three_quarter_unit_t, mp_scaled_type); + mpfi_set_d (math->three_quarter_unit_t.data.num, three_quarter_unit); + mp_new_number (mp, &math->zero_t, mp_scaled_type); + /*mpfi_set_zero (math->zero_t.data.num, 1);*/ + mpfi_set_d (math->zero_t.data.num, 0.0); + /* |fractions| */ + mp_new_number (mp, &math->arc_tol_k, mp_fraction_type); + { + mpfi_div_si (math->arc_tol_k.data.num, one, 4096); + /* quit when change in arc length estimate reaches this */ + } + mp_new_number (mp, &math->fraction_one_t, mp_fraction_type); + mpfi_set_si(math->fraction_one_t.data.num, fraction_one); + mp_new_number (mp, &math->fraction_half_t, mp_fraction_type); + mpfi_set_si(math->fraction_half_t.data.num, fraction_half); + mp_new_number (mp, &math->fraction_three_t, mp_fraction_type); + mpfi_set_si(math->fraction_three_t.data.num, fraction_three); + mp_new_number (mp, &math->fraction_four_t, mp_fraction_type); + mpfi_set_si(math->fraction_four_t.data.num, fraction_four); + /* |angles| */ + mp_new_number (mp, &math->three_sixty_deg_t, mp_angle_type); + mpfi_set_si(math->three_sixty_deg_t.data.num, 360 * angle_multiplier); + mp_new_number (mp, &math->one_eighty_deg_t, mp_angle_type); + mpfi_set_si(math->one_eighty_deg_t.data.num, 180 * angle_multiplier); + /* various approximations */ + mp_new_number (mp, &math->one_k, mp_scaled_type); + mpfi_set_d(math->one_k.data.num, 1.0/64); + mp_new_number (mp, &math->sqrt_8_e_k, mp_scaled_type); + { + mpfi_set_d(math->sqrt_8_e_k.data.num, 112428.82793 / 65536.0); + /* $2^{16}\sqrt{8/e}\approx 112428.82793$ */ + } + mp_new_number (mp, &math->twelve_ln_2_k, mp_fraction_type); + { + mpfi_set_d(math->twelve_ln_2_k.data.num, 139548959.6165 / 65536.0); + /* $2^{24}\cdot12\ln2\approx139548959.6165$ */ + } + mp_new_number (mp, &math->coef_bound_k, mp_fraction_type); + mpfi_set_d(math->coef_bound_k.data.num,coef_bound); + mp_new_number (mp, &math->coef_bound_minus_1, mp_fraction_type); + mpfi_set_d(math->coef_bound_minus_1.data.num,coef_bound - 1 / 65536.0); + mp_new_number (mp, &math->twelvebits_3, mp_scaled_type); + { + mpfi_set_d(math->twelvebits_3.data.num, 1365 / 65536.0); + /* $1365\approx 2^{12}/3$ */ + } + mp_new_number (mp, &math->twentysixbits_sqrt2_t, mp_fraction_type); + { + mpfi_set_d(math->twentysixbits_sqrt2_t.data.num, 94906265.62 / 65536.0); + /* $2^{26}\sqrt2\approx94906265.62$ */ + } + mp_new_number (mp, &math->twentyeightbits_d_t, mp_fraction_type); + { + mpfi_set_d(math->twentyeightbits_d_t.data.num, 35596754.69 / 65536.0); + /* $2^{28}d\approx35596754.69$ */ + } + mp_new_number (mp, &math->twentysevenbits_sqrt2_d_t, mp_fraction_type); + { + mpfi_set_d(math->twentysevenbits_sqrt2_d_t.data.num, 25170706.63 / 65536.0); + /* $2^{27}\sqrt2\,d\approx25170706.63$ */ + } + /* thresholds */ + mp_new_number (mp, &math->fraction_threshold_t, mp_fraction_type); + mpfi_set_d(math->fraction_threshold_t.data.num, fraction_threshold); + mp_new_number (mp, &math->half_fraction_threshold_t, mp_fraction_type); + mpfi_set_d(math->half_fraction_threshold_t.data.num, half_fraction_threshold); + mp_new_number (mp, &math->scaled_threshold_t, mp_scaled_type); + mpfi_set_d(math->scaled_threshold_t.data.num, scaled_threshold); + mp_new_number (mp, &math->half_scaled_threshold_t, mp_scaled_type); + mpfi_set_d(math->half_scaled_threshold_t.data.num, half_scaled_threshold); + mp_new_number (mp, &math->near_zero_angle_t, mp_angle_type); + mpfi_set_d(math->near_zero_angle_t.data.num, near_zero_angle); + mp_new_number (mp, &math->p_over_v_threshold_t, mp_fraction_type); + mpfi_set_d(math->p_over_v_threshold_t.data.num, p_over_v_threshold); + mp_new_number (mp, &math->equation_threshold_t, mp_scaled_type); + mpfi_set_d(math->equation_threshold_t.data.num, equation_threshold); + mp_new_number (mp, &math->tfm_warn_threshold_t, mp_scaled_type); + mpfi_set_d(math->tfm_warn_threshold_t.data.num, tfm_warn_threshold); + /* functions */ + math->from_int = mp_set_interval_from_int; + math->from_boolean = mp_set_interval_from_boolean; + math->from_scaled = mp_set_interval_from_scaled; + math->from_double = mp_set_interval_from_double; + math->from_addition = mp_set_interval_from_addition; + math->from_substraction = mp_set_interval_from_substraction; + math->from_oftheway = mp_set_interval_from_of_the_way; + math->from_div = mp_set_interval_from_div; + math->from_mul = mp_set_interval_from_mul; + math->from_int_div = mp_set_interval_from_int_div; + math->from_int_mul = mp_set_interval_from_int_mul; + math->negate = mp_number_negate; + math->add = mp_number_add; + math->substract = mp_number_substract; + math->half = mp_number_half; + math->halfp = mp_number_halfp; + math->do_double = mp_number_double; + math->abs = mp_interval_abs; + math->clone = mp_number_clone; + math->swap = mp_number_swap; + math->add_scaled = mp_number_add_scaled; + math->multiply_int = mp_number_multiply_int; + math->divide_int = mp_number_divide_int; + math->to_boolean = mp_number_to_boolean; + math->to_scaled = mp_number_to_scaled; + math->to_double = mp_number_to_double; + math->to_int = mp_number_to_int; + math->odd = mp_number_odd; + math->equal = mp_number_equal; + math->less = mp_number_less; + math->greater = mp_number_greater; + math->nonequalabs = mp_number_nonequalabs; + math->round_unscaled = mp_round_unscaled; + math->floor_scaled = mp_number_floor; + math->fraction_to_round_scaled = mp_interval_fraction_to_round_scaled; + math->make_scaled = mp_interval_number_make_scaled; + math->make_fraction = mp_interval_number_make_fraction; + math->take_fraction = mp_interval_number_take_fraction; + math->take_scaled = mp_interval_number_take_scaled; + math->velocity = mp_interval_velocity; + math->n_arg = mp_interval_n_arg; + math->m_log = mp_interval_m_log; + math->m_exp = mp_interval_m_exp; + math->m_unif_rand = mp_interval_m_unif_rand; + math->m_norm_rand = mp_interval_m_norm_rand; + math->pyth_add = mp_interval_pyth_add; + math->pyth_sub = mp_interval_pyth_sub; + math->fraction_to_scaled = mp_number_fraction_to_scaled; + math->scaled_to_fraction = mp_number_scaled_to_fraction; + math->scaled_to_angle = mp_number_scaled_to_angle; + math->angle_to_scaled = mp_number_angle_to_scaled; + math->init_randoms = mp_init_randoms; + math->sin_cos = mp_interval_sin_cos; + math->slow_add = mp_interval_slow_add; + math->sqrt = mp_interval_square_rt; + math->print = mp_interval_print_number; + math->tostring = mp_interval_number_tostring; + math->modulo = mp_interval_number_modulo; + math->ab_vs_cd = mp_ab_vs_cd; + math->crossing_point = mp_interval_crossing_point; + math->scan_numeric = mp_interval_scan_numeric_token; + math->scan_fractional = mp_interval_scan_fractional_token; + math->free_math = mp_free_interval_math; + math->set_precision = mp_interval_set_precision; + /* math interval new primitives */ + math->m_get_left_endpoint = mp_interval_m_get_left_endpoint; + math->m_get_right_endpoint = mp_interval_m_get_right_endpoint; + math->m_interval_set = mp_interval_m_interval_set ; + +return (void *)math; +} + +void mp_interval_set_precision (MP mp) { + double d = mpfi_get_d(internal_value (mp_number_precision).data.num); + precision_bits = precision_digits_to_bits(d); +} + +void mp_free_interval_math (MP mp) { + free_number (((math_data *)mp->math)->three_sixty_deg_t); + free_number (((math_data *)mp->math)->one_eighty_deg_t); + free_number (((math_data *)mp->math)->fraction_one_t); + free_number (((math_data *)mp->math)->zero_t); + free_number (((math_data *)mp->math)->half_unit_t); + free_number (((math_data *)mp->math)->three_quarter_unit_t); + free_number (((math_data *)mp->math)->unity_t); + free_number (((math_data *)mp->math)->two_t); + free_number (((math_data *)mp->math)->three_t); + free_number (((math_data *)mp->math)->one_third_inf_t); + free_number (((math_data *)mp->math)->inf_t); + free_number (((math_data *)mp->math)->warning_limit_t); + free_number (((math_data *)mp->math)->one_k); + free_number (((math_data *)mp->math)->sqrt_8_e_k); + free_number (((math_data *)mp->math)->twelve_ln_2_k); + free_number (((math_data *)mp->math)->coef_bound_k); + free_number (((math_data *)mp->math)->coef_bound_minus_1); + free_number (((math_data *)mp->math)->fraction_threshold_t); + free_number (((math_data *)mp->math)->half_fraction_threshold_t); + free_number (((math_data *)mp->math)->scaled_threshold_t); + free_number (((math_data *)mp->math)->half_scaled_threshold_t); + free_number (((math_data *)mp->math)->near_zero_angle_t); + free_number (((math_data *)mp->math)->p_over_v_threshold_t); + free_number (((math_data *)mp->math)->equation_threshold_t); + free_number (((math_data *)mp->math)->tfm_warn_threshold_t); + free_interval_constants(); + free(mp->math); +} + +@ Creating an destroying |mp_number| objects + +@ @c +void mp_new_number (MP mp, mp_number *n, mp_number_type t) { + (void)mp; + n->data.num = mp_xmalloc(mp,1,sizeof(mpfi_t)); + mpfi_init2 ((mpfi_ptr)(n->data.num), precision_bits); + /*mpfi_set_zero((mpfi_ptr)(n->data.num),1); *//* 1 == positive */ + mpfi_set_d((mpfi_ptr)(n->data.num),0.0); + n->type = t; +} + +@ + +@c +void mp_free_number (MP mp, mp_number *n) { + (void)mp; + if (n->data.num) { + mpfi_clear (n->data.num); + n->data.num = NULL; + } + n->type = mp_nan_type; +} + +@ Here are the low-level functions on |mp_number| items, setters first. + +@c +void mp_set_interval_from_int(mp_number *A, int B) { + mpfi_set_si(A->data.num,B); +} +void mp_set_interval_from_boolean(mp_number *A, int B) { + mpfi_set_si(A->data.num,B); +} +void mp_set_interval_from_scaled(mp_number *A, int B) { + mpfi_set_si(A->data.num, B); + mpfi_div_si(A->data.num, A->data.num, 65536); +} +void mp_set_interval_from_double(mp_number *A, double B) { + mpfi_set_d(A->data.num, B); +} +void mp_set_interval_from_addition(mp_number *A, mp_number B, mp_number C) { + mpfi_add(A->data.num,B.data.num,C.data.num); +} +void mp_set_interval_from_substraction (mp_number *A, mp_number B, mp_number C) { + mpfi_sub(A->data.num,B.data.num,C.data.num); +} +void mp_set_interval_from_div(mp_number *A, mp_number B, mp_number C) { + mpfi_div(A->data.num,B.data.num,C.data.num); +} +void mp_set_interval_from_mul(mp_number *A, mp_number B, mp_number C) { + mpfi_mul(A->data.num,B.data.num,C.data.num); +} +void mp_set_interval_from_int_div(mp_number *A, mp_number B, int C) { + mpfi_div_si(A->data.num,B.data.num,C); +} +void mp_set_interval_from_int_mul(mp_number *A, mp_number B, int C) { + mpfi_mul_si(A->data.num,B.data.num, C); +} +void mp_set_interval_from_of_the_way(MP mp, mp_number *A, mp_number t, mp_number B, mp_number C) { + mpfi_t c, r1; + mpfi_init2(c, precision_bits); + mpfi_init2(r1, precision_bits); + mpfi_sub (c,B.data.num, C.data.num); + mp_interval_take_fraction(mp, r1, c, t.data.num); + mpfi_sub (A->data.num, B.data.num, r1); + mpfi_clear(c); + mpfi_clear(r1); + mp_check_mpfi_t(mp, A->data.num); +} +void mp_number_negate(mp_number *A) { + mpfi_t c; + mpfi_init2(c, precision_bits); + mpfi_neg (c, A->data.num); + mpfi_set((mpfi_ptr)A->data.num,c); + mpfi_clear(c); +} +void mp_number_add(mp_number *A, mp_number B) { + mpfi_add (A->data.num,A->data.num,B.data.num); +} +void mp_number_substract(mp_number *A, mp_number B) { + mpfi_sub (A->data.num,A->data.num,B.data.num); +} +void mp_number_half(mp_number *A) { + mpfi_div_si(A->data.num, A->data.num, 2); +} +void mp_number_halfp(mp_number *A) { + mpfi_div_si(A->data.num,A->data.num, 2); +} +void mp_number_double(mp_number *A) { + mpfi_mul_si(A->data.num,A->data.num, 2); +} +void mp_number_add_scaled(mp_number *A, int B) { /* also for negative B */ + mpfi_add_d (A->data.num,A->data.num, B/65536.0); +} +void mp_number_multiply_int(mp_number *A, int B) { + mpfi_mul_si(A->data.num,A->data.num, B); +} +void mp_number_divide_int(mp_number *A, int B) { + mpfi_div_si(A->data.num,A->data.num, B); +} +void mp_interval_abs(mp_number *A) { + mpfi_abs(A->data.num, A->data.num); +} +void mp_number_clone(mp_number *A, mp_number B) { + /*mpfi_prec_round (A->data.num, precision_bits);*/ + mpfi_round_prec (A->data.num, precision_bits); + mpfi_set(A->data.num, (mpfi_ptr)B.data.num); +} +void mp_number_swap(mp_number *A, mp_number *B) { + mpfi_swap(A->data.num, B->data.num); +} +void mp_number_fraction_to_scaled (mp_number *A) { + A->type = mp_scaled_type; + mpfi_div (A->data.num, A->data.num, fraction_multiplier_mpfi_t); +} +void mp_number_angle_to_scaled (mp_number *A) { + A->type = mp_scaled_type; + mpfi_div (A->data.num, A->data.num, angle_multiplier_mpfi_t); +} +void mp_number_scaled_to_fraction (mp_number *A) { + A->type = mp_fraction_type; + mpfi_mul (A->data.num, A->data.num, fraction_multiplier_mpfi_t); +} +void mp_number_scaled_to_angle (mp_number *A) { + A->type = mp_angle_type; + mpfi_mul(A->data.num, A->data.num, angle_multiplier_mpfi_t); +} + + +@* Query functions. + +@ Convert a number to a scaled value. |decNumberToInt32| is not +able to make this conversion properly, so instead we are using +|decNumberToDouble| and a typecast. Bad! + +@c +int mp_number_to_scaled(mp_number A) { + double v = mpfi_get_d (A.data.num); + return (int)(v * 65536.0); +} + +@ + +@d odd(A) (abs(A)%2==1) + +@c +int mp_number_to_int(mp_number A) { + int32_t result = 0; + double temp; +// CHECK if (mpfi_fits_sint_p(A.data.num)) { +// CHECK result = mpfi_get_si(A.data.num); +// CHECK } + if (mpfi_bounded_p(A.data.num)) { + temp = ROUND(mpfi_get_d (A.data.num)); + if( (INT_MIN <= temp) && (temp <= INT_MAX) ) { + result = (int)(temp); + } + } + return result; +} +int mp_number_to_boolean(mp_number A) { + int32_t result = 0; + double temp; +// CHECK if (mpfi_fits_sint_p(A.data.num)) { +// CHECK result = mpfi_get_si(A.data.num); +// CHECK } + if (mpfi_bounded_p(A.data.num)) { + temp = ROUND(mpfi_get_d (A.data.num)); + if( (INT_MIN <= temp) && (temp <= INT_MAX) ) { + result = (int)(temp); + } + } + return result; +} +double mp_number_to_double(mp_number A) { + double res = 0.0; + if (mpfi_bounded_p (A.data.num)) { + res = mpfi_get_d(A.data.num); + } + return res; +} +int mp_number_odd(mp_number A) { + return odd(mp_number_to_int(A)); +} +int mp_number_equal(mp_number A, mp_number B) { +//CHECK return mpfi_equal_p(A.data.num,B.data.num); + mpfr_t lA,rA,lB,rB; + int la,ra,lb, rb; + mpfr_inits2(precision_bits,lA,rA,lB,rB,(mpfr_ptr) 0); + la = mpfi_get_left (lA, A.data.num); + lb = mpfi_get_left (lB, B.data.num); + ra = mpfi_get_right (rA, A.data.num); + rb = mpfi_get_right (rB, B.data.num); + return ( (la==0 && lb==0 && mpfr_equal_p(lA,lB)!=0) && (ra==0 && rb==0 && mpfr_equal_p(rA,rB)!=0) ); +} +int mp_number_greater(mp_number A, mp_number B) { +//CHECK return mpfi_greater_p(A.data.num,B.data.num); + return mpfi_cmp(A.data.num,B.data.num)>0; +} +int mp_number_less(mp_number A, mp_number B) { +//CHECK return mpfi_less_p(A.data.num,B.data.num); + return mpfi_cmp(A.data.num,B.data.num)<0; +} +int mp_number_nonequalabs(mp_number A, mp_number B) { + mpfi_t a,b ; + int temp; + mpfi_abs (a, A.data.num); + mpfi_abs (b, B.data.num); +//CHECK return !(mpfi_cmpabs(A.data.num, B.data.num)==0); + temp = mpfi_cmp(a,b); + return !(temp==0); +} + +@ Fixed-point arithmetic is done on {\sl scaled integers\/} that are multiples +of $2^{-16}$. In other words, a binary point is assumed to be sixteen bit +positions from the right end of a binary computer word. + +@ One of \MP's most common operations is the calculation of +$\lfloor{a+b\over2}\rfloor$, +the midpoint of two given integers |a| and~|b|. The most decent way to do +this is to write `|(a+b)/2|'; but on many machines it is more efficient +to calculate `|(a+b)>>1|'. + +Therefore the midpoint operation will always be denoted by `|half(a+b)|' +in this program. If \MP\ is being implemented with languages that permit +binary shifting, the |half| macro should be changed to make this operation +as efficient as possible. Since some systems have shift operators that can +only be trusted to work on positive numbers, there is also a macro |halfp| +that is used only when the quantity being halved is known to be positive +or zero. + +@ Here is a procedure analogous to |print_int|. The current version +is fairly stupid, and it is not round-trip safe, but this is good +enough for a beta test. + +@c +char * mp_intervalnumber_tostring (mpfi_t n) { +// CHECK +// This function probably should be rewritten +// it's the same as in mpmathbinary +// +// + char *str = NULL, *buffer = NULL; + mpfr_exp_t exp = 0; + int neg = 0; + mpfr_t nn; + mpfr_init2(nn,precision_bits); + mpfi_mid (nn, n); + if ((str = mpfr_get_str (NULL, &exp, 10, 0, nn, MPFR_ROUNDING))>0) { + int numprecdigits = precision_bits_to_digits(precision_bits); + if (*str == '-') { + neg = 1; + } + while (strlen(str)>0 && *(str+strlen(str)-1) == '0' ) { + *(str+strlen(str)-1) = '\0'; /* get rid of trailing zeroes */ + } + buffer = malloc(strlen(str)+13+numprecdigits+1); + /* the buffer should also fit at least strlen("E+\%d", exp) or (numprecdigits-2) worth of zeroes, + * because with numprecdigits == 33, the str for "1E32" will be "1", and needing 32 extra zeroes, + * and the decimal dot. To avoid miscalculations by myself, it is safer to add these + * three together. + */ + if (buffer) { + int i = 0, j = 0; + if (neg) { + buffer[i++] = '-'; + j = 1; + } + if (strlen(str+j) == 0) { + buffer[i++] = '0'; + } else { + /* non-zero */ + if (exp<=numprecdigits && exp > -6) { + if (exp>0) { + buffer[i++] = str[j++]; + while (--exp>0) { + buffer[i++] = (str[j] ? str[j++] : '0'); + } + if (str[j]) { + buffer[i++] = '.'; + while (str[j]) { + buffer[i++] = str[j++]; + } + } + } else { + int absexp; + buffer[i++] = '0'; + buffer[i++] = '.'; + absexp = -exp; + while (absexp-- > 0) { + buffer[i++] = '0'; + } + while (str[j]) { + buffer[i++] = str[j++]; + } + } + } else { + buffer[i++] = str[j++]; + if (str[j]) { + buffer[i++] = '.'; + while (str[j]) { + buffer[i++] = str[j++]; + } + } + { + char msg[256]; + int k = 0; + mp_snprintf (msg, 256, "%s%d", (exp>0?"+":""), (int)(exp>0 ? (exp-1) : (exp-1))); + buffer[i++] = 'E'; + while (msg[k]) { + buffer[i++] = msg[k++]; + } + } + } + } + buffer[i++] = '\0'; + } + mpfr_free_str(str); + } + return buffer; +} +char * mp_interval_number_tostring (MP mp, mp_number n) { + return mp_intervalnumber_tostring(n.data.num); +} + + +@ @c +void mp_interval_print_number (MP mp, mp_number n) { + char *str = mp_interval_number_tostring(mp, n); + mp_print (mp, str); + free (str); +} + + + + +@ Addition is not always checked to make sure that it doesn't overflow, +but in places where overflow isn't too unlikely the |slow_add| routine +is used. + +@c +void mp_interval_slow_add (MP mp, mp_number *ret, mp_number A, mp_number B) { + mpfi_add(ret->data.num,A.data.num,B.data.num); +} + +@ The |make_fraction| routine produces the |fraction| equivalent of +|p/q|, given integers |p| and~|q|; it computes the integer +$f=\lfloor2^{28}p/q+{1\over2}\rfloor$, when $p$ and $q$ are +positive. If |p| and |q| are both of the same scaled type |t|, +the ``type relation'' |make_fraction(t,t)=fraction| is valid; +and it's also possible to use the subroutine ``backwards,'' using +the relation |make_fraction(t,fraction)=t| between scaled types. + +If the result would have magnitude $2^{31}$ or more, |make_fraction| +sets |arith_error:=true|. Most of \MP's internal computations have +been designed to avoid this sort of error. + +If this subroutine were programmed in assembly language on a typical +machine, we could simply compute |(@t$2^{28}$@>*p)div q|, since a +double-precision product can often be input to a fixed-point division +instruction. But when we are restricted to int-eger arithmetic it +is necessary either to resort to multiple-precision maneuvering +or to use a simple but slow iteration. The multiple-precision technique +would be about three times faster than the code adopted here, but it +would be comparatively long and tricky, involving about sixteen +additional multiplications and divisions. + +This operation is part of \MP's ``inner loop''; indeed, it will +consume nearly 10\pct! of the running time (exclusive of input and output) +if the code below is left unchanged. A machine-dependent recoding +will therefore make \MP\ run faster. The present implementation +is highly portable, but slow; it avoids multiplication and division +except in the initial stage. System wizards should be careful to +replace it with a routine that is guaranteed to produce identical +results in all cases. +@^system dependencies@> + +As noted below, a few more routines should also be replaced by machine-dependent +code, for efficiency. But when a procedure is not part of the ``inner loop,'' +such changes aren't advisable; simplicity and robustness are +preferable to trickery, unless the cost is too high. +@^inner loop@> + +@c +void mp_interval_make_fraction (MP mp, mpfi_t ret, mpfi_t p, mpfi_t q) { + mpfi_div (ret, p, q); + mp_check_mpfi_t(mp, ret); + mpfi_mul (ret, ret, fraction_multiplier_mpfi_t); +} +void mp_interval_number_make_fraction (MP mp, mp_number *ret, mp_number p, mp_number q) { + mp_interval_make_fraction (mp, ret->data.num, p.data.num, q.data.num); +} + +@ @<Declarations@>= +void mp_interval_make_fraction (MP mp, mpfi_t ret, mpfi_t p, mpfi_t q); + +@ The dual of |make_fraction| is |take_fraction|, which multiplies a +given integer~|q| by a fraction~|f|. When the operands are positive, it +computes $p=\lfloor qf/2^{28}+{1\over2}\rfloor$, a symmetric function +of |q| and~|f|. + +This routine is even more ``inner loopy'' than |make_fraction|; +the present implementation consumes almost 20\pct! of \MP's computation +time during typical jobs, so a machine-language substitute is advisable. +@^inner loop@> @^system dependencies@> + +@c +void mp_interval_take_fraction (MP mp, mpfi_t ret, mpfi_t p, mpfi_t q) { + mpfi_mul(ret, p, q); + mpfi_div(ret, ret, fraction_multiplier_mpfi_t); +} +void mp_interval_number_take_fraction (MP mp, mp_number *ret, mp_number p, mp_number q) { + mp_interval_take_fraction (mp, ret->data.num, p.data.num, q.data.num); +} + +@ @<Declarations@>= +void mp_interval_take_fraction (MP mp, mpfi_t ret, mpfi_t p, mpfi_t q); + +@ When we want to multiply something by a |scaled| quantity, we use a scheme +analogous to |take_fraction| but with a different scaling. +Given positive operands, |take_scaled| +computes the quantity $p=\lfloor qf/2^{16}+{1\over2}\rfloor$. + +Once again it is a good idea to use a machine-language replacement if +possible; otherwise |take_scaled| will use more than 2\pct! of the running time +when the Computer Modern fonts are being generated. +@^inner loop@> + +@c +void mp_interval_number_take_scaled (MP mp, mp_number *ret, mp_number p_orig, mp_number q_orig) { + mpfi_mul(ret->data.num, p_orig.data.num, q_orig.data.num); +} + + +@ For completeness, there's also |make_scaled|, which computes a +quotient as a |scaled| number instead of as a |fraction|. +In other words, the result is $\lfloor2^{16}p/q+{1\over2}\rfloor$, if the +operands are positive. \ (This procedure is not used especially often, +so it is not part of \MP's inner loop.) + +@c +void mp_interval_number_make_scaled (MP mp, mp_number *ret, mp_number p_orig, mp_number q_orig) { + mpfi_div(ret->data.num, p_orig.data.num, q_orig.data.num); + mp_check_mpfi_t(mp, ret->data.num); +} + +@ +@d halfp(A) (integer)((unsigned)(A) >> 1) + +@* Scanning numbers in the input. + +The definitions below are temporarily here. + +@d set_cur_cmd(A) mp->cur_mod_->type=(A) +@d set_cur_mod(A) mpfi_set((mpfi_ptr)(mp->cur_mod_->data.n.data.num),A) + +@<Declarations...@>= +static void mp_wrapup_numeric_token(MP mp, unsigned char *start, unsigned char *stop); + +@ The check of the precision is based on the article "27 Bits are not enough for 8-Digit accuracy" +@ by Bennet Goldberg which roughly says that +@ given $p$ digits in base 10 and $q$ digits in base 2, +@ conversion from base 10 round-trip through base 2 if and only if $10^p < 2^{q-1}$. +@ In our case $p/\log_{10}2 + 1 < q$, or $q\geq a$ +@ where $q$ is the current precision in bits and $a=\left\lceil p/\log_{10}2 + 1\right\rceil$. +@ Therefore if $a>q$ the required precision could be too high and we emit a warning. +@d too_precise(a) (a>precision_bits) +@c +void mp_wrapup_numeric_token(MP mp, unsigned char *start, unsigned char *stop) { + int invalid = 0; + mpfi_t result; + size_t l = stop-start+1; + unsigned long lp, lpbit; + char *buf = mp_xmalloc(mp, l+1, 1); + char *bufp = buf; + buf[l] = '\0'; + mpfi_init2(result, precision_bits); + (void)strncpy(buf,(const char *)start, l); + invalid = mpfi_set_str(result,buf, 10); + /*|fprintf(stdout,"scan of [%s] produced %s, ", buf, mp_intervalnumber_tostring(result));|*/ + lp = (unsigned long) l; + /* strip leading - or + or 0 or .*/ + if ( (*bufp=='-') || (*bufp=='+') || (*bufp=='0') || (*bufp=='.') ) { lp--; bufp++;} + /* strip also . */ + lp = strchr(bufp,'.') ? lp-1: lp; + /* strip also trailing 0s */ + bufp = buf+l-1; + while(*bufp == '0') {bufp--; lp=( ((lp==0)||(lp==1))?1:lp-1);} + /* at least one digit, even if the number is 0 */ + lp = lp>0? lp: 1; + /* bits needed for buf */ + lpbit = (unsigned long)ceil(lp/log10(2)+1); + free(buf); + bufp = NULL; + if (invalid == 0) { + set_cur_mod(result); + /* |fprintf(stdout,"mod=%s\n", mp_interval_number_tostring(mp,mp->cur_mod_->data.n));|*/ + if (too_precise(lpbit)) { + if (mpfi_positive_p((mpfi_ptr)(internal_value (mp_warning_check).data.num)) && + (mp->scanner_status != tex_flushing)) { + char msg[256]; + const char *hlp[] = {"Continue and I'll try to cope", + "with that value; but it might be dangerous.", + "(Set warningcheck:=0 to suppress this message.)", + NULL }; + mp_snprintf (msg, 256, "Required precision is too high (%d vs. numberprecision = %f, required precision=%d bits vs internal precision=%f bits)", (unsigned int)lp,mpfi_get_d(internal_value (mp_number_precision).data.num),(int)lpbit,precision_bits); +@.Number is too large@>; + mp_error (mp, msg, hlp, true); + } + } + } else if (mp->scanner_status != tex_flushing) { + const char *hlp[] = {"I could not handle this number specification", + "probably because it is out of range. Error:", + "", + NULL }; + hlp[2] = strerror(errno); + mp_error (mp, "Enormous number has been reduced.", hlp, false); +@.Enormous number...@>; + set_cur_mod((mpfi_ptr)(((math_data *)(mp->math))->inf_t.data.num)); + } + set_cur_cmd((mp_variable_type)mp_numeric_token); + mpfi_clear(result); +} + +@ @c +static void find_exponent (MP mp) { + if (mp->buffer[mp->cur_input.loc_field] == 'e' || + mp->buffer[mp->cur_input.loc_field] == 'E') { + mp->cur_input.loc_field++; + if (!(mp->buffer[mp->cur_input.loc_field] == '+' || + mp->buffer[mp->cur_input.loc_field] == '-' || + mp->char_class[mp->buffer[mp->cur_input.loc_field]] == digit_class)) { + mp->cur_input.loc_field--; + return; + } + if (mp->buffer[mp->cur_input.loc_field] == '+' || + mp->buffer[mp->cur_input.loc_field] == '-') { + mp->cur_input.loc_field++; + } + while (mp->char_class[mp->buffer[mp->cur_input.loc_field]] == digit_class) { + mp->cur_input.loc_field++; + } + } +} +void mp_interval_scan_fractional_token (MP mp, int n) { /* n: scaled */ + unsigned char *start = &mp->buffer[mp->cur_input.loc_field -1]; + unsigned char *stop; + while (mp->char_class[mp->buffer[mp->cur_input.loc_field]] == digit_class) { + mp->cur_input.loc_field++; + } + find_exponent(mp); + stop = &mp->buffer[mp->cur_input.loc_field-1]; + mp_wrapup_numeric_token (mp, start, stop); +} + + +@ We just have to collect bytes. + +@c +void mp_interval_scan_numeric_token (MP mp, int n) { /* n: scaled */ + unsigned char *start = &mp->buffer[mp->cur_input.loc_field -1]; + unsigned char *stop; + while (mp->char_class[mp->buffer[mp->cur_input.loc_field]] == digit_class) { + mp->cur_input.loc_field++; + } + if (mp->buffer[mp->cur_input.loc_field] == '.' && + mp->buffer[mp->cur_input.loc_field+1] != '.') { + mp->cur_input.loc_field++; + while (mp->char_class[mp->buffer[mp->cur_input.loc_field]] == digit_class) { + mp->cur_input.loc_field++; + } + } + find_exponent(mp); + stop = &mp->buffer[mp->cur_input.loc_field-1]; + mp_wrapup_numeric_token (mp, start, stop); +} + +@ The |scaled| quantities in \MP\ programs are generally supposed to be +less than $2^{12}$ in absolute value, so \MP\ does much of its internal +arithmetic with 28~significant bits of precision. A |fraction| denotes +a scaled integer whose binary point is assumed to be 28 bit positions +from the right. + +@d fraction_half (fraction_multiplier/2) +@d fraction_one (1*fraction_multiplier) +@d fraction_two (2*fraction_multiplier) +@d fraction_three (3*fraction_multiplier) +@d fraction_four (4*fraction_multiplier) + +@ Here is a typical example of how the routines above can be used. +It computes the function +$${1\over3\tau}f(\theta,\phi)= +{\tau^{-1}\bigl(2+\sqrt2\,(\sin\theta-{1\over16}\sin\phi) + (\sin\phi-{1\over16}\sin\theta)(\cos\theta-\cos\phi)\bigr)\over +3\,\bigl(1+{1\over2}(\sqrt5-1)\cos\theta+{1\over2}(3-\sqrt5\,)\cos\phi\bigr)},$$ +where $\tau$ is a |scaled| ``tension'' parameter. This is \MP's magic +fudge factor for placing the first control point of a curve that starts +at an angle $\theta$ and ends at an angle $\phi$ from the straight path. +(Actually, if the stated quantity exceeds 4, \MP\ reduces it to~4.) + +The trigonometric quantity to be multiplied by $\sqrt2$ is less than $\sqrt2$. +(It's a sum of eight terms whose absolute values can be bounded using +relations such as $\sin\theta\cos\theta\L{1\over2}$.) Thus the numerator +is positive; and since the tension $\tau$ is constrained to be at least +$3\over4$, the numerator is less than $16\over3$. The denominator is +nonnegative and at most~6. + +The angles $\theta$ and $\phi$ are given implicitly in terms of |fraction| +arguments |st|, |ct|, |sf|, and |cf|, representing $\sin\theta$, $\cos\theta$, +$\sin\phi$, and $\cos\phi$, respectively. + +@c +void mp_interval_velocity (MP mp, mp_number *ret, mp_number st, mp_number ct, mp_number sf, + mp_number cf, mp_number t) { + mpfi_t acc, num, denom; /* registers for intermediate calculations */ + mpfi_t r1, r2; + mpfi_t arg1, arg2; + mpfi_t i16, fone, fhalf, ftwo, sqrtfive; + mpfi_inits2 (precision_bits, acc, num, denom, r1, r2, arg1, arg2, i16, fone, fhalf, ftwo, sqrtfive, (mpfi_ptr)0); + mpfi_set_si(i16, 16); + mpfi_set_si(fone, fraction_one); + mpfi_set_si(fhalf, fraction_half); + mpfi_set_si(ftwo, fraction_two); + mpfi_set_si(sqrtfive, 5); + mpfi_sqrt (sqrtfive, sqrtfive); + mpfi_div (arg1,sf.data.num, i16); // arg1 = sf / 16 + mpfi_sub (arg1,st.data.num, arg1); // arg1 = st - arg1 + mpfi_div (arg2,st.data.num, i16); // arg2 = st / 16 + mpfi_sub (arg2,sf.data.num, arg2); // arg2 = sf - arg2 + mp_interval_take_fraction (mp, acc, arg1, arg2); // acc = (arg1 * arg2) / fmul + + mpfi_set (arg1, acc); + mpfi_sub (arg2, ct.data.num, cf.data.num); // arg2 = ct - cf + mp_interval_take_fraction (mp, acc, arg1, arg2); // acc = (arg1 * arg2 ) / fmul + + mpfi_sqrt(arg1, two_mpfi_t); // arg1 = sqrt(2) + mpfi_mul(arg1, arg1, fone); // arg1 = arg1 * fmul + mp_interval_take_fraction (mp, r1, acc, arg1); // r1 = (acc * arg1) / fmul + mpfi_add(num, ftwo, r1); // num = ftwo + r1 + + mpfi_sub(arg1,sqrtfive, one); // arg1 = sqrt(5) - 1 + mpfi_mul(arg1,arg1,fhalf); // arg1 = arg1 * fmul/2 + mpfi_mul(arg1,arg1,three_mpfi_t); // arg1 = arg1 * 3 + + mpfi_sub(arg2,three_mpfi_t, sqrtfive); // arg2 = 3 - sqrt(5) + mpfi_mul(arg2,arg2,fhalf); // arg2 = arg2 * fmul/2 + mpfi_mul(arg2,arg2,three_mpfi_t); // arg2 = arg2 * 3 + mp_interval_take_fraction (mp, r1, ct.data.num, arg1) ; // r1 = (ct * arg1) / fmul + mp_interval_take_fraction (mp, r2, cf.data.num, arg2); // r2 = (cf * arg2) / fmul + + mpfi_set_si(denom, fraction_three); // denom = 3fmul + mpfi_add(denom, denom, r1); // denom = denom + r1 + mpfi_add(denom, denom, r2); // denom = denom + r2 + +//CHECK if (!mpfi_equal_p(t.data.num, one)) { // t != 1 + if (mpfi_cmp(t.data.num, one)!=0) { // t != 1 + mpfi_div(num, num, t.data.num); // num = num / t + } + mpfi_set(r2, num); // r2 = num / 4 + mpfi_div(r2, r2, four_mpfi_t); +// CHECK if (mpfi_less_p(denom,r2)) { // num/4 >= denom => denom < num/4 + if (mpfi_cmp(denom,r2)<0) { // num/4 >= denom => denom < num/4 + mpfi_set_si(ret->data.num,fraction_four); + } else { + mp_interval_make_fraction (mp, ret->data.num, num, denom); + } + mpfi_clears (acc, num, denom, r1, r2, arg1, arg2, i16, fone, fhalf, ftwo, sqrtfive, (mpfi_ptr)0); + mp_check_mpfi_t(mp, ret->data.num); +} + + +@ The following somewhat different subroutine tests rigorously if $ab$ is +greater than, equal to, or less than~$cd$, +given integers $(a,b,c,d)$. In most cases a quick decision is reached. +The result is $+1$, 0, or~$-1$ in the three respective cases. + +@c +void mp_ab_vs_cd (MP mp, mp_number *ret, mp_number a_orig, mp_number b_orig, mp_number c_orig, mp_number d_orig) { + mpfi_t q, r, test; /* temporary registers */ + mpfi_t a, b, c, d; + int cmp = 0; + (void)mp; + mpfi_inits2(precision_bits, q,r,test,a,b,c,d,(mpfi_ptr)0); + mpfi_set(a, (mpfi_ptr)a_orig.data.num); + mpfi_set(b, (mpfi_ptr )b_orig.data.num); + mpfi_set(c, (mpfi_ptr )c_orig.data.num); + mpfi_set(d, (mpfi_ptr )d_orig.data.num); + + mpfi_mul(q,a,b); + mpfi_mul(r,c,d); + cmp = mpfi_cmp(q,r); + if (cmp==0) { + mpfi_set(ret->data.num, zero); + goto RETURN; + } + if (cmp>0) { + mpfi_set(ret->data.num, one); + goto RETURN; + } + if (cmp<0) { + mpfi_set(ret->data.num, minusone); + goto RETURN; + } + + /*TODO: remove this part of the code until RETURN */ + @<Reduce to the case that |a,c>=0|, |b,d>0|@>; + while (1) { + mpfi_div(q,a,d); + mpfi_div(r,c,b); + cmp = mpfi_cmp(q,r); + if (cmp) { + if (cmp>1) { + mpfi_set(ret->data.num, one); + } else { + mpfi_set(ret->data.num, minusone); + } + goto RETURN; + } + mpfi_remainder(q,a,d); + mpfi_remainder(r,c,b); + if (mpfi_zero_p(r)) { + if (mpfi_zero_p(q)) { + mpfi_set(ret->data.num, zero); + } else { + mpfi_set(ret->data.num, one); + } + goto RETURN; + } + if (mpfi_zero_p(q)) { + mpfi_set(ret->data.num, minusone); + goto RETURN; + } + mpfi_set(a,b); + mpfi_set(b,q); + mpfi_set(c,d); + mpfi_set(d,r); + } /* now |a>d>0| and |c>b>0| */ +RETURN: +#if DEBUG + fprintf(stdout, "\n%f = ab_vs_cd(%f,%f,%f,%f)", mp_number_to_double(*ret), +mp_number_to_double(a_orig),mp_number_to_double(b_orig), +mp_number_to_double(c_orig),mp_number_to_double(d_orig)); +#endif + mp_check_mpfi_t(mp, ret->data.num); + mpfi_clears(q,r,test,a,b,c,d,(mpfi_ptr)0); + return; +} + + +@ @<Reduce to the case that |a...@>= +if (mpfi_negative_p(a)) { + mpfi_neg(a, a); + mpfi_neg(b, b); +} +if (mpfi_negative_p(c)) { + mpfi_neg(c, c); + mpfi_neg(d, d); +} +if (!mpfi_positive_p(d)) { + if (!mpfi_negative_p(b)) { + if ((mpfi_zero_p(a) || mpfi_zero_p(b)) && (mpfi_zero_p(c) || mpfi_zero_p(d))) + mpfi_set(ret->data.num, zero); + else + mpfi_set(ret->data.num, one); + goto RETURN; + } + if (mpfi_zero_p(d)) { + if (mpfi_zero_p(a)) + mpfi_set(ret->data.num, zero); + else + mpfi_set(ret->data.num, minusone); + goto RETURN; + } + mpfi_set(q, a); + mpfi_set(a, c); + mpfi_set(c, q); + mpfi_neg(q, b); + mpfi_neg(b, d); + mpfi_set(d, q); +} else if (!mpfi_positive_p(b)) { + if (mpfi_negative_p(b) && mpfi_positive_p(a)) { + mpfi_set(ret->data.num, minusone); + goto RETURN; + } + if (mpfi_zero_p(c)) + mpfi_set(ret->data.num, zero); + else + mpfi_set(ret->data.num, minusone); + goto RETURN; +} + +@ Now here's a subroutine that's handy for all sorts of path computations: +Given a quadratic polynomial $B(a,b,c;t)$, the |crossing_point| function +returns the unique |fraction| value |t| between 0 and~1 at which +$B(a,b,c;t)$ changes from positive to negative, or returns +|t=fraction_one+1| if no such value exists. If |a<0| (so that $B(a,b,c;t)$ +is already negative at |t=0|), |crossing_point| returns the value zero. + +The general bisection method is quite simple when $n=2$, hence +|crossing_point| does not take much time. At each stage in the +recursion we have a subinterval defined by |l| and~|j| such that +$B(a,b,c;2^{-l}(j+t))=B(x_0,x_1,x_2;t)$, and we want to ``zero in'' on +the subinterval where $x_0\G0$ and $\min(x_1,x_2)<0$. + +It is convenient for purposes of calculation to combine the values +of |l| and~|j| in a single variable $d=2^l+j$, because the operation +of bisection then corresponds simply to doubling $d$ and possibly +adding~1. Furthermore it proves to be convenient to modify +our previous conventions for bisection slightly, maintaining the +variables $X_0=2^lx_0$, $X_1=2^l(x_0-x_1)$, and $X_2=2^l(x_1-x_2)$. +With these variables the conditions $x_0\ge0$ and $\min(x_1,x_2)<0$ are +equivalent to $\max(X_1,X_1+X_2)>X_0\ge0$. + +The following code maintains the invariant relations +$0\L|x0|<\max(|x1|,|x1|+|x2|)$, +$\vert|x1|\vert<2^{30}$, $\vert|x2|\vert<2^{30}$; +it has been constructed in such a way that no arithmetic overflow +will occur if the inputs satisfy +$a<2^{30}$, $\vert a-b\vert<2^{30}$, and $\vert b-c\vert<2^{30}$. + +@d no_crossing { mpfi_set(ret->data.num, fraction_one_plus_mpfi_t); goto RETURN; } +@d one_crossing { mpfi_set(ret->data.num, fraction_one_mpfi_t); goto RETURN; } +@d zero_crossing { mpfi_set(ret->data.num, zero); goto RETURN; } + +@c +static void mp_interval_crossing_point (MP mp, mp_number *ret, mp_number aa, mp_number bb, mp_number cc) { + mpfi_t a,b,c; + double d; /* recursive counter */ + mpfi_t x, xx, x0, x1, x2; /* temporary registers for bisection */ + mpfi_t scratch; + mpfi_inits2 (precision_bits, a,b,c, x,xx,x0,x1,x2, scratch,(mpfi_ptr)0); + mpfi_set(a, (mpfi_ptr )aa.data.num); + mpfi_set(b, (mpfi_ptr )bb.data.num); + mpfi_set(c, (mpfi_ptr )cc.data.num); + if (mpfi_negative_p(a)) + zero_crossing; + if (!mpfi_negative_p(c)) { + if (!mpfi_negative_p(b)) { + if (mpfi_positive_p(c)) { + no_crossing; + } else if (mpfi_zero_p(a) && mpfi_zero_p(b)) { + no_crossing; + } else { + one_crossing; + } + } + if (mpfi_zero_p(a)) + zero_crossing; + } else if (mpfi_zero_p(a)) { + if (!mpfi_positive_p(b)) + zero_crossing; + } + + /* Use bisection to find the crossing point... */ + d = epsilonf; + mpfi_set(x0, a); + mpfi_sub(x1,a, b); + mpfi_sub(x2,b, c); + do { + /* not sure why the error correction has to be >= 1E-12 */ + mpfi_add(x, x1, x2); + mpfi_div(x, x, two_mpfi_t); + mpfi_add_d (x, x, 1E-12); + mpfi_sub(scratch, x1, x0); +// CHECK if (mpfi_greater_p(scratch, x0)) { + if (mpfi_cmp(scratch, x0)>0) { + mpfi_set(x2, x); + mpfi_add(x0, x0, x0); + d += d; + } else { + mpfi_add(xx, scratch, x); +// CHECK if (mpfi_greater_p(xx,x0)) { + if (mpfi_cmp(xx,x0)>0) { + mpfi_set(x2,x); + mpfi_add(x0, x0, x0); + d += d; + } else { + mpfi_sub(x0, x0, xx); +// CHECK if (!mpfi_greater_p(x,x0)) { + if (!(mpfi_cmp(x,x0)>0)) { + mpfi_add(scratch, x, x2); +// CHECK if (!mpfi_greater_p(scratch, x0)) + if (!(mpfi_cmp(scratch, x0)>0)) + no_crossing; + } + mpfi_set(x1,x); + d = d + d + epsilonf; + } + } + } while (d < fraction_one); + mpfi_set_d(scratch, d); + mpfi_sub(ret->data.num,scratch, fraction_one_mpfi_t); +RETURN: +#if DEBUG + fprintf(stdout, "\n%f = crossing_point(%f,%f,%f)", mp_number_to_double(*ret), +mp_number_to_double(aa),mp_number_to_double(bb),mp_number_to_double(cc)); +#endif + mpfi_clears (a,b,c, x,xx,x0,x1,x2, scratch, (mpfi_ptr)0); + mp_check_mpfi_t(mp, ret->data.num); + return; +} + + +@ We conclude this set of elementary routines with some simple rounding +and truncation operations. + + +@ |round_unscaled| rounds a |scaled| and converts it to |int| +@c +int mp_round_unscaled(mp_number x_orig) { + double xx = mp_number_to_double(x_orig); + int x = (int)ROUND(xx); + return x; +} + +@ |number_floor| floors a number + +@c +void mp_number_floor (mp_number *i) { +//CHECK mpfi_rint_floor(i->data.num, i->data.num, MPFR_RNDD); + mpfr_t le,re; + mpfr_inits2(precision_bits, le, re, (mpfr_ptr)0 ); + mpfi_get_left (le, i->data.num); mpfi_get_right(re, i->data.num); + mpfr_rint_floor(le, le, MPFR_RNDD); mpfr_rint_floor(re, re, MPFR_RNDD); + mpfi_interv_fr(i->data.num, le, re); + mpfr_clears(le, re, (mpfr_ptr)0); +} + +@ |fraction_to_scaled| rounds a |fraction| and converts it to |scaled| +@c +void mp_interval_fraction_to_round_scaled (mp_number *x_orig) { + x_orig->type = mp_scaled_type; + mpfi_div(x_orig->data.num, x_orig->data.num, fraction_multiplier_mpfi_t); +} + + + +@* Algebraic and transcendental functions. +\MP\ computes all of the necessary special functions from scratch, without +relying on |real| arithmetic or system subroutines for sines, cosines, etc. + +@ + +@c +void mp_interval_square_rt (MP mp, mp_number *ret, mp_number x_orig) { /* return, x: scaled */ + if (!mpfi_nonnegative_p((mpfi_ptr)x_orig.data.num)) { + @<Handle square root of zero or negative argument@>; + } else { + mpfi_sqrt(ret->data.num, x_orig.data.num); + } + mp_check_mpfi_t(mp, ret->data.num); +} + + +@ @<Handle square root of zero...@>= +{ + if (mpfi_negative_p((mpfi_ptr)x_orig.data.num)) { + char msg[256]; + const char *hlp[] = { + "Since I don't take square roots of negative numbers,", + "I'm zeroing this one. Proceed, with fingers crossed.", + NULL }; + char *xstr = mp_interval_number_tostring (mp, x_orig); + mp_snprintf(msg, 256, "Square root of %s has been replaced by 0", xstr); + free(xstr); +@.Square root...replaced by 0@>; + mp_error (mp, msg, hlp, true); + } else if ( mpfi_overlaps_zero_p((mpfi_ptr)x_orig.data.num)) { + char msg[256]; + const char *hlp[] = { + "Since I don't take square roots of intervals that contains negative and positive numbers,", + "I'm zeroing this one. Proceed, with fingers crossed.", + NULL }; + char *xstr = mp_interval_number_tostring (mp, x_orig); + mp_snprintf(msg, 256, "Square root of interval [a,b] with a<0 and b>0 that contains %s has been replaced by 0", xstr); + free(xstr); + mp_error (mp, msg, hlp, true); + } + /*mpfi_set_zero(ret->data.num,1); *//* 1 == positive */ + mpfi_set_d(ret->data.num,0.0); + return; +} + + +@ Pythagorean addition $\psqrt{a^2+b^2}$ is implemented by a quick hack + +@c +void mp_interval_pyth_add (MP mp, mp_number *ret, mp_number a_orig, mp_number b_orig) { + mpfi_t a, b, asq, bsq; + mpfi_inits2(precision_bits, a,b, asq, bsq, (mpfi_ptr)0); + mpfi_set(a, (mpfi_ptr)a_orig.data.num); + mpfi_set(b, (mpfi_ptr)b_orig.data.num); + /* mpfi_mul(asq, a, a); */ + /* mpfi_mul(bsq, b, b); */ + mpfi_sqr(asq, a); + mpfi_sqr(bsq, b); + mpfi_add(a, asq, bsq); + mpfi_sqrt(ret->data.num, a); + mp_check_mpfi_t(mp, ret->data.num); + mpfi_clears(a,b, asq, bsq, (mpfi_ptr)0); +} + +@ Here is a similar algorithm for $\psqrt{a^2-b^2}$. Same quick hack, also. + +@c +void mp_interval_pyth_sub (MP mp, mp_number *ret, mp_number a_orig, mp_number b_orig) { + mpfi_t a, b, asq, bsq; + mpfi_inits2(precision_bits, a,b, asq, bsq, (mpfi_ptr)0); + mpfi_set(a, (mpfi_ptr)a_orig.data.num); + mpfi_set(b, (mpfi_ptr)b_orig.data.num); +// CHECK if (!mpfi_greater_p(a,b)) { + if (!(mpfi_cmp(a,b)>0)) { + @<Handle erroneous |pyth_sub| and set |a:=0|@>; + } else { + /* mpfi_mul(asq, a, a); */ + /* mpfi_mul(bsq, b, b); */ + mpfi_sqr(asq, a); + mpfi_sqr(bsq, b); + mpfi_sub(a, asq, bsq); + mpfi_sqrt(a, a); + } + mpfi_set(ret->data.num, a); + mp_check_mpfi_t(mp, ret->data.num); +} + + +@ @<Handle erroneous |pyth_sub| and set |a:=0|@>= +{ +//CHECK if (mpfi_less_p(a, b)) { + if (mpfi_cmp(a, b)<0) { + char msg[256]; + const char *hlp[] = { + "Since I don't take square roots of negative numbers,", + "I'm zeroing this one. Proceed, with fingers crossed.", + NULL }; + char *astr = mp_interval_number_tostring (mp, a_orig); + char *bstr = mp_interval_number_tostring (mp, b_orig); + mp_snprintf (msg, 256, "Pythagorean subtraction %s+-+%s has been replaced by 0", astr, bstr); + free(astr); + free(bstr); +@.Pythagorean...@>; + mp_error (mp, msg, hlp, true); + } + /*mpfi_set_zero(a,1); */ /* 1 == positive */ + mpfi_set_d(a,0.0); +} + + +@ A new primitive to set an |interval| quantity: + +@c +void mp_interval_m_interval_set(MP mp, mp_number *ret, mp_number a, mp_number b) { + mpfi_t ret_val; + mpfi_init2(ret_val,precision_bits); + mpfi_interv_fr(ret_val, a.data.num, b.data.num); + mpfi_set(ret->data.num,ret_val); + mpfi_clear(ret_val); +} + + + +@ and two new primitives to retrive the left and right endpoint of an |interval| quantity|: + +@c +void mp_interval_m_get_left_endpoint (MP mp, mp_number *ret, mp_number x_orig) { + mpfr_t ret_val; + mpfr_init2(ret_val,precision_bits); + mpfi_get_left(ret_val, x_orig.data.num); + mpfi_set_fr(ret->data.num,ret_val); + mpfr_clear(ret_val); +} + +void mp_interval_m_get_right_endpoint (MP mp, mp_number *ret, mp_number x_orig) { + mpfr_t ret_val; + mpfr_init2(ret_val,precision_bits); + mpfi_get_right(ret_val, x_orig.data.num); + mpfi_set_fr(ret->data.num,ret_val); + mpfr_clear(ret_val); +} + + +@ Here is the routine that calculates $2^8$ times the natural logarithm +of a |scaled| quantity; + +@c +void mp_interval_m_log (MP mp, mp_number *ret, mp_number x_orig) { + if (!mpfi_positive_p((mpfi_ptr)x_orig.data.num)) { + @<Handle non-positive logarithm@>; + } else { + mpfi_log(ret->data.num, x_orig.data.num); + mp_check_mpfi_t(mp, ret->data.num); + mpfi_mul_si(ret->data.num, ret->data.num, 256); + } + mp_check_mpfi_t(mp, ret->data.num); +} + +@ @<Handle non-positive logarithm@>= +{ + char msg[256]; + const char *hlp[] = { + "Since I don't take logs of non-positive numbers,", + "I'm zeroing this one. Proceed, with fingers crossed.", + NULL }; + char *xstr = mp_interval_number_tostring (mp, x_orig); + mp_snprintf (msg, 256, "Logarithm of %s has been replaced by 0", xstr); + free (xstr); +@.Logarithm...replaced by 0@>; + mp_error (mp, msg, hlp, true); + /*mpfi_set_zero(ret->data.num,1); *//* 1 == positive */ + mpfi_set_d(ret->data.num,0.0); +} + + +@ Conversely, the exponential routine calculates $\exp(x/2^8)$, +when |x| is |scaled|. + +@c +void mp_interval_m_exp (MP mp, mp_number *ret, mp_number x_orig) { + mpfi_t temp; + mpfi_init2(temp, precision_bits); + mpfi_div_si(temp, x_orig.data.num, 256); + mpfi_exp(ret->data.num, temp); + mp_check_mpfi_t(mp, ret->data.num); + mpfi_clear (temp); +} + + +@ Given integers |x| and |y|, not both zero, the |n_arg| function +returns the |angle| whose tangent points in the direction $(x,y)$. + +@c +void mp_interval_n_arg (MP mp, mp_number *ret, mp_number x_orig, mp_number y_orig) { + if (mpfi_zero_p((mpfi_ptr )x_orig.data.num) && mpfi_zero_p((mpfi_ptr )y_orig.data.num)) { + @<Handle undefined arg@>; + } else { + mpfi_t atan2val, oneeighty_angle; + mpfi_init2(atan2val, precision_bits); + mpfi_init2(oneeighty_angle, precision_bits); + ret->type = mp_angle_type; + mpfi_set_si(oneeighty_angle, 180 * angle_multiplier); + mpfi_div(oneeighty_angle, oneeighty_angle, PI_mpfi_t); + checkZero((mpfi_ptr)y_orig.data.num); + checkZero((mpfi_ptr)x_orig.data.num); + mpfi_atan2(atan2val, y_orig.data.num, x_orig.data.num); + mpfi_mul(ret->data.num, atan2val, oneeighty_angle); + checkZero((mpfi_ptr)ret->data.num); + mpfi_clear(atan2val); + mpfi_clear(oneeighty_angle); + } + mp_check_mpfi_t(mp, ret->data.num); +} + + +@ @<Handle undefined arg@>= +{ + const char *hlp[] = { + "The `angle' between two identical points is undefined.", + "I'm zeroing this one. Proceed, with fingers crossed.", + NULL }; + mp_error (mp, "angle(0,0) is taken as zero", hlp, true); +@.angle(0,0)...zero@>; + /*mpfi_set_zero(ret->data.num,1); *//* 1 == positive */ + mpfi_set_d(ret->data.num,0.0); +} + + +@ Conversely, the |n_sin_cos| routine takes an |angle| and produces the sine +and cosine of that angle. The results of this routine are +stored in global integer variables |n_sin| and |n_cos|. + +@ Calculate sines and cosines. + +@c +void mp_interval_sin_cos (MP mp, mp_number z_orig, mp_number *n_cos, mp_number *n_sin) { + mpfi_t rad; + mpfi_t one_eighty; + mpfi_init2(rad, precision_bits); + mpfi_init2(one_eighty, precision_bits); + mpfi_set_si(one_eighty, 180 * 16); + mpfi_mul (rad, z_orig.data.num, PI_mpfi_t); + mpfi_div (rad, rad, one_eighty); + + mpfi_sin (n_sin->data.num, rad); + mpfi_cos (n_cos->data.num, rad); + + mpfi_mul (n_cos->data.num,n_cos->data.num, fraction_multiplier_mpfi_t); + mpfi_mul (n_sin->data.num,n_sin->data.num, fraction_multiplier_mpfi_t); + mp_check_mpfi_t(mp, n_cos->data.num); + mp_check_mpfi_t(mp, n_sin->data.num); + mpfi_clear (rad); + mpfi_clear (one_eighty); +} + +@ This is the http://www-cs-faculty.stanford.edu/~uno/programs/rng.c +with small cosmetic modifications. + +@c +#define KK 100 /* the long lag */ +#define LL 37 /* the short lag */ +#define MM (1L<<30) /* the modulus */ +#define mod_diff(x,y) (((x)-(y))&(MM-1)) /* subtraction mod MM */ +/* */ +static long ran_x[KK]; /* the generator state */ +/* */ +static void ran_array(long aa[],int n) /* put n new random numbers in aa */ + /* long aa[] destination */ + /* int n array length (must be at least KK) */ +{ + register int i,j; + for (j=0;j<KK;j++) aa[j]=ran_x[j]; + for (;j<n;j++) aa[j]=mod_diff(aa[j-KK],aa[j-LL]); + for (i=0;i<LL;i++,j++) ran_x[i]=mod_diff(aa[j-KK],aa[j-LL]); + for (;i<KK;i++,j++) ran_x[i]=mod_diff(aa[j-KK],ran_x[i-LL]); +} +/* */ +/* the following routines are from exercise 3.6--15 */ +/* after calling |ran_start|, get new randoms by, e.g., |x=ran_arr_next()| */ +/* */ +#define QUALITY 1009 /* recommended quality level for high-res use */ +static long ran_arr_buf[QUALITY]; +static long ran_arr_dummy=-1, ran_arr_started=-1; +static long *ran_arr_ptr=&ran_arr_dummy; /* the next random number, or -1 */ +/* */ +#define TT 70 /* guaranteed separation between streams */ +#define is_odd(x) ((x)&1) /* units bit of x */ +/* */ +static void ran_start(long seed) /* do this before using |ran_array| */ + /* long seed selector for different streams */ +{ + register int t,j; + long x[KK+KK-1]; /* the preparation buffer */ + register long ss=(seed+2)&(MM-2); + for (j=0;j<KK;j++) { + x[j]=ss; /* bootstrap the buffer */ + ss<<=1; if (ss>=MM) ss-=MM-2; /* cyclic shift 29 bits */ + } + x[1]++; /* make x[1] (and only x[1]) odd */ + for (ss=seed&(MM-1),t=TT-1; t; ) { + for (j=KK-1;j>0;j--) x[j+j]=x[j], x[j+j-1]=0; /* "square" */ + for (j=KK+KK-2;j>=KK;j--) + x[j-(KK-LL)]=mod_diff(x[j-(KK-LL)],x[j]), + x[j-KK]=mod_diff(x[j-KK],x[j]); + if (is_odd(ss)) { /* "multiply by z" */ + for (j=KK;j>0;j--) x[j]=x[j-1]; + x[0]=x[KK]; /* shift the buffer cyclically */ + x[LL]=mod_diff(x[LL],x[KK]); + } + if (ss) ss>>=1; else t--; + } + for (j=0;j<LL;j++) ran_x[j+KK-LL]=x[j]; + for (;j<KK;j++) ran_x[j-LL]=x[j]; + for (j=0;j<10;j++) ran_array(x,KK+KK-1); /* warm things up */ + ran_arr_ptr=&ran_arr_started; +} +/* */ +#define ran_arr_next() (*ran_arr_ptr>=0? *ran_arr_ptr++: ran_arr_cycle()) +static long ran_arr_cycle(void) +{ + if (ran_arr_ptr==&ran_arr_dummy) + ran_start(314159L); /* the user forgot to initialize */ + ran_array(ran_arr_buf,QUALITY); + ran_arr_buf[KK]=-1; + ran_arr_ptr=ran_arr_buf+1; + return ran_arr_buf[0]; +} + + + + +@ To initialize the |randoms| table, we call the following routine. + +@c +void mp_init_randoms (MP mp, int seed) { + int j, jj, k; /* more or less random integers */ + int i; /* index into |randoms| */ + j = abs (seed); + while (j >= fraction_one) { + j = j/2; + } + k = 1; + for (i = 0; i <= 54; i++) { + jj = k; + k = j - k; + j = jj; + if (k<0) + k += fraction_one; + mpfi_set_si(mp->randoms[(i * 21) % 55].data.num, j); + } + mp_new_randoms (mp); + mp_new_randoms (mp); + mp_new_randoms (mp); /* ``warm up'' the array */ + + ran_start ((unsigned long)seed); + +} + +@ @c +void mp_interval_number_modulo (mp_number *a, mp_number b) { + mpfi_remainder (a->data.num, a->data.num, b.data.num); +} + +@ To consume a random integer for the uniform generator, the program below will say `|next_unif_random|'. + +@c +static void mp_next_unif_random (MP mp, mp_number *ret) { + mp_number rop; + unsigned long int op; + float flt_op ; + (void)mp; + mp_new_number (mp, &rop, mp_scaled_type); + op = (unsigned)ran_arr_next(); + flt_op = op/(MM*1.0); + mpfi_set_d ((mpfi_ptr)(rop.data.num), flt_op); + mp_number_clone (ret, rop); + free_number (rop); +} + + + +@ To consume a random fraction, the program below will say `|next_random|'. + +@c +static void mp_next_random (MP mp, mp_number *ret) { + if ( mp->j_random==0 ) + mp_new_randoms(mp); + else + mp->j_random = mp->j_random-1; + mp_number_clone (ret, mp->randoms[mp->j_random]); +} + +@ To produce a uniform random number in the range |0<=u<x| or |0>=u>x| +or |0=u=x|, given a |scaled| value~|x|, we proceed as shown here. + +Note that the call of |take_fraction| will produce the values 0 and~|x| +with about half the probability that it will produce any other particular +values between 0 and~|x|, because it rounds its answers. + +@c +static void mp_interval_m_unif_rand (MP mp, mp_number *ret, mp_number x_orig) { +// CHECK +// This function probably should be rewritten +// it's the same as in mpmathbinary +// +// + mp_number y; /* trial value */ + mp_number x, abs_x; + mp_number u; + char *r ;mpfr_exp_t e; + mpfr_t ret_val; + double ret_d; + mpfr_init2(ret_val,precision_bits); + new_fraction (y); + new_number (x); + new_number (abs_x); + new_number (u); + mp_number_clone (&x, x_orig); + mp_number_clone (&abs_x, x); + mp_interval_abs (&abs_x); + mp_next_unif_random(mp, &u); + mpfi_mul (y.data.num, abs_x.data.num, u.data.num); + free_number (u); + if (mp_number_equal(y, abs_x)) { + mp_number_clone (ret, ((math_data *)mp->math)->zero_t); + } else if (mp_number_greater(x, ((math_data *)mp->math)->zero_t)) { + mp_number_clone (ret, y); + } else { + mp_number_clone (ret, y); + mp_number_negate (ret); + } + r = mpfr_get_str(NULL, /* |char *str|, */ + &e, /* |mpfi_exp_t *expptr|,*/ + 10, /* |int b|, */ + 0, /* |size_t n|, */ + ret_val, /* |mpfi_t op|, */ + MPFR_ROUNDING /* |mpfi_rnd_t rnd|*/ + ); + mpfr_free_str(r); + free_number (abs_x); + free_number (x); + free_number (y); + ret_d = mpfr_get_d(ret_val, MPFR_ROUNDING); + mpfi_set_d (ret->data.num, ret_d); +} + + + +@ Finally, a normal deviate with mean zero and unit standard deviation +can readily be obtained with the ratio method (Algorithm 3.4.1R in +{\sl The Art of Computer Programming\/}). + +@c +static void mp_interval_m_norm_rand (MP mp, mp_number *ret) { + mp_number ab_vs_cd; + mp_number abs_x; + mp_number u; + mp_number r; + mp_number la, xa; + new_number (ab_vs_cd); + new_number (la); + new_number (xa); + new_number (abs_x); + new_number (u); + new_number (r); + + do { + do { + mp_number v; + new_number (v); + mp_next_random(mp, &v); + mp_number_substract (&v, ((math_data *)mp->math)->fraction_half_t); + mp_interval_number_take_fraction (mp,&xa, ((math_data *)mp->math)->sqrt_8_e_k, v); + free_number (v); + mp_next_random(mp, &u); + mp_number_clone (&abs_x, xa); + mp_interval_abs (&abs_x); + } while (!mp_number_less(abs_x, u)); + mp_interval_number_make_fraction (mp, &r, xa, u); + mp_number_clone (&xa, r); + mp_interval_m_log (mp,&la, u); + mp_set_interval_from_substraction(&la, ((math_data *)mp->math)->twelve_ln_2_k, la); + mp_interval_ab_vs_cd (mp,&ab_vs_cd, ((math_data *)mp->math)->one_k, la, xa, xa); + } while (mp_number_less(ab_vs_cd,((math_data *)mp->math)->zero_t)); + mp_number_clone (ret, xa); + free_number (ab_vs_cd); + free_number (r); + free_number (abs_x); + free_number (la); + free_number (xa); + free_number (u); +} + + + +@ The following subroutine is used only in |norm_rand| and tests if $ab$ is +greater than, equal to, or less than~$cd$. +The result is $+1$, 0, or~$-1$ in the three respective cases. + +@c +static void mp_interval_ab_vs_cd (MP mp, mp_number *ret, mp_number a_orig, mp_number b_orig, mp_number c_orig, mp_number d_orig) { + mpfi_t a, b, c, d; + mpfi_t ab, cd; + + int cmp = 0; + (void)mp; + mpfi_inits2(precision_bits, a,b,c,d,ab,cd,(mpfi_ptr)0); + mpfi_set(a, (mpfi_ptr )a_orig.data.num); + mpfi_set(b, (mpfi_ptr )b_orig.data.num); + mpfi_set(c, (mpfi_ptr )c_orig.data.num); + mpfi_set(d, (mpfi_ptr )d_orig.data.num); + + mpfi_mul(ab,a,b); + mpfi_mul(cd,c,d); + + mpfi_set(ret->data.num, zero); + cmp = mpfi_cmp(ab,cd); + if (cmp) { + if (cmp>0) + mpfi_set(ret->data.num, one); + else + mpfi_set(ret->data.num, minusone); + } + mp_check_mpfi_t(mp, ret->data.num); + mpfi_clears(a,b,c,d,ab,cd,(mpfi_ptr)0); + return; +} + + diff --git a/Build/source/texk/web2c/mplibdir/mpost.w b/Build/source/texk/web2c/mplibdir/mpost.w index 5e447270678..352f659a7f7 100644 --- a/Build/source/texk/web2c/mplibdir/mpost.w +++ b/Build/source/texk/web2c/mplibdir/mpost.w @@ -915,6 +915,9 @@ static struct option mpost_options[] } else if (STREQ (optarg, "binary")) { options->math_mode = mp_math_binary_mode; internal_set_option("numbersystem=\"binary\""); + } else if (STREQ (optarg, "interval")) { + options->math_mode = mp_math_interval_mode; + internal_set_option("numbersystem=\"interval\""); } else { fprintf(stdout,"Ignoring unknown argument `%s' to --numbersystem\n", optarg); } @@ -1029,7 +1032,7 @@ fprintf(stdout, " -ini be inimpost, for dumping mem files\n" " -interaction=STRING set interaction mode (STRING=batchmode/nonstopmode/\n" " scrollmode/errorstopmode)\n" -" -numbersystem=STRING set number system mode (STRING=scaled/double/binary/decimal)\n" +" -numbersystem=STRING set number system mode (STRING=scaled/double/binary/interval/decimal)\n" " -jobname=STRING set the job name to STRING\n" " -progname=STRING set program (and mem) name to STRING\n" " -tex=TEXPROGRAM use TEXPROGRAM for text labels\n" diff --git a/Build/source/texk/web2c/omegafonts/Makefile.in b/Build/source/texk/web2c/omegafonts/Makefile.in index 3fe53e9527a..6a0c335586a 100644 --- a/Build/source/texk/web2c/omegafonts/Makefile.in +++ b/Build/source/texk/web2c/omegafonts/Makefile.in @@ -116,6 +116,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -569,6 +570,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ diff --git a/Build/source/texk/web2c/otps/Makefile.in b/Build/source/texk/web2c/otps/Makefile.in index 4c61adaf8de..9d146d11453 100644 --- a/Build/source/texk/web2c/otps/Makefile.in +++ b/Build/source/texk/web2c/otps/Makefile.in @@ -116,6 +116,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -603,6 +604,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ diff --git a/Build/source/texk/web2c/otps/win32/Makefile.in b/Build/source/texk/web2c/otps/win32/Makefile.in index fff8ce7086c..d99449f2f98 100644 --- a/Build/source/texk/web2c/otps/win32/Makefile.in +++ b/Build/source/texk/web2c/otps/win32/Makefile.in @@ -113,6 +113,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -322,6 +323,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ diff --git a/Build/source/texk/web2c/pmpostdir/ChangeLog b/Build/source/texk/web2c/pmpostdir/ChangeLog index a288c79c16f..c97c3c77339 100644 --- a/Build/source/texk/web2c/pmpostdir/ChangeLog +++ b/Build/source/texk/web2c/pmpostdir/ChangeLog @@ -1,3 +1,8 @@ +2024-02-01 Luigi Scarso <luigi.scarso@gmail.com> + + * pmp.ch: bump MetaPost version to 2.10 for mpfi. + * am/pmpost.am: link with mpfi. + 2023-09-16 TANAKA Takuji <ttk@t-lab.opal.ne.jp> * pmp.ch: Bump upmpost version to 2.02-0.04-u1.30. diff --git a/Build/source/texk/web2c/pmpostdir/am/pmpost.am b/Build/source/texk/web2c/pmpostdir/am/pmpost.am index f7dbe7d0bed..fde460647b0 100644 --- a/Build/source/texk/web2c/pmpostdir/am/pmpost.am +++ b/Build/source/texk/web2c/pmpostdir/am/pmpost.am @@ -39,9 +39,9 @@ call_upmpost_CPPFLAGS = -DEXEPROG=\"upmpost.exe\" nodist_call_upmpost_SOURCES = callexe.c call_upmpost_LDADD = -pmpost_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ +pmpost_CPPFLAGS = $(MPFI_INCLUDES) $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(PTEXENC_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir -pmpost_LDADD = $(PTEXENC_LIBS) $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ +pmpost_LDADD = $(PTEXENC_LIBS) $(KPATHSEA_LIBS) $(MPFI_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a upmpost_CPPFLAGS = -DUPMP $(pmpost_CPPFLAGS) @@ -65,13 +65,14 @@ pmp_ctangle = $(ctangle_silent)CWEBINPUTS=.:$(srcdir)/pmpostdir $(ctangle) pmp_ctangle_sh = CWEBINPUTS=.:$(srcdir)/pmpostdir AM_V_P=$(AM_V_P) $(SHELL) ./tangle-sh $@ $(CTANGLE) ## pMetaPost C sources -nodist_pmpost_SOURCES = $(pmp_c_h) $(pmpmath_c_h) $(pmpmathbinary_c_h) \ +nodist_pmpost_SOURCES = $(pmp_c_h) $(pmpmath_c_h) $(pmpmathinterval_c_h) $(pmpmathbinary_c_h) \ $(pmpmathdecimal_c_h) \ $(pmpmathdouble_c_h) pmpost.c $(pmpstrings_c_h) $(pmpxout_c_h) \ $(ppngout_c_h) $(ppsout_c_h) $(psvgout_c_h) ptfmin.c # pmp_c_h = pmp.c pmplib.h pmpmp.h pmpmath_c_h = pmpmath.c pmpmath.h +pmpmathinterval_c_h = pmpmathinterval.c pmpmathinterval.h pmpmathbinary_c_h = pmpmathbinary.c pmpmathbinary.h pmpmathdecimal_c_h = pmpmathdecimal.c pmpmathdecimal.h pmpmathdouble_c_h = pmpmathdouble.c pmpmathdouble.h @@ -98,6 +99,10 @@ pmpmath.c: mpmath.c $(AM_V_GEN)$(pmp_sed) mpmath.c >$@ pmpmath.h: mpmath.h $(AM_V_GEN)$(pmp_sed) mpmath.h >$@ +pmpmathinterval.c: mpmathinterval.c + $(AM_V_GEN)$(pmp_sed) mpmathinterval.c >$@ +pmpmathinterval.h: mpmathinterval.h + $(AM_V_GEN)$(pmp_sed) mpmathinterval.h >$@ pmpmathbinary.c: mpmathbinary.c $(AM_V_GEN)$(pmp_sed) mpmathbinary.c >$@ pmpmathbinary.h: mpmathbinary.h @@ -163,7 +168,7 @@ pmpost_web = pmpostdir/pmp.ch pmpostdir/pmpost.ch pmpostdir/pmpxout.ch pmpostdir pmpostdir/psvgout.ch pmpostdir/ptfmin.ch $(pmpost_OBJECTS) $(upmpost_OBJECTS): $(nodist_pmpost_SOURCES) $(PTEXENC_DEPEND) \ - $(LIBPNG_DEPEND) $(CAIRO_DEPEND) $(MPFR_DEPEND) + $(LIBPNG_DEPEND) $(CAIRO_DEPEND) $(MPFI_DEPEND) $(MPFR_DEPEND) EXTRA_DIST += pmpostdir/ChangeLog $(pmpost_web) diff --git a/Build/source/texk/web2c/pmpostdir/pmp.ch b/Build/source/texk/web2c/pmpostdir/pmp.ch index 716c662ed87..a3e7e76bb40 100644 --- a/Build/source/texk/web2c/pmpostdir/pmp.ch +++ b/Build/source/texk/web2c/pmpostdir/pmp.ch @@ -13,19 +13,19 @@ % @x -@d default_banner "This is MetaPost, Version 2.02" /* printed when \MP\ starts */ +@d default_banner "This is MetaPost, Version 2.10" /* printed when \MP\ starts */ @y @z @x -#define metapost_version "2.02" +#define metapost_version "2.10" @y #ifdef UPMP #define P_UP "up" -#define metapost_version "2.02-0.04-u1.30" +#define metapost_version "2.10-0.04-u1.30" #else #define P_UP "p" -#define metapost_version "2.02-0.04" +#define metapost_version "2.10-0.04" #endif #define default_banner "This is " P_UP "MetaPost, Version " metapost_version /* printed when \MP\ starts */ @z diff --git a/Build/source/texk/web2c/window/Makefile.in b/Build/source/texk/web2c/window/Makefile.in index fa927d2cff3..688ef00865e 100644 --- a/Build/source/texk/web2c/window/Makefile.in +++ b/Build/source/texk/web2c/window/Makefile.in @@ -113,6 +113,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/web2c-disable.m4 \ $(top_srcdir)/../../m4/kpse-lua53-flags.m4 \ $(top_srcdir)/../../m4/kpse-luajit-flags.m4 \ $(top_srcdir)/../../m4/kpse-macos-framework.m4 \ + $(top_srcdir)/../../m4/kpse-mpfi-flags.m4 \ $(top_srcdir)/../../m4/kpse-mpfr-flags.m4 \ $(top_srcdir)/../../m4/kpse-pixman-flags.m4 \ $(top_srcdir)/../../m4/kpse-potrace-flags.m4 \ @@ -337,6 +338,9 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ +MPFI_DEPEND = @MPFI_DEPEND@ +MPFI_INCLUDES = @MPFI_INCLUDES@ +MPFI_LIBS = @MPFI_LIBS@ MPFR_DEPEND = @MPFR_DEPEND@ MPFR_INCLUDES = @MPFR_INCLUDES@ MPFR_LIBS = @MPFR_LIBS@ |