--- /dev/null
+diff -Nur qd-2.3.12.orig/configure.ac qd-2.3.12/configure.ac
+--- qd-2.3.12.orig/configure.ac 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/configure.ac 2012-01-12 22:34:18.000000000 +0000
+@@ -308,12 +308,11 @@
+ AC_SUBST(FFLAGS, $FCFLAGS)
+
+ # Add libraries
+-LIBS="$LIBS -lm"
++AC_CHECK_LIB(m,sqrt)
+
+ # libtool stuff
+-# AC_DISABLE_SHARED
+-# AC_PROG_LIBTOOL
+-AC_PROG_RANLIB
++AC_DISABLE_SHARED
++AC_PROG_LIBTOOL
+
+ # Output
+ AC_CONFIG_FILES([Makefile config/Makefile src/Makefile include/Makefile
+diff -Nur qd-2.3.12.orig/fortran/Makefile.am qd-2.3.12/fortran/Makefile.am
+--- qd-2.3.12.orig/fortran/Makefile.am 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/fortran/Makefile.am 2012-01-12 22:48:19.000000000 +0000
+@@ -1,6 +1,6 @@
+ if HAVE_FORTRAN
+ AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include
+-LDADD=libqdmod.a libqd_f_main.a $(top_builddir)/src/libqd.a $(FCLIBS)
++LDADD=libqdmod.la libqd_f_main.la $(top_builddir)/src/libqd.la $(FCLIBS)
+
+ if UPCASE_MODULE
+ DDEXT=DDEXT.$(module_ext)
+@@ -14,17 +14,17 @@
+ DDMOD=ddmodule.$(module_ext)
+ endif
+
+-lib_LIBRARIES = libqdmod.a libqd_f_main.a
+-libqdmod_a_SOURCES = ddext.f ddmod.f qdext.f qdmod.f f_dd.cpp f_qd.cpp
+-libqd_f_main_a_SOURCES = main.cpp
+-ddmod.o: ddext.o
+-qdmod.o: ddmod.o qdext.o
+-$(QDMOD): qdmod.o
+-$(DDMOD): ddmod.o
+-$(DDEXT): ddext.o
+-$(QDEXT): qdext.o
++lib_LTLIBRARIES = libqdmod.la libqd_f_main.la
++libqdmod_la_SOURCES = ddext.f ddmod.f qdext.f qdmod.f f_dd.cpp f_qd.cpp
++libqd_f_main_la_SOURCES = main.cpp
++ddmod.lo: $(DDEXT) ddext.lo
++qdmod.lo: ddmod.lo $(DDMOD) qdext.lo
++$(QDMOD): qdmod.lo $(DDMOD)
++$(DDMOD): ddmod.lo
++$(DDEXT): ddext.lo
++$(QDEXT): qdext.lo $(DDEXT)
+
+-pkglib_DATA = $(QDMOD) $(QDEXT) $(DDMOD) $(DDEXT)
++include_HEADERS = $(QDMOD) $(QDEXT) $(DDMOD) $(DDEXT)
+
+ DEMO=quaderq$(EXEEXT) quadgsq2d$(EXEEXT) quadgsq$(EXEEXT) \
+ quadtsq$(EXEEXT) quadtsq2d$(EXEEXT)
+diff -Nur qd-2.3.12.orig/m4/ax_cxx_clock_gettime.m4 qd-2.3.12/m4/ax_cxx_clock_gettime.m4
+--- qd-2.3.12.orig/m4/ax_cxx_clock_gettime.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_cxx_clock_gettime.m4 2012-01-12 22:11:48.000000000 +0000
+@@ -3,13 +3,13 @@
+ AC_DEFUN([AX_CXX_CLOCK_GETTIME], [
+ AC_MSG_CHECKING([for clock_gettime useability])
+ AC_LANG_PUSH(C++)
+-AC_COMPILE_IFELSE([
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ #include <time.h>
+ int main() {
+ struct timespec tv;
+ return clock_gettime(CLOCK_REALTIME, &tv);
+ }
+-], [ax_cxx_clock_gettime="yes"], [ax_cxx_clock_gettime="no"])
++])], [ax_cxx_clock_gettime="yes"], [ax_cxx_clock_gettime="no"])
+ AC_LANG_POP(C++)
+ AC_MSG_RESULT([$ax_cxx_clock_gettime])
+ ])
+diff -Nur qd-2.3.12.orig/m4/ax_cxx_copysign.m4 qd-2.3.12/m4/ax_cxx_copysign.m4
+--- qd-2.3.12.orig/m4/ax_cxx_copysign.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_cxx_copysign.m4 2012-01-12 22:12:57.000000000 +0000
+@@ -6,19 +6,19 @@
+ AC_MSG_CHECKING([for copysign])
+ AC_LANG_PUSH(C++)
+ ax_cxx_copysign=
+-AC_COMPILE_IFELSE([#include <cmath>
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ std::copysign(1.0, 1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(std::copysign)
+ ax_cxx_copysign="std::copysign(x, y)"])
+ if test "x$ax_cxx_copysign" = "x"; then
+- AC_COMPILE_IFELSE([#include <cmath>
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ ::copysign(1.0, 1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(::copysign)
+ ax_cxx_copysign="::copysign(x, y)"],
+ [AC_MSG_RESULT(none)
+diff -Nur qd-2.3.12.orig/m4/ax_cxx_fma.m4 qd-2.3.12/m4/ax_cxx_fma.m4
+--- qd-2.3.12.orig/m4/ax_cxx_fma.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_cxx_fma.m4 2012-01-12 21:58:52.000000000 +0000
+@@ -19,14 +19,14 @@
+ case $name in
+ ibm)
+ # IBM VisualAge C++ __fmadd / __fmsub.
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ #include <builtins.h>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ double x = __fmadd(1.0 + d, 1.0 - d, -1.0);
+ double y = __fmsub(1.0 + d, 1.0 - d, 1.0);
+ return (x == -d*d && y == -d*d) ? 0 : 1;
+- }],
++ }])],
+ [ax_cxx_fma="__fmadd(x,y,z)"
+ ax_cxx_fms="__fmsub(x,y,z)"
+ AC_DEFINE([QD_VACPP_BUILTINS_H], [1],
+@@ -34,11 +34,11 @@
+ ;;
+ gnu)
+ # Later gcc (3.4 and later) have __builtin_fma that seems to work.
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ return (__builtin_fma(1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1);
+- }],
++ }])],
+ [ax_cxx_fma="__builtin_fma(x,y,z)"
+ ax_cxx_fms="__builtin_fma(x,y,-z)"])
+ ;;
+@@ -46,22 +46,22 @@
+ # Intel and HP compilers for IA 64 architecture seems to have
+ # _Asm_fma/fms macros. Not much documentation is available for
+ # these...
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ return (_Asm_fma(2, 1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1);
+- }],
++ }])],
+ [ax_cxx_fma="_Asm_fma(2, x,y,z)"
+ ax_cxx_fms="_Asm_fms(2, x,y,z)"])
+ ;;
+ c99)
+ # Try C99 fma() function. Some platforms doesn't seem to implement this
+ # correctly (Apple gcc-3.3 for example).
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ return (fma(1.0 + d, 1.0 - d, -1.0) == -d*d ? 0 : 1);
+- }],
++ }])],
+ [ax_cxx_fma="fma(x,y,z)"
+ ax_cxx_fms="fma(x,y,-z)"])
+ ;;
+@@ -69,11 +69,11 @@
+ # Try relying on the compiler to optimize x * y + z into an fma.
+ # This method is not recommended since if it is inlined it does not
+ # always produce the same correct code.
+- AC_RUN_IFELSE([#include <cmath>
++ AC_RUN_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ double d = std::ldexp(1.0, -52);
+ return ( (1.0 + d) * (1.0 - d) - 1.0 == -d*d ? 0 : 1);
+- }],
++ }])],
+ [ax_cxx_fma="((x)*(y) + (z))"
+ ax_cxx_fms="((x)*(y) - (z))"])
+ ;;
+diff -Nur qd-2.3.12.orig/m4/ax_cxx_isfinite.m4 qd-2.3.12/m4/ax_cxx_isfinite.m4
+--- qd-2.3.12.orig/m4/ax_cxx_isfinite.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_cxx_isfinite.m4 2012-01-12 22:13:36.000000000 +0000
+@@ -6,19 +6,19 @@
+ AC_MSG_CHECKING([for isfinite])
+ AC_LANG_PUSH(C++)
+ ax_cxx_isfinite=
+-AC_COMPILE_IFELSE([#include <cmath>
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ std::isfinite(1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(std::isfinite)
+ ax_cxx_isfinite="std::isfinite(x)"])
+ if test "x$ax_cxx_isfinite" = "x"; then
+- AC_COMPILE_IFELSE([#include <cmath>
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ ::isfinite(1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(::isfinite)
+ ax_cxx_isfinite="::isfinite(x)"],
+ [AC_MSG_RESULT(none)
+diff -Nur qd-2.3.12.orig/m4/ax_cxx_isinf.m4 qd-2.3.12/m4/ax_cxx_isinf.m4
+--- qd-2.3.12.orig/m4/ax_cxx_isinf.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_cxx_isinf.m4 2012-01-12 22:14:20.000000000 +0000
+@@ -6,19 +6,19 @@
+ AC_MSG_CHECKING([for isinf])
+ AC_LANG_PUSH(C++)
+ ax_cxx_isinf=
+-AC_COMPILE_IFELSE([#include <cmath>
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ std::isinf(1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(std::isinf)
+ ax_cxx_isinf="std::isinf(x)"])
+ if test "x$ax_cxx_isinf" = "x"; then
+- AC_COMPILE_IFELSE([#include <cmath>
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ ::isinf(1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(::isinf)
+ ax_cxx_isinf="::isinf(x)"],
+ [AC_MSG_RESULT(none)
+diff -Nur qd-2.3.12.orig/m4/ax_cxx_isnan.m4 qd-2.3.12/m4/ax_cxx_isnan.m4
+--- qd-2.3.12.orig/m4/ax_cxx_isnan.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_cxx_isnan.m4 2012-01-12 22:14:58.000000000 +0000
+@@ -6,19 +6,19 @@
+ AC_MSG_CHECKING([for isnan])
+ AC_LANG_PUSH(C++)
+ ax_cxx_isnan=
+-AC_COMPILE_IFELSE([#include <cmath>
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ std::isnan(1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(std::isnan)
+ ax_cxx_isnan="std::isnan(x)"])
+ if test "x$ax_cxx_isnan" = "x"; then
+- AC_COMPILE_IFELSE([#include <cmath>
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([#include <cmath>
+ int main() {
+ ::isnan(1.0);
+ return 0;
+- }],
++ }])],
+ [AC_MSG_RESULT(::isnan)
+ ax_cxx_isnan="::isnan(x)"],
+ [AC_MSG_RESULT(none)
+diff -Nur qd-2.3.12.orig/m4/ax_f90_module_flag.m4 qd-2.3.12/m4/ax_f90_module_flag.m4
+--- qd-2.3.12.orig/m4/ax_f90_module_flag.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_f90_module_flag.m4 2012-01-12 22:28:24.000000000 +0000
+@@ -16,7 +16,7 @@
+
+ AC_DEFUN([AX_F90_MODULE_FLAG],[
+ AC_CACHE_CHECK([fortran 90 modules inclusion flag],
+-ax_f90_modflag,
++ax_cv_f90_modflag,
+ [AC_LANG_PUSH(Fortran)
+ i=0
+ while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do
+@@ -24,24 +24,24 @@
+ done
+ mkdir tmpdir_$i
+ cd tmpdir_$i
+-AC_COMPILE_IFELSE([module conftest_module
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([module conftest_module
+ contains
+ subroutine conftest_routine
+ write(*,'(a)') 'gotcha!'
+ end subroutine conftest_routine
+ end module conftest_module
+- ],[],[])
++ ])],[],[])
+ cd ..
+ ax_f90_modflag="not found"
+ for ax_flag in "-I " "-M" "-p"; do
+ if test "$ax_f90_modflag" = "not found" ; then
+ ax_save_FCFLAGS="$FCFLAGS"
+ FCFLAGS="$ax_save_FCFLAGS ${ax_flag}tmpdir_$i"
+- AC_COMPILE_IFELSE([program conftest_program
++ AC_COMPILE_IFELSE([AC_LANG_SOURCE([program conftest_program
+ use conftest_module
+ call conftest_routine
+ end program conftest_program
+- ],[ax_f90_modflag="$ax_flag"],[])
++ ])],[ax_f90_modflag="$ax_flag"],[])
+ FCFLAGS="$ax_save_FCFLAGS"
+ fi
+ done
+diff -Nur qd-2.3.12.orig/m4/ax_f90_module_style.m4 qd-2.3.12/m4/ax_f90_module_style.m4
+--- qd-2.3.12.orig/m4/ax_f90_module_style.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_f90_module_style.m4 2012-01-12 22:28:50.000000000 +0000
+@@ -21,7 +21,7 @@
+
+ AC_DEFUN([AX_F90_MODULE_STYLE],[
+ AC_CACHE_CHECK([fortran 90 modules naming style],
+-ax_f90_module_style,
++ax_cv_f90_module_style,
+ [AC_LANG_PUSH(Fortran)
+ i=0
+ while test \( -f tmpdir_$i \) -o \( -d tmpdir_$i \) ; do
+@@ -29,13 +29,13 @@
+ done
+ mkdir tmpdir_$i
+ cd tmpdir_$i
+-AC_COMPILE_IFELSE([module conftest_module
++AC_COMPILE_IFELSE([AC_LANG_SOURCE([module conftest_module
+ contains
+ subroutine conftest_routine
+ write(*,'(a)') 'gotcha!'
+ end subroutine conftest_routine
+ end module conftest_module
+- ],
++ ])],
+ [ax_f90_modext=`ls | sed -n 's,conftest_module\.,,p'`
+ if test x$ax_f90_modext = x ; then
+ dnl Some F90 compilers put module filename in uppercase letters
+diff -Nur qd-2.3.12.orig/m4/ax_fc_etime.m4 qd-2.3.12/m4/ax_fc_etime.m4
+--- qd-2.3.12.orig/m4/ax_fc_etime.m4 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/m4/ax_fc_etime.m4 2012-01-12 22:42:03.000000000 +0000
+@@ -4,9 +4,9 @@
+ ax_fc_etime=
+ ax_fc_etime_names="etime etime_"
+ for name in $ax_fc_etime_names; do
+- AC_LINK_IFELSE([AC_LANG_PROGRAM(, [[
++ AC_LINK_IFELSE([AC_LANG_PROGRAM(, [AC_LANG_SOURCE([
+ real*4 t(2), tot
+- tot = $name(t)]])],
++ tot = $name(t)])])],
+ [ax_fc_etime=$name], [])
+ if test "x$ax_fc_etime" != "x"; then
+ break;
+diff -Nur qd-2.3.12.orig/Makefile.am qd-2.3.12/Makefile.am
+--- qd-2.3.12.orig/Makefile.am 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/Makefile.am 2012-01-12 20:21:15.000000000 +0000
+@@ -1,7 +1,6 @@
+ ACLOCAL_AMFLAGS = -I m4
+ SUBDIRS = config src include tests fortran
+
+-docdir=${datadir}/doc/${PACKAGE}
+ BUILT_SOURCES = docs/qd.pdf
+ dist_doc_DATA = README docs/qd.pdf
+ dist_noinst_DATA = docs/Makefile \
+@@ -24,7 +23,7 @@
+ doc: docs/qd.pdf
+
+ docs/qd.pdf:
+- cd docs && $(MAKE) qd.pdf
++ $(MAKE) -C docsqd.pdf
+
+ changelog:
+ git log >ChangeLog
+@@ -33,12 +32,12 @@
+ rm -f ${distdir}/ChangeLog && git log >${distdir}/ChangeLog
+
+ cpp-demo:
+- cd tests && make demo
++ $(MAKE) -C tests demo
+
+ if HAVE_FORTRAN
+
+ fortran-demo:
+- cd fortran && make demo
++ $(MAKE) -C fortran demo
+
+ demo: cpp-demo fortran-demo
+
+@@ -52,7 +51,7 @@
+ endif
+
+ time:
+- cd tests && make time
++ $(MAKE) -C tests time
+
+ bin_SCRIPTS=qd-config
+
+diff -Nur qd-2.3.12.orig/README.txt qd-2.3.12/README.txt
+--- qd-2.3.12.orig/README.txt 1970-01-01 01:00:00.000000000 +0100
++++ qd-2.3.12/README.txt 2012-01-12 20:17:09.000000000 +0000
+@@ -0,0 +1,704 @@
++-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐ \r
++QUAD-‐DOUBLE/DOUBLE-‐DOUBLE \r COMPUTATION \r PACKAGE \r \r
++ \r
++ \r
++ \r
++ \r
++ \r
++Copyright \r (c) \r 2005-‐2010 \r \r
++ \r
++ \r
++ \r
++ \r
++-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐-‐ \r
++ \r
++Revision \r date: \r \r 2010 \r June \r 14 \r
++ \r
++Authors: \r
++Yozo \r Hida \r
++ \r
++U.C. \r Berkeley \r \r \r \r \r
++ \r
++yozo@cs.berkeley.edu \r
++Xiaoye \r S. \r Li \r \r \r
++Lawrence \r Berkeley \r Natl \r Lab \r \r \r xiaoye@nersc.gov \r
++David \r H. \r Bailey \r \r \r
++Lawrence \r Berkeley \r Natl \r Lab \r \r \r dhbailey@lbl.gov \r
++ \r
++C++ \r usage \r guide: \r
++Alex \r Kaiser \r \r \r
++Lawrence \r Berkeley \r Natl \r Lab \r \r adkaiser@lbl.gov \r
++ \r
++This \r work \r was \r supported \r by \r the \r Director, \r Office \r of \r Science, \r Division \r of \r Mathematical, \r
++Information, \r and \r Computational \r Sciences \r of \r the \r U.S. \r Department \r of \r Energy \r under \r contract \r
++number \r DE-‐AC02-‐05CH11231. \r
++ \r
++This \r work \r was \r supported \r by \r the \r Director, \r Office \r of \r Science, \r Division \r of \r Mathematical, \r
++Information, \r and \r Computational \r Sciences \r of \r the \r U.S. \r Department \r of \r Energy \r under \r contract \r
++numbers \r DE-‐AC03-‐76SF00098 \r and \r DE-‐AC02-‐05CH11231. \r
++ \r
++*** \r IMPORTANT \r NOTES: \r
++ \r
++See \r the \r file \r COPYING \r for \r modified \r BSD \r license \r information. \r
++See \r the \r file \r INSTALL \r for \r installation \r instructions. \r
++See \r the \r file \r NEWS \r for \r recent \r revisions. \r
++ \r
++Outline: \r
++ \r
++I. \r \r \r Introduction \r
++II. \r \r Directories \r and \r Files \r
++III. \r C++ \r Usage \r
++IV. \r \r Fortran \r Usage \r
++V. \r \r \r Note \r on \r x86-‐Based \r Processors \r (MOST \r systems \r in \r use \r today) \r
++ \r
++ \r
++I. \r Introduction \r
++ \r
++This \r package \r provides \r numeric \r types \r of \r twice \r the \r precision \r of \r IEEE \r double \r (106 \r mantissa \r
++bits, \r or \r approximately \r 32 \r decimal \r digits) \r and \r four \r times \r the \r precision \r of \r IEEE \r double \r (212 \r
++mantissa \r bits, \r or \r approximately \r 64 \r decimal \r digits). \r \r Due \r to \r features \r such \r as \r operator \r and \r
++function \r overloading, \r these \r facilities \r can \r be \r utilized \r with \r only \r minor \r modifications \r to \r
++conventional \r C++ \r and \r Fortran-‐90 \r programs. \r
++ \r
++In \r addition \r to \r the \r basic \r arithmetic \r operations \r (add, \r subtract, \r multiply, \r divide, \r square \r root), \r
++common \r transcendental \r functions \r such \r as \r the \r exponential, \r logarithm, \r trigonometric \r and \r
++hyperbolic \r functions \r are \r also \r included. \r \r A \r detailed \r description \r of \r the \r algorithms \r used \r is \r
++
++\favailable \r in \r the \r docs \r subdirectory \r (see \r docs/qd.ps). \r \r An \r abridged \r version \r of \r this \r paper, \r
++which \r was \r presented \r at \r the \r ARITH-‐15 \r conference, \r is \r also \r available \r in \r this \r same \r directory \r
++(see \r docs/arith15.ps). \r
++ \r
++II. \r Directories \r and \r Files \r
++ \r
++There \r are \r six \r directories \r and \r several \r files \r in \r the \r main \r directory \r of \r this \r distribution, \r
++described \r below \r
++ \r
++src \r \r \r This \r contains \r the \r source \r code \r of \r the \r quad-‐double \r and \r double-‐double \r
++ \r \r
++ \r
++library. \r \r This \r source \r code \r does \r not \r include \r inline \r functions, \r
++ \r \r
++ \r
++which \r are \r found \r in \r the \r header \r files \r in \r the \r include \r directory. \r
++ \r
++include \r \r This \r directory \r contains \r the \r header \r files. \r
++ \r
++fortran \r \r This \r directory \r contains \r Fortran-‐90 \r files. \r
++ \r
++tests \r This \r directory \r contains \r some \r simple \r (not \r comprehensive) \r tests. \r
++ \r
++docs \r \r This \r directory \r contains \r two \r papers \r describing \r the \r algorithms. \r
++ \r
++config \r \r \r This \r directory \r contains \r various \r scripts \r used \r by \r the \r configure \r
++ \r \r
++ \r
++script \r and \r the \r Makefile. \r
++ \r
++ \r
++ \r
++ \r
++C++ \r Usage: \r \r
++ \r
++Please \r note \r that \r all \r commands \r refer \r to \r a \r Unix-‐type \r environment \r such \r as \r Mac \r OSX \r or \r Ubuntu \r
++Linux \r using \r the \r bash \r shell. \r \r
++ \r
++ \r
++A. \r Building \r
++ \r
++To \r build \r the \r library, \r first \r run \r the \r included \r configure \r script \r by \r typing \r \r
++ \r
++./configure \r
++ \r
++This \r script \r automatically \r generates \r makefiles \r for \r building \r the \r library \r and \r selects \r compilers \r
++and \r necessary \r flags \r and \r libraries \r to \r include. \r If \r the \r user \r wishes \r to \r specify \r compilers \r or \r flags \r
++they \r may \r use \r the \r following \r options. \r \r
++ \r
++CXX \r \r \r \r \r \r \r \r
++C++ \r compiler \r to \r use \r
++CXXFLAGS \r \r \r C++ \r compiler \r flags \r to \r use \r
++CC \r \r \r \r \r \r \r \r \r \r
++C \r compiler \r to \r use \r (for \r C \r demo \r program) \r
++CFLAGS \r \r \r \r \r
++C \r compiler \r flags \r to \r use \r (for \r C \r demo \r program) \r
++FC \r \r \r \r \r \r \r \r \r \r
++Fortran \r 90 \r compiler \r
++FCFLAGS \r \r \r \r
++Fortran \r 90 \r compiler \r flags \r to \r use \r
++FCLIBS \r \r \r \r \r
++Fortran \r 90 \r libraries \r needed \r to \r link \r with \r C++ \r code. \r
++ \r
++
++\fFor \r example, \r if \r one \r is \r using \r GNU \r compilers, \r configure \r with: \r
++ \r
++./configure \r CXX=g++ \r FC=gfortran \r
++ \r
++The \r Fortran \r and \r C++ \r compilers \r must \r produce \r compatible \r binaries. \r On \r some \r systems \r
++additional \r flags \r must \r be \r included \r to \r ensure \r that \r portions \r of \r the \r library \r are \r not \r built \r with \r 32 \r
++and \r 64 \r bit \r object \r files. \r For \r example, \r on \r 64-‐Bit \r Mac \r OSX \r 10.6 \r (Snow \r Leopard) \r the \r correct \r
++configure \r line \r using \r GNU \r compilers \r is: \r \r
++ \r
++ \r ./configure \r CXX=g++ \r FC=gfortran \r FCFLAGS=-‐m64 \r
++ \r
++To \r build \r the \r library, \r simply \r type \r \r
++ \r
++make \r \r
++ \r
++and \r the \r automatically \r generated \r makefiles \r will \r build \r the \r library \r including \r archive \r files. \r \r
++ \r
++To \r allow \r for \r easy \r linking \r to \r the \r library, \r the \r user \r may \r also \r wish \r to \r install \r the \r archive \r files \r to \r a \r
++standard \r place. \r To \r do \r this \r type: \r
++ \r
++make \r install \r
++ \r
++This \r will \r also \r build \r the \r library \r if \r it \r has \r not \r already \r been \r built. \r Many \r systems, \r including \r Mac \r
++and \r Ubuntu \r Linux \r systems, \r require \r administrator \r privileges \r to \r install \r the \r library \r at \r such \r
++standard \r places. \r On \r such \r systems, \r one \r may \r type: \r \r
++ \r
++sudo \r make \r install \r \r
++ \r
++instead \r if \r one \r has \r sufficient \r access. \r \r
++ \r
++The \r directory \r ‘tests’ \r contains \r programs \r for \r high \r precision \r quadrature \r and \r integer-‐relation \r
++detection. \r To \r build \r such \r programs, \r type: \r
++ \r
++ \r
++make \r demo \r
++ \r
++in \r the \r \r ‘tests’ \r directory. \r \r
++ \r
++B. \r Linking \r \r
++ \r
++The \r simplest \r way \r to \r link \r to \r the \r library \r is \r to \r install \r it \r to \r a \r standard \r place \r as \r described \r above, \r
++and \r use \r the \r –l \r option. \r For \r example \r
++ \r
++g++ \r compileExample.cpp \r -‐o \r compileExample \r -‐l \r qd \r
++ \r
++One \r can \r also \r use \r this \r method \r to \r build \r with \r make. \r A \r file \r called \r “compileExample.cpp” \r and \r the \r
++associated \r makefile \r “makeCompileExample” \r illustrate \r the \r process. \r \r
++ \r
++A \r third \r alternative \r is \r to \r use \r a \r link \r script. \r If \r one \r types \r “make \r demo” \r in \r the \r test \r directory, \r the \r
++output \r produced \r gives \r guidance \r as \r to \r how \r to \r build \r the \r files. \r By \r following \r the \r structure \r of \r
++the \r compiling \r commands \r one \r may \r copy \r the \r appropriate \r portions, \r perhaps \r replacing \r the \r
++
++\ffilename \r with \r an \r argument \r that \r the \r user \r can \r include \r at \r link \r time. \r An \r example \r of \r such \r a \r
++script \r is \r as \r follows: \r
++ \r
++g++ \r -‐DHAVE_CONFIG_H \r \r \r -‐I.. \r -‐I../include \r -‐I../include \r \r \r -‐O2 \r \r -‐MT \r $1.o \r -‐MD \r -‐MP \r -‐MF \r
++.deps/qd_test.Tpo \r -‐c \r -‐o \r $1.o \r $1.cpp \r
++mv \r -‐f \r .deps/$1.Tpo \r .deps/$1.Po \r
++g++ \r \r -‐O2 \r \r \r \r -‐o \r $1 \r $1.o \r ../src/libqd.a \r –lm \r
++ \r
++To \r use \r it, \r make \r the \r link \r script \r executable \r and \r type: \r
++ \r
++./link.scr \r compileExample \r
++ \r
++Note \r that \r the \r file \r extension \r is \r not \r included \r because \r the \r script \r handles \r all \r extensions, \r
++expecting \r the \r source \r file \r to \r have \r the \r extension \r ‘.cpp’ \r . \r \r
++ \r
++C. \r Programming \r techniques \r
++ \r
++As \r much \r as \r possible, \r operator \r overloading \r is \r included \r to \r make \r basic \r programming \r as \r much \r
++like \r using \r standard \r typed \r floating-‐point \r arithmetic. \r Changing \r many \r codes \r should \r be \r as \r
++simple \r as \r changing \r type \r statements \r and \r a \r few \r other \r lines. \r \r
++ \r
++i. \r Constructors \r
++ \r
++To \r create \r dd_real \r and \r qd_real \r variables \r calculated \r to \r the \r proper \r precision, \r one \r must \r use \r
++care \r to \r use \r the \r included \r constructors \r properly. \r Many \r computations \r in \r which \r variables \r are \r
++not \r explicitly \r typed \r to \r multiple-‐precision \r may \r be \r evaluated \r with \r double-‐precision \r
++arithmetic. \r The \r user \r must \r take \r care \r to \r ensure \r that \r this \r does \r not \r cause \r errors. \r In \r particular, \r
++an \r expression \r such \r as \r 1.0/3.0 \r will \r be \r evaluated \r to \r double \r precision \r before \r assignment \r or \r
++further \r arithmetic. \r Upon \r assignment \r to \r a \r multi-‐precision \r variable, \r the \r value \r will \r be \r zero \r
++padded. \r This \r problem \r is \r serious \r and \r potentially \r difficult \r to \r debug. \r To \r avoid \r this, \r use \r the \r
++included \r constructors \r to \r force \r arithmetic \r to \r be \r performed \r in \r the \r full \r precision \r requested. \r
++Here \r is \r a \r list \r of \r the \r included \r constructors \r with \r brief \r descriptions: \r
++ \r
++Type \r dd_real, \r with \r text \r of \r inline \r constructors \r included: \r \r
++ \r
++Constructor \r
++Description \r \r
++ \r
++ \r
++dd_real(double \r hi, \r double \r lo) \r \r
++Initializes \r from \r two \r double \r precision \r values. \r \r
++{ \r x[0] \r = \r hi; \r x[1] \r = \r lo; \r } \r
++ \r
++ \r
++ \r
++dd_real() \r {x[0] \r = \r 0.0; \r x[1] \r = \r 0.0; \r } \r
++Default \r constructor \r initializes \r to \r zero. \r \r
++ \r
++ \r
++dd_real(double \r h) \r { \r x[0] \r = \r h; \r x[1] \r = \r 0.0; \r } \r
++Initializes \r from \r a \r double \r precision \r value, \r
++ \r
++setting \r the \r trailing \r part \r to \r zero. \r Use \r care \r to \r
++ \r
++ensure \r that \r the \r trailing \r part \r should \r actually \r
++ \r
++be \r set \r to \r zero. \r \r
++ \r
++ \r
++ \r
++ \r
++ \r
++ \r
++dd_real(int \r h) \r { \r
++Initializes \r from \r an \r integer \r value, \r setting \r the \r
++
++\f \r \r \r \r x[0] \r = \r (static_cast<double>(h)); \r
++trailing \r part \r to \r zero. \r Use \r care \r to \r ensure \r that \r
++ \r \r \r \r x[1] \r = \r 0.0; \r
++the \r trailing \r part \r should \r actually \r be \r set \r to \r
++ \r \r } \r
++zero. \r \r
++ \r
++ \r
++dd_real \r (const \r char \r *s); \r
++Initializes \r from \r a \r string. \r \r
++ \r
++ \r
++explicit \r dd_real \r (const \r double \r *d) \r { \r
++Initializes \r from \r a \r length \r two \r array \r of \r double \r
++ \r \r \r \r x[0] \r = \r d[0]; \r x[1] \r = \r d[1]; \r
++precision \r values. \r \r
++ \r \r } \r \r
++ \r
++ \r
++ \r
++ \r
++ \r
++Type \r qd_real, \r with \r their \r functions \r included \r inline: \r \r
++ \r
++Constructor \r \r
++Description \r \r
++ \r
++ \r
++inline \r qd_real::qd_real \r
++Initializes \r from \r four \r double \r precision \r values. \r \r
++(double \r x0, \r double \r x1, \r double \r x2, \r double \r x3) \r \r
++{ \r
++ \r
++ \r \r \r
++ \r x[0] \r = \r x0; \r
++ \r
++ \r \r \r
++ \r x[1] \r = \r x1; \r
++ \r
++ \r \r \r
++ \r x[2] \r = \r x2; \r
++ \r
++ \r \r \r
++ \r x[3] \r = \r x3; \r
++ \r
++} \r
++ \r
++ \r
++ \r
++inline \r qd_real::qd_real(const \r double \r *xx) \r { \r
++Initializes \r from \r a \r length \r four \r array \r of \r double \r
++ \r \r \r
++ \r x[0] \r = \r xx[0]; \r
++precision \r values. \r \r
++ \r \r \r
++ \r x[1] \r = \r xx[1]; \r
++ \r
++ \r \r
++ \r x[2] \r = \r xx[2]; \r
++ \r
++ \r \r \r
++ \r x[3] \r = \r xx[3]; \r
++ \r
++ \r
++} \r
++ \r
++ \r
++ \r
++inline \r qd_real::qd_real(double \r x0) \r { \r
++Initializes \r from \r a \r double \r precision \r value, \r
++ \r \r \r
++ \r x[0] \r = \r x0; \r
++setting \r the \r trailing \r part \r to \r zero. \r Use \r care \r to \r
++ \r \r \r
++ \r x[1] \r = \r x[2] \r = \r x[3] \r = \r 0.0; \r
++ensure \r that \r the \r trailing \r part \r should \r actually \r
++} \r
++be \r set \r to \r zero. \r \r
++ \r
++ \r
++inline \r qd_real::qd_real() \r { \r
++Default \r constructor \r initializes \r to \r zero. \r \r
++ \r
++ \r x[0] \r = \r 0.0; \r \r
++ \r
++ \r
++ \r x[1] \r = \r 0.0; \r \r
++ \r
++ \r
++ \r x[2] \r = \r 0.0; \r \r
++ \r
++ \r
++ \r x[3] \r = \r 0.0; \r \r
++ \r
++} \r
++ \r
++ \r
++ \r
++inline \r qd_real::qd_real(const \r dd_real \r &a) \r { \r
++Initializes \r from \r a \r double-‐double \r value, \r
++ \r \r \r
++ \r x[0] \r = \r a._hi(); \r
++setting \r the \r trailing \r part \r to \r zero. \r
++ \r \r \r
++ \r x[1] \r = \r a._lo(); \r
++ \r
++ \r \r \r
++ \r x[2] \r = \r x[3] \r = \r 0.0; \r
++ \r
++} \r
++ \r
++inline \r qd_real::qd_real(int \r i) \r { \r
++Initializes \r from \r an \r integer \r value, \r setting \r the \r
++
++\f \r \r \r
++ \r x[0] \r = \r static_cast<double>(i); \r
++trailing \r part \r to \r zero. \r Use \r care \r to \r ensure \r that \r
++ \r \r \r
++ \r x[1] \r = \r x[2] \r = \r x[3] \r = \r 0.0; \r
++the \r trailing \r part \r should \r actually \r be \r set \r to \r
++} \r
++zero. \r \r
++ \r
++ \r
++ \r
++ \r
++Some \r examples \r of \r initialization \r are \r as \r follows \r
++ \r
++ \r
++qd_real \r x \r = \r “1.0” \r ; \r \r
++ \r
++x \r /= \r 3.0 \r ; \r \r
++ \r
++or \r \r
++ \r
++ \r
++qd_real \r x \r = \r qd_real(1.0) \r / \r 3.0 \r ; \r \r
++ \r
++ \r
++ii. \r Included \r functions \r and \r Constants \r \r
++ \r
++Supported \r functions \r include \r assignment \r operators, \r comparisons, \r arithmetic \r and \r
++assignment \r operators, \r and \r increments \r for \r integer \r types. \r Standard \r C \r math \r functions \r such \r as \r
++exponentiation, \r trigonometric, \r logarithmic, \r hyperbolic, \r exponential \r and \r rounding \r functions \r
++are \r included. \r As \r in \r assignment \r statements, \r one \r must \r be \r careful \r with \r implied \r typing \r of \r
++constants \r when \r using \r these \r functions. \r Many \r codes \r need \r particular \r conversion \r for \r the \r power \r
++function, \r which \r is \r frequently \r used \r with \r constants \r that \r must \r be \r explicitly \r typed \r for \r multi-‐
++precision \r codes. \r \r
++ \r
++Many \r constants \r are \r included, \r which \r are \r global \r and \r calculated \r upon \r initialization. \r The \r
++following \r list \r of \r constants \r is \r calculated \r for \r both \r the \r dd_real \r and \r qd_real \r classes \r separately. \r
++Use \r care \r to \r select \r the \r correct \r value. \r The \r variables, \r with \r type \r signatures, \r are: \r
++ \r
++Variable \r Name \r
++Explanation \r \r
++static \r const \r qd_real \r _2pi; \r
++Two \r pi. \r \r
++static \r const \r qd_real \r _pi; \r
++Pi. \r \r
++static \r const \r qd_real \r _3pi4; \r
++Three \r pi \r over \r four. \r \r
++static \r const \r qd_real \r _pi2; \r
++Pi \r over \r two. \r \r
++static \r const \r qd_real \r _pi4; \r
++Pi \r over \r four \r
++static \r const \r qd_real \r _e; \r
++e, \r the \r base \r of \r the \r natural \r logarithm. \r \r
++static \r const \r qd_real \r _log2; \r
++Natural \r logarithm \r of \r two. \r \r
++static \r const \r qd_real \r _log10; \r
++Natural \r logarithm \r of \r ten. \r \r
++static \r const \r qd_real \r _nan; \r
++Not \r a \r number. \r Behaves \r like \r a \r double-‐
++ \r
++precision \r nan. \r \r
++static \r const \r qd_real \r _inf; \r
++Infinity. \r Behaves \r like \r a \r double-‐precision \r inf. \r \r
++static \r const \r double \r _eps; \r
++Estimated \r precision \r for \r dd_real \r or \r qd_real \r
++ \r
++data \r type. \r
++static \r const \r double \r _min_normalized; \r
++Minimum \r absolute \r value \r represent \r able \r
++ \r
++without \r denormalization. \r \r
++static \r const \r qd_real \r _max; \r
++Maximum \r representable \r value. \r \r
++static \r const \r qd_real \r _safe_max; \r
++Maximum \r safe \r value. \r Slightly \r smaller \r than \r
++ \r
++maximum \r representable \r value. \r \r
++static \r const \r int \r _ndigits; \r
++Number \r of \r digits \r available \r for \r dd_real \r or \r
++
++\f \r
++qd_real \r datatypes. \r
++ \r
++ \r
++ \r
++ii. \r Conversion \r of \r types \r \r
++ \r
++Static \r casts \r may \r be \r used \r to \r convert \r constants \r between \r types. \r One \r may \r also \r use \r constructors \r
++to \r return \r temporary \r multi-‐precision \r types \r within \r expressions, \r but \r should \r be \r careful, \r as \r this \r
++will \r waste \r memory \r if \r done \r repeatedly. \r For \r example: \r \r
++ \r
++ \r
++ \r qd_real \r y \r ; \r \r
++y \r = \r sin( \r qd_real(4.0) \r / \r 3.0 \r ) \r ; \r
++ \r
++C–style \r casts \r may \r be \r used, \r but \r are \r not \r recommended. \r \r Dynamic \r and \r reinterpret \r casts \r are \r
++not \r supported \r and \r should \r be \r considered \r unreliable. \r Casting \r between \r multi-‐precision \r and \r
++standard \r precision \r types \r can \r be \r dangerous, \r and \r care \r must \r be \r taken \r to \r ensure \r that \r programs \r
++are \r working \r properly \r and \r accuracy \r has \r not \r degraded \r by \r use \r of \r a \r misplaced \r type-‐conversion. \r \r
++ \r
++D. \r Available \r precision, \r Control \r of \r Precision \r Levels, \r
++ \r
++The \r library \r provides \r greatly \r extended \r accuracy \r when \r compared \r to \r standard \r double \r
++precision. \r The \r type \r dd_real \r provides \r for \r 106 \r mantissa \r bits, \r or \r about \r 32 \r decimal \r digits. \r The \r
++type \r qd_real \r provides \r for \r 212 \r mantissa \r bits, \r or \r about \r 64 \r decimal \r digits. \r \r
++ \r
++Both \r the \r dd_real \r and \r qd_real \r values \r use \r the \r exponent \r from \r the \r highest \r double-‐precision \r
++word \r for \r arithmetic, \r and \r as \r such \r do \r not \r extend \r the \r total \r range \r of \r values \r available. \r That \r
++means \r that \r the \r maximum \r absolute \r value \r for \r either \r data \r type \r is \r the \r same \r as \r that \r of \r double-‐
++precision, \r or \r approximately \r 10^308. \r The \r precision \r near \r this \r range, \r however, \r is \r greatly \r
++increased. \r \r
++ \r
++To \r ensure \r that \r arithmetic \r is \r carried \r out \r with \r proper \r precision \r and \r accuracy, \r one \r must \r call \r
++the \r function \r “fpu_fix_start” \r before \r performing \r any \r double-‐double \r or \r quad-‐double \r
++arithmetic. \r This \r forces \r all \r arithmetic \r to \r be \r carried \r out \r in \r 64-‐bit \r double \r precision, \r not \r the \r 80-‐
++bit \r precision \r that \r is \r found \r on \r certain \r compilers \r and \r interferes \r with \r the \r existing \r library. \r \r
++ \r
++ \r
++ \r unsigned \r int \r old_cw; \r
++ \r
++fpu_fix_start(&old_cw); \r
++ \r
++To \r return \r standard \r settings \r for \r arithmetic \r on \r one’s \r system, \r call \r the \r function \r “fpu_fix_end”. \r
++For \r example: \r
++ \r
++ \r
++fpu_fix_end(&old_cw); \r
++ \r
++ \r
++E. \r I/O \r \r
++ \r
++The \r standard \r I/O \r stream \r routines \r have \r been \r overloaded \r to \r be \r fully \r compatible \r with \r all \r
++included \r data \r types. \r One \r may \r need \r to \r manually \r reset \r the \r precision \r of \r the \r stream \r to \r obtain \r
++full \r output. \r For \r example, \r if \r 60 \r digits \r are \r desired, \r use: \r \r
++ \r
++cout.precision(60) \r ; \r \r
++
++\f \r
++When \r reading \r values \r using \r cin, \r each \r input \r numerical \r value \r must \r start \r on \r a \r separate \r
++line. \r \r Two \r formats \r are \r acceptable: \r
++ \r
++ \r
++1. \r Write \r the \r full \r constant \r \r
++ \r
++3. \r Mantissa \r e \r exponent \r
++ \r
++Here \r are \r three \r valid \r examples: \r
++ \r
++ \r
++1.1 \r
++ \r
++3.14159 \r 26535 \r 89793 \r
++ \r
++123.123123e50 \r
++ \r
++ \r
++When \r read \r using \r cin, \r these \r constants \r will \r be \r converted \r using \r full \r multi-‐precision \r accuracy. \r
++ \r
++ \r
++IV. \r Fortran-‐90 \r Usage \r
++ \r
++NEW \r (2007-‐01-‐10): \r The \r Fortran \r translation \r modules \r now \r support \r the \r complex \r datatypes \r
++"dd_complex" \r and \r "qd_complex". \r
++ \r
++Since \r the \r quad-‐double \r library \r is \r written \r in \r C++, \r it \r must \r be \r linked \r in \r with \r a \r C++ \r compiler \r (so \r
++that \r C++ \r specific \r things \r such \r as \r static \r initializations \r are \r correctly \r handled). \r \r Thus \r the \r main \r
++program \r must \r be \r written \r in \r C/C++ \r and \r call \r the \r Fortran \r 90 \r subroutine. \r The \r Fortran \r 90 \r
++subroutine \r should \r be \r called \r f_main. \r
++ \r
++Here \r is \r a \r sample \r Fortran-‐90 \r program, \r equivalent \r to \r the \r above \r C++ \r program: \r
++ \r
++ \r \r subroutine \r f_main \r
++ \r
++use \r qdmodule \r \r
++ \r
++implicit \r none \r
++ \r
++type \r (qd_real) \r a, \r b \r
++ \r
++integer*4 \r old_cw \r
++ \r
++ \r
++call \r f_fpu_fix_start(old_cw) \r
++ \r
++a \r = \r 1.d0 \r
++ \r
++b \r = \r cos(a)**2 \r + \r sin(a)**2 \r -‐ \r 1.d0 \r
++ \r
++call \r qdwrite(6, \r b) \r
++ \r
++stop \r
++ \r \r end \r subroutine \r
++ \r
++This \r verifies \r that \r cos^2(1) \r + \r sin^2(1) \r = \r 1 \r to \r 64 \r digit \r accuracy. \r
++ \r
++Most \r operators \r and \r generic \r function \r references, \r including \r many \r mixed-‐mode \r type \r
++combinations \r with \r double-‐precision \r (ie \r real*8), \r have \r been \r overloaded \r (extended) \r to \r work \r
++with \r double-‐double \r and \r quad-‐double \r data. \r \r It \r is \r important, \r however, \r that \r users \r keep \r in \r
++mind \r the \r fact \r that \r expressions \r are \r evaluated \r strictly \r according \r to \r conventional \r Fortran \r
++operator \r precedence \r rules. \r \r Thus \r some \r subexpressions \r may \r be \r evaluated \r only \r to \r 15-‐digit \r
++accuracy. \r For \r example, \r with \r the \r code \r
++
++\f \r
++ \r \r \r real*8 \r d1 \r
++ \r \r \r type \r (dd_real) \r t1, \r t2 \r
++ \r \r \r ... \r
++ \r \r \r t1 \r = \r cos \r (t2) \r + \r d1/3.d0 \r
++ \r
++the \r expression \r d1/3.d0 \r is \r computed \r to \r real*8 \r accuracy \r only \r (about \r 15 \r digits), \r since \r both \r d1 \r
++and \r 3.d0 \r have \r type \r real*8. \r \r This \r result \r is \r then \r converted \r to \r dd_real \r by \r zero \r extension \r before \r
++being \r added \r to \r cos(t2). \r So, \r for \r example, \r if \r d1 \r held \r the \r value \r 1.d0, \r then \r the \r quotient \r d1/3.d0 \r
++would \r only \r be \r accurate \r to \r 15 \r digits. \r \r If \r a \r fully \r accurate \r double-‐double \r quotient \r is \r required, \r
++this \r should \r be \r written: \r
++ \r
++ \r \r real*8 \r d1 \r
++ \r \r type \r (dd_real) \r t1, \r t2 \r
++ \r \r \r ... \r
++ \r \r t1 \r = \r cos \r (t2) \r + \r ddreal \r (d1) \r / \r 3.d0 \r
++ \r
++which \r forces \r all \r operations \r to \r be \r performed \r with \r double-‐double \r arithmetic. \r
++ \r
++Along \r this \r line, \r a \r constant \r such \r as \r 1.1 \r appearing \r in \r an \r expression \r is \r evaluated \r only \r to \r real*4 \r
++accuracy, \r and \r a \r constant \r such \r as \r 1.1d0 \r is \r evaluated \r only \r to \r real*8 \r accuracy \r (this \r is \r
++according \r to \r standard \r Fortran \r conventions). \r \r If \r full \r quad-‐double \r accuracy \r is \r required, \r for \r
++instance, \r one \r should \r write \r
++ \r
++ \r \r \r type \r (qd_real) \r t1 \r
++ \r \r \r ... \r
++ \r \r \r t1 \r = \r '1.1' \r
++ \r
++The \r quotes \r enclosing \r 1.1 \r specify \r to \r the \r compiler \r that \r the \r constant \r is \r to \r be \r converted \r to \r
++binary \r using \r quad-‐double \r arithmetic, \r before \r assignment \r to \r t1. \r \r Quoted \r constants \r may \r only \r
++appear \r in \r assignment \r statements \r such \r as \r this. \r
++ \r
++To \r link \r a \r Fortran-‐90 \r program \r with \r the \r C++ \r qd \r library, \r it \r is \r \r recommended \r to \r link \r with \r the \r
++C++ \r compiler \r used \r to \r generate \r the \r library. \r \r \r The \r Fortran \r 90 \r interface \r (along \r with \r a \r C-‐style \r
++main \r function \r calling \r f_main) \r is \r found \r in \r qdmod \r library. \r \r The \r qd-‐config \r script \r installed \r
++during \r "make \r install" \r can \r be \r used \r to \r determine \r which \r flags \r to \r pass \r to \r compile \r and \r link \r your \r
++programs: \r
++ \r
++ \r \r "qd-‐config \r -‐-‐fcflags" \r \r displays \r compiler \r flags \r needed \r to \r compile \r your \r Fortran \r files. \r
++ \r \r "qd-‐config \r -‐-‐fclibs" \r \r \r displays \r linker \r flags \r needed \r by \r the \r C++ \r linker \r to \r link \r in \r all \r the \r \r
++necessary \r libraries. \r
++ \r
++A \r sample \r Makefile \r that \r can \r be \r used \r as \r a \r template \r for \r compiling \r Fortran \r programs \r using \r
++quad-‐double \r library \r is \r found \r in \r fortran/Makefile.sample. \r
++ \r
++F90 \r functions \r defined \r with \r dd_real \r arguments: \r
++ \r \r Arithmetic: \r \r + \r -‐ \r * \r / \r ** \r
++ \r \r Comparison \r tests: \r \r == \r < \r > \r <= \r >= \r /= \r
++ \r \r Others: \r abs, \r acos, \r aint, \r anint, \r asin, \r atan, \r atan2, \r cos, \r cosh, \r dble, \r erf, \r
++ \r \r erfc, \r exp, \r int, \r log, \r log10, \r max, \r min, \r mod, \r ddcsshf \r (cosh \r and \r sinh), \r
++
++\f \r \r ddcssnf \r (cos \r and \r sin), \r ddranf \r (random \r number \r generator \r in \r (0,1)), \r \r
++ \r \r ddnrtf \r (n-‐th \r root), \r sign, \r sin, \r sinh, \r sqr, \r sqrt, \r tan, \r tanh \r
++Similar \r functions \r are \r provided \r for \r qd_real \r arguments \r (with \r function \r
++ \r \r names \r qdcsshf, \r qdcssnf, \r qdranf \r and \r qdnrtf \r instead \r of \r the \r names \r in \r
++ \r \r the \r list \r above). \r
++ \r
++Input \r and \r output \r of \r double-‐double \r and \r quad-‐double \r data \r is \r done \r using \r the \r special \r
++subroutines \r ddread, \r ddwrite, \r qdread \r and \r qdwrite. \r \r The \r first \r argument \r of \r these \r subroutines \r
++is \r the \r Fortran \r I/O \r unit \r number, \r while \r additional \r arguments \r (as \r many \r as \r needed, \r up \r to \r 9 \r
++arguments) \r are \r scalar \r variables \r or \r array \r elements \r of \r the \r appropriate \r type. \r \r Example: \r
++ \r
++ \r \r \r integer \r n \r
++ \r \r \r type \r (qd_real) \r qda, \r qdb, \r qdc(n) \r
++ \r \r \r ... \r
++ \r \r \r call \r qdwrite \r (6, \r qda, \r qdb) \r
++ \r \r \r do \r j \r = \r 1, \r n \r
++ \r
++ \r call \r qdwrite \r (6, \r qdc(j)) \r
++ \r \r \r enddo \r
++ \r
++Each \r input \r values \r must \r be \r on \r a \r separate \r line, \r and \r may \r include \r D \r or \r E \r exponents. \r \r Double-‐
++double \r and \r quad-‐double \r constants \r may \r also \r be \r specified \r in \r assignment \r statements \r by \r
++enclosing \r them \r in \r quotes, \r as \r in \r
++ \r
++ \r \r ... \r
++ \r \r type \r (qd_real) \r pi \r
++ \r \r ... \r
++ \r \r pi \r = \r
++"3.14159265358979323846264338327950288419716939937510582097494459230" \r
++ \r \r ... \r
++ \r
++Sample \r Fortran-‐90 \r programs \r illustrating \r some \r of \r these \r features \r are \r provided \r in \r the \r f90 \r
++subdirectory. \r
++ \r
++ \r
++V. \r Note \r on \r x86-‐Based \r Processors \r (MOST \r systems \r in \r use \r today) \r
++ \r
++The \r algorithms \r in \r this \r library \r assume \r IEEE \r double \r precision \r floating \r point \r arithmetic. \r \r Since \r
++Intel \r x86 \r processors \r have \r extended \r (80-‐bit) \r floating \r point \r registers, \r the \r round-‐to-‐double \r
++flag \r must \r be \r enabled \r in \r the \r control \r word \r of \r the \r FPU \r for \r this \r library \r to \r function \r properly \r
++under \r x86 \r processors. \r \r The \r following \r functions \r contains \r appropriate \r code \r to \r facilitate \r
++manipulation \r of \r this \r flag. \r \r For \r non-‐x86 \r systems \r these \r functions \r do \r nothing \r (but \r still \r exist). \r
++ \r
++fpu_fix_start \r This \r turns \r on \r the \r round-‐to-‐double \r bit \r in \r the \r control \r word. \r
++fpu_fix_end \r
++ \r \r This \r restores \r the \r control \r flag. \r
++ \r
++These \r functions \r must \r be \r called \r by \r the \r main \r program, \r as \r follows: \r
++ \r
++ \r
++int \r main() \r { \r
++ \r
++ \r \r unsigned \r int \r old_cw; \r
++ \r
++ \r \r fpu_fix_start(&old_cw); \r
++
++\f \r
++ \r
++ \r \r ... \r user \r code \r using \r quad-‐double \r library \r ... \r
++ \r
++ \r
++ \r \r fpu_fix_end(&old_cw); \r
++ \r
++} \r
++ \r
++A \r Fortran-‐90 \r example \r is \r the \r following: \r
++ \r
++ \r
++subroutine \r f_main \r
++ \r
++use \r qdmodule \r
++ \r
++implicit \r none \r
++ \r
++integer*4 \r old_cw \r
++ \r
++ \r
++call \r f_fpu_fix_start(old_cw) \r
++ \r
++ \r
++ \r \r ... \r user \r code \r using \r quad-‐double \r library \r ... \r
++ \r
++ \r
++call \r f_fpu_fix_end(old_cw) \r
++ \r
++end \r subroutine \r
++ \r
++
++\f
+\ No newline at end of file
+diff -Nur qd-2.3.12.orig/src/Makefile.am qd-2.3.12/src/Makefile.am
+--- qd-2.3.12.orig/src/Makefile.am 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/src/Makefile.am 2012-01-12 19:49:45.000000000 +0000
+@@ -1,9 +1,9 @@
+ SRC = c_dd.cpp c_qd.cpp dd_real.cpp dd_const.cpp \
+ fpu.cpp qd_real.cpp qd_const.cpp util.cpp bits.cpp util.h
+
+-lib_LIBRARIES = libqd.a
++lib_LTLIBRARIES = libqd.la
+
+-libqd_a_SOURCES = $(SRC)
++libqd_la_SOURCES = $(SRC)
+
+ AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include
+
+diff -Nur qd-2.3.12.orig/tests/Makefile.am qd-2.3.12/tests/Makefile.am
+--- qd-2.3.12.orig/tests/Makefile.am 2012-01-12 19:44:25.000000000 +0000
++++ qd-2.3.12/tests/Makefile.am 2012-01-12 20:06:49.000000000 +0000
+@@ -1,4 +1,4 @@
+-LDADD = $(top_builddir)/src/libqd.a
++LDADD = $(top_builddir)/src/libqd.la
+ AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/include -I$(top_srcdir)/include
+
+ TESTS = qd_test pslq_test c_test
+@@ -15,9 +15,9 @@
+
+ f_test_SOURCES = f_test.f
+ f_test_LINK=$(CXXLINK)
+-f_test_LDADD = $(top_builddir)/fortran/libqdmod.a \
+- $(top_builddir)/fortran/libqd_f_main.a \
+- $(LDADD) $(top_builddir)/src/libqd.a $(FCLIBS)
++f_test_LDADD = $(top_builddir)/fortran/libqdmod.la \
++ $(top_builddir)/fortran/libqd_f_main.la \
++ $(LDADD) $(top_builddir)/src/libqd.la $(FCLIBS)
+ endif
+
+ CLEANFILES=qd_timer quadt_test huge