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

Last change on this file since 378 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
RevLine 
[133]1;+
[237]2; @file_comments
[163]3; Send back a vector or a matrix constituted of 0 and 1 in alternation
[133]4;
[237]5; @categories
[318]6; Matrix
[133]7;
[373]8; @param n1 {in}{required} {type=integer}
[237]9; number of elements in the first dimension
[133]10;
[373]11; @param n2 {in} {type=integer}
[237]12; number of elements in the second dimension
13;
[373]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;
[237]30; @returns
[373]31; an array of n1 dimension or n1xn2 dimensions
[237]32;
33; @history
34; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[133]35;                       1/12/98
36;
[237]37; @version
38; $Id$
[133]39;
40;-
[237]41FUNCTION zero_one, n1,n2
[133]42;
43  compile_opt idl2, strictarrsubs
44;
45   CASE N_PARAMS() OF
46      1:return, findgen(n1) mod 2
[237]47      2:BEGIN
[133]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')
[237]54   endcase
[133]55end
Note: See TracBrowser for help on using the repository browser.