# Source code for xgen.pro:

```function xgen,x1,x2,NPOINTS=npoints,LOGPLOT=logplot,DOUBLE_PREC=double_prec

;\$Id: xgen.pro, v2\$
;
; Copyright © 2005 Richard Massey and Alexandre Refregier.
;
; This file is a part of the Shapelets analysis code.
; www.astro.caltech.edu/~rjm/shapelets/
;
; The Shapelets code is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public Licence as published
; by the Free Software Foundation; either version 2 of the Licence, or
; (at your option) any later version.
;
; The Shapelets code is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public Licence for more details.
;
; You should have received a copy of the GNU General Public Licence
; along with the Shapelets code; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
;
;+
; NAME:
;       XGEN
;
; PURPOSE:
;       Generate a vector containing equally spaced numbers between
;       x1 and x2. This is typically used to generate an x-axis
;       vector in a plot.
;
; CATEGORY:
;       Miscellaneous.
;
; CALLING SEQUENCE:
;       Xarray = XGEN(x1, x2 [,NPOINTS ,/LOGPLOT] )
;
; INPUTS:
;       x1,x2: interval limits
;
; KEYWORD PARAMETERS:
;       NPOINTS: number of points (default=100)
;       LOGPLOT: produce spacing adapted for a log plot
;
; OUTPUTS:
;       Array of floating point numbers.
;
; PROCEDURES USED:
;       findgen - generate arrays of integers (as floating point variables).
;
; MODIFICATION HISTORY:
;       Oct 11 - DOUBLE keyword added by RM
;       Apr 07 - "Weird bug" fixed by Joel Berge.
;       Jul 03 - Header added by Richard Massey.
;       Jun 95 - Written by Alexandre Refregier.
;-

COMPILE_OPT idl2

if keyword_set(npoints) then np=npoints else np=100
if keyword_set(double_prec) then xx=dindgen(np) else xx=findgen(np)
if keyword_set(logplot) then begin
xx=10.^(xx*(alog10(x2)-alog10(x1))/float(np>1)+alog10(x1))
endif else begin
xx=xx*(float(x2)-float(x1))/float(np>1)+float(x1)
if x1 eq 0 and np eq x2 then begin
if keyword_set(double_prec) then xx=dindgen(np) else xx=findgen(np) ; Added by Joel Apr 07. Why?
endif
endelse

return,xx
end
```

Return to the shapelets web page or the code help menu.

 Last modified on 2nd Mar 2009 by Richard Massey.