Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6380 > unrolled thread

dynamic nested loops

Started byRon <ragove@verizon.net>
First post2011-11-11 10:03 +0000
Last post2011-11-13 09:43 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  dynamic nested loops Ron <ragove@verizon.net> - 2011-11-11 10:03 +0000
    Re: dynamic nested loops Peter Pein <petsie@dordos.net> - 2011-11-12 12:44 +0000
    Re: dynamic nested loops Ray Koopman <koopman@sfu.ca> - 2011-11-13 09:43 +0000

#6380 — dynamic nested loops

FromRon <ragove@verizon.net>
Date2011-11-11 10:03 +0000
Subjectdynamic nested loops
Message-ID<j9irsq$8g5$1@smc.vnet.net>
i need to perform nested sums such as Sum[f, {i,imin,imax},{j, jmin, jmax}, ...{}].  In each nest the new index is a function of the previous and the max values vary.  Also at the beginning I do not know how long a nest I need.  I can't come up with anything that works.  I could construct a list {{i,imin,imax},{j, jmin, jmax}, ...{}} but "Sum" doen't know what to do with the outside braces{...}.
ANy suggestions would be much appreciated.

[toc] | [next] | [standalone]


#6414

FromPeter Pein <petsie@dordos.net>
Date2011-11-12 12:44 +0000
Message-ID<j9lpn9$ljf$1@smc.vnet.net>
In reply to#6380
Am 11.11.2011 11:03, schrieb Ron:
>... I could construct a list {{i,imin,imax},{j, jmin, jmax}, ...{}} but "Sum" doen't know what to do with the outside braces{...}.
> ANy suggestions would be much appreciated.
>

If you've got such a list, let "Apply" remove the the outer curly braces ;-)

e.g.:
In[1]:= Sum[f[i,j,k],##]& @@ {{i, 1, 3}, {j, 1, 2}, {k, 5, 4, -1}}
Out[1]= f[1, 1, 4] + f[1, 1, 5] + f[1, 2, 4] + f[1, 2, 5] + f[2, 1, 4] + 
f[2, 1, 5] + f[2, 2, 4] + f[2, 2, 5] + f[3, 1, 4] + f[3, 1, 5] + f[3, 2, 
4] + f[3, 2, 5]

[toc] | [prev] | [next] | [standalone]


#6417

FromRay Koopman <koopman@sfu.ca>
Date2011-11-13 09:43 +0000
Message-ID<j9o3ff$t97$1@smc.vnet.net>
In reply to#6380
On Nov 11, 2:03 am, Ron <rag...@verizon.net> wrote:
> i need to perform nested sums such as Sum[f, {i,imin,imax},
> {j, jmin, jmax}, ...{}].  In each nest the new index is a
> function of the previous and the max values vary.  Also at
> the beginning I do not know how long a nest I need.  I can't
> come up with anything that works.  I could construct a list
> {{i,imin,imax},{j, jmin, jmax}, ...{}} but "Sum" doen't know
> what to do with the outside braces{...}.
> ANy suggestions would be much appreciated.

If you don't know at the start how deep the nest will be, how are
you constructing the list {{i,imin,imax},{j, jmin, jmax}, ...{}} ?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web