MathGroup Archive 2009

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

Search the Archive

Re: How to remove all cycles

  • To: mathgroup at
  • Subject: [mg98316] Re: [mg98269] How to remove all cycles
  • From: Bob Hanlon <hanlonr at>
  • Date: Sun, 5 Apr 2009 06:41:08 -0400 (EDT)
  • Reply-to: hanlonr at

n = 13;

A = Array[a, 2^(n + 1)];

B = Array[b, {2, 2^n}];

Do[Do[A[[j + BitShiftLeft[k - 1, 1]]] = B[[j, k]], {j, 1, 2}], {k, 1, 
   2^n}] // Timing


A2 = Flatten[Transpose[B]]; // Timing


A == A2


Bob Hanlon

---- buts <manger31 at> wrote: 

I want to write the following code using functional
programming, i.e. to remove all Do's.
There are two arrays: 

A[[i]], i=1,...,2^(n+1)
B[[j,k]], j=1,2;  k=1,...,2^n.

I need to assign B to A setting the first bit of the index i
to be the index j. Explicitly

Do[Do[A[[ j + BitShiftLeft[k-1,1] ]]= B[[j,k]],

I need to do it for multi-dimensional large arrays.
Is it possible to write it without Do's ?



Bob Hanlon

  • Prev by Date: Re: Styling the selected Tab's label in TabView
  • Next by Date: Re: How to remove all cycles
  • Previous by thread: How to remove all cycles
  • Next by thread: Re: How to remove all cycles