Mercurial > octave
annotate libinterp/corefcn/mappers.cc @ 24529:ed9a04087328
test: Use new constant for acos(2) in BIST tests of acos.
* mappers.cc: Use Mathematica variable precision to create an 18-digit constant
for acos(2) used in BIST tests.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 05 Jan 2018 14:57:03 -0800 |
parents | d511f7e15652 |
children | a6753fc10731 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1993-2017 John W. Eaton |
11523 | 4 Copyright (C) 2009-2010 VZLU Prague |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22498
diff
changeset
|
9 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22498
diff
changeset
|
10 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22498
diff
changeset
|
11 (at your option) any later version. |
1 | 12 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22498
diff
changeset
|
13 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22498
diff
changeset
|
14 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22498
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22498
diff
changeset
|
16 GNU General Public License for more details. |
1 | 17 |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21580
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
25 # include "config.h" |
1 | 26 #endif |
27 | |
2089 | 28 #include <cctype> |
1 | 29 |
4524 | 30 #include "lo-ieee.h" |
3156 | 31 #include "lo-specfun.h" |
2889 | 32 #include "lo-mappers.h" |
33 | |
1352 | 34 #include "defun.h" |
35 #include "error.h" | |
2955 | 36 #include "variables.h" |
1 | 37 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
38 DEFUN (abs, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
39 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
40 @deftypefn {} {} abs (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
41 Compute the magnitude of @var{z}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
42 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
43 The magnitude is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
44 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
45 $|z| = \sqrt{x^2 + y^2}$. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
46 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
47 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
48 |@var{z}| = @code{sqrt (x^2 + y^2)}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
49 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
50 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
51 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
52 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
53 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
54 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
55 abs (3 + 4i) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
56 @result{} 5 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
57 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
58 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
59 @seealso{arg} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
60 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
61 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
62 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
63 print_usage (); |
529 | 64 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
65 return ovl (args(0).abs ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
66 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
67 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
68 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
69 %!assert (abs (1), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
70 %!assert (abs (-3.5), 3.5) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
71 %!assert (abs (3+4i), 5) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
72 %!assert (abs (3-4i), 5) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
73 %!assert (abs ([1.1, 3i; 3+4i, -3-4i]), [1.1, 3; 5, 5]) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
74 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
75 %!assert (abs (single (1)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
76 %!assert (abs (single (-3.5)), single (3.5)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
77 %!assert (abs (single (3+4i)), single (5)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
78 %!assert (abs (single (3-4i)), single (5)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
79 %!assert (abs (single ([1.1, 3i; 3+4i, -3-4i])), single ([1.1, 3; 5, 5])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
80 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
81 %!error abs () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
82 %!error abs (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
83 */ |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
84 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
85 DEFUN (acos, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
86 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
87 @deftypefn {} {} acos (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
88 Compute the inverse cosine in radians for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
89 @seealso{cos, acosd} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
90 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
91 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
92 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
93 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
94 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
95 return ovl (args(0).acos ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
96 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
97 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
98 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
99 %!shared rt2, rt3 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
100 %! rt2 = sqrt (2); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
101 %! rt3 = sqrt (3); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
102 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
103 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
104 %! x = [1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
105 %! v = [0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
106 %! assert (acos (x), v, sqrt (eps)); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
107 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
108 %!test |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
109 %! x = single ([1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
110 %! v = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
111 %! assert (acos (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
112 |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
113 ## Test values on either side of branch cut |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
114 %!test |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
115 %! rval = 0; |
24529
ed9a04087328
test: Use new constant for acos(2) in BIST tests of acos.
Rik <rik@octave.org>
parents:
23995
diff
changeset
|
116 %! ival = 1.31695789692481671; |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
117 %! obs = acos ([2, 2-i*eps, 2+i*eps]); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
118 %! exp = [rval + ival*i, rval + ival*i, rval - ival*i]; |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
119 %! assert (obs, exp, 2*eps); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
120 %! rval = pi; |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
121 %! obs = acos ([-2, -2-i*eps, -2+i*eps]); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
122 %! exp = [rval - ival*i, rval + ival*i, rval - ival*i]; |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
123 %! assert (obs, exp, 2*eps); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
124 %! assert (acos ([2 0]), [ival*i, pi/2], 2*eps); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
125 %! assert (acos ([2 0i]), [ival*i, pi/2], 2*eps); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
126 |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
127 ## Test large magnitude arguments (bug #45507) |
23995
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
128 ## Test fails with older versions of libm, solution is to upgrade. |
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
129 %!test <*45507> |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
130 %! x = [1, -1, i, -i] .* 1e150; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
131 %! v = [0, pi, pi/2, pi/2]; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
132 %! assert (real (acos (x)), v); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
133 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
134 %!error acos () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
135 %!error acos (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
136 */ |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
137 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
138 DEFUN (acosh, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
139 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
140 @deftypefn {} {} acosh (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
141 Compute the inverse hyperbolic cosine for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
142 @seealso{cosh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
143 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
144 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
145 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
146 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
147 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
148 return ovl (args(0).acosh ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
149 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
150 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
151 /* |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
152 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
153 %! x = [1, 0, -1, 0]; |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
154 %! v = [0, pi/2*i, pi*i, pi/2*i]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
155 %! assert (acosh (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
156 |
22498
4d9c371d2cca
test: Mark acosh BIST tests with bug number 49091.
Rik <rik@octave.org>
parents:
22489
diff
changeset
|
157 ## FIXME: std::acosh on Windows platforms, returns a result that differs |
4d9c371d2cca
test: Mark acosh BIST tests with bug number 49091.
Rik <rik@octave.org>
parents:
22489
diff
changeset
|
158 ## by 1 in the last significant digit. This is ~30*eps which is quite large. |
4d9c371d2cca
test: Mark acosh BIST tests with bug number 49091.
Rik <rik@octave.org>
parents:
22489
diff
changeset
|
159 ## The decision now (9/15/2016) is to mark the test with a bug number so |
4d9c371d2cca
test: Mark acosh BIST tests with bug number 49091.
Rik <rik@octave.org>
parents:
22489
diff
changeset
|
160 ## it is understood why it is failing, and wait for MinGw to improve their |
4d9c371d2cca
test: Mark acosh BIST tests with bug number 49091.
Rik <rik@octave.org>
parents:
22489
diff
changeset
|
161 ## std library. |
4d9c371d2cca
test: Mark acosh BIST tests with bug number 49091.
Rik <rik@octave.org>
parents:
22489
diff
changeset
|
162 %!test <49091> |
19730
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
163 %! re = 2.99822295029797; |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
164 %! im = pi/2; |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
165 %! assert (acosh (-10i), re - i*im); |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
166 |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
167 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
168 %! x = single ([1, 0, -1, 0]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
169 %! v = single ([0, pi/2*i, pi*i, pi/2*i]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
170 %! assert (acosh (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
171 |
22498
4d9c371d2cca
test: Mark acosh BIST tests with bug number 49091.
Rik <rik@octave.org>
parents:
22489
diff
changeset
|
172 %!test <49091> |
19730
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
173 %! re = single (2.99822295029797); |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
174 %! im = single (pi/2); |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
175 %! assert (acosh (single (10i)), re + i*im, 5*eps ("single")); |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
176 %! assert (acosh (single (-10i)), re - i*im, 5*eps ("single")); |
554aaaf99644
Fix return phase of acosh to match Matlab (bug #44286).
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
177 |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
178 ## Test large magnitude arguments (bug #45507) |
23995
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
179 ## Test fails with older versions of libm, solution is to upgrade. |
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
180 %!test <*45507> |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
181 %! x = [1, -1, i, -i] .* 1e150; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
182 %! v = [0, pi, pi/2, -pi/2]; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
183 %! assert (imag (acosh (x)), v); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
184 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
185 %!error acosh () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
186 %!error acosh (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
187 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
188 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
189 DEFUN (angle, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
190 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
191 @deftypefn {} {} angle (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
192 See @code{arg}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
193 @seealso{arg} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
194 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
195 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
196 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
197 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
198 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
199 return ovl (args(0).arg ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
200 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
201 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
202 DEFUN (arg, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
203 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
204 @deftypefn {} {} arg (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
205 @deftypefnx {} {} angle (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
206 Compute the argument, i.e., angle of @var{z}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
207 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
208 This is defined as, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
209 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
210 $\theta = atan2 (y, x),$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
211 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
212 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
213 @var{theta} = @code{atan2 (@var{y}, @var{x})}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
214 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
215 in radians. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
216 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
217 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
218 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
219 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
220 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
221 arg (3 + 4i) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
222 @result{} 0.92730 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
223 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
224 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
225 @seealso{abs} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
226 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
227 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
228 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
229 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
230 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
231 return ovl (args(0).arg ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
232 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
233 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
234 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
235 %!assert (arg (1), 0) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
236 %!assert (arg (i), pi/2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
237 %!assert (arg (-1), pi) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
238 %!assert (arg (-i), -pi/2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
239 %!assert (arg ([1, i; -1, -i]), [0, pi/2; pi, -pi/2]) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
240 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
241 %!assert (arg (single (1)), single (0)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
242 %!assert (arg (single (i)), single (pi/2)) |
13093
1a21c4c5eeeb
Fix tolerance for mappers.cc test on MacOS.
Ben Abbott <bpabbott@mac.com>
parents:
12894
diff
changeset
|
243 %!test |
1a21c4c5eeeb
Fix tolerance for mappers.cc test on MacOS.
Ben Abbott <bpabbott@mac.com>
parents:
12894
diff
changeset
|
244 %! if (ismac ()) |
1a21c4c5eeeb
Fix tolerance for mappers.cc test on MacOS.
Ben Abbott <bpabbott@mac.com>
parents:
12894
diff
changeset
|
245 %! ## Avoid failing for a MacOS feature |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
246 %! assert (arg (single (-1)), single (pi), 2*eps (single (1))); |
13093
1a21c4c5eeeb
Fix tolerance for mappers.cc test on MacOS.
Ben Abbott <bpabbott@mac.com>
parents:
12894
diff
changeset
|
247 %! else |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
248 %! assert (arg (single (-1)), single (pi)); |
13093
1a21c4c5eeeb
Fix tolerance for mappers.cc test on MacOS.
Ben Abbott <bpabbott@mac.com>
parents:
12894
diff
changeset
|
249 %! endif |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
250 %!assert (arg (single (-i)), single (-pi/2)) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
251 %!assert (arg (single ([1, i; -1, -i])), single ([0, pi/2; pi, -pi/2]), 2e1*eps ("single")) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
252 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
253 %!error arg () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
254 %!error arg (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
255 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
256 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
257 DEFUN (asin, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
258 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
259 @deftypefn {} {} asin (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
260 Compute the inverse sine in radians for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
261 @seealso{sin, asind} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
262 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
263 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
264 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
265 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
266 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
267 return ovl (args(0).asin ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
268 } |
529 | 269 |
7385 | 270 /* |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
271 %!shared rt2, rt3 |
7385 | 272 %! rt2 = sqrt (2); |
273 %! rt3 = sqrt (3); | |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
274 |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
275 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
276 %! x = [0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]; |
7385 | 277 %! v = [0, pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6, 0]; |
19242
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
278 %! assert (asin (x), v, sqrt (eps)); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
279 |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
280 %!test |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
281 %! x = single ([0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
282 %! v = single ([0, pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6, 0]); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
283 %! assert (asin (x), v, sqrt (eps ("single"))); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
284 |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
285 ## Test values on either side of branch cut |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
286 %!test |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
287 %! rval = pi/2; |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
288 %! ival = 1.31695789692481635; |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
289 %! obs = asin ([2, 2-i*eps, 2+i*eps]); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
290 %! exp = [rval - ival*i, rval - ival*i, rval + ival*i]; |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
291 %! assert (obs, exp, 2*eps); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
292 %! obs = asin ([-2, -2-i*eps, -2+i*eps]); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
293 %! exp = [-rval + ival*i, -rval - ival*i, -rval + ival*i]; |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
294 %! assert (obs, exp, 2*eps); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
295 %! assert (asin ([2 0]), [rval - ival*i, 0], 2*eps); |
ba7e42dea4b2
Fix returned phase of asin, acos outside principal branch (bug #43349).
Rik <rik@octave.org>
parents:
19151
diff
changeset
|
296 %! assert (asin ([2 0i]), [rval - ival*i, 0], 2*eps); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
297 |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
298 ## Test large magnitude arguments (bug #45507) |
23995
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
299 ## Test fails with older versions of libm, solution is to upgrade. |
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
300 %!test <*45507> |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
301 %! x = [1, -1, i, -i] .* 1e150; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
302 %! v = [pi/2, -pi/2, 0, -0]; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
303 %! assert (real (asin (x)), v); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
304 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
305 %!error asin () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
306 %!error asin (1, 2) |
7385 | 307 */ |
308 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
309 DEFUN (asinh, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
310 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
311 @deftypefn {} {} asinh (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
312 Compute the inverse hyperbolic sine for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
313 @seealso{sinh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
314 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
315 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
316 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
317 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
318 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
319 return ovl (args(0).asinh ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
320 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
321 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
322 /* |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
323 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
324 %! v = [0, pi/2*i, 0, -pi/2*i]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
325 %! x = [0, i, 0, -i]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
326 %! assert (asinh (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
327 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
328 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
329 %! v = single ([0, pi/2*i, 0, -pi/2*i]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
330 %! x = single ([0, i, 0, -i]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
331 %! assert (asinh (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
332 |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
333 ## Test large magnitude arguments (bug #45507) |
23995
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
334 ## Test fails with older versions of libm, solution is to upgrade. |
d511f7e15652
Change xtests for bug #45507 to regular tests and mark as fixed.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
335 %!test <*45507> |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
336 %! x = [1, -1, i, -i] .* 1e150; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
337 %! v = [0, 0, pi/2, -pi/2]; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
338 %! assert (imag (asinh (x)), v); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
339 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
340 %!error asinh () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
341 %!error asinh (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
342 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
343 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
344 DEFUN (atan, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
345 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
346 @deftypefn {} {} atan (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
347 Compute the inverse tangent in radians for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
348 @seealso{tan, atand} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
349 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
350 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
351 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
352 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
353 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
354 return ovl (args(0).atan ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
355 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
356 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
357 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
358 %!shared rt2, rt3 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
359 %! rt2 = sqrt (2); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
360 %! rt3 = sqrt (3); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
361 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
362 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
363 %! v = [0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
364 %! x = [0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
365 %! assert (atan (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
366 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
367 %!test |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
368 %! v = single ([0, pi/6, pi/4, pi/3, -pi/3, -pi/4, -pi/6, 0]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
369 %! x = single ([0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
370 %! assert (atan (x), v, sqrt (eps ("single"))); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
371 |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
372 ## Test large magnitude arguments (bug #44310, bug #45507) |
23573
1b4f4ec53b4a
use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents:
23572
diff
changeset
|
373 %!test <*44310> |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
374 %! x = [1, -1, i, -i] .* 1e150; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
375 %! v = [pi/2, -pi/2, pi/2, -pi/2]; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
376 %! assert (real (atan (x)), v); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
377 %! assert (imag (atan (x)), [0, 0, 0, 0], eps); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
378 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
379 %!error atan () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
380 %!error atan (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
381 */ |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
382 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
383 DEFUN (atanh, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
384 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
385 @deftypefn {} {} atanh (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
386 Compute the inverse hyperbolic tangent for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
387 @seealso{tanh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
388 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
389 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
390 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
391 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
392 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
393 return ovl (args(0).atanh ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
394 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
395 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
396 /* |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
397 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
398 %! v = [0, 0]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
399 %! x = [0, 0]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
400 %! assert (atanh (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
401 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
402 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
403 %! v = single ([0, 0]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
404 %! x = single ([0, 0]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
405 %! assert (atanh (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
406 |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
407 ## Test large magnitude arguments (bug #44310, bug #45507) |
23573
1b4f4ec53b4a
use new script to tag fixed bugs in tests
John W. Eaton <jwe@octave.org>
parents:
23572
diff
changeset
|
408 %!test <*44310> |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
409 %! x = [1, -1, i, -i] .* 1e150; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
410 %! v = [pi/2, pi/2, pi/2, -pi/2]; |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
411 %! assert (imag (atanh (x)), v); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
412 %! assert (real (atanh (x)), [0, 0, 0, 0], eps); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21724
diff
changeset
|
413 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
414 %!error atanh () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
415 %!error atanh (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
416 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
417 |
10414
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
418 DEFUN (cbrt, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
419 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
420 @deftypefn {} {} cbrt (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
421 Compute the real cube root of each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
422 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
423 Unlike @code{@var{x}^(1/3)}, the result will be negative if @var{x} is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
424 negative. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
425 @seealso{nthroot} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
426 @end deftypefn */) |
10414
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
427 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
428 if (args.length () != 1) |
10414
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
429 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
430 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
431 return ovl (args(0).cbrt ()); |
10414
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
432 } |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
433 |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
434 /* |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
435 %!assert (cbrt (64), 4) |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
436 %!assert (cbrt (-125), -5) |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
437 %!assert (cbrt (0), 0) |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
438 %!assert (cbrt (Inf), Inf) |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
439 %!assert (cbrt (-Inf), -Inf) |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
440 %!assert (cbrt (NaN), NaN) |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
441 %!assert (cbrt (2^300), 2^100) |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
442 %!assert (cbrt (125*2^300), 5*2^100) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
443 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
444 %!error cbrt () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
445 %!error cbrt (1, 2) |
10414
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
446 */ |
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
447 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
448 DEFUN (ceil, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
449 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
450 @deftypefn {} {} ceil (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
451 Return the smallest integer not less than @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
452 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
453 This is equivalent to rounding towards positive infinity. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
454 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
455 If @var{x} is complex, return |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
456 @code{ceil (real (@var{x})) + ceil (imag (@var{x})) * I}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
457 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
458 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
459 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
460 ceil ([-2.7, 2.7]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
461 @result{} -2 3 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
462 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
463 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
464 @seealso{floor, round, fix} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
465 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
466 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
467 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
468 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
469 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
470 return ovl (args(0).ceil ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
471 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
472 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
473 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
474 ## double precision |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
475 %!assert (ceil ([2, 1.1, -1.1, -1]), [2, 2, -1, -1]) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
476 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
477 ## complex double precison |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
478 %!assert (ceil ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i]), [2+2i, 2+2i, -1-i, -1-i]) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
479 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
480 ## single precision |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
481 %!assert (ceil (single ([2, 1.1, -1.1, -1])), single ([2, 2, -1, -1])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
482 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
483 ## complex single precision |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
484 %!assert (ceil (single ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i])), single ([2+2i, 2+2i, -1-i, -1-i])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
485 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
486 %!error ceil () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
487 %!error ceil (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
488 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
489 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
490 DEFUN (conj, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
491 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
492 @deftypefn {} {} conj (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
493 Return the complex conjugate of @var{z}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
494 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
495 The complex conjugate is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
496 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
497 $\bar{z} = x - iy$. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
498 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
499 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
500 @code{conj (@var{z})} = @var{x} - @var{i}@var{y}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
501 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
502 @seealso{real, imag} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
503 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
504 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
505 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
506 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
507 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
508 return ovl (args(0).conj ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
509 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
510 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
511 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
512 %!assert (conj (1), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
513 %!assert (conj (i), -i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
514 %!assert (conj (1+i), 1-i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
515 %!assert (conj (1-i), 1+i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
516 %!assert (conj ([-1, -i; -1+i, -1-i]), [-1, i; -1-i, -1+i]) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
517 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
518 %!assert (conj (single (1)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
519 %!assert (conj (single (i)), single (-i)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
520 %!assert (conj (single (1+i)), single (1-i)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
521 %!assert (conj (single (1-i)), single (1+i)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
522 %!assert (conj (single ([-1, -i; -1+i, -1-i])), single ([-1, i; -1-i, -1+i])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
523 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
524 %!error conj () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
525 %!error conj (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
526 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
527 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
528 DEFUN (cos, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
529 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
530 @deftypefn {} {} cos (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
531 Compute the cosine for each element of @var{x} in radians. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
532 @seealso{acos, cosd, cosh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
533 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
534 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
535 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
536 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
537 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
538 return ovl (args(0).cos ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
539 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
540 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
541 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
542 %!shared rt2, rt3 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
543 %! rt2 = sqrt (2); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
544 %! rt3 = sqrt (3); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
545 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
546 %!test |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
547 %! x = [0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
548 %! v = [1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
549 %! assert (cos (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
550 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
551 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
552 %! rt2 = sqrt (2); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
553 %! rt3 = sqrt (3); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
554 %! x = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
555 %! v = single ([1, rt3/2, rt2/2, 1/2, 0, -1/2, -rt2/2, -rt3/2, -1]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
556 %! assert (cos (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
557 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
558 %!error cos () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
559 %!error cos (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
560 */ |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
561 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
562 DEFUN (cosh, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
563 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
564 @deftypefn {} {} cosh (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
565 Compute the hyperbolic cosine for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
566 @seealso{acosh, sinh, tanh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
567 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
568 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
569 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
570 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
571 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
572 return ovl (args(0).cosh ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
573 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
574 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
575 /* |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
576 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
577 %! x = [0, pi/2*i, pi*i, 3*pi/2*i]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
578 %! v = [1, 0, -1, 0]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
579 %! assert (cosh (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
580 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
581 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
582 %! x = single ([0, pi/2*i, pi*i, 3*pi/2*i]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
583 %! v = single ([1, 0, -1, 0]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
584 %! assert (cosh (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
585 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
586 %!error cosh () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
587 %!error cosh (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
588 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
589 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
590 DEFUN (erf, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
591 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
592 @deftypefn {} {} erf (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
593 Compute the error function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
594 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
595 The error function is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
596 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
597 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
598 {\rm erf} (z) = {2 \over \sqrt{\pi}}\int_0^z e^{-t^2} dt |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
599 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
600 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
601 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
602 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
603 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
604 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
605 z |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
606 2 / |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
607 erf (z) = --------- * | e^(-t^2) dt |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
608 sqrt (pi) / |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
609 t=0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
610 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
611 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
612 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
613 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
614 @seealso{erfc, erfcx, erfi, dawson, erfinv, erfcinv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
615 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
616 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
617 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
618 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
619 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
620 return ovl (args(0).erf ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
621 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
622 |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
623 /* |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
624 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
625 %! a = -1i*sqrt (-1/(6.4187*6.4187)); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
626 %! assert (erf (a), erf (real (a))); |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
627 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
628 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
629 %! x = [0,.5,1]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
630 %! v = [0, .520499877813047, .842700792949715]; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
631 %! assert (erf (x), v, 1.e-10); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
632 %! assert (erf (-x), -v, 1.e-10); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
633 %! assert (erfc (x), 1-v, 1.e-10); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
634 %! assert (erfinv (v), x, 1.e-10); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
635 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
636 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
637 %! a = -1i*sqrt (single (-1/(6.4187*6.4187))); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
638 %! assert (erf (a), erf (real (a))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
639 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
640 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
641 %! x = single ([0,.5,1]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
642 %! v = single ([0, .520499877813047, .842700792949715]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
643 %! assert (erf (x), v, 1.e-6); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
644 %! assert (erf (-x), -v, 1.e-6); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
645 %! assert (erfc (x), 1-v, 1.e-6); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
646 %! assert (erfinv (v), x, 1.e-6); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
647 |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
648 %!test |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
649 %! x = [1+2i,-1+2i,1e-6+2e-6i,0+2i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
650 %! v = [-0.53664356577857-5.04914370344703i, 0.536643565778565-5.04914370344703i, 0.112837916709965e-5+0.225675833419178e-5i, 18.5648024145755526i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
651 %! assert (erf (x), v, -1.e-10); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
652 %! assert (erf (-x), -v, -1.e-10); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
653 %! assert (erfc (x), 1-v, -1.e-10); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
654 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
655 %!error erf () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
656 %!error erf (1, 2) |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
657 */ |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
658 |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
659 DEFUN (erfinv, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
660 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
661 @deftypefn {} {} erfinv (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
662 Compute the inverse error function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
663 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
664 The inverse error function is defined such that |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
665 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
666 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
667 erf (@var{y}) == @var{x} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
668 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
669 @seealso{erf, erfc, erfcx, erfi, dawson, erfcinv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
670 @end deftypefn */) |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
671 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
672 if (args.length () != 1) |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
673 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
674 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
675 return ovl (args(0).erfinv ()); |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
676 } |
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
677 |
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
678 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
679 ## middle region |
10049
44e889c67abe
mappers.cc: Change test tolerance from 1e-16 to eps.
Ben Abbott <bpabbott@mac.com>
parents:
9835
diff
changeset
|
680 %!assert (erf (erfinv ([-0.9 -0.3 0 0.4 0.8])), [-0.9 -0.3 0 0.4 0.8], eps) |
14771
10ed11922f19
maint: code cleanup for new erfcinv function.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
681 %!assert (erf (erfinv (single ([-0.9 -0.3 0 0.4 0.8]))), single ([-0.9 -0.3 0 0.4 0.8]), eps ("single")) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
682 ## tail region |
10049
44e889c67abe
mappers.cc: Change test tolerance from 1e-16 to eps.
Ben Abbott <bpabbott@mac.com>
parents:
9835
diff
changeset
|
683 %!assert (erf (erfinv ([-0.999 -0.99 0.9999 0.99999])), [-0.999 -0.99 0.9999 0.99999], eps) |
14771
10ed11922f19
maint: code cleanup for new erfcinv function.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
684 %!assert (erf (erfinv (single ([-0.999 -0.99 0.9999 0.99999]))), single ([-0.999 -0.99 0.9999 0.99999]), eps ("single")) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
685 ## backward - loss of accuracy |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
686 %!assert (erfinv (erf ([-3 -1 -0.4 0.7 1.3 2.8])), [-3 -1 -0.4 0.7 1.3 2.8], -1e-12) |
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
687 %!assert (erfinv (erf (single ([-3 -1 -0.4 0.7 1.3 2.8]))), single ([-3 -1 -0.4 0.7 1.3 2.8]), -1e-4) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
688 ## exceptional |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
689 %!assert (erfinv ([-1, 1, 1.1, -2.1]), [-Inf, Inf, NaN, NaN]) |
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
690 %!error erfinv (1+2i) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
691 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
692 %!error erfinv () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
693 %!error erfinv (1, 2) |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
694 */ |
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
695 |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
696 DEFUN (erfcinv, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
697 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
698 @deftypefn {} {} erfcinv (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
699 Compute the inverse complementary error function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
700 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
701 The inverse complementary error function is defined such that |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
702 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
703 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
704 erfc (@var{y}) == @var{x} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
705 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
706 @seealso{erfc, erf, erfcx, erfi, dawson, erfinv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
707 @end deftypefn */) |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
708 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
709 if (args.length () != 1) |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
710 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
711 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
712 return ovl (args(0).erfcinv ()); |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
713 } |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
714 |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
715 /* |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
716 ## middle region |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
717 %!assert (erfc (erfcinv ([1.9 1.3 1 0.6 0.2])), [1.9 1.3 1 0.6 0.2], eps) |
14771
10ed11922f19
maint: code cleanup for new erfcinv function.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
718 %!assert (erfc (erfcinv (single ([1.9 1.3 1 0.6 0.2]))), single ([1.9 1.3 1 0.6 0.2]), eps ("single")) |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
719 ## tail region |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
720 %!assert (erfc (erfcinv ([0.001 0.01 1.9999 1.99999])), [0.001 0.01 1.9999 1.99999], eps) |
14771
10ed11922f19
maint: code cleanup for new erfcinv function.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
721 %!assert (erfc (erfcinv (single ([0.001 0.01 1.9999 1.99999]))), single ([0.001 0.01 1.9999 1.99999]), eps ("single")) |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
722 ## backward - loss of accuracy |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
723 %!assert (erfcinv (erfc ([-3 -1 -0.4 0.7 1.3 2.8])), [-3 -1 -0.4 0.7 1.3 2.8], -1e-12) |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
724 %!assert (erfcinv (erfc (single ([-3 -1 -0.4 0.7 1.3 2.8]))), single ([-3 -1 -0.4 0.7 1.3 2.8]), -1e-4) |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
725 ## exceptional |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
726 %!assert (erfcinv ([2, 0, -0.1, 2.1]), [-Inf, Inf, NaN, NaN]) |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
727 %!error erfcinv (1+2i) |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
728 |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
729 %!error erfcinv () |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
730 %!error erfcinv (1, 2) |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
731 */ |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14437
diff
changeset
|
732 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
733 DEFUN (erfc, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
734 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
735 @deftypefn {} {} erfc (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
736 Compute the complementary error function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
737 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
738 The complementary error function is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
739 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
740 $1 - {\rm erf} (z)$. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
741 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
742 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
743 @w{@code{1 - erf (@var{z})}}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
744 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
745 @seealso{erfcinv, erfcx, erfi, dawson, erf, erfinv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
746 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
747 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
748 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
749 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
750 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
751 return ovl (args(0).erfc ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
752 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
753 |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
754 /* |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
755 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
756 %! a = -1i*sqrt (-1/(6.4187*6.4187)); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
757 %! assert (erfc (a), erfc (real (a))); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
758 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
759 %!error erfc () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
760 %!error erfc (1, 2) |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
761 */ |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
762 |
10391
59e34bcdff13
implement built-in erfcx
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
763 DEFUN (erfcx, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
764 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
765 @deftypefn {} {} erfcx (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
766 Compute the scaled complementary error function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
767 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
768 The scaled complementary error function is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
769 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
770 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
771 e^{z^2} {\rm erfc} (z) \equiv e^{z^2} (1 - {\rm erf} (z)) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
772 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
773 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
774 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
775 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
776 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
777 exp (z^2) * erfc (z) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
778 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
779 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
780 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
781 @seealso{erfc, erf, erfi, dawson, erfinv, erfcinv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
782 @end deftypefn */) |
10391
59e34bcdff13
implement built-in erfcx
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
783 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
784 if (args.length () != 1) |
10391
59e34bcdff13
implement built-in erfcx
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
785 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
786 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
787 return ovl (args(0).erfcx ()); |
10391
59e34bcdff13
implement built-in erfcx
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
788 } |
59e34bcdff13
implement built-in erfcx
Jaroslav Hajek <highegg@gmail.com>
parents:
10160
diff
changeset
|
789 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
790 /* |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
791 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
792 %!test |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
793 %! x = [1+2i,-1+2i,1e-6+2e-6i,0+2i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
794 %! assert (erfcx (x), exp (x.^2) .* erfc(x), -1.e-10); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
795 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
796 %!test |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
797 %! x = [100, 100+20i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
798 %! v = [0.0056416137829894329, 0.0054246791754558-0.00108483153786434i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
799 %! assert (erfcx (x), v, -1.e-10); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
800 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
801 %!error erfcx () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
802 %!error erfcx (1, 2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
803 */ |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
804 |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
805 DEFUN (erfi, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
806 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
807 @deftypefn {} {} erfi (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
808 Compute the imaginary error function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
809 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
810 The imaginary error function is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
811 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
812 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
813 -i {\rm erf} (iz) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
814 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
815 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
816 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
817 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
818 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
819 -i * erf (i*z) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
820 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
821 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
822 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
823 @seealso{erfc, erf, erfcx, dawson, erfinv, erfcinv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
824 @end deftypefn */) |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
825 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
826 if (args.length () != 1) |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
827 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
828 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
829 return ovl (args(0).erfi ()); |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
830 } |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
831 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
832 /* |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
833 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
834 %!test |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
835 %! x = [-0.1, 0.1, 1, 1+2i,-1+2i,1e-6+2e-6i,0+2i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
836 %! assert (erfi (x), -i * erf(i*x), -1.e-10); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
837 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
838 %!error erfi () |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
839 %!error erfi (1, 2) |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
840 */ |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
841 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
842 DEFUN (dawson, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
843 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
844 @deftypefn {} {} dawson (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
845 Compute the Dawson (scaled imaginary error) function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
846 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
847 The Dawson function is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
848 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
849 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
850 {\sqrt{\pi} \over 2} e^{-z^2} {\rm erfi} (z) \equiv -i {\sqrt{\pi} \over 2} e^{-z^2} {\rm erf} (iz) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
851 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
852 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
853 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
854 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
855 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
856 (sqrt (pi) / 2) * exp (-z^2) * erfi (z) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
857 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
858 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
859 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
860 @seealso{erfc, erf, erfcx, erfi, erfinv, erfcinv} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
861 @end deftypefn */) |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
862 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
863 if (args.length () != 1) |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
864 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
865 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
866 return ovl (args(0).dawson ()); |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
867 } |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
868 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
869 /* |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
870 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
871 %!test |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
872 %! x = [0.1, 1, 1+2i,-1+2i,1e-4+2e-4i,0+2i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
873 %! v = [0.099335992397852861, 0.53807950691, -13.38892731648-11.828715104i, 13.38892731648-11.828715104i, 0.0001000000073333+0.000200000001333i, 48.160012114291i]; |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
874 %! assert (dawson (x), v, -1.e-10); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
875 %! assert (dawson (-x), -v, -1.e-10); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
876 |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
877 %!error dawson () |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
878 %!error dawson (1, 2) |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
879 */ |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15500
diff
changeset
|
880 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
881 DEFUN (exp, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
882 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
883 @deftypefn {} {} exp (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
884 Compute |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
885 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
886 $e^{x}$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
887 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
888 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
889 @code{e^x} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
890 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
891 for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
892 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
893 To compute the matrix exponential, see @ref{Linear Algebra}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
894 @seealso{log} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
895 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
896 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
897 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
898 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
899 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
900 return ovl (args(0).exp ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
901 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
902 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
903 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
904 %!assert (exp ([0, 1, -1, -1000]), [1, e, 1/e, 0], sqrt (eps)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
905 %!assert (exp (1+i), e * (cos (1) + sin (1) * i), sqrt (eps)) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
906 %!assert (exp (single ([0, 1, -1, -1000])), single ([1, e, 1/e, 0]), sqrt (eps ("single"))) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
907 %!assert (exp (single (1+i)), single (e * (cos (1) + sin (1) * i)), sqrt (eps ("single"))) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
908 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
909 %!assert (exp ([Inf, -Inf, NaN]), [Inf 0 NaN]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
910 %!assert (exp (single ([Inf, -Inf, NaN])), single ([Inf 0 NaN])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
911 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
912 %!error exp () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
913 %!error exp (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
914 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
915 |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
916 DEFUN (expm1, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
917 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
918 @deftypefn {} {} expm1 (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
919 Compute |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
920 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
921 $ e^{x} - 1 $ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
922 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
923 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
924 @code{exp (@var{x}) - 1} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
925 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
926 accurately in the neighborhood of zero. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
927 @seealso{exp} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
928 @end deftypefn */) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
929 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
930 if (args.length () != 1) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
931 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
932 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
933 return ovl (args(0).expm1 ()); |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
934 } |
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
935 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
936 /* |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
937 %!assert (expm1 (2*eps), 2*eps, 1e-29) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
938 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
939 %!assert (expm1 ([Inf, -Inf, NaN]), [Inf -1 NaN]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
940 %!assert (expm1 (single ([Inf, -Inf, NaN])), single ([Inf -1 NaN])) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
941 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
942 %!error expm1 () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
943 %!error expm1 (1, 2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
944 */ |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
945 |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11327
diff
changeset
|
946 DEFUN (isfinite, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
947 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
948 @deftypefn {} {} isfinite (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
949 Return a logical array which is true where the elements of @var{x} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
950 finite values and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
951 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
952 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
953 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
954 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
955 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
956 isfinite ([13, Inf, NA, NaN]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
957 @result{} [ 1, 0, 0, 0 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
958 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
959 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
960 @seealso{isinf, isnan, isna} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
961 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
962 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
963 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
964 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
965 |
21013
7f4c6d594e3d
Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
966 return ovl (args(0).isfinite ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
967 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
968 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
969 /* |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
970 %!assert (! isfinite (Inf)) |
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
971 %!assert (! isfinite (NaN)) |
19117
a4c226a963c5
Deprecate finite in favor of isfinite.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
972 %!assert (isfinite (rand (1,10))) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
973 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
974 %!assert (! isfinite (single (Inf))) |
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
975 %!assert (! isfinite (single (NaN))) |
19117
a4c226a963c5
Deprecate finite in favor of isfinite.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
976 %!assert (isfinite (single (rand (1,10)))) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
977 |
19117
a4c226a963c5
Deprecate finite in favor of isfinite.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
978 %!error isfinite () |
a4c226a963c5
Deprecate finite in favor of isfinite.
Rik <rik@octave.org>
parents:
18812
diff
changeset
|
979 %!error isfinite (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
980 */ |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
981 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
982 DEFUN (fix, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
983 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
984 @deftypefn {} {} fix (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
985 Truncate fractional portion of @var{x} and return the integer portion. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
986 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
987 This is equivalent to rounding towards zero. If @var{x} is complex, return |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
988 @code{fix (real (@var{x})) + fix (imag (@var{x})) * I}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
989 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
990 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
991 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
992 fix ([-2.7, 2.7]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
993 @result{} -2 2 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
994 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
995 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
996 @seealso{ceil, floor, round} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
997 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
998 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
999 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1000 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1001 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1002 return ovl (args(0).fix ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1003 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1004 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1005 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1006 %!assert (fix ([1.1, 1, -1.1, -1]), [1, 1, -1, -1]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1007 %!assert (fix ([1.1+1.1i, 1+i, -1.1-1.1i, -1-i]), [1+i, 1+i, -1-i, -1-i]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1008 %!assert (fix (single ([1.1, 1, -1.1, -1])), single ([1, 1, -1, -1])) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1009 %!assert (fix (single ([1.1+1.1i, 1+i, -1.1-1.1i, -1-i])), single ([1+i, 1+i, -1-i, -1-i])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1010 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1011 %!error fix () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1012 %!error fix (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1013 */ |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1014 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1015 DEFUN (floor, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1016 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1017 @deftypefn {} {} floor (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1018 Return the largest integer not greater than @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1019 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1020 This is equivalent to rounding towards negative infinity. If @var{x} is |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1021 complex, return @code{floor (real (@var{x})) + floor (imag (@var{x})) * I}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1022 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1023 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1024 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1025 floor ([-2.7, 2.7]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1026 @result{} -3 2 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1027 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1028 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1029 @seealso{ceil, round, fix} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1030 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1031 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1032 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1033 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1034 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1035 return ovl (args(0).floor ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1036 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1037 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1038 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1039 %!assert (floor ([2, 1.1, -1.1, -1]), [2, 1, -2, -1]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1040 %!assert (floor ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i]), [2+2i, 1+i, -2-2i, -1-i]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1041 %!assert (floor (single ([2, 1.1, -1.1, -1])), single ([2, 1, -2, -1])) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1042 %!assert (floor (single ([2+2i, 1.1+1.1i, -1.1-1.1i, -1-i])), single ([2+2i, 1+i, -2-2i, -1-i])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1043 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1044 %!error floor () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1045 %!error floor (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1046 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1047 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1048 DEFUN (gamma, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1049 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1050 @deftypefn {} {} gamma (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1051 Compute the Gamma function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1052 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1053 The Gamma function is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1054 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1055 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1056 \Gamma (z) = \int_0^\infty t^{z-1} e^{-t} dt. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1057 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1058 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1059 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1060 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1061 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1062 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1063 infinity |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1064 / |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1065 gamma (z) = | t^(z-1) exp (-t) dt. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1066 / |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1067 t=0 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1068 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1069 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1070 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1071 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1072 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1073 Programming Note: The gamma function can grow quite large even for small |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1074 input values. In many cases it may be preferable to use the natural |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1075 logarithm of the gamma function (@code{gammaln}) in calculations to minimize |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1076 loss of precision. The final result is then |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1077 @code{exp (@var{result_using_gammaln}).} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1078 @seealso{gammainc, gammaln, factorial} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1079 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1080 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1081 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1082 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1083 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1084 return ovl (args(0).gamma ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1085 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1086 |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1087 /* |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1088 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1089 %! a = -1i*sqrt (-1/(6.4187*6.4187)); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1090 %! assert (gamma (a), gamma (real (a))); |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1091 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1092 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1093 %! x = [.5, 1, 1.5, 2, 3, 4, 5]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1094 %! v = [sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1095 %! assert (gamma (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1096 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1097 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1098 %! a = single (-1i*sqrt (-1/(6.4187*6.4187))); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1099 %! assert (gamma (a), gamma (real (a))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1100 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1101 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1102 %! x = single ([.5, 1, 1.5, 2, 3, 4, 5]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1103 %! v = single ([sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1104 %! assert (gamma (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1105 |
10903
9f0f1a89c704
Add new %!tests for negative integer arguments to gamma, lgamma.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
1106 %!test |
17708
f10b7a578e2c
Correct return values of gamma() (see Numerical, item 3 on Projects page).
Craig Hudson <c_hudson_phd@hotmail.com>
parents:
16816
diff
changeset
|
1107 %! ## Test exceptional values |
f10b7a578e2c
Correct return values of gamma() (see Numerical, item 3 on Projects page).
Craig Hudson <c_hudson_phd@hotmail.com>
parents:
16816
diff
changeset
|
1108 %! x = [-Inf, -1, -0, 0, 1, Inf, NaN]; |
19357
c6437824681c
improve Matlab compatibility for gamma function (bug #43551)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
1109 %! v = [Inf, Inf, -Inf, Inf, 1, Inf, NaN]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1110 %! assert (gamma (x), v); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1111 %! assert (gamma (single (x)), single (v)); |
10903
9f0f1a89c704
Add new %!tests for negative integer arguments to gamma, lgamma.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
1112 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1113 %!error gamma () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1114 %!error gamma (1, 2) |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1115 */ |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1116 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1117 DEFUN (imag, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1118 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1119 @deftypefn {} {} imag (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1120 Return the imaginary part of @var{z} as a real number. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1121 @seealso{real, conj} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1122 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1123 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1124 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1125 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1126 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1127 return ovl (args(0).imag ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1128 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1129 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1130 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1131 %!assert (imag (1), 0) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1132 %!assert (imag (i), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1133 %!assert (imag (1+i), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1134 %!assert (imag ([i, 1; 1, i]), full (eye (2))) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1135 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1136 %!assert (imag (single (1)), single (0)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1137 %!assert (imag (single (i)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1138 %!assert (imag (single (1+i)), single (1)) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1139 %!assert (imag (single ([i, 1; 1, i])), full (eye (2,"single"))) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1140 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1141 %!error imag () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1142 %!error imag (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1143 */ |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1144 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1145 DEFUNX ("isalnum", Fisalnum, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1146 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1147 @deftypefn {} {} isalnum (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1148 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1149 letters or digits and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1150 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1151 This is equivalent to (@code{isalpha (@var{s}) | isdigit (@var{s})}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1152 @seealso{isalpha, isdigit, ispunct, isspace, iscntrl} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1153 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1154 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1155 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1156 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1157 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1158 return ovl (args(0).xisalnum ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1159 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1160 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1161 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1162 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1163 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1164 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1165 %! result(toascii ("A":"Z") + 1) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1166 %! result(toascii ("0":"9") + 1) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1167 %! result(toascii ("a":"z") + 1) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1168 %! assert (isalnum (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1169 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1170 %!error isalnum () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1171 %!error isalnum (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1172 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1173 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1174 DEFUNX ("isalpha", Fisalpha, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1175 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1176 @deftypefn {} {} isalpha (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1177 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1178 letters and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1179 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1180 This is equivalent to (@code{islower (@var{s}) | isupper (@var{s})}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1181 @seealso{isdigit, ispunct, isspace, iscntrl, isalnum, islower, isupper} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1182 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1183 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1184 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1185 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1186 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1187 return ovl (args(0).xisalpha ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1188 } |
2089 | 1189 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1190 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1191 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1192 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1193 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1194 %! result(toascii ("A":"Z") + 1) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1195 %! result(toascii ("a":"z") + 1) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1196 %! assert (isalpha (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1197 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1198 %!error isalpha () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1199 %!error isalpha (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1200 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1201 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1202 DEFUNX ("isascii", Fisascii, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1203 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1204 @deftypefn {} {} isascii (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1205 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1206 ASCII characters (in the range 0 to 127 decimal) and false where they are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1207 not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1208 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1209 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1210 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1211 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1212 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1213 return ovl (args(0).xisascii ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1214 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1215 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1216 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1217 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1218 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1219 %! result = true (1, 128); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1220 %! assert (isascii (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1221 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1222 %!error isascii () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1223 %!error isascii (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1224 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1225 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1226 DEFUNX ("iscntrl", Fiscntrl, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1227 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1228 @deftypefn {} {} iscntrl (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1229 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1230 control characters and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1231 @seealso{ispunct, isspace, isalpha, isdigit} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1232 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1233 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1234 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1235 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1236 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1237 return ovl (args(0).xiscntrl ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1238 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1239 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1240 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1241 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1242 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1243 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1244 %! result(1:32) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1245 %! result(128) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1246 %! assert (iscntrl (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1247 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1248 %!error iscntrl () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1249 %!error iscntrl (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1250 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1251 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1252 DEFUNX ("isdigit", Fisdigit, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1253 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1254 @deftypefn {} {} isdigit (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1255 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1256 decimal digits (0-9) and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1257 @seealso{isxdigit, isalpha, isletter, ispunct, isspace, iscntrl} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1258 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1259 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1260 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1261 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1262 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1263 return ovl (args(0).xisdigit ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1264 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1265 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1266 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1267 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1268 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1269 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1270 %! result(toascii ("0":"9") + 1) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1271 %! assert (isdigit (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1272 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1273 %!error isdigit () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1274 %!error isdigit (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1275 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1276 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1277 DEFUN (isinf, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1278 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1279 @deftypefn {} {} isinf (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1280 Return a logical array which is true where the elements of @var{x} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1281 infinite and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1282 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1283 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1284 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1285 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1286 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1287 isinf ([13, Inf, NA, NaN]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1288 @result{} [ 0, 1, 0, 0 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1289 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1290 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1291 @seealso{isfinite, isnan, isna} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1292 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1293 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1294 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1295 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1296 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1297 return ovl (args(0).isinf ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1298 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1299 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1300 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1301 %!assert (isinf (Inf)) |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1302 %!assert (! isinf (NaN)) |
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1303 %!assert (! isinf (NA)) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14817
diff
changeset
|
1304 %!assert (isinf (rand (1,10)), false (1,10)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1305 %!assert (isinf ([NaN -Inf -1 0 1 Inf NA]), [false, true, false, false, false, true, false]) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1306 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1307 %!assert (isinf (single (Inf))) |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1308 %!assert (! isinf (single (NaN))) |
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1309 %!assert (! isinf (single (NA))) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14817
diff
changeset
|
1310 %!assert (isinf (single (rand (1,10))), false (1,10)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1311 %!assert (isinf (single ([NaN -Inf -1 0 1 Inf NA])), [false, true, false, false, false, true, false]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1312 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1313 %!error isinf () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1314 %!error isinf (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1315 */ |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1316 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1317 DEFUNX ("isgraph", Fisgraph, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1318 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1319 @deftypefn {} {} isgraph (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1320 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1321 printable characters (but not the space character) and false where they are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1322 not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1323 @seealso{isprint} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1324 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1325 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1326 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1327 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1328 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1329 return ovl (args(0).xisgraph ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1330 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1331 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1332 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1333 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1334 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1335 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1336 %! result(34:127) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1337 %! assert (isgraph (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1338 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1339 %!error isgraph () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1340 %!error isgraph (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1341 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1342 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1343 DEFUNX ("islower", Fislower, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1344 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1345 @deftypefn {} {} islower (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1346 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1347 lowercase letters and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1348 @seealso{isupper, isalpha, isletter, isalnum} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1349 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1350 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1351 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1352 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1353 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1354 return ovl (args(0).xislower ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1355 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1356 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1357 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1358 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1359 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1360 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1361 %! result(toascii ("a":"z") + 1) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1362 %! assert (islower (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1363 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1364 %!error islower () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1365 %!error islower (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1366 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1367 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1368 DEFUN (isna, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1369 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1370 @deftypefn {} {} isna (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1371 Return a logical array which is true where the elements of @var{x} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1372 NA (missing) values and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1373 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1374 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1375 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1376 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1377 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1378 isna ([13, Inf, NA, NaN]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1379 @result{} [ 0, 0, 1, 0 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1380 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1381 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1382 @seealso{isnan, isinf, isfinite} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1383 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1384 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1385 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1386 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1387 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1388 return ovl (args(0).isna ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1389 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1390 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1391 /* |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1392 %!assert (! isna (Inf)) |
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1393 %!assert (! isna (NaN)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1394 %!assert (isna (NA)) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14817
diff
changeset
|
1395 %!assert (isna (rand (1,10)), false (1,10)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1396 %!assert (isna ([NaN -Inf -1 0 1 Inf NA]), [false, false, false, false, false, false, true]) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1397 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1398 %!assert (! isna (single (Inf))) |
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1399 %!assert (! isna (single (NaN))) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1400 %!assert (isna (single (NA))) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14817
diff
changeset
|
1401 %!assert (isna (single (rand (1,10))), false (1,10)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1402 %!assert (isna (single ([NaN -Inf -1 0 1 Inf NA])), [false, false, false, false, false, false, true]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1403 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1404 %!error isna () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1405 %!error isna (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1406 */ |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1407 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1408 DEFUN (isnan, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1409 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1410 @deftypefn {} {} isnan (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1411 Return a logical array which is true where the elements of @var{x} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1412 NaN values and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1413 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1414 NA values are also considered NaN values. For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1415 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1416 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1417 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1418 isnan ([13, Inf, NA, NaN]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1419 @result{} [ 0, 0, 1, 1 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1420 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1421 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1422 @seealso{isna, isinf, isfinite} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1423 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1424 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1425 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1426 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1427 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1428 return ovl (args(0).isnan ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1429 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1430 |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1431 /* |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1432 %!assert (! isnan (Inf)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1433 %!assert (isnan (NaN)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1434 %!assert (isnan (NA)) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14817
diff
changeset
|
1435 %!assert (isnan (rand (1,10)), false (1,10)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1436 %!assert (isnan ([NaN -Inf -1 0 1 Inf NA]), [true, false, false, false, false, false, true]) |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1437 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
1438 %!assert (! isnan (single (Inf))) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1439 %!assert (isnan (single (NaN))) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1440 %!assert (isnan (single (NA))) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14817
diff
changeset
|
1441 %!assert (isnan (single (rand (1,10))), false (1,10)) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1442 %!assert (isnan (single ([NaN -Inf -1 0 1 Inf NA])), [true, false, false, false, false, false, true]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1443 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1444 %!error isnan () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1445 %!error isnan (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1446 */ |
7814
87865ed7405f
Second set of single precision test code and fix of resulting bugs
David Bateman <dbateman@free.fr>
parents:
7667
diff
changeset
|
1447 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1448 DEFUNX ("isprint", Fisprint, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1449 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1450 @deftypefn {} {} isprint (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1451 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1452 printable characters (including the space character) and false where they |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1453 are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1454 @seealso{isgraph} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1455 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1456 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1457 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1458 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1459 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1460 return ovl (args(0).xisprint ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1461 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1462 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1463 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1464 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1465 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1466 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1467 %! result(33:127) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1468 %! assert (isprint (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1469 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1470 %!error isprint () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1471 %!error isprint (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1472 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1473 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1474 DEFUNX ("ispunct", Fispunct, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1475 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1476 @deftypefn {} {} ispunct (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1477 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1478 punctuation characters and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1479 @seealso{isalpha, isdigit, isspace, iscntrl} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1480 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1481 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1482 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1483 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1484 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1485 return ovl (args(0).xispunct ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1486 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1487 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1488 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1489 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1490 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1491 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1492 %! result(34:48) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1493 %! result(59:65) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1494 %! result(92:97) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1495 %! result(124:127) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1496 %! assert (ispunct (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1497 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1498 %!error ispunct () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1499 %!error ispunct (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1500 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1501 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1502 DEFUNX ("isspace", Fisspace, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1503 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1504 @deftypefn {} {} isspace (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1505 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1506 whitespace characters (space, formfeed, newline, carriage return, tab, and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1507 vertical tab) and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1508 @seealso{iscntrl, ispunct, isalpha, isdigit} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1509 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1510 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1511 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1512 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1513 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1514 return ovl (args(0).xisspace ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1515 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1516 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1517 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1518 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1519 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1520 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1521 %! result(toascii (" \f\n\r\t\v") + 1) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1522 %! assert (isspace (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1523 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1524 %!error isspace () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1525 %!error isspace (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1526 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1527 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1528 DEFUNX ("isupper", Fisupper, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1529 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1530 @deftypefn {} {} isupper (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1531 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1532 uppercase letters and false where they are not. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1533 @seealso{islower, isalpha, isletter, isalnum} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1534 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1535 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1536 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1537 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1538 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1539 return ovl (args(0).xisupper ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1540 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1541 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1542 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1543 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1544 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1545 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1546 %! result(toascii ("A":"Z") + 1) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1547 %! assert (isupper (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1548 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1549 %!error isupper () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1550 %!error isupper (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1551 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1552 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
1553 DEFUNX ("isxdigit", Fisxdigit, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1554 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1555 @deftypefn {} {} isxdigit (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1556 Return a logical array which is true where the elements of @var{s} are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1557 hexadecimal digits (0-9 and @nospell{a-fA-F}). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1558 @seealso{isdigit} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1559 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1560 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1561 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1562 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1563 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1564 return ovl (args(0).xisxdigit ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1565 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1566 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1567 /* |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1568 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
1569 %! charset = char (0:127); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1570 %! result = false (1, 128); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1571 %! result(toascii ("A":"F") + 1) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1572 %! result(toascii ("0":"9") + 1) = true; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1573 %! result(toascii ("a":"f") + 1) = true; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1574 %! assert (isxdigit (charset), result); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1575 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1576 %!error isxdigit () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1577 %!error isxdigit (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1578 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1579 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1580 DEFUN (lgamma, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1581 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1582 @deftypefn {} {} gammaln (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1583 @deftypefnx {} {} lgamma (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1584 Return the natural logarithm of the gamma function of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1585 @seealso{gamma, gammainc} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1586 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1587 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1588 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1589 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1590 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1591 return ovl (args(0).lgamma ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1592 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1593 |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1594 /* |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1595 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1596 %! a = -1i*sqrt (-1/(6.4187*6.4187)); |
19275
653ed3a6ba83
Use gammaln in preference to lgamma in core Octave code.
Rik <rik@octave.org>
parents:
19242
diff
changeset
|
1597 %! assert (gammaln (a), gammaln (real (a))); |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1598 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1599 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1600 %! x = [.5, 1, 1.5, 2, 3, 4, 5]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1601 %! v = [sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]; |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
1602 %! assert (gammaln (x), log (v), sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1603 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1604 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1605 %! a = single (-1i*sqrt (-1/(6.4187*6.4187))); |
19275
653ed3a6ba83
Use gammaln in preference to lgamma in core Octave code.
Rik <rik@octave.org>
parents:
19242
diff
changeset
|
1606 %! assert (gammaln (a), gammaln (real (a))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1607 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1608 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1609 %! x = single ([.5, 1, 1.5, 2, 3, 4, 5]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1610 %! v = single ([sqrt(pi), 1, .5*sqrt(pi), 1, 2, 6, 24]); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
1611 %! assert (gammaln (x), log (v), sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1612 |
10903
9f0f1a89c704
Add new %!tests for negative integer arguments to gamma, lgamma.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
1613 %!test |
9f0f1a89c704
Add new %!tests for negative integer arguments to gamma, lgamma.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
1614 %! x = [-1, 0, 1, Inf]; |
9f0f1a89c704
Add new %!tests for negative integer arguments to gamma, lgamma.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
1615 %! v = [Inf, Inf, 0, Inf]; |
19275
653ed3a6ba83
Use gammaln in preference to lgamma in core Octave code.
Rik <rik@octave.org>
parents:
19242
diff
changeset
|
1616 %! assert (gammaln (x), v); |
653ed3a6ba83
Use gammaln in preference to lgamma in core Octave code.
Rik <rik@octave.org>
parents:
19242
diff
changeset
|
1617 %! assert (gammaln (single (x)), single (v)); |
10903
9f0f1a89c704
Add new %!tests for negative integer arguments to gamma, lgamma.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
1618 |
19275
653ed3a6ba83
Use gammaln in preference to lgamma in core Octave code.
Rik <rik@octave.org>
parents:
19242
diff
changeset
|
1619 %!error gammaln () |
653ed3a6ba83
Use gammaln in preference to lgamma in core Octave code.
Rik <rik@octave.org>
parents:
19242
diff
changeset
|
1620 %!error gammaln (1,2) |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1621 */ |
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1622 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1623 DEFUN (log, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1624 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1625 @deftypefn {} {} log (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1626 Compute the natural logarithm, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1627 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1628 $\ln{(x)},$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1629 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1630 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1631 @code{ln (@var{x})}, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1632 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1633 for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1634 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1635 To compute the matrix logarithm, see @ref{Linear Algebra}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1636 @seealso{exp, log1p, log2, log10, logspace} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1637 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1638 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1639 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1640 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1641 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1642 return ovl (args(0).log ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1643 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1644 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1645 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1646 %!assert (log ([1, e, e^2]), [0, 1, 2], sqrt (eps)) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1647 %!assert (log ([-0.5, -1.5, -2.5]), log ([0.5, 1.5, 2.5]) + pi*1i, sqrt (eps)) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1648 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1649 %!assert (log (single ([1, e, e^2])), single ([0, 1, 2]), sqrt (eps ("single"))) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1650 %!assert (log (single ([-0.5, -1.5, -2.5])), single (log ([0.5, 1.5, 2.5]) + pi*1i), 4*eps ("single")) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1651 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1652 %!error log () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1653 %!error log (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1654 */ |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1655 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1656 DEFUN (log10, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1657 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1658 @deftypefn {} {} log10 (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1659 Compute the base-10 logarithm of each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1660 @seealso{log, log2, logspace, exp} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1661 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1662 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1663 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1664 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1665 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1666 return ovl (args(0).log10 ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1667 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1668 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1669 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1670 %!assert (log10 ([0.01, 0.1, 1, 10, 100]), [-2, -1, 0, 1, 2], sqrt (eps)) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1671 %!assert (log10 (single ([0.01, 0.1, 1, 10, 100])), single ([-2, -1, 0, 1, 2]), sqrt (eps ("single"))) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1672 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1673 %!error log10 () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1674 %!error log10 (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1675 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1676 |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1677 DEFUN (log1p, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1678 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1679 @deftypefn {} {} log1p (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1680 Compute |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1681 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1682 $\ln{(1 + x)}$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1683 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1684 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1685 @code{log (1 + @var{x})} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1686 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1687 accurately in the neighborhood of zero. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1688 @seealso{log, exp, expm1} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1689 @end deftypefn */) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1690 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1691 if (args.length () != 1) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1692 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1693 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1694 return ovl (args(0).log1p ()); |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1695 } |
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7636
diff
changeset
|
1696 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1697 /* |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1698 %!assert (log1p ([0, 2*eps, -2*eps]), [0, 2*eps, -2*eps], 1e-29) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1699 %!assert (log1p (single ([0, 2*eps, -2*eps])), single ([0, 2*eps, -2*eps]), 1e-29) |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1700 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1701 %!error log1p () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1702 %!error log1p (1, 2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1703 */ |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1704 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1705 DEFUN (real, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1706 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1707 @deftypefn {} {} real (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1708 Return the real part of @var{z}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1709 @seealso{imag, conj} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1710 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1711 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1712 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1713 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1714 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1715 return ovl (args(0).real ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1716 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1717 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1718 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1719 %!assert (real (1), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1720 %!assert (real (i), 0) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1721 %!assert (real (1+i), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1722 %!assert (real ([1, i; i, 1]), full (eye (2))) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1723 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1724 %!assert (real (single (1)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1725 %!assert (real (single (i)), single (0)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1726 %!assert (real (single (1+i)), single (1)) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1727 %!assert (real (single ([1, i; i, 1])), full (eye (2, "single"))) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1728 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1729 %!error real () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1730 %!error real (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1731 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1732 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1733 DEFUN (round, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1734 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1735 @deftypefn {} {} round (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1736 Return the integer nearest to @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1737 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1738 If @var{x} is complex, return |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1739 @code{round (real (@var{x})) + round (imag (@var{x})) * I}. If there |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1740 are two nearest integers, return the one further away from zero. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1741 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1742 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1743 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1744 round ([-2.7, 2.7]) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1745 @result{} -3 3 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1746 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1747 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1748 @seealso{ceil, floor, fix, roundb} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1749 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1750 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1751 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1752 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1753 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1754 return ovl (args(0).round ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1755 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1756 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1757 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1758 %!assert (round (1), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1759 %!assert (round (1.1), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1760 %!assert (round (5.5), 6) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1761 %!assert (round (i), i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1762 %!assert (round (2.5+3.5i), 3+4i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1763 %!assert (round (-2.6), -3) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1764 %!assert (round ([1.1, -2.4; -3.7, 7.1]), [1, -2; -4, 7]) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1765 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1766 %!assert (round (single (1)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1767 %!assert (round (single (1.1)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1768 %!assert (round (single (5.5)), single (6)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1769 %!assert (round (single (i)), single (i)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1770 %!assert (round (single (2.5+3.5i)), single (3+4i)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1771 %!assert (round (single (-2.6)), single (-3)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1772 %!assert (round (single ([1.1, -2.4; -3.7, 7.1])), single ([1, -2; -4, 7])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1773 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1774 %!error round () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1775 %!error round (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1776 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1777 |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
1778 DEFUN (roundb, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1779 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1780 @deftypefn {} {} roundb (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1781 Return the integer nearest to @var{x}. If there are two nearest |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1782 integers, return the even one (banker's rounding). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1783 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1784 If @var{x} is complex, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1785 return @code{roundb (real (@var{x})) + roundb (imag (@var{x})) * I}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1786 @seealso{round} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1787 @end deftypefn */) |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
1788 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1789 if (args.length () != 1) |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
1790 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1791 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1792 return ovl (args(0).roundb ()); |
7636
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
1793 } |
99c410f7f0b0
implement mapper function for banker's rounding
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
1794 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1795 /* |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1796 %!assert (roundb (1), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1797 %!assert (roundb (1.1), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1798 %!assert (roundb (1.5), 2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1799 %!assert (roundb (4.5), 4) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1800 %!assert (roundb (i), i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1801 %!assert (roundb (2.5+3.5i), 2+4i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1802 %!assert (roundb (-2.6), -3) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1803 %!assert (roundb ([1.1, -2.4; -3.7, 7.1]), [1, -2; -4, 7]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1804 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1805 %!assert (roundb (single (1)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1806 %!assert (roundb (single (1.1)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1807 %!assert (roundb (single (1.5)), single (2)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1808 %!assert (roundb (single (4.5)), single (4)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1809 %!assert (roundb (single (i)), single (i)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1810 %!assert (roundb (single (2.5+3.5i)), single (2+4i)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1811 %!assert (roundb (single (-2.6)), single (-3)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1812 %!assert (roundb (single ([1.1, -2.4; -3.7, 7.1])), single ([1, -2; -4, 7])) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1813 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1814 %!error roundb () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1815 %!error roundb (1, 2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1816 */ |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1817 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1818 DEFUN (sign, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1819 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1820 @deftypefn {} {} sign (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1821 Compute the @dfn{signum} function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1822 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1823 This is defined as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1824 @tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1825 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1826 {\rm sign} (@var{x}) = \cases{1,&$x>0$;\cr 0,&$x=0$;\cr -1,&$x<0$.\cr} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1827 $$ |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1828 @end tex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1829 @ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1830 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1831 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1832 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1833 -1, x < 0; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1834 sign (x) = 0, x = 0; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1835 1, x > 0. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1836 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1837 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1838 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1839 @end ifnottex |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1840 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1841 For complex arguments, @code{sign} returns @code{x ./ abs (@var{x})}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1842 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1843 Note that @code{sign (-0.0)} is 0. Although IEEE 754 floating point |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1844 allows zero to be signed, 0.0 and -0.0 compare equal. If you must test |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1845 whether zero is signed, use the @code{signbit} function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1846 @seealso{signbit} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1847 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1848 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1849 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1850 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1851 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1852 return ovl (args(0).signum ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1853 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1854 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1855 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1856 %!assert (sign (-2) , -1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1857 %!assert (sign (0), 0) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1858 %!assert (sign (3), 1) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1859 %!assert (sign ([1, -pi; e, 0]), [1, -1; 1, 0]) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1860 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1861 %!assert (sign (single (-2)) , single (-1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1862 %!assert (sign (single (0)), single (0)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1863 %!assert (sign (single (3)), single (1)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1864 %!assert (sign (single ([1, -pi; e, 0])), single ([1, -1; 1, 0])) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1865 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1866 %!error sign () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1867 %!error sign (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1868 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1869 |
15487
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1870 DEFUNX ("signbit", Fsignbit, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1871 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1872 @deftypefn {} {} signbit (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1873 Return logical true if the value of @var{x} has its sign bit set and false |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1874 otherwise. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1875 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1876 This behavior is consistent with the other logical functions. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1877 See @ref{Logical Values}. The behavior differs from the C language function |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1878 which returns nonzero if the sign bit is set. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1879 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1880 This is not the same as @code{x < 0.0}, because IEEE 754 floating point |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1881 allows zero to be signed. The comparison @code{-0.0 < 0.0} is false, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1882 but @code{signbit (-0.0)} will return a nonzero value. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1883 @seealso{sign} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1884 @end deftypefn */) |
15487
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1885 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1886 if (args.length () != 1) |
15487
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1887 print_usage (); |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1888 |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1889 octave_value tmp = args(0).xsignbit (); |
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1890 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1891 return ovl (tmp != 0); |
15487
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1892 } |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1893 |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1894 /* |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1895 %!assert (signbit (1) == 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1896 %!assert (signbit (-2) != 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1897 %!assert (signbit (0) == 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1898 %!assert (signbit (-0) != 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1899 |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1900 %!assert (signbit (single (1)) == 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1901 %!assert (signbit (single (-2)) != 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1902 %!assert (signbit (single (0)) == 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1903 %!assert (signbit (single (-0)) != 0) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1904 |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1905 %!error sign () |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1906 %!error sign (1, 2) |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1907 */ |
ecf5be238b4a
provide signbit mapper for real values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1908 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1909 DEFUN (sin, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1910 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1911 @deftypefn {} {} sin (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1912 Compute the sine for each element of @var{x} in radians. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1913 @seealso{asin, sind, sinh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1914 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1915 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1916 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1917 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1918 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1919 return ovl (args(0).sin ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1920 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1921 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1922 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1923 %!shared rt2, rt3 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1924 %! rt2 = sqrt (2); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1925 %! rt3 = sqrt (3); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1926 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1927 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1928 %! x = [0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1929 %! v = [0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1930 %! assert (sin (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1931 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1932 %!test |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1933 %! x = single ([0, pi/6, pi/4, pi/3, pi/2, 2*pi/3, 3*pi/4, 5*pi/6, pi]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1934 %! v = single ([0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1935 %! assert (sin (x), v, sqrt (eps ("single"))); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1936 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1937 %!error sin () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1938 %!error sin (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1939 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1940 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1941 DEFUN (sinh, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1942 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1943 @deftypefn {} {} sinh (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1944 Compute the hyperbolic sine for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1945 @seealso{asinh, cosh, tanh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1946 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1947 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1948 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1949 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1950 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1951 return ovl (args(0).sinh ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1952 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1953 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1954 /* |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1955 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1956 %! x = [0, pi/2*i, pi*i, 3*pi/2*i]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1957 %! v = [0, i, 0, -i]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1958 %! assert (sinh (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1959 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1960 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1961 %! x = single ([0, pi/2*i, pi*i, 3*pi/2*i]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1962 %! v = single ([0, i, 0, -i]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1963 %! assert (sinh (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1964 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1965 %!error sinh () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1966 %!error sinh (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
1967 */ |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1968 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1969 DEFUN (sqrt, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1970 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1971 @deftypefn {} {} sqrt (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1972 Compute the square root of each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1973 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1974 If @var{x} is negative, a complex result is returned. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1975 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1976 To compute the matrix square root, see @ref{Linear Algebra}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1977 @seealso{realsqrt, nthroot} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
1978 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1979 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
1980 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1981 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
1982 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
1983 return ovl (args(0).sqrt ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1984 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
1985 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1986 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1987 %!assert (sqrt (4), 2) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1988 %!assert (sqrt (-1), i) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1989 %!assert (sqrt (1+i), exp (0.5 * log (1+i)), sqrt (eps)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1990 %!assert (sqrt ([4, -4; i, 1-i]), [2, 2i; exp(0.5 * log (i)), exp(0.5 * log (1-i))], sqrt (eps)) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1991 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1992 %!assert (sqrt (single (4)), single (2)) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1993 %!assert (sqrt (single (-1)), single (i)) |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1994 %!assert (sqrt (single (1+i)), single (exp (0.5 * log (1+i))), sqrt (eps ("single"))) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
1995 %!assert (sqrt (single ([4, -4; i, 1-i])), single ([2, 2i; exp(0.5 * log (i)), exp(0.5 * log (1-i))]), sqrt (eps ("single"))) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1996 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1997 %!error sqrt () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
1998 %!error sqrt (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
1999 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2000 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2001 DEFUN (tan, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2002 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2003 @deftypefn {} {} tan (@var{z}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2004 Compute the tangent for each element of @var{x} in radians. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2005 @seealso{atan, tand, tanh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2006 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2007 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
2008 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2009 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
2010 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
2011 return ovl (args(0).tan ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2012 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2013 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2014 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2015 %!shared rt2, rt3 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2016 %! rt2 = sqrt (2); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2017 %! rt3 = sqrt (3); |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2018 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2019 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2020 %! x = [0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2021 %! v = [0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]; |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2022 %! assert (tan (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2023 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2024 %!test |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2025 %! x = single ([0, pi/6, pi/4, pi/3, 2*pi/3, 3*pi/4, 5*pi/6, pi]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2026 %! v = single ([0, rt3/3, 1, rt3, -rt3, -1, -rt3/3, 0]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2027 %! assert (tan (x), v, sqrt (eps ("single"))); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2028 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2029 %!error tan () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2030 %!error tan (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2031 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2032 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2033 DEFUN (tanh, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2034 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2035 @deftypefn {} {} tanh (@var{x}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2036 Compute hyperbolic tangent for each element of @var{x}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2037 @seealso{atanh, sinh, cosh} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2038 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2039 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
2040 if (args.length () != 1) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2041 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
2042 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
2043 return ovl (args(0).tanh ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2044 } |
1562 | 2045 |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2046 /* |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2047 %!test |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2048 %! x = [0, pi*i]; |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2049 %! v = [0, 0]; |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2050 %! assert (tanh (x), v, sqrt (eps)); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2051 |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2052 %!test |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2053 %! x = single ([0, pi*i]); |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2054 %! v = single ([0, 0]); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2055 %! assert (tanh (x), v, sqrt (eps ("single"))); |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2056 |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2057 %!error tanh () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2058 %!error tanh (1, 2) |
7815
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2059 */ |
a41df65f3f00
Add some single precision test code and fix resulting bugs
David Bateman <dbateman@free.fr>
parents:
7814
diff
changeset
|
2060 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
2061 DEFUNX ("toascii", Ftoascii, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2062 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2063 @deftypefn {} {} toascii (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2064 Return ASCII representation of @var{s} in a matrix. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2065 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2066 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2067 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2068 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2069 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2070 toascii ("ASCII") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2071 @result{} [ 65, 83, 67, 73, 73 ] |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2072 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2073 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2074 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2075 @seealso{char} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2076 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2077 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
2078 if (args.length () != 1) |
12892
67bf9b30f3f9
Error when given non-string input to tolower, toupper, toascii (Bug #33537).
Rik <octave@nomad.inbox5.com>
parents:
12683
diff
changeset
|
2079 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
2080 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
2081 return ovl (args(0).xtoascii ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2082 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2083 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
2084 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2085 %!assert (toascii (char (0:127)), 0:127) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2086 %!assert (toascii (" ":"@"), 32:64) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2087 %!assert (toascii ("A":"Z"), 65:90) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2088 %!assert (toascii ("[":"`"), 91:96) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2089 %!assert (toascii ("a":"z"), 97:122) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2090 %!assert (toascii ("{":"~"), 123:126) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2091 |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2092 %!error toascii () |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2093 %!error toascii (1, 2) |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
2094 */ |
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
2095 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
2096 DEFUNX ("tolower", Ftolower, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2097 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2098 @deftypefn {} {} tolower (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2099 @deftypefnx {} {} lower (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2100 Return a copy of the string or cell string @var{s}, with each uppercase |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2101 character replaced by the corresponding lowercase one; non-alphabetic |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2102 characters are left unchanged. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2103 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2104 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2105 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2106 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2107 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2108 tolower ("MiXeD cAsE 123") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2109 @result{} "mixed case 123" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2110 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2111 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2112 @seealso{toupper} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2113 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2114 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
2115 if (args.length () != 1) |
12892
67bf9b30f3f9
Error when given non-string input to tolower, toupper, toascii (Bug #33537).
Rik <octave@nomad.inbox5.com>
parents:
12683
diff
changeset
|
2116 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
2117 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
2118 return ovl (args(0).xtolower ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2119 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2120 |
8387
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2121 DEFALIAS (lower, tolower); |
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2122 |
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2123 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2124 %!assert (tolower ("OCTAVE"), "octave") |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
2125 %!assert (tolower ("123OCTave! _&"), "123octave! _&") |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2126 %!assert (tolower ({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}}) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2127 %!assert (tolower (["ABC"; "DEF"]), ["abc"; "def"]) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2128 %!assert (tolower ({["ABC"; "DEF"]}), {["abc";"def"]}) |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2129 %!assert (tolower (68), 68) |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2130 %!assert (tolower ({[68, 68; 68, 68]}), {[68, 68; 68, 68]}) |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2131 %!test |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2132 %! classes = {@char, @double, @single, ... |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2133 %! @int8, @int16, @int32, @int64, ... |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2134 %! @uint8, @uint16, @uint32, @uint64}; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2135 %! for i = 1:numel (classes) |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2136 %! cls = classes{i}; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2137 %! assert (class (tolower (cls (97))), class (cls (97))); |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2138 %! assert (class (tolower (cls ([98, 99]))), class (cls ([98, 99]))); |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2139 %! endfor |
8387
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2140 %!test |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2141 %! a(3,3,3,3) = "D"; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2142 %! assert (tolower (a)(3,3,3,3), "d"); |
8387
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2143 |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
2144 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
2145 %! charset = char (0:127); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
2146 %! result = charset; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2147 %! result (toascii ("A":"Z") + 1) = result (toascii ("a":"z") + 1); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2148 %! assert (tolower (charset), result); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2149 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2150 %!error <Invalid call to tolower> lower () |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2151 %!error <Invalid call to tolower> tolower () |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2152 %!error tolower (1, 2) |
8387
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2153 */ |
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2154 |
7528
26d8a92644de
try to avoid ctype macro problems
John W. Eaton <jwe@octave.org>
parents:
7503
diff
changeset
|
2155 DEFUNX ("toupper", Ftoupper, args, , |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2156 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2157 @deftypefn {} {} toupper (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2158 @deftypefnx {} {} upper (@var{s}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2159 Return a copy of the string or cell string @var{s}, with each lowercase |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2160 character replaced by the corresponding uppercase one; non-alphabetic |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2161 characters are left unchanged. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2162 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2163 For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2164 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2165 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2166 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2167 toupper ("MiXeD cAsE 123") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2168 @result{} "MIXED CASE 123" |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2169 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2170 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2171 @seealso{tolower} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21945
diff
changeset
|
2172 @end deftypefn */) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2173 { |
20805
2d6ddb2b157c
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20183
diff
changeset
|
2174 if (args.length () != 1) |
12892
67bf9b30f3f9
Error when given non-string input to tolower, toupper, toascii (Bug #33537).
Rik <octave@nomad.inbox5.com>
parents:
12683
diff
changeset
|
2175 print_usage (); |
20921
4d3daf7e43f3
eliminate trailing whitespace in source files
John W. Eaton <jwe@octave.org>
parents:
20853
diff
changeset
|
2176 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20921
diff
changeset
|
2177 return ovl (args(0).xtoupper ()); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2178 } |
3321 | 2179 |
8387
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2180 DEFALIAS (upper, toupper); |
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2181 |
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2182 /* |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2183 %!assert (toupper ("octave"), "OCTAVE") |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
2184 %!assert (toupper ("123OCTave! _&"), "123OCTAVE! _&") |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2185 %!assert (toupper ({"abc", "def", {"ghi", {"jkl"}}}), {"ABC", "DEF", {"GHI", {"JKL"}}}) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2186 %!assert (toupper (["abc"; "def"]), ["ABC"; "DEF"]) |
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2187 %!assert (toupper ({["abc"; "def"]}), {["ABC";"DEF"]}) |
18196
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2188 %!assert (toupper (100), 100) |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2189 %!assert (toupper ({[100, 100; 100, 100]}), {[100, 100; 100, 100]}) |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2190 %!test |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2191 %! classes = {@char, @double, @single, ... |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2192 %! @int8, @int16, @int32, @int64, ... |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2193 %! @uint8, @uint16, @uint32, @uint64}; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2194 %! for i = 1:numel (classes) |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2195 %! cls = classes{i}; |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2196 %! assert (class (toupper (cls (97))), class (cls (97))); |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2197 %! assert (class (toupper (cls ([98, 99]))), class (cls ([98, 99]))); |
1b6db9303933
allow toupper and tolower to handle numeric values (bug #33537)
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
2198 %! endfor |
8387
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2199 %!test |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2200 %! a(3,3,3,3) = "d"; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2201 %! assert (toupper (a)(3,3,3,3), "D"); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
2202 %!test |
13964
12fa52c6e886
Use char() instead of deprecated setstr() in %!test code.
Rik <octave@nomad.inbox5.com>
parents:
13929
diff
changeset
|
2203 %! charset = char (0:127); |
13140
98d23b0f16e1
maint: move test_string.m tests to source files
John W. Eaton <jwe@octave.org>
parents:
13093
diff
changeset
|
2204 %! result = charset; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2205 %! result (toascii ("a":"z") + 1) = result (toascii ("A":"Z") + 1); |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2206 %! assert (toupper (charset), result); |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2207 |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2208 %!error <Invalid call to toupper> toupper () |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14360
diff
changeset
|
2209 %!error <Invalid call to toupper> upper () |
13972
09432c6f23e7
mappers.cc: Update %!tests to modern coding standards
Rik <octave@nomad.inbox5.com>
parents:
13966
diff
changeset
|
2210 %!error toupper (1, 2) |
8387
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2211 */ |
1567db1e166c
make upper and lower aliases of toupper and tolower respectively
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
8366
diff
changeset
|
2212 |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7385
diff
changeset
|
2213 DEFALIAS (gammaln, lgamma); |