Hi Nils, excellent point! Adding a special case for gcd = 1 help a *lot* on many instances.
I'll definitely take the plunge and convert the code to lists or tuples instead of vectors. (The convenience of writing things like "alpha * v + w" is certainly not worth the performance penalty.) I don't think NumPy will help, as NumPy works with machine precision throughout, as far as I was able to figure out. Regarding Cython, I'll have to find out if there is a way to work with Cython and still use arbitrary precision arithmetic. Question in general: When using machine precision arithmetic (be it via Cython or NumPy), is there a way to tell whether at some point throughout a long computation there were numerical overflows - without paying a huge speed penalty for making this check? Thanks, Felix On Wednesday, November 20, 2013 8:00:41 PM UTC+1, Nils Bruin wrote: > > > > On Wednesday, November 20, 2013 10:54:29 AM UTC-8, Nils Bruin wrote: > >> return [c div g for c in v] >> > > Sorry, that's spelled [c // g for c in v] > > Incidentally, a typical vector of 20 integers has gcd 1 for its > coefficients. If that happens a lot in your data, you should shortcut on > gcd==1 to just return the original list/vector. Allocating the new > integers/list/vector is probably the majority of the cost. > -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.
