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

Last change on this file since 373 was 373, checked in by pinsard, 16 years ago

improvements of headers (examples and results)

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