1
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
|
4 2002, 2003, 2004, 2005, 2006, 2007 John W. Eaton |
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 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
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" |
2970
|
37 #include "ov-mapper.h" |
2955
|
38 #include "variables.h" |
1
|
39 |
5775
|
40 // FIXME -- perhaps this could be avoided by determining |
2190
|
41 // whether the is* functions are actually functions or just macros. |
|
42 |
2889
|
43 static int |
4100
|
44 xabs (int c) |
|
45 { |
|
46 return static_cast<unsigned char> (c); |
|
47 } |
|
48 |
|
49 static int |
2190
|
50 xisalnum (int c) |
|
51 { |
|
52 return isalnum (c); |
|
53 } |
|
54 |
2889
|
55 static int |
2190
|
56 xisalpha (int c) |
|
57 { |
|
58 return isalpha (c); |
|
59 } |
|
60 |
2889
|
61 static int |
2190
|
62 xisascii (int c) |
|
63 { |
|
64 return isascii (c); |
|
65 } |
|
66 |
2889
|
67 static int |
2190
|
68 xiscntrl (int c) |
|
69 { |
|
70 return iscntrl (c); |
|
71 } |
|
72 |
2889
|
73 static int |
2190
|
74 xisdigit (int c) |
|
75 { |
|
76 return isdigit (c); |
|
77 } |
|
78 |
2889
|
79 static int |
2190
|
80 xisgraph (int c) |
|
81 { |
|
82 return isgraph (c); |
|
83 } |
|
84 |
2889
|
85 static int |
2190
|
86 xislower (int c) |
|
87 { |
|
88 return islower (c); |
|
89 } |
|
90 |
2889
|
91 static int |
2190
|
92 xisprint (int c) |
|
93 { |
|
94 return isprint (c); |
|
95 } |
|
96 |
2889
|
97 static int |
2190
|
98 xispunct (int c) |
|
99 { |
|
100 return ispunct (c); |
|
101 } |
|
102 |
2889
|
103 static int |
2190
|
104 xisspace (int c) |
|
105 { |
|
106 return isspace (c); |
|
107 } |
|
108 |
2889
|
109 static int |
2190
|
110 xisupper (int c) |
|
111 { |
|
112 return isupper (c); |
|
113 } |
|
114 |
2889
|
115 static int |
2190
|
116 xisxdigit (int c) |
|
117 { |
|
118 return isxdigit (c); |
|
119 } |
|
120 |
2889
|
121 static int |
2267
|
122 xtoascii (int c) |
|
123 { |
5760
|
124 return toascii (c); |
2267
|
125 } |
|
126 |
2889
|
127 static int |
2267
|
128 xtolower (int c) |
|
129 { |
|
130 return tolower (c); |
|
131 } |
|
132 |
2889
|
133 static int |
2267
|
134 xtoupper (int c) |
|
135 { |
|
136 return toupper (c); |
|
137 } |
|
138 |
4524
|
139 static double |
|
140 xabs (const Complex& x) |
|
141 { |
|
142 return (xisinf (x.real ()) || xisinf (x.imag ())) ? octave_Inf : abs (x); |
|
143 } |
|
144 |
3564
|
145 static Complex |
|
146 xconj (const Complex& x) |
|
147 { |
|
148 return conj (x); |
|
149 } |
|
150 |
|
151 static double |
|
152 xconj (double x) |
|
153 { |
|
154 return x; |
|
155 } |
|
156 |
3586
|
157 static double |
3564
|
158 ximag (const Complex& x) |
|
159 { |
3586
|
160 return x.imag (); |
3564
|
161 } |
|
162 |
3586
|
163 static double |
3564
|
164 xreal (const Complex& x) |
|
165 { |
3586
|
166 return x.real (); |
3564
|
167 } |
|
168 |
6828
|
169 static int |
6831
|
170 dummyp (int) |
6828
|
171 { |
|
172 return 0; |
|
173 } |
|
174 |
529
|
175 void |
|
176 install_mapper_functions (void) |
|
177 { |
4524
|
178 DEFUN_MAPPER (abs, xabs, 0, 0, fabs, xabs, 0, 0.0, 0.0, 1, 0, |
3321
|
179 "-*- texinfo -*-\n\ |
|
180 @deftypefn {Mapping Function} {} abs (@var{z})\n\ |
|
181 Compute the magnitude of @var{z}, defined as\n\ |
|
182 @iftex\n\ |
|
183 @tex\n\ |
|
184 $|z| = \\sqrt{x^2 + y^2}$.\n\ |
|
185 @end tex\n\ |
|
186 @end iftex\n\ |
|
187 @ifinfo\n\ |
|
188 |@var{z}| = @code{sqrt (x^2 + y^2)}.\n\ |
|
189 @end ifinfo\n\ |
|
190 \n\ |
|
191 For example,\n\ |
|
192 \n\ |
|
193 @example\n\ |
|
194 @group\n\ |
|
195 abs (3 + 4i)\n\ |
|
196 @result{} 5\n\ |
|
197 @end group\n\ |
|
198 @end example\n\ |
|
199 @end deftypefn"); |
529
|
200 |
4268
|
201 DEFUN_MAPPER (acos, 0, 0, 0, acos, 0, acos, -1.0, 1.0, 0, 1, |
3321
|
202 "-*- texinfo -*-\n\ |
3428
|
203 @deftypefn {Mapping Function} {} acos (@var{x})\n\ |
|
204 Compute the inverse cosine of each element of @var{x}.\n\ |
3321
|
205 @end deftypefn"); |
529
|
206 |
4668
|
207 DEFUN_MAPPER (acosh, 0, 0, 0, acosh, 0, acosh, 1.0, octave_Inf, 0, 1, |
3321
|
208 "-*- texinfo -*-\n\ |
3428
|
209 @deftypefn {Mapping Function} {} acosh (@var{x})\n\ |
|
210 Compute the inverse hyperbolic cosine of each element of @var{x}.\n\ |
3321
|
211 @end deftypefn"); |
529
|
212 |
5261
|
213 DEFUN_MAPPER (angle, 0, 0, 0, arg, std::arg, 0, 0.0, 0.0, 0, 0, |
3458
|
214 "-*- texinfo -*-\n\ |
|
215 @deftypefn {Mapping Function} {} angle (@var{z})\n\ |
|
216 See arg.\n\ |
|
217 @end deftypefn"); |
529
|
218 |
5261
|
219 DEFUN_MAPPER (arg, 0, 0, 0, arg, std::arg, 0, 0.0, 0.0, 0, 0, |
3321
|
220 "-*- texinfo -*-\n\ |
3446
|
221 @deftypefn {Mapping Function} {} arg (@var{z})\n\ |
3458
|
222 @deftypefnx {Mapping Function} {} angle (@var{z})\n\ |
3321
|
223 Compute the argument of @var{z}, defined as\n\ |
|
224 @iftex\n\ |
|
225 @tex\n\ |
|
226 $\\theta = \\tan^{-1}(y/x)$.\n\ |
|
227 @end tex\n\ |
|
228 @end iftex\n\ |
|
229 @ifinfo\n\ |
|
230 @var{theta} = @code{atan (@var{y}/@var{x})}.\n\ |
|
231 @end ifinfo\n\ |
|
232 @noindent\n\ |
|
233 in radians. \n\ |
|
234 \n\ |
|
235 For example,\n\ |
|
236 \n\ |
|
237 @example\n\ |
|
238 @group\n\ |
|
239 arg (3 + 4i)\n\ |
|
240 @result{} 0.92730\n\ |
|
241 @end group\n\ |
|
242 @end example\n\ |
|
243 @end deftypefn"); |
529
|
244 |
4268
|
245 DEFUN_MAPPER (asin, 0, 0, 0, asin, 0, asin, -1.0, 1.0, 0, 1, |
3321
|
246 "-*- texinfo -*-\n\ |
3428
|
247 @deftypefn {Mapping Function} {} asin (@var{x})\n\ |
|
248 Compute the inverse sine of each element of @var{x}.\n\ |
3321
|
249 @end deftypefn"); |
529
|
250 |
7385
|
251 /* |
|
252 %!test |
|
253 %! rt2 = sqrt (2); |
|
254 %! rt3 = sqrt (3); |
|
255 %! v = [0, pi/6, pi/4, pi/3, pi/2, pi/3, pi/4, pi/6, 0]; |
|
256 %! x = [0, 1/2, rt2/2, rt3/2, 1, rt3/2, rt2/2, 1/2, 0]; |
|
257 %! assert(all (abs (asin (x) - v) < sqrt (eps))); |
|
258 %!error asin (); |
|
259 %!error asin (1, 2); |
|
260 */ |
|
261 |
4100
|
262 DEFUN_MAPPER (asinh, 0, 0, 0, asinh, 0, asinh, 0.0, 0.0, 0, 0, |
3321
|
263 "-*- texinfo -*-\n\ |
3428
|
264 @deftypefn {Mapping Function} {} asinh (@var{x})\n\ |
5016
|
265 Compute the inverse hyperbolic sine of each element of @var{x}.\n\ |
3321
|
266 @end deftypefn"); |
529
|
267 |
4268
|
268 DEFUN_MAPPER (atan, 0, 0, 0, atan, 0, atan, 0.0, 0.0, 0, 0, |
3321
|
269 "-*- texinfo -*-\n\ |
3428
|
270 @deftypefn {Mapping Function} {} atan (@var{x})\n\ |
|
271 Compute the inverse tangent of each element of @var{x}.\n\ |
3321
|
272 @end deftypefn"); |
529
|
273 |
4100
|
274 DEFUN_MAPPER (atanh, 0, 0, 0, atanh, 0, atanh, -1.0, 1.0, 0, 1, |
3321
|
275 "-*- texinfo -*-\n\ |
3428
|
276 @deftypefn {Mapping Function} {} atanh (@var{x})\n\ |
5016
|
277 Compute the inverse hyperbolic tangent of each element of @var{x}.\n\ |
3321
|
278 @end deftypefn"); |
529
|
279 |
4268
|
280 DEFUN_MAPPER (ceil, 0, 0, 0, ceil, 0, ceil, 0.0, 0.0, 0, 0, |
3321
|
281 "-*- texinfo -*-\n\ |
3373
|
282 @deftypefn {Mapping Function} {} ceil (@var{x})\n\ |
3321
|
283 Return the smallest integer not less than @var{x}. If @var{x} is\n\ |
|
284 complex, return @code{ceil (real (@var{x})) + ceil (imag (@var{x})) * I}.\n\ |
|
285 @end deftypefn"); |
529
|
286 |
4100
|
287 DEFUN_MAPPER (conj, 0, 0, 0, xconj, 0, xconj, 0.0, 0.0, 0, 0, |
3381
|
288 "-*- texinfo -*-\n\ |
3321
|
289 @deftypefn {Mapping Function} {} conj (@var{z})\n\ |
|
290 Return the complex conjugate of @var{z}, defined as\n\ |
|
291 @iftex\n\ |
|
292 @tex\n\ |
|
293 $\\bar{z} = x - iy$.\n\ |
|
294 @end tex\n\ |
|
295 @end iftex\n\ |
|
296 @ifinfo\n\ |
|
297 @code{conj (@var{z})} = @var{x} - @var{i}@var{y}.\n\ |
|
298 @end ifinfo\n\ |
5642
|
299 @seealso{real, imag}\n\ |
5646
|
300 @end deftypefn"); |
529
|
301 |
5261
|
302 DEFUN_MAPPER (cos, 0, 0, 0, cos, 0, std::cos, 0.0, 0.0, 0, 0, |
3321
|
303 "-*- texinfo -*-\n\ |
3428
|
304 @deftypefn {Mapping Function} {} cos (@var{x})\n\ |
|
305 Compute the cosine of each element of @var{x}.\n\ |
3321
|
306 @end deftypefn"); |
529
|
307 |
5261
|
308 DEFUN_MAPPER (cosh, 0, 0, 0, cosh, 0, std::cosh, 0.0, 0.0, 0, 0, |
3321
|
309 "-*- texinfo -*-\n\ |
3428
|
310 @deftypefn {Mapping Function} {} cosh (@var{x})\n\ |
|
311 Compute the hyperbolic cosine of each element of @var{x}.\n\ |
3321
|
312 @end deftypefn"); |
529
|
313 |
4100
|
314 DEFUN_MAPPER (erf, 0, 0, 0, erf, 0, 0, 0.0, 0.0, 0, 0, |
3321
|
315 "-*- texinfo -*-\n\ |
|
316 @deftypefn {Mapping Function} {} erf (@var{z})\n\ |
|
317 Computes the error function,\n\ |
|
318 @iftex\n\ |
|
319 @tex\n\ |
|
320 $$\n\ |
|
321 {\\rm erf} (z) = {2 \\over \\sqrt{\\pi}}\\int_0^z e^{-t^2} dt\n\ |
|
322 $$\n\ |
|
323 @end tex\n\ |
|
324 @end iftex\n\ |
|
325 @ifinfo\n\ |
|
326 \n\ |
|
327 @smallexample\n\ |
|
328 z\n\ |
|
329 /\n\ |
|
330 erf (z) = (2/sqrt (pi)) | e^(-t^2) dt\n\ |
|
331 /\n\ |
|
332 t=0\n\ |
|
333 @end smallexample\n\ |
|
334 @end ifinfo\n\ |
5642
|
335 @seealso{erfc, erfinv}\n\ |
|
336 @end deftypefn"); |
624
|
337 |
4100
|
338 DEFUN_MAPPER (erfc, 0, 0, 0, erfc, 0, 0, 0.0, 0.0, 0, 0, |
3321
|
339 "-*- texinfo -*-\n\ |
|
340 @deftypefn {Mapping Function} {} erfc (@var{z})\n\ |
|
341 Computes the complementary error function,\n\ |
|
342 @iftex\n\ |
|
343 @tex\n\ |
|
344 $1 - {\\rm erf} (z)$.\n\ |
|
345 @end tex\n\ |
|
346 @end iftex\n\ |
|
347 @ifinfo\n\ |
|
348 @code{1 - erf (@var{z})}.\n\ |
|
349 @end ifinfo\n\ |
5642
|
350 @seealso{erf, erfinv}\n\ |
|
351 @end deftypefn"); |
624
|
352 |
5261
|
353 DEFUN_MAPPER (exp, 0, 0, 0, exp, 0, std::exp, 0.0, 0.0, 0, 0, |
3321
|
354 "-*- texinfo -*-\n\ |
3373
|
355 @deftypefn {Mapping Function} {} exp (@var{x})\n\ |
3321
|
356 Compute the exponential of @var{x}. To compute the matrix exponential,\n\ |
|
357 see @ref{Linear Algebra}.\n\ |
|
358 @end deftypefn"); |
529
|
359 |
6830
|
360 DEFUN_MAPPER (finite, dummyp, xfinite, xfinite, 0, 0, 0, 0.0, 0.0, 0, 0, |
3369
|
361 "-*- texinfo -*-\n\ |
|
362 @deftypefn {Mapping Function} {} finite (@var{x})\n\ |
3600
|
363 Return 1 for elements of @var{x} that are finite values and zero\n\ |
3369
|
364 otherwise. For example,\n\ |
|
365 \n\ |
|
366 @example\n\ |
|
367 @group\n\ |
5016
|
368 finite ([13, Inf, NA, NaN])\n\ |
|
369 @result{} [ 1, 0, 0, 0 ]\n\ |
3369
|
370 @end group\n\ |
|
371 @end example\n\ |
|
372 @end deftypefn"); |
529
|
373 |
4100
|
374 DEFUN_MAPPER (fix, 0, 0, 0, fix, 0, fix, 0.0, 0.0, 0, 0, |
3321
|
375 "-*- texinfo -*-\n\ |
3373
|
376 @deftypefn {Mapping Function} {} fix (@var{x})\n\ |
3321
|
377 Truncate @var{x} toward zero. If @var{x} is complex, return\n\ |
|
378 @code{fix (real (@var{x})) + fix (imag (@var{x})) * I}.\n\ |
|
379 @end deftypefn"); |
529
|
380 |
4268
|
381 DEFUN_MAPPER (floor, 0, 0, 0, floor, 0, floor, 0.0, 0.0, 0, 0, |
3321
|
382 "-*- texinfo -*-\n\ |
3373
|
383 @deftypefn {Mapping Function} {} floor (@var{x})\n\ |
3321
|
384 Return the largest integer not greater than @var{x}. If @var{x} is\n\ |
|
385 complex, return @code{floor (real (@var{x})) + floor (imag (@var{x})) * I}.\n\ |
|
386 @end deftypefn"); |
529
|
387 |
4100
|
388 DEFUN_MAPPER (gamma, 0, 0, 0, xgamma, 0, 0, 0.0, 0.0, 0, 0, |
3321
|
389 "-*- texinfo -*-\n\ |
|
390 @deftypefn {Mapping Function} {} gamma (@var{z})\n\ |
|
391 Computes the Gamma function,\n\ |
|
392 @iftex\n\ |
|
393 @tex\n\ |
|
394 $$\n\ |
|
395 \\Gamma (z) = \\int_0^\\infty t^{z-1} e^{-t} dt.\n\ |
|
396 $$\n\ |
|
397 @end tex\n\ |
|
398 @end iftex\n\ |
|
399 @ifinfo\n\ |
|
400 \n\ |
|
401 @example\n\ |
|
402 infinity\n\ |
|
403 /\n\ |
|
404 gamma (z) = | t^(z-1) exp (-t) dt.\n\ |
|
405 /\n\ |
|
406 t=0\n\ |
|
407 @end example\n\ |
|
408 @end ifinfo\n\ |
5642
|
409 @seealso{gammai, lgamma}\n\ |
|
410 @end deftypefn"); |
624
|
411 |
4100
|
412 DEFUN_MAPPER (imag, 0, 0, 0, imag, ximag, 0, 0.0, 0.0, 0, 0, |
3321
|
413 "-*- texinfo -*-\n\ |
|
414 @deftypefn {Mapping Function} {} imag (@var{z})\n\ |
|
415 Return the imaginary part of @var{z} as a real number.\n\ |
5642
|
416 @seealso{real, conj}\n\ |
|
417 @end deftypefn"); |
2089
|
418 |
4100
|
419 DEFUN_MAPPER (isalnum, xisalnum, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
420 "-*- texinfo -*-\n\ |
|
421 @deftypefn {Mapping Function} {} isalnum (@var{s})\n\ |
|
422 Return 1 for characters that are letters or digits (@code{isalpha\n\ |
4165
|
423 (@var{s})} or @code{isdigit (@var{s})} is true).\n\ |
3361
|
424 @end deftypefn"); |
2089
|
425 |
4100
|
426 DEFUN_MAPPER (isalpha, xisalpha, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
427 "-*- texinfo -*-\n\ |
|
428 @deftypefn {Mapping Function} {} isalpha (@var{s})\n\ |
4168
|
429 @deftypefnx {Mapping Function} {} isletter (@var{s})\n\ |
4165
|
430 Return true for characters that are letters (@code{isupper (@var{s})}\n\ |
|
431 or @code{islower (@var{s})} is true).\n\ |
3361
|
432 @end deftypefn"); |
2089
|
433 |
6206
|
434 #ifdef isascii |
|
435 #undef isascii |
|
436 #endif |
|
437 |
4100
|
438 DEFUN_MAPPER (isascii, xisascii, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
439 "-*- texinfo -*-\n\ |
|
440 @deftypefn {Mapping Function} {} isascii (@var{s})\n\ |
|
441 Return 1 for characters that are ASCII (in the range 0 to 127 decimal).\n\ |
|
442 @end deftypefn"); |
2089
|
443 |
4100
|
444 DEFUN_MAPPER (iscntrl, xiscntrl, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
445 "-*- texinfo -*-\n\ |
|
446 @deftypefn {Mapping Function} {} iscntrl (@var{s})\n\ |
|
447 Return 1 for control characters.\n\ |
|
448 @end deftypefn"); |
2089
|
449 |
4100
|
450 DEFUN_MAPPER (isdigit, xisdigit, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
451 "-*- texinfo -*-\n\ |
|
452 @deftypefn {Mapping Function} {} isdigit (@var{s})\n\ |
|
453 Return 1 for characters that are decimal digits.\n\ |
|
454 @end deftypefn"); |
2089
|
455 |
6830
|
456 DEFUN_MAPPER (isinf, dummyp, xisinf, xisinf, 0, 0, 0, 0.0, 0.0, 0, 0, |
3369
|
457 "-*- texinfo -*-\n\ |
|
458 @deftypefn {Mapping Function} {} isinf (@var{x})\n\ |
|
459 Return 1 for elements of @var{x} that are infinite and zero\n\ |
|
460 otherwise. For example,\n\ |
|
461 \n\ |
|
462 @example\n\ |
|
463 @group\n\ |
4025
|
464 isinf ([13, Inf, NA, NaN])\n\ |
|
465 @result{} [ 0, 1, 0, 0 ]\n\ |
3369
|
466 @end group\n\ |
|
467 @end example\n\ |
|
468 @end deftypefn"); |
529
|
469 |
4100
|
470 DEFUN_MAPPER (isgraph, xisgraph, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
471 "-*- texinfo -*-\n\ |
|
472 @deftypefn {Mapping Function} {} isgraph (@var{s})\n\ |
|
473 Return 1 for printable characters (but not the space character).\n\ |
|
474 @end deftypefn"); |
529
|
475 |
4100
|
476 DEFUN_MAPPER (islower, xislower, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
477 "-*- texinfo -*-\n\ |
|
478 @deftypefn {Mapping Function} {} islower (@var{s})\n\ |
|
479 Return 1 for characters that are lower case letters.\n\ |
|
480 @end deftypefn"); |
2089
|
481 |
6830
|
482 DEFUN_MAPPER (isna, dummyp, octave_is_NA, octave_is_NA, 0, 0, 0, 0.0, 0.0, 0, 0, |
4025
|
483 "-*- texinfo -*-\n\ |
|
484 @deftypefn {Mapping Function} {} isna (@var{x})\n\ |
|
485 Return 1 for elements of @var{x} that are NA (missing) values and zero\n\ |
5389
|
486 otherwise. For example,\n\ |
4025
|
487 \n\ |
|
488 @example\n\ |
|
489 @group\n\ |
6218
|
490 isna ([13, Inf, NA, NaN])\n\ |
4025
|
491 @result{} [ 0, 0, 1, 0 ]\n\ |
|
492 @end group\n\ |
|
493 @end example\n\ |
|
494 @end deftypefn"); |
|
495 |
6830
|
496 DEFUN_MAPPER (isnan, dummyp, xisnan, xisnan, 0, 0, 0, 0.0, 0.0, 0, 0, |
3369
|
497 "-*- texinfo -*-\n\ |
|
498 @deftypefn {Mapping Function} {} isnan (@var{x})\n\ |
|
499 Return 1 for elements of @var{x} that are NaN values and zero\n\ |
5389
|
500 otherwise. NA values are also considered NaN values. For example,\n\ |
3369
|
501 \n\ |
|
502 @example\n\ |
|
503 @group\n\ |
4025
|
504 isnan ([13, Inf, NA, NaN])\n\ |
5389
|
505 @result{} [ 0, 0, 1, 1 ]\n\ |
3369
|
506 @end group\n\ |
|
507 @end example\n\ |
|
508 @end deftypefn"); |
624
|
509 |
4100
|
510 DEFUN_MAPPER (isprint, xisprint, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
511 "-*- texinfo -*-\n\ |
|
512 @deftypefn {Mapping Function} {} isprint (@var{s})\n\ |
|
513 Return 1 for printable characters (including the space character).\n\ |
|
514 @end deftypefn"); |
2089
|
515 |
4100
|
516 DEFUN_MAPPER (ispunct, xispunct, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
517 "-*- texinfo -*-\n\ |
|
518 @deftypefn {Mapping Function} {} ispunct (@var{s})\n\ |
|
519 Return 1 for punctuation characters.\n\ |
|
520 @end deftypefn"); |
2089
|
521 |
4100
|
522 DEFUN_MAPPER (isspace, xisspace, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
523 "-*- texinfo -*-\n\ |
|
524 @deftypefn {Mapping Function} {} isspace (@var{s})\n\ |
|
525 Return 1 for whitespace characters (space, formfeed, newline,\n\ |
|
526 carriage return, tab, and vertical tab).\n\ |
|
527 @end deftypefn"); |
2089
|
528 |
4100
|
529 DEFUN_MAPPER (isupper, xisupper, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
530 "-*- texinfo -*-\n\ |
|
531 @deftypefn {Mapping Function} {} isupper (@var{s})\n\ |
|
532 Return 1 for upper case letters.\n\ |
|
533 @end deftypefn"); |
2089
|
534 |
4100
|
535 DEFUN_MAPPER (isxdigit, xisxdigit, 0, 0, 0, 0, 0, 0.0, 0.0, 0, 0, |
3361
|
536 "-*- texinfo -*-\n\ |
|
537 @deftypefn {Mapping Function} {} isxdigit (@var{s})\n\ |
|
538 Return 1 for characters that are hexadecimal digits.\n\ |
|
539 @end deftypefn"); |
2089
|
540 |
6969
|
541 DEFUN_MAPPER (lgamma, 0, 0, 0, xlgamma, 0, 0, 0.0, 0.0, 0, 0, |
3321
|
542 "-*- texinfo -*-\n\ |
5518
|
543 @deftypefn {Mapping Function} {} lgamma (@var{x})\n\ |
|
544 @deftypefnx {Mapping Function} {} gammaln (@var{x})\n\ |
6969
|
545 Return the natural logarithm of the absolute value of the gamma\n\ |
|
546 function of @var{x}.\n\ |
5642
|
547 @seealso{gamma, gammai}\n\ |
|
548 @end deftypefn"); |
529
|
549 |
5261
|
550 DEFUN_MAPPER (log, 0, 0, 0, log, 0, std::log, 0.0, octave_Inf, 0, 1, |
3321
|
551 "-*- texinfo -*-\n\ |
|
552 @deftypefn {Mapping Function} {} log (@var{x})\n\ |
|
553 Compute the natural logarithm for each element of @var{x}. To compute the\n\ |
|
554 matrix logarithm, see @ref{Linear Algebra}.\n\ |
5642
|
555 @seealso{log2, log10, logspace, exp}\n\ |
|
556 @end deftypefn"); |
529
|
557 |
5261
|
558 DEFUN_MAPPER (log10, 0, 0, 0, log10, 0, std::log10, 0.0, octave_Inf, 0, 1, |
3321
|
559 "-*- texinfo -*-\n\ |
|
560 @deftypefn {Mapping Function} {} log10 (@var{x})\n\ |
|
561 Compute the base-10 logarithm for each element of @var{x}.\n\ |
5642
|
562 @seealso{log, log2, logspace, exp}\n\ |
|
563 @end deftypefn"); |
529
|
564 |
4100
|
565 DEFUN_MAPPER (real, 0, 0, 0, real, xreal, 0, 0.0, 0.0, 0, 0, |
3381
|
566 "-*- texinfo -*-\n\ |
3321
|
567 @deftypefn {Mapping Function} {} real (@var{z})\n\ |
|
568 Return the real part of @var{z}.\n\ |
5642
|
569 @seealso{imag, conj}\n\ |
|
570 @end deftypefn"); |
529
|
571 |
4968
|
572 DEFUN_MAPPER (round, 0, 0, 0, xround, 0, xround, 0.0, 0.0, 0, 0, |
3321
|
573 "-*- texinfo -*-\n\ |
|
574 @deftypefn {Mapping Function} {} round (@var{x})\n\ |
|
575 Return the integer nearest to @var{x}. If @var{x} is complex, return\n\ |
|
576 @code{round (real (@var{x})) + round (imag (@var{x})) * I}.\n\ |
5642
|
577 @seealso{rem}\n\ |
|
578 @end deftypefn"); |
529
|
579 |
4100
|
580 DEFUN_MAPPER (sign, 0, 0, 0, signum, 0, signum, 0.0, 0.0, 0, 0, |
3321
|
581 "-*- texinfo -*-\n\ |
|
582 @deftypefn {Mapping Function} {} sign (@var{x})\n\ |
|
583 Compute the @dfn{signum} function, which is defined as\n\ |
|
584 @iftex\n\ |
|
585 @tex\n\ |
|
586 $$\n\ |
|
587 {\\rm sign} (@var{x}) = \\cases{1,&$x>0$;\\cr 0,&$x=0$;\\cr -1,&$x<0$.\\cr}\n\ |
|
588 $$\n\ |
|
589 @end tex\n\ |
|
590 @end iftex\n\ |
|
591 @ifinfo\n\ |
|
592 \n\ |
|
593 @example\n\ |
|
594 -1, x < 0;\n\ |
|
595 sign (x) = 0, x = 0;\n\ |
|
596 1, x > 0.\n\ |
|
597 @end example\n\ |
|
598 @end ifinfo\n\ |
|
599 \n\ |
|
600 For complex arguments, @code{sign} returns @code{x ./ abs (@var{x})}.\n\ |
|
601 @end deftypefn"); |
529
|
602 |
5261
|
603 DEFUN_MAPPER (sin, 0, 0, 0, sin, 0, std::sin, 0.0, 0.0, 0, 0, |
3321
|
604 "-*- texinfo -*-\n\ |
3428
|
605 @deftypefn {Mapping Function} {} sin (@var{x})\n\ |
5016
|
606 Compute the sine of each element of @var{x}.\n\ |
3321
|
607 @end deftypefn"); |
529
|
608 |
5261
|
609 DEFUN_MAPPER (sinh, 0, 0, 0, sinh, 0, std::sinh, 0.0, 0.0, 0, 0, |
3321
|
610 "-*- texinfo -*-\n\ |
3428
|
611 @deftypefn {Mapping Function} {} sinh (@var{x})\n\ |
5418
|
612 Compute the hyperbolic sine of each element of @var{x}.\n\ |
3321
|
613 @end deftypefn"); |
529
|
614 |
5261
|
615 DEFUN_MAPPER (sqrt, 0, 0, 0, sqrt, 0, std::sqrt, 0.0, octave_Inf, 0, 1, |
3321
|
616 "-*- texinfo -*-\n\ |
|
617 @deftypefn {Mapping Function} {} sqrt (@var{x})\n\ |
|
618 Compute the square root of @var{x}. If @var{x} is negative, a complex\n\ |
|
619 result is returned. To compute the matrix square root, see\n\ |
|
620 @ref{Linear Algebra}.\n\ |
|
621 @end deftypefn"); |
529
|
622 |
5261
|
623 DEFUN_MAPPER (tan, 0, 0, 0, tan, 0, std::tan, 0.0, 0.0, 0, 0, |
3321
|
624 "-*- texinfo -*-\n\ |
|
625 @deftypefn {Mapping Function} {} tan (@var{z})\n\ |
5016
|
626 Compute tangent of each element of @var{x}.\n\ |
3321
|
627 @end deftypefn"); |
529
|
628 |
5261
|
629 DEFUN_MAPPER (tanh, 0, 0, 0, tanh, 0, std::tanh, 0.0, 0.0, 0, 0, |
3321
|
630 "-*- texinfo -*-\n\ |
3428
|
631 @deftypefn {Mapping Function} {} tanh (@var{x})\n\ |
|
632 Compute hyperbolic tangent of each element of @var{x}.\n\ |
3321
|
633 @end deftypefn"); |
1562
|
634 |
6123
|
635 #ifdef toascii |
|
636 #undef toascii |
|
637 #endif |
|
638 |
4100
|
639 DEFUN_MAPPER (toascii, xtoascii, 0, 0, 0, 0, 0, 0.0, 0.0, 1, 0, |
3361
|
640 "-*- texinfo -*-\n\ |
|
641 @deftypefn {Mapping Function} {} toascii (@var{s})\n\ |
|
642 Return ASCII representation of @var{s} in a matrix. For example,\n\ |
|
643 \n\ |
|
644 @example\n\ |
|
645 @group\n\ |
|
646 toascii (\"ASCII\")\n\ |
|
647 @result{} [ 65, 83, 67, 73, 73 ]\n\ |
|
648 @end group\n\ |
|
649 \n\ |
|
650 @end example\n\ |
3362
|
651 @end deftypefn"); |
2267
|
652 |
4100
|
653 DEFUN_MAPPER (tolower, xtolower, 0, 0, 0, 0, 0, 0.0, 0.0, 2, 0, |
3361
|
654 "-*- texinfo -*-\n\ |
|
655 @deftypefn {Mapping Function} {} tolower (@var{s})\n\ |
|
656 Return a copy of the string @var{s}, with each upper-case character\n\ |
|
657 replaced by the corresponding lower-case one; nonalphabetic characters\n\ |
|
658 are left unchanged. For example,\n\ |
|
659 \n\ |
|
660 @example\n\ |
|
661 tolower (\"MiXeD cAsE 123\")\n\ |
|
662 @result{} \"mixed case 123\"\n\ |
|
663 @end example\n\ |
3362
|
664 @end deftypefn"); |
2267
|
665 |
4100
|
666 DEFUN_MAPPER (toupper, xtoupper, 0, 0, 0, 0, 0, 0.0, 0.0, 2, 0, |
3361
|
667 "-*- texinfo -*-\n\ |
3368
|
668 @deftypefn {Built-in Function} {} toupper (@var{s})\n\ |
3361
|
669 Return a copy of the string @var{s}, with each lower-case character\n\ |
|
670 replaced by the corresponding upper-case one; nonalphabetic characters\n\ |
|
671 are left unchanged. For example,\n\ |
|
672 \n\ |
|
673 @example\n\ |
|
674 @group\n\ |
3552
|
675 toupper (\"MiXeD cAsE 123\")\n\ |
3361
|
676 @result{} \"MIXED CASE 123\"\n\ |
|
677 @end group\n\ |
|
678 @end example\n\ |
3362
|
679 @end deftypefn"); |
2267
|
680 |
1562
|
681 DEFALIAS (gammaln, lgamma); |
3206
|
682 |
|
683 DEFALIAS (isfinite, finite); |
3321
|
684 |
|
685 // Leave the previous new line, mkgendoc needs it! |
529
|
686 } |
|
687 |
1
|
688 /* |
|
689 ;;; Local Variables: *** |
|
690 ;;; mode: C++ *** |
|
691 ;;; End: *** |
|
692 */ |