Code covered by the BSD License  

Highlights from
Multiple Precision Toolbox for MATLAB

4.2

4.2 | 15 ratings Rate this file 68 Downloads (last 30 days) File Size: 917 KB File ID: #6446

Multiple Precision Toolbox for MATLAB

by

 

01 Dec 2004 (Updated )

This toolbox defines a new mp class allowing multiple precision objects in MATLAB.

| Watch this File

File Information
Description

The mp toolbox defines a new class, the mp class, which holds arbitrary precision quantities. Many common numerical functions are overloaded for this class and therefore work without modification to source code. Look at the @mp directory under the MATLAB directory for a list of mp supported functions. If the function is not specifically written for mp objects, it still may work if the function in question relies only on functions in the @mp directory. Precompiled and builtin function from TMW like eig, etc. will not work with mp objects unless specifically written using overloaded functions from the @mp directory.A simple script, mp_makeall.m looks through the current variables,and converts all doubles to mp objects.The mp toolbox is only implemented for base 10 quantities, and the rounding mode is fixed to be GMP_RNDN (unless you change it in all the /private/*.c files and recompile).The overloaded functions sum, min, and max only work for 1 or 2 dimensional mp objects right now.mp random numbers can be generated using rand() if rand at least 1 of the input arguments is an mp object. However, the seed given to gmp_randseed_ui is only in the range 0<seed<1000000, but this can be adjusted in @mp/rand.mA zeta function using m arithmetic is provided, whereas native MATLAB has no such function except for sym objects.

Acknowledgements

This file inspired Variable Precision Integer Arithmetic and Hpf A Big Decimal Class.

MATLAB release MATLAB 7 (R14)
Other requirements GMP (GNU Multiple Precision Arithmetic Library): http://www.swox.com/gmp/ and the MPFR (multiple-precision floating-point computations with exact rounding): http://www.mpfr.org/
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (36)
24 Oct 2013 Sascha D. Krauß  
28 Jun 2013 edu

When I run mp_compile_all.m I encounter with following message:
MATLABROOT =

D:\MATLAB\R2012a

C:\MinGW\bin\dlltool: Can't open def file: ../../extern/include/libmex.def

ans =

1

C:\MinGW\bin\dlltool: Can't open def file: ../../extern/include/libmat.def

ans =

1

C:\MinGW\bin\dlltool: Can't open def file: ../../extern/include/libmx.def

ans =

1

The syntax of the command is incorrect.

ans =

1

The syntax of the command is incorrect.

ans =

1

The syntax of the command is incorrect.

ans =

1

compiling: gmp_prototype.c

txt =

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ogmp_prototype.dll -ID:\MATLAB\R2012a\extern\include -I. -L. gmp_prototype.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ogmp_prototype.dll -ID:\MATLAB\R2012a\extern\include -I. -L. gmp_prototype.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm
compiling: mpfr_absc.c

txt =

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_absc.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_absc.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_absc.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_absc.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm
compiling: mpfr_add.c

txt =

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_add.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_add.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_add.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_add.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm
compiling: mpfr_atan2.c

txt =

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_atan2.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_atan2.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_atan2.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_atan2.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm
compiling: mpfr_ceil.c

txt =

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_ceil.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_ceil.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_ceil.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_ceil.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm
compiling: mpfr_const_log2.c

txt =

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_const_log2.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_const_log2.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm

!C:\MinGW\bin\gcc -g -O2 -shared -fexceptions -ompfr_const_log2.dll -ID:\MATLAB\R2012a\extern\include -I. -L. mpfr_const_log2.c gmp.dll mpfr.dll -lmat -lmex -lmx -lm
Operation terminated by user during mp_compile_all (line 54)
------------------
Then when I run the mp_TESTING.m I encounter eith the same problem of Sascha Krauß . Can anyone help me?

08 Jun 2013 Sascha D. Krauß

I'm sorry, I haven't used it for a year and can't remember the solution. (Or even the problem.) Maybe I can have another look, when I'm back in office on Monday, but I don't think, that it will help much...

07 Jun 2013 edu

Hi, I have downloaded this toolbox but I dont know how it works. I have set the path of extracted toolbox in my Matlab's search path but it doesnt work!
Actually I have the same problem of Haula Dias.

14 May 2013 Hasula Dias

Hi Sascha, can you please explain how you fixed that problem ? I'm getting the same error when I try to run the test program,i.e,

Undefined function or method 'mpfr_construct_dd' for input
arguments of type 'double'

I don't see a mfile with the same name ?!..

31 May 2012 Sascha D. Krauß

Problem solved.

(Why is there no edit or delete function?)

31 May 2012 Sascha D. Krauß

When I try the examples from the readme file, I get the following error. Why? (GMP and MPFR are installed. I use Ubuntu 11.10 and Matlab R2011b 64-bit.)

>> ymp=mp(2,1000)
Undefined function 'mpfr_construct_dd' for input arguments of type 'double'.

Error in mp (line 27)
[str,exponent]=mpfr_construct_dd(real(x(ii)),precision);

24 May 2012 Pavel Holoborodko

@Ahmed Fasih
Try Multiprecision Computing Toolbox from here: http://advanpix.com

It supports 32 and 64-bit versions of Windows and the latest Matlabs. Easily installed in a few seconds, no compilation required - everything are installed and tuned automatically for the best performance on your CPU.

@Charles
Mas OS X (64-bit) and Linux (32 & 64-bit) are also supported. No compilation is required.

Multiprecision Computing Toolbox from Advanpix supports much wider set of MATLAB functions missing in the submission, including eig, det, cond, fft/ifft, chol, fzero, null to name a few. Many advanced numerical methods are supported too - matrix functions, optimization, ODE, root finding, special functions, numerical integration, etc....

02 May 2012 Ahmed Fasih

Any updates on getting this easily going on Win64 with R2011 or R2012? The pre-compiled binaries are DLLs, I can't seem to load them with newer Matlabs, while the compilation seems to need .def files (libmex.def, libmat.def, etc.) which are unavailable in newer Matlabs.

22 Nov 2011 David Goldsmith

Also, is the cast of a struct into a class the only sense in which this thing is a class? That's kind of weak.

22 Nov 2011 David Goldsmith

"The mp toolbox is only implemented for base 10 quantities"

Does this mean that the IEEE 754-2008 32-bit base 2 format, which results in a variable number of ~7.225 digits precision in decimal, can't be represented precisely?

24 Nov 2010 Christo Fogelberg  
06 Aug 2010 Charles

Anyone have this working on the latest mac os x (10.6.4) and matlab r2010a? or have compiled win64 libraries?

05 Feb 2010 Paul Hur

This is awesome. It will greatly help me with calculation of my equations. However, I cannot find a function for gammainc. Is there anybody who has this function of window version and helps me?

12 Oct 2009 Dmitry Savransky

Absolutely fantastic. Exactly what I needed - many thanks. Quick note for anyone installing on RHEL5. The default rpms that may be pre-installed for GMP don't seem to work when it comes time to compile the c files. However, if you get rid of these and compile GMP and MPFR from source, everything works great.

30 Sep 2009 Nigel Delaney

I just reinstalled this package for a windows 7 64 bit computer (running 64 bit matlab). It was a bit of work so I thought I would share the process, or offer to email anyone the binaries/toolbox as I have it.
The first issue is that building mpfr/gmp for x64 is quite hard. Apparently, there is a new ming compiler out for 64 bit, but no one has had it work so far (and I didn't try it). The second option, SUA is also useless as there is no gcc compiler for x64 with it, and you would be forced to make a 32 bit version. So, in order to get the libraries I had to use MPIR (which can substitute for GMP) and then compile mpfr with this instead of gmp. To do this, you need to do the following:
Download MPFR ad MPIR :
http://www.mpfr.org/
http://www.mpir.org/
Now, both of these are hard to build, but someone has setup a way to build them with either visual studio or visual studio express that is reasonably painless. Go here to get the build instructions.
http://gladman.plushost.co.uk/oldsite/computing/gmp4win.php
Note that in order to get the visual studio build to work, you have to install a yasm assembler program and integerate it into visual studio (follow the 3 step instructions on their website).
http://www.tortall.net/projects/yasm/
One you are setup to go, first build mpir using visual studio. Note that there is a vcbuild directory included with the mpir program that you can use directly to make the files. This program can substitute for gmp in the next linking step, so use the gmp.h header file that comes with it next. With that done, you can now open the VS project from the gladman site and get ready to compile mpfr. Note that the project files he hands out do not include the actual code, so you will have to move the mpfr source files and reference mpir library files around to make sure they appear in their correct locations relative to the what is in the .sln file gladwell gives out. Once this is done, you are all set to build and things should compile just fine.
Next, compile the .mex files (which should be pretty straightforward now that the libraries are built). Now the package is up and running, however it did not work right away for me. It appears that for whatever reason if matlab saw this type of code:
length(x)==1
in the toolbox .m files, it would call the eq.m method of this toolbox instead of the builtin method, and this broke the dang thing as it would not know how to work with two double types. The same was true for <, >, etc.. This seemed very strange to me and I am not sure if it is due to matlab upgrades or to some odd system setting on my machine. In any event, changing the relevant files to check for a double and go to the builtin method seemed to work around the problem okay, and so far the code is working fine.

Great package overall!!! Certainly a lot of work must have gone into it, only giving it 4 out of 5 because I just spent 6 hours getting it to work, but I am sure if I had gone the 32 bit route it would have been much easier.

23 Jul 2009 Brent Ware

Anyone had any luck getting this to work with recent versions of OS X? The old instructions don't seem to work.

03 Nov 2008 Kevin Mitchell

Beautiful! This rivals laprint.m (http://www.mathworks.com/matlabcentral/fileexchange/4638) for packages that really should be included with Matlab by default.

03 Nov 2008 Kevin Mitchell  
28 Aug 2008 HH VD

Windows version here: http://www.thedigitalmap.com/~carlos/software/index.htm

09 Jun 2008 grat c

can anyone tell me how exactly to install the binaries in windows? thanks

09 Apr 2008 Zolotykh Nikolai  
09 Apr 2008 Nikolai Zolotykh

It's really useful and greate soft

14 Mar 2008 Ronan Fleming

When installing in suse 10.1, I found it necessary to explicitly provide the path '/usr/local/lib' in the mp_compile_all.m file as that is where my lmpfr libraries were

e.g. If you get the error
mex: link of 'mpfr_something.mexglx' failed.

Then change lines 12 & 13 to

disp(['compiling: mex ',dd(ii).name,' -L/usr/local/lib -lmpfr -lgmp'])
mex([dd(ii).name],'-L/usr/local/lib -lmpfr -lgmp');

30 Jan 2008 Andrew Wildes

Installed on windows, and works well. It's slow, so it would be difficult to use with any fitting program. We found a couple of bugs and contacted Mr. Barrowes, who was very receptive and replied quickly and enthusiastically. Recommended!

01 Jan 2008 Laszlo Sragner

Some small precisions (1-2) can cause Matlab to break. Some operations cause memory dump errors , maybe this is due to passing illegal arguments somewhere to mex functions.
The GMP mex wrapper functions work well with the supported dlls on a windows XP for these it is worth using it and writing your own m-class around them.

09 Aug 2007 Martin Andersson

I got this system working well on xp-based Matlab, R13 but I never got the compilation to work, an error about missing h-files came up. Anyway, there is no need to compile it as it worked fine using the dll files from Lopes. Before I could use it, I needed to put some work on it a bit and rewrite a few of the m-files, but now it seems OK.

Yes, like other pointed out already, the calculations do become very, very slow, but at least I became able to see what happens when using more digits.

Slower as expected, but still an Excellent tool. (But the Windows installation guide is difficult to understand).

Thanks

11 Jul 2007 Christoph Krautz

Installation fails on Windows! Documentation is more than bad!

18 Jun 2007 Umberto .

Really excellent. However it can be improved, e.g.: (i) some functions are really slow when applied to large matrices (e.g. the overloaded function "prod") and (ii) it worked for me under Matlab 7.3 (2006b) but not under Matlab 6.5. I give a five star rating since this toolbox fills a serious gap into the Matlab numeric representation capabilities.

24 Nov 2006 Carlos López

I were able to compile it for R13 under Windows, but failed miserably to do so for 7.0 and 7.2.
If anyone needs such version contact me to describe what I did.
I added some other test to the toolbox, and overall it appears to run fine.

25 Mar 2006 Egemen Kolemen

For those who are interested in using gcc of cgywin please see:

http://gnumex.sourceforge.net/

14 Mar 2006 Jarek Grzegogrze³kowski  
08 Feb 2006 Leo da Li

Well, in Linux (Fedora Code 4 and Ubuntu) the installation was successful. Actually, on the line 7 of the file mp_compile_all.m:

mex([dd(ii).name,' mpfr_atan2.c'],'-lmpfr -lgmp');

i had to delete ",' mpfr_atan2.c'", otherwise an error is produced. But well, it works pretty great ;) But it would be nice if some functins were included or completed. For exemple, the mrdivide.m function is not fully functional, so we can't accomplish operations where inv of a matrix is required. Usually, mrdivide(A,B) does the same as A*inv(B), but hugely faster and more accurate (inv is neither included).

But, well, this toolbox works really fine. I rate 4 just because it is not fully functional (yet).

19 Jan 2006 Leo da Li

It really seams that this toolbox, as it is, was made to work uniquely under matlab for linux. I tried many diferent things to compile it in matlab for windows (xp) and i couldn't! It could be realy helpfull if instructions/modifications for matlab in windows were provided! I used gcc of cygwin to compile gmp and mpfr, but i can't make a mexopts.bat to gcc on matlab for windows!

12 Dec 2005 Tim Eakin

I have the same problems encountered by Zhiyi when attempting installation on a Windows XP platform. It looks like there may need to be some sort of -I or -L mex switch in a mexopts.bat file. I use Lcc for the C compiler.

08 Dec 2005 Zhiyi Li

I can not compile the C files in it using mex. The compiler can't find mpfr.h

Updates
09 Dec 2004

Added support for pi, euler, and log(2) constants.

22 Dec 2004

Bug fixes. Added functionality.

27 Dec 2004

fixed memory leak

05 Jan 2005

speed enhancements

17 Feb 2005

Som eenhancements and bug fixes. Added complex.m.

05 Jul 2005

Bug fix release.

09 Aug 2005

Some bug fixes, including one with subsasgn.

14 Feb 2006

02/06/06 - fixed ones display bug
02/06/06 - added mp_dontmakeall functionality to mp_makeall.m
02/06/06 - added cumprod.m for mp objects
02/10/06 - added inv, fixed eye not returning mp object

22 Nov 2006

Added some functionality. Tested under recent MPFR and GMP. Mac installation instructions.

18 Jun 2009

License fixed

Contact us