1
$\begingroup$

I need to use variable precision arithmetic in MATLAB for an expensive set of computation.

The vpa function provided by the symbolic math toolbox is very slow. I found a non-free alternative toolbox known as "Advanpix" (http://www.advanpix.com/) ,which sped up things by an order of magnitude, using a trial version.

However, my funding body does not allow purchase of any additional software for this project.

Is there a viable/fast alternative to advanpix/vpa for MATLAB ?

$\endgroup$
6
  • $\begingroup$ What about this? $\endgroup$
    – nicoguaro
    Commented Mar 7, 2017 at 21:25
  • $\begingroup$ Still quite slow compared to advanpix. Also, seems to be relatively old package. Is there any other toolbox ? $\endgroup$ Commented Mar 7, 2017 at 21:54
  • $\begingroup$ Have you tried [mpmath]( mpmath.org) on Python? $\endgroup$
    – nicoguaro
    Commented Mar 7, 2017 at 21:56
  • $\begingroup$ Do you need full variable precision or just extended precision, e.g., quad precision? $\endgroup$
    – horchler
    Commented Mar 7, 2017 at 22:52
  • 2
    $\begingroup$ Sometimes if you want the best stuff, you have to pay up. BTW, I'd like to have the nicest house in the world - and i need to get it for free. $\endgroup$ Commented Mar 8, 2017 at 3:11

1 Answer 1

3
$\begingroup$

While I do not know of a toolbox which fits the bill, a good open source alternative to MATLAB and Octave which does have a good solution to this problem is Julia. The linear algebra syntax from MATLAB/Octave almost transfers over to Julia directly, though you need to swap indexing like A(i) to A[i]. But after a quick translation, you can use Julia's BigFloats for variable precision numbers. That's a wrapper of the MPFR library which is pretty standard and does okay. A faster implementation for bitsizes <500 is given in ArbFloats.jl which is based on the Arb library. Lastly, if you just want 128-bit numbers, DecFP.jl gives some good implementations.

What's nice about going this route is that Julia's dispatch system makes these just stand-in for standard numbers, so you can use them in most well written libraries. So you can take these high-speed variable precision numbers and just call generic matrix multiplication, SVD factorization, \, differential equation solvers, optimization routines, etc. and expect them to work in place of Float64s.

$\endgroup$
1
  • $\begingroup$ Thank you for the answer. Unfortunately, there are other inseparable pieces of this complex project (about 3000 lines of code) which relies on external MATLAB-only toolboxes, and hence migrating to Julia at this stage looks difficult. However, I had a look at the julia library and it seems to be useful for future projects. Thanks a lot for the suggestion though. $\endgroup$ Commented Mar 8, 2017 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.