[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: multiplication*From*: James Kuyper <kuyper(at)wizard.net>*Date*: Tue, 28 Mar 2000 12:11:37 GMT*Newsgroups*: comp.lang.idl-pvwave*Organization*: Not Enough*References*: <38E03BDC.868B8396@hotmail.com> <f9XD4.136$i3.1947@uchinews>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:19067

meron@cars3.uchicago.edu wrote: > > 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))) ... > 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)))) You can't honestly be suggesting that this is a good technique? Ignore for a momement what happens if any element of 'a' is 0. That code performs two transcendental function evaluations per element of 'a'. IDL would have to be very badly engineered (which I suppose is possible), for a 'for' loop to execute more slowly than your code.

**Follow-Ups**:**Re: multiplication***From:*Carsten Dominik

**Re: multiplication***From:*J.D. Smith

**References**:**multiplication***From:*marc

**Re: multiplication***From:*meron

- Prev by Date:
**Re: Object graphics and real postscript** - Next by Date:
**Re: multiplication** - Prev by thread:
**Re: multiplication** - Next by thread:
**Re: multiplication** - Index(es):