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