Viewing contents of file '../idllib/contrib/mallozzi/create_array.pro'
;+
; NAME:
;	CREATE_ARRAY
;
; PURPOSE:
;       Given the number of elements and the minumim and maximum values, 
;       creates an array. The most complex datatype of the two 
;       values MINV, MAXV will set the type of array.
;
;       The type of array is set by the most complex  datatype of MINV, MAXV.  
;       For example, the call X = CREATE_ARRAY(100, 0, 10.0) will return a 
;       floating point array.
;
; TYPE:
;       FUNCTION
;
; CATEGORY:
;       Arrays 
;
; CALLING SEQUENCE:
;       RESULT = CREATE_ARRAY(NPTS, MINV, MAXV)
;
; INPUTS:
;       NPTS = total number of array elements
;       MINV = the minimum value of the array
;       MAXV = the maximum value of the array
;
; INPUT PARAMETERS:
;       NONE.
; 
; KEYWORD PARAMETERS:
;       NONE.
;
; OUTPUTS:
;       RESULT = an array with the desired characteristics
;
; COMMON BLOCKS:
;	NONE
;
; SIDE EFFECTS:
;       NONE
;
; RESTRICTIONS:
;	Does not work for arrays of structures, objects, or pointers
;
; DEPENDENCIES:
;       NONE
;
; MODIFICATION HISTORY:
;	Written by Robert.Mallozzi@msfc.nasa.gov, February, 1995.
;-
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

FUNCTION CREATE_ARRAY, NPTS, MINV, MAXV

; Get the datatype
;
TEMP     = SIZE(MINV)
MIN_TYPE = TEMP(N_ELEMENTS(TEMP) - 2)
TEMP     = SIZE(MAXV)
MAX_TYPE = TEMP(N_ELEMENTS(TEMP) - 2)
TYPE     = MAX_TYPE > MIN_TYPE

CASE (TYPE) OF 
     1: OUTARR = ( (BINDGEN(NPTS) / (NPTS - 1)) * (MAXV - MINV) ) + MINV
     2: OUTARR = FIX(( (FINDGEN(NPTS) / (NPTS - 1)) * (MAXV - MINV) ) + MINV)
     3: OUTARR = LONG(( (FINDGEN(NPTS) / (NPTS - 1)) * (MAXV - MINV) ) + MINV)
     4: OUTARR = ( (FINDGEN(NPTS) / (NPTS - 1)) * (MAXV - MINV) ) + MINV
     5: OUTARR = ( (DINDGEN(NPTS) / (NPTS - 1)) * (MAXV - MINV) ) + MINV
     6: OUTARR = ( (CINDGEN(NPTS) / (NPTS - 1)) * (MAXV - MINV) ) + MINV
     7: OUTARR = ( (SINDGEN(NPTS) / (NPTS - 1)) * (MAXV - MINV) ) + MINV
     ELSE: BEGIN
           PRINT,'** ERROR in call to CREATE_ARRAY.'
           RETURN, -1
           END
ENDCASE  


RETURN, OUTARR
END