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

Home » Public Forums » archive » Speedy way to get compare array elements. . .
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: Speedy way to get compare array elements. . . [message #33030 is a reply to message #32838] Thu, 28 November 2002 08:13 Go to previous messageGo to previous message
Jaco van Gorkom is currently offline  Jaco van Gorkom
Messages: 97
Registered: November 2000
Member
"trouble" <the_cacc@hotmail.com> wrote in message news:5f9f0a23.0211280658.71bff9f4@posting.google.com...
> Craig Markwardt <craigmnet@cow.physics.wisc.edu> wrote in message
news:<on4raklqpk.fsf@cow.physics.wisc.edu>...
>> ...The cool thing about the trick is that IDL *automatically* truncates
>> the vector A so that it matches the length of A[1:*].
>
> Ah, but is there any way to not make it do that? Say you have 2
> vectors of different lengths:
>
> x = findgen(50)
> y = findgen(100)
>
> and you want to form z = x * y, but have z the same length as y
> putting zeros where x has no value. The (sorry) way I am doing it is
>
> z = y * 0
> z[0:49] = x * y
>
> which clearly is too much programmer work since I have to get the
> lengths... Any ideas?

Well, inserting an array into a subrange of another array can also be
done by specifying just the start index. So your
z[0:49] = x * y
is equivalent to
z[0] = x * y
In fact, the second option executes quite a bit faster.

cheers,
Jaco
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: CW_FORM
Next Topic: CreateDrawWidget fails " Unable to acquire a GL context."

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

Current Time: Wed Oct 08 19:33:54 PDT 2025

Total time taken to generate the page: 0.00234 seconds