Viewing contents of file '../idllib/contrib/meron/splinroot.pro'
Function Splinroot, spc, range, eps, error = ervl, status = stat, done = don, $
    _extra = _e

;+
; NAME:
;	SPLINROOT
; VERSION:
;	3.0
; PURPOSE:
;	Finds roots of function provided as a set of spline coefficients.
; CATEGORY:
;	Mathematical function (general).
; CALLING SEQUENCE:
;	Result = SPLINROOT(SPC [,RANGE ] [, EPS] [, keywords])
; INPUTS:
;    SPC
;	An (n,3) array of spline coefficients, generated by SPLIN_COEFFS.
; OPTIONAL INPUT PARAMETERS:
;    RANGE
;	Search range.  Defaults to full range present in SPC.  If exceeding 
;	the range in SPC, a warning is issued.
;    EPS
;	Allowed error.  Default is machine precision (according to data type).
; KEYWORD PARAMETERS:
;	All the keyword parameters of ROOT with the exception of PARAMS are 
;	accepted.
; OUTPUTS:
;	Returns a vector containing the location(s) of the root(s).  If no root
;	is found returns machine maximum.
; OPTIONAL OUTPUT PARAMETERS:
;	Same as for the function ROOT, i.e. ERROR, STATUS and DONE.
; COMMON BLOCKS:
;	None.
; SIDE EFFECTS:
;	None.
; RESTRICTIONS:
;	None.
; PROCEDURE:
;	Calls ROOT from MIDL, using SPLIN_EVAL (also from MIDL) as the function
;	to provide the roots.  Also calls DEFAULT, from MIDL.
; MODIFICATION HISTORY:
;	Created 25-NOV-1996 by Mati Meron.
;-

    on_error, 1
    drange = [min(spc(*,0),max=xmax),xmax]
    wrange = Default(range,drange, /dtyp)
    if wrange(0) gt wrange(1) then wrange = reverse(wrange)

    if wrange(0) lt drange(0) or wrange(1) gt drange(1) then begin
	wrange(0) = wrange(0) > drange(0)
	wrange(1) = wrange(1) < drange(1)
	message, 'Warning, range has been truncated!', /continue
    endif

    return, Root('Splin_eval', wrange, eps, param = spc, $
	error = ervl, status = stat, done = don, _extra = _e)

end