├── .gitignore ├── AUTHORS ├── COPYING ├── INSTALL ├── LICENSE ├── Makefile.am ├── NEWS ├── README ├── README.md ├── TODO ├── configure.ac ├── docs ├── Makefile ├── nine-two-sum.eps ├── nine-two-sum.fig ├── normal_sum_prod.eps ├── normal_sum_prod.fig ├── qd.bib ├── qd.tex ├── qd_add.eps ├── qd_add.fig ├── qd_add_proof.eps ├── qd_add_proof.fig ├── qd_add_qd_d.eps ├── qd_add_qd_d.fig ├── qd_mul_accum.eps ├── qd_mul_accum.fig ├── qd_mul_qd_d.eps ├── qd_mul_qd_d.fig ├── quick-two-sum.eps ├── quick-two-sum.fig ├── six-three-sum.eps ├── six-three-sum.fig ├── three-sum-2.eps ├── three-sum-2.fig ├── three-sum-3.eps ├── three-sum-3.fig ├── three-sum.eps ├── three-sum.fig ├── two-prod.eps ├── two-prod.fig ├── two-sum.eps └── two-sum.fig ├── fortran ├── Makefile.am ├── Makefile.sample ├── ddext.f ├── ddmod.f ├── f_dd.cpp ├── f_qd.cpp ├── main.cpp ├── qdext.f ├── qdmod.f ├── second.f.in ├── tquaderq.f ├── tquadgsq.f ├── tquadgsq2d.f ├── tquadtsq.f ├── tquadtsq2d.f └── zz_timer.f ├── include ├── Makefile.am └── qd │ ├── bits.h │ ├── c_dd.h │ ├── c_qd.h │ ├── dd_inline.h │ ├── dd_real.h │ ├── fpu.h │ ├── inline.h │ ├── qd_config.h.in │ ├── qd_inline.h │ └── qd_real.h ├── m4 ├── ax_cxx_clock_gettime.m4 ├── ax_cxx_copysign.m4 ├── ax_cxx_fc_lib.m4 ├── ax_cxx_fma.m4 ├── ax_cxx_isfinite.m4 ├── ax_cxx_isinf.m4 ├── ax_cxx_isnan.m4 ├── ax_f90_module_flag.m4 ├── ax_f90_module_style.m4 └── ax_fc_etime.m4 ├── qd-config.in ├── qd.pc.in ├── src ├── Makefile.am ├── bits.cpp ├── c_dd.cpp ├── c_qd.cpp ├── dd_const.cpp ├── dd_real.cpp ├── fpu.cpp ├── qd_const.cpp ├── qd_real.cpp ├── util.cpp └── util.h └── tests ├── Makefile.am ├── c_test.c ├── coeff.dat ├── f_test.f ├── huge.cpp ├── pslq.h ├── pslq_test.cpp ├── qd_test.cpp ├── qd_timer.cpp ├── quadt.h ├── quadt_test.cpp ├── tictoc.cpp └── tictoc.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | libqd: quad-double / double-double computation package 2 | ------------------------------------------------------ 3 | 4 | Authors 5 | ------- 6 | Yozo Hida U.C. Berkeley 7 | Xiaoye S. Li Lawrence Berkeley Natl Lab 8 | David H. Bailey Lawrence Berkeley Natl Lab 9 | 10 | Contributors 11 | ------------ 12 | Alex Kaiser 13 | - Made some improvements and wrote the C++ usage guide. 14 | Yves Renard 15 | - Provided initial autotoolization (autoconf / automake / libool). 16 | E. Jason Riedy 17 | - Various bug fixes and code cleanup. 18 | Michael Orlitzky 19 | - Bug fixes, build system cleanup, and a new release. 20 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | This work was supported by the Director, Office of Science, Division 2 | of Mathematical, Information, and Computational Sciences of the 3 | U.S. Department of Energy under contract numbers DE-AC03-76SF00098 and 4 | DE-AC02-05CH11231. 5 | 6 | Copyright (c) 2003-2023, The Regents of the University of California, 7 | through Lawrence Berkeley National Laboratory (subject to receipt of 8 | any required approvals from U.S. Dept. of Energy) All rights reserved. 9 | 10 | By downloading or using this software you are agreeing to the modified 11 | BSD license that is in file "LICENSE" in the main directory. 12 | If you wish to use the software for commercial purposes 13 | please contact the Technology Transfer Department at TTD@lbl.gov or 14 | call 510-286-6457. 15 | 16 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Quad-Double computation package 2 | Copyright (C) 2003-2018 3 | ================================================ 4 | 5 | Revised 30 Oct 2018 6 | 7 | To build this library, follow the steps below. 8 | Some system specific notes are at the end of this file. 9 | 10 | Build Instructions 11 | ================== 12 | 13 | 1. Create the configure script by typing 14 | autoconf 15 | 16 | 2. Run the configure script by typing 17 | 18 | ./configure 19 | 20 | The script will attempt to automatically detect various system-dependent 21 | variables used during compilation (such as the C++/fortran compiler, 22 | compiler flags, and linker flags). 23 | 24 | If you want to specify a particular C++ / F90 compiler and their flags, 25 | you can set them as environmental variables. For example: 26 | 27 | FC=ifc FCFLAGS="-O2 -FR" ./configure 28 | 29 | Important variables are 30 | 31 | CXX C++ compiler to use 32 | CXXFLAGS C++ compiler flags to use 33 | CC C compiler to use (for C demo program) 34 | CFLAGS C compiler flags to use (for C demo program) 35 | FC Fortran 90 compiler 36 | FCFLAGS Fortran 90 compiler flags to use 37 | FCLIBS Fortran 90 libraries needed to to link with C++ code. 38 | 39 | See ./configure --help to see other options. 40 | 41 | 3. The configure script should also have created the files 'config.h' and 42 | 'include/qd/qd_config.h', which will contain the compile time 43 | defines. Examine these and edit them if necessary. In most cases 44 | no edits are necessary, since the options are detected when configure 45 | was run. 46 | 47 | 4. Type "make". This will build the library, and necessary Fortran 48 | wrappers. 49 | 50 | 5. Optionally, one can build and run some simple test programs. 51 | To do this, type "make check". Some programs run during this 52 | phase is a good demonstration of how to use the qd library in C++. 53 | 54 | 6. You can now install the QD library by issuing "make install". 55 | 56 | 7. If you want to build some sample programs written in C++ 57 | you can type "make cpp-demo". 58 | 59 | 8. If you want to build some sample programs written in Fortran 90, 60 | you can type "make fortran-demo". 61 | 62 | 9. If you want to compile the Experimental Mathematician's Toolkit, 63 | type "make toolkit". This will compile the Fortran-90 codes in 64 | the toolkit cirectory, including the "mathinit" and "mathtool" 65 | Read the "README" file in the toolkit directory for additional details. 66 | 67 | 68 | System-Specific Notes 69 | ===================== 70 | 71 | Linux with Intel processors 72 | ------------------- 73 | You can use g++ to compile the C++ code, which is a part of all 74 | Linux or other Unix distributions. The Fortran 90 codes 75 | can be compiled using the gfortran compiler available at 76 | 77 | https://gcc.gnu.org/wiki/GFortranBinaries 78 | 79 | Alternatively, one can use the Intel compilers, available at: 80 | 81 | http://www.intel.com/software/products/compilers/clin/ 82 | http://www.intel.com/software/products/compilers/flin/ 83 | 84 | One can specify specific compilers for the configure script, as in: 85 | 86 | ./configure CXX=g++ FC=gfortran 87 | 88 | 89 | Apple (OS X) 90 | ------------ 91 | 92 | For Apple OS X Intel-based systems, it is recommended that you use 93 | the g++ compiler and related command-line tools, available via this URL: 94 | 95 | https://developer.apple.com/downloads/index.action 96 | 97 | See "Command-line tools" for your version of OS X. The above URL requires 98 | a registered Apple ID. It may be necessary to install Apple's Xcode 99 | package first. 100 | 101 | The gfortran compiler for Mac OS X can be downloaded from: 102 | https://gcc.gnu.org/wiki/GFortranBinaries 103 | 104 | After installing these compilers, in the main qd directory type 105 | 106 | ./configure CXX=g++ FC=gfortran FCFLAGS=-m64 107 | 108 | then type "make" to construct the library. See the "README" file on 109 | how to construct a compile-link script for your own codes. 110 | 111 | IBM (Power) 112 | ----------- 113 | 114 | With IBM's xlC/xlf90 compilers, you may want to experiment with 115 | --enable-fma option which uses a faster code but relies on the 116 | compiler to generate a fused multiply-accumulate instruction. 117 | WARNING: since the compiler is not required to produce such 118 | instructions, this is not guaranteed to work. Please test before 119 | using. 120 | 121 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, highprecision 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | SUBDIRS = src include tests fortran 3 | 4 | pkgconfigdir = $(libdir)/pkgconfig 5 | pkgconfig_DATA = qd.pc 6 | 7 | BUILT_SOURCES = docs/qd.pdf 8 | dist_doc_DATA = README README.md docs/qd.pdf 9 | dist_noinst_DATA = docs/Makefile \ 10 | docs/qd.tex docs/qd.bib \ 11 | docs/nine-two-sum.eps docs/nine-two-sum.fig \ 12 | docs/normal_sum_prod.eps docs/normal_sum_prod.fig \ 13 | docs/qd_add.eps docs/qd_add.fig \ 14 | docs/qd_add_proof.eps docs/qd_add_proof.fig \ 15 | docs/qd_add_qd_d.eps docs/qd_add_qd_d.fig \ 16 | docs/qd_mul_accum.eps docs/qd_mul_accum.fig \ 17 | docs/qd_mul_qd_d.eps docs/qd_mul_qd_d.fig \ 18 | docs/quick-two-sum.eps docs/quick-two-sum.fig \ 19 | docs/six-three-sum.eps docs/six-three-sum.fig \ 20 | docs/three-sum-2.eps docs/three-sum-2.fig \ 21 | docs/three-sum-3.eps docs/three-sum-3.fig \ 22 | docs/three-sum.eps docs/three-sum.fig \ 23 | docs/two-prod.eps docs/two-prod.fig \ 24 | docs/two-sum.eps docs/two-sum.fig 25 | 26 | doc: docs/qd.pdf 27 | 28 | docs/qd.pdf: 29 | $(MAKE) -C docs qd.pdf 30 | 31 | cpp-demo: 32 | $(MAKE) -C tests demo 33 | 34 | if HAVE_FORTRAN 35 | 36 | fortran-demo: 37 | $(MAKE) -C fortran demo 38 | 39 | demo: cpp-demo fortran-demo 40 | 41 | else 42 | 43 | fortran-demo: 44 | @echo "You need a Fortran 95 compiler to build fortran demo programs." && false 45 | 46 | demo: cpp-demo 47 | 48 | endif 49 | 50 | time: 51 | $(MAKE) -C tests time 52 | 53 | bin_SCRIPTS=qd-config 54 | 55 | .PHONY: cpp-demo fortran-demo demo time doc 56 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Changes for 2.3.24 2 | Installed a patch suggested by Sharlatan Hellseher to improve the accuracy 3 | of a spherical geometry application. 4 | 5 | Changes for 2.3.23 6 | Fixed underlinking of libqdmod and libqd_f_main (bug). 7 | Don't set CC=$CXX (fixes a new build issue with autoconf-2.71, bug). 8 | Fixed typo in the rule to build docs/qd.pdf (bug). 9 | Fixed "make dist" rule (built headers cannot be dist'd, bug). 10 | Fixed the build with --disable-inline (bug). 11 | Don't add "-O2" to CXXFLAGS or FCFLAGS when they're empty (portability). 12 | Don't manually search for compilers & flags in configure.ac (portability). 13 | Removed the --enable-warnings and --enable-debug flags (portability). 14 | Modernized all of configure.ac for use with autoconf-2.71 (housekeeping). 15 | 16 | Changes for 2.3.22 17 | Made changes suggested by Vasiliy Sotnikov 18 | 19 | Changes for 2.3.21 20 | Changed renorm in include/qd/qd_inline.h 21 | 22 | Changes for 2.3.20 23 | added #include to quadt_test.cpp 24 | changed references to 2.3.20 from 2.3.18 25 | 26 | Changes for 2.3.19 27 | - Updated qd_real.cpp and dd_real.cpp to fix a buffer overflow problem. 28 | 29 | Changes for 2.3.18 30 | - Updated qd_real.cpp and dd_real.cpp to fix a problem in output. 31 | 32 | Changes for 2.3.17 33 | - updated qd_real.cpp, to fix a problem with improper treatment of 34 | negative arguments in nroot. 35 | 36 | Changes for 2.3.16 37 | - Updated dd_real.cpp, to fix a problem with inaccurate values of 38 | tanh for small arguments. 39 | 40 | Changes for 2.3.15 41 | - Updated qd_real.cpp, to fix a problem with static definitions. 42 | 43 | Changes for 2.3.14 44 | - Updated autoconfig (replaced config.sub and config.guess) 45 | 46 | Changes for 2.3.7 47 | - Fixed bug in to_digits where digits larger than 10 48 | where output occasionally. 49 | 50 | Changes for 2.3.6 51 | - Added fmod (C++) and mod (Fortran) functions. 52 | 53 | Changes for 2.3.5 54 | - Fixed bug in division of qd_real by dd_real. 55 | - Fixed bug in ddoutc (Fortran ddmod.f). 56 | - Now compiles with g++ 4.3. 57 | - Distribute tests/coeff.dat. 58 | 59 | Changes for 2.3.4 60 | - Fixed bug in Makefile for cygwin / mingw systems. 61 | 62 | Changes for 2.3.3 63 | - Fixed bug in atan2. 64 | 65 | Changes for 2.3.2 66 | - Fixed bug in sin / cos / sincos where too much accuracy was 67 | lost for (moderately) large angles. 68 | - Use fused-multiply add intrinsics on IA-64 platforms if 69 | compiled by Intel compiler. 70 | - Fixed bug in c_dd_write and c_qd_write. 71 | - Fixed bug were qdext.mod was not being installed. 72 | 73 | Changes for 2.3.1 74 | - Fixed bug in sincos and cos_taylor. This affected the result 75 | of trigonometric functions in some cases. 76 | 77 | Changes for 2.3.0 78 | This is a fairly significant change, breaking API compatibility. 79 | - Moved C++ main entry in libqdmod.a to libqd_f_main.a. 80 | This allows to link Fortran code using QD with custom 81 | C++ main function. Pure Fortran code will need to be linked 82 | with qd_f_main library in addition to qdmod and qd library. 83 | - Constructors accepting pointers made explicit. 84 | - Fortran routines labeled as elemental or pure, where appropriate. 85 | - Write() is now to_string(), and now takes a single fmtflag. 86 | - dd_real addition and multiplication made commutative. 87 | - dd_real now represented as array of two doubles, instead of 88 | two discrete scalars. 89 | - New Fortran generic routines to read / write, operations with 90 | complex and integers. 91 | - Improved exp, sin, and cos functions. 92 | - Removed unused constants and obscure constants only used internally 93 | from public interface. 94 | 95 | Changes for 2.2.6 96 | - Fixed bug in mixed precision multiplication: qd_real * dd_real. 97 | 98 | Changes for 2.2.5 99 | - Bug fix in qd_real addition when --enable-ieee-add is specified. 100 | - Debugging routines dump and dump_bits updated; 101 | dump_components removed (just use dump). 102 | - Fortran support for Fortran strings. Use character arrays instead. 103 | - Return NaN under error conditions. 104 | - Added _inf constant; exp now returns Inf when argument is too large. 105 | - Output formatting fixes for Inf and NaNs. 106 | - Added more real-complex mixed arithmetic routines in Fortran 107 | interface. 108 | 109 | Changes for 2.2.4 110 | - Added random_number interface for Fortran modules. 111 | - Use slightly more conservative values for eps. 112 | - Avoid unnecessary overflow near overflow threshold. 113 | - Added radix, digits, min/maxexponent, range, and precision 114 | intrinsics to Fortran interface. 115 | - Added safe_max (C++) and safe_huge (Fortran). 116 | 117 | Changes for 2.2.3 118 | - Fix sign function bug in Fortran modules. 119 | 120 | Changes for 2.2.2 121 | - Do not bother setting uninitialized dd_real and qd_reals to zero. 122 | - Use clock_gettime if available for timing. 123 | - Fortran I/O should be more consistent with C++ version. 124 | - fpu.h is now included with dd_real.h. 125 | 126 | Changes for 2.2.1 127 | - Minor fixes when printing in scientific format. 128 | - Change search order of C++ compilers in Apple systems to avoid 129 | case insensitive filesystems. 130 | 131 | Changes for 2.2.0 132 | - Added F95 interface for complex types. 133 | - Renamed dd.h and qd.h to dd_real.h and qd_real.h, respectively. 134 | This will break older C++ code using 2.1.x library, but it was 135 | conflicting with QuickDraw libraries on Macs. (Hence the version 136 | bump to 2.2). 137 | - Removed overloaded typecast operators for int and double. These 138 | permitted *automatic* conversion of dd_real/qd_real to double or 139 | int, which is somewhat dangerous. Instead to_int and to_double 140 | routines are added. 141 | 142 | Changes for 2.1.214 143 | - Updated pslq_test. 144 | - Implmented numeric_limits<>. 145 | - Better polyroot. 146 | - Added isnan, isfinite, isinf functions. 147 | - Fix / improve input output functions. 148 | - Drop Microsoft Visual C++ 6.0 support. 149 | - More efficient dd_real::sin. 150 | 151 | Changes for 2.1.213 152 | - Support for x86_64 platforms. 153 | - Drop libtool support for now. 154 | 155 | Changes for 2.1.212 156 | - Support for pathCC compiler. 157 | - Added accurate and sloppy versions of add / sub / mul / div avaialble. 158 | - Added autodetection of fma functions. 159 | 160 | Changes for 2.1 (2003-12-30) 161 | - added automake scripts. 162 | - use libtool to compile / link and build libraries. 163 | - supports standard installation targets (make install). 164 | - support for Intel C++ compilers (icc / ecc). 165 | - Fortran programs are now linked by C++ compiler. 166 | - support for building shared library. 167 | - minor bug fixes. 168 | 169 | Changes for 2.0 (2003-12-08) 170 | - all header files are in "include/qd" directory. 171 | - added autoconf scripts. 172 | - added config.h and qd_config.h to store configuration information. 173 | - renamed x86_* routines to fpu_* routines. 174 | - added separate Fortran interface (f_* routines). 175 | - options for sloppy multiply and sloppy divison separated. 176 | - fixed C interface to be actually in C syntax. 177 | - updated / added README, AUTHORS, NEWS, and LICENSE files. 178 | - minor bug fixes. 179 | 180 | Changes for 1.2 (2003-12-04) 181 | - added "dist-clean" target in Makefile 182 | - initialize dd and qd variables to zero 183 | - increases tolerance for qd / dd tests 184 | - changed .cc extension to .cpp 185 | - updated README, COPYING, and NEWS files 186 | - added ChangeLog file 187 | - fixed bug in '-all' flag in qd_test 188 | - minor bug fixes 189 | 190 | Changes for 1.1 (2002-10-22) 191 | - added "Changes" file (this file) 192 | - fixed to 193 | - fixed constant (3/4) * pi 194 | - fixed exp(x) to return zero if x is a large negative number 195 | - removed "docs" target in Makefile 196 | 197 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QD 2 | A double-double and quad-double package for Fortran and C++ 3 | 4 | ## End-user documentation 5 | 6 | For historical reasons, the original user-focused documentation is 7 | located in the `README` file, sans the `.md` extension. In-depth 8 | technical documentation is also provided, as `docs/qd.pdf` in the 9 | release tarballs. To build the PDF from its LaTeX sources, run 10 | 11 | ``` 12 | $ make -C docs qd.pdf 13 | ``` 14 | 15 | after installing the necessary LaTeX bits on your system. 16 | 17 | ## Tips for developers 18 | 19 | Before you can build QD from the git repository, you will likely have 20 | to generate the "autotools" files (such as `./configure`) that are 21 | normally provided for you in a release tarball. The easiest way to do 22 | that is to run, 23 | 24 | ``` 25 | $ autoreconf -fi 26 | ``` 27 | 28 | as a shortcut for running each of *autoconf*, *autoheader*, *aclocal*, 29 | *automake*, and *libtoolize* as many times as necessary and in the 30 | correct order. The `-fi` flags force autoreconf to regenerate 31 | everything, and to install any missing auxiliary files. You will of 32 | course need all of the relevant autotools packages (autoconf, 33 | automake, and libtool) installed for this to work. 34 | 35 | Afterwards, you can `./configure` the package and build it like you 36 | normally would from a release tarball. 37 | 38 | ### Running the test suite 39 | 40 | The QD library comes with an automated test suite that should always 41 | pass. To run it, execute `make check` after building the 42 | library. Ignoring the noise from the compiler (the test suite itself 43 | must be compiled), the output should look something like 44 | 45 | ``` 46 | $ ./configure 47 | ... 48 | $ make 49 | ... 50 | $ make check 51 | ... 52 | PASS: qd_test 53 | PASS: pslq_test 54 | PASS: c_test 55 | PASS: f_test 56 | ============================================================================ 57 | Testsuite summary for qd 2.3.23 58 | ============================================================================ 59 | # TOTAL: 4 60 | # PASS: 4 61 | # SKIP: 0 62 | # XFAIL: 0 63 | # FAIL: 0 64 | # XPASS: 0 65 | # ERROR: 0 66 | ============================================================================ 67 | 68 | ``` 69 | 70 | ### Making a release 71 | 72 | There are several steps that need to be performed when making a new 73 | release: 74 | 75 | 1. Ensure that all important user-facing changes are mentioned 76 | in the `NEWS` file. 77 | 78 | 2. Update the package version number in `configure.ac`. 79 | 80 | 3. Build a release tarball. First, run `git clean -x -f -d` to ensure 81 | that you're starting fresh. Then run `autoreconf -fi` to regenerate 82 | all of the autotools files. Run `./configure` to create your 83 | Makefiles, and finally, `make dist` to create the release tarball. 84 | 85 | 4. Run `make distcheck` to ensure that the release tarball works. 86 | 87 | 5. Tag the commit that corresponds to the release with `git tag -s 88 | `. 89 | 90 | 6. Push everything to Github. 91 | 92 | 7. Upload the release tarball (created earlier) to the Github release 93 | page that corresponds to your new version tag. This ensures that 94 | end-users can run `./configure` and such "out of the box," without 95 | having to install the GNU autotools (or learn their commands). 96 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * update documentation 2 | * add integer format support 3 | * support complex types. 4 | * partial template specialization for complex divide. 5 | * support x86 double-extended format (see Hladky's work) 6 | * perhaps rewrite core code in C preprocessor, with C/C++ wrappers. 7 | * complete numeric_limits 8 | * sane handling of overflow / underflow / NaNs. 9 | * handle more general streams, e.g., wide character streams 10 | * use automake within the docs/ directory. 11 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | LATEX = latex 2 | DVIPS = dvips 3 | DVIPDF = dvipdf 4 | BIBTEX = bibtex 5 | 6 | EPSFIGS = nine-two-sum.eps normal_sum_prod.eps qd_add.eps qd_add_proof.eps \ 7 | qd_add_qd_d.eps qd_mul_accum.eps qd_mul_qd_d.eps quick-two-sum.eps \ 8 | six-three-sum.eps three-sum-2.eps three-sum-3.eps three-sum.eps \ 9 | two-prod.eps two-sum.eps 10 | 11 | all: qd.pdf 12 | 13 | dvi: qd.dvi 14 | 15 | pdf: qd.pdf 16 | 17 | ps: qd.ps 18 | 19 | qd.dvi: qd.tex qd.bib $(EPSFIGS) 20 | $(LATEX) $< && $(BIBTEX) qd && \ 21 | $(LATEX) $< && $(LATEX) $< 22 | 23 | qd.ps: qd.dvi 24 | $(DVIPS) -o $@ $< 25 | 26 | qd.pdf: qd.dvi 27 | $(DVIPDF) $< 28 | 29 | clean: 30 | rm -f qd.dvi qd.blg qd.bbl qd.toc qd.log qd.aux 31 | 32 | maintainer-clean: clean 33 | rm -f qd.ps qd.pdf 34 | 35 | .PHONY: clean maintainer-clean all 36 | 37 | -------------------------------------------------------------------------------- /docs/nine-two-sum.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 75 75 2625 2775 11 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 12 | 675 675 975 675 975 975 675 975 675 675 13 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 14 | 1575 1275 1875 1275 1875 1575 1575 1575 1575 1275 15 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 16 | 1 1 1.00 60.00 120.00 17 | 75 825 675 825 18 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 19 | 1 1 1.00 60.00 120.00 20 | 825 75 825 675 21 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 22 | 1 1 1.00 60.00 120.00 23 | 1725 75 1725 1275 24 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 25 | 1 1 1.00 60.00 120.00 26 | 75 1425 1575 1425 27 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 28 | 1 1 1.00 60.00 120.00 29 | 825 975 825 2625 2025 2625 30 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 4 31 | 1 1 1.00 60.00 120.00 32 | 975 825 1275 825 1275 2325 2025 2325 33 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 4 34 | 1 1 1.00 60.00 120.00 35 | 1725 1575 1725 1875 2175 1875 2175 2175 36 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 37 | 1 1 1.00 60.00 120.00 38 | 1875 1425 2475 1425 2475 2175 39 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 40 | 2025 2175 2625 2175 2625 2775 2025 2775 2025 2175 41 | -6 42 | 6 2775 75 5325 2775 43 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 44 | 3375 675 3675 675 3675 975 3375 975 3375 675 45 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 46 | 4275 1275 4575 1275 4575 1575 4275 1575 4275 1275 47 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 48 | 1 1 1.00 60.00 120.00 49 | 3525 75 3525 675 50 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 51 | 1 1 1.00 60.00 120.00 52 | 4425 75 4425 1275 53 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 54 | 1 1 1.00 60.00 120.00 55 | 3525 975 3525 2625 4725 2625 56 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 4 57 | 1 1 1.00 60.00 120.00 58 | 3675 825 3975 825 3975 2325 4725 2325 59 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 4 60 | 1 1 1.00 60.00 120.00 61 | 4425 1575 4425 1875 4875 1875 4875 2175 62 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 63 | 1 1 1.00 60.00 120.00 64 | 4575 1425 5175 1425 5175 2175 65 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 66 | 4725 2175 5325 2175 5325 2775 4725 2775 4725 2175 67 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 68 | 1 1 1.00 60.00 120.00 69 | 3075 75 3075 825 3375 825 70 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 71 | 1 1 1.00 60.00 120.00 72 | 2775 75 2775 1425 4275 1425 73 | -6 74 | 6 4350 1350 4500 1500 75 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 76 | 4425 1350 4425 1500 77 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 78 | 4350 1425 4500 1425 79 | -6 80 | 6 3450 750 3600 900 81 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 82 | 3525 750 3525 900 83 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 84 | 3450 825 3600 825 85 | -6 86 | 6 1650 1350 1800 1500 87 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 88 | 1725 1350 1725 1500 89 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 90 | 1650 1425 1800 1425 91 | -6 92 | 6 750 750 900 900 93 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 94 | 825 750 825 900 95 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 96 | 750 825 900 825 97 | -6 98 | 6 2250 2400 2400 2550 99 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 100 | 2325 2400 2325 2550 101 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 102 | 2250 2475 2400 2475 103 | -6 104 | 6 4950 2400 5100 2550 105 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 106 | 5025 2400 5025 2550 107 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 108 | 4950 2475 5100 2475 109 | -6 110 | 6 4950 3300 5100 3450 111 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 112 | 5025 3300 5025 3450 113 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 114 | 4950 3375 5100 3375 115 | -6 116 | 6 4950 4050 5100 4200 117 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 118 | 5025 4050 5025 4200 119 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 120 | 4950 4125 5100 4125 121 | -6 122 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 123 | 1 1 1.00 60.00 120.00 124 | 2175 2775 2175 3225 4725 3225 125 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 126 | 1 1 1.00 60.00 120.00 127 | 2475 2775 2475 3525 4725 3525 128 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 129 | 4725 3075 5325 3075 5325 3675 4725 3675 4725 3075 130 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 131 | 1 1 1.00 60.00 120.00 132 | 4875 2775 4875 3075 133 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 134 | 1 1 1.00 60.00 120.00 135 | 5175 2775 5175 3075 136 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 137 | 4725 3975 5325 3975 5325 4275 4725 4275 4725 3975 138 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 139 | 1 1 1.00 60.00 120.00 140 | 4875 3675 4875 3975 141 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 142 | 1 1 1.00 60.00 120.00 143 | 5175 3675 5175 3975 144 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 145 | 1 1 1.00 60.00 120.00 146 | 75 4125 4725 4125 147 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 148 | 1 1 1.00 60.00 120.00 149 | 4875 4275 4875 5025 150 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 151 | 1 1 1.00 60.00 120.00 152 | 5175 4275 5175 4575 5925 4575 153 | 2 2 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 154 | 375 375 5625 375 5625 4725 375 4725 375 375 155 | -------------------------------------------------------------------------------- /docs/normal_sum_prod.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: normal_sum_prod.eps 3 | %%Creator: fig2dev Version 3.2.3 Patchlevel 4 | %%CreationDate: Wed Aug 2 14:12:28 2000 5 | %%For: yozo@n2001.lbl.gov () 6 | %%BoundingBox: 0 0 175 113 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 113 moveto 0 0 lineto 175 0 lineto 175 113 lineto closepath clip newpath 49 | % Fill background color 50 | 0 0 moveto 175 0 lineto 175 113 lineto 0 113 lineto 51 | closepath 1.00 1.00 1.00 setrgbcolor fill 52 | 53 | 7.0 106.0 translate 54 | 1 -1 scale 55 | 56 | /cp {closepath} bind def 57 | /ef {eofill} bind def 58 | /gr {grestore} bind def 59 | /gs {gsave} bind def 60 | /sa {save} bind def 61 | /rs {restore} bind def 62 | /l {lineto} bind def 63 | /m {moveto} bind def 64 | /rm {rmoveto} bind def 65 | /n {newpath} bind def 66 | /s {stroke} bind def 67 | /sh {show} bind def 68 | /slc {setlinecap} bind def 69 | /slj {setlinejoin} bind def 70 | /slw {setlinewidth} bind def 71 | /srgb {setrgbcolor} bind def 72 | /rot {rotate} bind def 73 | /sc {scale} bind def 74 | /sd {setdash} bind def 75 | /ff {findfont} bind def 76 | /sf {setfont} bind def 77 | /scf {scalefont} bind def 78 | /sw {stringwidth} bind def 79 | /tr {translate} bind def 80 | /tnt {dup dup currentrgbcolor 81 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 82 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 83 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 84 | bind def 85 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 86 | 4 -2 roll mul srgb} bind def 87 | /DrawEllipse { 88 | /endangle exch def 89 | /startangle exch def 90 | /yrad exch def 91 | /xrad exch def 92 | /y exch def 93 | /x exch def 94 | /savematrix mtrx currentmatrix def 95 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 96 | closepath 97 | savematrix setmatrix 98 | } def 99 | 100 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 101 | /$F2psEnd {$F2psEnteredState restore end} def 102 | 103 | $F2psBegin 104 | %%Page: 1 1 105 | 10 setmiterlimit 106 | 0.06000 0.06000 sc 107 | 7.500 slw 108 | % Ellipse 109 | n 825 825 150 150 0 360 DrawEllipse gs col0 s gr 110 | 111 | % Polyline 112 | n 750 825 m 113 | 900 825 l gs col0 s gr 114 | % Polyline 115 | n 825 750 m 116 | 825 900 l gs col0 s gr 117 | % Ellipse 118 | n 2475 825 150 150 0 360 DrawEllipse gs col0 s gr 119 | 120 | % Polyline 121 | n 2400 750 m 122 | 2550 900 l gs col0 s gr 123 | % Polyline 124 | n 2550 750 m 125 | 2400 900 l gs col0 s gr 126 | % Polyline 127 | gs clippath 128 | 795 690 m 855 690 l 855 539 l 825 659 l 795 539 l cp 129 | eoclip 130 | n 825 75 m 131 | 825 675 l gs col0 s gr gr 132 | 133 | % arrowhead 134 | n 795 539 m 825 659 l 855 539 l 795 539 l cp gs 0.00 setgray ef gr col0 s 135 | % Polyline 136 | gs clippath 137 | 690 855 m 690 795 l 539 795 l 659 825 l 539 855 l cp 138 | eoclip 139 | n 75 825 m 140 | 675 825 l gs col0 s gr gr 141 | 142 | % arrowhead 143 | n 539 855 m 659 825 l 539 795 l 539 855 l cp gs 0.00 setgray ef gr col0 s 144 | % Polyline 145 | gs clippath 146 | 795 1590 m 855 1590 l 855 1439 l 825 1559 l 795 1439 l cp 147 | eoclip 148 | n 825 975 m 149 | 825 1575 l gs col0 s gr gr 150 | 151 | % arrowhead 152 | n 795 1439 m 825 1559 l 855 1439 l 795 1439 l cp gs 0.00 setgray ef gr col0 s 153 | % Polyline 154 | gs clippath 155 | 2445 690 m 2505 690 l 2505 539 l 2475 659 l 2445 539 l cp 156 | eoclip 157 | n 2475 75 m 158 | 2475 675 l gs col0 s gr gr 159 | 160 | % arrowhead 161 | n 2445 539 m 2475 659 l 2505 539 l 2445 539 l cp gs 0.00 setgray ef gr col0 s 162 | % Polyline 163 | gs clippath 164 | 2340 855 m 2340 795 l 2189 795 l 2309 825 l 2189 855 l cp 165 | eoclip 166 | n 1725 825 m 167 | 2325 825 l gs col0 s gr gr 168 | 169 | % arrowhead 170 | n 2189 855 m 2309 825 l 2189 795 l 2189 855 l cp gs 0.00 setgray ef gr col0 s 171 | % Polyline 172 | gs clippath 173 | 2445 1590 m 2505 1590 l 2505 1439 l 2475 1559 l 2445 1439 l cp 174 | eoclip 175 | n 2475 975 m 176 | 2475 1575 l gs col0 s gr gr 177 | 178 | % arrowhead 179 | n 2445 1439 m 2475 1559 l 2505 1439 l 2445 1439 l cp gs 0.00 setgray ef gr col0 s 180 | $F2psEnd 181 | rs 182 | -------------------------------------------------------------------------------- /docs/normal_sum_prod.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 75 75 2625 1575 11 | 6 675 675 975 975 12 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 825 825 150 150 825 825 975 825 13 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 14 | 750 825 900 825 15 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 16 | 825 750 825 900 17 | -6 18 | 6 2325 675 2625 975 19 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 2475 825 150 150 2475 825 2625 825 20 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 21 | 2400 750 2550 900 22 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 23 | 2550 750 2400 900 24 | -6 25 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 26 | 1 1 1.00 60.00 120.00 27 | 825 75 825 675 28 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 29 | 1 1 1.00 60.00 120.00 30 | 75 825 675 825 31 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 32 | 1 1 1.00 60.00 120.00 33 | 825 975 825 1575 34 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 35 | 1 1 1.00 60.00 120.00 36 | 2475 75 2475 675 37 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 38 | 1 1 1.00 60.00 120.00 39 | 1725 825 2325 825 40 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 41 | 1 1 1.00 60.00 120.00 42 | 2475 975 2475 1575 43 | -6 44 | -------------------------------------------------------------------------------- /docs/qd.bib: -------------------------------------------------------------------------------- 1 | 2 | @article{she97, 3 | author = {Jonathan R. Shewchuk}, 4 | title = {Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates}, 5 | journal = {Discrete \& Computational Geometry}, 6 | year = 1997, 7 | volume = 18, 8 | number = 3, 9 | pages = {305-363} } 10 | 11 | @article{dek71, 12 | author = {T.J. Dekker}, 13 | title = {A Floating-Point Technique for Extending the Available Precision}, 14 | journal = {Numerische Mathematik}, 15 | year = 1971, 16 | volume = 18, 17 | pages = {224-242} } 18 | 19 | @phdthesis{pri92, 20 | author = {Douglas M. Priest}, 21 | title = {On Properties of Floating Point Arithmetics: Numerical Stability and the Cost of Accurate Computations}, 22 | school = {University of California, Berkeley}, 23 | year = 1992, 24 | month = {November}, 25 | note = {Available by anonymous FTP at {\tt ftp.icsi.berkeley.edu/pub/theory/ 26 | \linebreak[0]priest-thesis.ps.Z}} } 27 | 28 | @book{knu81, 29 | author = {Donald E. Knuth}, 30 | title = {The Art of Computer Programming: Seminumerical Algorithms}, 31 | publisher = {Addison Wesley}, 32 | year = 1981, 33 | volume = 2, 34 | address = {Reading, Massachusetts} } 35 | 36 | @misc{bai-dd, 37 | author = {David H. Bailey}, 38 | title = {A Fortran-90 double-double library}, 39 | note = {Available at {\tt http://www.nersc.gov/\linebreak\~{ }dhbailey/mpdist/mpdist.html}} } 40 | 41 | @article{bai-mp, 42 | author = {David H. Bailey}, 43 | title = {A Fortran-90 based multiprecision system}, 44 | journal = {ACM Transactions on Mathematical Software}, 45 | year = 1995, 46 | volume = 21, 47 | number = 4, 48 | pages = {379-387}, 49 | note = {Software available at {\tt http://www.nersc.gov/\linebreak\~{ }dhbailey/mpdist/mpdist.html}} } 50 | 51 | @misc{cha98, 52 | author = {Siddhardtha Chatterjee}, 53 | title = {{MPFUN++}: A Multiple Precision Floating Point Computation Package in {C}++}, 54 | note = {Available at {\tt http://www.cs.unc.edu/Research/HARPOON/mpfun++/}}, 55 | year = 1998} } 56 | 57 | @article{bai93, 58 | author = {David H. Bailey and Robert Krasny and Richard Pelz}, 59 | title = {Multiple Precision, Multiple Processor Vortex Sheet Roll-Up 60 | Computation}, 61 | journal = {Proc. Sixth SIAM Conference on Parallel Processing for 62 | Scientific Computing}, 63 | year = 1993, 64 | pages = {52-56} } 65 | 66 | @MISC{kbriggs97, 67 | AUTHOR = {Briggs, K.}, 68 | TITLE = {Doubledouble Floating Point Arithmetic}, 69 | HOWPUBLISHED = {{\tt http://www-epidem.plantsci.cam.ac.uk\linebreak[0] 70 | /$\sim$kbriggs/doubledouble.html}}, 71 | YEAR = {1998} } 72 | 73 | @ARTICLE{brent, 74 | AUTHOR = {R. Brent}, 75 | TITLE = {A {Fortran} Multiple Precision Arithmetic Package}, 76 | JOURNAL = {{ACM} Trans. Math. Soft.}, 77 | YEAR = {1978}, 78 | VOLUME = {4}, 79 | PAGES = {57--70}} 80 | 81 | @TECHREPORT{hida00, 82 | AUTHOR = {Yozo Hida and Xiaoye S. Li and David H. Bailey}, 83 | TITLE = {Quad-Double Arithmetic: Algorithms, Implementation, 84 | and Application}, 85 | INSTITUTION = {Lawrence Berkeley National Laboratory}, 86 | note = {Available at {\tt http://www.nersc.gov/\~{ }dhbailey/mpdist/mpdist.html}}, 87 | YEAR = {2000}, 88 | MONTH = {October}, 89 | ADDRESS = {Berkeley, CA 94720}, 90 | NUMBER = {LBNL-46996} } 91 | 92 | @misc{gnu-mp, 93 | key = {gmp}, 94 | title = {{GMP}}, 95 | note = {{\tt http://www.swox.com/gmp/}} } 96 | 97 | % pgs. 282-283, 292-297, 635-636, 675-677. 98 | @book{c++, 99 | author = {Bjarne Stroustrup}, 100 | title = {The C++ Programming Language}, 101 | publisher = {Addison Wesley}, 102 | year = 1997, 103 | address = {Reading Massachusetts} } 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /docs/qd_add.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 975 900 1275 1200 11 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 12 | 975 900 1275 900 1275 1200 975 1200 975 900 13 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 14 | 1050 1050 1200 1050 15 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 16 | 1125 975 1125 1125 17 | -6 18 | 6 1875 1500 2175 1800 19 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 20 | 1875 1500 2175 1500 2175 1800 1875 1800 1875 1500 21 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 22 | 1950 1650 2100 1650 23 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 24 | 2025 1575 2025 1725 25 | -6 26 | 6 2775 2100 3075 2400 27 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 28 | 2775 2100 3075 2100 3075 2400 2775 2400 2775 2100 29 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 30 | 2850 2250 3000 2250 31 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 32 | 2925 2175 2925 2325 33 | -6 34 | 6 3675 2700 3975 3000 35 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 36 | 3675 2700 3975 2700 3975 3000 3675 3000 3675 2700 37 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 38 | 3750 2850 3900 2850 39 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 40 | 3825 2775 3825 2925 41 | -6 42 | 6 1875 3900 2175 4200 43 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 44 | 1875 3900 2175 3900 2175 4200 1875 4200 1875 3900 45 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 46 | 1950 4050 2100 4050 47 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 48 | 2025 3975 2025 4125 49 | -6 50 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 51 | 1 1 1.00 60.00 120.00 52 | 375 1050 975 1050 53 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 54 | 1 1 1.00 60.00 120.00 55 | 375 1650 1875 1650 56 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 57 | 1 1 1.00 60.00 120.00 58 | 375 2250 2775 2250 59 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 60 | 1 1 1.00 60.00 120.00 61 | 375 2850 3675 2850 62 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 63 | 1 1 1.00 60.00 120.00 64 | 2025 1800 2025 3900 65 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 66 | 1 1 1.00 60.00 120.00 67 | 2925 2400 2925 3600 68 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 69 | 1 1 1.00 60.00 120.00 70 | 1275 1050 1575 1050 1575 4050 1875 4050 71 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 72 | 1 1 1.00 60.00 120.00 73 | 2175 1650 2475 1650 2475 3750 2775 3750 74 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 75 | 3675 3300 3975 3300 3975 3900 3675 3900 3675 3300 76 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 77 | 1 1 1.00 60.00 120.00 78 | 2175 4050 2775 4050 79 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 80 | 2775 3600 3075 3600 3075 4200 2775 4200 2775 3600 81 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 82 | 1 1 1.00 60.00 120.00 83 | 3075 3750 3675 3750 84 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 85 | 1 1 1.00 60.00 120.00 86 | 3075 2250 3375 2250 3375 3450 3675 3450 87 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 88 | 1 1 1.00 60.00 120.00 89 | 3825 3000 3825 3300 90 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 91 | 4575 3600 4875 3600 4875 4200 4575 4200 4575 3600 92 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 93 | 1 1 1.00 60.00 120.00 94 | 3975 3750 4575 3750 95 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 96 | 1 1 1.00 60.00 120.00 97 | 3075 4050 4575 4050 98 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 99 | 1 1 1.00 60.00 120.00 100 | 3975 2850 4725 2850 4725 3600 101 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 102 | 1 1 1.00 60.00 120.00 103 | 1125 1200 1125 4650 104 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 105 | 1 1 1.00 60.00 120.00 106 | 2025 4200 2025 4650 107 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 108 | 1 1 1.00 60.00 120.00 109 | 2925 4200 2925 4650 110 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 111 | 1 1 1.00 60.00 120.00 112 | 3825 3900 3825 4650 113 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 114 | 1 1 1.00 60.00 120.00 115 | 4725 4200 4725 4650 116 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 117 | 2850 3900 3000 3900 118 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 119 | 2925 3825 2925 3975 120 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 121 | 3750 3600 3900 3600 122 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 123 | 3825 3525 3825 3675 124 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 125 | 4650 3900 4800 3900 126 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 127 | 4725 3825 4725 3975 128 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 129 | 825 4650 5025 4650 5025 4950 825 4950 825 4650 130 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 131 | 1 1 1.00 60.00 120.00 132 | 1425 4950 1425 5400 133 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 134 | 1 1 1.00 60.00 120.00 135 | 2325 4950 2325 5400 136 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 137 | 1 1 1.00 60.00 120.00 138 | 3225 4950 3225 5400 139 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 140 | 1 1 1.00 60.00 120.00 141 | 4125 4950 4125 5400 142 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 143 | 1 1 1.00 60.00 120.00 144 | 1125 300 1125 900 145 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 146 | 1 1 1.00 60.00 120.00 147 | 2025 300 2025 1500 148 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 149 | 1 1 1.00 60.00 120.00 150 | 2925 300 2925 2100 151 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 152 | 1 1 1.00 60.00 120.00 153 | 3825 300 3825 2700 154 | 4 1 0 50 0 0 12 0.0000 4 135 1155 2925 4875 Renormalization\001 155 | 4 1 0 50 0 1 12 0.0000 4 90 90 3825 225 a\001 156 | 4 1 0 50 0 0 7 0.0000 4 60 45 3900 300 3\001 157 | 4 1 0 50 0 1 12 0.0000 4 90 90 2925 225 a\001 158 | 4 1 0 50 0 0 7 0.0000 4 60 45 3000 300 2\001 159 | 4 1 0 50 0 1 12 0.0000 4 90 90 2025 225 a\001 160 | 4 1 0 50 0 0 7 0.0000 4 60 45 2100 300 1\001 161 | 4 1 0 50 0 1 12 0.0000 4 90 90 1125 225 a\001 162 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 1125 b\001 163 | 4 1 0 50 0 0 7 0.0000 4 60 45 225 1200 0\001 164 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 1725 b\001 165 | 4 1 0 50 0 0 7 0.0000 4 60 45 225 1800 1\001 166 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 2325 b\001 167 | 4 1 0 50 0 0 7 0.0000 4 60 45 225 2400 2\001 168 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 2925 b\001 169 | 4 1 0 50 0 0 9 0.0000 4 105 75 225 3000 3\001 170 | 4 1 0 50 0 0 7 0.0000 4 60 45 1200 300 0\001 171 | 4 1 0 50 0 1 12 0.0000 4 90 75 1425 5625 s\001 172 | 4 1 0 50 0 0 7 0.0000 4 60 45 1500 5700 0\001 173 | 4 1 0 50 0 1 12 0.0000 4 90 75 2325 5625 s\001 174 | 4 1 0 50 0 0 7 0.0000 4 60 45 2400 5700 1\001 175 | 4 1 0 50 0 1 12 0.0000 4 90 75 3225 5625 s\001 176 | 4 1 0 50 0 0 7 0.0000 4 60 45 3300 5700 2\001 177 | 4 1 0 50 0 1 12 0.0000 4 90 75 4125 5625 s\001 178 | 4 1 0 50 0 0 7 0.0000 4 60 45 4200 5700 3\001 179 | -------------------------------------------------------------------------------- /docs/qd_add_qd_d.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 900 900 1200 1200 11 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 12 | 900 900 1200 900 1200 1200 900 1200 900 900 13 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 14 | 975 1050 1125 1050 15 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 16 | 1050 975 1050 1125 17 | -6 18 | 6 1800 900 2100 1200 19 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 20 | 1800 900 2100 900 2100 1200 1800 1200 1800 900 21 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 22 | 1875 1050 2025 1050 23 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 24 | 1950 975 1950 1125 25 | -6 26 | 6 2700 900 3000 1200 27 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 28 | 2700 900 3000 900 3000 1200 2700 1200 2700 900 29 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 30 | 2775 1050 2925 1050 31 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 32 | 2850 975 2850 1125 33 | -6 34 | 6 3600 900 3900 1200 35 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 36 | 3600 900 3900 900 3900 1200 3600 1200 3600 900 37 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 38 | 3675 1050 3825 1050 39 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 40 | 3750 975 3750 1125 41 | -6 42 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 43 | 1 1 1.00 60.00 120.00 44 | 300 1050 900 1050 45 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 46 | 1 1 1.00 60.00 120.00 47 | 1200 1050 1800 1050 48 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 49 | 1 1 1.00 60.00 120.00 50 | 2100 1050 2700 1050 51 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 52 | 1 1 1.00 60.00 120.00 53 | 3000 1050 3600 1050 54 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 55 | 1 1 1.00 60.00 120.00 56 | 1050 1200 1050 1800 57 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 58 | 1 1 1.00 60.00 120.00 59 | 1950 1200 1950 1800 60 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 61 | 1 1 1.00 60.00 120.00 62 | 2850 1200 2850 1800 63 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 64 | 1 1 1.00 60.00 120.00 65 | 3750 1200 3750 1800 66 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 67 | 1 1 1.00 60.00 120.00 68 | 3900 1050 4500 1050 4500 1800 69 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 70 | 1 1 1.00 60.00 120.00 71 | 1050 300 1050 900 72 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 73 | 1 1 1.00 60.00 120.00 74 | 1950 300 1950 900 75 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 76 | 1 1 1.00 60.00 120.00 77 | 2850 300 2850 900 78 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 79 | 1 1 1.00 60.00 120.00 80 | 3750 300 3750 900 81 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 82 | 750 1800 4800 1800 4800 2100 750 2100 750 1800 83 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 84 | 1 1 1.00 60.00 120.00 85 | 1350 2100 1350 2700 86 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 87 | 1 1 1.00 60.00 120.00 88 | 2250 2100 2250 2700 89 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 90 | 1 1 1.00 60.00 120.00 91 | 3150 2100 3150 2700 92 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 93 | 1 1 1.00 60.00 120.00 94 | 4050 2100 4050 2700 95 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 1125 b\001 96 | 4 1 0 50 0 0 12 0.0000 4 135 1155 2700 2025 Renormalization\001 97 | 4 1 0 50 0 1 12 0.0000 4 90 90 1050 225 a\001 98 | 4 1 0 50 0 0 7 0.0000 4 60 45 1125 300 0\001 99 | 4 1 0 50 0 1 12 0.0000 4 90 90 1950 225 a\001 100 | 4 1 0 50 0 0 7 0.0000 4 60 45 2025 300 1\001 101 | 4 1 0 50 0 1 12 0.0000 4 90 90 2850 225 a\001 102 | 4 1 0 50 0 0 7 0.0000 4 60 45 2925 300 2\001 103 | 4 1 0 50 0 1 12 0.0000 4 90 90 3750 225 a\001 104 | 4 1 0 50 0 0 7 0.0000 4 60 45 3825 300 3\001 105 | 4 1 0 50 0 1 12 0.0000 4 90 75 4050 2850 s\001 106 | 4 1 0 50 0 0 7 0.0000 4 60 45 4125 2925 3\001 107 | 4 1 0 50 0 1 12 0.0000 4 90 75 3150 2850 s\001 108 | 4 1 0 50 0 0 7 0.0000 4 60 45 3225 2925 2\001 109 | 4 1 0 50 0 0 7 0.0000 4 60 45 2325 2925 1\001 110 | 4 1 0 50 0 1 12 0.0000 4 90 75 1350 2850 s\001 111 | 4 1 0 50 0 0 7 0.0000 4 60 45 1425 2925 0\001 112 | 4 1 0 50 0 1 12 0.0000 4 90 75 2250 2850 s\001 113 | -------------------------------------------------------------------------------- /docs/qd_mul_accum.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 4500 4350 4650 4500 11 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 12 | 4500 4425 4650 4425 13 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 14 | 4575 4350 4575 4500 15 | -6 16 | 6 3600 2850 3750 3000 17 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 18 | 3600 2925 3750 2925 19 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 20 | 3675 2850 3675 3000 21 | -6 22 | 6 2700 1575 2850 1725 23 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 24 | 2700 1650 2850 1650 25 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 26 | 2775 1575 2775 1725 27 | -6 28 | 6 2250 675 2400 825 29 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 30 | 2250 750 2400 750 31 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 32 | 2325 675 2325 825 33 | -6 34 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 35 | 1 1 1.00 60.00 120.00 36 | 1125 600 2175 600 37 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 38 | 2175 450 2475 450 2475 1050 2175 1050 2175 450 39 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 40 | 1 1 1.00 60.00 120.00 41 | 1125 900 2175 900 42 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 43 | 1 1 1.00 60.00 120.00 44 | 2475 600 2775 600 2775 1200 45 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 46 | 1 1 1.00 60.00 120.00 47 | 1125 1350 2625 1350 48 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 49 | 1 1 1.00 60.00 120.00 50 | 1125 1500 2625 1500 51 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 52 | 1 1 1.00 60.00 120.00 53 | 1125 1650 2625 1650 54 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 55 | 1 1 1.00 60.00 120.00 56 | 1125 1800 2625 1800 57 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 58 | 1 1 1.00 60.00 120.00 59 | 1125 1950 2625 1950 60 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 61 | 2625 1200 2925 1200 2925 2100 2625 2100 2625 1200 62 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 63 | 1 1 1.00 60.00 120.00 64 | 1125 2550 3525 2550 65 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 66 | 1 1 1.00 60.00 120.00 67 | 1125 2700 3525 2700 68 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 69 | 1 1 1.00 60.00 120.00 70 | 1125 2850 3525 2850 71 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 72 | 1 1 1.00 60.00 120.00 73 | 1125 3000 3525 3000 74 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 75 | 1 1 1.00 60.00 120.00 76 | 1125 3150 3525 3150 77 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 78 | 1 1 1.00 60.00 120.00 79 | 1125 3300 3525 3300 80 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 81 | 1 1 1.00 60.00 120.00 82 | 1125 3450 3525 3450 83 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 84 | 1 1 1.00 60.00 120.00 85 | 2475 900 3675 900 3675 2250 86 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 87 | 1 1 1.00 60.00 120.00 88 | 2925 1500 3225 1500 3225 2400 3525 2400 89 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 90 | 1 1 1.00 60.00 120.00 91 | 3825 2925 4125 2925 4125 3900 4425 3900 92 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 93 | 1 1 1.00 60.00 120.00 94 | 2925 1800 4575 1800 4575 3750 95 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 96 | 3525 2250 3825 2250 3825 3600 3525 3600 3525 2250 97 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 98 | 1 1 1.00 60.00 120.00 99 | 1125 4050 4425 4050 100 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 101 | 1 1 1.00 60.00 120.00 102 | 1125 4200 4425 4200 103 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 104 | 1 1 1.00 60.00 120.00 105 | 1125 4350 4425 4350 106 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 107 | 1 1 1.00 60.00 120.00 108 | 1125 4500 4425 4500 109 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 110 | 1 1 1.00 60.00 120.00 111 | 1125 4650 4425 4650 112 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 113 | 1 1 1.00 60.00 120.00 114 | 1125 4800 4425 4800 115 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 116 | 1 1 1.00 60.00 120.00 117 | 1125 4950 4425 4950 118 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 119 | 4425 3750 4725 3750 4725 5100 4425 5100 4425 3750 120 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 121 | 1 1 1.00 60.00 120.00 122 | 1125 150 1575 150 1575 5550 123 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 124 | 1 1 1.00 60.00 120.00 125 | 2325 1050 2325 5550 126 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 127 | 1 1 1.00 60.00 120.00 128 | 2775 2100 2775 5550 129 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 130 | 1 1 1.00 60.00 120.00 131 | 3675 3600 3675 5550 132 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 133 | 1 1 1.00 60.00 120.00 134 | 4575 5100 4575 5550 135 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 136 | 1275 5550 4875 5550 4875 5850 1275 5850 1275 5550 137 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 138 | 1 1 1.00 60.00 120.00 139 | 1725 5850 1725 6450 140 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 141 | 1 1 1.00 60.00 120.00 142 | 2625 5850 2625 6450 143 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 144 | 1 1 1.00 60.00 120.00 145 | 3525 5850 3525 6450 146 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 147 | 1 1 1.00 60.00 120.00 148 | 4425 5850 4425 6450 149 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 150 | 1 1 1.00 60.00 120.00 151 | 1125 750 2175 750 152 | 4 1 0 50 0 0 12 0.0000 4 135 1155 3075 5775 Renormalization\001 153 | 4 1 0 50 0 0 12 0.0000 4 165 60 300 225 (\001 154 | 4 1 0 50 0 1 12 0.0000 4 135 135 225 225 O\001 155 | 4 1 0 50 0 0 12 0.0000 4 165 60 450 225 )\001 156 | 4 1 0 50 0 0 12 0.0000 4 135 90 375 225 1\001 157 | 4 1 0 50 0 0 12 0.0000 4 120 315 750 225 term\001 158 | 4 1 0 50 0 1 12 0.0000 4 135 135 225 825 O\001 159 | 4 1 0 50 0 0 12 0.0000 4 120 390 750 825 terms\001 160 | 4 1 0 50 0 1 12 0.0000 4 135 135 150 1725 O\001 161 | 4 1 0 50 0 32 12 0.0000 4 90 75 300 1725 e\001 162 | 4 1 0 50 0 0 7 0.0000 4 60 45 375 1650 2\001 163 | 4 1 0 50 0 0 12 0.0000 4 120 390 750 1725 terms\001 164 | 4 1 0 50 0 1 12 0.0000 4 135 135 150 3075 O\001 165 | 4 1 0 50 0 32 12 0.0000 4 90 75 300 3075 e\001 166 | 4 1 0 50 0 0 7 0.0000 4 60 45 375 3000 3\001 167 | 4 1 0 50 0 0 12 0.0000 4 120 390 750 3075 terms\001 168 | 4 1 0 50 0 1 12 0.0000 4 135 135 150 4575 O\001 169 | 4 1 0 50 0 32 12 0.0000 4 90 75 300 4575 e\001 170 | 4 1 0 50 0 0 7 0.0000 4 60 45 375 4500 4\001 171 | 4 1 0 50 0 0 12 0.0000 4 120 390 750 4575 terms\001 172 | 4 1 0 50 0 1 12 0.0000 4 135 135 3075 1425 O\001 173 | 4 1 0 50 0 32 12 0.0000 4 90 75 3225 1425 e\001 174 | 4 1 0 50 0 0 7 0.0000 4 60 45 3300 1350 3\001 175 | 4 1 0 50 0 1 12 0.0000 4 135 135 4200 1725 O\001 176 | 4 1 0 50 0 32 12 0.0000 4 90 75 4350 1725 e\001 177 | 4 1 0 50 0 0 7 0.0000 4 60 45 4425 1650 4\001 178 | 4 1 0 50 0 1 12 0.0000 4 135 135 3300 825 O\001 179 | 4 1 0 50 0 32 12 0.0000 4 90 75 3450 825 e\001 180 | 4 1 0 50 0 0 7 0.0000 4 60 45 3525 750 3\001 181 | 4 1 0 50 0 1 12 0.0000 4 135 135 2625 525 O\001 182 | 4 1 0 50 0 32 12 0.0000 4 90 75 2775 525 e\001 183 | 4 1 0 50 0 0 7 0.0000 4 60 45 2850 450 2\001 184 | 4 1 0 50 0 1 12 0.0000 4 135 135 3975 2850 O\001 185 | 4 1 0 50 0 32 12 0.0000 4 90 75 4125 2850 e\001 186 | 4 1 0 50 0 0 7 0.0000 4 60 45 4200 2775 4\001 187 | 4 1 0 50 0 1 12 0.0000 4 90 75 4425 6600 s\001 188 | 4 1 0 50 0 0 7 0.0000 4 60 45 4500 6675 3\001 189 | 4 1 0 50 0 1 12 0.0000 4 90 75 3525 6600 s\001 190 | 4 1 0 50 0 0 7 0.0000 4 60 45 3600 6675 2\001 191 | 4 1 0 50 0 0 7 0.0000 4 60 45 2700 6675 1\001 192 | 4 1 0 50 0 1 12 0.0000 4 90 75 2625 6600 s\001 193 | 4 1 0 50 0 1 12 0.0000 4 90 75 1725 6600 s\001 194 | 4 1 0 50 0 0 7 0.0000 4 60 45 1800 6675 0\001 195 | 4 1 0 50 0 0 12 0.0000 4 165 60 300 825 (\001 196 | 4 1 0 50 0 0 12 0.0000 4 165 60 225 1725 (\001 197 | 4 1 0 50 0 0 12 0.0000 4 165 60 225 3075 (\001 198 | 4 1 0 50 0 0 12 0.0000 4 165 60 225 4575 (\001 199 | 4 1 0 50 0 0 12 0.0000 4 165 60 4050 2850 (\001 200 | 4 1 0 50 0 0 12 0.0000 4 165 60 4275 1725 (\001 201 | 4 1 0 50 0 0 12 0.0000 4 165 60 3150 1425 (\001 202 | 4 1 0 50 0 0 12 0.0000 4 165 60 3375 825 (\001 203 | 4 1 0 50 0 0 12 0.0000 4 165 60 2700 525 (\001 204 | 4 1 0 50 0 0 12 0.0000 4 165 60 450 825 )\001 205 | 4 1 0 50 0 0 12 0.0000 4 165 60 450 1725 )\001 206 | 4 1 0 50 0 0 12 0.0000 4 165 60 450 3075 )\001 207 | 4 1 0 50 0 0 12 0.0000 4 165 60 450 4575 )\001 208 | 4 1 0 50 0 0 12 0.0000 4 165 60 4275 2850 )\001 209 | 4 1 0 50 0 0 12 0.0000 4 165 60 4500 1725 )\001 210 | 4 1 0 50 0 0 12 0.0000 4 165 60 3375 1425 )\001 211 | 4 1 0 50 0 0 12 0.0000 4 165 60 3600 825 )\001 212 | 4 1 0 50 0 0 12 0.0000 4 165 60 2925 525 )\001 213 | 4 1 0 50 0 32 12 0.0000 4 90 75 375 825 e\001 214 | -------------------------------------------------------------------------------- /docs/qd_mul_qd_d.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 1800 975 2100 1275 11 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 12 | 1800 975 2100 975 2100 1275 1800 1275 1800 975 13 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 14 | 1875 1050 2025 1200 15 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 16 | 2025 1050 1875 1200 17 | -6 18 | 6 2700 1575 3000 1875 19 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 20 | 2700 1575 3000 1575 3000 1875 2700 1875 2700 1575 21 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 22 | 2775 1650 2925 1800 23 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 24 | 2925 1650 2775 1800 25 | -6 26 | 6 3600 2175 3900 2475 27 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 28 | 3600 2175 3900 2175 3900 2475 3600 2475 3600 2175 29 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 30 | 3675 2250 3825 2400 31 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 32 | 3825 2250 3675 2400 33 | -6 34 | 6 2700 3975 3000 4275 35 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 36 | 2700 3975 3000 3975 3000 4275 2700 4275 2700 3975 37 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 38 | 2775 4125 2925 4125 39 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 40 | 2850 4050 2850 4200 41 | -6 42 | 6 4500 2775 4800 3075 43 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 4650 2925 150 150 4650 2925 4800 2925 44 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 45 | 4575 2850 4725 3000 46 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 47 | 4725 2850 4575 3000 48 | -6 49 | 6 5250 3975 5550 4275 50 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 5400 4125 150 150 5400 4125 5550 4125 51 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 52 | 5325 4125 5475 4125 53 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 54 | 5400 4050 5400 4200 55 | -6 56 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 57 | 1 1 1.00 60.00 120.00 58 | 1950 375 1950 975 59 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 60 | 1 1 1.00 60.00 120.00 61 | 2100 1125 2400 1125 2400 4125 2700 4125 62 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 63 | 1 1 1.00 60.00 120.00 64 | 2850 375 2850 1575 65 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 66 | 1 1 1.00 60.00 120.00 67 | 3750 375 3750 2175 68 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 69 | 1 1 1.00 60.00 120.00 70 | 2850 1875 2850 3975 71 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 72 | 1 1 1.00 60.00 120.00 73 | 3000 1725 3300 1725 3300 3825 3600 3825 74 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 75 | 1 1 1.00 60.00 120.00 76 | 3750 2475 3750 3675 77 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 78 | 1 1 1.00 60.00 120.00 79 | 3900 2325 4200 2325 4200 3525 4500 3525 80 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 81 | 1 1 1.00 60.00 120.00 82 | 3000 4125 3600 4125 83 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 84 | 3750 3900 3750 4050 85 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 86 | 3675 3975 3825 3975 87 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 88 | 3600 3675 3900 3675 3900 4275 3600 4275 3600 3675 89 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 90 | 1 1 1.00 60.00 120.00 91 | 3900 3825 4500 3825 92 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 93 | 4500 3375 4800 3375 4800 3975 4500 3975 4500 3375 94 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 95 | 1 1 1.00 60.00 120.00 96 | 4650 375 4650 2775 97 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 98 | 1 1 1.00 60.00 120.00 99 | 4650 3075 4650 3375 100 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 101 | 4575 3675 4725 3675 102 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 103 | 4650 3600 4650 3750 104 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 105 | 1 1 1.00 60.00 120.00 106 | 4800 3675 5400 3675 5400 3975 107 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 108 | 1 1 1.00 60.00 120.00 109 | 3900 4125 5250 4125 110 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 111 | 1 1 1.00 60.00 120.00 112 | 2850 4275 2850 4875 113 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 114 | 1 1 1.00 60.00 120.00 115 | 1950 1275 1950 4875 116 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 117 | 1 1 1.00 60.00 120.00 118 | 3750 4275 3750 4875 119 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 120 | 1 1 1.00 60.00 120.00 121 | 4650 3975 4650 4875 122 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 123 | 1 1 1.00 60.00 120.00 124 | 5400 4275 5400 4875 125 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 126 | 1650 4875 5700 4875 5700 5175 1650 5175 1650 4875 127 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 128 | 1 1 1.00 60.00 120.00 129 | 2400 5175 2400 5775 130 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 131 | 1 1 1.00 60.00 120.00 132 | 3300 5175 3300 5775 133 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 134 | 1 1 1.00 60.00 120.00 135 | 4200 5175 4200 5775 136 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 137 | 1 1 1.00 60.00 120.00 138 | 5100 5175 5100 5775 139 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 140 | 1 1 1.00 60.00 120.00 141 | 825 2100 1275 1125 1800 1125 142 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 143 | 1 1 1.00 60.00 120.00 144 | 825 2100 1275 1725 2700 1725 145 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 146 | 1 1 1.00 60.00 120.00 147 | 825 2100 1275 2325 3600 2325 148 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 149 | 1 1 1.00 60.00 120.00 150 | 825 2100 1275 2925 4500 2925 151 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 152 | 225 2100 825 2100 153 | 4 1 0 50 0 0 12 0.0000 4 135 1155 3600 5100 Renormalization\001 154 | 4 1 0 50 0 1 12 0.0000 4 90 90 1950 225 a\001 155 | 4 1 0 50 0 0 7 0.0000 4 60 45 2025 300 0\001 156 | 4 1 0 50 0 0 7 0.0000 4 60 45 2925 300 1\001 157 | 4 1 0 50 0 1 12 0.0000 4 90 90 2850 225 a\001 158 | 4 1 0 50 0 1 12 0.0000 4 90 90 3750 225 a\001 159 | 4 1 0 50 0 0 7 0.0000 4 60 45 3825 300 2\001 160 | 4 1 0 50 0 1 12 0.0000 4 90 90 4650 225 a\001 161 | 4 1 0 50 0 0 7 0.0000 4 60 45 4725 300 3\001 162 | 4 1 0 50 0 1 12 0.0000 4 90 75 3300 5925 s\001 163 | 4 1 0 50 0 1 12 0.0000 4 90 75 2400 5925 s\001 164 | 4 1 0 50 0 0 7 0.0000 4 60 45 2475 6000 0\001 165 | 4 1 0 50 0 1 12 0.0000 4 90 75 4200 5925 s\001 166 | 4 1 0 50 0 0 7 0.0000 4 60 45 4275 6000 2\001 167 | 4 1 0 50 0 1 12 0.0000 4 90 75 5100 5925 s\001 168 | 4 1 0 50 0 0 7 0.0000 4 60 45 5175 6000 3\001 169 | 4 1 0 50 0 1 12 0.0000 4 135 90 75 2175 b\001 170 | 4 1 0 50 0 0 7 0.0000 4 60 45 3375 6000 1\001 171 | -------------------------------------------------------------------------------- /docs/quick-two-sum.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: quick-two-sum.eps 3 | %%Creator: fig2dev Version 3.2.3 Patchlevel 4 | %%CreationDate: Tue Aug 1 15:41:53 2000 5 | %%For: yozo@n2001.lbl.gov () 6 | %%BoundingBox: 0 0 130 130 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 130 moveto 0 0 lineto 130 0 lineto 130 130 lineto closepath clip newpath 49 | % Fill background color 50 | 0 0 moveto 130 0 lineto 130 130 lineto 0 130 lineto 51 | closepath 1.00 1.00 1.00 setrgbcolor fill 52 | 53 | 9.0 123.0 translate 54 | 1 -1 scale 55 | 56 | /cp {closepath} bind def 57 | /ef {eofill} bind def 58 | /gr {grestore} bind def 59 | /gs {gsave} bind def 60 | /sa {save} bind def 61 | /rs {restore} bind def 62 | /l {lineto} bind def 63 | /m {moveto} bind def 64 | /rm {rmoveto} bind def 65 | /n {newpath} bind def 66 | /s {stroke} bind def 67 | /sh {show} bind def 68 | /slc {setlinecap} bind def 69 | /slj {setlinejoin} bind def 70 | /slw {setlinewidth} bind def 71 | /srgb {setrgbcolor} bind def 72 | /rot {rotate} bind def 73 | /sc {scale} bind def 74 | /sd {setdash} bind def 75 | /ff {findfont} bind def 76 | /sf {setfont} bind def 77 | /scf {scalefont} bind def 78 | /sw {stringwidth} bind def 79 | /tr {translate} bind def 80 | /tnt {dup dup currentrgbcolor 81 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 82 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 83 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 84 | bind def 85 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 86 | 4 -2 roll mul srgb} bind def 87 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 88 | /$F2psEnd {$F2psEnteredState restore end} def 89 | 90 | $F2psBegin 91 | %%Page: 1 1 92 | 10 setmiterlimit 93 | 0.06000 0.06000 sc 94 | % Polyline 95 | 7.500 slw 96 | gs clippath 97 | 870 840 m 930 840 l 930 689 l 900 809 l 870 689 l cp 98 | eoclip 99 | n 900 225 m 100 | 900 825 l gs col0 s gr gr 101 | 102 | % arrowhead 103 | n 870 689 m 900 809 l 930 689 l 870 689 l cp gs 0.00 setgray ef gr col0 s 104 | % Polyline 105 | gs clippath 106 | 765 1005 m 765 945 l 614 945 l 734 975 l 614 1005 l cp 107 | eoclip 108 | n 150 975 m 109 | 750 975 l gs col0 s gr gr 110 | 111 | % arrowhead 112 | n 614 1005 m 734 975 l 614 945 l 614 1005 l cp gs 0.00 setgray ef gr col0 s 113 | % Polyline 114 | gs clippath 115 | 870 1740 m 930 1740 l 930 1589 l 900 1709 l 870 1589 l cp 116 | eoclip 117 | n 900 1125 m 118 | 900 1725 l gs col0 s gr gr 119 | 120 | % arrowhead 121 | n 870 1589 m 900 1709 l 930 1589 l 870 1589 l cp gs 0.00 setgray ef gr col0 s 122 | % Polyline 123 | gs clippath 124 | 1665 1005 m 1665 945 l 1514 945 l 1634 975 l 1514 1005 l cp 125 | eoclip 126 | n 1050 975 m 127 | 1650 975 l gs col0 s gr gr 128 | 129 | % arrowhead 130 | n 1514 1005 m 1634 975 l 1514 945 l 1514 1005 l cp gs 0.00 setgray ef gr col0 s 131 | /Times-Italic ff 180.00 scf sf 132 | 900 150 m 133 | gs 1 -1 sc (a) dup sw pop 2 div neg 0 rm col0 sh gr 134 | /Times-Italic ff 180.00 scf sf 135 | 75 1050 m 136 | gs 1 -1 sc (b) dup sw pop 2 div neg 0 rm col0 sh gr 137 | /Times-Italic ff 180.00 scf sf 138 | 900 1875 m 139 | gs 1 -1 sc (s) dup sw pop 2 div neg 0 rm col0 sh gr 140 | /Times-Italic ff 180.00 scf sf 141 | 1800 1050 m 142 | gs 1 -1 sc (e) dup sw pop 2 div neg 0 rm col0 sh gr 143 | % Polyline 144 | n 900 1125 m 1050 975 l 900 825 l 750 975 l 145 | cp gs col0 s gr 146 | % Polyline 147 | n 825 975 m 148 | 975 975 l gs col0 s gr 149 | % Polyline 150 | n 900 900 m 151 | 900 1050 l gs col0 s gr 152 | $F2psEnd 153 | rs 154 | -------------------------------------------------------------------------------- /docs/quick-two-sum.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 11 | 1 1 1.00 60.00 120.00 12 | 900 225 900 825 13 | 2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 14 | 1 1 1.00 60.00 120.00 15 | 150 975 750 975 16 | 2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 17 | 1 1 1.00 60.00 120.00 18 | 900 1125 900 1725 19 | 2 1 0 1 0 7 100 0 -1 0.000 0 0 -1 1 0 2 20 | 1 1 1.00 60.00 120.00 21 | 1050 975 1650 975 22 | 2 3 0 1 0 7 50 0 -1 0.000 0 0 0 0 0 5 23 | 900 1125 1050 975 900 825 750 975 900 1125 24 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 25 | 825 975 975 975 26 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 27 | 900 900 900 1050 28 | 4 1 0 100 0 1 12 0.0000 4 90 90 900 150 a\001 29 | 4 1 0 100 0 1 12 0.0000 4 135 90 75 1050 b\001 30 | 4 1 0 100 0 1 12 0.0000 4 90 75 900 1875 s\001 31 | 4 1 0 100 0 1 12 0.0000 4 90 75 1800 1050 e\001 32 | -------------------------------------------------------------------------------- /docs/six-three-sum.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 2850 4500 3000 4650 11 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 12 | 2925 4500 2925 4650 13 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 14 | 2850 4575 3000 4575 15 | -6 16 | 6 3750 4350 3900 4500 17 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 18 | 3825 4350 3825 4500 19 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 20 | 3750 4425 3900 4425 21 | -6 22 | 6 3750 3600 3900 3750 23 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 24 | 3825 3600 3825 3750 25 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 26 | 3750 3675 3900 3675 27 | -6 28 | 6 1950 2400 2100 2550 29 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 30 | 2025 2400 2025 2550 31 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 32 | 1950 2475 2100 2475 33 | -6 34 | 6 2850 3000 3000 3150 35 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 36 | 2925 3000 2925 3150 37 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 38 | 2850 3075 3000 3075 39 | -6 40 | 6 750 1800 900 1950 41 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 42 | 825 1800 825 1950 43 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 44 | 750 1875 900 1875 45 | -6 46 | 6 750 600 900 750 47 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 48 | 825 600 825 750 49 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 50 | 750 675 900 675 51 | -6 52 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 3825 3675 150 150 3825 3675 3975 3675 53 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 54 | 675 375 975 375 975 975 675 975 675 375 55 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 56 | 1 1 1.00 60.00 120.00 57 | 75 525 675 525 58 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 59 | 1 1 1.00 60.00 120.00 60 | 75 825 675 825 61 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 62 | 1 1 1.00 60.00 120.00 63 | 75 675 675 675 64 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 65 | 675 1575 975 1575 975 2175 675 2175 675 1575 66 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 67 | 1 1 1.00 60.00 120.00 68 | 75 1725 675 1725 69 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 70 | 1 1 1.00 60.00 120.00 71 | 75 1875 675 1875 72 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 73 | 1 1 1.00 60.00 120.00 74 | 75 2025 675 2025 75 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 76 | 1 1 1.00 60.00 120.00 77 | 825 2175 825 2475 1875 2475 78 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 79 | 1875 2325 2175 2325 2175 2625 1875 2625 1875 2325 80 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 81 | 2775 2925 3075 2925 3075 3225 2775 3225 2775 2925 82 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 83 | 1 1 1.00 60.00 120.00 84 | 975 2025 1275 2025 1275 3675 3675 3675 85 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 86 | 1 1 1.00 60.00 120.00 87 | 975 1725 1575 1725 1575 3075 2775 3075 88 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 89 | 1 1 1.00 60.00 120.00 90 | 825 975 825 1275 2025 1275 2025 2325 91 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 92 | 1 1 1.00 60.00 120.00 93 | 975 825 3825 825 3825 3525 94 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 95 | 1 1 1.00 60.00 120.00 96 | 975 525 2925 525 2925 2925 97 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 98 | 1 1 1.00 60.00 120.00 99 | 2175 2475 2475 2475 2475 4575 2775 4575 100 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 101 | 1 1 1.00 60.00 120.00 102 | 2925 3225 2925 4425 103 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 104 | 1 1 1.00 60.00 120.00 105 | 3075 3075 3375 3075 3375 4275 3675 4275 106 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 107 | 2775 4425 3075 4425 3075 4725 2775 4725 2775 4425 108 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 109 | 1 1 1.00 60.00 120.00 110 | 3075 4575 3675 4575 111 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 112 | 3675 4125 3975 4125 3975 4725 3675 4725 3675 4125 113 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 114 | 1 1 1.00 60.00 120.00 115 | 3825 3825 3825 4125 116 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 117 | 1 1 1.00 60.00 120.00 118 | 2025 2625 2025 5925 119 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 120 | 1 1 1.00 60.00 120.00 121 | 2925 4725 2925 5025 4575 5025 122 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 123 | 1 1 1.00 60.00 120.00 124 | 3825 4725 3825 5325 4575 5325 125 | 2 2 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 126 | 375 75 4275 75 4275 5625 375 5625 375 75 127 | -------------------------------------------------------------------------------- /docs/three-sum-2.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: three-sum-2.eps 3 | %%Creator: fig2dev Version 3.2.3 Patchlevel 4 | %%CreationDate: Thu Oct 12 10:29:57 2000 5 | %%For: xiaoye@scg1 (Sherry Li) 6 | %%BoundingBox: 0 0 144 150 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 150 moveto 0 0 lineto 144 0 lineto 144 150 lineto closepath clip newpath 49 | -6.0 158.0 translate 50 | 1 -1 scale 51 | 52 | /cp {closepath} bind def 53 | /ef {eofill} bind def 54 | /gr {grestore} bind def 55 | /gs {gsave} bind def 56 | /sa {save} bind def 57 | /rs {restore} bind def 58 | /l {lineto} bind def 59 | /m {moveto} bind def 60 | /rm {rmoveto} bind def 61 | /n {newpath} bind def 62 | /s {stroke} bind def 63 | /sh {show} bind def 64 | /slc {setlinecap} bind def 65 | /slj {setlinejoin} bind def 66 | /slw {setlinewidth} bind def 67 | /srgb {setrgbcolor} bind def 68 | /rot {rotate} bind def 69 | /sc {scale} bind def 70 | /sd {setdash} bind def 71 | /ff {findfont} bind def 72 | /sf {setfont} bind def 73 | /scf {scalefont} bind def 74 | /sw {stringwidth} bind def 75 | /tr {translate} bind def 76 | /tnt {dup dup currentrgbcolor 77 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 78 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 79 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 80 | bind def 81 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 82 | 4 -2 roll mul srgb} bind def 83 | /DrawEllipse { 84 | /endangle exch def 85 | /startangle exch def 86 | /yrad exch def 87 | /xrad exch def 88 | /y exch def 89 | /x exch def 90 | /savematrix mtrx currentmatrix def 91 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 92 | closepath 93 | savematrix setmatrix 94 | } def 95 | 96 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 97 | /$F2psEnd {$F2psEnteredState restore end} def 98 | 99 | $F2psBegin 100 | %%Page: 1 1 101 | 10 setmiterlimit 102 | 0.06000 0.06000 sc 103 | % Polyline 104 | 7.500 slw 105 | n 825 900 m 1125 900 l 1125 1200 l 825 1200 l 106 | cp gs col0 s gr 107 | % Polyline 108 | n 975 975 m 109 | 975 1125 l gs col0 s gr 110 | % Polyline 111 | n 900 1050 m 112 | 1050 1050 l gs col0 s gr 113 | % Polyline 114 | n 825 1500 m 1125 1500 l 1125 1800 l 825 1800 l 115 | cp gs col0 s gr 116 | % Polyline 117 | n 975 1575 m 118 | 975 1725 l gs col0 s gr 119 | % Polyline 120 | n 900 1650 m 121 | 1050 1650 l gs col0 s gr 122 | % Ellipse 123 | n 1575 1650 150 150 0 360 DrawEllipse gs col0 s gr 124 | 125 | % Polyline 126 | n 1500 1650 m 127 | 1650 1650 l gs col0 s gr 128 | % Polyline 129 | n 1575 1575 m 130 | 1575 1725 l gs col0 s gr 131 | /Times-Italic ff 180.00 scf sf 132 | 975 2550 m 133 | gs 1 -1 sc (r) dup sw pop 2 div neg 0 rm col0 sh gr 134 | /Times-Roman ff 105.00 scf sf 135 | 1050 2625 m 136 | gs 1 -1 sc (0) dup sw pop 2 div neg 0 rm col0 sh gr 137 | /Times-Italic ff 180.00 scf sf 138 | 2400 1650 m 139 | gs 1 -1 sc (r) dup sw pop 2 div neg 0 rm col0 sh gr 140 | /Times-Roman ff 105.00 scf sf 141 | 2475 1725 m 142 | gs 1 -1 sc (1) dup sw pop 2 div neg 0 rm col0 sh gr 143 | % Polyline 144 | gs clippath 145 | 945 1515 m 1005 1515 l 1005 1364 l 975 1484 l 945 1364 l cp 146 | eoclip 147 | n 975 1200 m 148 | 975 1500 l gs col0 s gr gr 149 | 150 | % arrowhead 151 | n 945 1364 m 975 1484 l 1005 1364 l 945 1364 l cp gs 0.00 setgray ef gr col0 s 152 | % Polyline 153 | gs clippath 154 | 1545 1515 m 1605 1515 l 1605 1364 l 1575 1484 l 1545 1364 l cp 155 | eoclip 156 | n 1125 1050 m 1575 1050 l 157 | 1575 1500 l gs col0 s gr gr 158 | 159 | % arrowhead 160 | n 1545 1364 m 1575 1484 l 1605 1364 l 1545 1364 l cp gs 0.00 setgray ef gr col0 s 161 | % Polyline 162 | gs clippath 163 | 1440 1680 m 1440 1620 l 1289 1620 l 1409 1650 l 1289 1680 l cp 164 | eoclip 165 | n 1125 1650 m 166 | 1425 1650 l gs col0 s gr gr 167 | 168 | % arrowhead 169 | n 1289 1680 m 1409 1650 l 1289 1620 l 1289 1680 l cp gs 0.00 setgray ef gr col0 s 170 | % Polyline 171 | gs clippath 172 | 945 2415 m 1005 2415 l 1005 2264 l 975 2384 l 945 2264 l cp 173 | eoclip 174 | n 975 1800 m 175 | 975 2400 l gs col0 s gr gr 176 | 177 | % arrowhead 178 | n 945 2264 m 975 2384 l 1005 2264 l 945 2264 l cp gs 0.00 setgray ef gr col0 s 179 | % Polyline 180 | gs clippath 181 | 2340 1680 m 2340 1620 l 2189 1620 l 2309 1650 l 2189 1680 l cp 182 | eoclip 183 | n 1725 1650 m 184 | 2325 1650 l gs col0 s gr gr 185 | 186 | % arrowhead 187 | n 2189 1680 m 2309 1650 l 2189 1620 l 2189 1680 l cp gs 0.00 setgray ef gr col0 s 188 | % Polyline 189 | gs clippath 190 | 945 915 m 1005 915 l 1005 764 l 975 884 l 945 764 l cp 191 | eoclip 192 | n 975 300 m 193 | 975 900 l gs col0 s gr gr 194 | 195 | % arrowhead 196 | n 945 764 m 975 884 l 1005 764 l 945 764 l cp gs 0.00 setgray ef gr col0 s 197 | % Polyline 198 | gs clippath 199 | 840 1080 m 840 1020 l 689 1020 l 809 1050 l 689 1080 l cp 200 | eoclip 201 | n 225 1050 m 202 | 825 1050 l gs col0 s gr gr 203 | 204 | % arrowhead 205 | n 689 1080 m 809 1050 l 689 1020 l 689 1080 l cp gs 0.00 setgray ef gr col0 s 206 | % Polyline 207 | gs clippath 208 | 840 1680 m 840 1620 l 689 1620 l 809 1650 l 689 1680 l cp 209 | eoclip 210 | n 225 1650 m 211 | 825 1650 l gs col0 s gr gr 212 | 213 | % arrowhead 214 | n 689 1680 m 809 1650 l 689 1620 l 689 1680 l cp gs 0.00 setgray ef gr col0 s 215 | % Polyline 216 | [15 45] 45 sd 217 | n 525 600 m 2025 600 l 2025 2100 l 525 2100 l 218 | cp gs col0 s gr [] 0 sd 219 | /Times-Italic ff 180.00 scf sf 220 | 975 225 m 221 | gs 1 -1 sc (x) dup sw pop 2 div neg 0 rm col0 sh gr 222 | /Times-Italic ff 180.00 scf sf 223 | 150 1050 m 224 | gs 1 -1 sc (y) dup sw pop 2 div neg 0 rm col0 sh gr 225 | /Times-Italic ff 180.00 scf sf 226 | 150 1650 m 227 | gs 1 -1 sc (z) dup sw pop 2 div neg 0 rm col0 sh gr 228 | $F2psEnd 229 | rs 230 | -------------------------------------------------------------------------------- /docs/three-sum-2.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 825 900 1125 1200 11 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 12 | 825 900 1125 900 1125 1200 825 1200 825 900 13 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 14 | 975 975 975 1125 15 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 16 | 900 1050 1050 1050 17 | -6 18 | 6 825 1500 1125 1800 19 | 2 2 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 20 | 825 1500 1125 1500 1125 1800 825 1800 825 1500 21 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 22 | 975 1575 975 1725 23 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 0 0 2 24 | 900 1650 1050 1650 25 | -6 26 | 6 1425 1500 1725 1800 27 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 1575 1650 150 150 1575 1650 1725 1650 28 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 29 | 1500 1650 1650 1650 30 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 31 | 1575 1575 1575 1725 32 | -6 33 | 6 900 2400 1125 2625 34 | 4 1 0 50 0 1 12 0.0000 4 90 75 975 2550 r\001 35 | 4 1 0 50 0 0 7 0.0000 4 60 45 1050 2625 0\001 36 | -6 37 | 6 2325 1500 2550 1725 38 | 4 1 0 50 0 1 12 0.0000 4 90 75 2400 1650 r\001 39 | 4 1 0 50 0 0 7 0.0000 4 60 45 2475 1725 1\001 40 | -6 41 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 42 | 1 1 1.00 60.00 120.00 43 | 975 1200 975 1500 44 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 3 45 | 1 1 1.00 60.00 120.00 46 | 1125 1050 1575 1050 1575 1500 47 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 48 | 1 1 1.00 60.00 120.00 49 | 1125 1650 1425 1650 50 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 51 | 1 1 1.00 60.00 120.00 52 | 975 1800 975 2400 53 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 54 | 1 1 1.00 60.00 120.00 55 | 1725 1650 2325 1650 56 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 57 | 1 1 1.00 60.00 120.00 58 | 975 300 975 900 59 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 60 | 1 1 1.00 60.00 120.00 61 | 225 1050 825 1050 62 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 63 | 1 1 1.00 60.00 120.00 64 | 225 1650 825 1650 65 | 2 2 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 66 | 525 600 2025 600 2025 2100 525 2100 525 600 67 | 4 1 0 50 0 1 12 0.0000 4 90 75 975 225 x\001 68 | 4 1 0 50 0 1 12 0.0000 4 135 75 150 1050 y\001 69 | 4 1 0 50 0 1 12 0.0000 4 90 75 150 1650 z\001 70 | -------------------------------------------------------------------------------- /docs/three-sum-3.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: three-sum-3.eps 3 | %%Creator: fig2dev Version 3.2.3 Patchlevel 4 | %%CreationDate: Sat Oct 7 22:58:56 2000 5 | %%For: yozo@yozo.HIP.Berkeley.EDU (Yozo Hida) 6 | %%BoundingBox: 0 0 101 170 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 170 moveto 0 0 lineto 101 0 lineto 101 170 lineto closepath clip newpath 49 | % Fill background color 50 | 0 0 moveto 101 0 lineto 101 170 lineto 0 170 lineto 51 | closepath 1.00 1.00 1.00 setrgbcolor fill 52 | 53 | 4.0 168.0 translate 54 | 1 -1 scale 55 | 56 | /cp {closepath} bind def 57 | /ef {eofill} bind def 58 | /gr {grestore} bind def 59 | /gs {gsave} bind def 60 | /sa {save} bind def 61 | /rs {restore} bind def 62 | /l {lineto} bind def 63 | /m {moveto} bind def 64 | /rm {rmoveto} bind def 65 | /n {newpath} bind def 66 | /s {stroke} bind def 67 | /sh {show} bind def 68 | /slc {setlinecap} bind def 69 | /slj {setlinejoin} bind def 70 | /slw {setlinewidth} bind def 71 | /srgb {setrgbcolor} bind def 72 | /rot {rotate} bind def 73 | /sc {scale} bind def 74 | /sd {setdash} bind def 75 | /ff {findfont} bind def 76 | /sf {setfont} bind def 77 | /scf {scalefont} bind def 78 | /sw {stringwidth} bind def 79 | /tr {translate} bind def 80 | /tnt {dup dup currentrgbcolor 81 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 82 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 83 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 84 | bind def 85 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 86 | 4 -2 roll mul srgb} bind def 87 | /DrawEllipse { 88 | /endangle exch def 89 | /startangle exch def 90 | /yrad exch def 91 | /xrad exch def 92 | /y exch def 93 | /x exch def 94 | /savematrix mtrx currentmatrix def 95 | x y tr xrad yrad sc 0 0 1 startangle endangle arc 96 | closepath 97 | savematrix setmatrix 98 | } def 99 | 100 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 101 | /$F2psEnd {$F2psEnteredState restore end} def 102 | 103 | $F2psBegin 104 | %%Page: 1 1 105 | 10 setmiterlimit 106 | 0.06000 0.06000 sc 107 | 7.500 slw 108 | % Ellipse 109 | n 975 1050 150 150 0 360 DrawEllipse gs col0 s gr 110 | 111 | % Polyline 112 | n 900 1050 m 113 | 1050 1050 l gs col0 s gr 114 | % Polyline 115 | n 975 975 m 116 | 975 1125 l gs col0 s gr 117 | % Ellipse 118 | n 975 1650 150 150 0 360 DrawEllipse gs col0 s gr 119 | 120 | % Polyline 121 | n 900 1650 m 122 | 1050 1650 l gs col0 s gr 123 | % Polyline 124 | n 975 1575 m 125 | 975 1725 l gs col0 s gr 126 | % Polyline 127 | gs clippath 128 | 945 915 m 1005 915 l 1005 764 l 975 884 l 945 764 l cp 129 | eoclip 130 | n 975 300 m 131 | 975 900 l gs col0 s gr gr 132 | 133 | % arrowhead 134 | n 945 764 m 975 884 l 1005 764 l 945 764 l cp gs 0.00 setgray ef gr col0 s 135 | % Polyline 136 | gs clippath 137 | 840 1080 m 840 1020 l 689 1020 l 809 1050 l 689 1080 l cp 138 | eoclip 139 | n 225 1050 m 140 | 825 1050 l gs col0 s gr gr 141 | 142 | % arrowhead 143 | n 689 1080 m 809 1050 l 689 1020 l 689 1080 l cp gs 0.00 setgray ef gr col0 s 144 | % Polyline 145 | gs clippath 146 | 945 1515 m 1005 1515 l 1005 1364 l 975 1484 l 945 1364 l cp 147 | eoclip 148 | n 975 1200 m 149 | 975 1500 l gs col0 s gr gr 150 | 151 | % arrowhead 152 | n 945 1364 m 975 1484 l 1005 1364 l 945 1364 l cp gs 0.00 setgray ef gr col0 s 153 | % Polyline 154 | gs clippath 155 | 840 1680 m 840 1620 l 689 1620 l 809 1650 l 689 1680 l cp 156 | eoclip 157 | n 225 1650 m 158 | 825 1650 l gs col0 s gr gr 159 | 160 | % arrowhead 161 | n 689 1680 m 809 1650 l 689 1620 l 689 1680 l cp gs 0.00 setgray ef gr col0 s 162 | % Polyline 163 | gs clippath 164 | 945 2415 m 1005 2415 l 1005 2264 l 975 2384 l 945 2264 l cp 165 | eoclip 166 | n 975 1800 m 167 | 975 2400 l gs col0 s gr gr 168 | 169 | % arrowhead 170 | n 945 2264 m 975 2384 l 1005 2264 l 945 2264 l cp gs 0.00 setgray ef gr col0 s 171 | % Polyline 172 | [15 45] 45 sd 173 | n 525 600 m 1425 600 l 1425 2100 l 525 2100 l 174 | cp gs col0 s gr [] 0 sd 175 | /Times-Italic ff 180.00 scf sf 176 | 975 2550 m 177 | gs 1 -1 sc (r) dup sw pop 2 div neg 0 rm col0 sh gr 178 | /Times-Roman ff 105.00 scf sf 179 | 1050 2625 m 180 | gs 1 -1 sc (0) dup sw pop 2 div neg 0 rm col0 sh gr 181 | /Times-Italic ff 180.00 scf sf 182 | 975 225 m 183 | gs 1 -1 sc (x) dup sw pop 2 div neg 0 rm col0 sh gr 184 | /Times-Italic ff 180.00 scf sf 185 | 150 1050 m 186 | gs 1 -1 sc (y) dup sw pop 2 div neg 0 rm col0 sh gr 187 | /Times-Italic ff 180.00 scf sf 188 | 150 1650 m 189 | gs 1 -1 sc (z) dup sw pop 2 div neg 0 rm col0 sh gr 190 | $F2psEnd 191 | rs 192 | -------------------------------------------------------------------------------- /docs/three-sum-3.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 75 75 1425 2625 11 | 6 225 300 1425 2400 12 | 6 825 900 1125 1200 13 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 975 1050 150 150 975 1050 1125 1050 14 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 15 | 900 1050 1050 1050 16 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 17 | 975 975 975 1125 18 | -6 19 | 6 825 1500 1125 1800 20 | 1 3 0 1 0 7 50 0 -1 0.000 1 0.0000 975 1650 150 150 975 1650 1125 1650 21 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 22 | 900 1650 1050 1650 23 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 24 | 975 1575 975 1725 25 | -6 26 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 27 | 1 1 1.00 60.00 120.00 28 | 975 300 975 900 29 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 30 | 1 1 1.00 60.00 120.00 31 | 225 1050 825 1050 32 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 33 | 1 1 1.00 60.00 120.00 34 | 975 1200 975 1500 35 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 36 | 1 1 1.00 60.00 120.00 37 | 225 1650 825 1650 38 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 39 | 1 1 1.00 60.00 120.00 40 | 975 1800 975 2400 41 | 2 2 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 42 | 525 600 1425 600 1425 2100 525 2100 525 600 43 | -6 44 | 6 900 2400 1125 2625 45 | 4 1 0 50 0 1 12 0.0000 4 90 60 975 2550 r\001 46 | 4 1 0 50 0 0 7 0.0000 4 75 60 1050 2625 0\001 47 | -6 48 | 4 1 0 50 0 1 12 0.0000 4 90 90 975 225 x\001 49 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 1050 y\001 50 | 4 1 0 50 0 1 12 0.0000 4 90 75 150 1650 z\001 51 | -6 52 | -------------------------------------------------------------------------------- /docs/three-sum.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: three-sum.eps 3 | %%Creator: fig2dev Version 3.2.3 Patchlevel 4 | %%CreationDate: Sat Oct 7 23:13:22 2000 5 | %%For: yozo@yozo.HIP.Berkeley.EDU (Yozo Hida) 6 | %%BoundingBox: 0 0 187 197 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 197 moveto 0 0 lineto 187 0 lineto 187 197 lineto closepath clip newpath 49 | % Fill background color 50 | 0 0 moveto 187 0 lineto 187 197 lineto 0 197 lineto 51 | closepath 1.00 1.00 1.00 setrgbcolor fill 52 | 53 | 4.0 195.0 translate 54 | 1 -1 scale 55 | 56 | /cp {closepath} bind def 57 | /ef {eofill} bind def 58 | /gr {grestore} bind def 59 | /gs {gsave} bind def 60 | /sa {save} bind def 61 | /rs {restore} bind def 62 | /l {lineto} bind def 63 | /m {moveto} bind def 64 | /rm {rmoveto} bind def 65 | /n {newpath} bind def 66 | /s {stroke} bind def 67 | /sh {show} bind def 68 | /slc {setlinecap} bind def 69 | /slj {setlinejoin} bind def 70 | /slw {setlinewidth} bind def 71 | /srgb {setrgbcolor} bind def 72 | /rot {rotate} bind def 73 | /sc {scale} bind def 74 | /sd {setdash} bind def 75 | /ff {findfont} bind def 76 | /sf {setfont} bind def 77 | /scf {scalefont} bind def 78 | /sw {stringwidth} bind def 79 | /tr {translate} bind def 80 | /tnt {dup dup currentrgbcolor 81 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 82 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 83 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 84 | bind def 85 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 86 | 4 -2 roll mul srgb} bind def 87 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 88 | /$F2psEnd {$F2psEnteredState restore end} def 89 | 90 | $F2psBegin 91 | %%Page: 1 1 92 | 10 setmiterlimit 93 | 0.06000 0.06000 sc 94 | % Polyline 95 | 7.500 slw 96 | n 900 900 m 1200 900 l 1200 1200 l 900 1200 l 97 | cp gs col0 s gr 98 | % Polyline 99 | n 975 1050 m 100 | 1125 1050 l gs col0 s gr 101 | % Polyline 102 | n 1050 975 m 103 | 1050 1125 l gs col0 s gr 104 | % Polyline 105 | n 900 1500 m 1200 1500 l 1200 1800 l 900 1800 l 106 | cp gs col0 s gr 107 | % Polyline 108 | n 975 1650 m 109 | 1125 1650 l gs col0 s gr 110 | % Polyline 111 | n 1050 1575 m 112 | 1050 1725 l gs col0 s gr 113 | % Polyline 114 | n 1500 1500 m 1800 1500 l 1800 1800 l 1500 1800 l 115 | cp gs col0 s gr 116 | % Polyline 117 | n 1575 1650 m 118 | 1725 1650 l gs col0 s gr 119 | % Polyline 120 | n 1650 1575 m 121 | 1650 1725 l gs col0 s gr 122 | /Times-Italic ff 180.00 scf sf 123 | 2775 1950 m 124 | gs 1 -1 sc (r) dup sw pop 2 div neg 0 rm col0 sh gr 125 | /Times-Roman ff 105.00 scf sf 126 | 2850 2025 m 127 | gs 1 -1 sc (1) dup sw pop 2 div neg 0 rm col0 sh gr 128 | /Times-Italic ff 180.00 scf sf 129 | 2775 2250 m 130 | gs 1 -1 sc (r) dup sw pop 2 div neg 0 rm col0 sh gr 131 | /Times-Roman ff 105.00 scf sf 132 | 2850 2325 m 133 | gs 1 -1 sc (2) dup sw pop 2 div neg 0 rm col0 sh gr 134 | % Polyline 135 | gs clippath 136 | 1020 915 m 1080 915 l 1080 764 l 1050 884 l 1020 764 l cp 137 | eoclip 138 | n 1050 300 m 139 | 1050 900 l gs col0 s gr gr 140 | 141 | % arrowhead 142 | n 1020 764 m 1050 884 l 1080 764 l 1020 764 l cp gs 0.00 setgray ef gr col0 s 143 | % Polyline 144 | gs clippath 145 | 915 1080 m 915 1020 l 764 1020 l 884 1050 l 764 1080 l cp 146 | eoclip 147 | n 300 1050 m 148 | 900 1050 l gs col0 s gr gr 149 | 150 | % arrowhead 151 | n 764 1080 m 884 1050 l 764 1020 l 764 1080 l cp gs 0.00 setgray ef gr col0 s 152 | % Polyline 153 | gs clippath 154 | 1020 1515 m 1080 1515 l 1080 1364 l 1050 1484 l 1020 1364 l cp 155 | eoclip 156 | n 1050 1200 m 157 | 1050 1500 l gs col0 s gr gr 158 | 159 | % arrowhead 160 | n 1020 1364 m 1050 1484 l 1080 1364 l 1020 1364 l cp gs 0.00 setgray ef gr col0 s 161 | % Polyline 162 | gs clippath 163 | 1020 2865 m 1080 2865 l 1080 2714 l 1050 2834 l 1020 2714 l cp 164 | eoclip 165 | n 1050 1800 m 166 | 1050 2850 l gs col0 s gr gr 167 | 168 | % arrowhead 169 | n 1020 2714 m 1050 2834 l 1080 2714 l 1020 2714 l cp gs 0.00 setgray ef gr col0 s 170 | % Polyline 171 | gs clippath 172 | 1515 1680 m 1515 1620 l 1364 1620 l 1484 1650 l 1364 1680 l cp 173 | eoclip 174 | n 1200 1650 m 175 | 1500 1650 l gs col0 s gr gr 176 | 177 | % arrowhead 178 | n 1364 1680 m 1484 1650 l 1364 1620 l 1364 1680 l cp gs 0.00 setgray ef gr col0 s 179 | % Polyline 180 | gs clippath 181 | 1620 1515 m 1680 1515 l 1680 1364 l 1650 1484 l 1620 1364 l cp 182 | eoclip 183 | n 1200 1050 m 1650 1050 l 184 | 1650 1500 l gs col0 s gr gr 185 | 186 | % arrowhead 187 | n 1620 1364 m 1650 1484 l 1680 1364 l 1620 1364 l cp gs 0.00 setgray ef gr col0 s 188 | % Polyline 189 | gs clippath 190 | 915 1680 m 915 1620 l 764 1620 l 884 1650 l 764 1680 l cp 191 | eoclip 192 | n 300 1650 m 193 | 900 1650 l gs col0 s gr gr 194 | 195 | % arrowhead 196 | n 764 1680 m 884 1650 l 764 1620 l 764 1680 l cp gs 0.00 setgray ef gr col0 s 197 | % Polyline 198 | [15 45] 45 sd 199 | n 600 600 m 2400 600 l 2400 2550 l 600 2550 l 200 | cp gs col0 s gr [] 0 sd 201 | % Polyline 202 | gs clippath 203 | 2715 2280 m 2715 2220 l 2564 2220 l 2684 2250 l 2564 2280 l cp 204 | eoclip 205 | n 1800 1650 m 2100 1650 l 2100 2250 l 206 | 2700 2250 l gs col0 s gr gr 207 | 208 | % arrowhead 209 | n 2564 2280 m 2684 2250 l 2564 2220 l 2564 2280 l cp gs 0.00 setgray ef gr col0 s 210 | % Polyline 211 | gs clippath 212 | 2715 1980 m 2715 1920 l 2564 1920 l 2684 1950 l 2564 1980 l cp 213 | eoclip 214 | n 1650 1800 m 1650 1950 l 215 | 2700 1950 l gs col0 s gr gr 216 | 217 | % arrowhead 218 | n 2564 1980 m 2684 1950 l 2564 1920 l 2564 1980 l cp gs 0.00 setgray ef gr col0 s 219 | /Times-Italic ff 180.00 scf sf 220 | 150 1125 m 221 | gs 1 -1 sc (y) dup sw pop 2 div neg 0 rm col0 sh gr 222 | /Times-Italic ff 180.00 scf sf 223 | 1050 225 m 224 | gs 1 -1 sc (x) dup sw pop 2 div neg 0 rm col0 sh gr 225 | /Times-Italic ff 180.00 scf sf 226 | 150 1725 m 227 | gs 1 -1 sc (z) dup sw pop 2 div neg 0 rm col0 sh gr 228 | /Times-Italic ff 135.00 scf sf 229 | 900 1350 m 230 | gs 1 -1 sc (u) dup sw pop 2 div neg 0 rm col0 sh gr 231 | /Times-Italic ff 135.00 scf sf 232 | 1350 975 m 233 | gs 1 -1 sc (v) dup sw pop 2 div neg 0 rm col0 sh gr 234 | /Times-Italic ff 135.00 scf sf 235 | 1350 1800 m 236 | gs 1 -1 sc (w) dup sw pop 2 div neg 0 rm col0 sh gr 237 | /Times-Italic ff 180.00 scf sf 238 | 1050 3000 m 239 | gs 1 -1 sc (r) dup sw pop 2 div neg 0 rm col0 sh gr 240 | /Times-Roman ff 105.00 scf sf 241 | 1125 3075 m 242 | gs 1 -1 sc (0) dup sw pop 2 div neg 0 rm col0 sh gr 243 | $F2psEnd 244 | rs 245 | -------------------------------------------------------------------------------- /docs/three-sum.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 900 900 1200 1200 11 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 12 | 900 900 1200 900 1200 1200 900 1200 900 900 13 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 14 | 975 1050 1125 1050 15 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 16 | 1050 975 1050 1125 17 | -6 18 | 6 900 1500 1200 1800 19 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 20 | 900 1500 1200 1500 1200 1800 900 1800 900 1500 21 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 22 | 975 1650 1125 1650 23 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 24 | 1050 1575 1050 1725 25 | -6 26 | 6 1500 1500 1800 1800 27 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 28 | 1500 1500 1800 1500 1800 1800 1500 1800 1500 1500 29 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 30 | 1575 1650 1725 1650 31 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 32 | 1650 1575 1650 1725 33 | -6 34 | 6 2700 1800 2925 2025 35 | 4 1 0 50 0 1 12 0.0000 4 90 60 2775 1950 r\001 36 | 4 1 0 50 0 0 7 0.0000 4 75 60 2850 2025 1\001 37 | -6 38 | 6 2700 2100 2925 2325 39 | 4 1 0 50 0 1 12 0.0000 4 90 60 2775 2250 r\001 40 | 4 1 0 50 0 0 7 0.0000 4 75 60 2850 2325 2\001 41 | -6 42 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 43 | 1 1 1.00 60.00 120.00 44 | 1050 300 1050 900 45 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 46 | 1 1 1.00 60.00 120.00 47 | 300 1050 900 1050 48 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 49 | 1 1 1.00 60.00 120.00 50 | 1050 1200 1050 1500 51 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 52 | 1 1 1.00 60.00 120.00 53 | 1050 1800 1050 2850 54 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 55 | 1 1 1.00 60.00 120.00 56 | 1200 1650 1500 1650 57 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 58 | 1 1 1.00 60.00 120.00 59 | 1200 1050 1650 1050 1650 1500 60 | 2 1 0 1 0 7 50 0 -1 3.000 0 0 -1 1 0 2 61 | 1 1 1.00 60.00 120.00 62 | 300 1650 900 1650 63 | 2 2 2 1 0 7 50 0 -1 3.000 0 0 -1 0 0 5 64 | 600 600 2400 600 2400 2550 600 2550 600 600 65 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 4 66 | 1 1 1.00 60.00 120.00 67 | 1800 1650 2100 1650 2100 2250 2700 2250 68 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 3 69 | 1 1 1.00 60.00 120.00 70 | 1650 1800 1650 1950 2700 1950 71 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 1125 y\001 72 | 4 1 0 50 0 1 12 0.0000 4 90 90 1050 225 x\001 73 | 4 1 0 50 0 1 12 0.0000 4 90 75 150 1725 z\001 74 | 4 1 0 50 0 1 9 0.0000 4 75 75 900 1350 u\001 75 | 4 1 0 50 0 1 9 0.0000 4 75 75 1350 975 v\001 76 | 4 1 0 50 0 1 9 0.0000 4 75 105 1350 1800 w\001 77 | 4 1 0 50 0 1 12 0.0000 4 90 60 1050 3000 r\001 78 | 4 1 0 50 0 0 7 0.0000 4 75 60 1125 3075 0\001 79 | -------------------------------------------------------------------------------- /docs/two-prod.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: two-prod.eps 3 | %%Creator: fig2dev Version 3.2.3 Patchlevel 4 | %%CreationDate: Thu Aug 3 16:13:32 2000 5 | %%For: yozo@n2001.lbl.gov () 6 | %%BoundingBox: 0 0 129 132 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 132 moveto 0 0 lineto 129 0 lineto 129 132 lineto closepath clip newpath 49 | % Fill background color 50 | 0 0 moveto 129 0 lineto 129 132 lineto 0 132 lineto 51 | closepath 1.00 1.00 1.00 setrgbcolor fill 52 | 53 | 4.0 130.0 translate 54 | 1 -1 scale 55 | 56 | /cp {closepath} bind def 57 | /ef {eofill} bind def 58 | /gr {grestore} bind def 59 | /gs {gsave} bind def 60 | /sa {save} bind def 61 | /rs {restore} bind def 62 | /l {lineto} bind def 63 | /m {moveto} bind def 64 | /rm {rmoveto} bind def 65 | /n {newpath} bind def 66 | /s {stroke} bind def 67 | /sh {show} bind def 68 | /slc {setlinecap} bind def 69 | /slj {setlinejoin} bind def 70 | /slw {setlinewidth} bind def 71 | /srgb {setrgbcolor} bind def 72 | /rot {rotate} bind def 73 | /sc {scale} bind def 74 | /sd {setdash} bind def 75 | /ff {findfont} bind def 76 | /sf {setfont} bind def 77 | /scf {scalefont} bind def 78 | /sw {stringwidth} bind def 79 | /tr {translate} bind def 80 | /tnt {dup dup currentrgbcolor 81 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 82 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 83 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 84 | bind def 85 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 86 | 4 -2 roll mul srgb} bind def 87 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 88 | /$F2psEnd {$F2psEnteredState restore end} def 89 | 90 | $F2psBegin 91 | %%Page: 1 1 92 | 10 setmiterlimit 93 | 0.06000 0.06000 sc 94 | % Polyline 95 | 7.500 slw 96 | n 825 900 m 1125 900 l 1125 1200 l 825 1200 l 97 | cp gs col0 s gr 98 | % Polyline 99 | n 900 975 m 100 | 1050 1125 l gs col0 s gr 101 | % Polyline 102 | n 1050 975 m 103 | 900 1125 l gs col0 s gr 104 | % Polyline 105 | gs clippath 106 | 840 1080 m 840 1020 l 689 1020 l 809 1050 l 689 1080 l cp 107 | eoclip 108 | n 225 1050 m 109 | 825 1050 l gs col0 s gr gr 110 | 111 | % arrowhead 112 | n 689 1080 m 809 1050 l 689 1020 l 689 1080 l cp gs 0.00 setgray ef gr col0 s 113 | % Polyline 114 | gs clippath 115 | 945 915 m 1005 915 l 1005 764 l 975 884 l 945 764 l cp 116 | eoclip 117 | n 975 300 m 118 | 975 900 l gs col0 s gr gr 119 | 120 | % arrowhead 121 | n 945 764 m 975 884 l 1005 764 l 945 764 l cp gs 0.00 setgray ef gr col0 s 122 | % Polyline 123 | gs clippath 124 | 945 1815 m 1005 1815 l 1005 1664 l 975 1784 l 945 1664 l cp 125 | eoclip 126 | n 975 1200 m 127 | 975 1800 l gs col0 s gr gr 128 | 129 | % arrowhead 130 | n 945 1664 m 975 1784 l 1005 1664 l 945 1664 l cp gs 0.00 setgray ef gr col0 s 131 | % Polyline 132 | gs clippath 133 | 1740 1080 m 1740 1020 l 1589 1020 l 1709 1050 l 1589 1080 l cp 134 | eoclip 135 | n 1125 1050 m 136 | 1725 1050 l gs col0 s gr gr 137 | 138 | % arrowhead 139 | n 1589 1080 m 1709 1050 l 1589 1020 l 1589 1080 l cp gs 0.00 setgray ef gr col0 s 140 | /Times-Italic ff 180.00 scf sf 141 | 975 225 m 142 | gs 1 -1 sc (a) dup sw pop 2 div neg 0 rm col0 sh gr 143 | /Times-Italic ff 180.00 scf sf 144 | 150 1125 m 145 | gs 1 -1 sc (b) dup sw pop 2 div neg 0 rm col0 sh gr 146 | /Times-Italic ff 180.00 scf sf 147 | 1875 1125 m 148 | gs 1 -1 sc (e) dup sw pop 2 div neg 0 rm col0 sh gr 149 | /Times-Italic ff 180.00 scf sf 150 | 975 1950 m 151 | gs 1 -1 sc (p) dup sw pop 2 div neg 0 rm col0 sh gr 152 | $F2psEnd 153 | rs 154 | -------------------------------------------------------------------------------- /docs/two-prod.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 6 825 900 1125 1200 11 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 12 | 825 900 1125 900 1125 1200 825 1200 825 900 13 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 14 | 900 975 1050 1125 15 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 16 | 1050 975 900 1125 17 | -6 18 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 19 | 1 1 1.00 60.00 120.00 20 | 225 1050 825 1050 21 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 22 | 1 1 1.00 60.00 120.00 23 | 975 300 975 900 24 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 25 | 1 1 1.00 60.00 120.00 26 | 975 1200 975 1800 27 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 28 | 1 1 1.00 60.00 120.00 29 | 1125 1050 1725 1050 30 | 4 1 0 50 0 1 12 0.0000 4 90 90 975 225 a\001 31 | 4 1 0 50 0 1 12 0.0000 4 135 90 150 1125 b\001 32 | 4 1 0 50 0 1 12 0.0000 4 90 75 1875 1125 e\001 33 | 4 1 0 50 0 1 12 0.0000 4 135 90 975 1950 p\001 34 | -------------------------------------------------------------------------------- /docs/two-sum.eps: -------------------------------------------------------------------------------- 1 | %!PS-Adobe-2.0 EPSF-2.0 2 | %%Title: two-sum.eps 3 | %%Creator: fig2dev Version 3.2.3 Patchlevel 4 | %%CreationDate: Tue Aug 1 15:41:11 2000 5 | %%For: yozo@n2001.lbl.gov () 6 | %%BoundingBox: 0 0 130 130 7 | %%Magnification: 1.0000 8 | %%EndComments 9 | /$F2psDict 200 dict def 10 | $F2psDict begin 11 | $F2psDict /mtrx matrix put 12 | /col-1 {0 setgray} bind def 13 | /col0 {0.000 0.000 0.000 srgb} bind def 14 | /col1 {0.000 0.000 1.000 srgb} bind def 15 | /col2 {0.000 1.000 0.000 srgb} bind def 16 | /col3 {0.000 1.000 1.000 srgb} bind def 17 | /col4 {1.000 0.000 0.000 srgb} bind def 18 | /col5 {1.000 0.000 1.000 srgb} bind def 19 | /col6 {1.000 1.000 0.000 srgb} bind def 20 | /col7 {1.000 1.000 1.000 srgb} bind def 21 | /col8 {0.000 0.000 0.560 srgb} bind def 22 | /col9 {0.000 0.000 0.690 srgb} bind def 23 | /col10 {0.000 0.000 0.820 srgb} bind def 24 | /col11 {0.530 0.810 1.000 srgb} bind def 25 | /col12 {0.000 0.560 0.000 srgb} bind def 26 | /col13 {0.000 0.690 0.000 srgb} bind def 27 | /col14 {0.000 0.820 0.000 srgb} bind def 28 | /col15 {0.000 0.560 0.560 srgb} bind def 29 | /col16 {0.000 0.690 0.690 srgb} bind def 30 | /col17 {0.000 0.820 0.820 srgb} bind def 31 | /col18 {0.560 0.000 0.000 srgb} bind def 32 | /col19 {0.690 0.000 0.000 srgb} bind def 33 | /col20 {0.820 0.000 0.000 srgb} bind def 34 | /col21 {0.560 0.000 0.560 srgb} bind def 35 | /col22 {0.690 0.000 0.690 srgb} bind def 36 | /col23 {0.820 0.000 0.820 srgb} bind def 37 | /col24 {0.500 0.190 0.000 srgb} bind def 38 | /col25 {0.630 0.250 0.000 srgb} bind def 39 | /col26 {0.750 0.380 0.000 srgb} bind def 40 | /col27 {1.000 0.500 0.500 srgb} bind def 41 | /col28 {1.000 0.630 0.630 srgb} bind def 42 | /col29 {1.000 0.750 0.750 srgb} bind def 43 | /col30 {1.000 0.880 0.880 srgb} bind def 44 | /col31 {1.000 0.840 0.000 srgb} bind def 45 | 46 | end 47 | save 48 | newpath 0 130 moveto 0 0 lineto 130 0 lineto 130 130 lineto closepath clip newpath 49 | % Fill background color 50 | 0 0 moveto 130 0 lineto 130 130 lineto 0 130 lineto 51 | closepath 1.00 1.00 1.00 setrgbcolor fill 52 | 53 | 9.0 123.0 translate 54 | 1 -1 scale 55 | 56 | /cp {closepath} bind def 57 | /ef {eofill} bind def 58 | /gr {grestore} bind def 59 | /gs {gsave} bind def 60 | /sa {save} bind def 61 | /rs {restore} bind def 62 | /l {lineto} bind def 63 | /m {moveto} bind def 64 | /rm {rmoveto} bind def 65 | /n {newpath} bind def 66 | /s {stroke} bind def 67 | /sh {show} bind def 68 | /slc {setlinecap} bind def 69 | /slj {setlinejoin} bind def 70 | /slw {setlinewidth} bind def 71 | /srgb {setrgbcolor} bind def 72 | /rot {rotate} bind def 73 | /sc {scale} bind def 74 | /sd {setdash} bind def 75 | /ff {findfont} bind def 76 | /sf {setfont} bind def 77 | /scf {scalefont} bind def 78 | /sw {stringwidth} bind def 79 | /tr {translate} bind def 80 | /tnt {dup dup currentrgbcolor 81 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 82 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add 83 | 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} 84 | bind def 85 | /shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 86 | 4 -2 roll mul srgb} bind def 87 | /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def 88 | /$F2psEnd {$F2psEnteredState restore end} def 89 | 90 | $F2psBegin 91 | %%Page: 1 1 92 | 10 setmiterlimit 93 | 0.06000 0.06000 sc 94 | /Times-Italic ff 180.00 scf sf 95 | 900 150 m 96 | gs 1 -1 sc (a) dup sw pop 2 div neg 0 rm col0 sh gr 97 | /Times-Italic ff 180.00 scf sf 98 | 75 1050 m 99 | gs 1 -1 sc (b) dup sw pop 2 div neg 0 rm col0 sh gr 100 | /Times-Italic ff 180.00 scf sf 101 | 900 1875 m 102 | gs 1 -1 sc (s) dup sw pop 2 div neg 0 rm col0 sh gr 103 | /Times-Italic ff 180.00 scf sf 104 | 1800 1050 m 105 | gs 1 -1 sc (e) dup sw pop 2 div neg 0 rm col0 sh gr 106 | % Polyline 107 | 7.500 slw 108 | n 750 825 m 1050 825 l 1050 1125 l 750 1125 l 109 | cp gs col0 s gr 110 | % Polyline 111 | n 825 975 m 112 | 975 975 l gs col0 s gr 113 | % Polyline 114 | n 900 900 m 115 | 900 1050 l gs col0 s gr 116 | % Polyline 117 | gs clippath 118 | 765 1005 m 765 945 l 614 945 l 734 975 l 614 1005 l cp 119 | eoclip 120 | n 150 975 m 121 | 750 975 l gs col0 s gr gr 122 | 123 | % arrowhead 124 | n 614 1005 m 734 975 l 614 945 l 614 1005 l cp gs 0.00 setgray ef gr col0 s 125 | % Polyline 126 | gs clippath 127 | 870 840 m 930 840 l 930 689 l 900 809 l 870 689 l cp 128 | eoclip 129 | n 900 225 m 130 | 900 825 l gs col0 s gr gr 131 | 132 | % arrowhead 133 | n 870 689 m 900 809 l 930 689 l 870 689 l cp gs 0.00 setgray ef gr col0 s 134 | % Polyline 135 | gs clippath 136 | 1665 1005 m 1665 945 l 1514 945 l 1634 975 l 1514 1005 l cp 137 | eoclip 138 | n 1050 975 m 139 | 1650 975 l gs col0 s gr gr 140 | 141 | % arrowhead 142 | n 1514 1005 m 1634 975 l 1514 945 l 1514 1005 l cp gs 0.00 setgray ef gr col0 s 143 | % Polyline 144 | gs clippath 145 | 870 1740 m 930 1740 l 930 1589 l 900 1709 l 870 1589 l cp 146 | eoclip 147 | n 900 1125 m 148 | 900 1725 l gs col0 s gr gr 149 | 150 | % arrowhead 151 | n 870 1589 m 900 1709 l 930 1589 l 870 1589 l cp gs 0.00 setgray ef gr col0 s 152 | $F2psEnd 153 | rs 154 | -------------------------------------------------------------------------------- /docs/two-sum.fig: -------------------------------------------------------------------------------- 1 | #FIG 3.2 2 | Landscape 3 | Center 4 | Inches 5 | Letter 6 | 100.00 7 | Single 8 | -2 9 | 1200 2 10 | 2 2 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 5 11 | 750 825 1050 825 1050 1125 750 1125 750 825 12 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 13 | 825 975 975 975 14 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 0 0 2 15 | 900 900 900 1050 16 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 17 | 1 1 1.00 60.00 120.00 18 | 150 975 750 975 19 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 20 | 1 1 1.00 60.00 120.00 21 | 900 225 900 825 22 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 23 | 1 1 1.00 60.00 120.00 24 | 1050 975 1650 975 25 | 2 1 0 1 0 7 50 0 -1 0.000 0 0 -1 1 0 2 26 | 1 1 1.00 60.00 120.00 27 | 900 1125 900 1725 28 | 4 1 0 100 0 1 12 0.0000 4 90 90 900 150 a\001 29 | 4 1 0 100 0 1 12 0.0000 4 135 90 75 1050 b\001 30 | 4 1 0 100 0 1 12 0.0000 4 90 75 900 1875 s\001 31 | 4 1 0 100 0 1 12 0.0000 4 90 75 1800 1050 e\001 32 | -------------------------------------------------------------------------------- /fortran/Makefile.am: -------------------------------------------------------------------------------- 1 | if HAVE_FORTRAN 2 | AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include 3 | LDADD=libqdmod.la libqd_f_main.la $(top_builddir)/src/libqd.la $(FCLIBS) 4 | 5 | if UPCASE_MODULE 6 | DDEXT=DDEXT.$(module_ext) 7 | QDEXT=QDEXT.$(module_ext) 8 | QDMOD=QDMODULE.$(module_ext) 9 | DDMOD=DDMODULE.$(module_ext) 10 | else 11 | DDEXT=ddext.$(module_ext) 12 | QDEXT=qdext.$(module_ext) 13 | QDMOD=qdmodule.$(module_ext) 14 | DDMOD=ddmodule.$(module_ext) 15 | endif 16 | 17 | lib_LTLIBRARIES = libqdmod.la libqd_f_main.la 18 | libqdmod_la_SOURCES = ddext.f ddmod.f qdext.f qdmod.f f_dd.cpp f_qd.cpp 19 | libqdmod_la_LIBADD = $(top_builddir)/src/libqd.la $(FCLIBS) 20 | libqd_f_main_la_SOURCES = main.cpp 21 | libqd_f_main_la_LIBADD = $(top_builddir)/src/libqd.la libqdmod.la $(FCLIBS) 22 | ddmod.lo: $(DDEXT) ddext.lo 23 | qdmod.lo: ddmod.lo $(DDMOD) qdext.lo 24 | $(QDMOD): qdmod.lo $(DDMOD) 25 | $(DDMOD): ddmod.lo 26 | $(DDEXT): ddext.lo 27 | $(QDEXT): qdext.lo $(DDEXT) 28 | 29 | nodist_pkginclude_HEADERS = $(QDMOD) $(QDEXT) $(DDMOD) $(DDEXT) 30 | 31 | DEMO=quaderq$(EXEEXT) quadgsq2d$(EXEEXT) quadgsq$(EXEEXT) \ 32 | quadtsq$(EXEEXT) quadtsq2d$(EXEEXT) 33 | TIMER = dd_timer$(EXEEXT) qd_timer$(EXEEXT) 34 | EXTRA_PROGRAMS=$(DEMO) $(TIMER) 35 | 36 | quaderq_SOURCES = tquaderq.f 37 | nodist_quaderq_SOURCES=second.f 38 | quaderq_LINK=$(CXXLINK) 39 | 40 | quadgsq2d_SOURCES = tquadgsq2d.f 41 | nodist_quadgsq2d_SOURCES=second.f 42 | quadgsq2d_LINK=$(CXXLINK) 43 | 44 | quadgsq_SOURCES = tquadgsq.f 45 | nodist_quadgsq_SOURCES=second.f 46 | quadgsq_LINK=$(CXXLINK) 47 | 48 | quadtsq_SOURCES = tquadtsq.f 49 | nodist_quadtsq_SOURCES=second.f 50 | quadtsq_LINK=$(CXXLINK) 51 | 52 | quadtsq2d_SOURCES = tquadtsq2d.f 53 | nodist_quadtsq2d_SOURCES=second.f 54 | quadtsq2d_LINK=$(CXXLINK) 55 | 56 | dd_timer_SOURCES = dd_timer.f 57 | nodist_dd_timer_SOURCES = second.f 58 | dd_timer_LINK=$(CXXLINK) 59 | 60 | qd_timer_SOURCES = qd_timer.f 61 | nodist_qd_timer_SOURCES = second.f 62 | qd_timer_LINK=$(CXXLINK) 63 | 64 | demo: $(DEMO) 65 | 66 | CLEANFILES = $(EXTRA_PROGRAMS) $(nodist_pkginclude_HEADERS) 67 | 68 | endif 69 | 70 | MAINTAINERCLEANFILES = dd_timer.f qd_timer.f 71 | EXTRA_DIST = dd_timer.f qd_timer.f zz_timer.f Makefile.sample 72 | 73 | dd_timer.f: zz_timer.f 74 | sed -e 's/@@/dd/' zz_timer.f >dd_timer.f 75 | 76 | qd_timer.f: zz_timer.f 77 | sed -e 's/@@/qd/' zz_timer.f >qd_timer.f 78 | 79 | if HAVE_FORTRAN 80 | .PHONY: demo 81 | endif 82 | 83 | -------------------------------------------------------------------------------- /fortran/Makefile.sample: -------------------------------------------------------------------------------- 1 | # Sample Makefile for compiling Fortran programs using Quad-Double library. 2 | # Make sure the script qd-config (installed during "make install") 3 | # is in your path. 4 | 5 | # Fortran compiler. Should be whatever "qd-config --fc" returns. 6 | FC=$(shell qd-config --fc) 7 | 8 | # C++ compiler. Used for linking. 9 | # Should be whatever "qd-config --cxx" returns. 10 | CXX=$(shell qd-config --cxx) 11 | 12 | # Fortran compiler flags. Should be whatever "qd-config --fcflags" 13 | # returns, but some items (like optimization levels) # can be 14 | # tweaked if desired. 15 | FCFLAGS=$(shell qd-config --fcflags) 16 | 17 | # Linker flags. Includes the Quad-Double library and any Fortran 18 | # libraries that needs to be linked in. Should be whatever 19 | # "qd-config --fclibs" returns 20 | FCLIBS=$(shell qd-config --fclibs) 21 | 22 | # If your main proram is written in Fortran, you need declare your 23 | # main program as "subroutine f_main", not "program myprog", since 24 | # C++ linker must find the main entry, provided by 25 | # "qd-config --fmainlib". 26 | FCMAIN=$(shell qd-config --fmainlib) 27 | 28 | fortran_test: fortran_test.o 29 | $(CXX) -o $@ fortran_test.o $(FCLIBS) $(FCMAIN) 30 | 31 | %.o: %.f90 32 | $(FC) -c $(FCFLAGS) $< 33 | 34 | -------------------------------------------------------------------------------- /fortran/ddext.f: -------------------------------------------------------------------------------- 1 | ! module file describing the C++-to-Fortran interface found in f_dd.cpp. 2 | 3 | module ddext 4 | implicit none 5 | 6 | interface 7 | pure subroutine f_dd_add(a, b, c) 8 | real*8, intent(in) :: a(2), b(2) 9 | real*8, intent(out) :: c(2) 10 | end subroutine 11 | 12 | pure subroutine f_dd_add_dd_d(a, b, c) 13 | real*8, intent(in) :: a(2), b 14 | real*8, intent(out) :: c(2) 15 | end subroutine 16 | 17 | pure subroutine f_dd_sub(a, b, c) 18 | real*8, intent(in) :: a(2), b(2) 19 | real*8, intent(out) :: c(2) 20 | end subroutine 21 | 22 | pure subroutine f_dd_sub_dd_d(a, b, c) 23 | real*8, intent(in) :: a(2), b 24 | real*8, intent(out) :: c(2) 25 | end subroutine 26 | 27 | pure subroutine f_dd_sub_d_dd(a, b, c) 28 | real*8, intent(in) :: a, b(2) 29 | real*8, intent(out) :: c(2) 30 | end subroutine 31 | 32 | pure subroutine f_dd_mul(a, b, c) 33 | real*8, intent(in) :: a(2), b(2) 34 | real*8, intent(out) :: c(2) 35 | end subroutine 36 | 37 | pure subroutine f_dd_mul_dd_d(a, b, c) 38 | real*8, intent(in) :: a(2), b 39 | real*8, intent(out) :: c(2) 40 | end subroutine 41 | 42 | pure subroutine f_dd_div(a, b, c) 43 | real*8, intent(in) :: a(2), b(2) 44 | real*8, intent(out) :: c(2) 45 | end subroutine 46 | 47 | pure subroutine f_dd_div_dd_d(a, b, c) 48 | real*8, intent(in) :: a(2), b 49 | real*8, intent(out) :: c(2) 50 | end subroutine 51 | 52 | pure subroutine f_dd_div_d_dd(a, b, c) 53 | real*8, intent(in) :: a, b(2) 54 | real*8, intent(out) :: c(2) 55 | end subroutine 56 | 57 | pure subroutine f_dd_sqrt(a, b) 58 | real*8, intent(in) :: a(2) 59 | real*8, intent(out) :: b(2) 60 | end subroutine 61 | 62 | pure subroutine f_dd_sqr(a, b) 63 | real*8, intent(in) :: a(2) 64 | real*8, intent(out) :: b(2) 65 | end subroutine 66 | 67 | pure subroutine f_dd_abs(a, b) 68 | real*8, intent(in) :: a(2) 69 | real*8, intent(out) :: b(2) 70 | end subroutine 71 | 72 | pure subroutine f_dd_npwr(a, n, b) 73 | real*8, intent(in) :: a(2) 74 | integer, intent(in) :: n 75 | real*8, intent(out) :: b(2) 76 | end subroutine 77 | 78 | pure subroutine f_dd_nroot(a, n, b) 79 | real*8, intent(in) :: a(2) 80 | integer, intent(in) :: n 81 | real*8, intent(out) :: b(2) 82 | end subroutine 83 | 84 | pure subroutine f_dd_nint(a, b) 85 | real*8, intent(in) :: a(2) 86 | real*8, intent(out) :: b(2) 87 | end subroutine 88 | 89 | pure subroutine f_dd_aint(a, b) 90 | real*8, intent(in) :: a(2) 91 | real*8, intent(out) :: b(2) 92 | end subroutine 93 | 94 | pure subroutine f_dd_floor(a, b) 95 | real*8, intent(in) :: a(2) 96 | real*8, intent(out) :: b(2) 97 | end subroutine 98 | 99 | pure subroutine f_dd_ceil(a, b) 100 | real*8, intent(in) :: a(2) 101 | real*8, intent(out) :: b(2) 102 | end subroutine 103 | 104 | pure subroutine f_dd_log(a, b) 105 | real*8, intent(in) :: a(2) 106 | real*8, intent(out) :: b(2) 107 | end subroutine 108 | 109 | pure subroutine f_dd_log10(a, b) 110 | real*8, intent(in) :: a(2) 111 | real*8, intent(out) :: b(2) 112 | end subroutine 113 | 114 | pure subroutine f_dd_exp(a, b) 115 | real*8, intent(in) :: a(2) 116 | real*8, intent(out) :: b(2) 117 | end subroutine 118 | 119 | pure subroutine f_dd_sin(a, b) 120 | real*8, intent(in) :: a(2) 121 | real*8, intent(out) :: b(2) 122 | end subroutine 123 | 124 | pure subroutine f_dd_cos(a, b) 125 | real*8, intent(in) :: a(2) 126 | real*8, intent(out) :: b(2) 127 | end subroutine 128 | 129 | pure subroutine f_dd_tan(a, b) 130 | real*8, intent(in) :: a(2) 131 | real*8, intent(out) :: b(2) 132 | end subroutine 133 | 134 | pure subroutine f_dd_asin(a, b) 135 | real*8, intent(in) :: a(2) 136 | real*8, intent(out) :: b(2) 137 | end subroutine 138 | 139 | pure subroutine f_dd_acos(a, b) 140 | real*8, intent(in) :: a(2) 141 | real*8, intent(out) :: b(2) 142 | end subroutine 143 | 144 | pure subroutine f_dd_atan(a, b) 145 | real*8, intent(in) :: a(2) 146 | real*8, intent(out) :: b(2) 147 | end subroutine 148 | 149 | pure subroutine f_dd_atan2(a, b, c) 150 | real*8, intent(in) :: a(2), b(2) 151 | real*8, intent(out) :: c(2) 152 | end subroutine 153 | 154 | pure subroutine f_dd_sinh(a, b) 155 | real*8, intent(in) :: a(2) 156 | real*8, intent(out) :: b(2) 157 | end subroutine 158 | 159 | pure subroutine f_dd_cosh(a, b) 160 | real*8, intent(in) :: a(2) 161 | real*8, intent(out) :: b(2) 162 | end subroutine 163 | 164 | pure subroutine f_dd_tanh(a, b) 165 | real*8, intent(in) :: a(2) 166 | real*8, intent(out) :: b(2) 167 | end subroutine 168 | 169 | pure subroutine f_dd_asinh(a, b) 170 | real*8, intent(in) :: a(2) 171 | real*8, intent(out) :: b(2) 172 | end subroutine 173 | 174 | pure subroutine f_dd_acosh(a, b) 175 | real*8, intent(in) :: a(2) 176 | real*8, intent(out) :: b(2) 177 | end subroutine 178 | 179 | pure subroutine f_dd_atanh(a, b) 180 | real*8, intent(in) :: a(2) 181 | real*8, intent(out) :: b(2) 182 | end subroutine 183 | 184 | pure subroutine f_dd_sincos(a, s, c) 185 | real*8, intent(in) :: a(2) 186 | real*8, intent(out) :: s(2), c(2) 187 | end subroutine 188 | 189 | pure subroutine f_dd_sincosh(a, s, c) 190 | real*8, intent(in) :: a(2) 191 | real*8, intent(out) :: s(2), c(2) 192 | end subroutine 193 | 194 | subroutine f_dd_swrite(a, prec, str, maxlen) 195 | real*8, intent(in) :: a(2) 196 | integer, intent(in) :: prec, maxlen 197 | character, intent(out) :: str(maxlen) 198 | end subroutine 199 | 200 | subroutine f_dd_rand(a) 201 | real*8, intent(out) :: a(2) 202 | end subroutine 203 | 204 | pure subroutine f_dd_comp(a, b, r) 205 | real*8, intent(in) :: a(2), b(2) 206 | integer, intent(out) :: r 207 | end subroutine 208 | 209 | pure subroutine f_dd_comp_dd_d(a, b, r) 210 | real*8, intent(in) :: a(2), b 211 | integer, intent(out) :: r 212 | end subroutine 213 | 214 | pure subroutine f_dd_comp_d_dd(a, b, r) 215 | real*8, intent(in) :: a, b(2) 216 | integer, intent(out) :: r 217 | end subroutine 218 | 219 | pure subroutine f_dd_pi(a) 220 | real*8, intent(out) :: a(2) 221 | end subroutine 222 | 223 | pure subroutine f_dd_nan(a) 224 | real*8, intent(out) :: a(2) 225 | end subroutine 226 | 227 | end interface 228 | end 229 | -------------------------------------------------------------------------------- /fortran/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "config.h" 4 | 5 | #define f_main FC_FUNC_(f_main, F_MAIN) 6 | 7 | extern "C" void f_main(); 8 | 9 | int main() { 10 | fpu_fix_start(NULL); 11 | f_main(); 12 | return 0; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /fortran/qdext.f: -------------------------------------------------------------------------------- 1 | ! module file describing the C++-to-Fortran interface found in f_qd.cpp. 2 | 3 | module qdext 4 | implicit none 5 | 6 | interface 7 | pure subroutine f_qd_add(a, b, c) 8 | real*8, intent(in) :: a(4), b(4) 9 | real*8, intent(out) :: c(4) 10 | end subroutine 11 | 12 | pure subroutine f_qd_add_qd_d(a, b, c) 13 | real*8, intent(in) :: a(4), b 14 | real*8, intent(out) :: c(4) 15 | end subroutine 16 | 17 | pure subroutine f_qd_add_d_qd(a, b, c) 18 | real*8, intent(in) :: a, b(4) 19 | real*8, intent(out) :: c(4) 20 | end subroutine 21 | 22 | pure subroutine f_qd_sub(a, b, c) 23 | real*8, intent(in) :: a(4), b(4) 24 | real*8, intent(out) :: c(4) 25 | end subroutine 26 | 27 | pure subroutine f_qd_sub_qd_d(a, b, c) 28 | real*8, intent(in) :: a(4), b 29 | real*8, intent(out) :: c(4) 30 | end subroutine 31 | 32 | pure subroutine f_qd_sub_d_qd(a, b, c) 33 | real*8, intent(in) :: a, b(4) 34 | real*8, intent(out) :: c(4) 35 | end subroutine 36 | 37 | pure subroutine f_qd_mul(a, b, c) 38 | real*8, intent(in) :: a(4), b(4) 39 | real*8, intent(out) :: c(4) 40 | end subroutine 41 | 42 | pure subroutine f_qd_mul_qd_d(a, b, c) 43 | real*8, intent(in) :: a(4), b 44 | real*8, intent(out) :: c(4) 45 | end subroutine 46 | 47 | pure subroutine f_qd_mul_d_qd(a, b, c) 48 | real*8, intent(in) :: a, b(4) 49 | real*8, intent(out) :: c(4) 50 | end subroutine 51 | 52 | pure subroutine f_qd_div(a, b, c) 53 | real*8, intent(in) :: a(4), b(4) 54 | real*8, intent(out) :: c(4) 55 | end subroutine 56 | 57 | pure subroutine f_qd_div_qd_d(a, b, c) 58 | real*8, intent(in) :: a(4), b 59 | real*8, intent(out) :: c(4) 60 | end subroutine 61 | 62 | pure subroutine f_qd_div_d_qd(a, b, c) 63 | real*8, intent(in) :: a, b(4) 64 | real*8, intent(out) :: c(4) 65 | end subroutine 66 | 67 | pure subroutine f_qd_sqrt(a, b) 68 | real*8, intent(in) :: a(4) 69 | real*8, intent(out) :: b(4) 70 | end subroutine 71 | 72 | pure subroutine f_qd_sqr(a, b) 73 | real*8, intent(in) :: a(4) 74 | real*8, intent(out) :: b(4) 75 | end subroutine 76 | 77 | pure subroutine f_qd_abs(a, b) 78 | real*8, intent(in) :: a(4) 79 | real*8, intent(out) :: b(4) 80 | end subroutine 81 | 82 | pure subroutine f_qd_npwr(a, n, b) 83 | real*8, intent(in) :: a(4) 84 | integer, intent(in) :: n 85 | real*8, intent(out) :: b(4) 86 | end subroutine 87 | 88 | pure subroutine f_qd_nroot(a, n, b) 89 | real*8, intent(in) :: a(4) 90 | integer, intent(in) :: n 91 | real*8, intent(out) :: b(4) 92 | end subroutine 93 | 94 | pure subroutine f_qd_nint(a, b) 95 | real*8, intent(in) :: a(4) 96 | real*8, intent(out) :: b(4) 97 | end subroutine 98 | 99 | pure subroutine f_qd_aint(a, b) 100 | real*8, intent(in) :: a(4) 101 | real*8, intent(out) :: b(4) 102 | end subroutine 103 | 104 | pure subroutine f_qd_floor(a, b) 105 | real*8, intent(in) :: a(4) 106 | real*8, intent(out) :: b(4) 107 | end subroutine 108 | 109 | pure subroutine f_qd_ceil(a, b) 110 | real*8, intent(in) :: a(4) 111 | real*8, intent(out) :: b(4) 112 | end subroutine 113 | 114 | pure subroutine f_qd_log(a, b) 115 | real*8, intent(in) :: a(4) 116 | real*8, intent(out) :: b(4) 117 | end subroutine 118 | 119 | pure subroutine f_qd_log10(a, b) 120 | real*8, intent(in) :: a(4) 121 | real*8, intent(out) :: b(4) 122 | end subroutine 123 | 124 | pure subroutine f_qd_exp(a, b) 125 | real*8, intent(in) :: a(4) 126 | real*8, intent(out) :: b(4) 127 | end subroutine 128 | 129 | pure subroutine f_qd_sin(a, b) 130 | real*8, intent(in) :: a(4) 131 | real*8, intent(out) :: b(4) 132 | end subroutine 133 | 134 | pure subroutine f_qd_cos(a, b) 135 | real*8, intent(in) :: a(4) 136 | real*8, intent(out) :: b(4) 137 | end subroutine 138 | 139 | pure subroutine f_qd_tan(a, b) 140 | real*8, intent(in) :: a(4) 141 | real*8, intent(out) :: b(4) 142 | end subroutine 143 | 144 | pure subroutine f_qd_asin(a, b) 145 | real*8, intent(in) :: a(4) 146 | real*8, intent(out) :: b(4) 147 | end subroutine 148 | 149 | pure subroutine f_qd_acos(a, b) 150 | real*8, intent(in) :: a(4) 151 | real*8, intent(out) :: b(4) 152 | end subroutine 153 | 154 | pure subroutine f_qd_atan(a, b) 155 | real*8, intent(in) :: a(4) 156 | real*8, intent(out) :: b(4) 157 | end subroutine 158 | 159 | pure subroutine f_qd_atan2(a, b, c) 160 | real*8, intent(in) :: a(4), b(4) 161 | real*8, intent(out) :: c(4) 162 | end subroutine 163 | 164 | pure subroutine f_qd_sinh(a, b) 165 | real*8, intent(in) :: a(4) 166 | real*8, intent(out) :: b(4) 167 | end subroutine 168 | 169 | pure subroutine f_qd_cosh(a, b) 170 | real*8, intent(in) :: a(4) 171 | real*8, intent(out) :: b(4) 172 | end subroutine 173 | 174 | pure subroutine f_qd_tanh(a, b) 175 | real*8, intent(in) :: a(4) 176 | real*8, intent(out) :: b(4) 177 | end subroutine 178 | 179 | pure subroutine f_qd_asinh(a, b) 180 | real*8, intent(in) :: a(4) 181 | real*8, intent(out) :: b(4) 182 | end subroutine 183 | 184 | pure subroutine f_qd_acosh(a, b) 185 | real*8, intent(in) :: a(4) 186 | real*8, intent(out) :: b(4) 187 | end subroutine 188 | 189 | pure subroutine f_qd_atanh(a, b) 190 | real*8, intent(in) :: a(4) 191 | real*8, intent(out) :: b(4) 192 | end subroutine 193 | 194 | pure subroutine f_qd_sincos(a, s, c) 195 | real*8, intent(in) :: a(4) 196 | real*8, intent(out) :: s(4), c(4) 197 | end subroutine 198 | 199 | pure subroutine f_qd_sincosh(a, s, c) 200 | real*8, intent(in) :: a(4) 201 | real*8, intent(out) :: s(4), c(4) 202 | end subroutine 203 | 204 | subroutine f_qd_swrite(a, prec, str, maxlen) 205 | real*8, intent(in) :: a(4) 206 | integer, intent(in) :: prec, maxlen 207 | character, intent(out) :: str(*) 208 | end subroutine 209 | 210 | subroutine f_qd_rand(a) 211 | real*8, intent(out) :: a(4) 212 | end subroutine 213 | 214 | pure subroutine f_qd_comp(a, b, r) 215 | real*8, intent(in) :: a(4), b(4) 216 | integer, intent(out) :: r 217 | end subroutine 218 | 219 | pure subroutine f_qd_comp_qd_d(a, b, r) 220 | real*8, intent(in) :: a(4), b 221 | integer, intent(out) :: r 222 | end subroutine 223 | 224 | pure subroutine f_qd_comp_d_qd(a, b, r) 225 | real*8, intent(in) :: a, b(4) 226 | integer, intent(out) :: r 227 | end subroutine 228 | 229 | pure subroutine f_qd_pi(a) 230 | real*8, intent(out) :: a(4) 231 | end subroutine 232 | 233 | pure subroutine f_qd_nan(a) 234 | real*8, intent(out) :: a(4) 235 | end subroutine 236 | 237 | end interface 238 | end 239 | -------------------------------------------------------------------------------- /fortran/second.f.in: -------------------------------------------------------------------------------- 1 | function second () 2 | double precision second 3 | real*4 t(2) 4 | second = @ETIME@(t) 5 | return 6 | end 7 | 8 | -------------------------------------------------------------------------------- /fortran/zz_timer.f: -------------------------------------------------------------------------------- 1 | ! program to time the various routines 2 | subroutine f_main 3 | 4 | use @@module 5 | implicit none 6 | integer*4 old_cw 7 | double precision t 8 | double precision second 9 | double precision time_thresh 10 | parameter (time_thresh = 0.5d0) 11 | type (@@_real) a, b, c, d 12 | integer n, i, k 13 | 14 | call f_fpu_fix_start (old_cw) 15 | 16 | write (6, *) 'Timing addition / subtraction ...' 17 | n = 512 18 | do k = 1, 25 19 | n = n * 2 20 | a = @@pi() 21 | b = sqrt(a) 22 | c = sqrt(b) 23 | d = sqrt(c) 24 | t = second() 25 | do i = 1, n 26 | a = b + c 27 | b = a - d 28 | a = b + c 29 | b = a - d 30 | enddo 31 | t = second() - t 32 | if (t .ge. time_thresh) exit 33 | enddo 34 | n = n * 4 35 | write (6, *) n, ' operations in ', t, ' seconds.' 36 | write (6, *) t/n*1.0d6, ' usec' 37 | call @@write(6, a) 38 | 39 | write (6, *) 'Timing multiplication ...' 40 | n = 512 41 | do k = 1, 25 42 | n = n * 2 43 | a = 1.0d0 + @@pi() * 1.0d-7 44 | b = a + 1.0d-7 45 | c = b + 1.0d-8 46 | d = c + 1.0d-9 47 | t = second() 48 | do i = 1, n 49 | a = b * c 50 | b = a * d 51 | a = b * c 52 | b = a * d 53 | enddo 54 | t = second() - t 55 | if (t .ge. time_thresh) exit 56 | enddo 57 | n = n * 4 58 | write (6, *) n, ' operations in ', t, ' seconds.' 59 | write (6, *) t/n*1.0d6, ' usec' 60 | call @@write(6, a) 61 | 62 | write (6, *) 'Timing division ...' 63 | n = 512 64 | do k = 1, 25 65 | n = n * 2 66 | a = 1.0d0 + @@pi() 67 | b = 2.0d0 + @@pi() 68 | c = 1.0d0 + 1.0d-8 69 | d = 1.0d0 + 1.0d-9 70 | t = second() 71 | do i = 1, n 72 | a = b / c 73 | b = a / d 74 | a = b / c 75 | b = a / d 76 | enddo 77 | t = second() - t 78 | if (t .ge. time_thresh) exit 79 | enddo 80 | n = n * 4 81 | write (6, *) n, ' operations in ', t, ' seconds.' 82 | write (6, *) t/n*1.0d6, ' usec' 83 | call @@write(6, a) 84 | 85 | write (6, *) 'Timing square root ...' 86 | n = 512 87 | do k = 1, 25 88 | n = n * 2 89 | a = 0.0d0 90 | b = 2.0d0 + @@pi() 91 | t = second() 92 | do i = 1, n 93 | a = sqrt(a + b) 94 | enddo 95 | t = second() - t 96 | if (t .ge. time_thresh) exit 97 | enddo 98 | write (6, *) n, ' operations in ', t, ' seconds.' 99 | write (6, *) t/n*1.0d6, ' usec' 100 | call @@write(6, a) 101 | 102 | write (6, *) 'Timing sin ...' 103 | n = 512 104 | do k = 1, 25 105 | n = n * 2 106 | a = 0.0d0 107 | c = 1.7d0 * @@real(1.0d0) / dble(n) 108 | d = 2.45d0 * @@pi() / dble(n + 3) 109 | t = second() 110 | do i = 1, n 111 | a = a + sin(c) 112 | c = c + d 113 | enddo 114 | t = second() - t 115 | if (t .ge. time_thresh) exit 116 | enddo 117 | write (6, *) n, ' operations in ', t, ' seconds.' 118 | write (6, *) t/n*1.0d6, ' usec' 119 | call @@write(6, a) 120 | 121 | write (6, *) 'Timing log ...' 122 | n = 512 123 | do k = 1, 25 124 | n = n * 2 125 | a = 0.0d0 126 | c = exp(@@real(-50.1d0)); 127 | d = exp(@@real(100.2d0) / dble(n)) 128 | t = second() 129 | do i = 1, n 130 | a = a + log(c) 131 | c = c * d 132 | enddo 133 | t = second() - t 134 | if (t .ge. time_thresh) exit 135 | enddo 136 | write (6, *) n, ' operations in ', t, ' seconds.' 137 | write (6, *) t/n*1.0d6, ' usec' 138 | call @@write(6, a) 139 | 140 | end 141 | 142 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | nobase_include_HEADERS = qd/c_dd.h qd/c_qd.h qd/dd_real.h qd/dd_inline.h \ 2 | qd/fpu.h qd/inline.h qd/qd_real.h qd/qd_inline.h \ 3 | qd/bits.h 4 | 5 | nobase_nodist_include_HEADERS = qd/qd_config.h 6 | 7 | DISTCLEANFILES = qd/qd_config.h 8 | 9 | -------------------------------------------------------------------------------- /include/qd/bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/bits.h 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * This file defines various routines to get / set bits of a IEEE floating 11 | * point number. This is used by the library for debugging purposes. 12 | */ 13 | 14 | #ifndef _QD_BITS_H 15 | #define _QD_BITS_H 16 | 17 | #include 18 | #include 19 | 20 | /* Returns the exponent of the double precision number. 21 | Returns INT_MIN is x is zero, and INT_MAX if x is INF or NaN. */ 22 | int get_double_expn(double x); 23 | 24 | /* Prints 25 | SIGN EXPN MANTISSA 26 | of the given double. If x is NaN, INF, or Zero, this 27 | prints out the strings NaN, +/- INF, and 0. */ 28 | void print_double_info(std::ostream &os, double x); 29 | 30 | 31 | #endif /* _QD_BITS_H */ 32 | 33 | -------------------------------------------------------------------------------- /include/qd/c_dd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/c_dd.h 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * Contains C wrapper function prototypes for double-double precision 11 | * arithmetic. This can also be used from fortran code. 12 | */ 13 | #ifndef _QD_C_DD_H 14 | #define _QD_C_DD_H 15 | 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /* add */ 24 | void c_dd_add(const double *a, const double *b, double *c); 25 | void c_dd_add_d_dd(double a, const double *b, double *c); 26 | void c_dd_add_dd_d(const double *a, double b, double *c); 27 | 28 | /* sub */ 29 | void c_dd_sub(const double *a, const double *b, double *c); 30 | void c_dd_sub_d_dd(double a, const double *b, double *c); 31 | void c_dd_sub_dd_d(const double *a, double b, double *c); 32 | 33 | /* mul */ 34 | void c_dd_mul(const double *a, const double *b, double *c); 35 | void c_dd_mul_d_dd(double a, const double *b, double *c); 36 | void c_dd_mul_dd_d(const double *a, double b, double *c); 37 | 38 | /* div */ 39 | void c_dd_div(const double *a, const double *b, double *c); 40 | void c_dd_div_d_dd(double a, const double *b, double *c); 41 | void c_dd_div_dd_d(const double *a, double b, double *c); 42 | 43 | /* copy */ 44 | void c_dd_copy(const double *a, double *b); 45 | void c_dd_copy_d(double a, double *b); 46 | 47 | void c_dd_sqrt(const double *a, double *b); 48 | void c_dd_sqr(const double *a, double *b); 49 | 50 | void c_dd_abs(const double *a, double *b); 51 | 52 | void c_dd_npwr(const double *a, int b, double *c); 53 | void c_dd_nroot(const double *a, int b, double *c); 54 | 55 | void c_dd_nint(const double *a, double *b); 56 | void c_dd_aint(const double *a, double *b); 57 | void c_dd_floor(const double *a, double *b); 58 | void c_dd_ceil(const double *a, double *b); 59 | 60 | void c_dd_exp(const double *a, double *b); 61 | void c_dd_log(const double *a, double *b); 62 | void c_dd_log10(const double *a, double *b); 63 | 64 | void c_dd_sin(const double *a, double *b); 65 | void c_dd_cos(const double *a, double *b); 66 | void c_dd_tan(const double *a, double *b); 67 | 68 | void c_dd_asin(const double *a, double *b); 69 | void c_dd_acos(const double *a, double *b); 70 | void c_dd_atan(const double *a, double *b); 71 | void c_dd_atan2(const double *a, const double *b, double *c); 72 | 73 | void c_dd_sinh(const double *a, double *b); 74 | void c_dd_cosh(const double *a, double *b); 75 | void c_dd_tanh(const double *a, double *b); 76 | 77 | void c_dd_asinh(const double *a, double *b); 78 | void c_dd_acosh(const double *a, double *b); 79 | void c_dd_atanh(const double *a, double *b); 80 | 81 | void c_dd_sincos(const double *a, double *s, double *c); 82 | void c_dd_sincosh(const double *a, double *s, double *c); 83 | 84 | void c_dd_read(const char *s, double *a); 85 | void c_dd_swrite(const double *a, int precision, char *s, int len); 86 | void c_dd_write(const double *a); 87 | void c_dd_neg(const double *a, double *b); 88 | void c_dd_rand(double *a); 89 | void c_dd_comp(const double *a, const double *b, int *result); 90 | void c_dd_comp_dd_d(const double *a, double b, int *result); 91 | void c_dd_comp_d_dd(double a, const double *b, int *result); 92 | void c_dd_pi(double *a); 93 | void c_dd_2pi(double *a); 94 | double c_dd_epsilon(void); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | 100 | #endif /* _QD_C_DD_H */ 101 | -------------------------------------------------------------------------------- /include/qd/c_qd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/c_qd.h 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * Contains C wrapper function prototypes for quad-double precision 11 | * arithmetic. This can also be used from fortran code. 12 | */ 13 | #ifndef _QD_C_QD_H 14 | #define _QD_C_QD_H 15 | 16 | #include 17 | #include 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /* add */ 24 | void c_qd_add(const double *a, const double *b, double *c); 25 | void c_qd_add_dd_qd(const double *a, const double *b, double *c); 26 | void c_qd_add_qd_dd(const double *a, const double *b, double *c); 27 | void c_qd_add_d_qd(double a, const double *b, double *c); 28 | void c_qd_add_qd_d(const double *a, double b, double *c); 29 | void c_qd_selfadd(const double *a, double *b); 30 | void c_qd_selfadd_dd(const double *a, double *b); 31 | void c_qd_selfadd_d(double a, double *b); 32 | 33 | /* sub */ 34 | void c_qd_sub(const double *a, const double *b, double *c); 35 | void c_qd_sub_dd_qd(const double *a, const double *b, double *c); 36 | void c_qd_sub_qd_dd(const double *a, const double *b, double *c); 37 | void c_qd_sub_d_qd(double a, const double *b, double *c); 38 | void c_qd_sub_qd_d(const double *a, double b, double *c); 39 | void c_qd_selfsub(const double *a, double *b); 40 | void c_qd_selfsub_dd(const double *a, double *b); 41 | void c_qd_selfsub_d(double a, double *b); 42 | 43 | /* mul */ 44 | void c_qd_mul(const double *a, const double *b, double *c); 45 | void c_qd_mul_dd_qd(const double *a, const double *b, double *c); 46 | void c_qd_mul_qd_dd(const double *a, const double *b, double *c); 47 | void c_qd_mul_d_qd(double a, const double *b, double *c); 48 | void c_qd_mul_qd_d(const double *a, double b, double *c); 49 | void c_qd_selfmul(const double *a, double *b); 50 | void c_qd_selfmul_dd(const double *a, double *b); 51 | void c_qd_selfmul_d(double a, double *b); 52 | 53 | /* div */ 54 | void c_qd_div(const double *a, const double *b, double *c); 55 | void c_qd_div_dd_qd(const double *a, const double *b, double *c); 56 | void c_qd_div_qd_dd(const double *a, const double *b, double *c); 57 | void c_qd_div_d_qd(double a, const double *b, double *c); 58 | void c_qd_div_qd_d(const double *a, double b, double *c); 59 | void c_qd_selfdiv(const double *a, double *b); 60 | void c_qd_selfdiv_dd(const double *a, double *b); 61 | void c_qd_selfdiv_d(double a, double *b); 62 | 63 | /* copy */ 64 | void c_qd_copy(const double *a, double *b); 65 | void c_qd_copy_dd(const double *a, double *b); 66 | void c_qd_copy_d(double a, double *b); 67 | 68 | int c_qd_sqrt(const double *a, double *b); 69 | void c_qd_sqr(const double *a, double *b); 70 | 71 | void c_qd_abs(const double *a, double *b); 72 | 73 | void c_qd_npwr(const double *a, int b, double *c); 74 | void c_qd_nroot(const double *a, int b, double *c); 75 | 76 | void c_qd_nint(const double *a, double *b); 77 | void c_qd_aint(const double *a, double *b); 78 | void c_qd_floor(const double *a, double *b); 79 | void c_qd_ceil(const double *a, double *b); 80 | 81 | void c_qd_exp(const double *a, double *b); 82 | void c_qd_log(const double *a, double *b); 83 | void c_qd_log10(const double *a, double *b); 84 | 85 | void c_qd_sin(const double *a, double *b); 86 | void c_qd_cos(const double *a, double *b); 87 | void c_qd_tan(const double *a, double *b); 88 | 89 | void c_qd_asin(const double *a, double *b); 90 | void c_qd_acos(const double *a, double *b); 91 | void c_qd_atan(const double *a, double *b); 92 | void c_qd_atan2(const double *a, const double *b, double *c); 93 | 94 | void c_qd_sinh(const double *a, double *b); 95 | void c_qd_cosh(const double *a, double *b); 96 | void c_qd_tanh(const double *a, double *b); 97 | 98 | void c_qd_asinh(const double *a, double *b); 99 | void c_qd_acosh(const double *a, double *b); 100 | void c_qd_atanh(const double *a, double *b); 101 | 102 | void c_qd_sincos(const double *a, double *s, double *c); 103 | void c_qd_sincosh(const double *a, double *s, double *c); 104 | 105 | void c_qd_read(const char *s, double *a); 106 | void c_qd_swrite(const double *a, int precision, char *s, int len); 107 | void c_qd_write(const double *a); 108 | void c_qd_neg(const double *a, double *b); 109 | void c_qd_rand(double *a); 110 | void c_qd_comp(const double *a, const double *b, int *result); 111 | void c_qd_comp_qd_d(const double *a, double b, int *result); 112 | void c_qd_comp_d_qd(double a, const double *b, int *result); 113 | void c_qd_pi(double *a); 114 | void c_qd_2pi(double *a); 115 | double c_qd_epsilon(void); 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* _QD_C_QD_H */ 122 | -------------------------------------------------------------------------------- /include/qd/fpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/fpu.h 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2001 9 | * 10 | * Contains functions to set and restore the round-to-double flag in the 11 | * control word of a x86 FPU. The algorithms in the double-double and 12 | * quad-double package does not function with the extended mode found in 13 | * these FPU. 14 | */ 15 | #ifndef _QD_FPU_H 16 | #define _QD_FPU_H 17 | 18 | #include 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /* 25 | * Set the round-to-double flag, and save the old control word in old_cw. 26 | * If old_cw is NULL, the old control word is not saved. 27 | */ 28 | QD_API void fpu_fix_start(unsigned int *old_cw); 29 | 30 | /* 31 | * Restore the control word. 32 | */ 33 | QD_API void fpu_fix_end(unsigned int *old_cw); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* _QD_FPU_H */ 40 | -------------------------------------------------------------------------------- /include/qd/inline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * include/inline.h 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * This file contains the basic functions used both by double-double 11 | * and quad-double package. These are declared as inline functions as 12 | * they are the smallest building blocks of the double-double and 13 | * quad-double arithmetic. 14 | */ 15 | #ifndef _QD_INLINE_H 16 | #define _QD_INLINE_H 17 | 18 | #define _QD_SPLITTER 134217729.0 // = 2^27 + 1 19 | #define _QD_SPLIT_THRESH 6.69692879491417e+299 // = 2^996 20 | 21 | #ifdef QD_VACPP_BUILTINS_H 22 | /* For VisualAge C++ __fmadd */ 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | 29 | namespace qd { 30 | 31 | static const double _d_nan = std::numeric_limits::quiet_NaN(); 32 | static const double _d_inf = std::numeric_limits::infinity(); 33 | 34 | /*********** Basic Functions ************/ 35 | /* Computes fl(a+b) and err(a+b). Assumes |a| >= |b|. */ 36 | inline double quick_two_sum(double a, double b, double &err) { 37 | double s = a + b; 38 | err = b - (s - a); 39 | return s; 40 | } 41 | 42 | /* Computes fl(a-b) and err(a-b). Assumes |a| >= |b| */ 43 | inline double quick_two_diff(double a, double b, double &err) { 44 | double s = a - b; 45 | err = (a - s) - b; 46 | return s; 47 | } 48 | 49 | /* Computes fl(a+b) and err(a+b). */ 50 | inline double two_sum(double a, double b, double &err) { 51 | double s = a + b; 52 | double bb = s - a; 53 | err = (a - (s - bb)) + (b - bb); 54 | return s; 55 | } 56 | 57 | /* Computes fl(a-b) and err(a-b). */ 58 | inline double two_diff(double a, double b, double &err) { 59 | double s = a - b; 60 | double bb = s - a; 61 | err = (a - (s - bb)) - (b + bb); 62 | return s; 63 | } 64 | 65 | #ifndef QD_FMS 66 | /* Computes high word and lo word of a */ 67 | inline void split(double a, double &hi, double &lo) { 68 | double temp; 69 | if (a > _QD_SPLIT_THRESH || a < -_QD_SPLIT_THRESH) { 70 | a *= 3.7252902984619140625e-09; // 2^-28 71 | temp = _QD_SPLITTER * a; 72 | hi = temp - (temp - a); 73 | lo = a - hi; 74 | hi *= 268435456.0; // 2^28 75 | lo *= 268435456.0; // 2^28 76 | } else { 77 | temp = _QD_SPLITTER * a; 78 | hi = temp - (temp - a); 79 | lo = a - hi; 80 | } 81 | } 82 | #endif 83 | 84 | /* Computes fl(a*b) and err(a*b). */ 85 | inline double two_prod(double a, double b, double &err) { 86 | #ifdef QD_FMS 87 | double p = a * b; 88 | err = QD_FMS(a, b, p); 89 | return p; 90 | #else 91 | double a_hi, a_lo, b_hi, b_lo; 92 | double p = a * b; 93 | split(a, a_hi, a_lo); 94 | split(b, b_hi, b_lo); 95 | err = ((a_hi * b_hi - p) + a_hi * b_lo + a_lo * b_hi) + a_lo * b_lo; 96 | return p; 97 | #endif 98 | } 99 | 100 | /* Computes fl(a*a) and err(a*a). Faster than the above method. */ 101 | inline double two_sqr(double a, double &err) { 102 | #ifdef QD_FMS 103 | double p = a * a; 104 | err = QD_FMS(a, a, p); 105 | return p; 106 | #else 107 | double hi, lo; 108 | double q = a * a; 109 | split(a, hi, lo); 110 | err = ((hi * hi - q) + 2.0 * hi * lo) + lo * lo; 111 | return q; 112 | #endif 113 | } 114 | 115 | /* Computes the nearest integer to d. */ 116 | inline double nint(double d) { 117 | if (d == std::floor(d)) 118 | return d; 119 | return std::floor(d + 0.5); 120 | } 121 | 122 | /* Computes the truncated integer. */ 123 | inline double aint(double d) { 124 | return (d >= 0.0) ? std::floor(d) : std::ceil(d); 125 | } 126 | 127 | /* These are provided to give consistent 128 | interface for double with double-double and quad-double. */ 129 | inline void sincosh(double t, double &sinh_t, double &cosh_t) { 130 | sinh_t = std::sinh(t); 131 | cosh_t = std::cosh(t); 132 | } 133 | 134 | inline double sqr(double t) { 135 | return t * t; 136 | } 137 | 138 | inline double to_double(double a) { return a; } 139 | inline int to_int(double a) { return static_cast(a); } 140 | 141 | } 142 | 143 | #endif /* _QD_INLINE_H */ 144 | -------------------------------------------------------------------------------- /include/qd/qd_config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef _QD_QD_CONFIG_H 2 | #define _QD_QD_CONFIG_H 1 3 | 4 | #ifndef QD_API 5 | #undef QD_API 6 | #endif 7 | 8 | /* Set to 1 if using VisualAge C++ compiler for __fmadd builtin. */ 9 | #ifndef QD_VACPP_BUILTINS_H 10 | #undef QD_VACPP_BUILTINS_H 11 | #endif 12 | 13 | /* If fused multiply-add is available, define to correct macro for 14 | using it. It is invoked as QD_FMA(a, b, c) to compute fl(a * b + c). 15 | If correctly rounded multiply-add is not available (or if unsure), 16 | keep it undefined.*/ 17 | #ifndef QD_FMA 18 | #undef QD_FMA 19 | #endif 20 | 21 | /* If fused multiply-subtract is available, define to correct macro for 22 | using it. It is invoked as QD_FMS(a, b, c) to compute fl(a * b - c). 23 | If correctly rounded multiply-add is not available (or if unsure), 24 | keep it undefined.*/ 25 | #ifndef QD_FMS 26 | #undef QD_FMS 27 | #endif 28 | 29 | /* Set the following to 1 to define commonly used function 30 | to be inlined. This should be set to 1 unless the compiler 31 | does not support the "inline" keyword, or if building for 32 | debugging purposes. */ 33 | #ifndef QD_INLINE 34 | #undef QD_INLINE 35 | #endif 36 | 37 | /* Set the following to 1 to use ANSI C++ standard header files 38 | such as cmath, iostream, etc. If set to zero, it will try to 39 | include math.h, iostream.h, etc, instead. */ 40 | #ifndef QD_HAVE_STD 41 | #undef QD_HAVE_STD 42 | #endif 43 | 44 | /* Set the following to 1 to make the addition and subtraction 45 | to satisfy the IEEE-style error bound 46 | 47 | fl(a + b) = (1 + d) * (a + b) 48 | 49 | where |d| <= eps. If set to 0, the addition and subtraction 50 | will satisfy the weaker Cray-style error bound 51 | 52 | fl(a + b) = (1 + d1) * a + (1 + d2) * b 53 | 54 | where |d1| <= eps and |d2| eps. */ 55 | #ifndef QD_IEEE_ADD 56 | #undef QD_IEEE_ADD 57 | #endif 58 | 59 | /* Set the following to 1 to use slightly inaccurate but faster 60 | version of multiplication. */ 61 | #ifndef QD_SLOPPY_MUL 62 | #undef QD_SLOPPY_MUL 63 | #endif 64 | 65 | /* Set the following to 1 to use slightly inaccurate but faster 66 | version of division. */ 67 | #ifndef QD_SLOPPY_DIV 68 | #undef QD_SLOPPY_DIV 69 | #endif 70 | 71 | /* Define this macro to be the isfinite(x) function. */ 72 | #ifndef QD_ISFINITE 73 | #undef QD_ISFINITE 74 | #endif 75 | 76 | /* Define this macro to be the isinf(x) function. */ 77 | #ifndef QD_ISINF 78 | #undef QD_ISINF 79 | #endif 80 | 81 | /* Define this macro to be the isnan(x) function. */ 82 | #ifndef QD_ISNAN 83 | #undef QD_ISNAN 84 | #endif 85 | 86 | 87 | #endif /* _QD_QD_CONFIG_H */ 88 | -------------------------------------------------------------------------------- /m4/ax_cxx_clock_gettime.m4: -------------------------------------------------------------------------------- 1 | dnl Tries to determine whether clock_gettime is useable. 2 | dnl 3 | AC_DEFUN([AX_CXX_CLOCK_GETTIME], [ 4 | AC_MSG_CHECKING([for clock_gettime useability]) 5 | AC_LANG_PUSH(C++) 6 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 7 | #include 8 | int main() { 9 | struct timespec tv; 10 | return clock_gettime(CLOCK_REALTIME, &tv); 11 | } 12 | ])], [ax_cxx_clock_gettime="yes"], [ax_cxx_clock_gettime="no"]) 13 | AC_LANG_POP(C++) 14 | AC_MSG_RESULT([$ax_cxx_clock_gettime]) 15 | ]) 16 | 17 | -------------------------------------------------------------------------------- /m4/ax_cxx_copysign.m4: -------------------------------------------------------------------------------- 1 | dnl Tries to determine if the copysign function exists in std namespace, 2 | dnl global namespace, or doesn't exist (in which case an appropriate 3 | dnl macro is generated). The result is put into ax_cxx_copysign. 4 | dnl 5 | AC_DEFUN([AX_CXX_COPYSIGN], [ 6 | AC_MSG_CHECKING([for copysign]) 7 | AC_LANG_PUSH(C++) 8 | ax_cxx_copysign= 9 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 10 | int main() { 11 | std::copysign(1.0, 1.0); 12 | return 0; 13 | }])], 14 | [AC_MSG_RESULT(std::copysign) 15 | ax_cxx_copysign="std::copysign(x, y)"]) 16 | if test "x$ax_cxx_copysign" = "x"; then 17 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 18 | int main() { 19 | ::copysign(1.0, 1.0); 20 | return 0; 21 | }])], 22 | [AC_MSG_RESULT(::copysign) 23 | ax_cxx_copysign="::copysign(x, y)"], 24 | [AC_MSG_RESULT(none) 25 | ax_cxx_copysign="( ((y) != 0.0) ? ( ((y) > 0.0) ? (x) : -(x) ) : ( ((1.0 / y) > 0.0) ? (x) : -(x) ) )"]) 26 | fi 27 | AC_LANG_POP(C++) 28 | ]) 29 | -------------------------------------------------------------------------------- /m4/ax_cxx_fc_lib.m4: -------------------------------------------------------------------------------- 1 | dnl Still not quite there yet, as FC_DUMMY_MAIN may be needed 2 | dnl but that complicates matters since FC_DUMMY_MAIN needs the 3 | dnl correct libraries to link. 4 | dnl 5 | AC_DEFUN([AX_CXX_FC_LIB], [ 6 | AC_MSG_CHECKING([whether extra library is needed to link Fortran and C++]) 7 | AC_LANG_PUSH(C++) 8 | ax_cxx_fc_lib= 9 | ax_cxx_fc_lib_names="none -lompstubs -lmtsk" 10 | for name in $ax_cxx_fc_lib_names; do 11 | if test "x$name" = xnone; then 12 | lib="" 13 | else 14 | lib=$name 15 | fi 16 | save_LIBS="$LIBS" 17 | LIBS="$LIBS $FCLIBS $lib" 18 | AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [ax_cxx_fc_lib=$name], []) 19 | LIBS="$save_LIBS" 20 | if test "x$ax_cxx_fc_lib" != "x"; then 21 | break 22 | fi 23 | done 24 | AC_LANG_POP(C++) 25 | if test "x$ax_cxx_fc_lib" != x; then 26 | AC_MSG_RESULT($ax_cxx_fc_lib) 27 | if test "x$ax_cxx_fc_lib" = xnone; then 28 | ax_cxx_fc_lib= 29 | fi 30 | ifelse([$1],,FCLIBS="$FCLIBS $ax_cxx_fc_lib", [$2]) 31 | else 32 | AC_MSG_RESULT(unknown) 33 | ifelse([$2],,AC_MSG_ERROR(Cannot link C++ and Fortran.), [$2]) 34 | fi 35 | ]) 36 | -------------------------------------------------------------------------------- /m4/ax_cxx_fma.m4: -------------------------------------------------------------------------------- 1 | dnl Tries to determine appropriate function names for 2 | dnl fused multiply-add (fma) and fused multiply-subtract (fms). 3 | dnl 4 | dnl Usage: ACX_CXX_FMA(list) 5 | dnl where fma_list can contain any of ibm, c99. If list is 6 | dnl blank it will search for a first compatible function. 7 | dnl 8 | AC_DEFUN([AX_CXX_FMA], [ 9 | AC_MSG_CHECKING([for fused multiply-add/subtract]) 10 | AC_LANG_PUSH(C++) 11 | ax_cxx_fma_list=$1 12 | if test "x$ax_cxx_fma_list" = "x"; then 13 | ax_cxx_fma_list="ibm gnu c99 compiler" 14 | fi 15 | ax_cxx_fma= 16 | ax_cxx_fms= 17 | for name in $ax_cxx_fma_list; do 18 | if test "x$ax_cxx_fma" = "x"; then 19 | case $name in 20 | ibm) 21 | # IBM VisualAge C++ __fmadd / __fmsub. 22 | AC_RUN_IFELSE([AC_LANG_SOURCE([#include 23 | #include 24 | int main() { 25 | double d = std::ldexp(1.0, -52); 26 | double x = __fmadd(1.0 + d, 1.0 - d, -1.0); 27 | double y = __fmsub(1.0 + d, 1.0 - d, 1.0); 28 | return (x == -d*d && y == -d*d) ? 0 : 1; 29 | }])], 30 | [ax_cxx_fma="__fmadd(x,y,z)" 31 | ax_cxx_fms="__fmsub(x,y,z)" 32 | AC_DEFINE([QD_VACPP_BUILTINS_H], [1], 33 | [Set to 1 if using VisualAge C++ compiler for __fmadd builtin.])]) 34 | ;; 35 | gnu) 36 | # Later gcc (3.4 and later) have __builtin_fma that seems to work. 37 | AC_RUN_IFELSE([AC_LANG_SOURCE([#include 38 | int main() { 39 | double d = std::ldexp(1.0, -52); 40 | return (__builtin_fma(1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1); 41 | }])], 42 | [ax_cxx_fma="__builtin_fma(x,y,z)" 43 | ax_cxx_fms="__builtin_fma(x,y,-z)"]) 44 | ;; 45 | ia64) 46 | # Intel and HP compilers for IA 64 architecture seems to have 47 | # _Asm_fma/fms macros. Not much documentation is available for 48 | # these... 49 | AC_RUN_IFELSE([AC_LANG_SOURCE([#include 50 | int main() { 51 | double d = std::ldexp(1.0, -52); 52 | return (_Asm_fma(2, 1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1); 53 | }])], 54 | [ax_cxx_fma="_Asm_fma(2, x,y,z)" 55 | ax_cxx_fms="_Asm_fms(2, x,y,z)"]) 56 | ;; 57 | c99) 58 | # Try C99 fma() function. Some platforms doesn't seem to implement this 59 | # correctly (Apple gcc-3.3 for example). 60 | AC_RUN_IFELSE([AC_LANG_SOURCE([#include 61 | int main() { 62 | double d = std::ldexp(1.0, -52); 63 | return (fma(1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1); 64 | }])], 65 | [ax_cxx_fma="fma(x,y,z)" 66 | ax_cxx_fms="fma(x,y,-z)"]) 67 | ;; 68 | compiler) 69 | # Try relying on the compiler to optimize x * y + z into an fma. 70 | # This method is not recommended since if it is inlined it does not 71 | # always produce the same correct code. 72 | AC_RUN_IFELSE([AC_LANG_SOURCE([#include 73 | int main() { 74 | double d = std::ldexp(1.0, -52); 75 | return ( (1.0 + d) * (1.0 - d) - 1.0 == -d*d ? 0 : 1); 76 | }])], 77 | [ax_cxx_fma="((x)*(y) + (z))" 78 | ax_cxx_fms="((x)*(y) - (z))"]) 79 | ;; 80 | *) AC_MSG_ERROR([Unknown option $name to --enable-fma.]) ;; 81 | esac 82 | fi 83 | done 84 | AC_LANG_POP(C++) 85 | if test "x$ax_cxx_fma" != "x"; then 86 | AC_MSG_RESULT([$ax_cxx_fma, $ax_cxx_fms]) 87 | else 88 | AC_MSG_RESULT(none) 89 | fi 90 | ]) 91 | -------------------------------------------------------------------------------- /m4/ax_cxx_isfinite.m4: -------------------------------------------------------------------------------- 1 | dnl Tries to determine if the isfinite function exists in std namespace, 2 | dnl global namespace, or doesn't exist (in which case an appropriate 3 | dnl macro is generated). The result is put into ax_cxx_isfinite. 4 | dnl 5 | AC_DEFUN([AX_CXX_ISFINITE], [ 6 | AC_MSG_CHECKING([for isfinite]) 7 | AC_LANG_PUSH(C++) 8 | ax_cxx_isfinite= 9 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 10 | int main() { 11 | std::isfinite(1.0); 12 | return 0; 13 | }])], 14 | [AC_MSG_RESULT(std::isfinite) 15 | ax_cxx_isfinite="std::isfinite(x)"]) 16 | if test "x$ax_cxx_isfinite" = "x"; then 17 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 18 | int main() { 19 | ::isfinite(1.0); 20 | return 0; 21 | }])], 22 | [AC_MSG_RESULT(::isfinite) 23 | ax_cxx_isfinite="::isfinite(x)"], 24 | [AC_MSG_RESULT(none) 25 | ax_cxx_isfinite="( ((x) == 0.0) || ((x) != (2.0 * (x))) )"]) 26 | fi 27 | AC_LANG_POP(C++) 28 | ]) 29 | -------------------------------------------------------------------------------- /m4/ax_cxx_isinf.m4: -------------------------------------------------------------------------------- 1 | dnl Tries to determine if the isinf function exists in std namespace, 2 | dnl global namespace, or doesn't exist (in which case an appropriate 3 | dnl macro is generated). The result is put into ax_cxx_isinf. 4 | dnl 5 | AC_DEFUN([AX_CXX_ISINF], [ 6 | AC_MSG_CHECKING([for isinf]) 7 | AC_LANG_PUSH(C++) 8 | ax_cxx_isinf= 9 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 10 | int main() { 11 | std::isinf(1.0); 12 | return 0; 13 | }])], 14 | [AC_MSG_RESULT(std::isinf) 15 | ax_cxx_isinf="std::isinf(x)"]) 16 | if test "x$ax_cxx_isinf" = "x"; then 17 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 18 | int main() { 19 | ::isinf(1.0); 20 | return 0; 21 | }])], 22 | [AC_MSG_RESULT(::isinf) 23 | ax_cxx_isinf="::isinf(x)"], 24 | [AC_MSG_RESULT(none) 25 | ax_cxx_isinf="( (x) != 0.0 && (x) == 2.0 * (x) )"]) 26 | fi 27 | AC_LANG_POP(C++) 28 | ]) 29 | -------------------------------------------------------------------------------- /m4/ax_cxx_isnan.m4: -------------------------------------------------------------------------------- 1 | dnl Tries to determine if the isnan function exists in std namespace, 2 | dnl global namespace, or doesn't exist (in which case an appropriate 3 | dnl macro is generated). The result is put into ax_cxx_isnan. 4 | dnl 5 | AC_DEFUN([AX_CXX_ISNAN], [ 6 | AC_MSG_CHECKING([for isnan]) 7 | AC_LANG_PUSH(C++) 8 | ax_cxx_isnan= 9 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 10 | int main() { 11 | std::isnan(1.0); 12 | return 0; 13 | }])], 14 | [AC_MSG_RESULT(std::isnan) 15 | ax_cxx_isnan="std::isnan(x)"]) 16 | if test "x$ax_cxx_isnan" = "x"; then 17 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include 18 | int main() { 19 | ::isnan(1.0); 20 | return 0; 21 | }])], 22 | [AC_MSG_RESULT(::isnan) 23 | ax_cxx_isnan="::isnan(x)"], 24 | [AC_MSG_RESULT(none) 25 | ax_cxx_isnan="((x) != (x))"]) 26 | fi 27 | AC_LANG_POP(C++) 28 | ]) 29 | -------------------------------------------------------------------------------- /m4/ax_f90_module_flag.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AX_F90_MODULE_FLAG 2 | dnl 3 | dnl @summary Find Fortran 90 modules inclusion flag. 4 | dnl 5 | dnl Find Fortran 90 modules inclusion flag. The module inclusion flag 6 | dnl is stored in the cached variable ax_f90_modflag. An error is 7 | dnl triggered if the flag cannot be found. Supported are the -I GNU 8 | dnl compilers flag, the -M SUN compilers flag, and the -p Absoft Pro 9 | dnl Fortran compiler flag. 10 | dnl 11 | dnl @category Fortran 12 | dnl @author Luc Maisonobe 13 | dnl @author Julian C. Cummings 14 | dnl @version 2006-01-28 15 | dnl @license AllPermissive 16 | 17 | AC_DEFUN([AX_F90_MODULE_FLAG],[ 18 | AC_CACHE_CHECK([fortran 90 modules inclusion flag], 19 | ax_cv_f90_modflag, 20 | [AC_LANG_PUSH(Fortran) 21 | i=0 22 | while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do 23 | i=`expr $i + 1` 24 | done 25 | mkdir tmpdir_$i 26 | cd tmpdir_$i 27 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([module conftest_module 28 | contains 29 | subroutine conftest_routine 30 | write(*,'(a)') 'gotcha!' 31 | end subroutine conftest_routine 32 | end module conftest_module 33 | ])],[],[]) 34 | cd .. 35 | ax_f90_modflag="not found" 36 | for ax_flag in "-I " "-M" "-p"; do 37 | if test "$ax_f90_modflag" = "not found" ; then 38 | ax_save_FCFLAGS="$FCFLAGS" 39 | FCFLAGS="$ax_save_FCFLAGS ${ax_flag}tmpdir_$i" 40 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([program conftest_program 41 | use conftest_module 42 | call conftest_routine 43 | end program conftest_program 44 | ])],[ax_f90_modflag="$ax_flag"],[]) 45 | FCFLAGS="$ax_save_FCFLAGS" 46 | fi 47 | done 48 | rm -fr tmpdir_$i 49 | if test "$ax_modflag" = "not found" ; then 50 | AC_MSG_ERROR([unable to find compiler flag for modules inclusion]) 51 | fi 52 | AC_LANG_POP(Fortran) 53 | ])]) 54 | -------------------------------------------------------------------------------- /m4/ax_f90_module_style.m4: -------------------------------------------------------------------------------- 1 | dnl ax_f90_module_style 2 | dnl 3 | dnl Figures out the F90 module naming style: 4 | dnl - whether the base name is lower or upper case, and 5 | dnl - the suffix (usually .mod or .MOD). 6 | dnl 7 | dnl Y. Hida (2006-02-17) 8 | dnl 9 | dnl The code is based on the ax_f90_module_extension code: 10 | dnl 11 | dnl @synopsis AX_F90_MODULE_EXTENSION 12 | dnl 13 | dnl Find Fortran 90 modules file extension. The module extension is 14 | dnl stored in the cached variable ax_f90_modext, or "unknown" if the 15 | dnl extension cannot be found. 16 | dnl 17 | dnl @category Fortran 18 | dnl @author Luc Maisonobe 19 | dnl @version 2005-06-17 20 | dnl @license AllPermissive 21 | 22 | AC_DEFUN([AX_F90_MODULE_STYLE],[ 23 | AC_CACHE_CHECK([fortran 90 modules naming style], 24 | ax_cv_f90_module_style, 25 | [AC_LANG_PUSH(Fortran) 26 | i=0 27 | while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do 28 | i=`expr $i + 1` 29 | done 30 | mkdir tmpdir_$i 31 | cd tmpdir_$i 32 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([module conftest_module 33 | contains 34 | subroutine conftest_routine 35 | write(*,'(a)') 'gotcha!' 36 | end subroutine conftest_routine 37 | end module conftest_module 38 | ])], 39 | [ax_f90_modext=`ls | sed -n 's,conftest_module\.,,p'` 40 | if test x$ax_f90_modext = x ; then 41 | dnl Some F90 compilers put module filename in uppercase letters 42 | ax_f90_modext=`ls | sed -n 's,CONFTEST_MODULE\.,,p'` 43 | if test x$ax_f90_modext = x ; then 44 | ax_f90_modext=unknown 45 | else 46 | ax_f90_module_style="uppercase, $ax_f90_modext" 47 | fi 48 | else 49 | ax_f90_module_style="lowercase, $ax_f90_modext" 50 | fi 51 | ], 52 | [ax_f90_module_style=unknown]) 53 | cd .. 54 | rm -fr tmpdir_$i 55 | AC_LANG_POP(Fortran) 56 | ])]) 57 | -------------------------------------------------------------------------------- /m4/ax_fc_etime.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AX_FC_ETIME], [ 2 | AC_MSG_CHECKING([for etime]) 3 | AC_LANG_PUSH(Fortran) 4 | ax_fc_etime= 5 | ax_fc_etime_names="etime etime_" 6 | for name in $ax_fc_etime_names; do 7 | AC_LINK_IFELSE([AC_LANG_PROGRAM(, [AC_LANG_SOURCE([ 8 | real*4 t(2), tot 9 | tot = $name(t)])])], 10 | [ax_fc_etime=$name], []) 11 | if test "x$ax_fc_etime" != "x"; then 12 | break; 13 | fi 14 | done 15 | AC_LANG_POP(Fortran) 16 | if test "x$ax_fc_etime" != "x"; then 17 | AC_MSG_RESULT($ax_fc_etime) 18 | $1 19 | else 20 | AC_MSG_RESULT(none) 21 | ifelse([$2],,AC_MSG_ERROR([Cannot find etime.]), [$2]) 22 | fi 23 | ]) 24 | -------------------------------------------------------------------------------- /qd-config.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # @configure_input@ 3 | prefix="@prefix@" 4 | exec_prefix="@exec_prefix@" 5 | includedir="@includedir@" 6 | libdir="@libdir@" 7 | bindir="@bindir@" 8 | datadir="@datarootdir@" 9 | mandir="@mandir@" 10 | sysconfdir="@sysconfdir@" 11 | sharedstatedir="@sharedstatedir@" 12 | srcdir="@abs_top_srcdir@" 13 | builddir="@abs_top_builddir@" 14 | build_CXXFLAGS="@CXXFLAGS@" 15 | build_LDFLAGS="@LDFLAGS@" 16 | CXX="@CXX@" 17 | CXXFLAGS="-I$includedir" 18 | FC="@FC@" 19 | 20 | LDFLAGS="-L$libdir -lqd @LIBS@" 21 | STATICLDFLAGS="$libdir/libqd.a @LIBS@" 22 | LALDFLAGS="$libdir/libqd.la @LIBS@" 23 | SRC_LDFLAGS="$builddir/src/.libs/libqd.so @LIBS@" 24 | SRC_LALDFLAGS="$builddir/src/libqd.la @LIBS@" 25 | SRC_STATICLDFLAGS="$builddir/src/.libs/libqd.a @LIBS@" 26 | 27 | CFLAGS="@CPPFLAGS@ -I$includedir" 28 | SRC_CFLAGS="-I$srcdir/src -I$builddir/src @CPPFLAGS@" 29 | 30 | FCLIBS="-L$libdir -lqdmod -lqd @LIBS@ @FCLIBS@" 31 | FMAINLIB="-L$libdir -lqd_f_main" 32 | FCFLAGS="@REQ_FCFLAGS@" 33 | MODFLAG="@ax_f90_modflag@$includedir/qd" 34 | 35 | build="@BUILDER@-@BUILDDATE@" 36 | configure_args="@CONFIGURE_ARGS@" 37 | from_source=0 38 | usage() 39 | { 40 | cat <&2 141 | ;; 142 | esac 143 | shift 144 | done 145 | 146 | -------------------------------------------------------------------------------- /qd.pc.in: -------------------------------------------------------------------------------- 1 | /------------------ qd.pc ------------------------ 2 | prefix=@prefix@ 3 | exec_prefix=@prefix@ 4 | libdir=@prefix@/lib 5 | includedir=@prefix@/include 6 | 7 | Name: qd 8 | Description: A C++/Fortran-90 double-double and quad-double package 9 | URL: http://crd-legacy.lbl.gov/~dhbailey/mpdist/ 10 | Version: @VERSION@ 11 | Requires: 12 | Libs: -L@libdir@ -lqd 13 | Cflags: -I@includedir@ 14 | \------------------------------------------------------- 15 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | SRC = c_dd.cpp c_qd.cpp dd_real.cpp dd_const.cpp \ 2 | fpu.cpp qd_real.cpp qd_const.cpp util.cpp bits.cpp util.h 3 | 4 | lib_LTLIBRARIES = libqd.la 5 | 6 | libqd_la_SOURCES = $(SRC) 7 | 8 | AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include 9 | 10 | -------------------------------------------------------------------------------- /src/bits.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * src/bits.cc 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * Defines various routines to get / set bits of a IEEE floating point 11 | * number. This used by the library for debugging purposes. 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "config.h" 20 | #include 21 | #include 22 | 23 | #ifdef HAVE_IEEEFP_H 24 | #include 25 | #endif 26 | 27 | using std::setw; 28 | 29 | int get_double_expn(double x) { 30 | if (x == 0.0) 31 | return INT_MIN; 32 | if (QD_ISINF(x) || QD_ISNAN(x)) 33 | return INT_MAX; 34 | 35 | double y = std::abs(x); 36 | int i = 0; 37 | if (y < 1.0) { 38 | while (y < 1.0) { 39 | y *= 2.0; 40 | i++; 41 | } 42 | return -i; 43 | } else if (y >= 2.0) { 44 | while (y >= 2.0) { 45 | y *= 0.5; 46 | i++; 47 | } 48 | return i; 49 | } 50 | return 0; 51 | } 52 | 53 | void print_double_info(std::ostream &os, double x) { 54 | std::streamsize old_prec = os.precision(19); 55 | std::ios_base::fmtflags old_flags = os.flags(); 56 | os << std::scientific; 57 | 58 | os << setw(27) << x << ' '; 59 | if (QD_ISNAN(x) || QD_ISINF(x) || (x == 0.0)) { 60 | os << " "; 61 | } else { 62 | 63 | x = std::abs(x); 64 | int expn = get_double_expn(x); 65 | double d = std::ldexp(1.0, expn); 66 | os << setw(5) << expn << " "; 67 | for (int i = 0; i < 53; i++) { 68 | if (x >= d) { 69 | x -= d; 70 | os << '1'; 71 | } else 72 | os << '0'; 73 | d *= 0.5; 74 | } 75 | 76 | if (x != 0.0) { 77 | // should not happen 78 | os << " +trailing stuff"; 79 | } 80 | } 81 | 82 | os.precision(old_prec); 83 | os.flags(old_flags); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/c_dd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * src/c_dd.cc 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * Contains the C wrapper functions for double-double precision arithmetic. 11 | * This can be used from Fortran code. 12 | */ 13 | #include 14 | 15 | #include "config.h" 16 | #include 17 | #include 18 | 19 | #define TO_DOUBLE_PTR(a, ptr) ptr[0] = a.x[0]; ptr[1] = a.x[1]; 20 | 21 | extern "C" { 22 | 23 | /* add */ 24 | void c_dd_add(const double *a, const double *b, double *c) { 25 | dd_real cc; 26 | cc = dd_real(a) + dd_real(b); 27 | TO_DOUBLE_PTR(cc, c); 28 | } 29 | void c_dd_add_dd_d(const double *a, double b, double *c) { 30 | dd_real cc; 31 | cc = dd_real(a) + b; 32 | TO_DOUBLE_PTR(cc, c); 33 | } 34 | void c_dd_add_d_dd(double a, const double *b, double *c) { 35 | dd_real cc; 36 | cc = a + dd_real(b); 37 | TO_DOUBLE_PTR(cc, c); 38 | } 39 | 40 | 41 | /* sub */ 42 | void c_dd_sub(const double *a, const double *b, double *c) { 43 | dd_real cc; 44 | cc = dd_real(a) - dd_real(b); 45 | TO_DOUBLE_PTR(cc, c); 46 | } 47 | void c_dd_sub_dd_d(const double *a, double b, double *c) { 48 | dd_real cc; 49 | cc = dd_real(a) - b; 50 | TO_DOUBLE_PTR(cc, c); 51 | } 52 | void c_dd_sub_d_dd(double a, const double *b, double *c) { 53 | dd_real cc; 54 | cc = a - dd_real(b); 55 | TO_DOUBLE_PTR(cc, c); 56 | } 57 | 58 | 59 | /* mul */ 60 | void c_dd_mul(const double *a, const double *b, double *c) { 61 | dd_real cc; 62 | cc = dd_real(a) * dd_real(b); 63 | TO_DOUBLE_PTR(cc, c); 64 | } 65 | void c_dd_mul_dd_d(const double *a, double b, double *c) { 66 | dd_real cc; 67 | cc = dd_real(a) * b; 68 | TO_DOUBLE_PTR(cc, c); 69 | } 70 | void c_dd_mul_d_dd(double a, const double *b, double *c) { 71 | dd_real cc; 72 | cc = a * dd_real(b); 73 | TO_DOUBLE_PTR(cc, c); 74 | } 75 | 76 | 77 | /* div */ 78 | void c_dd_div(const double *a, const double *b, double *c) { 79 | dd_real cc; 80 | cc = dd_real(a) / dd_real(b); 81 | TO_DOUBLE_PTR(cc, c); 82 | } 83 | void c_dd_div_dd_d(const double *a, double b, double *c) { 84 | dd_real cc; 85 | cc = dd_real(a) / b; 86 | TO_DOUBLE_PTR(cc, c); 87 | } 88 | void c_dd_div_d_dd(double a, const double *b, double *c) { 89 | dd_real cc; 90 | cc = a / dd_real(b); 91 | TO_DOUBLE_PTR(cc, c); 92 | } 93 | 94 | 95 | /* copy */ 96 | void c_dd_copy(const double *a, double *b) { 97 | b[0] = a[0]; 98 | b[1] = a[1]; 99 | } 100 | void c_dd_copy_d(double a, double *b) { 101 | b[0] = a; 102 | b[1] = 0.0; 103 | } 104 | 105 | 106 | void c_dd_sqrt(const double *a, double *b) { 107 | dd_real bb; 108 | bb = sqrt(dd_real(a)); 109 | TO_DOUBLE_PTR(bb, b); 110 | } 111 | void c_dd_sqr(const double *a, double *b) { 112 | dd_real bb; 113 | bb = sqr(dd_real(a)); 114 | TO_DOUBLE_PTR(bb, b); 115 | } 116 | 117 | void c_dd_abs(const double *a, double *b) { 118 | dd_real bb; 119 | bb = abs(dd_real(a)); 120 | TO_DOUBLE_PTR(bb, b); 121 | } 122 | 123 | void c_dd_npwr(const double *a, int n, double *b) { 124 | dd_real bb; 125 | bb = npwr(dd_real(a), n); 126 | TO_DOUBLE_PTR(bb, b); 127 | } 128 | 129 | void c_dd_nroot(const double *a, int n, double *b) { 130 | dd_real bb; 131 | bb = nroot(dd_real(a), n); 132 | TO_DOUBLE_PTR(bb, b); 133 | } 134 | 135 | void c_dd_nint(const double *a, double *b) { 136 | dd_real bb; 137 | bb = nint(dd_real(a)); 138 | TO_DOUBLE_PTR(bb, b); 139 | } 140 | void c_dd_aint(const double *a, double *b) { 141 | dd_real bb; 142 | bb = aint(dd_real(a)); 143 | TO_DOUBLE_PTR(bb, b); 144 | } 145 | void c_dd_floor(const double *a, double *b) { 146 | dd_real bb; 147 | bb = floor(dd_real(a)); 148 | TO_DOUBLE_PTR(bb, b); 149 | } 150 | void c_dd_ceil(const double *a, double *b) { 151 | dd_real bb; 152 | bb = ceil(dd_real(a)); 153 | TO_DOUBLE_PTR(bb, b); 154 | } 155 | 156 | void c_dd_log(const double *a, double *b) { 157 | dd_real bb; 158 | bb = log(dd_real(a)); 159 | TO_DOUBLE_PTR(bb, b); 160 | } 161 | void c_dd_log10(const double *a, double *b) { 162 | dd_real bb; 163 | bb = log10(dd_real(a)); 164 | TO_DOUBLE_PTR(bb, b); 165 | } 166 | void c_dd_exp(const double *a, double *b) { 167 | dd_real bb; 168 | bb = exp(dd_real(a)); 169 | TO_DOUBLE_PTR(bb, b); 170 | } 171 | 172 | void c_dd_sin(const double *a, double *b) { 173 | dd_real bb; 174 | bb = sin(dd_real(a)); 175 | TO_DOUBLE_PTR(bb, b); 176 | } 177 | void c_dd_cos(const double *a, double *b) { 178 | dd_real bb; 179 | bb = cos(dd_real(a)); 180 | TO_DOUBLE_PTR(bb, b); 181 | } 182 | void c_dd_tan(const double *a, double *b) { 183 | dd_real bb; 184 | bb = tan(dd_real(a)); 185 | TO_DOUBLE_PTR(bb, b); 186 | } 187 | 188 | void c_dd_asin(const double *a, double *b) { 189 | dd_real bb; 190 | bb = asin(dd_real(a)); 191 | TO_DOUBLE_PTR(bb, b); 192 | } 193 | void c_dd_acos(const double *a, double *b) { 194 | dd_real bb; 195 | bb = acos(dd_real(a)); 196 | TO_DOUBLE_PTR(bb, b); 197 | } 198 | void c_dd_atan(const double *a, double *b) { 199 | dd_real bb; 200 | bb = atan(dd_real(a)); 201 | TO_DOUBLE_PTR(bb, b); 202 | } 203 | 204 | void c_dd_atan2(const double *a, const double *b, double *c) { 205 | dd_real cc; 206 | cc = atan2(dd_real(a), dd_real(b)); 207 | TO_DOUBLE_PTR(cc, c); 208 | } 209 | 210 | void c_dd_sinh(const double *a, double *b) { 211 | dd_real bb; 212 | bb = sinh(dd_real(a)); 213 | TO_DOUBLE_PTR(bb, b); 214 | } 215 | void c_dd_cosh(const double *a, double *b) { 216 | dd_real bb; 217 | bb = cosh(dd_real(a)); 218 | TO_DOUBLE_PTR(bb, b); 219 | } 220 | void c_dd_tanh(const double *a, double *b) { 221 | dd_real bb; 222 | bb = tanh(dd_real(a)); 223 | TO_DOUBLE_PTR(bb, b); 224 | } 225 | 226 | void c_dd_asinh(const double *a, double *b) { 227 | dd_real bb; 228 | bb = asinh(dd_real(a)); 229 | TO_DOUBLE_PTR(bb, b); 230 | } 231 | void c_dd_acosh(const double *a, double *b) { 232 | dd_real bb; 233 | bb = acosh(dd_real(a)); 234 | TO_DOUBLE_PTR(bb, b); 235 | } 236 | void c_dd_atanh(const double *a, double *b) { 237 | dd_real bb; 238 | bb = atanh(dd_real(a)); 239 | TO_DOUBLE_PTR(bb, b); 240 | } 241 | 242 | void c_dd_sincos(const double *a, double *s, double *c) { 243 | dd_real ss, cc; 244 | sincos(dd_real(a), ss, cc); 245 | TO_DOUBLE_PTR(ss, s); 246 | TO_DOUBLE_PTR(cc, c); 247 | } 248 | 249 | void c_dd_sincosh(const double *a, double *s, double *c) { 250 | dd_real ss, cc; 251 | sincosh(dd_real(a), ss, cc); 252 | TO_DOUBLE_PTR(ss, s); 253 | TO_DOUBLE_PTR(cc, c); 254 | } 255 | 256 | void c_dd_read(const char *s, double *a) { 257 | dd_real aa(s); 258 | TO_DOUBLE_PTR(aa, a); 259 | } 260 | 261 | void c_dd_swrite(const double *a, int precision, char *s, int len) { 262 | dd_real(a).write(s, len, precision); 263 | } 264 | 265 | void c_dd_write(const double *a) { 266 | std::cout << dd_real(a).to_string(dd_real::_ndigits) << std::endl; 267 | } 268 | 269 | void c_dd_neg(const double *a, double *b) { 270 | b[0] = -a[0]; 271 | b[1] = -a[1]; 272 | } 273 | 274 | void c_dd_rand(double *a) { 275 | dd_real aa; 276 | aa = ddrand(); 277 | TO_DOUBLE_PTR(aa, a); 278 | } 279 | 280 | void c_dd_comp(const double *a, const double *b, int *result) { 281 | dd_real aa(a), bb(b); 282 | if (aa < bb) 283 | *result = -1; 284 | else if (aa > bb) 285 | *result = 1; 286 | else 287 | *result = 0; 288 | } 289 | 290 | void c_dd_comp_dd_d(const double *a, double b, int *result) { 291 | dd_real aa(a), bb(b); 292 | if (aa < bb) 293 | *result = -1; 294 | else if (aa > bb) 295 | *result = 1; 296 | else 297 | *result = 0; 298 | } 299 | 300 | void c_dd_comp_d_dd(double a, const double *b, int *result) { 301 | dd_real aa(a), bb(b); 302 | if (aa < bb) 303 | *result = -1; 304 | else if (aa > bb) 305 | *result = 1; 306 | else 307 | *result = 0; 308 | } 309 | 310 | void c_dd_pi(double *a) { 311 | TO_DOUBLE_PTR(dd_real::_pi, a); 312 | } 313 | 314 | void c_dd_2pi(double *a) { 315 | TO_DOUBLE_PTR(dd_real::_2pi, a); 316 | } 317 | 318 | double c_dd_epsilon(void) { 319 | return (double) std::numeric_limits::epsilon(); 320 | } 321 | 322 | } 323 | -------------------------------------------------------------------------------- /src/dd_const.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * src/dd_const.cc 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2007 9 | */ 10 | #include "config.h" 11 | #include 12 | #include 13 | 14 | const dd_real dd_real::_2pi = dd_real(6.283185307179586232e+00, 15 | 2.449293598294706414e-16); 16 | const dd_real dd_real::_pi = dd_real(3.141592653589793116e+00, 17 | 1.224646799147353207e-16); 18 | const dd_real dd_real::_pi2 = dd_real(1.570796326794896558e+00, 19 | 6.123233995736766036e-17); 20 | const dd_real dd_real::_pi4 = dd_real(7.853981633974482790e-01, 21 | 3.061616997868383018e-17); 22 | const dd_real dd_real::_3pi4 = dd_real(2.356194490192344837e+00, 23 | 9.1848509936051484375e-17); 24 | const dd_real dd_real::_e = dd_real(2.718281828459045091e+00, 25 | 1.445646891729250158e-16); 26 | const dd_real dd_real::_log2 = dd_real(6.931471805599452862e-01, 27 | 2.319046813846299558e-17); 28 | const dd_real dd_real::_log10 = dd_real(2.302585092994045901e+00, 29 | -2.170756223382249351e-16); 30 | const dd_real dd_real::_nan = dd_real(qd::_d_nan, qd::_d_nan); 31 | const dd_real dd_real::_inf = dd_real(qd::_d_inf, qd::_d_inf); 32 | 33 | const double dd_real::_eps = 4.93038065763132e-32; // 2^-104 34 | const double dd_real::_min_normalized = 2.0041683600089728e-292; // = 2^(-1022 + 53) 35 | const dd_real dd_real::_max = 36 | dd_real(1.79769313486231570815e+308, 9.97920154767359795037e+291); 37 | const dd_real dd_real::_safe_max = 38 | dd_real(1.7976931080746007281e+308, 9.97920154767359795037e+291); 39 | const int dd_real::_ndigits = 31; 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/fpu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * src/fpu.cc 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * Contains functions to set and restore the round-to-double flag in the 11 | * control word of a x86 FPU. 12 | */ 13 | 14 | #include "config.h" 15 | #include 16 | 17 | #ifdef X86 18 | #ifdef _WIN32 19 | #include 20 | #else 21 | 22 | #ifdef HAVE_FPU_CONTROL_H 23 | #include 24 | #endif 25 | 26 | #ifndef _FPU_GETCW 27 | #define _FPU_GETCW(x) asm volatile ("fnstcw %0":"=m" (x)); 28 | #endif 29 | 30 | #ifndef _FPU_SETCW 31 | #define _FPU_SETCW(x) asm volatile ("fldcw %0": :"m" (x)); 32 | #endif 33 | 34 | #ifndef _FPU_EXTENDED 35 | #define _FPU_EXTENDED 0x0300 36 | #endif 37 | 38 | #ifndef _FPU_DOUBLE 39 | #define _FPU_DOUBLE 0x0200 40 | #endif 41 | 42 | #endif 43 | #endif /* X86 */ 44 | 45 | extern "C" { 46 | 47 | void fpu_fix_start(unsigned int *old_cw) { 48 | #ifdef X86 49 | #ifdef _WIN32 50 | #ifdef __BORLANDC__ 51 | /* Win 32 Borland C */ 52 | unsigned short cw = _control87(0, 0); 53 | _control87(0x0200, 0x0300); 54 | if (old_cw) { 55 | *old_cw = cw; 56 | } 57 | #else 58 | /* Win 32 MSVC */ 59 | unsigned int cw = _control87(0, 0); 60 | _control87(0x00010000, 0x00030000); 61 | if (old_cw) { 62 | *old_cw = cw; 63 | } 64 | #endif 65 | #else 66 | /* Linux */ 67 | volatile unsigned short cw, new_cw; 68 | _FPU_GETCW(cw); 69 | 70 | new_cw = (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE; 71 | _FPU_SETCW(new_cw); 72 | 73 | if (old_cw) { 74 | *old_cw = cw; 75 | } 76 | #endif 77 | #endif 78 | } 79 | 80 | void fpu_fix_end(unsigned int *old_cw) { 81 | #ifdef X86 82 | #ifdef _WIN32 83 | 84 | #ifdef __BORLANDC__ 85 | /* Win 32 Borland C */ 86 | if (old_cw) { 87 | unsigned short cw = (unsigned short) *old_cw; 88 | _control87(cw, 0xFFFF); 89 | } 90 | #else 91 | /* Win 32 MSVC */ 92 | if (old_cw) { 93 | _control87(*old_cw, 0xFFFFFFFF); 94 | } 95 | #endif 96 | 97 | #else 98 | /* Linux */ 99 | if (old_cw) { 100 | int cw; 101 | cw = *old_cw; 102 | _FPU_SETCW(cw); 103 | } 104 | #endif 105 | #endif 106 | } 107 | 108 | #ifdef HAVE_FORTRAN 109 | 110 | #define f_fpu_fix_start FC_FUNC_(f_fpu_fix_start, F_FPU_FIX_START) 111 | #define f_fpu_fix_end FC_FUNC_(f_fpu_fix_end, F_FPU_FIX_END) 112 | 113 | void f_fpu_fix_start(unsigned int *old_cw) { 114 | fpu_fix_start(old_cw); 115 | } 116 | 117 | void f_fpu_fix_end(unsigned int *old_cw) { 118 | fpu_fix_end(old_cw); 119 | } 120 | 121 | #endif 122 | 123 | } 124 | 125 | -------------------------------------------------------------------------------- /src/qd_const.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * src/qd_const.cc 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * Defines constants used in quad-double package. 11 | */ 12 | #include "config.h" 13 | #include 14 | #include 15 | 16 | /* Some useful constants. */ 17 | const qd_real qd_real::_2pi = qd_real(6.283185307179586232e+00, 18 | 2.449293598294706414e-16, 19 | -5.989539619436679332e-33, 20 | 2.224908441726730563e-49); 21 | const qd_real qd_real::_pi = qd_real(3.141592653589793116e+00, 22 | 1.224646799147353207e-16, 23 | -2.994769809718339666e-33, 24 | 1.112454220863365282e-49); 25 | const qd_real qd_real::_pi2 = qd_real(1.570796326794896558e+00, 26 | 6.123233995736766036e-17, 27 | -1.497384904859169833e-33, 28 | 5.562271104316826408e-50); 29 | const qd_real qd_real::_pi4 = qd_real(7.853981633974482790e-01, 30 | 3.061616997868383018e-17, 31 | -7.486924524295849165e-34, 32 | 2.781135552158413204e-50); 33 | const qd_real qd_real::_3pi4 = qd_real(2.356194490192344837e+00, 34 | 9.1848509936051484375e-17, 35 | 3.9168984647504003225e-33, 36 | -2.5867981632704860386e-49); 37 | const qd_real qd_real::_e = qd_real(2.718281828459045091e+00, 38 | 1.445646891729250158e-16, 39 | -2.127717108038176765e-33, 40 | 1.515630159841218954e-49); 41 | const qd_real qd_real::_log2 = qd_real(6.931471805599452862e-01, 42 | 2.319046813846299558e-17, 43 | 5.707708438416212066e-34, 44 | -3.582432210601811423e-50); 45 | const qd_real qd_real::_log10 = qd_real(2.302585092994045901e+00, 46 | -2.170756223382249351e-16, 47 | -9.984262454465776570e-33, 48 | -4.023357454450206379e-49); 49 | const qd_real qd_real::_nan = qd_real(qd::_d_nan, qd::_d_nan, 50 | qd::_d_nan, qd::_d_nan); 51 | const qd_real qd_real::_inf = qd_real(qd::_d_inf, qd::_d_inf, 52 | qd::_d_inf, qd::_d_inf); 53 | 54 | const double qd_real::_eps = 1.21543267145725e-63; // = 2^-209 55 | const double qd_real::_min_normalized = 1.6259745436952323e-260; // = 2^(-1022 + 3*53) 56 | const qd_real qd_real::_max = qd_real( 57 | 1.79769313486231570815e+308, 9.97920154767359795037e+291, 58 | 5.53956966280111259858e+275, 3.07507889307840487279e+259); 59 | const qd_real qd_real::_safe_max = qd_real( 60 | 1.7976931080746007281e+308, 9.97920154767359795037e+291, 61 | 5.53956966280111259858e+275, 3.07507889307840487279e+259); 62 | const int qd_real::_ndigits = 62; 63 | 64 | -------------------------------------------------------------------------------- /src/util.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "util.h" 3 | 4 | void append_expn(std::string &str, int expn) { 5 | int k; 6 | 7 | str += (expn < 0 ? '-' : '+'); 8 | expn = std::abs(expn); 9 | 10 | if (expn >= 100) { 11 | k = (expn / 100); 12 | str += '0' + k; 13 | expn -= 100*k; 14 | } 15 | 16 | k = (expn / 10); 17 | str += '0' + k; 18 | expn -= 10*k; 19 | 20 | str += '0' + expn; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/util.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void append_expn(std::string &str, int expn); 4 | 5 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | LDADD = $(top_builddir)/src/libqd.la 2 | AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include 3 | 4 | TESTS = qd_test pslq_test c_test 5 | check_PROGRAMS = qd_test pslq_test c_test 6 | EXTRA_PROGRAMS = qd_timer quadt_test huge 7 | 8 | dist_noinst_DATA = coeff.dat 9 | 10 | if HAVE_FORTRAN 11 | TESTS += f_test 12 | check_PROGRAMS += f_test 13 | AM_FCFLAGS = @ax_f90_modflag@$(top_builddir)/fortran 14 | AM_FFLAGS = $(AM_FCFLAGS) 15 | 16 | f_test_SOURCES = f_test.f 17 | f_test_LINK=$(CXXLINK) 18 | f_test_LDADD = $(top_builddir)/fortran/libqdmod.la \ 19 | $(top_builddir)/fortran/libqd_f_main.la \ 20 | $(LDADD) $(top_builddir)/src/libqd.la $(FCLIBS) 21 | endif 22 | 23 | CLEANFILES=qd_timer quadt_test huge 24 | 25 | qd_test_SOURCES = qd_test.cpp 26 | pslq_test_SOURCES = pslq.h pslq_test.cpp tictoc.cpp tictoc.h 27 | qd_timer_SOURCES = qd_timer.cpp tictoc.cpp tictoc.h 28 | quadt_test_SOURCES = quadt_test.cpp tictoc.cpp quadt.h tictoc.h 29 | huge_SOURCES = huge.cpp 30 | 31 | c_test_SOURCES = c_test.c 32 | c_test_LINK = $(CXXLINK) 33 | 34 | time: qd_timer$(EXEEXT) 35 | ./qd_timer$(EXEEXT) 36 | 37 | demo: $(check_PROGRAMS) $(EXTRA_PROGRAMS) 38 | 39 | .PHONY: time demo 40 | -------------------------------------------------------------------------------- /tests/c_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Test 1. Salamin-Brent quadratically convergent formula for pi. */ 6 | int test_1() { 7 | 8 | double a[4], b[4], s[4], p[4], t[4], t2[4]; 9 | double a_new[4], b_new[4], p_old[4]; 10 | double m, err; 11 | int r, i; 12 | const int max_iter = 20; 13 | 14 | puts("Test 1. (Salamin-Brent quadratically convergent formula for pi)"); 15 | 16 | c_qd_copy_d(1.0, a); /* a = 1.0 */ 17 | c_qd_copy_d(0.5, t); /* t = 0.5 */ 18 | c_qd_sqrt(t, b); /* b = sqrt(t) */ 19 | c_qd_copy_d(0.5, s); /* s = 0.5 */ 20 | m = 1.0; 21 | 22 | c_qd_sqr(a, p); 23 | c_qd_selfmul_d(2.0, p); 24 | c_qd_selfdiv(s, p); 25 | 26 | printf(" iteration 0: "); 27 | c_qd_write(p); 28 | for (i = 1; i <= max_iter; i++) { 29 | m *= 2.0; 30 | 31 | /* a_new = 0.5 * (a + b) */ 32 | c_qd_add(a, b, a_new); 33 | c_qd_selfmul_d(0.5, a_new); 34 | 35 | c_qd_mul(a, b, b_new); /* b_new = a * b */ 36 | 37 | /* Compute s = s - m * (a_new^2 - b) */ 38 | c_qd_sqr(a_new, t); /* t = a_new ^ 2 */ 39 | c_qd_selfsub(b_new, t); /* t -= b_new */ 40 | c_qd_selfmul_d(m, t); /* t *= m */ 41 | c_qd_selfsub(t, s); /* s -= t */ 42 | 43 | c_qd_copy(a_new, a); 44 | c_qd_sqrt(b_new, b); 45 | c_qd_copy(p, p_old); 46 | 47 | /* Compute p = 2.0 * a^2 / s */ 48 | c_qd_sqr(a, p); 49 | c_qd_selfmul_d(2.0, p); 50 | c_qd_selfdiv(s, p); 51 | 52 | /* Test for convergence by looking at |p - p_old|. */ 53 | c_qd_sub(p, p_old, t); 54 | c_qd_abs(t, t2); 55 | c_qd_comp_qd_d(t2, 1e-60, &r); 56 | if (r < 0) break; 57 | 58 | printf(" iteration %1d: ", i); 59 | c_qd_write(p); 60 | } 61 | 62 | c_qd_pi(p); /* p = pi */ 63 | printf(" _pi: "); 64 | c_qd_write(p); 65 | printf(" error: %.5e = %g eps\n", t2[0], t2[0] / ldexp(1.0, -209)); 66 | 67 | return 0; 68 | } 69 | 70 | int main(void) { 71 | fpu_fix_start(NULL); 72 | return test_1(); 73 | } 74 | -------------------------------------------------------------------------------- /tests/coeff.dat: -------------------------------------------------------------------------------- 1 | -0.9775167951976489664525469954372956343358810013057749724417862774e-3 2 | -0.2075676914283777492727118016432227494608152196024915261153999901e-9 3 | -0.1269367038136010543068339663371323731348000676768267625469448102e-15 4 | -0.1052027278699348005047071676902386524189075944232894389841628352e-21 5 | -0.1013862709339873804983259618712856406431507368366630114746652194e-27 6 | -0.1070797160782079391652093252929022125892146568458306459066625793e-33 7 | -0.1203024682204313742995875291169966746331236984031736777114302104e-39 8 | -0.1413186765666548861807857674447967052084667162327752320681199850e-45 9 | -0.1716934680463467799119970534957860324650302035114942758068507743e-51 10 | -0.2141684303810732445664109047220683197049353785918847781307915946e-57 11 | -0.2728728792013858214594623359015171594414499690547350426316476317e-63 12 | -0.3537740851099290910904125744688322503286308246823228589610390084e-69 13 | -0.4653866593076211746014999930808477556007283760568825784729118519e-75 14 | -0.6198222036629372113743376552741744231526282610241755912017865074e-81 15 | -0.8343163573566567964173005299761236198983193010010688597971245423e-87 16 | -0.1133440877126749833628201009730991589630882455080264498144743046e-92 17 | -0.1552307178288950850127847197432548602832581363150190995926321077e-98 18 | -0.2141210693832760804471301181576487171556527761449953933723182650e-104 19 | -0.2972374323937510048005418816630916320169010435263863852744755146e-110 20 | -0.4149755825466059459836047799507803845640790041662842575959069864e-116 21 | -0.5823334821134826021273748665219614719678055975439919739619995591e-122 22 | -0.8209959030180363085847618386282698731878699835548748108868571308e-128 23 | -0.1162380824812159815904187845984270255078065890997783213660727935e-133 24 | -0.1652097958843265314528716469448290562813587320057617748784776789e-139 25 | -0.2356483265664698414998912101530115585067265981922030210933715902e-145 26 | -0.3372189144799648585521738136801552767051945061785360441880935746e-151 27 | -0.4840277541130058059157644310674025433331802025292052611788876935e-157 28 | -0.6966956086460986977095368691634405902169916528521680617493920982e-163 29 | -0.1005412505814013202384573697823240736205894362609894605083067754e-168 30 | -0.1454442845520587196539767533367342012940113398448039080001484172e-174 31 | -0.2108776891671463482330396738781660457871205397711439187061630602e-180 32 | -0.3063961604774525057027798220963629256575803255896446562939600635e-186 33 | 34 | -------------------------------------------------------------------------------- /tests/f_test.f: -------------------------------------------------------------------------------- 1 | ! program fortran_test 2 | subroutine f_main 3 | ! A simple test of the fortran wrappers 4 | 5 | use qdmodule 6 | implicit none 7 | integer*4 old_cw 8 | integer i 9 | type (qd_real) x, y, z 10 | 11 | call f_fpu_fix_start (old_cw) 12 | 13 | ! Test for read/write 14 | z = "3.14159265358979323846264338327950288419716939937510582097494459230" 15 | call write_scalar(6, z) 16 | 17 | ! Test for atan/write 18 | do i=1,3 19 | x = qdreal(dble(i)) 20 | call write_scalar(6, x) 21 | y = atan(x) 22 | call write_scalar(6, y) 23 | end do 24 | 25 | call write_scalar(6, nan(x)) 26 | call write_scalar(6, qdcomplex(x, y)) 27 | 28 | call f_fpu_fix_end (old_cw) 29 | end 30 | 31 | -------------------------------------------------------------------------------- /tests/huge.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/huge.cpp 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2007 9 | * 10 | * This contains tests for check for accuracy when dealing with numbers 11 | * near overflow. 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | using std::cout; 23 | using std::cerr; 24 | using std::endl; 25 | using std::string; 26 | 27 | // Global flags passed to the main program. 28 | static bool flag_test_dd = false; 29 | static bool flag_test_qd = false; 30 | bool flag_verbose = false; 31 | 32 | bool print_result(bool result) { 33 | if (result) 34 | cout << "Test passed." << endl; 35 | else 36 | cout << "Test FAILED." << endl; 37 | return result; 38 | } 39 | 40 | void print_usage() { 41 | cout << "qd_test [-h] [-dd] [-qd] [-all]" << endl; 42 | cout << " Tests output of large numbers." << endl; 43 | cout << endl; 44 | cout << " -h -help Prints this usage message." << endl; 45 | cout << " -dd Perform tests with double-double types." << endl; 46 | cout << " -qd Perform tests with quad-double types." << endl; 47 | cout << " This is the default." << endl; 48 | cout << " -all Perform both double-double and quad-double tests." << endl; 49 | cout << " -v" << endl; 50 | cout << " -verbose Print detailed information for each test." << endl; 51 | } 52 | 53 | bool check(string str, string true_str) { 54 | bool pass = (str == true_str); 55 | if (!pass) { 56 | cout << " fail: " << str << endl; 57 | cout << "should be: " << true_str << endl; 58 | } else if (flag_verbose) { 59 | cout << " pass: " << str << endl; 60 | } 61 | return pass; 62 | } 63 | 64 | template 65 | bool test_huge() { 66 | bool pass = true; 67 | int digits = T::_ndigits - 1; 68 | T x = T::_pi * T("1.0e290"); 69 | 70 | string pi_str = T::_pi.to_string(digits, 0, std::ios_base::fixed); 71 | if (flag_verbose) cout << pi_str << endl; 72 | for (int i = 0; i < 18; i++, x *= 10.0) { 73 | std::ostringstream os; 74 | os << pi_str << "e+" << (290 + i); 75 | pass &= check(x.to_string(digits), os.str()); 76 | } 77 | 78 | x = -T::_pi * T("1.0e290"); 79 | pi_str = "-" + pi_str; 80 | for (int i = 0; i < 18; i++, x *= 10.0) { 81 | std::ostringstream os; 82 | os << pi_str << "e+" << (290 + i); 83 | pass &= check(x.to_string(digits), os.str()); 84 | } 85 | 86 | return pass; 87 | } 88 | 89 | template 90 | bool test_max(string true_str) { 91 | bool pass = true; 92 | int digits = T::_ndigits - 1; 93 | pass &= check(T::_max.to_string(digits), true_str); 94 | pass &= check((-T::_max).to_string(digits), "-" + true_str); 95 | return pass; 96 | } 97 | 98 | int main(int argc, char *argv[]) { 99 | 100 | bool pass = true; 101 | unsigned int old_cw; 102 | fpu_fix_start(&old_cw); 103 | 104 | /* Parse the arguments. */ 105 | for (int i = 1; i < argc; i++) { 106 | string arg(argv[i]); 107 | 108 | if (arg == "-h" || arg == "-help") { 109 | print_usage(); 110 | exit(0); 111 | } else if (arg == "-dd") { 112 | flag_test_dd = true; 113 | } else if (arg == "-qd") { 114 | flag_test_qd = true; 115 | } else if (arg == "-all") { 116 | flag_test_dd = flag_test_qd = true; 117 | } else if (arg == "-v" || arg == "-verbose") { 118 | flag_verbose = true; 119 | } else { 120 | cerr << "Unknown flag `" << arg << "'." << endl; 121 | } 122 | } 123 | 124 | /* If no flag, test both double-double and quad-double. */ 125 | if (!flag_test_dd && !flag_test_qd) { 126 | flag_test_dd = true; 127 | flag_test_qd = true; 128 | } 129 | 130 | cout << "Testing output of huge numbers..." << endl; 131 | 132 | if (flag_test_dd) { 133 | cout << endl; 134 | cout << "Testing dd_real ..." << endl; 135 | pass &= test_huge(); 136 | pass &= test_max("1.797693134862315807937289714053e+308"); 137 | print_result(pass); 138 | } 139 | 140 | if (flag_test_qd) { 141 | cout << endl; 142 | cout << "Testing qd_real ..." << endl; 143 | pass &= test_huge(); 144 | pass &= test_max( 145 | "1.7976931348623158079372897140530286112296785259868571699620069e+308"); 146 | print_result(pass); 147 | } 148 | 149 | fpu_fix_end(&old_cw); 150 | return (pass ? 0 : 1); 151 | } 152 | 153 | -------------------------------------------------------------------------------- /tests/pslq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/pslq.h 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * 11 | * Implementation of PSLQ Integer Relation Detection Algorithm 12 | * due to H. R. P. Ferguson and D. H. Bailey. See 13 | * 14 | * A new polynomial time algorithm for finding relations among 15 | * real numbers, Supercomputing Research Center Tech Report 16 | * SRC-93-093 (March 1993). 17 | * 18 | * This code is based in part on David Bailey's F90 version. 19 | */ 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | using std::sqrt; 29 | using std::abs; 30 | 31 | using namespace qd; 32 | 33 | #define MIN(a, b) ( ((a)<(b)) ? (a) : (b) ) 34 | #define MAX(a, b) ( ((a)>(b)) ? (a) : (b) ) 35 | #define SWAP(a, b) { t = a; a = b; b = t; } 36 | #define SQR(a) ( (a)*(a) ) 37 | 38 | /* Create an n-by-m matrix of T. Diagonal elements 39 | are initialized to diag, while all other elements are 40 | initialized to elem. */ 41 | template 42 | T **new_matrix(int nr_rows, int nr_cols, 43 | T diag = 0.0, T elem = 0.0) { 44 | T **m = new T *[nr_rows]; 45 | int i, j; 46 | 47 | for (i = 0; i < nr_rows; i++) 48 | m[i] = new T[nr_cols]; 49 | for (i = 0; i < nr_rows; i++) 50 | for (j = 0; j < nr_cols; j++) 51 | m[i][j] = (i == j) ? diag : elem; 52 | return m; 53 | } 54 | 55 | /* Create an n-vector of T. Each elements are initialized to elem. */ 56 | template 57 | T *new_vector(int n, T elem = 0.0) { 58 | T *v = new T[n]; 59 | for (int i = 0; i < n; i++) 60 | v[i] = elem; 61 | return v; 62 | } 63 | 64 | /* Destroys a matrix m. */ 65 | template 66 | void delete_matrix(T **m, int nr_rows) { 67 | for (int i = 0; i < nr_rows; i++) 68 | delete [] m[i]; 69 | delete [] m; 70 | } 71 | 72 | /* Destroys a vector v. */ 73 | template 74 | void delete_vector(T *v) { 75 | delete [] v; 76 | } 77 | 78 | /* The parameter gamma used in the PSLQ algorithm. */ 79 | static const double gam = 1.2; 80 | 81 | /* Perform PSLQ integer relation algorithm to find any 82 | linear relation among the n numbers in the vector x. 83 | It returns the coefficients found in the vector r. 84 | The parameter eps provides the precision of type T. */ 85 | template 86 | int pslq(const T *x, int n, T *r, double eps, int max_itr) { 87 | T *s = new_vector(n); 88 | T *y = new_vector(n); 89 | T **a = new_matrix(n, n, 1.0); 90 | T **b = new_matrix(n, n, 1.0); 91 | T **h = new_matrix(n, n-1, 0.0); 92 | T t; 93 | double teps = 16.0 * eps; 94 | int i, j, k; 95 | int err = 0; 96 | 97 | /* Compute the vector s */ 98 | t = x[n-1] * x[n-1]; 99 | s[n-1] = abs(x[n-1]); 100 | for (i = n-2; i >= 0; i--) { 101 | t += x[i] * x[i]; 102 | s[i] = sqrt(t); 103 | } 104 | 105 | /* Normalize the vector x, s. */ 106 | t = s[0]; 107 | for (i = 0; i < n; i++) 108 | y[i] = x[i] / t; 109 | s[0] = 1.0; 110 | for (i = 1; i < n; i++) 111 | s[i] /= t; 112 | 113 | /* Construct matrix H. */ 114 | for (i = 0; i < n; i++) { 115 | for (j = 0; j <= MIN(i, n-2); j++) { 116 | h[i][j] = (i == j) ? s[j+1]/s[j] : - y[i]*y[j] / (s[j] * s[j+1]); 117 | } 118 | } 119 | 120 | /* Reduce matrix H. */ 121 | for (i = 1; i < n; i++) { 122 | for (j = i-1; j >= 0; j--) { 123 | t = nint(h[i][j] / h[j][j]); 124 | y[j] += t * y[i]; 125 | for (k = 0; k <= j; k++) 126 | h[i][k] -= t * h[j][k]; 127 | for (k = 0; k < n; k++) { 128 | a[i][k] -= t * a[j][k]; 129 | b[k][j] += t * b[k][i]; 130 | } 131 | } 132 | } 133 | 134 | int m; 135 | int itr = 0; 136 | bool done = false; 137 | 138 | while(!done) { 139 | 140 | itr++; 141 | 142 | /* Select m such that gam^i * |H_ii| is maximal when i = m. */ 143 | T m_val = -1.0; 144 | T g = gam; 145 | m = -1; 146 | 147 | for (i = 0; i < n-1; i++, g *= gam) { 148 | t = abs(g * h[i][i]); 149 | if (t > m_val) { 150 | m_val = t; 151 | m = i; 152 | } 153 | } 154 | 155 | if (m < 0) { 156 | /* This shouldn't happen. */ 157 | err = 1; 158 | break; 159 | } 160 | 161 | /* Exchange entries m and m+1 of y, 162 | rows m and m+1 of A and H, 163 | columns m and m+1 of B. */ 164 | SWAP(y[m], y[m+1]) 165 | for (i = 0; i < n; i++) { 166 | SWAP(a[m][i], a[m+1][i]) 167 | } 168 | for (i = 0; i < n-1; i++) { 169 | SWAP(h[m][i], h[m+1][i]) 170 | } 171 | for (i = 0; i < n; i++) { 172 | SWAP(b[i][m], b[i][m+1]) 173 | } 174 | 175 | 176 | /* Remove the corner on H diagonal. */ 177 | if (m < n-2) { 178 | T t0, t1, t2, t3, t4; 179 | t0 = sqrt(SQR(h[m][m]) + SQR(h[m][m+1])); 180 | t1 = h[m][m] / t0; 181 | t2 = h[m][m+1] / t0; 182 | for (i = m; i < n; i++) { 183 | t3 = h[i][m]; 184 | t4 = h[i][m+1]; 185 | h[i][m] = t1 * t3 + t2 * t4; 186 | h[i][m+1] = t1 * t4 - t2 * t3; 187 | } 188 | } 189 | 190 | /* Reduce H. */ 191 | for (i = m+1; i < n; i++) { 192 | for (j = MIN(i-1, m+1); j >= 0; j--) { 193 | t = nint(h[i][j]/h[j][j]); 194 | y[j] += t * y[i]; 195 | for (k = 0; k <= j; k++) { 196 | h[i][k] -= t * h[j][k]; 197 | } 198 | for (k = 0; k < n; k++) { 199 | a[i][k] -= t * a[j][k]; 200 | b[k][j] += t * b[k][i]; 201 | } 202 | } 203 | } 204 | 205 | 206 | /* Norm bound */ 207 | m_val = -1.0e308; 208 | for (j = 0; j < n-1; j++) { 209 | t = abs(h[j][j]); 210 | if (t > m_val) 211 | m_val = t; 212 | } 213 | 214 | /* Check the y vector for zeros. */ 215 | for (i = 0; i < n; i++) { 216 | t = abs(y[i]); 217 | if (t < teps) { 218 | m = i; 219 | done = true; 220 | break; 221 | } 222 | } 223 | 224 | if (itr > max_itr) { 225 | done = true; 226 | err = -1; 227 | } 228 | 229 | } /* while */ 230 | 231 | /* Get the coefficients. */ 232 | if (err == 0) { 233 | for (i = 0; i < n; i++) { 234 | r[i] = b[i][m]; 235 | } 236 | } 237 | 238 | delete_matrix(h, n); 239 | delete_matrix(a, n); 240 | delete_matrix(b, n); 241 | delete_vector(y); 242 | delete_vector(s); 243 | 244 | return err; 245 | } 246 | 247 | -------------------------------------------------------------------------------- /tests/pslq_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/pslq_test.cpp 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * A driver for the pslq program which exercises the double-double and 11 | * quad-double library. 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "tictoc.h" 23 | #include "pslq.h" 24 | 25 | using std::cout; 26 | using std::cerr; 27 | using std::endl; 28 | using std::strcmp; 29 | 30 | int g_verbose = 0; 31 | bool flag_double_pslq = false; 32 | bool flag_dd_pslq = false; 33 | bool flag_qd_pslq = false; 34 | 35 | /* Computes the value of the given n-th degree polynomial at point x 36 | where the (n+1) coefficients of the polynomial is given in a. */ 37 | template 38 | T polyeval(T *a, int n, T &x, double &err_bnd) { 39 | /* Use Horner's evaluation scheme. */ 40 | 41 | T t = a[n]; 42 | err_bnd = std::abs(to_double(t)) * 0.5; 43 | for (int i = n-1; i >= 0; i--) { 44 | t *= x; 45 | t += a[i]; 46 | err_bnd *= std::abs(to_double(x)); 47 | err_bnd += std::abs(to_double(t)); 48 | } 49 | err_bnd = (2.0 * err_bnd - to_double(t)) * std::numeric_limits::epsilon(); 50 | 51 | return t; 52 | } 53 | 54 | double nroot(double x, int n) { 55 | return std::pow(x, 1.0 / n); 56 | } 57 | 58 | bool is_int(double x) { 59 | return (std::abs(x) <= std::numeric_limits::max() && 60 | static_cast(x) == x); 61 | } 62 | 63 | /* Sets r = 2^(1/p) + 3^(1/q) and tries to recover the algebraic 64 | * polynomial of degree pq performing PSLQ on 1, r, r^2, ..., r^n. */ 65 | template 66 | bool pslq_test(int p, int q, double eps, int max_itr = 100000) { 67 | T *x, *b; 68 | T r = nroot(T(2.0), p) + nroot(T(3.0), q); 69 | T t; 70 | int err; 71 | tictoc tv; 72 | double tm; 73 | int n = p * q + 1; 74 | std::ios_base::fmtflags fmt = cout.flags(); 75 | 76 | b = new T[n]; 77 | x = new T[n]; 78 | 79 | /* Fill in vector x with powers of r. */ 80 | x[0] = 1.0; 81 | x[1] = r; 82 | t = r*r; 83 | for (int i = 2; i < n; i++, t *= r) x[i] = t; 84 | 85 | cout << " testing pslq_test(" << p << ", " << q << ") ..." << endl; 86 | if (g_verbose) cout << std::setprecision(std::numeric_limits::digits10) << " r = " << r << endl; 87 | 88 | /* Construct algebraic relation */ 89 | tic(&tv); 90 | err = pslq(x, n, b, eps, max_itr); 91 | tm = toc(&tv); 92 | 93 | cout << " elapsed time = " << std::setprecision(4) << tm << " seconds." << endl; 94 | cout << std::right << std::setprecision(2) << std::fixed; 95 | if (!err) { 96 | if (g_verbose) { 97 | cout << " polynomial: "; 98 | for (int i = 0; i < n; i++) { 99 | if (i > 0) cout << " "; 100 | cout << std::setprecision(0) << std::setw(24) << b[i] << endl; 101 | } 102 | } 103 | 104 | /* Check if r satisfies the polynomial. */ 105 | double err_bnd; 106 | t = abs(polyeval(b, n-1, r, err_bnd)); 107 | err = t > 10.0 * err_bnd; 108 | cout << std::scientific << std::setprecision(4); 109 | if (err || g_verbose) { 110 | cout << " residual = " << t << endl; 111 | cout << " error bound = " << err_bnd << endl; 112 | } 113 | } 114 | 115 | delete [] x; 116 | delete [] b; 117 | 118 | if (err) 119 | cout << " test FAILED." << endl; 120 | else 121 | cout << " test passed." << endl; 122 | cout << endl; 123 | 124 | cout.flags(fmt); 125 | return !err; 126 | } 127 | 128 | /* We need this since Sun C++ compiler seems to miscompile when 129 | * eps parameter is given default (templated) argument. */ 130 | template 131 | bool pslq_test(int p, int q) { 132 | return pslq_test(p, q, std::numeric_limits::epsilon()); 133 | } 134 | 135 | void print_usage() { 136 | cout << "pslq_test [-h] [-n N] [-d] [-dd] [-qd] [-all] [-verbose]" << endl; 137 | cout << " Performs the PSLQ algorithm on 1, r, r^2, ..., r^{n-1}" << endl; 138 | cout << " where r is a root of a constructed integer coefficient" << endl; 139 | cout << " polynomial. PSLQ algorithm should reconstruct the polynomial" << endl; 140 | cout << " in most cases where the degree is not too high and the" << endl; 141 | cout << " polynomial is irreducible over the rationals." << endl; 142 | cout << endl; 143 | cout << " -h -help Print this usage message and exit." << endl; 144 | cout << " -d Perform PSLQ with double precision (53 bit mantissa)." << endl; 145 | cout << " -dd Perform PSLQ with double-double precision." << endl; 146 | cout << " (about 106 bits of significand)." << endl; 147 | cout << " -qd Perform PSLQ with quad-double precision." << endl; 148 | cout << " (about 212 bits of significand). This is the default." << endl; 149 | cout << " -all Perform PSLQ with all three precisions above." << endl; 150 | cout << " -verbose" << endl; 151 | cout << " -v Increase verbosity." << endl; 152 | } 153 | 154 | int main(int argc, char **argv) { 155 | char *arg; 156 | 157 | /* Parse the command-line arguments. */ 158 | for (int i = 1; i < argc; i++) { 159 | arg = argv[i]; 160 | if (strcmp(arg, "-h") == 0 || strcmp(arg, "-help") == 0) { 161 | print_usage(); 162 | return 0; 163 | } else if (strcmp(arg, "-d") == 0) { 164 | flag_double_pslq = true; 165 | } else if (strcmp(arg, "-dd") == 0) { 166 | flag_dd_pslq = true; 167 | } else if (strcmp(arg, "-qd") == 0) { 168 | flag_qd_pslq = true; 169 | } else if (strcmp(arg, "-all") == 0) { 170 | flag_double_pslq = flag_dd_pslq = flag_qd_pslq = true; 171 | } else if (strcmp(arg, "-v") == 0 || strcmp(arg, "-verbose") == 0) { 172 | g_verbose++; 173 | } else { 174 | cerr << "Unknown flag `" << arg << "'." << endl; 175 | } 176 | } 177 | 178 | if (!flag_double_pslq && !flag_dd_pslq && !flag_qd_pslq) { 179 | flag_dd_pslq = true; 180 | flag_qd_pslq = true; 181 | } 182 | 183 | unsigned int old_cw; 184 | fpu_fix_start(&old_cw); 185 | 186 | bool pass = true; 187 | if (flag_double_pslq) { 188 | cout << "Performing double-precision PSLQ." << endl; 189 | pass &= pslq_test(2, 2); 190 | pass &= pslq_test(3, 2); 191 | } 192 | 193 | if (flag_dd_pslq) { 194 | cout << "Performing double-double precision PSLQ." << endl; 195 | pass &= pslq_test(2, 2); 196 | pass &= pslq_test(2, 3); 197 | pass &= pslq_test(2, 4); 198 | pass &= pslq_test(3, 3); 199 | pass &= pslq_test(2, 5); 200 | } 201 | 202 | if (flag_qd_pslq) { 203 | cout << "Performing quad-double precision PSLQ." << endl; 204 | pass &= pslq_test(3, 3); 205 | pass &= pslq_test(2, 5); 206 | pass &= pslq_test(4, 3); 207 | pass &= pslq_test(2, 6); 208 | pass &= pslq_test(2, 7); 209 | pass &= pslq_test(3, 5); 210 | } 211 | 212 | if (pass) 213 | cout << "All tests passed." << endl; 214 | else 215 | cout << "Some tests FAILED." << endl; 216 | 217 | fpu_fix_end(&old_cw); 218 | return (pass ? 0 : 1); 219 | } 220 | 221 | 222 | -------------------------------------------------------------------------------- /tests/quadt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/quadt.cpp 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * This contains a C++ class template for a tanh-sinh quadrature 11 | * algorithm, which employs the transformation 12 | * 13 | * t <-- tanh (sinh (x)) 14 | * 15 | * This quadrature scheme is suitable for any function that is 16 | * continuous, infinitely differentiable and integrable on a finite 17 | * open interval. It can also be used for certain integrals on 18 | * infinite intervals by making a suitable change of variable. 19 | * While this routine is not quite as efficient as Gaussian quadrature, 20 | * it can be used for functions with an integrable singularity at one 21 | * or both of the endpoints. Further, this scheme has the advantage 22 | * that function evaluation at one level are all utilized at the next 23 | * level, thus saving significant computation. 24 | * 25 | * This program is based on David Bailey's tquadt.f program (written 26 | * in Fortran 90). C++ conversion, quad-double precision support, 27 | * and few other changes have been added. 28 | */ 29 | #ifndef _QUADT_CC_ 30 | #define _QUADT_CC_ 31 | 32 | /* Suppose we are given the integral 33 | * 34 | * / 1 35 | * I = | f(x) dx 36 | * / -1 37 | * 38 | * Then the substitution t = tanh (sinh (x)) gives 39 | * 40 | * dt = (tanh (sinh (x))' dx = (sech (sinh (x)))^2 * cosh(x) dx 41 | * 42 | * Also the limit point x = 1 corresponds to t = 43 | */ 44 | #include 45 | #include 46 | #include 47 | 48 | #include 49 | 50 | template 51 | class quadt { 52 | public: 53 | /* Constructor. This will create a tanh-sinh quadrature class. 54 | Parameters 55 | eps -- The machine epsilon of the variable type to be used. */ 56 | quadt(double eps); 57 | 58 | /* Destructor. This will take care of disposing internal tables, etc. */ 59 | ~quadt(); 60 | 61 | /* Computes the integral of the function f from -1 to 1. 62 | The class F is any class with overloaded operator() (T &). */ 63 | template 64 | int integrate_u(const F &f, double tol, T &result, double &err); 65 | 66 | /* Computes the integral of the function f from a to b. 67 | The class F is any class with overloaded operator() (T &). */ 68 | template 69 | int integrate(const F &f, T a, T b, double tol, T &result, double &err); 70 | 71 | private: 72 | int max_level; 73 | double initial_width, final_width; 74 | int table_size; 75 | double eps; 76 | 77 | /* Pre-computed quadrature points. */ 78 | T *weights; 79 | T *points; 80 | 81 | /* Scales and translates the given function f from the 82 | interval [a, b] to [-1, 1] so it can be evaluated using 83 | the tanh-sinh substitution. */ 84 | template 85 | class UnitFunction { 86 | private: 87 | F f; 88 | T offset, h; 89 | public: 90 | UnitFunction(const F &f, const T &a, const T &b) : f(f) { 91 | offset = 0.5 * (a + b); 92 | h = (b - a) * 0.5; 93 | } 94 | T operator()(T x) const { 95 | return f(offset + h * x) * h; 96 | } 97 | }; 98 | 99 | /* Initializes the weight and abcissa table. */ 100 | void init_table(); 101 | }; 102 | 103 | 104 | 105 | /*-**** Class Template Implementations ****-*/ 106 | template 107 | quadt::quadt(double eps) { 108 | max_level = 11; 109 | initial_width = 0.5; 110 | final_width = std::ldexp(initial_width, -max_level+1); 111 | table_size = static_cast(2.0 * 7.0 / final_width); 112 | this->eps = eps; 113 | 114 | init_table(); 115 | } 116 | 117 | template 118 | quadt::~quadt() { 119 | delete [] weights; 120 | delete [] points; 121 | } 122 | 123 | template 124 | void quadt::init_table() { 125 | 126 | weights = new T[table_size]; 127 | points = new T[table_size]; 128 | 129 | double h = initial_width * 2.0; 130 | double dt; 131 | double t; 132 | int i = 0; 133 | T sinh_t, cosh_t, sinh_s, cosh_s; 134 | T x, w; 135 | for (int level = 1; level <= max_level; level++, h *= 0.5) { 136 | t = h * 0.5; 137 | dt = (level == 1) ? t : h; 138 | for (;; t += dt) { 139 | sincosh(T(t), sinh_t, cosh_t); 140 | sincosh(sinh_t, sinh_s, cosh_s); 141 | x = sinh_s / cosh_s; 142 | // w = (cosh_t / cosh_s) / cosh_s; 143 | w = (cosh_t / sqr(cosh_s)); 144 | 145 | if (x == 1.0 || w < eps) { 146 | weights[i++] = 0.0; 147 | break; 148 | } 149 | 150 | points[i] = x; 151 | weights[i] = w; 152 | i++; 153 | } 154 | } 155 | 156 | } 157 | 158 | template template 159 | int quadt::integrate_u(const F &f, double tol, 160 | T &result, double &err) { 161 | T r1, r2, r3, s; 162 | T x, w; 163 | int level; 164 | double h = initial_width; 165 | bool conv = false; 166 | int i = 0; 167 | 168 | r1 = r2 = r3 = 0.0; 169 | s = f(T(0.0)); 170 | for (level = 1; level <= max_level; level++, h *= 0.5) { 171 | 172 | /* Compute the integral */ 173 | for (;;) { 174 | x = points[i]; 175 | w = weights[i]; 176 | i++; 177 | if (w == 0.0) 178 | break; 179 | s += w * (f(x) + f(-x)); 180 | } 181 | 182 | r1 = s * h; 183 | 184 | /* Check for convergence. */ 185 | if (level > 2) { 186 | double e1, e2, d1, d2; 187 | 188 | e1 = abs(to_double(r1 - r2)); 189 | if (e1 == 0.0) 190 | err = eps; 191 | else { 192 | e2 = abs(to_double(r1 - r3)); 193 | d1 = log(e1); 194 | d2 = log(e2); 195 | 196 | err = exp(d1 * d1 / d2); 197 | } 198 | 199 | cout << " level = " << level << endl; 200 | cout << " r = " << r1 << endl; 201 | cout << " err = " << err << endl; 202 | 203 | if (err < abs(r1) * tol) { 204 | conv = true; 205 | break; 206 | } 207 | } 208 | 209 | r2 = r1; 210 | r3 = r2; 211 | } 212 | 213 | if (level > max_level) 214 | puts("Level exhausted."); 215 | 216 | result = r1; 217 | if (!conv) { 218 | /* No convergence. */ 219 | return -1; 220 | } 221 | 222 | return 0; 223 | } 224 | 225 | template template 226 | int quadt::integrate(const F &f, T a, T b, double tol, 227 | T &result, double &err) { 228 | if (a == -1.0 && b == 1.0) 229 | return integrate_u(f, tol, result, err); 230 | else { 231 | UnitFunction unit_f(f, a, b); 232 | return integrate_u< UnitFunction >(unit_f, tol, result, err); 233 | } 234 | } 235 | 236 | #endif /* _QUADT_CC_ */ 237 | 238 | 239 | -------------------------------------------------------------------------------- /tests/tictoc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/tictoc.cpp 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2006 9 | * 10 | * Contains function used for timing. 11 | */ 12 | 13 | #include "tictoc.h" 14 | 15 | 16 | #ifndef _WIN32 17 | 18 | #ifdef HAVE_CLOCK_GETTIME 19 | 20 | #ifdef CLOCK_HIGHRES 21 | #define SAMPLED_CLOCK CLOCK_HIGHRES 22 | #else 23 | #define SAMPLED_CLOCK CLOCK_REALTIME 24 | #endif 25 | 26 | void tic(tictoc *tv) { 27 | if (clock_gettime(SAMPLED_CLOCK, tv)) 28 | tv->tv_sec = tv->tv_nsec = -1; 29 | } 30 | 31 | double toc(tictoc *tv) { 32 | struct timespec tv2; 33 | 34 | if (clock_gettime(SAMPLED_CLOCK, &tv2)) 35 | tv2.tv_sec = tv2.tv_nsec = -1; 36 | 37 | double sec = static_cast(tv2.tv_sec - tv->tv_sec); 38 | double nsec = static_cast(tv2.tv_nsec - tv->tv_nsec); 39 | 40 | return (sec + 1.0e-9 * nsec); 41 | } 42 | #else 43 | 44 | #ifdef HAVE_GETTIMEOFDAY 45 | 46 | void tic(tictoc *tv) { 47 | gettimeofday(tv, 0L); 48 | } 49 | 50 | double toc(tictoc *tv) { 51 | tictoc tv2; 52 | 53 | gettimeofday(&tv2, 0L); 54 | double sec = static_cast(tv2.tv_sec - tv->tv_sec); 55 | double usec = static_cast(tv2.tv_usec - tv->tv_usec); 56 | 57 | return (sec + 1.0e-6 * usec); 58 | } 59 | 60 | #else 61 | // Fall back to C/C++ low resolution time function. 62 | 63 | void tic(tictoc *tv) { 64 | time(tv); 65 | } 66 | 67 | double toc(tictoc *tv) { 68 | tictoc tv2; 69 | time(&tv2); 70 | return difftime(tv2, *tv); 71 | } 72 | 73 | #endif 74 | 75 | #endif 76 | 77 | #else 78 | 79 | // Windows. 80 | 81 | void tic(tictoc *tv) { 82 | *tv = GetTickCount(); 83 | } 84 | 85 | double toc(tictoc *tv) { 86 | tictoc tv2; 87 | tv2 = GetTickCount(); 88 | return 1.0e-3 * (tv2 - *tv); 89 | } 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /tests/tictoc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tests/timer.h 3 | * 4 | * This work was supported by the Director, Office of Science, Division 5 | * of Mathematical, Information, and Computational Sciences of the 6 | * U.S. Department of Energy under contract number DE-AC03-76SF00098. 7 | * 8 | * Copyright (c) 2000-2001 9 | * 10 | * Contains function used for timing. 11 | */ 12 | 13 | #ifndef TICTOC_H__ 14 | #define TICTOC_H__ 15 | 16 | #include "config.h" 17 | 18 | #ifdef _WIN32 19 | 20 | #include 21 | typedef DWORD tictoc; 22 | #else 23 | 24 | #ifdef HAVE_CLOCK_GETTIME 25 | #include 26 | typedef struct timespec tictoc; 27 | #else 28 | 29 | #ifdef HAVE_GETTIMEOFDAY 30 | #include 31 | typedef struct timeval tictoc; 32 | #else 33 | #include 34 | typedef time_t tictoc; 35 | #endif 36 | 37 | #endif 38 | 39 | #endif 40 | 41 | void tic(tictoc *tv); /* start timing. */ 42 | double toc(tictoc *tv); /* stop timing. */ 43 | 44 | #endif 45 | --------------------------------------------------------------------------------