JensGrabner / mpmath-2

Automatically exported from code.google.com/p/mpmath
Other
3 stars 0 forks source link

linear algebra #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If you are going to implement some stuff for solving linear equations (as
you mentioned in your recent blog post), I could provide working (yet
somewhat messy) code to do the basic stuff like LU decomposition (this
includes solving linear systems and calculating the inverse/determinant
efficiently). Additionally I could share code for solving overdetermined
(and ordinary) linear systems via QR decomposition (LU decomposition is two
times faster, but less accurate).

Original issue reported on code.google.com by Vinzent.Steinberg@gmail.com on 2 Jul 2008 at 7:58

GoogleCodeExporter commented 9 years ago
Fixed imports, better __pow__, fixed residual precision.

But I have problems importing inverse from linalg (needed for negative powers):

Traceback (most recent call last):
  File "matrices.py", line 6, in <module>
    from linalg import inverse
  File "../../mpmath/linalg.py", line 12, in <module>
    from matrices import matrix, swap_row, extend, mnorm_1, norm_p
  File "/home/one/src/mpmath/svn/mpmath/matrices.py", line 6, in <module>
    from linalg import inverse
ImportError: cannot import name inverse

Original comment by Vinzent.Steinberg@gmail.com on 12 Sep 2008 at 10:44

Attachments:

GoogleCodeExporter commented 9 years ago
It should work if you put the import inside the function.

def __pow__(...):
    from linalg import inverse
    ...

Original comment by fredrik....@gmail.com on 12 Sep 2008 at 10:52

GoogleCodeExporter commented 9 years ago
Fixed and tests added.

Is it ok to commit now?

What about a relative extraprec() btw?

Original comment by Vinzent.Steinberg@gmail.com on 13 Sep 2008 at 11:24

Attachments:

GoogleCodeExporter commented 9 years ago
Please go ahead.

It should be sufficient to do extraprec(0, normalize_output=True) and set 
mp.prec *=
2 in the function. However, due to a bug in extraprec, the output doesn't 
actually
get normalized.

By the way, matrix needs to implement __pow__ so that normalization works.

Original comment by fredrik....@gmail.com on 13 Sep 2008 at 11:30

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/mpmath/source/detail?r=558

Original comment by Vinzent.Steinberg@gmail.com on 13 Sep 2008 at 11:54