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

*Subject*: Re: multiplication*From*: meron(at)cars3.uchicago.edu*Date*: Tue, 28 Mar 2000 05:10:35 GMT*Newsgroups*: comp.lang.idl-pvwave*Organization*: CARS, U. of Chicago, Chicago IL 60637*References*: <38E03BDC.868B8396@hotmail.com>*Reply-To*: meron(at)cars3.uchicago.edu*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:19065

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"

**Follow-Ups**:**Re: multiplication***From:*James Kuyper

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

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