On Thu, Sep 9, 2010 at 2:02 AM, maldun <[email protected]> wrote: > On Sep 8, 6:19 pm, KvS <[email protected]> wrote: >> Dear all, >> >> I am trying to implement a recursive algorithm that is rather complex, >> in the sense that it uses a high number of variables and (elementary) >> computations. The output in Sage looks fine but it gets quite slow, so >> I am thinking of ways to speed it up. Given that it is mainly a lot of >> looping and a lot of elementary computations, I would guess >> translating it to Cython could help a lot. >> >> However I am afraid that doubles won't have enough precision to avoid >> too much numerical noise in the end result of the algorithm. So I >> would like to use a higher precision real number representation. The >> question is whether this is possible, and if so what is a sensible >> choice? Could/Should I use mpmath e.g. or rather something else? What >> I need to be doing, next to elementary computations, is: >> >> - compute exponentials >> - perform find_root's >> - being able to store those real numbers in a few big Numpy-arrays. >> >> I am very grateful for any hint! >> >> Many thanks, Kees > > Why don't using mpmath for the critical numerical steps?
With the exception of lots of special functions or very large precisions, this probably won't be a speed advantage over Sage's native RealNumbers given that they both have Python overhead. (As the precision grows, the arithmetic itself will be comprable, as they are both using MPIR/GMP under the hood.) > It supports the features you need, is quite efficient, and also has > multi precision vectors and matrices. > And after the problematic steps, getting back to numpy arrays isn't > really a problem. > > If you really want to get out the every tiny bit of efficiency out of > your code, then you have to stick to cython and mpfr. > But I'm not sure if this is really necessary. > > greez > maldun > > -- > 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 > URL: http://www.sagemath.org > -- 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 URL: http://www.sagemath.org
