;+ ; @file_comments ; Send back a vector or a matrix constituted of 0 and 1 in alternation ; ; @categories ; Matrix ; ; @param n1 {in}{required} {type=integer} ; number of elements in the first dimension ; ; @param n2 {in} {type=integer} ; number of elements in the second dimension ; ; @examples ; ; IDL> a=zero_one(3) ; IDL> help,a ; A FLOAT = Array[3] ; IDL> print,a ; 0.00000 1.00000 0.00000 ; ; IDL> a=zero_one(2,3) ; IDL> help,a ; A FLOAT = Array[2, 3] ; IDL> print,a ; 0.00000 1.00000 ; 1.00000 0.00000 ; 0.00000 1.00000 ; ; @returns ; an array of n1 dimension or n1xn2 dimensions ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; 1/12/98 ; ; @version ; $Id$ ; ;- FUNCTION zero_one, n1,n2 ; compile_opt idl2, strictarrsubs ; CASE N_PARAMS() OF 1:return, findgen(n1) mod 2 2:BEGIN if fix(n1/2) EQ n1/2. then BEGIN ;even number of columns res = findgen(n1+1,n2) mod 2 return, res[0:n1-1, *] ENDIF ELSE return, findgen(n1,n2) mod 2 ;odd number of columns END else: return, report('bad number of arguments') endcase end