|
Re: which array dimensions are contiguous? [message #47522 is a reply to message #47521] |
Tue, 14 February 2006 02:31  |
greg michael
Messages: 163 Registered: January 2006
|
Senior Member |
|
|
Thanks, David. My question was really only about whether the first
dimensions of an array are the contiguous ones, to which I understand
the answer is yes. The indexing mess is different (and probably worse)
than the one I was imagining, so thanks for that, too.
Still, there's something in that article I couldn't grasp...
IDL> myArray = FltArr(3660, 1680)
IDL> indices = Randomu(seed, 100000) * 3660L * 1680L
IDL> myArray[indices, indices] = 5
I'd have understood if the 3rd line said myArray[indices] = 5. What's
going on here? Why doesn't it cause an error to put in a list of
indices which exceed the dimension?
IDL> print,max(indices)
6.14869e+006
I suppose they're being first enumerated into a single list, and then
being applied as 1-d subscripts? I wouldn't have said "No problems with
this. "!
regards,
Greg
|
|
|
Re: which array dimensions are contiguous? [message #47523 is a reply to message #47522] |
Mon, 13 February 2006 12:04  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
greg michael writes:
> I know somebody wrote this only recently, but I can't find it again. If
> the function below, EvaluateFunctionSection, returns a 2-d array
> (ns,nl), will assignment put it into contiguous memory, or make some
> kind of awful (slow?) mess?
>
> b=fltarr(ns,nl,n_elements(f))
> for i=1,n_elements(f) do begin
>
> b[*,*,i]=self-> EvaluateFunctionSection(f[i],ln,sm,nl,ns,downsample=downsamp le)
> endfor
It will make a (slow) mess. Do this, instead:
b[0,0,I]=self->EvaluateFunctionSection[I], $
ln,sm,nl,ns,downsample=downsample)
See this article:
http://www.dfanning.com/misc_tips/submemory.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|