MathGroup Archive 2000

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

Search the Archive

Re: CALCULATION TIME

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21431] Re: CALCULATION TIME
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 7 Jan 2000 00:20:41 -0500 (EST)
  • References: <851ek8$4b5@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Jerry,
Re the summation:
Why not use Dot?
Example:

y = Table[Random[], {30000}];

Sum[y[[i]]^2, {i, 20000}] // Timing

{2.42 Second, 6672.59}


#.# &[Take[y, 20000]] // Timing

{0.39 Second, 6672.59}


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



"Blimbaum Jerry DLPC" <BlimbaumJE at ncsc.navy.mil> wrote in message
news:851ek8$4b5 at smc.vnet.net...
> I have some code performing (roughly) the following Do Loops:
>
> Do[.........
>                      Do[x[[m,n+1]] = x[[m,n]] + B*       y[[n+m-1]]*e[[n]]
>
> ----------------------------------------------,
>
> eps+Sum[y[[n-q]]^2,{q,0,M-1}]
>                   {m,M}        ],
>
>                 {n,M,Length[y]}]
>
> where y, e are lists (y is data that contains about 30000 elements),
> etc.     Running a data set takes about 10.5 secs.  I wanted to shorten
the
> time but couldnt figure out how to write it either in Nest or Compile form
> so I went thru it piece meal to see if I could find a culprit and from
this
> I noticed if I replace the Sum term in the denominator by a number, lets
say
> 1, and then perform the calculations it only takes about 2.5 seconds!   I
> did a sample Sum[expr^2] with a similar Do loop separately and it takes no
> time at all.
>
> What is wrong?
>
> thanks.   Jerry Blimbaum    NSWC   Panama City, Fl
>



  • Prev by Date: Re: greek labels
  • Next by Date: Re: CALCULATION TIME
  • Previous by thread: CALCULATION TIME
  • Next by thread: Re: CALCULATION TIME