[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: findgen([variable])




JD Smith <jdsmith@astro.cornell.edu> writes:

> Craig Markwardt wrote:
> > 
> > Martin Skou Andersen <skou@fys.ku.dk> writes:
> > > Is it posible to make an mutiple dimensional array by using a variable
> > > such as findgen(x)?
> > 
> > This is virtually impossible, right?  You are asking for each row of
> > the resulting array to be of a different length.  That's not really a
> > 2 dimensional array is it?
> 
> 
> Are we sure he doesn't just mean:
> 
> findgen(x[0],x[1]) ?

Ah yes, that would be a good idea.  In fact, one of my "top ten"
requests was to have all of the functions that accept dimensions,
accept them in a consistent way.  REBIN, REFORM and TOTAL are all
different.  We should be able to specify dimensions consistently
between them, and either as an array, or a list of scalars.

Here is my entry.  Sorry, no HISTOGRAM call, but I need to give it a
rest once in a while.

nel = dims(0)
for i = 1L, n_elements(dims)-1 do nel = nel * dims(i)
arr = reform(findgen(nel), dims)

Craig

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------