├── .gitattributes ├── AUTHORS ├── BSD-LBNL-License.doc ├── COPYING ├── ChangeLog ├── INSTALL ├── INSTALL.pdf ├── LICENSE ├── Makefile.am ├── Makefile.in ├── NEWS ├── README.md ├── README_QD ├── README_QD.pdf ├── TODO ├── [config.h].in ├── aclocal.m4 ├── autom4te.cache ├── output.0 ├── output.1 ├── output.2 ├── output.3 ├── requests ├── traces.0 ├── traces.1 ├── traces.2 └── traces.3 ├── config.h.in ├── config ├── Makefile.am ├── Makefile.in ├── autogen.sh ├── config.guess ├── config.sub ├── depcomp ├── install-sh ├── ltmain.sh ├── makedist.sh ├── missing └── mkinstalldirs ├── configure ├── configure.ac ├── configure.ac.orig ├── docs ├── Makefile ├── nine-two-sum.eps ├── nine-two-sum.fig ├── normal_sum_prod.eps ├── normal_sum_prod.fig ├── qd.bib ├── qd.pdf ├── 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.in ├── Makefile.sample ├── dd_timer.f ├── ddext.f ├── ddmod.f ├── f_dd.cpp ├── f_qd.cpp ├── main.cpp ├── qd_timer.f ├── qdext.f ├── qdmod.f ├── second.f.in ├── tquaderq.f ├── tquadgsq.f ├── tquadgsq2d.f ├── tquadtsq.f ├── tquadtsq2d.f └── zz_timer.f ├── include ├── Makefile.am ├── Makefile.in └── qd │ ├── bits.h │ ├── c_dd.h │ ├── c_qd.h │ ├── dd_inline.h │ ├── dd_real.h │ ├── fpu.h │ ├── inline.h │ ├── metal_qd.h │ ├── qd_config.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 ├── libtool.m4 ├── ltoptions.m4 ├── ltsugar.m4 ├── ltversion.m4 └── lt~obsolete.m4 ├── qd-config.in ├── src ├── Makefile.am ├── Makefile.in ├── bits.cpp ├── c_dd.cpp ├── c_qd.cpp ├── dd_const.cpp ├── dd_real.cpp ├── dd_real.cpp.orig ├── fpu.cpp ├── qd_const.cpp ├── qd_real.cpp ├── util.cpp └── util.h └── tests ├── Makefile.am ├── Makefile.in ├── c_test.c ├── coeff.dat ├── compileExample.cpp ├── f_test.f ├── huge.cpp ├── makeCompileExample ├── metal_qd_test.cpp ├── pslq.h ├── pslq_test.cpp ├── qd_test.cpp ├── qd_timer.cpp ├── quadt.h ├── quadt_test.cpp ├── tictoc.cpp └── tictoc.h /.gitattributes: -------------------------------------------------------------------------------- 1 | docs/* linguist-documentation 2 | autom4te.cache/* linguist-vendored 3 | config/* linguist-vendored 4 | -------------------------------------------------------------------------------- /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 | Yves Renard 13 | - provided initial autotoolization (autoconf / automake / libool) 14 | E. Jason Riedy 15 | - various bug fixes and code cleanup. 16 | 17 | -------------------------------------------------------------------------------- /BSD-LBNL-License.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrianSwift/MetalQD/c736686610a7e5dd503bde001c6ed5b5aa1ebdd7/BSD-LBNL-License.doc -------------------------------------------------------------------------------- /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-2009, 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 "BSD-LBNL-License.doc" in the main ARPREC 12 | directory. 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 | ---- 17 | Regaurding use for commercial purposes, per 9/30/2016 18 | email from the Principal Commercialization & Licensing Lead, 19 | Computing Sciences Division, Innovation & Partnerships Office, 20 | at Lawrence Berkeley National Laboratory: 21 | 22 | "The software is on our standard LBNL BSD form as linked. You may use 23 | the software for commercial use or non-commercial use under such BSD 24 | terms as you see fit." 25 | ---- 26 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Quad-Double computation package 2 | Copyright (C) 2003-2012 3 | ================================================ 4 | 5 | Revised 13 Mar 2012 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. Run the configure script by typing 14 | 15 | ./configure 16 | 17 | The script will attempt to automatically detect various system-dependent 18 | variables used during compilation (such as the C++/fortran compiler, 19 | compiler flags, and linker flags). 20 | 21 | If you want to specify a particular C++ / F90 compiler and their flags, 22 | you can set them as environmental variables. For example: 23 | 24 | FC=ifc FCFLAGS="-O2 -FR" ./configure 25 | 26 | Important variables are 27 | 28 | CXX C++ compiler to use 29 | CXXFLAGS C++ compiler flags to use 30 | CC C compiler to use (for C demo program) 31 | CFLAGS C compiler flags to use (for C demo program) 32 | FC Fortran 90 compiler 33 | FCFLAGS Fortran 90 compiler flags to use 34 | FCLIBS Fortran 90 libraries needed to to link with C++ code. 35 | 36 | See ./configure --help to see other options. 37 | 38 | 3. The configure script should also have created the files 'config.h' and 39 | 'include/qd/qd_config.h', which will contain the compile time 40 | defines. Examine these and edit them if necessary. In most cases 41 | no edits are necessary, since the options are detected when configure 42 | was run. 43 | 44 | 4. Type "make". This will build the library, and necessary Fortran 45 | wrappers. 46 | 47 | 5. Optionally, one can build and run some simple test programs. 48 | To do this, type "make check". Some programs run during this 49 | phase is a good demonstration of how to use the qd library in C++. 50 | 51 | 6. You can now install the QD library by issuing "make install". 52 | 53 | 7. If you want to build some sample programs written in C++ 54 | you can type "make cpp-demo". 55 | 56 | 8. If you want to build some sample programs written in Fortran 90, 57 | you can type "make fortran-demo". 58 | 59 | 9. If you want to compile the Experimental Mathematician's Toolkit, 60 | type "make toolkit". This will compile the Fortran-90 codes in 61 | the toolkit cirectory, including the "mathinit" and "mathtool" 62 | Read the "README" file in the toolkit directory for additional details. 63 | 64 | 65 | System-Specific Notes 66 | ===================== 67 | 68 | Linux x86 / Itanium 69 | ------------------- 70 | You can use g++ to compile the C++ code. The Fortran 90 codes 71 | can be compiled using Intel Fortran 95 compiler 72 | 73 | http://www.intel.com/software/products/compilers/flin/ 74 | 75 | available freely for non-commercial uses. There is also a C++ 76 | compiler available (for non-commercial use) at 77 | 78 | http://www.intel.com/software/products/compilers/clin/ 79 | 80 | which can be used to compile the C++ portion. By default the 81 | configure script will use the Intel compiler if found. 82 | 83 | Apple (OS X) 84 | ------------ 85 | 86 | For Apple OS X Intel-badsed systems, it is recommended that you use 87 | the g++-4.0 (or higher) compiler and the gfortran compiler. The 88 | g++-4.0 (or higher) compiler and related command-line tools are now 89 | available via this URL (see command-line tools): 90 | https://developer.apple.com/downloads/index.action 91 | 92 | The gfortran compiler can be downloaded from: 93 | http://www.macresearch.org/files/gfortran/gfortran-4.3-Nov.mpkg.zip 94 | 95 | After installing these compilers, in the main qd directory type 96 | 97 | ./configure CXX=g++ FC=gfortran FCFLAGS=-m64 98 | 99 | then type "make" to construct the library. See the "README" file on 100 | how to construct a compile-link script for your own codes. 101 | 102 | IBM (Power) 103 | ----------- 104 | 105 | With IBM's xlC/xlf90 compilers, you may want to experiment with 106 | --enable-fma option which uses a faster code but relies on the 107 | compiler to generate a fused multiply-accumulate instruction. 108 | WARNING: since the compiler is not required to produce such 109 | instructions, this is not guaranteed to work. Please test before 110 | using. 111 | 112 | -------------------------------------------------------------------------------- /INSTALL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrianSwift/MetalQD/c736686610a7e5dd503bde001c6ed5b5aa1ebdd7/INSTALL.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2003-2009, The Regents of the University of California, 4 | through Lawrence Berkeley National Laboratory (subject to receipt of 5 | any required approvals from U.S. Dept. of Energy) 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright notice, this 12 | list of conditions and the following disclaimer. 13 | 14 | * Redistributions in binary form must reproduce the above copyright notice, 15 | this list of conditions and the following disclaimer in the documentation 16 | and/or other materials provided with the distribution. 17 | 18 | * Neither the name of the University of California, 19 | Lawrence Berkeley National Laboratory, U.S. Dept. of 20 | Energy nor the names of its contributors may be used to 21 | endorse or promote products derived from this software 22 | without specific prior written permission. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 28 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 32 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | SUBDIRS = config src include tests fortran 3 | 4 | BUILT_SOURCES = docs/qd.pdf 5 | dist_doc_DATA = README docs/qd.pdf 6 | dist_noinst_DATA = docs/Makefile \ 7 | docs/qd.tex docs/qd.bib \ 8 | docs/nine-two-sum.eps docs/nine-two-sum.fig \ 9 | docs/normal_sum_prod.eps docs/normal_sum_prod.fig \ 10 | docs/qd_add.eps docs/qd_add.fig \ 11 | docs/qd_add_proof.eps docs/qd_add_proof.fig \ 12 | docs/qd_add_qd_d.eps docs/qd_add_qd_d.fig \ 13 | docs/qd_mul_accum.eps docs/qd_mul_accum.fig \ 14 | docs/qd_mul_qd_d.eps docs/qd_mul_qd_d.fig \ 15 | docs/quick-two-sum.eps docs/quick-two-sum.fig \ 16 | docs/six-three-sum.eps docs/six-three-sum.fig \ 17 | docs/three-sum-2.eps docs/three-sum-2.fig \ 18 | docs/three-sum-3.eps docs/three-sum-3.fig \ 19 | docs/three-sum.eps docs/three-sum.fig \ 20 | docs/two-prod.eps docs/two-prod.fig \ 21 | docs/two-sum.eps docs/two-sum.fig 22 | 23 | doc: docs/qd.pdf 24 | 25 | docs/qd.pdf: 26 | $(MAKE) -C docsqd.pdf 27 | 28 | changelog: 29 | git log >ChangeLog 30 | 31 | dist-hook: 32 | rm -f ${distdir}/ChangeLog && git log >${distdir}/ChangeLog 33 | 34 | cpp-demo: 35 | $(MAKE) -C tests demo 36 | 37 | if HAVE_FORTRAN 38 | 39 | fortran-demo: 40 | $(MAKE) -C fortran demo 41 | 42 | demo: cpp-demo fortran-demo 43 | 44 | else 45 | 46 | fortran-demo: 47 | @echo "You need a Fortran 95 compiler to build fortran demo programs." && false 48 | 49 | demo: cpp-demo 50 | 51 | endif 52 | 53 | time: 54 | $(MAKE) -C tests time 55 | 56 | bin_SCRIPTS=qd-config 57 | 58 | .PHONY: changelog cpp-demo fortran-demo demo time doc 59 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Changes for 2.3.17 2 | - updated qd_real.cpp, to fix a problem with improper treatment of 3 | negative arguments in nroot. 4 | 5 | Changes for 2.3.16 6 | - Updated dd_real.cpp, to fix a problem with inaccurate values of 7 | tanh for small arguments. 8 | 9 | Changes for 2.3.15 10 | - Updated qd_real.cpp, to fix a problem with static definitions. 11 | 12 | Changes for 2.3.14 13 | - Updated autoconfig (replaced config.sub and config.guess) 14 | 15 | Changes for 2.3.7 16 | - Fixed bug in to_digits where digits larger than 10 17 | where output occasionally. 18 | 19 | Changes for 2.3.6 20 | - Added fmod (C++) and mod (Fortran) functions. 21 | 22 | Changes for 2.3.5 23 | - Fixed bug in division of qd_real by dd_real. 24 | - Fixed bug in ddoutc (Fortran ddmod.f). 25 | - Now compiles with g++ 4.3. 26 | - Distribute tests/coeff.dat. 27 | 28 | Changes for 2.3.4 29 | - Fixed bug in Makefile for cygwin / mingw systems. 30 | 31 | Changes for 2.3.3 32 | - Fixed bug in atan2. 33 | 34 | Changes for 2.3.2 35 | - Fixed bug in sin / cos / sincos where too much accuracy was 36 | lost for (moderately) large angles. 37 | - Use fused-multiply add intrinsics on IA-64 platforms if 38 | compiled by Intel compiler. 39 | - Fixed bug in c_dd_write and c_qd_write. 40 | - Fixed bug were qdext.mod was not being installed. 41 | 42 | Changes for 2.3.1 43 | - Fixed bug in sincos and cos_taylor. This affected the result 44 | of trigonometric functions in some cases. 45 | 46 | Changes for 2.3.0 47 | This is a fairly significant change, breaking API compatibility. 48 | - Moved C++ main entry in libqdmod.a to libqd_f_main.a. 49 | This allows to link Fortran code using QD with custom 50 | C++ main function. Pure Fortran code will need to be linked 51 | with qd_f_main library in addition to qdmod and qd library. 52 | - Constructors accepting pointers made explicit. 53 | - Fortran routines labeled as elemental or pure, where appropriate. 54 | - Write() is now to_string(), and now takes a single fmtflag. 55 | - dd_real addition and multiplication made commutative. 56 | - dd_real now represented as array of two doubles, instead of 57 | two discrete scalars. 58 | - New Fortran generic routines to read / write, operations with 59 | complex and integers. 60 | - Improved exp, sin, and cos functions. 61 | - Removed unused constants and obscure constants only used internally 62 | from public interface. 63 | 64 | Changes for 2.2.6 65 | - Fixed bug in mixed precision multiplication: qd_real * dd_real. 66 | 67 | Changes for 2.2.5 68 | - Bug fix in qd_real addition when --enable-ieee-add is specified. 69 | - Debugging routines dump and dump_bits updated; 70 | dump_components removed (just use dump). 71 | - Fortran support for Fortran strings. Use character arrays instead. 72 | - Return NaN under error conditions. 73 | - Added _inf constant; exp now returns Inf when argument is too large. 74 | - Output formatting fixes for Inf and NaNs. 75 | - Added more real-complex mixed arithmetic routines in Fortran 76 | interface. 77 | 78 | Changes for 2.2.4 79 | - Added random_number interface for Fortran modules. 80 | - Use slightly more conservative values for eps. 81 | - Avoid unnecessary overflow near overflow threshold. 82 | - Added radix, digits, min/maxexponent, range, and precision 83 | intrinsics to Fortran interface. 84 | - Added safe_max (C++) and safe_huge (Fortran). 85 | 86 | Changes for 2.2.3 87 | - Fix sign function bug in Fortran modules. 88 | 89 | Changes for 2.2.2 90 | - Do not bother setting uninitialized dd_real and qd_reals to zero. 91 | - Use clock_gettime if available for timing. 92 | - Fortran I/O should be more consistent with C++ version. 93 | - fpu.h is now included with dd_real.h. 94 | 95 | Changes for 2.2.1 96 | - Minor fixes when printing in scientific format. 97 | - Change search order of C++ compilers in Apple systems to avoid 98 | case insensitive filesystems. 99 | 100 | Changes for 2.2.0 101 | - Added F95 interface for complex types. 102 | - Renamed dd.h and qd.h to dd_real.h and qd_real.h, respectively. 103 | This will break older C++ code using 2.1.x library, but it was 104 | conflicting with QuickDraw libraries on Macs. (Hence the version 105 | bump to 2.2). 106 | - Removed overloaded typecast operators for int and double. These 107 | permitted *automatic* conversion of dd_real/qd_real to double or 108 | int, which is somewhat dangerous. Instead to_int and to_double 109 | routines are added. 110 | 111 | Changes for 2.1.214 112 | - Updated pslq_test. 113 | - Implmented numeric_limits<>. 114 | - Better polyroot. 115 | - Added isnan, isfinite, isinf functions. 116 | - Fix / improve input output functions. 117 | - Drop Microsoft Visual C++ 6.0 support. 118 | - More efficient dd_real::sin. 119 | 120 | Changes for 2.1.213 121 | - Support for x86_64 platforms. 122 | - Drop libtool support for now. 123 | 124 | Changes for 2.1.212 125 | - Support for pathCC compiler. 126 | - Added accurate and sloppy versions of add / sub / mul / div avaialble. 127 | - Added autodetection of fma functions. 128 | 129 | Changes for 2.1 (2003-12-30) 130 | - added automake scripts. 131 | - use libtool to compile / link and build libraries. 132 | - supports standard installation targets (make install). 133 | - support for Intel C++ compilers (icc / ecc). 134 | - Fortran programs are now linked by C++ compiler. 135 | - support for building shared library. 136 | - minor bug fixes. 137 | 138 | Changes for 2.0 (2003-12-08) 139 | - all header files are in "include/qd" directory. 140 | - added autoconf scripts. 141 | - added config.h and qd_config.h to store configuration information. 142 | - renamed x86_* routines to fpu_* routines. 143 | - added separate Fortran interface (f_* routines). 144 | - options for sloppy multiply and sloppy divison separated. 145 | - fixed C interface to be actually in C syntax. 146 | - updated / added README, AUTHORS, NEWS, and LICENSE files. 147 | - minor bug fixes. 148 | 149 | Changes for 1.2 (2003-12-04) 150 | - added "dist-clean" target in Makefile 151 | - initialize dd and qd variables to zero 152 | - increases tolerance for qd / dd tests 153 | - changed .cc extension to .cpp 154 | - updated README, COPYING, and NEWS files 155 | - added ChangeLog file 156 | - fixed bug in '-all' flag in qd_test 157 | - minor bug fixes 158 | 159 | Changes for 1.1 (2002-10-22) 160 | - added "Changes" file (this file) 161 | - fixed to 162 | - fixed constant (3/4) * pi 163 | - fixed exp(x) to return zero if x is a large negative number 164 | - removed "docs" target in Makefile 165 | 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Metal QD: QD extended precision library for Metal 2 | 3 | Metal QD is _(preliminary work on)_ a port of the QD extended precision library to Apple's Metal GPU compute language. 4 | 5 | QD is a library for Quad-Double arithmetic in which extended precision numbers are represented by the unevaluated sum of four double precision machine numbers. QD comes from http://crd-legacy.lbl.gov/~dhbailey/mpdist/ 6 | 7 | Metal QD adapts QD to the Metal environment primarily by using single precision floats instead of doubles. This allows calculations with 96-bits of precision. This port also disables references to features unavailable on the GPU, such as `iostream, string, limits, cmath`. 8 | 9 | Metal QD is based off of `qd-2.3.17` 10 | 11 | What is supported? 12 | * Constructors 13 | * Arithmetic operators: `+, -, *, =, +=, -=` 14 | * Comparison operators: `<, >, ==, !=` 15 | * Special Functions: `sqr(), mul_pwr2()` 16 | 17 | What hasn't been ported? 18 | * Anything not implemented in the _inline_ library. 19 | * Division 20 | * Trig and other transendental functions 21 | * The DD (Double-Double) type 22 | * I/O 23 | 24 | ## Usage 25 | 26 | * Copy these files to project: `metal_qd.h, qd_real.h, qd_config.h, qd_inline.h, inline.h` 27 | 28 | * In Metal or Objective-C++ source file: `#include "metal_qd.h"` 29 | 30 | * Disable Metal's unsafe floating-point optimizations. 31 | Add **-fno-fast-math** to Build Phases -> Compile Sources -> Compiler Flags for any Metal files using `metal_qd.h` 32 | * Read the `README_QD` section **C. Programming techniques** 33 | 34 | 35 | ## Example Code Snipet 36 | 37 | qd_real q; 38 | q=1.; // native 1.0 converted to qd_real q 39 | q+=exp2(-95.); // native 2^-95 added to qd_real q 40 | // q now represents 1.000000000000000000000000000025 41 | // This has more precision than can be represented in a native double 42 | 43 | // Conversion to/from float4 usefull for passing values between CPU and GPU 44 | simd::float4 vq; 45 | vq=to_float4(q); // Convert qd_real to float4 46 | 47 | qd_real qvq; // Convert and float4 back to qd_real 48 | qvq=vq; 49 | 50 | Find the above in `tests/metal_qd_test.cpp` 51 | 52 | ## Future Work 53 | 54 | * Port non-inline and `DD` portions of library 55 | * Create proper Metal framework 56 | * Create demo app using Metal QD on GPU (in addition to CPU) 57 | * Test having both QD and Metal_QD in same CPU source 58 | * Update documentation to reflect Metal_QD 59 | -------------------------------------------------------------------------------- /README_QD.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrianSwift/MetalQD/c736686610a7e5dd503bde001c6ed5b5aa1ebdd7/README_QD.pdf -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /[config.h].in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrianSwift/MetalQD/c736686610a7e5dd503bde001c6ed5b5aa1ebdd7/[config.h].in -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to dummy `main' function (if any) required to link to the Fortran 4 | libraries. */ 5 | #undef FC_DUMMY_MAIN 6 | 7 | /* Define if F77 and FC dummy `main' functions are identical. */ 8 | #undef FC_DUMMY_MAIN_EQ_F77 9 | 10 | /* Define to a macro mangling the given C identifier (in lower and upper 11 | case), which must not contain underscores, for linking with Fortran. */ 12 | #undef FC_FUNC 13 | 14 | /* As FC_FUNC, but for C identifiers containing underscores. */ 15 | #undef FC_FUNC_ 16 | 17 | /* Define to alternate name for `main' routine that is called from a `main' in 18 | the Fortran libraries. */ 19 | #undef FC_MAIN 20 | 21 | /* Define to 1 if your system has the clock_gettime function. */ 22 | #undef HAVE_CLOCK_GETTIME 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_DLFCN_H 26 | 27 | /* Define to 1 if Fortran interface is to be compiled. */ 28 | #undef HAVE_FORTRAN 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_FPU_CONTROL_H 32 | 33 | /* Define to 1 if you have the `gettimeofday' function. */ 34 | #undef HAVE_GETTIMEOFDAY 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_IEEEFP_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_INTTYPES_H 41 | 42 | /* Define to 1 if you have the `m' library (-lm). */ 43 | #undef HAVE_LIBM 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_MEMORY_H 47 | 48 | /* Define to 1 if stdbool.h conforms to C99. */ 49 | #undef HAVE_STDBOOL_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_STDINT_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_STDLIB_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_STRINGS_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #undef HAVE_STRING_H 62 | 63 | /* Define to 1 if you have the header file. */ 64 | #undef HAVE_SYS_STAT_H 65 | 66 | /* Define to 1 if you have the header file. */ 67 | #undef HAVE_SYS_TYPES_H 68 | 69 | /* Define to 1 if you have the header file. */ 70 | #undef HAVE_UNISTD_H 71 | 72 | /* Define to 1 if the system has the type `_Bool'. */ 73 | #undef HAVE__BOOL 74 | 75 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 76 | */ 77 | #undef LT_OBJDIR 78 | 79 | /* qd major version number */ 80 | #undef MAJOR_VERSION 81 | 82 | /* qd minor version number */ 83 | #undef MINOR_VERSION 84 | 85 | /* Name of package */ 86 | #undef PACKAGE 87 | 88 | /* Define to the address where bug reports for this package should be sent. */ 89 | #undef PACKAGE_BUGREPORT 90 | 91 | /* Define to the full name of this package. */ 92 | #undef PACKAGE_NAME 93 | 94 | /* Define to the full name and version of this package. */ 95 | #undef PACKAGE_STRING 96 | 97 | /* Define to the one symbol short name of this package. */ 98 | #undef PACKAGE_TARNAME 99 | 100 | /* Define to the home page for this package. */ 101 | #undef PACKAGE_URL 102 | 103 | /* Define to the version of this package. */ 104 | #undef PACKAGE_VERSION 105 | 106 | /* qd patch number (sub minor version) */ 107 | #undef PATCH_VERSION 108 | 109 | /* Any special symbols needed for exporting APIs. */ 110 | #undef QD_API 111 | 112 | /* Define this macro to be the copysign(x, y) function. */ 113 | #undef QD_COPYSIGN 114 | 115 | /* Define to 1 to enable debugging code. */ 116 | #undef QD_DEBUG 117 | 118 | /* If fused multiply-add is available, define correct macro for using it. */ 119 | #undef QD_FMA 120 | 121 | /* If fused multiply-subtract is available, define correct macro for using it. 122 | */ 123 | #undef QD_FMS 124 | 125 | /* Define to 1 if your compiler have the C++ standard include files. */ 126 | #undef QD_HAVE_STD 127 | 128 | /* Define to 1 to use additions with IEEE-style error bounds. */ 129 | #undef QD_IEEE_ADD 130 | 131 | /* Define to 1 to inline commonly used functions. */ 132 | #undef QD_INLINE 133 | 134 | /* Define this macro to be the isfinite(x) function. */ 135 | #undef QD_ISFINITE 136 | 137 | /* Define this macro to be the isinf(x) function. */ 138 | #undef QD_ISINF 139 | 140 | /* Define this macro to be the isnan(x) function. */ 141 | #undef QD_ISNAN 142 | 143 | /* Define to 1 to use sloppy division (which is faster by slightly 144 | inaccurate). */ 145 | #undef QD_SLOPPY_DIV 146 | 147 | /* Define to 1 to use sloppy multiplication (which is faster by slightly 148 | inaccurate). */ 149 | #undef QD_SLOPPY_MUL 150 | 151 | /* Set to 1 if using VisualAge C++ compiler for __fmadd builtin. */ 152 | #undef QD_VACPP_BUILTINS_H 153 | 154 | /* Define to 1 if you have the ANSI C header files. */ 155 | #undef STDC_HEADERS 156 | 157 | /* Define to 1 if you can safely include both and . */ 158 | #undef TIME_WITH_SYS_TIME 159 | 160 | /* Define to 1 if your declares `struct tm'. */ 161 | #undef TM_IN_SYS_TIME 162 | 163 | /* Version number of package */ 164 | #undef VERSION 165 | 166 | /* Whether to use x86 fpu fix. */ 167 | #undef X86 168 | -------------------------------------------------------------------------------- /config/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = autogen.sh config.guess config.sub depcomp install-sh \ 2 | ltmain.sh makedist.sh missing mkinstalldirs 3 | -------------------------------------------------------------------------------- /config/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "Creating changelog..." && git log >ChangeLog && 3 | echo "Running aclocal..." && aclocal -I ./m4 $ACLOCAL_FLAGS && 4 | echo "Running autoheader..." && autoheader && 5 | echo "Running automake..." && automake && 6 | echo "Running autoconf..." && autoconf && 7 | rm -rf autom4te.cache 8 | 9 | -------------------------------------------------------------------------------- /config/makedist.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PACKAGE_NAME=qd 3 | MAJOR_VERSION=2 4 | MINOR_VERSION=3 5 | PATCH_LEVEL=$1 6 | if [ -z "$PATCH_LEVEL" ]; then 7 | echo "Usage: makedist.sh patch-level" 8 | exit 9 | fi 10 | 11 | if [ "$PATCH_LEVEL" = "git" ]; then 12 | PATCH_LEVEL=git-$(git log --max-count=1 --pretty=oneline | cut -c -8) 13 | fi 14 | VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL 15 | 16 | echo "Creating $PACKAGE_NAME-$VERSION distribution..." 17 | 18 | DIR=/var/tmp/$PACKAGE_NAME-$$ 19 | ORIG_DIR=`pwd` 20 | 21 | export CXX=g++ 22 | export FC=gfortran 23 | 24 | mkdir -p $DIR && 25 | cp -pr . $DIR && 26 | cd $DIR && 27 | mv configure.ac configure.old && 28 | sed "/^define(\[QD_PATCH_VERSION\]/s/devel/$PATCH_LEVEL/" configure.old >configure.ac && 29 | rm -f configure.old && 30 | config/autogen.sh && 31 | ./configure && 32 | git log --no-merges >ChangeLog && 33 | make doc && 34 | make distcheck && 35 | cp $PACKAGE_NAME-$VERSION.tar.gz $ORIG_DIR && 36 | rm -rf $DIR 37 | 38 | -------------------------------------------------------------------------------- /config/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | 4 | scriptversion=2006-05-11.19 5 | 6 | # Original author: Noah Friedman 7 | # Created: 1993-05-16 8 | # Public domain. 9 | # 10 | # This file is maintained in Automake, please report 11 | # bugs to or send patches to 12 | # . 13 | 14 | nl=' 15 | ' 16 | IFS=" "" $nl" 17 | errstatus=0 18 | dirmode= 19 | 20 | usage="\ 21 | Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... 22 | 23 | Create each directory DIR (with mode MODE, if specified), including all 24 | leading file name components. 25 | 26 | Report bugs to ." 27 | 28 | # process command line arguments 29 | while test $# -gt 0 ; do 30 | case $1 in 31 | -h | --help | --h*) # -h for help 32 | echo "$usage" 33 | exit $? 34 | ;; 35 | -m) # -m PERM arg 36 | shift 37 | test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } 38 | dirmode=$1 39 | shift 40 | ;; 41 | --version) 42 | echo "$0 $scriptversion" 43 | exit $? 44 | ;; 45 | --) # stop option processing 46 | shift 47 | break 48 | ;; 49 | -*) # unknown option 50 | echo "$usage" 1>&2 51 | exit 1 52 | ;; 53 | *) # first non-opt arg 54 | break 55 | ;; 56 | esac 57 | done 58 | 59 | for file 60 | do 61 | if test -d "$file"; then 62 | shift 63 | else 64 | break 65 | fi 66 | done 67 | 68 | case $# in 69 | 0) exit 0 ;; 70 | esac 71 | 72 | # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and 73 | # mkdir -p a/c at the same time, both will detect that a is missing, 74 | # one will create a, then the other will try to create a and die with 75 | # a "File exists" error. This is a problem when calling mkinstalldirs 76 | # from a parallel make. We use --version in the probe to restrict 77 | # ourselves to GNU mkdir, which is thread-safe. 78 | case $dirmode in 79 | '') 80 | if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then 81 | echo "mkdir -p -- $*" 82 | exec mkdir -p -- "$@" 83 | else 84 | # On NextStep and OpenStep, the `mkdir' command does not 85 | # recognize any option. It will interpret all options as 86 | # directories to create, and then abort because `.' already 87 | # exists. 88 | test -d ./-p && rmdir ./-p 89 | test -d ./--version && rmdir ./--version 90 | fi 91 | ;; 92 | *) 93 | if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && 94 | test ! -d ./--version; then 95 | echo "mkdir -m $dirmode -p -- $*" 96 | exec mkdir -m "$dirmode" -p -- "$@" 97 | else 98 | # Clean up after NextStep and OpenStep mkdir. 99 | for d in ./-m ./-p ./--version "./$dirmode"; 100 | do 101 | test -d $d && rmdir $d 102 | done 103 | fi 104 | ;; 105 | esac 106 | 107 | for file 108 | do 109 | case $file in 110 | /*) pathcomp=/ ;; 111 | *) pathcomp= ;; 112 | esac 113 | oIFS=$IFS 114 | IFS=/ 115 | set fnord $file 116 | shift 117 | IFS=$oIFS 118 | 119 | for d 120 | do 121 | test "x$d" = x && continue 122 | 123 | pathcomp=$pathcomp$d 124 | case $pathcomp in 125 | -*) pathcomp=./$pathcomp ;; 126 | esac 127 | 128 | if test ! -d "$pathcomp"; then 129 | echo "mkdir $pathcomp" 130 | 131 | mkdir "$pathcomp" || lasterr=$? 132 | 133 | if test ! -d "$pathcomp"; then 134 | errstatus=$lasterr 135 | else 136 | if test ! -z "$dirmode"; then 137 | echo "chmod $dirmode $pathcomp" 138 | lasterr= 139 | chmod "$dirmode" "$pathcomp" || lasterr=$? 140 | 141 | if test ! -z "$lasterr"; then 142 | errstatus=$lasterr 143 | fi 144 | fi 145 | fi 146 | fi 147 | 148 | pathcomp=$pathcomp/ 149 | done 150 | done 151 | 152 | exit $errstatus 153 | 154 | # Local Variables: 155 | # mode: shell-script 156 | # sh-indentation: 2 157 | # eval: (add-hook 'write-file-hooks 'time-stamp) 158 | # time-stamp-start: "scriptversion=" 159 | # time-stamp-format: "%:y-%02m-%02d.%02H" 160 | # time-stamp-end: "$" 161 | # End: 162 | -------------------------------------------------------------------------------- /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.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BrianSwift/MetalQD/c736686610a7e5dd503bde001c6ed5b5aa1ebdd7/docs/qd.pdf -------------------------------------------------------------------------------- /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_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.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.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 | libqd_f_main_la_SOURCES = main.cpp 20 | ddmod.lo: $(DDEXT) ddext.lo 21 | qdmod.lo: ddmod.lo $(DDMOD) qdext.lo 22 | $(QDMOD): qdmod.lo $(DDMOD) 23 | $(DDMOD): ddmod.lo 24 | $(DDEXT): ddext.lo 25 | $(QDEXT): qdext.lo $(DDEXT) 26 | 27 | qdmoddir = $(includedir)/$(PACKAGE) 28 | qdmod_HEADERS = $(QDMOD) $(QDEXT) $(DDMOD) $(DDEXT) 29 | 30 | DEMO=quaderq$(EXEEXT) quadgsq2d$(EXEEXT) quadgsq$(EXEEXT) \ 31 | quadtsq$(EXEEXT) quadtsq2d$(EXEEXT) 32 | TIMER = dd_timer$(EXEEXT) qd_timer$(EXEEXT) 33 | EXTRA_PROGRAMS=$(DEMO) $(TIMER) 34 | 35 | quaderq_SOURCES = tquaderq.f 36 | nodist_quaderq_SOURCES=second.f 37 | quaderq_LINK=$(CXXLINK) 38 | 39 | quadgsq2d_SOURCES = tquadgsq2d.f 40 | nodist_quadgsq2d_SOURCES=second.f 41 | quadgsq2d_LINK=$(CXXLINK) 42 | 43 | quadgsq_SOURCES = tquadgsq.f 44 | nodist_quadgsq_SOURCES=second.f 45 | quadgsq_LINK=$(CXXLINK) 46 | 47 | quadtsq_SOURCES = tquadtsq.f 48 | nodist_quadtsq_SOURCES=second.f 49 | quadtsq_LINK=$(CXXLINK) 50 | 51 | quadtsq2d_SOURCES = tquadtsq2d.f 52 | nodist_quadtsq2d_SOURCES=second.f 53 | quadtsq2d_LINK=$(CXXLINK) 54 | 55 | dd_timer_SOURCES = dd_timer.f 56 | nodist_dd_timer_SOURCES = second.f 57 | dd_timer_LINK=$(CXXLINK) 58 | 59 | qd_timer_SOURCES = qd_timer.f 60 | nodist_qd_timer_SOURCES = second.f 61 | qd_timer_LINK=$(CXXLINK) 62 | 63 | demo: $(DEMO) 64 | 65 | CLEANFILES = $(EXTRA_PROGRAMS) *.mod 66 | 67 | endif 68 | 69 | MAINTAINERCLEANFILES = dd_timer.f qd_timer.f 70 | EXTRA_DIST = dd_timer.f qd_timer.f zz_timer.f Makefile.sample 71 | 72 | dd_timer.f: zz_timer.f 73 | sed -e 's/@@/dd/' zz_timer.f >dd_timer.f 74 | 75 | qd_timer.f: zz_timer.f 76 | sed -e 's/@@/qd/' zz_timer.f >qd_timer.f 77 | 78 | if HAVE_FORTRAN 79 | .PHONY: demo 80 | endif 81 | 82 | -------------------------------------------------------------------------------- /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/dd_timer.f: -------------------------------------------------------------------------------- 1 | ! program to time the various routines 2 | subroutine f_main 3 | 4 | use ddmodule 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 (dd_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 = ddpi() 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 ddwrite(6, a) 38 | 39 | write (6, *) 'Timing multiplication ...' 40 | n = 512 41 | do k = 1, 25 42 | n = n * 2 43 | a = 1.0d0 + ddpi() * 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 ddwrite(6, a) 61 | 62 | write (6, *) 'Timing division ...' 63 | n = 512 64 | do k = 1, 25 65 | n = n * 2 66 | a = 1.0d0 + ddpi() 67 | b = 2.0d0 + ddpi() 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 ddwrite(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 + ddpi() 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 ddwrite(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 * ddreal(1.0d0) / dble(n) 108 | d = 2.45d0 * ddpi() / 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 ddwrite(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(ddreal(-50.1d0)); 127 | d = exp(ddreal(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 ddwrite(6, a) 139 | 140 | end 141 | 142 | -------------------------------------------------------------------------------- /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/qd_timer.f: -------------------------------------------------------------------------------- 1 | ! program to time the various routines 2 | subroutine f_main 3 | 4 | use qdmodule 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 (qd_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 = qdpi() 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 qdwrite(6, a) 38 | 39 | write (6, *) 'Timing multiplication ...' 40 | n = 512 41 | do k = 1, 25 42 | n = n * 2 43 | a = 1.0d0 + qdpi() * 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 qdwrite(6, a) 61 | 62 | write (6, *) 'Timing division ...' 63 | n = 512 64 | do k = 1, 25 65 | n = n * 2 66 | a = 1.0d0 + qdpi() 67 | b = 2.0d0 + qdpi() 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 qdwrite(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 + qdpi() 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 qdwrite(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 * qdreal(1.0d0) / dble(n) 108 | d = 2.45d0 * qdpi() / 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 qdwrite(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(qdreal(-50.1d0)); 127 | d = exp(qdreal(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 qdwrite(6, a) 139 | 140 | end 141 | 142 | -------------------------------------------------------------------------------- /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 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | 98 | #endif /* _QD_C_DD_H */ 99 | -------------------------------------------------------------------------------- /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 | void 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 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* _QD_C_QD_H */ 120 | -------------------------------------------------------------------------------- /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 | // Configure for non-metal-ported behavior 19 | #ifndef QDT 20 | #define QDT double 21 | #define QDT_double 1 22 | #define QDT_float 0 23 | #define QD_ASQ /* */ 24 | #define QD_GPU 0 25 | #define QD_HAVE_SIMD 0 26 | #endif 27 | 28 | 29 | #if QDT_double 30 | #define _QD_SPLITTER 134217729.0 // = 2^27 + 1 31 | #define _QD_SPLIT_THRESH 6.69692879491417e+299 // = 2^996 (996=Emax"1023"-27) 32 | #elif QDT_float 33 | #define _QD_SPLITTER 4097.0 // = 2^12 + 1 34 | #define _QD_SPLIT_THRESH 4.153837487E34 // = 2^115 (115=Emax"127"-12) 35 | #else 36 | #error "Must define QDT_double or QDT_float" 37 | #endif 38 | 39 | #ifdef QD_VACPP_BUILTINS_H 40 | /* For VisualAge C++ __fmadd */ 41 | #include 42 | #endif 43 | 44 | #if !QD_GPU 45 | #include 46 | #include 47 | #else 48 | #endif 49 | 50 | namespace qd { 51 | 52 | #if !QD_GPU 53 | static const QDT _d_nan = std::numeric_limits::quiet_NaN(); 54 | static const QDT _d_inf = std::numeric_limits::infinity(); 55 | #else 56 | #endif 57 | 58 | #ifdef __FAST_MATH__ 59 | #error Following code incompatible with -ffast-math , needs -fno-fast-math 60 | #endif 61 | 62 | /*********** Basic Functions ************/ 63 | /* Computes fl(a+b) and err(a+b). Assumes |a| >= |b|. */ 64 | inline QDT quick_two_sum(QDT a, QDT b, QD_ASQ QDT &err) { 65 | QDT s = a + b; 66 | err = b - (s - a); 67 | return s; 68 | } 69 | 70 | /* Computes fl(a-b) and err(a-b). Assumes |a| >= |b| */ 71 | inline QDT quick_two_diff(QDT a, QDT b, QD_ASQ QDT &err) { 72 | QDT s = a - b; 73 | err = (a - s) - b; 74 | return s; 75 | } 76 | 77 | /* Computes fl(a+b) and err(a+b). */ 78 | inline QDT two_sum(QDT a, QDT b, QD_ASQ QDT &err) { 79 | QDT s = a + b; 80 | QDT bb = s - a; 81 | err = (a - (s - bb)) + (b - bb); 82 | return s; 83 | } 84 | 85 | /* Computes fl(a-b) and err(a-b). */ 86 | inline QDT two_diff(QDT a, QDT b, QD_ASQ QDT &err) { 87 | QDT s = a - b; 88 | QDT bb = s - a; 89 | err = (a - (s - bb)) - (b + bb); 90 | return s; 91 | } 92 | 93 | #if QD_GPU 94 | #ifndef QD_FMS 95 | #error QD_FMS should be defined when using metal 96 | #endif 97 | #endif 98 | 99 | #ifndef QD_FMS 100 | /* Computes high word and lo word of a */ 101 | inline void split(QDT a, QDT &hi, QDT &lo) { 102 | QDT temp; 103 | if (a > _QD_SPLIT_THRESH || a < -_QD_SPLIT_THRESH) { 104 | #if QDT_double 105 | a *= 3.7252902984619140625e-09; // 2^-28 106 | temp = _QD_SPLITTER * a; 107 | hi = temp - (temp - a); 108 | lo = a - hi; 109 | hi *= 268435456.0; // 2^28 110 | lo *= 268435456.0; // 2^28 111 | #elif QDT_float 112 | a *= .00012207031250000000; // 2^-13 113 | temp = _QD_SPLITTER * a; 114 | hi = temp - (temp - a); 115 | lo = a - hi; 116 | hi *= 8192.; // 2^13 117 | lo *= 8192.; // 2^13 118 | #else 119 | #error "Must define QDT_double or QDT_float" 120 | #endif 121 | } else { 122 | temp = _QD_SPLITTER * a; 123 | hi = temp - (temp - a); 124 | lo = a - hi; 125 | } 126 | } 127 | #endif 128 | 129 | /* Computes fl(a*b) and err(a*b). */ 130 | inline QDT two_prod(QDT a, QDT b, QD_ASQ QDT &err) { 131 | #ifdef QD_FMS 132 | QDT p = a * b; 133 | err = QD_FMS(a, b, p); 134 | return p; 135 | #else 136 | QDT a_hi, a_lo, b_hi, b_lo; 137 | QDT p = a * b; 138 | split(a, a_hi, a_lo); 139 | split(b, b_hi, b_lo); 140 | err = ((a_hi * b_hi - p) + a_hi * b_lo + a_lo * b_hi) + a_lo * b_lo; 141 | return p; 142 | #endif 143 | } 144 | 145 | /* Computes fl(a*a) and err(a*a). Faster than the above method. */ 146 | inline QDT two_sqr(QDT a, QD_ASQ QDT &err) { 147 | #ifdef QD_FMS 148 | QDT p = a * a; 149 | err = QD_FMS(a, a, p); 150 | return p; 151 | #else 152 | QDT hi, lo; 153 | QDT q = a * a; 154 | split(a, hi, lo); 155 | err = ((hi * hi - q) + 2.0 * hi * lo) + lo * lo; 156 | return q; 157 | #endif 158 | } 159 | 160 | /* Computes the nearest integer to d. */ 161 | inline QDT nint(QDT d) { 162 | if (d == std::floor(d)) 163 | return d; 164 | return std::floor(d + 0.5); 165 | } 166 | 167 | /* Computes the truncated integer. */ 168 | inline QDT aint(QDT d) { 169 | return (d >= 0.0) ? std::floor(d) : std::ceil(d); 170 | } 171 | 172 | /* These are provided to give consistent 173 | interface for double with double-double and quad-double. */ 174 | inline void sincosh(QDT t, QD_ASQ QDT &sinh_t, QD_ASQ QDT &cosh_t) { 175 | sinh_t = std::sinh(t); 176 | cosh_t = std::cosh(t); 177 | } 178 | 179 | inline QDT sqr(QDT t) { 180 | return t * t; 181 | } 182 | 183 | inline QDT to_double(QDT a) { return a; } 184 | inline int to_int(QDT a) { return static_cast(a); } 185 | 186 | } 187 | 188 | #endif /* _QD_INLINE_H */ 189 | -------------------------------------------------------------------------------- /include/qd/metal_qd.h: -------------------------------------------------------------------------------- 1 | // 2 | // metal_qd.h 3 | // Mandelbits 4 | // 5 | // Created by Brian Swift on 10/8/16. 6 | // Copyright © 2016 Brian Swift. All rights reserved. 7 | // 8 | 9 | // Various definitions to configure QD library to be quad float based, 10 | // and to be usable in both Metal on GPU and C++ on CPU. 11 | 12 | #ifndef metal_qd_h 13 | #define metal_qd_h 14 | 15 | #define QDT float 16 | #define QDT_float 1 17 | #define QDT_double 0 18 | #define QD_GPU 1 /* Disables I/O and other definitions not ported to GPU yet */ 19 | 20 | #ifdef __METAL_VERSION__ 21 | #define QD_ASQ thread /* address space qualifier */ 22 | #else 23 | #define QD_ASQ /* */ 24 | #endif 25 | 26 | #ifdef __METAL_VERSION__ 27 | namespace std = metal; /* fixes various uses of std::math_function */ 28 | #else 29 | #import 30 | #endif 31 | 32 | #ifdef __METAL_VERSION__ 33 | #define QD_FMS(x,y,z) precise::fma(x,y,-z) 34 | #else 35 | #define QD_FMS(x,y,z) fma(x,y,-z) 36 | #endif 37 | 38 | // #define inline /* */ /* to disable inline for dubugging and analysis */ 39 | 40 | // enable float4 conversions if SIMD available 41 | #if defined(SIMD_LIBRARY_VERSION)||defined(__METAL_VERSION__)||defined(matrix_add) 42 | #define QD_HAVE_SIMD 1 43 | #else 44 | #define QD_HAVE_SIMD 0 45 | #endif 46 | 47 | 48 | #include "qd_real.h" 49 | 50 | 51 | #ifndef __METAL_VERSION__ 52 | inline qd_real::qd_real(double d) { 53 | x[0]=d; 54 | x[1]=d-x[0]; 55 | x[2]=d-x[0]-x[1]; 56 | x[3]=d-x[0]-x[1]-x[2]; // this should be 0 57 | qd::renorm(x[0],x[1],x[2],x[3]); 58 | } 59 | #endif 60 | 61 | 62 | #if QD_HAVE_SIMD 63 | // define conversions from and to float4 64 | inline qd_real::qd_real(simd::float4 xx) { 65 | x[0] = xx.x; 66 | x[1] = xx.y; 67 | x[2] = xx.z; 68 | x[3] = xx.w; 69 | } 70 | 71 | inline simd::float4 to_float4(const QD_ASQ qd_real &a) { 72 | simd::float4 t={a[0],a[1],a[2],a[3]}; 73 | return t; 74 | } 75 | #endif 76 | 77 | 78 | #endif /* metal_qd_h */ 79 | -------------------------------------------------------------------------------- /include/qd/qd_config.h: -------------------------------------------------------------------------------- 1 | /* include/qd/qd_config.h. Generated from qd_config.h.in by configure. */ 2 | #ifndef _QD_QD_CONFIG_H 3 | #define _QD_QD_CONFIG_H 1 4 | 5 | #ifndef QD_API 6 | #define QD_API /**/ 7 | #endif 8 | 9 | /* Set to 1 if using VisualAge C++ compiler for __fmadd builtin. */ 10 | #ifndef QD_VACPP_BUILTINS_H 11 | /* #undef QD_VACPP_BUILTINS_H */ 12 | #endif 13 | 14 | /* If fused multiply-add is available, define to correct macro for 15 | using it. It is invoked as QD_FMA(a, b, c) to compute fl(a * b + c). 16 | If correctly rounded multiply-add is not available (or if unsure), 17 | keep it undefined.*/ 18 | #ifndef QD_FMA 19 | /* #undef QD_FMA */ 20 | #endif 21 | 22 | /* If fused multiply-subtract is available, define to correct macro for 23 | using it. It is invoked as QD_FMS(a, b, c) to compute fl(a * b - c). 24 | If correctly rounded multiply-add is not available (or if unsure), 25 | keep it undefined.*/ 26 | #ifndef QD_FMS 27 | /* #undef QD_FMS */ 28 | #endif 29 | 30 | /* Set the following to 1 to define commonly used function 31 | to be inlined. This should be set to 1 unless the compiler 32 | does not support the "inline" keyword, or if building for 33 | debugging purposes. */ 34 | #ifndef QD_INLINE 35 | #define QD_INLINE 1 36 | #endif 37 | 38 | /* Set the following to 1 to use ANSI C++ standard header files 39 | such as cmath, iostream, etc. If set to zero, it will try to 40 | include math.h, iostream.h, etc, instead. */ 41 | #ifndef QD_HAVE_STD 42 | #define QD_HAVE_STD 1 43 | #endif 44 | 45 | /* Set the following to 1 to make the addition and subtraction 46 | to satisfy the IEEE-style error bound 47 | 48 | fl(a + b) = (1 + d) * (a + b) 49 | 50 | where |d| <= eps. If set to 0, the addition and subtraction 51 | will satisfy the weaker Cray-style error bound 52 | 53 | fl(a + b) = (1 + d1) * a + (1 + d2) * b 54 | 55 | where |d1| <= eps and |d2| eps. */ 56 | #ifndef QD_IEEE_ADD 57 | /* #undef QD_IEEE_ADD */ 58 | #endif 59 | 60 | /* Set the following to 1 to use slightly inaccurate but faster 61 | version of multiplication. */ 62 | #ifndef QD_SLOPPY_MUL 63 | #define QD_SLOPPY_MUL 1 64 | #endif 65 | 66 | /* Set the following to 1 to use slightly inaccurate but faster 67 | version of division. */ 68 | #ifndef QD_SLOPPY_DIV 69 | #define QD_SLOPPY_DIV 1 70 | #endif 71 | 72 | /* Define this macro to be the isfinite(x) function. */ 73 | #ifndef QD_ISFINITE 74 | #define QD_ISFINITE(x) std::isfinite(x) 75 | #endif 76 | 77 | /* Define this macro to be the isinf(x) function. */ 78 | #ifndef QD_ISINF 79 | #define QD_ISINF(x) std::isinf(x) 80 | #endif 81 | 82 | /* Define this macro to be the isnan(x) function. */ 83 | #ifndef QD_ISNAN 84 | #define QD_ISNAN(x) std::isnan(x) 85 | #endif 86 | 87 | 88 | #endif /* _QD_QD_CONFIG_H */ 89 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3017 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3017]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6b' 20 | macro_revision='1.3017' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /m4/lt~obsolete.m4: -------------------------------------------------------------------------------- 1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004. 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 4 lt~obsolete.m4 11 | 12 | # These exist entirely to fool aclocal when bootstrapping libtool. 13 | # 14 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) 15 | # which have later been changed to m4_define as they aren't part of the 16 | # exported API, or moved to Autoconf or Automake where they belong. 17 | # 18 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 19 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 20 | # using a macro with the same name in our local m4/libtool.m4 it'll 21 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define 22 | # and doesn't know about Autoconf macros at all.) 23 | # 24 | # So we provide this file, which has a silly filename so it's always 25 | # included after everything else. This provides aclocal with the 26 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 27 | # because those macros already exist, or will be overwritten later. 28 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 29 | # 30 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 31 | # Yes, that means every name once taken will need to remain here until 32 | # we give up compatibility with versions before 1.7, at which point 33 | # we need to keep only those names which we still refer to. 34 | 35 | # This is to help aclocal find these macros, as it can't see m4_define. 36 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 37 | 38 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 39 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 40 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 41 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 42 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 43 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 44 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 45 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 46 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 47 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 48 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 49 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 50 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 51 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 52 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 53 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 54 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 55 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 56 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 57 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 58 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 59 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 60 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 61 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 62 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 63 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 64 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 65 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 66 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 67 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 68 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 69 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 70 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 71 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 72 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 73 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 74 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 75 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 76 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 77 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 78 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 79 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 80 | m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) 81 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 82 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 83 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 84 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 85 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 86 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 87 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 88 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 89 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 90 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 91 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 92 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 93 | -------------------------------------------------------------------------------- /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 @REQ_CXXFLAGS@" 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 | -------------------------------------------------------------------------------- /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/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 | 13 | const dd_real dd_real::_2pi = dd_real(6.283185307179586232e+00, 14 | 2.449293598294706414e-16); 15 | const dd_real dd_real::_pi = dd_real(3.141592653589793116e+00, 16 | 1.224646799147353207e-16); 17 | const dd_real dd_real::_pi2 = dd_real(1.570796326794896558e+00, 18 | 6.123233995736766036e-17); 19 | const dd_real dd_real::_pi4 = dd_real(7.853981633974482790e-01, 20 | 3.061616997868383018e-17); 21 | const dd_real dd_real::_3pi4 = dd_real(2.356194490192344837e+00, 22 | 9.1848509936051484375e-17); 23 | const dd_real dd_real::_e = dd_real(2.718281828459045091e+00, 24 | 1.445646891729250158e-16); 25 | const dd_real dd_real::_log2 = dd_real(6.931471805599452862e-01, 26 | 2.319046813846299558e-17); 27 | const dd_real dd_real::_log10 = dd_real(2.302585092994045901e+00, 28 | -2.170756223382249351e-16); 29 | const dd_real dd_real::_nan = dd_real(qd::_d_nan, qd::_d_nan); 30 | const dd_real dd_real::_inf = dd_real(qd::_d_inf, qd::_d_inf); 31 | 32 | const double dd_real::_eps = 4.93038065763132e-32; // 2^-104 33 | const double dd_real::_min_normalized = 2.0041683600089728e-292; // = 2^(-1022 + 53) 34 | const dd_real dd_real::_max = 35 | dd_real(1.79769313486231570815e+308, 9.97920154767359795037e+291); 36 | const dd_real dd_real::_safe_max = 37 | dd_real(1.7976931080746007281e+308, 9.97920154767359795037e+291); 38 | const int dd_real::_ndigits = 31; 39 | 40 | 41 | -------------------------------------------------------------------------------- /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 | 15 | /* Some useful constants. */ 16 | const qd_real qd_real::_2pi = qd_real(6.283185307179586232e+00, 17 | 2.449293598294706414e-16, 18 | -5.989539619436679332e-33, 19 | 2.224908441726730563e-49); 20 | const qd_real qd_real::_pi = qd_real(3.141592653589793116e+00, 21 | 1.224646799147353207e-16, 22 | -2.994769809718339666e-33, 23 | 1.112454220863365282e-49); 24 | const qd_real qd_real::_pi2 = qd_real(1.570796326794896558e+00, 25 | 6.123233995736766036e-17, 26 | -1.497384904859169833e-33, 27 | 5.562271104316826408e-50); 28 | const qd_real qd_real::_pi4 = qd_real(7.853981633974482790e-01, 29 | 3.061616997868383018e-17, 30 | -7.486924524295849165e-34, 31 | 2.781135552158413204e-50); 32 | const qd_real qd_real::_3pi4 = qd_real(2.356194490192344837e+00, 33 | 9.1848509936051484375e-17, 34 | 3.9168984647504003225e-33, 35 | -2.5867981632704860386e-49); 36 | const qd_real qd_real::_e = qd_real(2.718281828459045091e+00, 37 | 1.445646891729250158e-16, 38 | -2.127717108038176765e-33, 39 | 1.515630159841218954e-49); 40 | const qd_real qd_real::_log2 = qd_real(6.931471805599452862e-01, 41 | 2.319046813846299558e-17, 42 | 5.707708438416212066e-34, 43 | -3.582432210601811423e-50); 44 | const qd_real qd_real::_log10 = qd_real(2.302585092994045901e+00, 45 | -2.170756223382249351e-16, 46 | -9.984262454465776570e-33, 47 | -4.023357454450206379e-49); 48 | const qd_real qd_real::_nan = qd_real(qd::_d_nan, qd::_d_nan, 49 | qd::_d_nan, qd::_d_nan); 50 | const qd_real qd_real::_inf = qd_real(qd::_d_inf, qd::_d_inf, 51 | qd::_d_inf, qd::_d_inf); 52 | 53 | const double qd_real::_eps = 1.21543267145725e-63; // = 2^-209 54 | const double qd_real::_min_normalized = 1.6259745436952323e-260; // = 2^(-1022 + 3*53) 55 | const qd_real qd_real::_max = qd_real( 56 | 1.79769313486231570815e+308, 9.97920154767359795037e+291, 57 | 5.53956966280111259858e+275, 3.07507889307840487279e+259); 58 | const qd_real qd_real::_safe_max = qd_real( 59 | 1.7976931080746007281e+308, 9.97920154767359795037e+291, 60 | 5.53956966280111259858e+275, 3.07507889307840487279e+259); 61 | const int qd_real::_ndigits = 62; 62 | 63 | -------------------------------------------------------------------------------- /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/compileExample.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | // simple exaple of QD usage to illustrate linking process 4 | // Alex Kaiser, LBNL, 6/3/2010 5 | 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main() { 15 | 16 | // ensure that 80-bit arithmetic is not in place 17 | // this call forces 64-bit arithmetic 18 | unsigned int old_cw; 19 | fpu_fix_start(&old_cw); 20 | 21 | cout.precision(60); 22 | 23 | // simple read example 24 | /* 25 | qd_real readTest ; 26 | cin >> readTest ; 27 | cout << "readTest = " << readTest << endl ; 28 | */ 29 | 30 | // simple demo 31 | qd_real x = "1.0" ; 32 | x /= 3.0 ; 33 | qd_real y ; 34 | y = pow( qd_real(2.0) , 3 ) ; 35 | cout << "y = " << y << endl; 36 | cout << "x = " << x << endl; 37 | 38 | 39 | qd_real a ; 40 | qd_real b = qd_real("0.1"); 41 | 42 | a = sqrt(b); 43 | cout << " sqrt(0.1) = " << a << endl; 44 | cout << " sqrt(0.1) * sqrt(0.1) = " << a * a << endl; 45 | 46 | fpu_fix_end(&old_cw); 47 | return 0; 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /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/makeCompileExample: -------------------------------------------------------------------------------- 1 | all: compileExample 2 | 3 | CXX = g++ -Wall 4 | 5 | compileExample: compileExample.o 6 | $(CXX) compileExample.o -o compileExample -l qd 7 | 8 | compileExample.o: 9 | $(CXX) -c compileExample.cpp 10 | 11 | 12 | clean: 13 | rm compileExample.o compileExample -------------------------------------------------------------------------------- /tests/metal_qd_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Basic test of Metal_QD on CPU 3 | 4 | Build and run: 5 | c++ metal_qd_test.cpp -I../include/qd -o metal_qd_test && ./metal_qd_test 6 | 7 | Expected Output: 8 | qvq = 1.000000000000000000000000000025 9 | vq = 0x1p+0 0x1p-95 0x0p+0 0x0p+0 10 | d = 1 0x1p+0 11 | */ 12 | 13 | #import 14 | 15 | #include "metal_qd.h" 16 | 17 | #import 18 | 19 | using namespace std; 20 | 21 | #if QDT_double 22 | #define print_precision 67 23 | #elif QDT_float 24 | #define print_precision 30 25 | #else 26 | #error "Must define QDT_double or QDT_float" 27 | #endif 28 | 29 | // A hack to print simple QD numbers. 30 | // Actual code to correctly print QD value is significantly more complex. 31 | // See to_string and to_digits in qd_real.cpp 32 | void print_qd(const qd_real &a){ 33 | qd_real x = a; 34 | int t = trunc(x[0]); 35 | cout << t ; 36 | cout << "." ; 37 | x -= t; 38 | for(int i = 0 ; i < print_precision ; i++){ 39 | x *= 10. ; 40 | t = trunc(x[0]); 41 | cout << t ; 42 | x -= t; 43 | } 44 | } 45 | 46 | int main() { 47 | 48 | qd_real q; 49 | q=1.; // native 1.0 converted to qd_real q 50 | q+=exp2(-95.); // native 2^-95 added to qd_real q 51 | // q now represents 1.000000000000000000000000000025 52 | // This has more precision than can be represented in a native double 53 | 54 | simd::float4 vq; 55 | vq=to_float4(q); // Convert qd_real to float4 56 | 57 | qd_real qvq; // Convert and float4 back to qd_real 58 | qvq=vq; 59 | 60 | 61 | // Demonstrate machine double lacks sufficient precision to represent this number 62 | double d; 63 | d=1.0; 64 | d+=exp2(-95.); // d remains 1.0 65 | 66 | cout << "qvq = " ; print_qd(qvq); cout << endl; // qvq = 1.000000000000000000000000000025 67 | 68 | printf("vq = %a %a %a %a\n",vq.x,vq.y,vq.z,vq.w); // vq = 0x1p+0 0x1p-95 0x0p+0 0x0p+0 69 | 70 | printf("d = %g %a\n",d,d); // d = 1 0x1p+0 71 | 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /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 | 27 | using std::sqrt; 28 | using std::abs; 29 | 30 | using namespace qd; 31 | 32 | #define MIN(a, b) ( ((a)<(b)) ? (a) : (b) ) 33 | #define MAX(a, b) ( ((a)>(b)) ? (a) : (b) ) 34 | #define SWAP(a, b) { t = a; a = b; b = t; } 35 | #define SQR(a) ( (a)*(a) ) 36 | 37 | /* Create an n-by-m matrix of T. Diagonal elements 38 | are initialized to diag, while all other elements are 39 | initialized to elem. */ 40 | template 41 | T **new_matrix(int nr_rows, int nr_cols, 42 | T diag = 0.0, T elem = 0.0) { 43 | T **m = new T *[nr_rows]; 44 | int i, j; 45 | 46 | for (i = 0; i < nr_rows; i++) 47 | m[i] = new T[nr_cols]; 48 | for (i = 0; i < nr_rows; i++) 49 | for (j = 0; j < nr_cols; j++) 50 | m[i][j] = (i == j) ? diag : elem; 51 | return m; 52 | } 53 | 54 | /* Create an n-vector of T. Each elements are initialized to elem. */ 55 | template 56 | T *new_vector(int n, T elem = 0.0) { 57 | T *v = new T[n]; 58 | for (int i = 0; i < n; i++) 59 | v[i] = elem; 60 | return v; 61 | } 62 | 63 | /* Destroys a matrix m. */ 64 | template 65 | void delete_matrix(T **m, int nr_rows) { 66 | for (int i = 0; i < nr_rows; i++) 67 | delete [] m[i]; 68 | delete [] m; 69 | } 70 | 71 | /* Destroys a vector v. */ 72 | template 73 | void delete_vector(T *v) { 74 | delete [] v; 75 | } 76 | 77 | /* The parameter gamma used in the PSLQ algorithm. */ 78 | static const double gam = 1.2; 79 | 80 | /* Perform PSLQ integer relation algorithm to find any 81 | linear relation among the n numbers in the vector x. 82 | It returns the coefficients found in the vector r. 83 | The parameter eps provides the precision of type T. */ 84 | template 85 | int pslq(const T *x, int n, T *r, double eps, int max_itr) { 86 | T *s = new_vector(n); 87 | T *y = new_vector(n); 88 | T **a = new_matrix(n, n, 1.0); 89 | T **b = new_matrix(n, n, 1.0); 90 | T **h = new_matrix(n, n-1, 0.0); 91 | T t; 92 | double teps = 16.0 * eps; 93 | int i, j, k; 94 | int err = 0; 95 | 96 | /* Compute the vector s */ 97 | t = x[n-1] * x[n-1]; 98 | s[n-1] = abs(x[n-1]); 99 | for (i = n-2; i >= 0; i--) { 100 | t += x[i] * x[i]; 101 | s[i] = sqrt(t); 102 | } 103 | 104 | /* Normalize the vector x, s. */ 105 | t = s[0]; 106 | for (i = 0; i < n; i++) 107 | y[i] = x[i] / t; 108 | s[0] = 1.0; 109 | for (i = 1; i < n; i++) 110 | s[i] /= t; 111 | 112 | /* Construct matrix H. */ 113 | for (i = 0; i < n; i++) { 114 | for (j = 0; j <= MIN(i, n-2); j++) { 115 | h[i][j] = (i == j) ? s[j+1]/s[j] : - y[i]*y[j] / (s[j] * s[j+1]); 116 | } 117 | } 118 | 119 | /* Reduce matrix H. */ 120 | for (i = 1; i < n; i++) { 121 | for (j = i-1; j >= 0; j--) { 122 | t = nint(h[i][j] / h[j][j]); 123 | y[j] += t * y[i]; 124 | for (k = 0; k <= j; k++) 125 | h[i][k] -= t * h[j][k]; 126 | for (k = 0; k < n; k++) { 127 | a[i][k] -= t * a[j][k]; 128 | b[k][j] += t * b[k][i]; 129 | } 130 | } 131 | } 132 | 133 | int m; 134 | int itr = 0; 135 | bool done = false; 136 | 137 | while(!done) { 138 | 139 | itr++; 140 | 141 | /* Select m such that gam^i * |H_ii| is maximal when i = m. */ 142 | T m_val = -1.0; 143 | T g = gam; 144 | m = -1; 145 | 146 | for (i = 0; i < n-1; i++, g *= gam) { 147 | t = abs(g * h[i][i]); 148 | if (t > m_val) { 149 | m_val = t; 150 | m = i; 151 | } 152 | } 153 | 154 | if (m < 0) { 155 | /* This shouldn't happen. */ 156 | err = 1; 157 | break; 158 | } 159 | 160 | /* Exchange entries m and m+1 of y, 161 | rows m and m+1 of A and H, 162 | columns m and m+1 of B. */ 163 | SWAP(y[m], y[m+1]) 164 | for (i = 0; i < n; i++) { 165 | SWAP(a[m][i], a[m+1][i]) 166 | } 167 | for (i = 0; i < n-1; i++) { 168 | SWAP(h[m][i], h[m+1][i]) 169 | } 170 | for (i = 0; i < n; i++) { 171 | SWAP(b[i][m], b[i][m+1]) 172 | } 173 | 174 | 175 | /* Remove the corner on H diagonal. */ 176 | if (m < n-2) { 177 | T t0, t1, t2, t3, t4; 178 | t0 = sqrt(SQR(h[m][m]) + SQR(h[m][m+1])); 179 | t1 = h[m][m] / t0; 180 | t2 = h[m][m+1] / t0; 181 | for (i = m; i < n; i++) { 182 | t3 = h[i][m]; 183 | t4 = h[i][m+1]; 184 | h[i][m] = t1 * t3 + t2 * t4; 185 | h[i][m+1] = t1 * t4 - t2 * t3; 186 | } 187 | } 188 | 189 | /* Reduce H. */ 190 | for (i = m+1; i < n; i++) { 191 | for (j = MIN(i-1, m+1); j >= 0; j--) { 192 | t = nint(h[i][j]/h[j][j]); 193 | y[j] += t * y[i]; 194 | for (k = 0; k <= j; k++) { 195 | h[i][k] -= t * h[j][k]; 196 | } 197 | for (k = 0; k < n; k++) { 198 | a[i][k] -= t * a[j][k]; 199 | b[k][j] += t * b[k][i]; 200 | } 201 | } 202 | } 203 | 204 | 205 | /* Norm bound */ 206 | m_val = -1.0e308; 207 | for (j = 0; j < n-1; j++) { 208 | t = abs(h[j][j]); 209 | if (t > m_val) 210 | m_val = t; 211 | } 212 | 213 | /* Check the y vector for zeros. */ 214 | for (i = 0; i < n; i++) { 215 | t = abs(y[i]); 216 | if (t < teps) { 217 | m = i; 218 | done = true; 219 | break; 220 | } 221 | } 222 | 223 | if (itr > max_itr) { 224 | done = true; 225 | err = -1; 226 | } 227 | 228 | } /* while */ 229 | 230 | /* Get the coefficients. */ 231 | if (err == 0) { 232 | for (i = 0; i < n; i++) { 233 | r[i] = b[i][m]; 234 | } 235 | } 236 | 237 | delete_matrix(h, n); 238 | delete_matrix(a, n); 239 | delete_matrix(b, n); 240 | delete_vector(y); 241 | delete_vector(s); 242 | 243 | return err; 244 | } 245 | 246 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------