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

Home » Public Forums » archive » Re: A simple vector - array operation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: A simple vector - array operation [message #70902] Wed, 12 May 2010 09:21
Timm Weitkamp is currently offline  Timm Weitkamp
Messages: 66
Registered: August 2002
Member
On May 12, 5:35 pm, Carsten Lechte <c...@toppoint.de> wrote:

> You could try A = REBIN( V, 25, 100) or A = TRANSPOSE( REBIN( V, 25, 100))

Instead of the latter, A = REBIN(TRANSPOSE(V), 100, 25) may be
slightly more efficient.

But you can also use a matrix multiplication: A = MAKE_ARRAY(100,
VALUE=1) # V

The question whether the REBIN or the matrix multiplication is faster
is not easy to answer. It will depend on number of elements and on the
hardware and software configuration you are using.

Timm
Re: A simple vector - array operation [message #70903 is a reply to message #70902] Wed, 12 May 2010 08:35 Go to previous message
Carsten Lechte is currently offline  Carsten Lechte
Messages: 124
Registered: August 2006
Senior Member
francois wrote:
> Let say that I have an array A of 25 columns by 100 lines and a vector
> V of 25 elements.
> ...
> What would be a fast way of doing this without using the FOR loop ?

You could try A = REBIN( V, 25, 100) or A = TRANSPOSE( REBIN( V, 25, 100))

Depending on the sizes of the arrays and your RAM, this method should
usually be faster than the loop.


chl
Re: A simple vector - array operation [message #70904 is a reply to message #70903] Wed, 12 May 2010 08:29 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
francois writes:

> Let say that I have an array A of 25 columns by 100 lines and a vector
> V of 25 elements.
> I want that each line of A takes the value of V such that:
> for i=0, 99 do begin
> A[i,*] = V
> endfor
>
> What would be a fast way of doing this without using the FOR loop ?

a = Rebin(v, 25, 100)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: A simple vector - array operation
Next Topic: Re: Landsat HDF

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

Current Time: Wed Oct 08 20:01:39 PDT 2025

Total time taken to generate the page: 0.00545 seconds