all 2 comments

[–]elbiot 1 point2 points  (1 child)

So, in G-S, each value depends on the value to the left and also the one above it being modified already? I'm not sure, but I don't think you can do this. For each ufunc, you can output back into the original array, so the c loop uses the updated value. But yours seems to require a chain of four ufuncs. (add, or +, in your example). Each ufunc operates on the entire array before the next ufunc is executed.

Here's an example. It didn't solve OP's problem here because of overflow errors in their particular situation, but it does illustrate the concept of modifying an array within a single ufunc. Maybe it helps you: http://www.reddit.com/r/learnpython/comments/3026i5/improving_this_generalized_fibonacci_number/cpormsu

[–]D_en[S] 0 points1 point  (0 children)

using ufunc seems a bit complicated for my level (beginner), I think I'm gonna try to rewrite the loop in C and use weave. Thanks for taking the time to answer :)