MathGroup Archive 2011

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

Search the Archive

Re: dynamic nested loops


Sum has non-standard evaluation-order going on, hence something like this:

limits = {{i, 1, 3}, {j, 2, 5}}
sum[f[i, j], Sequence @@ limits] /. sum -> Sum

{{i, 1, 3}, {j, 2, 5}}

f[1, 2] + f[1, 3] + f[1, 4] + f[1, 5] + f[2, 2] + f[2, 3] + f[2, 4] +
  f[2, 5] + f[3, 2] + f[3, 3] + f[3, 4] + f[3, 5]

Bobby

On Fri, 11 Nov 2011 03:56:10 -0600, Ron <ragove at 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.
>


-- 
DrMajorBob at yahoo.com



  • Prev by Date: Re: large integration result for simple problem: 1/x,, also BesselJ
  • Next by Date: Re: large integration result for simple problem: 1/x,, also BesselJ
  • Previous by thread: dynamic nested loops
  • Next by thread: Re: dynamic nested loops