MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Insufficient memory "General::nomem:" using Tuples

  • To: mathgroup at smc.vnet.net
  • Subject: [mg130235] Re: Insufficient memory "General::nomem:" using Tuples
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Wed, 27 Mar 2013 03:53:56 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kirkrt$at6$1@smc.vnet.net>

On Mar 26, 1:05 am, Iv=E1n Lazaro <gamins... at 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}}



  • Prev by Date: Re: Table with condition
  • Next by Date: Plotting a transition function
  • Previous by thread: Insufficient memory "General::nomem:" using Tuples
  • Next by thread: Re: Insufficient memory "General::nomem:" using Tuples