Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13937
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Insufficient memory "General::nomem:" using Tuples |
| Date | 2013-03-27 23:00 +0000 |
| Message-ID | <kivtlt$dbl$1@smc.vnet.net> (permalink) |
| References | <kirkrt$at6$1@smc.vnet.net> |
| Organization | Time-Warner Telecom |
On Mar 26, 1:05 am, Iv=E1n Lazaro <gamins...@gmail.com> wrote:
> Hi all!
>
> I've encounter a weird behavior today using Mathematica 9 under Linux.
>
> I'm defining a list of available modes
>
> num = 15;
> maxModes = ConstantArray[2, num];
>
> and then trying to organize them in all possible tuples
>
> lst=Tuples[Range[0, #] & /@ Join[maxModes - 1, maxModes - 1]];
>
> I expect a BIG number of outcomes, but then I'm just removing some
> (almost all) of them from the list:
>
> lst1=DeleteCases[Map[If[Total@Take[#, num] != Total@Take[#,
> {num + 1, 2 num}], sym, #] &,lst], _Symbol];
>
> The problem is that the computation doesn't finish building the
> tuples. I'm getting the output "General::nomem: The current
> computation was aborted because there was insufficient memory
> available to complete the computation."
>
> Is there a way to avoid this?
>
> Thanks in advance!
Each term in the reduced list is the concatenation of the num-bit
binary representations of two integers in [0, 2^num - 1]. The pairs
are all those in which the binary representations of both members
have the same number of 1-bits. The length of the reduced list is
With[{num = 15}, #.#& @ Binomial[num,Range[0,num]]] -> 155117520
It is probably better to generate the list in packed form,
and then to unpack it as necessary. Here is a toy example:
num = 3;
p = Join@@(Tuples[FromDigits[#,2]& /@ Permutations@
IntegerDigits[#,2,num], 2].{2^num,1} & /@ Table[2^k-1,{k,0,num}])
{0,9,10,12,17,18,20,33,34,36,27,29,30,43,45,46,51,53,54,63}
Since num is small we can unpack the whole list:
IntegerDigits[#,2,2*num]& /@ p
{{0,0,0,0,0,0},{0,0,1,0,0,1},{0,0,1,0,1,0},{0,0,1,1,0,0},
{0,1,0,0,0,1},{0,1,0,0,1,0},{0,1,0,1,0,0},{1,0,0,0,0,1},
{1,0,0,0,1,0},{1,0,0,1,0,0},{0,1,1,0,1,1},{0,1,1,1,0,1},
{0,1,1,1,1,0},{1,0,1,0,1,1},{1,0,1,1,0,1},{1,0,1,1,1,0},
{1,1,0,0,1,1},{1,1,0,1,0,1},{1,1,0,1,1,0},{1,1,1,1,1,1}}
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Insufficient memory "General::nomem:" using Tuples Iván Lazaro <gaminster@gmail.com> - 2013-03-26 08:05 +0000 Re: Insufficient memory "General::nomem:" using Tuples Ray Koopman <koopman@sfu.ca> - 2013-03-27 23:00 +0000 Re: Insufficient memory "General::nomem:" using Tuples Iván Lazaro <gaminster@gmail.com> - 2013-03-30 08:06 +0000
csiph-web