Mercurial > octave
annotate scripts/specfun/realpow.m @ 29359:7854d5752dd2
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 10:10:40 -0500 |
parents | d8318c12d903 0a5b15007766 |
children | 796f54d4ddbf |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 ## Copyright (C) 2008-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
7 ## |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22470
diff
changeset
|
13 ## (at your option) any later version. |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
14 ## |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22470
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22470
diff
changeset
|
18 ## GNU General Public License for more details. |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 ## |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
25 |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
27 ## @deftypefn {} {} realpow (@var{x}, @var{y}) |
19102
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
28 ## Compute the real-valued, element-by-element power operator. |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
29 ## |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
30 ## This is equivalent to @w{@code{@var{x} .^ @var{y}}}, except that |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
31 ## @code{realpow} reports an error if any return value is complex. |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
32 ## @seealso{power, reallog, realsqrt} |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
33 ## @end deftypefn |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
34 |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
35 function z = realpow (x, y) |
19102
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
36 |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
37 if (nargin != 2) |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
38 print_usage (); |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 endif |
19102
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
40 |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 z = x .^ y; |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 if (iscomplex (z)) |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 error ("realpow: produced complex result"); |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
44 endif |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
45 |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
46 endfunction |
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
47 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
48 |
19102
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
49 %!assert (realpow (1:10, 0.5:0.5:5), power (1:10, 0.5:0.5:5)) |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
50 %!assert (realpow (1:10, 0.5:0.5:5), [1:10] .^ [0.5:0.5:5]) |
7621
4682dda22527
Add the reallog, realsqrt and realpow functions
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
51 %!test |
19102
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
52 %! x = rand (10, 10); |
bb20384acf7b
doc: Overhaul documentation for some functions in specfun/ dir.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
53 %! y = randn (10, 10); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 %! assert (x.^y, realpow (x,y)); |
22470
9d4cb0cf9cd2
maint: tag xtests and tests that fail on some systems with bug numbers
Mike Miller <mtmiller@octave.org>
parents:
22323
diff
changeset
|
55 %!assert <47775> (realpow (1i,2), -1) |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 |
28886
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
57 %!error <Invalid call> realpow () |
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
58 %!error <Invalid call> realpow (1) |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 %!error <produced complex result> realpow (-1, 1/2) |