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

Home » Public Forums » archive » Re: Generally accessing the rest of the elements in 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: Generally accessing the rest of the elements in an array [message #23778 is a reply to message #23777] Wed, 21 February 2001 06:21 Go to previous messageGo to previous message
Jaco van Gorkom is currently offline  Jaco van Gorkom
Messages: 97
Registered: November 2000
Member
tbowers wrote:
...
> a = indgen(3,2,4)
>
> I want the equivalent of (in this case):
> b = (a[0,*,*])^2 + (a[1,*,*])^2 + (a[2,*,*])^2
>
> but this requires *'ing the correct dimensions ([0,*,*] for 3 dims,
> [0,*,*,*] for 4 dims
> etc). What I need is a general way to access the "rest" of the data, as Paul
> Harvey
> would say.
>
> Actually, what I *really* want is to access it all generally so if a is 3
> columns, it'll be
> as above
>
> b = (a[0,*,*])^2 + (a[1,*,*])^2 + (a[2,*,*])^2
> but if it's 4 columns, it'll be
> b = (a[0,*,*])^2 + (a[1,*,*])^2 + (a[2,*,*])^2 + (a[3,*,*])^2
> 5 columns...
> b = (a[0,*,*])^2 + (a[1,*,*])^2 + (a[2,*,*])^2 + (a[3,*,*])^2 + (a[4,*,*])^2
> n columns...
> b = (a[0,*,*])^2 + (a[1,*,*])^2 + (a[2,*,*])^2 + ... + (a[n-1,*,*])^2
>
> but I don't think this is possible without a for loop.
>

Hi Todd,

I would guess that this is only a solution to your simplified example,
and not to your real problem:

b = TOTAL(a^2, 1)

Maybe it comes in useful somehow. It can be made more general by
combination with REFORM and TRANSPOSE, in order to sum over almost any
periodic subset of an array.

groetjes,
Jaco van Gorkom


Oops! Sorry, I meant to stay in lurking for 3 months... now I still
can't make it into David's thread! Hello anyway, I'm Jaco, no dog.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Win32 and Removeable Drives
Next Topic: Newsgroup archive online

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

Current Time: Sat Oct 11 12:12:01 PDT 2025

Total time taken to generate the page: 3.12011 seconds