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

Home » Public Forums » archive » Re: multiplication
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: multiplication [message #19426] Tue, 28 March 2000 00:00
meron is currently offline  meron
Messages: 51
Registered: July 1995
Member
In article <38E03BDC.868B8396@hotmail.com>, marc <m_schellens@hotmail.com> writes:
> Is there a function like TOTAL but for multiplication.
> Like the big PI symbol in mathematical notation.
> Or this really something for the for loop?
>
> I.E.
>
> a=[1,2,3,...]
>
> result=a[1]*a[2]*a[3]...
>
if all the elements of a are positive then you can simply do

result = exp(total(alog(a)))

*** warning: This has a big chance to result in overflow, even for
moderately sized arrays. But you can check for it before you take the
EXP***

If some of the elements are negative, you can still handle it. do

dum = where(a lt 0, ndum)
sig = (-1)^ndum
result = sig*exp(total(alog(abs(a))))

Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Object graphic 3d Scatterplot
Next Topic: MRI processing

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

Current Time: Wed Oct 08 13:53:27 PDT 2025

Total time taken to generate the page: 0.00419 seconds