annotate libinterp/corefcn/mappers.cc @ 17787:175b392e91fe

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