MathGroup Archive 2002

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

Search the Archive

Re: Particular structure 2

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33627] Re: Particular structure 2
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Wed, 3 Apr 2002 18:09:02 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Yas emailed me privately asking for a less memory demanding soluton than my
earlier on using Outer.
Here is my reply

How about this (Quit needs to be evaluated each time separately - or you
could quit the kernel from the kernel menu)

New code

    Quit

    x= y=Table[1,{400}];f=Plus;F= Times@@#&;

    Table[Function[kk,ReleaseHold[#]][y[[i]]],{i,Length[y]}]& [
      Hold[F][f[#,kk,z]&/@x]];//Timing

            {15.21 Second,Null}

    MaxMemoryUsed[ ]

            1385656

Old code

    Quit

    x= y=Table[1,{400}];f=Plus;F= Times@@#&;

    F/@Map[First,Transpose[Outer[f,x,y,{z}]],{2}];//Timing

            {29.11 Second,Null}

    MaxMemoryUsed[ ]

                    19250032
Compare to     1385656




--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Allan Hayes" <hay at haystack.demon.co.uk> wrote in message
news:a86k5e$jm4$1 at smc.vnet.net...
> Yas,
>
> F/@Map[First,Transpose[Outer[f,{x1,x2,x3},{y1,y2,y3,y4},{z}]],{2}]
>
>
{F[{f[x1,y1,z],f[x2,y1,z],f[x3,y1,z]}],F[{f[x1,y2,z],f[x2,y2,z],f[x3,y2,z]}]
> ,
>
>
F[{f[x1,y3,z],f[x2,y3,z],f[x3,y3,z]}],F[{f[x1,y4,z],f[x2,y4,z],f[x3,y4,z]}]}
>
> Where F is the function to be used at the second stage.
>
> --
> Allan
>
> ---------------------
> Allan Hayes
> Mathematica Training and Consulting
> Leicester UK
> www.haystack.demon.co.uk
> hay at haystack.demon.co.uk
> Voice: +44 (0)116 271 4198
> Fax: +44 (0)870 164 0565
>
>
> "Yas" <yast at optushome.com.au> wrote in message
> news:a81jgj$778$1 at smc.vnet.net...
> > G'day,
> > How do I go about achieving the structured list below,
> >
> > {f[x1, y1, z], ... , f[xn, y1, z]}
> >
> > followed by some operation on the above list (e.g Fold), store the
> > result and then, do the same again for other y values, as in,
> >
> > {f[x1, ym, z], ... , f[xn, ym, z]}
> >
> > until the last value of ym.
> >
> > In summary, the n values of x get slotted in first for one value of y
> > then the resulting list is evaluated, the answer stored, values of x get
> > slotted in again, y is incremented and so forth until all (m) values of
> > y have been done.
> >
> > Thanks
> > Yas
> >
> >
>
>
>




  • Prev by Date: Re: Re: information on Eigensystem
  • Next by Date: Re: Re: information on Eigensystem
  • Previous by thread: Re: problems with ContourPlot
  • Next by thread: RE: Re: Particular structure 2