2537
|
1 ## Copyright (C) 1995, 1996 Kurt Hornik |
3426
|
2 ## |
3922
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
2537
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
3426
|
9 ## |
3922
|
10 ## Octave is distributed in the hope that it will be useful, but |
2537
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
13 ## General Public License for more details. |
|
14 ## |
2537
|
15 ## You should have received a copy of the GNU General Public License |
3922
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
2537
|
19 |
3321
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Mapping Function} {} pow2 (@var{x}) |
|
22 ## @deftypefnx {Mapping Function} {} pow2 (@var{f}, @var{e}) |
|
23 ## With one argument, computes |
|
24 ## @iftex |
|
25 ## @tex |
|
26 ## $2^x$ |
|
27 ## @end tex |
|
28 ## @end iftex |
|
29 ## @ifinfo |
|
30 ## 2 .^ x |
|
31 ## @end ifinfo |
|
32 ## for each element of @var{x}. With two arguments, returns |
|
33 ## @iftex |
|
34 ## @tex |
|
35 ## $f \cdot 2^e$. |
|
36 ## @end tex |
|
37 ## @end iftex |
|
38 ## @ifinfo |
|
39 ## f .* (2 .^ e). |
|
40 ## @end ifinfo |
|
41 ## @end deftypefn |
5053
|
42 ## |
3407
|
43 ## @seealso{nextpow2} |
2537
|
44 |
|
45 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> |
|
46 ## Created: 17 October 1994 |
|
47 ## Adapted-By: jwe |
|
48 |
|
49 function y = pow2 (f, e) |
3426
|
50 |
2537
|
51 if (nargin == 1) |
|
52 y = 2 .^ f; |
|
53 elseif (nargin == 2) |
|
54 y = f .* (2 .^ e); |
|
55 else |
3456
|
56 usage ("y = pow2 (f, e)"); |
2537
|
57 endif |
|
58 |
|
59 endfunction |