From: SMTP%"uemura@fnalp.fnal.gov" 9-NOV-1993 20:45:02.50 To: EVERHART CC: Subj: RE: Big integer arithmetic X-Newsgroups: comp.os.vms Subject: RE: Big integer arithmetic Message-ID: <8NOV93164811@fnalp.fnal.gov> From: uemura@fnalp.fnal.gov (N10118_UEMURA, NOBUYUKI) Date: Mon, 8 Nov 1993 22:48:11 GMT Reply-To: uemura@fnalp.fnal.gov Sender: daemon@linac.fnal.gov (The Background Man) Distribution: world Organization: Fermi National Accelerator Laboratory News-Software: VAX/VMS VNEWS 1.4-a4 Nntp-Posting-Host: fnalp.fnal.gov Lines: 184 To: Info-VAX@CRVAX.SRI.COM X-Gateway-Source-Info: USENET Check out a multi-precision computation package called MPFUN which was written by David H. Bailey at NASA Ames Research Center. The package includes not only a multi-precision FORTRAN library but also a translation program called TRANSMP which translates your F77 program into a program with the appropriate multiprecision subroutine calls. You can get the package by ftp: scss3.cl.msu.edu: /pub/bignum/mpfun_fortran_June93.tar.Z /pub/bignum/mpfun_tex_papers_May93.tar.Z research.att.com: /netlib/toms/719.Z or from the author dbailey@nas.nasa.gov. (I recommend you to contact with the author.) You need some modifications for TRANSMP.FOR to compile with DEC Fortran. 1) The program assumes CarriageControl='LIST'. So you need to place the following line at the beginning of the program. OPEN(6,FILE='SYS$OUTPUT',STATUS='UNKNOWN',CARRIAGECONTROL='LIST') 2) The program quotes ' character as "'". This should be changed to ''''. Also you need to compile TRANSMP.FOR with /RECURSIVE qualifier. The following simple F77 program: CMP+ PRECISION LEVEL 300 CMP+ OUTPUT PRECISION 290 PROGRAM TMP CMP+ IMPLICIT MULTIP REAL (A-H,O-Z) CMP+ IMPLICIT MULTIP INTEGER (I-N) OPEN (6,FILE='SYS$OUTPUT',STATUS='UNKNOWN',CARRIAGECONTROL='LIST') PI = ATAN(1.) * 4. WRITE(6,*) PI I = 123456789 WRITE(6,*) I**10 END is translated by TRANSMP into: CMP+ PRECISION LEVEL 300 CMP+ OUTPUT PRECISION 290 PROGRAM TMP CMP+ IMPLICIT MULTIP REAL (A-H,O-Z) CMP+ IMPLICIT MULTIP INTEGER (I-N) REAL PI(46) CHARACTER*20 MPA2 CHARACTER*1 MPA1(403) INTEGER MPI1 REAL MPM1(46) REAL MPM2(46) REAL MPM3(46) REAL I(46) REAL MPJ1(46) INTEGER MPNWQ, MPNW4 REAL MPL02, MPL10, MPPIC COMMON /MPTCON/ MPNWQ, MPNW4, MPL02(46), MPL10(46), MPPIC(46) C CALL MPSETP ('NW', 42) MPNWQ = 42 MPNW4 = 46 CALL MPDMC (2.D0, 0, MPM1) CALL MPLOG (MPM1, MPL02, MPL02) CALL MPDMC (10.D0, 0, MPM1) CALL MPLOG (MPM1, MPL02, MPL10) CALL MPPI (MPPIC) CMP< OPEN (6,FILE='SYS$OUTPUT',STATUS='UNKNOWN',CARRIAGECONTROL='LIST') CMP> PI = ATAN(1.) * 4. MPA2 = '10^0 x 1.' READ (MPA2, '( 9A1)' ) (MPA1(MPI1), MPI1 = 1, 9) CALL MPINPC (MPA1, 9, MPM1) CALL MPDMC (1.D0, 0, MPM3) CALL MPANG (MPM3, MPM1, MPPIC, MPM2) MPA2 = '10^0 x 4.' READ (MPA2, '( 9A1)' ) (MPA1(MPI1), MPI1 = 1, 9) CALL MPINPC (MPA1, 9, MPM1) CALL MPMUL (MPM2, MPM1, MPM3) CALL MPEQ (MPM3, PI) CMP< CMP> WRITE(6,*) PI CALL MPOUT (6, PI, 290, MPA1) CMP< CMP> I = 123456789 MPA2 = '10^0 x 123456789' READ (MPA2, '( 16A1)' ) (MPA1(MPI1), MPI1 = 1, 16) CALL MPINPC (MPA1, 16, MPJ1) CALL MPEQ (MPJ1, I) CMP< CMP> WRITE(6,*) I**10 CALL MPNPWR (I, 10, MPJ1) CALL MPINFR (MPJ1, MPJ1, MPM1) CALL MPOUT (6, MPJ1, 290, MPA1) CMP< END and will give the following output. 10 ^ 0 x 3.1415926535897932384626433832795028841971693993751058209749 445923078164062862089986280348253421170679821480865132823066470938446095505822 317253594081284811174502841027019385211055596446229489549303819644288109756659 3344612847564823378678316527120190914564856692346034861045432664821339360726, 10 ^ 80 x 8.2252625914710257950476114366153554776413789229551416809370 1699676416207799736601, Below my signature, I will include a post from the author which I got a while ago. Nobuyuki Uemura ------------------------------------------------------------------------------ High Energy Physics Lab, Univ. of Tsukuba & Research Div./CDF, Fermilab ::::::::::::::::::: Mail Address DECnet: FNAL::UEMURA, UTKBP::UEMURA Nobuyuki Uemura Bitnet: UEMURA@FNAL, UEMURA@JPNKEKVX ::::::::::::::::::: Internet: uemura@fnal.fnal.gov uemura@kekvax.kek.jp Article: 4572 of sci.math.num-analysis From: dbailey@wk49.nas.nasa.gov (David H. Bailey) Newsgroups: sci.math.num-analysis Subject: Fortran multiple precision package and translator Date: 6 Nov 92 01:12:07 GMT Organization: NAS, NASA Ames Research Center, Moffett Field, CA Some of you may be aware of a multiprecision computation package and a multiprecision Fortran translator that I have developed during the past year or two. I am now pleased to announce that this software has been approved by NASA Ames for unlimited international distribution, at no cost. A brief description of this software is as follows: The first package contains approximately 85 Fortran subroutines that perform a variety of arithmetic operations and transcendental functions. The basic arithmetic routines are very efficient, and for extra high levels of precision (about about 1000 digits), some additional routines are available that employ advanced algorithms, such FFT-based multiplication and the Borwein transcendental algorithms, for additional speedup. On some problems these routines are over 200 times faster than certain other multiprecision tools. However, as with other such packages, manually converting a program to use these routines is a tedious and error-prone process. To facilitate such conversions, I have now developed a multiprecision translator for Fortran programs. By means of source directives (special comments) placed in a standard Fortran-77 program, the user declares the precision level and specifies which variables in each subprogram are to be treated as multiprecision. The translator program reads this source program and outputs a program with the appropriate multiprecision subroutine calls, which can then be linked with the multiprecision package and executed. This translator program supports multiprecision integer, real and complex datatypes. The required array space for multiprecision data types is automatically allocated. In the evaluation of computational expressions, all of the usual conventions for operator precedence and mixed mode operations are upheld. Furthermore, most of the Fortran-77 intrinsics, such as ABS, MOD, NINT, COS, EXP are supported and produce true multiprecision values. Both the multiprecision package and translator are written in highly portable Fortran-77 and have been successfully implemented on a variety of systems, ranging from parallel supercomputers to workstations. If anyone is interested in obtaining this software, plus the accompanying documentation, send me a note, and I will respond by e-mail. I eventually intend to place this software on public media such as netlib, but for the time being I am handling it myself, so that any bug fixes or enhancements can be promptly distributed. Since it is a small but significant amount of trouble for me to respond, please don't request unless you are somewhat serious about needing this software. David H. Bailey NASA Ames Research Center dbailey@nas.nasa.gov