2

I am using mpmath for arbitrary decimal precision. I am creating large square matrices (30 x 30 and 100 x 100). For my code, I am executing singular value decomposition and matrix inversion using mpmath's built-in packages.

My problem is that mpmath is slow, even with a gmpy back-end. I need precision up to 50 decimal points (if the solution is fast, I prefer it to scale to more decimal points).

Is there a solution to speeding up these linear algebra problems in python?

Someone asked a similar question here, but there are 2 differences:

  1. The answers did not address singular value decomposition
  2. The answers gave methods of estimating the inverse, but they did not attempt to show that approaching the true answer is faster than mpmath's method. I have tried the solution given in this post, and I have found it to be slower than mpmath's internal algorithm.
Community
  • 1
  • 1
Paul Terwilliger
  • 1,596
  • 1
  • 20
  • 45
  • 1
    If Frederik doesn’t see this, consider opening an issue on the mpmath Github repo. It’s linear algebra routines probably haven’t received as much love as the rest of it, but maybe he has some idea. You have my heartfelt best wishes… this is a tough question. – Ahmed Fasih May 11 '17 at 02:13
  • @AhmedFasih I'm not familiar with opening an issue on a Github repo... How do I do that? – Paul Terwilliger May 11 '17 at 13:57
  • https://github.com/fredrik-johansson/mpmath/issues – Ahmed Fasih May 11 '17 at 16:33

1 Answers1

0

The way in this case is to rewrite the code that needs to be accelerated to pure c/с++ using the fastest algorithms. For example, try to use GPM library on c++ directly, without using python wrappers. After that, connect this code to python code using pybind11. Example with pybind11: https://github.com/pybind/python_example

don_vanchos
  • 1,280
  • 13
  • 13