"be consistent" | |
PerlMonks |
Re: Obtaining terms in an expansionby ivancho (Hermit) |
on Jan 06, 2006 at 00:57 UTC ( [id://521394]=note: print w/replies, xml ) | Need Help?? |
ok, so the 2^N terms are each a product of N terms, a[i][j], where j can be 0 or 1 and i goes from 0 to N-1 ie, each one looks like, say a[0][0] * a[1][0] * a[2][1] * a[3][0] * ... * a[N-1][1] So, we want do some binary magic. how about something like:
note, $size must be a power of 2, for vec to work, and unless you're on a 64-bit machine, it probably cannot be more than 32. also, this works for $N no more than 31(32?) - but you may have other problems (memory say), if you want to go above that. Hope this helps.
In Section
Seekers of Perl Wisdom
|
|