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