[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: numerator? denominator?



On Sun, Feb 06, 2000 at 04:07:00PM -0500, Nils Barth wrote:
> Okay.
> Actually, if you're working on that -anyhow-, you might want to
> implement fast exponentiation. Basically, exponentiation mod n can be
> done very quickly, so if
> a^b mod n
> were computed internally mod n, it would be MUCH faster than
> a^b % n
> i.e., first do a^b, then mod is slow.

That was one of the reasons for also doing the mod operator, so that such
optimizations are possible.  However for a first stab at making it work it'll
probably not be there :)

> To see the relevant algorithm, see:
> dr-genius/lib/number_theory/misc.gel
> function PowerMod
> 
> It's not a big deal if this isn't built-in (heck, m9a (=mathematica)
> doesn't have it built-in), but it would be more elegant.

Oh it would be very nice to have this, and I don't think it should be so
terribly complicated to build in either.

Another optimization which I'm thinking about is imagine you have a bunch of
different sized matricies and you multiply them all together

A*B*C*D

genius could figure out the grouping of the matricies so that you do the
least number of operations.

George