comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Need a function to multiply the elements of an array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Need a function to multiply the elements of an array [message #4062 is a reply to message #4052] Wed, 26 April 1995 00:00 Go to previous message
dan is currently offline  dan
Messages: 27
Registered: March 1993
Junior Member
In article <3nm2uk$qqq@pinot.umd.edu>, barsam@Glue.umd.edu (Barsam Marasli) writes:
|>
|> Hi,
|>
|> I am looking for a routine to multiply the elements of an array.
|> Is there a faster way of doing it than the following?
|>
|>
|> function prod, x
|> n = n_elements(x)-1
|> z = 1.d0
|> for i = 0, n do z = z * x(i)
|> return, z
|> end
|>
|>
|>
|> BM
|>

How about

z = exp(total(alog(x)))

Which only works if all x's greater than zero.
--
************************************************************ ***
** Dan Bergmann dbergmann@llnl.gov **
** Global Climate Research fax (510) 422-5844 **
** Lawrence Livermore National Lab human (510) 423-6765 **
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: HELP,<return_string>=<variable of interest> ??
Next Topic: Scroll w/o repaint OR pixmap allocation limits?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 18 04:08:00 PDT 2025

Total time taken to generate the page: 1.91939 seconds