Re: A simple vector - array operation [message #70902] |
Wed, 12 May 2010 09:21 |
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  |
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  |
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.")
|
|
|