source: trunk/SRC/Matrix/zero_one.pro @ 163

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; @file_comments
6; Send back a vector or a matrix constituted of 0 and 1 in alternation
7;
8; @categories
9; Function, Matrix
10;
11; @param n1 {in}{required} number of elements in the first dimension
12; @param n2 {in}{required} number of elements in the second dimension
13;
14; @returns result
15;
16; @history Sebastien Masson (smasson\@lodyc.jussieu.fr)
17;                       1/12/98
18;
19; @version $Id$
20;
21;-
22;------------------------------------------------------------
23;------------------------------------------------------------
24;------------------------------------------------------------
25function zero_one, n1,n2
26;
27  compile_opt idl2, strictarrsubs
28;
29   CASE N_PARAMS() OF
30      1:return, findgen(n1) mod 2
31      2:BEGIN
32         if fix(n1/2) EQ n1/2. then BEGIN ;even number of columns
33            res = findgen(n1+1,n2) mod 2
34            return, res[0:n1-1, *]
35         ENDIF ELSE return, findgen(n1,n2) mod 2 ;odd number of columns
36      END
37      else: return,  report('bad number of arguments')
38   endcase           
39end
Note: See TracBrowser for help on using the repository browser.