annotate scripts/specfun/pow2.m @ 20595:c1a6c31ac29a

eliminate more simple uses of error_state * ov-classdef.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 00:20:02 -0400
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19136
diff changeset
1 ## Copyright (C) 1995-2015 Kurt Hornik
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3407
diff changeset
2 ##
3922
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
3 ## This file is part of Octave.
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
4 ##
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3407
diff changeset
9 ##
3922
38c61cbf086c [project @ 2002-05-01 06:48:35 by jwe]
jwe
parents: 3456
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
2537
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3407
diff changeset
13 ## General Public License for more details.
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3407
diff changeset
14 ##
2537
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
2537
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
18
3321
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2537
diff changeset
19 ## -*- texinfo -*-
19136
bb20384acf7b doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents: 17744
diff changeset
20 ## @deftypefn {Function File} {} pow2 (@var{x})
bb20384acf7b doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents: 17744
diff changeset
21 ## @deftypefnx {Function File} {} pow2 (@var{f}, @var{e})
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
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2537
diff changeset
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
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2537
diff changeset
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 ##
19136
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
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2537
diff changeset
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
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2537
diff changeset
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
19136
bb20384acf7b doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents: 17744
diff changeset
38 ## @seealso{log2, nextpow2, power}
3321
6923abb04e16 [project @ 1999-10-26 18:15:30 by jwe]
jwe
parents: 2537
diff changeset
39 ## @end deftypefn
2537
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
40
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
41 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at>
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
42 ## Created: 17 October 1994
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
43 ## Adapted-By: jwe
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
44
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
45 function y = pow2 (f, e)
3426
f8dde1807dee [project @ 2000-01-13 08:40:00 by jwe]
jwe
parents: 3407
diff changeset
46
2537
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
47 if (nargin == 1)
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
48 y = 2 .^ f;
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
49 elseif (nargin == 2)
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
50 y = f .* (2 .^ e);
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
51 else
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5642
diff changeset
52 print_usage ();
2537
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
53 endif
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
54
80b982e7f4b1 [project @ 1996-11-19 21:15:06 by jwe]
jwe
parents:
diff changeset
55 endfunction
7385
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
56
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
57
7385
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
58 %!test
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
59 %! x = [3, 0, -3];
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
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
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
62
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
63 %!test
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
64 %! x = [3, 0, -3, 4, 0, -4, 5, 0, -5];
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
65 %! y = [-2, -2, -2, 1, 1, 1, 3, 3, 3];
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
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
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
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 ()
19136
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
8b7b4f58199f [project @ 2008-01-15 20:49:09 by jwe]
jwe
parents: 7017
diff changeset
71