Mercurial > octave
annotate test/recursion.tst @ 31198:863730dd0f83 stable
nextpow2: Fix for input between 0.5 and 1 (bug #62947).
* scripts/general/nextpow2.m: Switch to a naïve implementation using log2 with
a single output argument and ceil.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 24 Aug 2022 17:15:34 +0200 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
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 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
3 ## Copyright (C) 2006-2022 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/>. |
7016 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24325
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
7016 | 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:
24325
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:
22323
diff
changeset
|
13 ## (at your option) any later version. |
7016 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
7016 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
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:
24325
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 ######################################################################## |
7016 | 25 |
5590 | 26 %!function y = f (x) |
27 %! if (x == 1) | |
28 %! y = x; | |
29 %! return; | |
30 %! else | |
31 %! y = x * f (x-1); | |
32 %! endif | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
33 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 %! |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
35 %!assert (f (5), 120) |
5590 | 36 |
37 %!function y = f (x) | |
38 %! if (x == 1) | |
39 %! y = x; | |
40 %! return; | |
41 %! else | |
42 %! y = f (x-1) * x; | |
43 %! endif | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
44 %!endfunction |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
45 %! |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
46 %!assert (f (5), 120) |
5590 | 47 |
24325
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
48 %!function r = f (x) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
49 %! persistent p = 1; |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
50 %! if (x == 1) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
51 %! f (x + 1); |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
52 %! r = p; |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
53 %! else |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
54 %! clear p |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
55 %! p = 13; |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
56 %! endif |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
57 %!endfunction |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
58 %! |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
59 %!error <'p' undefined> f (1) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
60 |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
61 %!function r = f (x) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
62 %! persistent p = 1; |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
63 %! if (x == 1) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
64 %! f (x + 1); |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
65 %! r = p; |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
66 %! else |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
67 %! p = 13; |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
68 %! endif |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
69 %!endfunction |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
70 %! |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
71 %!assert (f (1), 13) |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
72 |
bc65aa8a5ff1
don't store persistent variables separately in scope object
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
73 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
74 %%FIXME: Need test for maximum recursion depth |