annotate liboctave/numeric/lo-specfun.cc @ 30394:f3f3e3793fb5 stable

maint: style check C++ files in liboctave/ ahead of 7.1 release. * Array.cc, Array.h, CMatrix.cc, CSparse.cc, MArray.cc, MSparse.cc, MatrixType.cc, MatrixType.h, Range.cc, Range.h, Sparse.cc, Sparse.h, dMatrix.cc, dSparse.cc, fCMatrix.cc, fCMatrix.h, fMatrix.cc, fMatrix.h, idx-vector.cc, idx-vector.h, CollocWt.cc, CollocWt.h, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, Quad.cc, aepbalance.cc, chol.cc, eigs-base.cc, gepbalance.cc, gsvd.cc, lo-amos-proto.h, lo-arpack-proto.h, lo-blas-proto.h, lo-lapack-proto.h, lo-qrupdate-proto.h, lo-specfun.cc, oct-convn.h, oct-fftw.h, oct-norm.cc, oct-spparms.cc, randmtzig.cc, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, sparse-qr.h, svd.cc, file-ops.cc, file-stat.cc, lo-sysinfo.cc, oct-env.cc, f77-fcn.h, lo-cutils.h, lo-ieee.h, lo-regexp.cc, lo-utils.cc, oct-binmap.h, oct-inttypes.h, oct-sparse.cc, oct-sparse.h, oct-string.cc, url-transfer.cc: Style check C++ files in liboctave/ ahead of 7.1 release.
author Rik <rik@octave.org>
date Mon, 29 Nov 2021 10:03:47 -0800
parents 0a5b15007766
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27957
diff changeset
3 // Copyright (C) 1996-2021 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
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
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
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
28 #endif
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
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
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
36 #include "CColVector.h"
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
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
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
40 #include "dMatrix.h"
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
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
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
51 #include "lo-error.h"
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
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
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
55 #include "lo-specfun.h"
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
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
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
58 namespace octave
21231
5f318c8ec634 eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
59 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
60 namespace math
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
61 {
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
129
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
130 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
131 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
132 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
133 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
134 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
135
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
136 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
137 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
138
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
139 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
140 F77_INT nz, 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
141
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
142 F77_FUNC (zairy, ZAIRY) (zr, zi, id, 2, ar, ai, nz, 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
143
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
144 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
145
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
146 if (! scaled)
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 Complex expz = exp (- 2.0 / 3.0 * z * sqrt (z));
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 double rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
151 double iexpz = expz.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
152
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
153 double tmp = ar*rexpz - ai*iexpz;
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 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
156 ar = tmp;
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
159 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
160 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
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 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
163 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
164
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
165 ComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
166 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
167 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
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 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
170 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
171
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
172 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
173
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
174 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
175
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
176 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
177 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
178 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
179
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
180 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
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
183 ComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
184 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
185 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
186 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
187 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
188 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
189 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
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 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
192
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
193 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
194 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
195
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
196 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
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
199 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
200 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
201 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
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 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
204
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
205 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
206 F77_INT nz, 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
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 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, 2,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
209 F77_CMPLX_ARG (&a), nz, 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
210
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
211 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
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 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
214 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
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 if (! scaled)
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 FloatComplex expz = exp (- 2.0f / 3.0f * z * sqrt (z));
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 float rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
221 float iexpz = expz.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
222
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
223 float tmp = ar*rexpz - ai*iexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
224
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
225 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
226 ar = tmp;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
227 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
228
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
229 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
230 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
231
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
232 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
233 }
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 FloatComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
236 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
237 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
238 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
239 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
240 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
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 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
243
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
244 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
245
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
246 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
247 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
248 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
249
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
250 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
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
253 FloatComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
254 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
255 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
256 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
257 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
258 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
259 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
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 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
262
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
263 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
264 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
265
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
266 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
267 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
268
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
269 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
270 is_integer_value (double x)
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 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
273 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
274
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
275 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
276 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
277
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
278 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
279 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
280
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
281 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
282 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
283
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
284 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
285 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
286
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
287 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
288 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
289
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
290 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
291 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
292
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
293 static inline Complex
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
294 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
295 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
296 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
297
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
298 if (alpha >= 0.0)
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 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
301 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
302
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
303 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
304
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
305 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
306 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
307
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
308 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
309
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
310 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
311
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
312 if (zi == 0.0 && zr >= 0.0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
313 yi = 0.0;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
314
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
315 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
316 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
317 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
318 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
319 // 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
320 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
321 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
322 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
323 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
324 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
325 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
326 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
327 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
328 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
329
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
330 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
331
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
332 if (ierr == 0 || ierr == 3)
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 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
335
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
336 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
337 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
338 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
339 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
340 numeric_limits<double>::NaN ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
341 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
342
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
343 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
344 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
345
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
346 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
347 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
348 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
349 Complex retval;
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 (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
352 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
353 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
354 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
355
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
356 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
357
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
358 double wr, wi;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
359
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
360 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
361 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
362
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
363 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
364
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
365 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
366 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
367 yr = -numeric_limits<double>::Inf ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
368 yi = 0.0;
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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
371 {
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
372 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
373 &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
374
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
375 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
376
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
377 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
378 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
379 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
380
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
381 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
382 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
383 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
384 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
385 // 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
386 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
387 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
388 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
389 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
390 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
391 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
392 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
393 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
394 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
395
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
396 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
397
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
398 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
399 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
400 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
401
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
402 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
403 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
404 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
405 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
406 numeric_limits<double>::NaN ());
21786
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
409 return retval;
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
410 }
21786
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 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
413 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
414 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
415 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
416
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
417 if (alpha >= 0.0)
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 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
420 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
421
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
422 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
423
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
424 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
425 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
426
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
427 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
428
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
429 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
430
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
431 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
432 yi = 0.0;
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 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
435 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
436 else if (is_integer_value (alpha))
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 // 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
439 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
440 Complex tmp = zbesi (z, alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
441 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
442 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
443 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
444 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
445 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
446
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
447 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
448
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
449 if (ierr == 0 || ierr == 3)
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 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
452 * zbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
453
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
454 if (kode == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
455 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
456 // 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
457 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
458 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
459
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
460 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
461
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
462 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
463 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
464 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
465 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
466 numeric_limits<double>::NaN ());
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
467 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
468
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
469 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
470 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
471
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
472 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
473 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
474 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
475 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
476
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
477 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
478 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
479 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
480 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
481
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
482 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
483
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
484 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
485 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
486
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
487 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
488
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
489 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
490 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
491 yr = numeric_limits<double>::Inf ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
492 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
493 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
494 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
495 {
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
496 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
497 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
498
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
499 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
500
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
501 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
502 yi = 0.0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
503 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
504
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
505 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
506 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
507 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
508 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
509 Complex tmp = zbesk (z, -alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
510
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
511 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
512 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
513
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
514 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
515 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
516
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
517 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
518 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
519 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
520 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
521
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
522 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
523 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
524 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
525 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
526
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
527 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
528
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
529 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
530 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
531
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
532 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
533 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
534
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
535 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
536
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
537 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
538 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
539 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
540 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
541 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
542
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
543 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
544
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
545 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
546
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
547 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
548 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
549
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
550 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
551 }
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 inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
554 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
555 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
556 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
557
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
558 if (alpha >= 0.0)
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 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
561 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
562
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
563 F77_INT nz, t_ierr;
21786
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 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
566 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
567
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
568 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
569 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
570
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
571 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
572
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
573 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
574 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
575 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
576 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
577 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
578
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
579 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
580
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
581 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
582
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
583 retval = bessel_return_value (tmp, ierr);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
586 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
587 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
588
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
589 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
590
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
591 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
592 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
593 bool scaled, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
594 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
595 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
596
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
597 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
598
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
599 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
600 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
601
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
602 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
603 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
604 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
605 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
606 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
607 octave_idx_type nc = x.cols ();
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 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
610
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
611 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
612
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
613 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
614 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
615 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
616
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
617 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
618 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
619
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
620 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
621 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
622 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
623 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
624 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
625 octave_idx_type nc = alpha.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
626
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
627 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
628
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
629 ierr.resize (dim_vector (nr, 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 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
632 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
633 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
634
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
635 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
636 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
637
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
638 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
639 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
640 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
641 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
642 ComplexMatrix retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
643
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
644 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
645 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
646
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
647 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
648 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
649
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
650 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
651 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
652 ("%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
653
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
654 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
655 octave_idx_type nc = x_nc;
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 retval.resize (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
658
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
659 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
660
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
661 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
662 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
663 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
664
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
665 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
666 }
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 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
669 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
670 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
671 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
672 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
673 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
674 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
675
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
676 ierr.resize (dv);
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 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
679 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
680
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
681 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
682 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
683
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
684 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
685 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
686 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
687 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
688 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
689 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
690 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
691
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
692 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
693
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
694 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
695 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
696
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
697 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
698 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
699
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
700 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
701 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
702 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
703 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
704 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
705 ComplexNDArray retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
706
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
707 if (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
708 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
709 ("%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
710
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
711 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
712
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
713 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
714 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
715
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
716 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
717 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
718
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
719 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
720 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
721
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
722 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
723 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
724 const ComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
725 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
726 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
727 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
728 octave_idx_type nc = alpha.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
729
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
730 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
731
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
732 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
733
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
734 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
735 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
736 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
737
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
738 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
739 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
740
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
741 #define SS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
742 Complex \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
743 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
744 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
745 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
746 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
747
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
748 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
749 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
750 name (double alpha, const ComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
751 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
752 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
753 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
754 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
755
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
756 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
757 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
758 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
759 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
760 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
761 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
762 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
763
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
764 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
765 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
766 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
767 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
768 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
769 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
770 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
771
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
772 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
773 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
774 name (double alpha, const ComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
775 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
776 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
777 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
778 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
779
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
780 #define NS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
781 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
782 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
783 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
784 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
785 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
786 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
787
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
788 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
789 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
790 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
791 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
792 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
793 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
794 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
795
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
796 #define RC_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
797 ComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
798 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
799 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
800 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
801 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
802 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
803
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
804 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
805 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
806 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
807 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
808 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
809 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
810 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
811 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
812 RC_BESSEL (name, fcn)
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 ALL_BESSEL (besselj, zbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
815 ALL_BESSEL (bessely, zbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
816 ALL_BESSEL (besseli, zbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
817 ALL_BESSEL (besselk, zbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
818 ALL_BESSEL (besselh1, zbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
819 ALL_BESSEL (besselh2, zbesh2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
820
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
821 #undef ALL_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
822 #undef SS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
823 #undef SM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
824 #undef MS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
825 #undef MM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
826 #undef SN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
827 #undef NS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
828 #undef NN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
829 #undef RC_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
830
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
831 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
832 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
833
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
834 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
835 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
836
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
837 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
838 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
839
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
840 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
841 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
842
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
843 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
844 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
845
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
846 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
847 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
848
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
849 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
850 is_integer_value (float x)
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 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
853 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
854
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
855 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
856 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
857 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
858 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
859
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
860 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
861 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
862 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
863
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
864 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
865
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
866 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
867 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
868
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
869 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
870
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
871 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
872 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
873
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
874 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
875 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
876 else if (is_integer_value (alpha))
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 // 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
879 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
880 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
881 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
882 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
883 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
884 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
885 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
886 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
887 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
888
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
889 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
890 * cbesj (z, alpha, kode, 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 if (ierr == 0 || ierr == 3)
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 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
895 * cbesy (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
896
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
897 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
898 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
899 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
900 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
901 numeric_limits<float>::NaN ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
902 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
903
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
904 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
905 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
906
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
907 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
908 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
909 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
910 FloatComplex retval;
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 if (alpha >= 0.0)
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 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
915
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
916 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
917
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
918 FloatComplex w;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
919
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
920 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
921
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
922 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
923 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
924 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
925 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
926 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
927 {
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
928 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
929 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
930 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
931
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
932 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
933
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
934 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
935 y = FloatComplex (y.real (), 0.0);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
938 return bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
939 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
940 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
941 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
942 // 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
943 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
944 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
945 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
946 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
947 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
948 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
949 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
950 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
951 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
952
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
953 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
954 * cbesy (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
955
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
956 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
957 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
958 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
959 * cbesj (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
960
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
961 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
962 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
963 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
964 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
965 numeric_limits<float>::NaN ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
966 }
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 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
971 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
972 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
973 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
974 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
975
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
976 if (alpha >= 0.0)
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 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
979
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
980 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
981
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
982 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
983 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
984
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
985 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
986
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
987 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
988 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
989
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
990 retval = bessel_return_value (y, ierr);
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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
993 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
994 alpha = -alpha;
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 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
997
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
998 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
999 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1000 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
1001 * sinf (static_cast<float> (M_PI) * alpha)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1002 * cbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1003
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1004 if (kode == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1005 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1006 // 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
1007 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
1008 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1009
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1010 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1011
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1012 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1013 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1014 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
1015 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
1016 numeric_limits<float>::NaN ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1017 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1018
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1019 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1020 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1021
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1022 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1023 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
1024 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1025 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1026
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1027 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1028 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1029 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1030
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1031 F77_INT nz, t_ierr;
21786
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 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1034
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
1035 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
1036 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
1037 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
1038 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1039 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1040 {
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
1041 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
1042 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
1043
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1044 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1045
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
1046 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
1047 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1048 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1049
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1050 retval = bessel_return_value (y, ierr);
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 else
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 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
1055
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1056 retval = bessel_return_value (tmp, ierr);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1059 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1060 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1061
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1062 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1063 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
1064 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1065 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1066
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1067 if (alpha >= 0.0)
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 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1070
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1071 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1072
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
1073 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
1074 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
1075
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1076 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1077
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1078 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1079 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1080 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1081 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1082 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1083
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1084 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
1085
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1086 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
1087 * cbesh1 (z, alpha, kode, ierr);
21786
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 retval = bessel_return_value (tmp, ierr);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1092 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1093 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1094
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1095 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1096 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
1097 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1098 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1099
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1100 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1101 {
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1102 FloatComplex y = 0.0;;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1103
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1104 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1105
24906
451f4f291f46 Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents: 24904
diff changeset
1106 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
1107 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
1108
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1109 ierr = t_ierr;
21786
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 = bessel_return_value (y, 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 else
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 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1116
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1117 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
1118
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1119 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
1120 * cbesh2 (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1121
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1122 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1123 }
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 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1128 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
1129 octave_idx_type&);
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 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1132 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
1133 bool scaled, octave_idx_type& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1134 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1135 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1136
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1137 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
1138
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1139 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1140 }
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 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1143 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
1144 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
1145 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1146 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1147 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1148
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1149 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1150
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1151 ierr.resize (dim_vector (nr, nc));
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 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
1154 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
1155 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
1156
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1157 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1158 }
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 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1161 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
1162 const FloatComplex& x,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1163 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
1164 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1165 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1166 octave_idx_type nc = alpha.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1167
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1168 FloatComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1171
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1172 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
1173 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
1174 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
1175
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1176 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1177 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1178
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1179 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1180 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
1181 const FloatComplexMatrix& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1182 Array<octave_idx_type>& ierr)
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 FloatComplexMatrix retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1185
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1186 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
1187 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
1188
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1189 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
1190 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
1191
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1192 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
1193 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1194 ("%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
1195
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1196 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1197 octave_idx_type nc = x_nc;
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 retval.resize (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1200
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1201 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1202
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1203 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
1204 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
1205 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
1206
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1207 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1208 }
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 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1211 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
1212 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
1213 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1214 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1215 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1216 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1217
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1218 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1219
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1220 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
1221 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
1222
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1223 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1224 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1225
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1226 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1227 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
1228 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
1229 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1230 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1231 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1232 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1233
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1234 ierr.resize (dv);
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 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
1237 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
1238
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1239 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1240 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1241
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1242 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1243 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
1244 const FloatComplexNDArray& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1245 Array<octave_idx_type>& ierr)
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 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1248 FloatComplexNDArray retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1249
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1250 if (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1251 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1252 ("%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
1253
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1254 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1255
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1256 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1257 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1258
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1259 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
1260 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
1261
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1262 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1263 }
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 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1266 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
1267 const FloatComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1268 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1269 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1270 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1271 octave_idx_type nc = alpha.numel ();
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 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1274
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1275 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1276
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1277 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
1278 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
1279 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
1280
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1281 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1282 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1283
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1284 #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
1285 FloatComplex \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1286 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
1287 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
1288 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1289 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
1290 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1291
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1292 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1293 FloatComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1294 name (float alpha, const FloatComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1295 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1296 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1297 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
1298 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1299
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1300 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1301 FloatComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1302 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
1303 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1304 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1305 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
1306 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1307
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1308 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1309 FloatComplexMatrix \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1310 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
1311 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1312 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1313 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
1314 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1315
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1316 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1317 FloatComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1318 name (float alpha, const FloatComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1319 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1320 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1321 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
1322 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1323
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1324 #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
1325 FloatComplexNDArray \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1326 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
1327 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
1328 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1329 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
1330 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1331
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1332 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1333 FloatComplexNDArray \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1334 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
1335 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1336 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1337 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
1338 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1339
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1340 #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
1341 FloatComplexMatrix \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1342 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
1343 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
1344 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
1345 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1346 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
1347 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1348
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1349 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1350 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1351 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1352 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1353 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1354 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1355 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1356 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1357 RC_BESSEL (name, fcn)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1358
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1359 ALL_BESSEL (besselj, cbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1360 ALL_BESSEL (bessely, cbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1361 ALL_BESSEL (besseli, cbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1362 ALL_BESSEL (besselk, cbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1363 ALL_BESSEL (besselh1, cbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1364 ALL_BESSEL (besselh2, cbesh2)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1365
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1366 #undef ALL_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1367 #undef SS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1368 #undef SM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1369 #undef MS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1370 #undef MM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1371 #undef SN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1372 #undef NS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1373 #undef NN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1374 #undef RC_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1375
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1376 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1377 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
1378 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1379 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
1380 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
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 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
1383 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
1384
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1385 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
1386 F77_INT 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
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 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, 2, ar, ai, 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
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 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
1391
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1392 if (! 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 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1394 Complex expz = exp (std::abs (std::real (2.0 / 3.0 * z * sqrt (z))));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1395
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1396 double rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1397 double iexpz = expz.imag ();
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 double tmp = ar*rexpz - ai*iexpz;
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 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1402 ar = tmp;
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1405 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
1406 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
1407
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1408 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
1409 }
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 ComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1412 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
1413 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
1414 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1415 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
1416 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
1417
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1418 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
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.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
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 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
1423 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
1424 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
1425
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1426 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
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1429 ComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1430 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
1431 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
1432 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1433 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
1434 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
1435 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
1436
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1437 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
1438
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1439 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
1440 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
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 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
1443 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1444
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1445 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1446 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
1447 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
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 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
1450
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1451 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
1452 F77_INT 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
1453
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1454 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, 2,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1455 F77_CMPLX_ARG (&a), 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
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 = 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
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 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
1460 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
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 if (! scaled)
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 FloatComplex expz
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1465 = exp (std::abs (std::real (2.0f / 3.0f * z * sqrt (z))));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1466
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 rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1468 float iexpz = expz.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1469
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1470 float tmp = ar*rexpz - ai*iexpz;
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 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1473 ar = tmp;
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1476 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
1477 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
1478
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1479 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
1480 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1481
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1482 FloatComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1483 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
1484 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
1485 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1486 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
1487 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
1488
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1489 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
1490
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1491 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
1492
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1493 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
1494 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
1495 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
1496
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1497 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
1498 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1499
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1500 FloatComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1501 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
1502 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
1503 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1504 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
1505 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
1506 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
1507
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1508 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
1509
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1510 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
1511 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
1512
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1513 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
1514 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1515
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1516 // 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
1517 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
1518 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
1519
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1520 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1521 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
1522 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1523 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
1524 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1525
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1526 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1527 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
1528 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1529 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
1530 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
1531 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
1532 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
1533 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1534
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1535 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1536 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
1537 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1538 static const int Nmax = 16;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1539 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
1540 int n, Nn, ii;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1541
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1542 if (m < 0 || m > 1)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1543 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1544 (*current_liboctave_warning_with_id_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1545 ("Octave:ellipj-invalid-m",
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1546 "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
1547
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1548 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
1549
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1550 return;
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1551 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1552
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
1553 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
1554 if (m < sqrt_eps)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1555 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1556 // 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
1557 si_u = sin (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1558 co_u = cos (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1559 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
1560 sn = si_u - t * co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1561 cn = co_u + t * si_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1562 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
1563 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1564 else if ((1 - m) < sqrt_eps)
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 // 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
1567 m1 = 1 - m;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1568 si_u = sinh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1569 co_u = cosh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1570 ta_u = tanh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1571 se_u = 1/co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1572 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
1573 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
1574 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
1575 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1576 else
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1577 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1578 // Arithmetic-Geometric Mean (AGM) algorithm
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1579 // (Abramowitz and Stegun, Section 16.4)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1580 a[0] = 1;
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
1581 b = std::sqrt (1 - m);
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
1582 c[0] = std::sqrt (m);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1583 for (n = 1; n < Nmax; ++n)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1584 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1585 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
1586 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
1587 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
1588 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
1589 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1590 if (n >= Nmax - 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1591 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1592 err = 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1593 return;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1594 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1595 Nn = n;
26442
3d1a335fb9ce lo-specfun.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 26376
diff changeset
1596 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
1597 phi = ii*a[Nn]*u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1598 for (n = Nn; n > 0; --n)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1599 {
23682
6fe13cd3543c Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents: 23668
diff changeset
1600 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
1601 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1602 sn = sin (phi);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1603 cn = cos (phi);
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
1604 dn = std::sqrt (1 - m*sn*sn);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1605 }
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1606 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1607
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1608 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1609 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
1610 double& err)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1611 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1612 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
1613
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
1614 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
1615 if (u.real () == 0)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1616 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1617 // 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
1618 sn = Complex (0, ss1/cc1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1619 cn = 1/cc1; // cn.imag = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1620 dn = dd1/cc1; // dn.imag = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1621 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1622 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1623 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1624 // u is generic complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1625 double ss, cc, dd, ddd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1626
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
1627 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
1628 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
1629 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
1630 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
1631 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
1632 }
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
1633 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1634
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1635 // 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
1636 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1637 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
1638 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1639 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
1640 }
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 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1643 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
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 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
1646 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
1647 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
1648 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1649
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1650 // 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
1651 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1652 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
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 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
1655 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1656
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1657 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1658 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
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 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
1661 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
1662 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
1663 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1664
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 26442
diff changeset
1665 // 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
1666 // 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
1667 // 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
1668 // explanation.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1669
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1670 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
1671 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1672 // 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
1673 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
1674 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1675 -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
1676 -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
1677 -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
1678 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1679 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
1680 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1681 -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
1682 -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
1683 -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
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 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
1686 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1687 -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
1688 -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
1689 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
1690 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1691 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
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 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
1694 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
1695 };
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 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
1698 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
1699 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
1700 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
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 // 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
1703 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
1704 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1705 // 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
1706 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
1707 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
1708 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
1709 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
1710 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1711 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
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 // 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
1714 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
1715 ? 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
1716 : 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
1717
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1718 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
1719
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1720 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
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 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
1723
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1724 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
1725 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
1726 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1727 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
1728 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
1729 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
1730 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
1731 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
1732 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
1733
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1734 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
1735 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1736 // 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
1737 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
1738 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
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1741 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
1742 }
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 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
1745 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1746 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
1747 }
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 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
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 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
1752 }
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 // 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
1755 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
1756 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
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 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1759 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
1760 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1761 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
1762 }
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 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1765 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
1766 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1767 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
1768 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
1769 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
1770 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
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1773 // 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
1774 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
1775 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
1776
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1777 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1778 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
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 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
1781 }
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 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1784 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
1785 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1786 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
1787 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
1788 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
1789 }
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 // 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
1792 //
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1793 // 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
1794 //
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1795 // 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
1796 // 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
1797 // 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
1798 // 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
1799
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1800 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
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 // 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
1803 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
1804 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1805 -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
1806 -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
1807 -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
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 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
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 -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
1812 -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
1813 -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
1814 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1815 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
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 -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
1818 -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
1819 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
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 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
1822 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1823 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
1824 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
1825 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1826
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1827 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
1828 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
1829 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
1830
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1831 // 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
1832 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
1833 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1834 // 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
1835 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
1836 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
1837 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
1838 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
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 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
1841 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1842 // 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
1843 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
1844 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
1845 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
1846 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
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 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
1849 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
1850 else
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
1851 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
1852
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1853 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
1854 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1855 // 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
1856 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
1857 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
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 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
1861 }
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 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
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 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
1866 }
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 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
1869 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1870 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
1871 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1872
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1873 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1874 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
1875 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1876 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
1877
24199
2ac103974d00 Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents: 23761
diff changeset
1878 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
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 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
1881 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
1882 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
1883 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
1884 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
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 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1887 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
1888
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1889 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
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1892 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1893 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
1894 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1895 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
1896
24199
2ac103974d00 Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents: 23761
diff changeset
1897 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
1898 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1899 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
1900 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
1901 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
1902 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
1903 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
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 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1906 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
1907
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1908 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
1909 }
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1912 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
1913 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1914 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
1915
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1916 // 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
1917 // 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
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 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
1920 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
1921 ? -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
1922 : 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
1923 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
1924 || math::isinf (x))
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
1925 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
1926 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
1927 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
1928 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1929 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
1930
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1931 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
1932 }
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
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1935 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
1936 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1937 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
1938
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1939 // 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
1940 // 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
1941
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1942 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
1943 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
1944 ? -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
1945 : 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
1946 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
1947 || math::isinf (x))
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
1948 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
1949 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
1950 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
1951 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1952 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
1953
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1954 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
1955 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1956
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1957 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1958 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
1959 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1960 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
1961
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1962 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
1963
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1964 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
1965 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1966 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
1967 retval = Complex (log1p (u / (1+std::sqrt (u+1))),
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1968 atan2 (1 + r, i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1969 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1970 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1971 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
1972
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1973 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
1974 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1975
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1976 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1977 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
1978 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1979 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
1980
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1981 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
1982
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1983 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
1984 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1985 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
1986 retval = FloatComplex (log1p (u / (1+std::sqrt (u+1))),
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1987 atan2 (1 + r, i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1988 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1989 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1990 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
1991
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1992 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
1993 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1994
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1995 static const double pi = 3.14159265358979323846;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1996
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1997 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1998 static inline T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1999 xlog (const T& x)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2000 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2001 return log (x);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2002 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2003
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2004 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2005 inline double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2006 xlog (const double& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2007 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2008 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2009 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2010
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2011 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2012 inline float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2013 xlog (const float& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2014 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2015 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2016 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2017
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2018 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2019 static T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2020 lanczos_approximation_psi (const T zc)
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 // 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
2023 // 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
2024 // 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
2025 // 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
2026 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
2027 {
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26442
diff changeset
2028 -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
2029 -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
2030 -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
2031 -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
2032 -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
2033 };
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2034
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2035 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
2036 T overz2k = overz2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2037
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2038 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2039 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
2040 p += dg_coeff[k] * overz2k;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2041 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
2042 return p;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2045 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2046 T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2047 xpsi (T z)
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2048 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26442
diff changeset
2049 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
2050 = 0.577215664901532860606512090082402431042;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2051
23726
1147e5c912aa Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents: 23696
diff changeset
2052 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
2053
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2054 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2055 if (z <= 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2056 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2057 // limits - zeros of the gamma function
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2058 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
2059 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
2060 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2061 // 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
2062 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
2063 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2064 else if (is_int)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2065 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2066 // 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
2067 p = - euler_mascheroni;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2068 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
2069 p += 1.0 / k;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2070 }
23726
1147e5c912aa Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents: 23696
diff changeset
2071 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
2072 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2073 // 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
2074 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
2075 p += 1.0 / (2 * k - 1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2076
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2077 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
2078 }
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2079 else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2080 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2081 // adapted from XLiFE++ gammaFunctions
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 T zc = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2084 // 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
2085 if (z < 10)
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 const signed char n = 10 - z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2088 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
2089 p -= 1.0 / (k + z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2090 zc += n;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2091 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2092 p += lanczos_approximation_psi (zc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2093 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2094
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2095 return p;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2096 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2097
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2098 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2099 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
2100 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
2101
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2102 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2103 std::complex<T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2104 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
2105 {
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2106 // adapted from XLiFE++ gammaFunctions
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2107
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2108 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
2109
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2110 P z_r = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2111 P z_ra = z_r;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2112
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2113 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
2114 if (z.imag () == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2115 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
2116 else if (z_r < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2117 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
2118 else
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2119 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2120 // 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
2121 std::complex<T> z_m = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2122 if (z_ra < 8)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2123 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2124 unsigned char n = 8 - z_ra;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2125 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
2126
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2127 // 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
2128 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2129 // 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
2130 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
2131 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
2132 dgam -= P (1.0) / z_p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2133 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2134
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2135 // 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
2136 // LogGamma
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2137 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2138 // 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
2139 // + 7/1680z^8 - 9/1188z^10 + ...
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2140 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2141 // (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
2142 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
2143 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2144 return dgam;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2145 }
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
2146
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2147 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2148 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
2149 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
2150
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2151 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2152 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
2153 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
2154
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2155 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2156 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
2157 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
2158 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
2159 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
2160 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
2161 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
2162 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
2163 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
2164 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2165 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2166
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2167 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2168 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
2169 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
2170 float& ans, octave_idx_type& ierr)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
2171 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23682
diff changeset
2172 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
2173 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
2174 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
2175 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
2176 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2177 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2178
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2179 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2180 T
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2181 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
2182 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2183 T ans;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2184 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
2185 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
2186 if (ierr == 0)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
2187 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2188 // 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
2189 // 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
2190 // 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
2191 if (n > 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2192 // 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
2193 // way too fast.
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
2194 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
2195 else if (n == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2196 ans = -ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
2197 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2198 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
2199 ans = - numeric_limits<T>::Inf ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2200 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
2201 ans = numeric_limits<T>::NaN ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2202
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2203 return ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
2204 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2205
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2206 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
2207 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
2208
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2209 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2210 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
2211 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2212 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
2213
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2214 #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
2215 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
2216 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
2217 #else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2218 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
2219 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
2220 #endif
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2221
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2222 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
2223 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
2224 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2225 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
2226 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2227
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2228 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2229 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
2230 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2231 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
2232
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2233 #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
2234 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
2235 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
2236 #else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2237 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
2238 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
2239 #endif
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2240
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2241 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
2242 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
2243 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2244 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
2245 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2246
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2247 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
2248 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2249 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
2250 ? 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
2251 : 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
2252 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2253
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2254 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
2255 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2256 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
2257 ? 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
2258 : 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
2259 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2260 }
20161
65e22ba879f0 psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents: 20156
diff changeset
2261 }