Mercurial > octave
annotate liboctave/numeric/lo-specfun.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | c8ad083a5802 |
children | aac27ad79be6 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30394
diff
changeset
|
3 // Copyright (C) 1996-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
3146 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21231
diff
changeset
|
27 # include "config.h" |
3146 | 28 #endif |
29 | |
23623
4feed155a1f2
Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
30 #include <cmath> |
4feed155a1f2
Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
31 |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
32 #include <algorithm> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
33 #include <limits> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
34 #include <string> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
35 |
3220 | 36 #include "CColVector.h" |
37 #include "CMatrix.h" | |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
38 #include "CNDArray.h" |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
39 #include "Faddeeva.hh" |
3146 | 40 #include "dMatrix.h" |
4844 | 41 #include "dNDArray.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
42 #include "dRowVector.h" |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
43 #include "f77-fcn.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
44 #include "fCColVector.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
45 #include "fCMatrix.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
46 #include "fCNDArray.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
47 #include "fMatrix.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
48 #include "fNDArray.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
49 #include "fRowVector.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
50 #include "lo-amos-proto.h" |
3146 | 51 #include "lo-error.h" |
3220 | 52 #include "lo-ieee.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
53 #include "lo-mappers.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
54 #include "lo-slatec-proto.h" |
3220 | 55 #include "lo-specfun.h" |
3146 | 56 #include "mx-inlines.cc" |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15271
diff
changeset
|
57 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31548
diff
changeset
|
58 OCTAVE_BEGIN_NAMESPACE(octave) |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31548
diff
changeset
|
59 |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31548
diff
changeset
|
60 OCTAVE_BEGIN_NAMESPACE(math) |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31548
diff
changeset
|
61 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
62 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
63 bessel_return_value (const Complex& val, octave_idx_type ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
64 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
65 static const Complex inf_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
66 = Complex (numeric_limits<double>::Inf (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
67 numeric_limits<double>::Inf ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
68 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
69 static const Complex nan_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
70 = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
71 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
72 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
73 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
74 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
75 switch (ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
76 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
77 case 0: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
78 case 3: |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
79 case 4: |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
80 retval = val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
81 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
82 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
83 case 2: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
84 retval = inf_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
85 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
86 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
87 default: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
88 retval = nan_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
89 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
90 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
91 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
92 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
93 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
94 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
95 static inline FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
96 bessel_return_value (const FloatComplex& val, octave_idx_type ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
97 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
98 static const FloatComplex inf_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
99 = FloatComplex (numeric_limits<float>::Inf (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
100 numeric_limits<float>::Inf ()); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
101 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
102 static const FloatComplex nan_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
103 = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
104 numeric_limits<float>::NaN ()); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
105 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
106 FloatComplex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
107 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
108 switch (ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
109 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
110 case 0: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
111 case 3: |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
112 case 4: |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
113 retval = val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
114 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
115 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
116 case 2: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
117 retval = inf_val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
118 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
119 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
120 default: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
121 retval = nan_val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
122 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
123 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
124 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
125 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
126 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
127 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
128 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
129 airy (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
130 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
131 double ar = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
132 double ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
133 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
134 double zr = z.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
135 double zi = z.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
136 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
137 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
138 F77_INT nz, t_ierr; |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
139 F77_INT sc = (scaled ? 2 : 1); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
140 |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
141 F77_FUNC (zairy, ZAIRY) (zr, zi, id, sc, ar, ai, nz, t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
142 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
143 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
144 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
145 if (zi == 0.0 && (! scaled || zr >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
146 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
147 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
148 return bessel_return_value (Complex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
149 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
150 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
151 ComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
152 airy (const ComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
153 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
154 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
155 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
156 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
157 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
158 ComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
159 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
160 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
161 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
162 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
163 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
164 retval(i, j) = airy (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
165 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
166 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
167 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
168 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
169 ComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
170 airy (const ComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
171 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
172 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
173 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
174 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
175 ComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
176 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
177 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
178 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
179 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
180 retval(i) = airy (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
181 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
182 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
183 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
184 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
185 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
186 airy (const FloatComplex& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
187 octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
188 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
189 FloatComplex a; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
190 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
191 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
192 F77_INT nz, t_ierr; |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
193 F77_INT sc = (scaled ? 2 : 1); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
194 |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
195 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, sc, |
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
196 F77_CMPLX_ARG (&a), nz, t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
197 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
198 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
199 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
200 float ar = a.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
201 float ai = a.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
202 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
203 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
204 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
205 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
206 return bessel_return_value (FloatComplex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
207 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
208 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
209 FloatComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
210 airy (const FloatComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
211 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
212 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
213 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
214 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
215 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
216 FloatComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
217 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
218 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
219 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
220 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
221 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
222 retval(i, j) = airy (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
223 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
224 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
225 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
226 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
227 FloatComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
228 airy (const FloatComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
229 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
230 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
231 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
232 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
233 FloatComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
234 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
235 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
236 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
237 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
238 retval(i) = airy (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
239 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
240 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
241 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
242 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
243 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
244 is_integer_value (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
245 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
246 return x == static_cast<double> (static_cast<long> (x)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
247 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
248 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
249 static inline Complex |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
250 zbesj (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
251 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
252 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
253 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
254 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
255 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
256 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
257 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
258 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
259 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
260 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
261 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
262 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
263 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
264 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
265 zbesh2 (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
266 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
267 static inline Complex |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
268 zbesj (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
269 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
270 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
271 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
272 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
273 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
274 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
275 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
276 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
277 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
278 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
279 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
280 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
281 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
282 F77_FUNC (zbesj, ZBESJ) (zr, zi, alpha, kode, 1, &yr, &yi, nz, t_ierr); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
283 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
284 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
285 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
286 if (zi == 0.0 && zr >= 0.0) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
287 yi = 0.0; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
288 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
289 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
290 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
291 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
292 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
293 // zbesy can overflow as z->0, and cause troubles for generic case below |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
294 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
295 Complex tmp = zbesj (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
296 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
297 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
298 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
299 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
300 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
301 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
302 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
303 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
304 Complex tmp = cos (M_PI * alpha) * zbesj (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
305 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
306 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
307 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
308 tmp -= sin (M_PI * alpha) * zbesy (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
309 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
310 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
311 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
312 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
313 retval = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
314 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
315 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
316 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
317 return retval; |
3220 | 318 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
319 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
320 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
321 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
4911 | 322 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
323 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
324 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
325 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
326 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
327 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
328 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
329 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
330 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
331 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
332 double wr, wi; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
333 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
334 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
335 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
336 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
337 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
338 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
339 if (zr == 0.0 && zi == 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
340 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
341 yr = -numeric_limits<double>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
342 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
343 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
344 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
345 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
346 F77_FUNC (zbesy, ZBESY) (zr, zi, alpha, kode, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
347 &wr, &wi, t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
348 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
349 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
350 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
351 if (zi == 0.0 && zr >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
352 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
353 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
354 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
355 return bessel_return_value (Complex (yr, yi), ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
356 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
357 else if (is_integer_value (alpha - 0.5)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
358 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
359 // zbesy can overflow as z->0, and cause troubles for generic case below |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
360 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
361 Complex tmp = zbesj (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
362 if ((static_cast<long> (alpha - 0.5)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
363 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
364 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
365 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
366 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
367 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
368 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
369 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
370 Complex tmp = cos (M_PI * alpha) * zbesy (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
371 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
372 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
373 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
374 tmp += sin (M_PI * alpha) * zbesj (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
375 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
376 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
377 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
378 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
379 retval = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
380 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
381 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
382 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
383 return retval; |
4911 | 384 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
385 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
386 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
387 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 388 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
389 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
390 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
391 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
392 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
393 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
394 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
395 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
396 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
397 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
398 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
399 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
400 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
401 F77_FUNC (zbesi, ZBESI) (zr, zi, alpha, kode, 1, &yr, &yi, nz, t_ierr); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
402 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
403 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
404 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
405 if (zi == 0.0 && zr >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
406 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
407 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
408 retval = bessel_return_value (Complex (yr, yi), ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
409 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
410 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
411 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
412 // zbesi can overflow as z->0, and cause troubles for generic case below |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
413 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
414 Complex tmp = zbesi (z, alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
415 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
416 } |
3220 | 417 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
418 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
419 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
420 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
421 Complex tmp = zbesi (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
422 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
423 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
424 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
425 Complex tmp2 = (2.0 / M_PI) * sin (M_PI * alpha) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
426 * zbesk (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
427 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
428 if (kode == 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
429 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
430 // Compensate for different scaling factor of besk. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
431 tmp2 *= exp (-z - std::abs (z.real ())); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
432 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
433 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
434 tmp += tmp2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
435 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
436 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
437 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
438 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
439 retval = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
440 numeric_limits<double>::NaN ()); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
441 } |
3146 | 442 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
443 return retval; |
3146 | 444 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
445 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
446 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
447 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 448 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
449 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
450 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
451 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
452 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
453 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
454 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
455 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
456 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
457 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
458 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
459 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
460 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
461 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
462 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
463 if (zr == 0.0 && zi == 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
464 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
465 yr = numeric_limits<double>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
466 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
467 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
468 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
469 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
470 F77_FUNC (zbesk, ZBESK) (zr, zi, alpha, kode, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
471 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
472 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
473 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
474 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
475 if (zi == 0.0 && zr >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
476 yi = 0.0; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
477 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
478 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
479 retval = bessel_return_value (Complex (yr, yi), ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
480 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
481 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
482 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
483 Complex tmp = zbesk (z, -alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
484 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
485 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
486 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
487 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
488 return retval; |
3220 | 489 } |
490 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
491 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
492 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 493 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
494 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
495 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
496 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
497 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
498 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
499 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
500 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
501 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
502 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
503 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
504 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
505 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
506 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, kode, 1, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
507 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
508 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
509 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
510 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
511 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
512 } |
3220 | 513 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
514 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
515 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
516 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
517 static const Complex eye = Complex (0.0, 1.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
518 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
519 Complex tmp = exp (M_PI * alpha * eye) * zbesh1 (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
520 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
521 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
522 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
523 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
524 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
525 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
526 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
527 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
528 zbesh2 (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
529 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
530 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
531 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
532 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
533 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
534 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
535 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
536 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
537 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
538 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
539 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
540 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
541 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
542 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, kode, 2, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
543 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
544 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
545 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
546 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
547 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
548 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
549 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
550 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
551 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
552 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
553 static const Complex eye = Complex (0.0, 1.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
554 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
555 Complex tmp = exp (-M_PI * alpha * eye) * zbesh2 (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
556 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
557 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
558 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
559 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
560 return retval; |
3220 | 561 } |
3146 | 562 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
563 typedef Complex (*dptr) (const Complex&, double, int, octave_idx_type&); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
564 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
565 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
566 do_bessel (dptr f, const char *, double alpha, const Complex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
567 bool scaled, octave_idx_type& ierr) |
3220 | 568 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
569 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
570 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
571 retval = f (x, alpha, (scaled ? 2 : 1), ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
572 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
573 return retval; |
3220 | 574 } |
3146 | 575 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
576 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
577 do_bessel (dptr f, const char *, double alpha, const ComplexMatrix& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
578 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 579 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
580 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
581 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
582 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
583 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
584 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
585 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
586 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
587 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
588 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
589 retval(i, j) = f (x(i, j), alpha, (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
590 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
591 return retval; |
3146 | 592 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
593 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
594 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
595 do_bessel (dptr f, const char *, const Matrix& alpha, const Complex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
596 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 597 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
598 octave_idx_type nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
599 octave_idx_type nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
600 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
601 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
602 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
603 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
604 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
605 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
606 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
607 retval(i, j) = f (x, alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
608 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
609 return retval; |
3220 | 610 } |
611 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
612 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
613 do_bessel (dptr f, const char *fn, const Matrix& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
614 const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
615 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
616 ComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
617 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
618 octave_idx_type x_nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
619 octave_idx_type x_nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
620 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
621 octave_idx_type alpha_nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
622 octave_idx_type alpha_nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
623 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
624 if (x_nr != alpha_nr || x_nc != alpha_nc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
625 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
626 ("%s: the sizes of alpha and x must conform", fn); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
627 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
628 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
629 octave_idx_type nc = x_nc; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
630 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
631 retval.resize (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
632 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
633 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
634 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
635 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
636 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
637 retval(i, j) = f (x(i, j), alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
638 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
639 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
640 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
641 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
642 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
643 do_bessel (dptr f, const char *, double alpha, const ComplexNDArray& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
644 bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
645 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
646 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
647 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
648 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
649 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
650 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
651 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
652 for (octave_idx_type i = 0; i < nel; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
653 retval(i) = f (x(i), alpha, (scaled ? 2 : 1), ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
654 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
655 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
656 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
657 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
658 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
659 do_bessel (dptr f, const char *, const NDArray& alpha, const Complex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
660 bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
661 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
662 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
663 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
664 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
665 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
666 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
667 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
668 for (octave_idx_type i = 0; i < nel; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
669 retval(i) = f (x, alpha(i), (scaled ? 2 : 1), ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
670 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
671 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
672 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
673 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
674 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
675 do_bessel (dptr f, const char *fn, const NDArray& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
676 const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
677 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
678 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
679 ComplexNDArray retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
680 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
681 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
682 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
683 ("%s: the sizes of alpha and x must conform", fn); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
684 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
685 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
686 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
687 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
688 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
689 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
690 for (octave_idx_type i = 0; i < nel; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
691 retval(i) = f (x(i), alpha(i), (scaled ? 2 : 1), ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
692 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
693 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
694 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
695 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
696 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
697 do_bessel (dptr f, const char *, const RowVector& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
698 const ComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
699 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
700 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
701 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
702 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
703 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
704 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
705 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
706 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
707 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
708 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
709 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
710 retval(i, j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
711 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
712 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
713 } |
3146 | 714 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
715 #define SS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
716 Complex \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
717 name (double alpha, const Complex& x, bool scaled, octave_idx_type& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
718 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
719 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
720 } |
3220 | 721 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
722 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
723 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
724 name (double alpha, const ComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
725 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
726 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
727 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
728 } |
3220 | 729 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
730 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
731 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
732 name (const Matrix& alpha, const Complex& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
733 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
734 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
735 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
736 } |
3220 | 737 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
738 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
739 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
740 name (const Matrix& alpha, const ComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
741 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
742 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
743 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
744 } |
3220 | 745 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
746 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
747 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
748 name (double alpha, const ComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
749 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
750 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
751 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
752 } |
4844 | 753 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
754 #define NS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
755 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
756 name (const NDArray& alpha, const Complex& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
757 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
758 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
759 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
760 } |
4844 | 761 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
762 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
763 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
764 name (const NDArray& alpha, const ComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
765 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
766 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
767 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
768 } |
4844 | 769 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
770 #define RC_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
771 ComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
772 name (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
773 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
774 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
775 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
776 } |
3220 | 777 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
778 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
779 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
780 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
781 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
782 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
783 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
784 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
785 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
786 RC_BESSEL (name, fcn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
787 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
788 ALL_BESSEL (besselj, zbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
789 ALL_BESSEL (bessely, zbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
790 ALL_BESSEL (besseli, zbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
791 ALL_BESSEL (besselk, zbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
792 ALL_BESSEL (besselh1, zbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
793 ALL_BESSEL (besselh2, zbesh2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
794 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
795 #undef ALL_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
796 #undef SS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
797 #undef SM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
798 #undef MS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
799 #undef MM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
800 #undef SN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
801 #undef NS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
802 #undef NN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
803 #undef RC_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
804 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
805 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
806 cbesj (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
807 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
808 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
809 cbesy (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
810 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
811 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
812 cbesi (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
813 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
814 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
815 cbesk (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
816 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
817 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
818 cbesh1 (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
819 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
820 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
821 cbesh2 (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
822 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
823 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
824 is_integer_value (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
825 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
826 return x == static_cast<float> (static_cast<long> (x)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
827 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
828 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
829 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
830 cbesj (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
831 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
832 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
833 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
834 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
835 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
836 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
837 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
838 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
839 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
840 F77_FUNC (cbesj, CBESJ) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
841 F77_CMPLX_ARG (&y), nz, t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
842 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
843 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
844 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
845 if (z.imag () == 0.0 && z.real () >= 0.0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
846 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
847 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
848 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
849 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
850 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
851 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
852 // zbesy can overflow as z->0, and cause troubles for generic case below |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
853 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
854 FloatComplex tmp = cbesj (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
855 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
856 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
857 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
858 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
859 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
860 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
861 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
862 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
863 FloatComplex tmp = cosf (static_cast<float> (M_PI) * alpha) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
864 * cbesj (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
865 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
866 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
867 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
868 tmp -= sinf (static_cast<float> (M_PI) * alpha) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
869 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
870 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
871 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
872 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
873 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
874 retval = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
875 numeric_limits<float>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
876 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
877 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
878 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
879 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
880 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
881 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
882 cbesy (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
883 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
884 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
885 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
886 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
887 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
888 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
889 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
890 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
891 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
892 FloatComplex w; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
893 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
894 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
895 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
896 if (z.real () == 0.0 && z.imag () == 0.0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
897 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
898 y = FloatComplex (-numeric_limits<float>::Inf (), 0.0); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
899 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
900 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
901 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
902 F77_FUNC (cbesy, CBESY) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
903 F77_CMPLX_ARG (&y), nz, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
904 F77_CMPLX_ARG (&w), t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
905 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
906 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
907 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
908 if (z.imag () == 0.0 && z.real () >= 0.0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
909 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
910 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
911 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
912 return bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
913 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
914 else if (is_integer_value (alpha - 0.5)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
915 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
916 // zbesy can overflow as z->0, and cause troubles for generic case below |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
917 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
918 FloatComplex tmp = cbesj (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
919 if ((static_cast<long> (alpha - 0.5)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
920 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
921 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
922 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
923 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
924 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
925 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
926 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
927 FloatComplex tmp = cosf (static_cast<float> (M_PI) * alpha) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
928 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
929 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
930 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
931 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
932 tmp += sinf (static_cast<float> (M_PI) * alpha) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
933 * cbesj (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
934 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
935 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
936 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
937 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
938 retval = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
939 numeric_limits<float>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
940 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
941 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
942 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
943 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
944 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
945 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
946 cbesi (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
947 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
948 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
949 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
950 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
951 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
952 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
953 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
954 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
955 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
956 F77_FUNC (cbesi, CBESI) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
957 F77_CMPLX_ARG (&y), nz, t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
958 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
959 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
960 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
961 if (z.imag () == 0.0 && z.real () >= 0.0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
962 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
963 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
964 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
965 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
966 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
967 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
968 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
969 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
970 FloatComplex tmp = cbesi (z, alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
971 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
972 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
973 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
974 FloatComplex tmp2 = static_cast<float> (2.0 / M_PI) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
975 * sinf (static_cast<float> (M_PI) * alpha) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
976 * cbesk (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
977 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
978 if (kode == 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
979 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
980 // Compensate for different scaling factor of besk. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
981 tmp2 *= exp (-z - std::abs (z.real ())); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
982 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
983 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
984 tmp += tmp2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
985 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
986 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
987 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
988 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
989 retval = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
990 numeric_limits<float>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
991 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
992 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
993 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
994 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
995 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
996 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
997 cbesk (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
998 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
999 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1000 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1001 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1002 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1003 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1004 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1005 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1006 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1007 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1008 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1009 if (z.real () == 0.0 && z.imag () == 0.0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1010 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1011 y = FloatComplex (numeric_limits<float>::Inf (), 0.0); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1012 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1013 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1014 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1015 F77_FUNC (cbesk, CBESK) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1016 F77_CMPLX_ARG (&y), nz, t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1017 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1018 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1019 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1020 if (z.imag () == 0.0 && z.real () >= 0.0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1021 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1022 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1023 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1024 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1025 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1026 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1027 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1028 FloatComplex tmp = cbesk (z, -alpha, kode, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1029 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1030 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1031 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1032 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1033 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1034 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1035 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1036 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1037 cbesh1 (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1038 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1039 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1040 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1041 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1042 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1043 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1044 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1045 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1046 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1047 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1048 F77_CMPLX_ARG (&y), nz, t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1049 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1050 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1051 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1052 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1053 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1054 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1055 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1056 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1057 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1058 static const FloatComplex eye = FloatComplex (0.0, 1.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1059 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1060 FloatComplex tmp = exp (static_cast<float> (M_PI) * alpha * eye) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1061 * cbesh1 (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1062 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1063 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1064 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1065 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1066 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1067 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1068 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1069 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1070 cbesh2 (const FloatComplex& z, float alpha, int kode, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1071 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1072 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1073 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1074 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1075 { |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1076 FloatComplex y = 0.0;; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1077 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1078 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1079 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1080 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 2, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1081 F77_CMPLX_ARG (&y), nz, t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1082 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1083 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1084 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1085 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1086 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1087 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1088 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1089 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1090 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1091 static const FloatComplex eye = FloatComplex (0.0, 1.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1092 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1093 FloatComplex tmp = exp (-static_cast<float> (M_PI) * alpha * eye) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1094 * cbesh2 (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1095 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1096 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1097 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1098 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1099 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1100 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1101 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1102 typedef FloatComplex (*fptr) (const FloatComplex&, float, int, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1103 octave_idx_type&); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1104 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1105 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1106 do_bessel (fptr f, const char *, float alpha, const FloatComplex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1107 bool scaled, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1108 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1109 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1110 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1111 retval = f (x, alpha, (scaled ? 2 : 1), ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1112 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1113 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1114 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1115 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1116 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1117 do_bessel (fptr f, const char *, float alpha, const FloatComplexMatrix& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1118 bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1119 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1120 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1121 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1122 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1123 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1124 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1125 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1126 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1127 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1128 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1129 retval(i, j) = f (x(i, j), alpha, (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1130 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1131 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1132 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1133 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1134 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1135 do_bessel (fptr f, const char *, const FloatMatrix& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1136 const FloatComplex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1137 bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1138 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1139 octave_idx_type nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1140 octave_idx_type nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1141 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1142 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1143 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1144 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1145 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1146 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1147 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1148 retval(i, j) = f (x, alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1149 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1150 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1151 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1152 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1153 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1154 do_bessel (fptr f, const char *fn, const FloatMatrix& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1155 const FloatComplexMatrix& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1156 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1157 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1158 FloatComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1159 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1160 octave_idx_type x_nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1161 octave_idx_type x_nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1162 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1163 octave_idx_type alpha_nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1164 octave_idx_type alpha_nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1165 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1166 if (x_nr != alpha_nr || x_nc != alpha_nc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1167 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1168 ("%s: the sizes of alpha and x must conform", fn); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1169 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1170 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1171 octave_idx_type nc = x_nc; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1172 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1173 retval.resize (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1174 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1175 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1176 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1177 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1178 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1179 retval(i, j) = f (x(i, j), alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1180 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1181 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1182 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1183 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1184 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1185 do_bessel (fptr f, const char *, float alpha, const FloatComplexNDArray& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1186 bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1187 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1188 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1189 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1190 FloatComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1191 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1192 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1193 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1194 for (octave_idx_type i = 0; i < nel; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1195 retval(i) = f (x(i), alpha, (scaled ? 2 : 1), ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1196 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1197 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1198 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1199 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1200 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1201 do_bessel (fptr f, const char *, const FloatNDArray& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1202 const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1203 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1204 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1205 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1206 FloatComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1207 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1208 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1209 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1210 for (octave_idx_type i = 0; i < nel; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1211 retval(i) = f (x, alpha(i), (scaled ? 2 : 1), ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1212 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1213 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1214 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1215 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1216 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1217 do_bessel (fptr f, const char *fn, const FloatNDArray& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1218 const FloatComplexNDArray& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1219 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1220 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1221 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1222 FloatComplexNDArray retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1223 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1224 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1225 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1226 ("%s: the sizes of alpha and x must conform", fn); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1227 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1228 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1229 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1230 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1231 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1232 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1233 for (octave_idx_type i = 0; i < nel; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1234 retval(i) = f (x(i), alpha(i), (scaled ? 2 : 1), ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1235 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1236 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1237 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1238 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1239 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1240 do_bessel (fptr f, const char *, const FloatRowVector& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1241 const FloatComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1242 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1243 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1244 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1245 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1246 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1247 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1248 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1249 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1250 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1251 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1252 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1253 retval(i, j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1254 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1255 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1256 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1257 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1258 #define SS_BESSEL(name, fcn) \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1259 FloatComplex \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1260 name (float alpha, const FloatComplex& x, bool scaled, \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1261 octave_idx_type& ierr) \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1262 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1263 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1264 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1265 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1266 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1267 FloatComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1268 name (float alpha, const FloatComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1269 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1270 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1271 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1272 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1273 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1274 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1275 FloatComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1276 name (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1277 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1278 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1279 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1280 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1281 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1282 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1283 FloatComplexMatrix \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1284 name (const FloatMatrix& alpha, const FloatComplexMatrix& x, \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1285 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1286 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1287 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1288 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1289 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1290 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1291 FloatComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1292 name (float alpha, const FloatComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1293 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1294 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1295 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1296 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1297 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1298 #define NS_BESSEL(name, fcn) \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1299 FloatComplexNDArray \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1300 name (const FloatNDArray& alpha, const FloatComplex& x, \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1301 bool scaled, Array<octave_idx_type>& ierr) \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1302 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1303 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1304 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1305 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1306 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1307 FloatComplexNDArray \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1308 name (const FloatNDArray& alpha, const FloatComplexNDArray& x, \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1309 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1310 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1311 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1312 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1313 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1314 #define RC_BESSEL(name, fcn) \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1315 FloatComplexMatrix \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1316 name (const FloatRowVector& alpha, \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1317 const FloatComplexColumnVector& x, bool scaled, \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1318 Array<octave_idx_type>& ierr) \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1319 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1320 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1321 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1322 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1323 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1324 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1325 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1326 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1327 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1328 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1329 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1330 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1331 RC_BESSEL (name, fcn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1332 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1333 ALL_BESSEL (besselj, cbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1334 ALL_BESSEL (bessely, cbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1335 ALL_BESSEL (besseli, cbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1336 ALL_BESSEL (besselk, cbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1337 ALL_BESSEL (besselh1, cbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1338 ALL_BESSEL (besselh2, cbesh2) |
3220 | 1339 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1340 #undef ALL_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1341 #undef SS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1342 #undef SM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1343 #undef MS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1344 #undef MM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1345 #undef SN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1346 #undef NS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1347 #undef NN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1348 #undef RC_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1349 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1350 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1351 biry (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1352 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1353 double ar = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1354 double ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1355 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1356 double zr = z.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1357 double zi = z.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1358 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1359 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1360 F77_INT t_ierr; |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
1361 F77_INT sc = (scaled ? 2 : 1); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1362 |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
1363 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, sc, ar, ai, t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1364 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1365 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1366 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1367 if (zi == 0.0 && (! scaled || zr >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1368 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1369 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1370 return bessel_return_value (Complex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1371 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1372 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1373 ComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1374 biry (const ComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1375 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1376 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1377 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1378 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1379 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1380 ComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1381 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1382 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1383 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1384 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1385 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1386 retval(i, j) = biry (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1387 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1388 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1389 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1390 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1391 ComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1392 biry (const ComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1393 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1394 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1395 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1396 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1397 ComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1398 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1399 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1400 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1401 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1402 retval(i) = biry (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1403 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1404 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1405 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1406 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1407 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1408 biry (const FloatComplex& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1409 octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1410 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1411 FloatComplex a; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1412 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1413 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1414 F77_INT t_ierr; |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
1415 F77_INT sc = (scaled ? 2 : 1); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1416 |
30943
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
1417 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, sc, |
1f7fcac1fac9
lo-specfun.cc: Remove more duplication (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30942
diff
changeset
|
1418 F77_CMPLX_ARG (&a), t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1419 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1420 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1421 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1422 float ar = a.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1423 float ai = a.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1424 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1425 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1426 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1427 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1428 return bessel_return_value (FloatComplex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1429 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1430 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1431 FloatComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1432 biry (const FloatComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1433 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1434 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1435 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1436 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1437 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1438 FloatComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1439 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1440 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1441 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1442 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1443 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1444 retval(i, j) = biry (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1445 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1446 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1447 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1448 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1449 FloatComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1450 biry (const FloatComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1451 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1452 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1453 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1454 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1455 FloatComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1456 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1457 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1458 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1459 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1460 retval(i) = biry (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1461 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1462 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1463 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1464 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1465 // Real and complex Dawson function (= scaled erfi) from Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1466 double dawson (double x) { return Faddeeva::Dawson (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1467 float dawson (float x) { return Faddeeva::Dawson (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1468 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1469 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1470 dawson (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1471 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1472 return Faddeeva::Dawson (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1473 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1474 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1475 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1476 dawson (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1477 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1478 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1479 Complex ret; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1480 ret = Faddeeva::Dawson (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1481 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1482 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1483 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1484 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1485 ellipj (double u, double m, double& sn, double& cn, double& dn, double& err) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1486 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1487 static const int Nmax = 16; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1488 double m1, t=0, si_u, co_u, se_u, ta_u, b, c[Nmax], a[Nmax], phi; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1489 int n, Nn, ii; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1490 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1491 if (m < 0 || m > 1) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1492 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1493 (*current_liboctave_warning_with_id_handler) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1494 ("Octave:ellipj-invalid-m", |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1495 "ellipj: invalid M value, required value 0 <= M <= 1"); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1496 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1497 sn = cn = dn = lo_ieee_nan_value (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1498 |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1499 return; |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1500 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1501 |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1502 double sqrt_eps = std::sqrt (std::numeric_limits<double>::epsilon ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1503 if (m < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1504 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1505 // For small m, (Abramowitz and Stegun, Section 16.13) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1506 si_u = sin (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1507 co_u = cos (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1508 t = 0.25*m*(u - si_u*co_u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1509 sn = si_u - t * co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1510 cn = co_u + t * si_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1511 dn = 1 - 0.5*m*si_u*si_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1512 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1513 else if ((1 - m) < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1514 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1515 // For m1 = (1-m) small (Abramowitz and Stegun, Section 16.15) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1516 m1 = 1 - m; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1517 si_u = sinh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1518 co_u = cosh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1519 ta_u = tanh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1520 se_u = 1/co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1521 sn = ta_u + 0.25*m1*(si_u*co_u - u)*se_u*se_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1522 cn = se_u - 0.25*m1*(si_u*co_u - u)*ta_u*se_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1523 dn = se_u + 0.25*m1*(si_u*co_u + u)*ta_u*se_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1524 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1525 else |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1526 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1527 // Arithmetic-Geometric Mean (AGM) algorithm |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1528 // (Abramowitz and Stegun, Section 16.4) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1529 a[0] = 1; |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1530 b = std::sqrt (1 - m); |
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1531 c[0] = std::sqrt (m); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1532 for (n = 1; n < Nmax; ++n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1533 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1534 a[n] = (a[n - 1] + b)/2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1535 c[n] = (a[n - 1] - b)/2; |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1536 b = std::sqrt (a[n - 1]*b); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1537 if (c[n]/a[n] < std::numeric_limits<double>::epsilon ()) break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1538 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1539 if (n >= Nmax - 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1540 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1541 err = 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1542 return; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1543 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1544 Nn = n; |
26442
3d1a335fb9ce
lo-specfun.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
1545 for (ii = 1; n > 0; ii *= 2, --n) {} // ii = pow(2,Nn) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1546 phi = ii*a[Nn]*u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1547 for (n = Nn; n > 0; --n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1548 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23668
diff
changeset
|
1549 phi = (std::asin ((c[n]/a[n])* sin (phi)) + phi)/2; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1550 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1551 sn = sin (phi); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1552 cn = cos (phi); |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1553 dn = std::sqrt (1 - m*sn*sn); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1554 } |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1555 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1556 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1557 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1558 ellipj (const Complex& u, double m, Complex& sn, Complex& cn, Complex& dn, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1559 double& err) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1560 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1561 double m1 = 1 - m, ss1, cc1, dd1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1562 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1563 ellipj (u.imag (), m1, ss1, cc1, dd1, err); |
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1564 if (u.real () == 0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1565 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1566 // u is pure imag: Jacoby imag. transf. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1567 sn = Complex (0, ss1/cc1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1568 cn = 1/cc1; // cn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1569 dn = dd1/cc1; // dn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1570 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1571 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1572 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1573 // u is generic complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1574 double ss, cc, dd, ddd; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1575 |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22197
diff
changeset
|
1576 ellipj (u.real (), m, ss, cc, dd, err); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1577 ddd = cc1*cc1 + m*ss*ss*ss1*ss1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1578 sn = Complex (ss*dd1/ddd, cc*dd*ss1*cc1/ddd); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1579 cn = Complex (cc*cc1/ddd, -ss*dd*ss1*dd1/ddd); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1580 dn = Complex (dd*cc1*dd1/ddd, -m*ss*cc*ss1/ddd); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1581 } |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1582 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1583 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1584 // Complex error function from the Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1585 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1586 erf (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1587 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1588 return Faddeeva::erf (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1589 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1590 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1591 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1592 erf (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1593 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1594 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1595 Complex ret = Faddeeva::erf (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1596 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1597 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1598 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1599 // Complex complementary error function from the Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1600 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1601 erfc (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1602 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1603 return Faddeeva::erfc (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1604 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1605 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1606 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1607 erfc (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1608 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1609 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1610 Complex ret = Faddeeva::erfc (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1611 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1612 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1613 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1614 // The algorithm for erfcinv is an adaptation of the erfinv algorithm |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1615 // above from P. J. Acklam. It has been modified to run over the |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1616 // different input domain of erfcinv. See the notes for erfinv for an |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1617 // explanation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1618 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1619 static double do_erfcinv (double x, bool refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1620 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1621 // Coefficients of rational approximation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1622 static const double a[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1623 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1624 -2.806989788730439e+01, 1.562324844726888e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1625 -1.951109208597547e+02, 9.783370457507161e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1626 -2.168328665628878e+01, 1.772453852905383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1627 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1628 static const double b[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1629 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1630 -5.447609879822406e+01, 1.615858368580409e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1631 -1.556989798598866e+02, 6.680131188771972e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1632 -1.328068155288572e+01 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1633 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1634 static const double c[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1635 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1636 -5.504751339936943e-03, -2.279687217114118e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1637 -1.697592457770869e+00, -1.802933168781950e+00, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1638 3.093354679843505e+00, 2.077595676404383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1639 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1640 static const double d[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1641 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1642 7.784695709041462e-03, 3.224671290700398e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1643 2.445134137142996e+00, 3.754408661907416e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1644 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1645 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1646 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1647 static const double pbreak_lo = 0.04850; // 1-pbreak |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1648 static const double pbreak_hi = 1.95150; // 1+pbreak |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1649 double y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1650 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1651 // Select case. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1652 if (x >= pbreak_lo && x <= pbreak_hi) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1653 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1654 // Middle region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1655 const double q = 0.5*(1-x), r = q*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1656 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1657 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1658 y = yn / yd; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1659 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1660 else if (x > 0.0 && x < 2.0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1661 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1662 // Tail region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1663 const double q = (x < 1 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1664 ? std::sqrt (-2*std::log (0.5*x)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1665 : std::sqrt (-2*std::log (0.5*(2-x)))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1666 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1667 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1668 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1669 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1670 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1671 y = yn / yd; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1672 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1673 if (x < pbreak_lo) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1674 y = -y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1675 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1676 else if (x == 0.0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1677 return numeric_limits<double>::Inf (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1678 else if (x == 2.0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1679 return -numeric_limits<double>::Inf (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1680 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1681 return numeric_limits<double>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1682 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1683 if (refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1684 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1685 // One iteration of Halley's method gives full precision. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1686 double u = (erf (y) - (1-x)) * spi2 * exp (y*y); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1687 y -= u / (1 + y*u); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1688 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1689 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1690 return y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1691 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1692 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1693 double erfcinv (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1694 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1695 return do_erfcinv (x, true); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1696 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1697 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1698 float erfcinv (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1699 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1700 return do_erfcinv (x, false); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1701 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1702 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1703 // Real and complex scaled complementary error function from Faddeeva pkg. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1704 double erfcx (double x) { return Faddeeva::erfcx (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1705 float erfcx (float x) { return Faddeeva::erfcx (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1706 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1707 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1708 erfcx (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1709 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1710 return Faddeeva::erfcx (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1711 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1712 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1713 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1714 erfcx (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1715 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1716 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1717 Complex ret; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1718 ret = Faddeeva::erfcx (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1719 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1720 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1721 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1722 // Real and complex imaginary error function from Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1723 double erfi (double x) { return Faddeeva::erfi (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1724 float erfi (float x) { return Faddeeva::erfi (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1725 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1726 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1727 erfi (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1728 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1729 return Faddeeva::erfi (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1730 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1731 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1732 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1733 erfi (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1734 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1735 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1736 Complex ret = Faddeeva::erfi (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1737 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1738 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1739 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1740 // This algorithm is due to P. J. Acklam. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1741 // |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1742 // See http://home.online.no/~pjacklam/notes/invnorm/ |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1743 // |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1744 // The rational approximation has relative accuracy 1.15e-9 in the whole |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1745 // region. For doubles, it is refined by a single step of Halley's 3rd |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1746 // order method. For single precision, the accuracy is already OK, so |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1747 // we skip it to get faster evaluation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1748 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1749 static double do_erfinv (double x, bool refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1750 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1751 // Coefficients of rational approximation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1752 static const double a[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1753 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1754 -2.806989788730439e+01, 1.562324844726888e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1755 -1.951109208597547e+02, 9.783370457507161e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1756 -2.168328665628878e+01, 1.772453852905383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1757 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1758 static const double b[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1759 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1760 -5.447609879822406e+01, 1.615858368580409e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1761 -1.556989798598866e+02, 6.680131188771972e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1762 -1.328068155288572e+01 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1763 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1764 static const double c[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1765 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1766 -5.504751339936943e-03, -2.279687217114118e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1767 -1.697592457770869e+00, -1.802933168781950e+00, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1768 3.093354679843505e+00, 2.077595676404383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1769 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1770 static const double d[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1771 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1772 7.784695709041462e-03, 3.224671290700398e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1773 2.445134137142996e+00, 3.754408661907416e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1774 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1775 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1776 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1777 static const double pbreak = 0.95150; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1778 double ax = fabs (x), y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1779 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1780 // Select case. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1781 if (ax <= pbreak) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1782 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1783 // Middle region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1784 const double q = 0.5 * x, r = q*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1785 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1786 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1787 y = yn / yd; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1788 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1789 else if (ax < 1.0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1790 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1791 // Tail region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1792 const double q = std::sqrt (-2*std::log (0.5*(1-ax))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1793 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1794 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1795 y = yn / yd * math::signum (-x); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1796 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1797 else if (ax == 1.0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1798 return numeric_limits<double>::Inf () * math::signum (x); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1799 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1800 return numeric_limits<double>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1801 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1802 if (refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1803 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1804 // One iteration of Halley's method gives full precision. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1805 double u = (erf (y) - x) * spi2 * exp (y*y); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1806 y -= u / (1 + y*u); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1807 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1808 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1809 return y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1810 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1811 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1812 double erfinv (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1813 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1814 return do_erfinv (x, true); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1815 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1816 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1817 float erfinv (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1818 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1819 return do_erfinv (x, false); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1820 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1821 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1822 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1823 expm1 (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1824 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1825 Complex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1826 |
24199
2ac103974d00
Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents:
23761
diff
changeset
|
1827 if (std::abs (x) < 1) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1828 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1829 double im = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1830 double u = expm1 (x.real ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1831 double v = sin (im/2); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1832 v = -2*v*v; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1833 retval = Complex (u*v + u + v, (u+1) * sin (im)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1834 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1835 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1836 retval = std::exp (x) - Complex (1); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1837 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1838 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1839 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1840 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1841 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1842 expm1 (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1843 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1844 FloatComplex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1845 |
24199
2ac103974d00
Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents:
23761
diff
changeset
|
1846 if (std::abs (x) < 1) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1847 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1848 float im = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1849 float u = expm1 (x.real ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1850 float v = sin (im/2); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1851 v = -2*v*v; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1852 retval = FloatComplex (u*v + u + v, (u+1) * sin (im)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1853 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1854 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1855 retval = std::exp (x) - FloatComplex (1); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1856 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1857 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1858 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1859 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1860 double |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1861 gamma (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1862 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1863 double result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1864 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1865 // Special cases for (near) compatibility with Matlab instead of tgamma. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1866 // Matlab does not have -0. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1867 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1868 if (x == 0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1869 result = (math::negative_sign (x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1870 ? -numeric_limits<double>::Inf () |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1871 : numeric_limits<double>::Inf ()); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1872 else if ((x < 0 && math::x_nint (x) == x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1873 || math::isinf (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1874 result = numeric_limits<double>::Inf (); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1875 else if (math::isnan (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1876 result = numeric_limits<double>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1877 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1878 result = std::tgamma (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1879 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1880 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1881 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1882 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1883 float |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1884 gamma (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1885 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1886 float result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1887 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1888 // Special cases for (near) compatibility with Matlab instead of tgamma. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1889 // Matlab does not have -0. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1890 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1891 if (x == 0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1892 result = (math::negative_sign (x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1893 ? -numeric_limits<float>::Inf () |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1894 : numeric_limits<float>::Inf ()); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1895 else if ((x < 0 && math::x_nint (x) == x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1896 || math::isinf (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1897 result = numeric_limits<float>::Inf (); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1898 else if (math::isnan (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1899 result = numeric_limits<float>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1900 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1901 result = std::tgammaf (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1902 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1903 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1904 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1905 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1906 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1907 log1p (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1908 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1909 Complex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1910 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1911 double r = x.real (), i = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1912 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1913 if (fabs (r) < 0.5 && fabs (i) < 0.5) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1914 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1915 double u = 2*r + r*r + i*i; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1916 retval = Complex (log1p (u / (1+std::sqrt (u+1))), |
30781
d041ca628d99
log1p: Correct order of arguments for atan2 (bug #62094).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
1917 atan2 (i, 1 + r)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1918 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1919 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1920 retval = std::log (Complex (1) + x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1921 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1922 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1923 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1924 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1925 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1926 log1p (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1927 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1928 FloatComplex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1929 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1930 float r = x.real (), i = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1931 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1932 if (fabs (r) < 0.5 && fabs (i) < 0.5) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1933 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1934 float u = 2*r + r*r + i*i; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1935 retval = FloatComplex (log1p (u / (1+std::sqrt (u+1))), |
30781
d041ca628d99
log1p: Correct order of arguments for atan2 (bug #62094).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
1936 atan2 (i, 1 + r)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1937 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1938 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1939 retval = std::log (FloatComplex (1) + x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1940 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1941 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1942 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1943 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1944 static const double pi = 3.14159265358979323846; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1945 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1946 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1947 static inline T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1948 xlog (const T& x) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1949 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1950 return log (x); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1951 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1952 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1953 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1954 inline double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1955 xlog (const double& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1956 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
1957 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1958 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1959 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1960 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1961 inline float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1962 xlog (const float& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1963 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
1964 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1965 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1966 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1967 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1968 static T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1969 lanczos_approximation_psi (const T zc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1970 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1971 // Coefficients for C.Lanczos expansion of psi function from XLiFE++ |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1972 // gammaFunctions psi_coef[k] = - (2k+1) * lg_coef[k] (see melina++ |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1973 // gamma functions -1/12, 3/360,-5/1260, 7/1680,-9/1188, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1974 // 11*691/360360,-13/156, 15*3617/122400, ? , ? |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1975 static const T dg_coeff[10] = |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1976 { |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1977 -0.83333333333333333e-1, 0.83333333333333333e-2, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1978 -0.39682539682539683e-2, 0.41666666666666667e-2, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1979 -0.75757575757575758e-2, 0.21092796092796093e-1, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1980 -0.83333333333333333e-1, 0.4432598039215686, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1981 -0.3053954330270122e+1, 0.125318899521531e+2 |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1982 }; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1983 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1984 T overz2 = T (1.0) / (zc * zc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1985 T overz2k = overz2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1986 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1987 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1988 for (octave_idx_type k = 0; k < 10; k++, overz2k *= overz2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1989 p += dg_coeff[k] * overz2k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1990 p += xlog (zc) - T (0.5) / zc; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1991 return p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1992 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1993 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1994 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1995 T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1996 xpsi (T z) |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
1997 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1998 static const double euler_mascheroni |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1999 = 0.577215664901532860606512090082402431042; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2000 |
23726
1147e5c912aa
Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
2001 const bool is_int = (std::floor (z) == z); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2002 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2003 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2004 if (z <= 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2005 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2006 // limits - zeros of the gamma function |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2007 if (is_int) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2008 p = -numeric_limits<T>::Inf (); // Matlab returns -Inf for psi (0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2009 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2010 // Abramowitz and Stegun, page 259, eq 6.3.7 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2011 p = psi (1 - z) - (pi / tan (pi * z)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2012 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2013 else if (is_int) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2014 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2015 // Abramowitz and Stegun, page 258, eq 6.3.2 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2016 p = - euler_mascheroni; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2017 for (octave_idx_type k = z - 1; k > 0; k--) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2018 p += 1.0 / k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2019 } |
23726
1147e5c912aa
Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
2020 else if (std::floor (z + 0.5) == z + 0.5) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2021 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2022 // Abramowitz and Stegun, page 258, eq 6.3.3 and 6.3.4 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2023 for (octave_idx_type k = z; k > 0; k--) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2024 p += 1.0 / (2 * k - 1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2025 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2026 p = - euler_mascheroni - 2 * std::log (2) + 2 * (p); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2027 } |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2028 else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2029 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2030 // adapted from XLiFE++ gammaFunctions |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2031 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2032 T zc = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2033 // Use formula for derivative of LogGamma(z) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2034 if (z < 10) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2035 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2036 const signed char n = 10 - z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2037 for (signed char k = n - 1; k >= 0; k--) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2038 p -= 1.0 / (k + z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2039 zc += n; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2040 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2041 p += lanczos_approximation_psi (zc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2042 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2043 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2044 return p; |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2045 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2046 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2047 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2048 double psi (double z) { return xpsi (z); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2049 float psi (float z) { return xpsi (z); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2050 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2051 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2052 std::complex<T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2053 xpsi (const std::complex<T>& z) |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2054 { |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2055 // adapted from XLiFE++ gammaFunctions |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2056 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2057 typedef typename std::complex<T>::value_type P; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2058 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2059 P z_r = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2060 P z_ra = z_r; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2061 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2062 std::complex<T> dgam (0.0, 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2063 if (z.imag () == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2064 dgam = std::complex<T> (psi (z_r), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2065 else if (z_r < 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2066 dgam = psi (P (1.0) - z)- (P (pi) / tan (P (pi) * z)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2067 else |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2068 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2069 // Use formula for derivative of LogGamma(z) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2070 std::complex<T> z_m = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2071 if (z_ra < 8) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2072 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2073 unsigned char n = 8 - z_ra; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2074 z_m = z + std::complex<T> (n, 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2075 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2076 // Recurrence formula. For | Re(z) | < 8, use recursively |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2077 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2078 // DiGamma(z) = DiGamma(z+1) - 1/z |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2079 std::complex<T> z_p = z + P (n - 1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2080 for (unsigned char k = n; k > 0; k--, z_p -= 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2081 dgam -= P (1.0) / z_p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2082 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2083 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2084 // for | Re(z) | > 8, use derivative of C.Lanczos expansion for |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2085 // LogGamma |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2086 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2087 // psi(z) = log(z) - 1/(2z) - 1/12z^2 + 3/360z^4 - 5/1260z^6 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2088 // + 7/1680z^8 - 9/1188z^10 + ... |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2089 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2090 // (Abramowitz&Stegun, page 259, formula 6.3.18 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2091 dgam += lanczos_approximation_psi (z_m); |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2092 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2093 return dgam; |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2094 } |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2095 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2096 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2097 Complex psi (const Complex& z) { return xpsi (z); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2098 FloatComplex psi (const FloatComplex& z) { return xpsi (z); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2099 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2100 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2101 static inline void |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2102 fortran_psifn (T z, octave_idx_type n, T& ans, octave_idx_type& ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2103 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2104 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2105 inline void |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2106 fortran_psifn<double> (double z, octave_idx_type n_arg, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2107 double& ans, octave_idx_type& ierr) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2108 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2109 F77_INT n = to_f77_int (n_arg); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2110 F77_INT flag = 0; |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2111 F77_INT t_ierr; |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2112 F77_XFCN (dpsifn, DPSIFN, (z, n, 1, 1, ans, flag, t_ierr)); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2113 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2114 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2115 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2116 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2117 inline void |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2118 fortran_psifn<float> (float z, octave_idx_type n_arg, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2119 float& ans, octave_idx_type& ierr) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2120 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2121 F77_INT n = to_f77_int (n_arg); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2122 F77_INT flag = 0; |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2123 F77_INT t_ierr; |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2124 F77_XFCN (psifn, PSIFN, (z, n, 1, 1, ans, flag, t_ierr)); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2125 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2126 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2127 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2128 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2129 T |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2130 xpsi (octave_idx_type n, T z) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2131 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2132 T ans; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2133 octave_idx_type ierr = 0; |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2134 fortran_psifn<T> (z, n, ans, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2135 if (ierr == 0) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2136 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2137 // Remember that psifn and dpsifn return scales values |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2138 // When n is 1: do nothing since ((-1)**(n+1)/gamma(n+1)) == 1 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2139 // When n is 0: change sign since ((-1)**(n+1)/gamma(n+1)) == -1 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2140 if (n > 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2141 // FIXME: xgamma here is a killer for our precision since it grows |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2142 // way too fast. |
23639 | 2143 ans = ans / (std::pow (-1.0, n + 1) / gamma (double (n+1))); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2144 else if (n == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2145 ans = -ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2146 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2147 else if (ierr == 2) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2148 ans = - numeric_limits<T>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2149 else // we probably never get here |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2150 ans = numeric_limits<T>::NaN (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2151 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2152 return ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2153 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2154 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2155 double psi (octave_idx_type n, double z) { return xpsi (n, z); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2156 float psi (octave_idx_type n, float z) { return xpsi (n, z); } |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2157 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2158 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2159 rc_lgamma (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2160 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2161 double result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2162 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2163 #if defined (HAVE_LGAMMA_R) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2164 int sgngam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2165 result = lgamma_r (x, &sgngam); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2166 #else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2167 result = std::lgamma (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2168 int sgngam = signgam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2169 #endif |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2170 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2171 if (sgngam < 0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2172 return result + Complex (0., M_PI); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2173 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2174 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2175 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2176 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2177 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2178 rc_lgamma (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2179 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2180 float result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2181 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2182 #if defined (HAVE_LGAMMAF_R) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2183 int sgngam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2184 result = lgammaf_r (x, &sgngam); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2185 #else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2186 result = std::lgammaf (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2187 int sgngam = signgam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2188 #endif |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2189 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2190 if (sgngam < 0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2191 return result + FloatComplex (0., M_PI); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2192 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2193 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2194 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2195 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2196 Complex rc_log1p (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2197 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2198 return (x < -1.0 |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23726
diff
changeset
|
2199 ? Complex (std::log (-(1.0 + x)), M_PI) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2200 : Complex (log1p (x))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2201 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2202 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2203 FloatComplex rc_log1p (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2204 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2205 return (x < -1.0f |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23726
diff
changeset
|
2206 ? FloatComplex (std::log (-(1.0f + x)), M_PI) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2207 : FloatComplex (log1p (x))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2208 } |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31548
diff
changeset
|
2209 |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31548
diff
changeset
|
2210 OCTAVE_END_NAMESPACE(math) |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31548
diff
changeset
|
2211 OCTAVE_END_NAMESPACE(octave) |