Re: Concatenate arrays of different dimensions [message #51168] |
Wed, 08 November 2006 09:52 |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
Gianguido Cianci wrote:
> I seem to remember that concatenation is slow with big arrays or
> something...
[...]
> a[*]=-1
If speed is a concern, REPLICATE or REPLICATE_INPLACE should be faster!
Jean
|
|
|
Re: Concatenate arrays of different dimensions [message #51171 is a reply to message #51168] |
Wed, 08 November 2006 09:31  |
cgguido
Messages: 195 Registered: August 2005
|
Senior Member |
|
|
I seem to remember that concatenation is slow with big arrays or
something...
If you have to do this often (especially inside a loop!) and if you can
put a higher limit on the number of rows, I would do:
a=fltarr(40,N) ; you would do this outside the loop, if any.
; where N is a number that is an over estimate of the size you will
need at the end.
a[*]=-1
; or some value you know won't appear in real data. I seem to only ever
encounter positive ; numbers :-) Dunno if you could fill it with
NaNs....
;now you fill a with your sub arrays
a[*,0:29]=f
a[*,30:300+29]=f1
a[*,330:3330+329]=f2
;finaly clean it up
b=a[where(a[*] ne -1)]
a=0
Or someting along these lines anyway... hope this helps.
Gianguido
|
|
|
|
|