On Thu, Jun 18, 2009 at 8:31 PM, Ethan Van Andel<[email protected]> wrote:
>
> Does sage have a way to use a numeric method (such as Jacobi, or Gauss-
> Sidel) to solve matrix equations of the form A*x = b? (CDF matrices by
> the way). the A.solve_right(b) method is too slow.
>
> Thanks,
> Ethan

Here is an example of how to convert back/forth to numpy to solve A*x
= b very quickly.  Below we do this with A a 1000x1000 matrix, and it
takes about a half second.   It would be *great* if somebody made it
so this would work in Sage automatically without having to explicitly
use numpy like I've done before.  But for you, I bet this is a minor
inconvenience.

sage: n = 1000
sage: a = random_matrix(CDF,n); v = random_matrix(CDF,n,1)
sage: aa = a.numpy(); vv = v.numpy()
sage: import numpy
sage: time ww = numpy.linalg.solve(aa, vv)
Time: CPU 0.57 s, Wall: 0.41 s
sage: w = matrix(CDF, ww)
sage: max([abs(z) for z in a*w - v])
5.46740430707e-12 + 8.431033649e-13*I

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to