Mercurial > hg > octave-jordi
annotate scripts/specfun/pow2.m @ 20852:1142cf6abc0d
2015 Code Sprint: remove class of function from docstring for all C++ files.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 12 Dec 2015 07:40:03 -0800 |
parents | 516bb87ea72e |
children |
rev | line source |
---|---|
19696
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19101
diff
changeset
|
1 ## Copyright (C) 1995-2015 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) 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 |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
2537 | 18 |
3321 | 19 ## -*- texinfo -*- |
20851
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19696
diff
changeset
|
20 ## @deftypefn {} {} pow2 (@var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19696
diff
changeset
|
21 ## @deftypefnx {} {} pow2 (@var{f}, @var{e}) |
19101
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
22 ## With one input argument, compute |
3321 | 23 ## @tex |
9167
1231b1762a9a
Simplify TeXinfo and eliminate use of @iftex in arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
24 ## $2^x$ |
3321 | 25 ## @end tex |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7742
diff
changeset
|
26 ## @ifnottex |
9167
1231b1762a9a
Simplify TeXinfo and eliminate use of @iftex in arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
27 ## 2 .^ x |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7742
diff
changeset
|
28 ## @end ifnottex |
9141
c1fff751b5a8
Update section 17.1 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
29 ## for each element of @var{x}. |
c1fff751b5a8
Update section 17.1 (Utility Functions) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
30 ## |
19101
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
31 ## With two input arguments, return |
3321 | 32 ## @tex |
9167
1231b1762a9a
Simplify TeXinfo and eliminate use of @iftex in arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
33 ## $f \cdot 2^e$. |
3321 | 34 ## @end tex |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7742
diff
changeset
|
35 ## @ifnottex |
9167
1231b1762a9a
Simplify TeXinfo and eliminate use of @iftex in arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
9141
diff
changeset
|
36 ## f .* (2 .^ e). |
8517
81d6ab3ac93c
Allow documentation tobe built for other formats than tex and info
sh@sh-laptop
parents:
7742
diff
changeset
|
37 ## @end ifnottex |
19101
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
38 ## @seealso{log2, nextpow2, power} |
3321 | 39 ## @end deftypefn |
2537 | 40 |
41 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> | |
42 ## Created: 17 October 1994 | |
43 ## Adapted-By: jwe | |
44 | |
45 function y = pow2 (f, e) | |
3426 | 46 |
2537 | 47 if (nargin == 1) |
48 y = 2 .^ f; | |
49 elseif (nargin == 2) | |
50 y = f .* (2 .^ e); | |
51 else | |
6046 | 52 print_usage (); |
2537 | 53 endif |
54 | |
55 endfunction | |
7385 | 56 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 |
7385 | 58 %!test |
59 %! x = [3, 0, -3]; | |
60 %! v = [8, 1, .125]; | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
61 %! assert (pow2 (x), v, sqrt (eps)); |
7385 | 62 |
63 %!test | |
64 %! x = [3, 0, -3, 4, 0, -4, 5, 0, -5]; | |
65 %! y = [-2, -2, -2, 1, 1, 1, 3, 3, 3]; | |
66 %! z = x .* (2 .^ y); | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
67 %! assert (pow2 (x,y), z, sqrt (eps)); |
7385 | 68 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
69 %!error pow2 () |
19101
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
70 %!error pow2 (1,2,3) |
7385 | 71 |