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

Home » Public Forums » archive » simple array math question
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: simple array math question [message #33788 is a reply to message #33713] Mon, 27 January 2003 10:20 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Fri, 24 Jan 2003 12:29:11 -0700, Craig Markwardt wrote:


> "Pepijn Kenter" <kenter@tpd.tno.nl> writes:
>> "Kenneth Bowman" <k-bowman@null.tamu.edu> wrote in message
>> news:k-bowman-4D0582.08381824012003@news.tamu.edu...
>>> In article <b0rce6$23c$1@news.surfnet.nl>,
>>> "Pepijn Kenter" <kenter@tpd.tno.nl> wrote:
>>>
>>>> And does any IDL-wizard know a similar trick to average each
>>>> row/column
>> of
>>>> a?
>>>> i.e. to replace the following lines:
>>>>
>>>> result = dblarr(3)
>>>> for i = 0, 2 do result[i] = mean(a[*,i])
>>>
>>> That's an easy one:
>>>
>>> result1 = TOTAL(a, 1, /DOUBLE)/n1
>>> result2 = TOTAL(a, 2, /DOUBLE)/n2
>>>
>>> where n1 and n2 are the sizes of the first and second dimensions,
>>> respectively.
>>>
>>> Ken Bowman
>>
>> Thanks, but what I actually meant was a way where you can replace the
>> mean function by any, arbitrary function. I forgot about the dimension
>> parameter of the TOTAL function, so my example was a bad one. Sorry.
>
> "Arbitrary function"? No. In more recent versions of IDL, quite a
> number of built-in math functions have the ability to specify one or
> more dimensions over which the function is to be applied. I have a
> function called CMAPPLY, which may be useful with older versions of IDL,
> and does many of those same things. One thing it can do is apply an
> arbitrary function, but it won't necessarily be speedy. JD Smith also
> has a DLM which did a lot of these kinds of things.
>

My REDUCE DLM has been entirely superseded with v5.6 by builtin
methods. I think the list currently stands at:

MAX
MEAN
MEDIAN
MIN
MULTIPLY (PRODUCT)
TOTAL

And of course REFORM and REBIN (obviously).

You can use these primitives to build up the moments along any
dimension... see MOMENT and moment.pro. In fact, I think just
sticking an _EXTRA in all the totals in that file, and touching up the
argument checking would buy you a REDUCE-capable MOMENT as well (not
sure why RSI didn't do this for us). Note that sometimes you use a
keyword (DIMENSION) and sometimes you use a vector argument.

What we don't have is an APL style function-as-argument mechanism,
with the attendant abilities to thread and collaps function over any
dimension of arbitrarily sized arrays. But IDL's argument rules are
far too loose to permit this anyway.

Good luck,

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Polyfill, z-buffer & postscript
Next Topic: True size of a gzip compressed file?

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

Current Time: Wed Oct 08 13:10:59 PDT 2025

Total time taken to generate the page: 0.00252 seconds