Mercurial > octave
annotate liboctave/numeric/lo-specfun.cc @ 23463:5296657cde44
use lgamma if lgamma_r is not available (bug #50919)
* lo-specfun.cc (rc_lgamma): Use lgamma (or lgammaf) if lgamma_r
(or lgammaf_r) is not available. Only fall back to DLGAMS and ALGAMS
from SLATEC if both are missing.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 03 May 2017 09:32:56 -0400 |
parents | 855122b993da |
children | d691ed308237 |
rev | line source |
---|---|
3146 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
4 Copyright (C) 2007-2010 D. Martin |
10391
59e34bcdff13
implement built-in erfcx
Jaroslav Hajek <highegg@gmail.com>
parents:
10352
diff
changeset
|
5 Copyright (C) 2010 Jaroslav Hajek |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10414
diff
changeset
|
6 Copyright (C) 2010 VZLU Prague |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
22322
diff
changeset
|
7 Copyright (C) 2016 Carnë Draug |
3146 | 8 |
9 This file is part of Octave. | |
10 | |
11 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
12 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
13 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
14 (at your option) any later version. |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
15 |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
16 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
19 GNU General Public License for more details. |
3146 | 20 |
21 You should have received a copy of the GNU General Public License | |
7016 | 22 along with Octave; see the file COPYING. If not, see |
23 <http://www.gnu.org/licenses/>. | |
3146 | 24 |
25 */ | |
26 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
27 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21231
diff
changeset
|
28 # include "config.h" |
3146 | 29 #endif |
30 | |
31 #include "Range.h" | |
3220 | 32 #include "CColVector.h" |
33 #include "CMatrix.h" | |
34 #include "dRowVector.h" | |
3146 | 35 #include "dMatrix.h" |
4844 | 36 #include "dNDArray.h" |
37 #include "CNDArray.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
38 #include "fCColVector.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
39 #include "fCMatrix.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
40 #include "fRowVector.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
41 #include "fMatrix.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
42 #include "fNDArray.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
43 #include "fCNDArray.h" |
3146 | 44 #include "f77-fcn.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
45 #include "lo-amos-proto.h" |
3146 | 46 #include "lo-error.h" |
3220 | 47 #include "lo-ieee.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
48 #include "lo-slatec-proto.h" |
3220 | 49 #include "lo-specfun.h" |
3146 | 50 #include "mx-inlines.cc" |
5701 | 51 #include "lo-mappers.h" |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
52 #include "lo-math.h" |
3146 | 53 |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15271
diff
changeset
|
54 #include "Faddeeva.hh" |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15271
diff
changeset
|
55 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
56 namespace octave |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
57 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
58 namespace math |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
59 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
60 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
61 acosh (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
62 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
63 #if defined (HAVE_ACOSH) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
64 return ::acosh (x); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
65 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
66 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
67 F77_XFCN (xdacosh, XDACOSH, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
68 return retval; |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
69 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
70 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
71 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
72 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
73 acosh (float x) |
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 #if defined (HAVE_ACOSHF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
76 return acoshf (x); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
77 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
78 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
79 F77_XFCN (xacosh, XACOSH, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
80 return retval; |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
81 #endif |
21786
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
84 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
85 acosh (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
86 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
87 #if defined (HAVE_COMPLEX_STD_ACOSH) |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
88 return std::acosh (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
89 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
90 return log (x + sqrt (x + 1.0) * sqrt (x - 1.0)); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
91 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
92 } |
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 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
95 acosh (const FloatComplex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
96 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
97 #if defined (HAVE_COMPLEX_STD_ACOSH) |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
98 return std::acosh (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
99 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
100 return log (x + sqrt (x + 1.0f) * sqrt (x - 1.0f)); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
101 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
102 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
103 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
104 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
105 asinh (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
106 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
107 #if defined (HAVE_ASINH) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
108 return ::asinh (x); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
109 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
110 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
111 F77_XFCN (xdasinh, XDASINH, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
112 return retval; |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
113 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
114 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
115 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
116 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
117 asinh (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
118 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
119 #if defined (HAVE_ASINHF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
120 return asinhf (x); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
121 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
122 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
123 F77_XFCN (xasinh, XASINH, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
124 return retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
125 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
126 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
127 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
128 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
129 asinh (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
130 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
131 #if defined (HAVE_COMPLEX_STD_ASINH) |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
132 return std::asinh (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
133 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
134 return log (x + sqrt (x*x + 1.0)); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
135 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
136 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
137 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
138 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
139 asinh (const FloatComplex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
140 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
141 #if defined (HAVE_COMPLEX_STD_ASINH) |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
142 return std::asinh (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
143 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
144 return log (x + sqrt (x*x + 1.0f)); |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
145 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
146 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
147 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
148 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
149 atanh (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
150 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
151 #if defined (HAVE_ATANH) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
152 return ::atanh (x); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
153 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
154 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
155 F77_XFCN (xdatanh, XDATANH, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
156 return retval; |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
157 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
158 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
159 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
160 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
161 atanh (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
162 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
163 #if defined (HAVE_ATANHF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
164 return atanhf (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
165 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
166 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
167 F77_XFCN (xatanh, XATANH, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
168 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
169 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
170 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
171 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
172 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
173 atanh (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
174 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
175 #if defined (HAVE_COMPLEX_STD_ATANH) |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
176 return std::atanh (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
177 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
178 return log ((1.0 + x) / (1.0 - x)) / 2.0; |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
179 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
180 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
181 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
182 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
183 atanh (const FloatComplex& x) |
17708
f10b7a578e2c
Correct return values of gamma() (see Numerical, item 3 on Projects page).
Craig Hudson <c_hudson_phd@hotmail.com>
parents:
17502
diff
changeset
|
184 { |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
185 #if defined (HAVE_COMPLEX_STD_ATANH) |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
186 return std::atanh (x); |
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
187 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
188 return log ((1.0f + x) / (1.0f - x)) / 2.0f; |
21945
e9765b62d4e8
Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents:
21942
diff
changeset
|
189 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
190 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
191 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
192 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
193 erf (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
194 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
195 #if defined (HAVE_ERF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
196 return ::erf (x); |
11327
ef0e995f8c0f
correctly compute gamma for negative integer values when tgamma is available
Marco Atzeri <marco_atzeri@yahoo.it>
parents:
10902
diff
changeset
|
197 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
198 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
199 F77_XFCN (xderf, XDERF, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
200 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
201 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
202 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
203 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
204 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
205 erf (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
206 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
207 #if defined (HAVE_ERFF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
208 return erff (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
209 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
210 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
211 F77_XFCN (xerf, XERF, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
212 return retval; |
11327
ef0e995f8c0f
correctly compute gamma for negative integer values when tgamma is available
Marco Atzeri <marco_atzeri@yahoo.it>
parents:
10902
diff
changeset
|
213 #endif |
17708
f10b7a578e2c
Correct return values of gamma() (see Numerical, item 3 on Projects page).
Craig Hudson <c_hudson_phd@hotmail.com>
parents:
17502
diff
changeset
|
214 } |
6969 | 215 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
216 // Complex error function from the Faddeeva package |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
217 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
218 erf (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
219 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
220 return Faddeeva::erf (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
221 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
222 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
223 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
224 erf (const FloatComplex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
225 { |
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
|
226 Complex xd (x.real (), x.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
227 Complex ret = Faddeeva::erf (xd, std::numeric_limits<float>::epsilon ()); |
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
|
228 return FloatComplex (ret.real (), ret.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
229 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
230 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
231 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
232 erfc (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
233 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
234 #if defined (HAVE_ERFC) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
235 return ::erfc (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
236 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
237 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
238 F77_XFCN (xderfc, XDERFC, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
239 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
240 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
241 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
242 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
243 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
244 erfc (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
245 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
246 #if defined (HAVE_ERFCF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
247 return erfcf (x); |
6969 | 248 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
249 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
250 F77_XFCN (xerfc, XERFC, (x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
251 return retval; |
6969 | 252 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
253 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
254 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
255 // Complex complementary error function from the Faddeeva package |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
256 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
257 erfc (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
258 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
259 return Faddeeva::erfc (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
260 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
261 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
262 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
263 erfc (const FloatComplex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
264 { |
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
|
265 Complex xd (x.real (), x.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
266 Complex ret = Faddeeva::erfc (xd, std::numeric_limits<float>::epsilon ()); |
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
|
267 return FloatComplex (ret.real (), ret.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
268 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
269 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
270 // Real and complex scaled complementary error function from Faddeeva package |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
271 float erfcx (float x) { return Faddeeva::erfcx(x); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
272 double erfcx (double x) { return Faddeeva::erfcx(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 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
275 erfcx (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
276 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
277 return Faddeeva::erfcx (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
278 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
279 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
280 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
281 erfcx (const FloatComplex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
282 { |
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
|
283 Complex xd (x.real (), x.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
284 Complex ret = Faddeeva::erfcx (xd, std::numeric_limits<float>::epsilon ()); |
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
|
285 return FloatComplex (ret.real (), ret.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
286 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
287 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
288 // Real and complex imaginary error function from Faddeeva package |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
289 float erfi (float x) { return Faddeeva::erfi(x); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
290 double erfi (double x) { return Faddeeva::erfi(x); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
291 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
292 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
293 erfi (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
294 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
295 return Faddeeva::erfi (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
296 } |
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 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
299 erfi (const FloatComplex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
300 { |
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
|
301 Complex xd (x.real (), x.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
302 Complex ret = Faddeeva::erfi (xd, std::numeric_limits<float>::epsilon ()); |
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
|
303 return FloatComplex (ret.real (), ret.imag ()); |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
306 // Real and complex Dawson function (= scaled erfi) from Faddeeva package |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
307 float dawson (float x) { return Faddeeva::Dawson(x); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
308 double dawson (double x) { return Faddeeva::Dawson(x); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
309 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
310 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
311 dawson (const Complex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
312 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
313 return Faddeeva::Dawson (x); |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
316 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
317 dawson (const FloatComplex& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
318 { |
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
|
319 Complex xd (x.real (), x.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
320 Complex ret = Faddeeva::Dawson (xd, std::numeric_limits<float>::epsilon ()); |
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
|
321 return FloatComplex (ret.real (), ret.imag ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
322 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
323 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
324 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
325 gamma (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
326 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
327 double result; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
328 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
329 // Special cases for (near) compatibility with Matlab instead of |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
330 // tgamma. Matlab does not have -0. |
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 (x == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
333 result = (octave::math::negative_sign (x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
334 ? -octave::numeric_limits<double>::Inf () |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
335 : octave::numeric_limits<double>::Inf ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
336 else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
337 result = octave::numeric_limits<double>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
338 else if (octave::math::isnan (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
339 result = octave::numeric_limits<double>::NaN (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
340 else |
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 #if defined (HAVE_TGAMMA) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
343 result = tgamma (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
344 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
345 F77_XFCN (xdgamma, XDGAMMA, (x, result)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
346 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
347 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
348 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
349 return result; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
352 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
353 lgamma (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
354 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
355 #if defined (HAVE_LGAMMA) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
356 return ::lgamma (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
357 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
358 double result; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
359 double sgngam; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
360 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
361 if (octave::math::isnan (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
362 result = x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
363 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
364 result = octave::numeric_limits<double>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
365 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
366 F77_XFCN (dlgams, DLGAMS, (x, result, sgngam)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
367 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
368 return result; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
369 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
370 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
371 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
372 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
373 rc_lgamma (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
374 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
375 double result; |
7601
8a939b217863
Treat negative values to lgamma and beta correctly
David Bateman <dbateman@free.fr>
parents:
7176
diff
changeset
|
376 |
8a939b217863
Treat negative values to lgamma and beta correctly
David Bateman <dbateman@free.fr>
parents:
7176
diff
changeset
|
377 #if defined (HAVE_LGAMMA_R) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
378 int sgngam; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
379 result = lgamma_r (x, &sgngam); |
23463
5296657cde44
use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
380 #elif defined (HAVE_LGAMMA) |
5296657cde44
use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
381 result = lgamma (x); |
5296657cde44
use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
382 int sgngam = signgam; |
11327
ef0e995f8c0f
correctly compute gamma for negative integer values when tgamma is available
Marco Atzeri <marco_atzeri@yahoo.it>
parents:
10902
diff
changeset
|
383 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
384 double sgngam = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
385 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
386 if (octave::math::isnan (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
387 result = x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
388 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
389 result = octave::numeric_limits<double>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
390 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
391 F77_XFCN (dlgams, DLGAMS, (x, result, sgngam)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
392 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
393 #endif |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
394 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
395 if (sgngam < 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
396 return result + Complex (0., M_PI); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
397 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
398 return result; |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
399 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
400 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
401 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
402 gamma (float x) |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
403 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
404 float result; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
405 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
406 // Special cases for (near) compatibility with Matlab instead of |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
407 // tgamma. Matlab does not have -0. |
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 if (x == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
410 result = (octave::math::negative_sign (x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
411 ? -octave::numeric_limits<float>::Inf () |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
412 : octave::numeric_limits<float>::Inf ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
413 else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
414 result = octave::numeric_limits<float>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
415 else if (octave::math::isnan (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
416 result = octave::numeric_limits<float>::NaN (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
417 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
418 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
419 #if defined (HAVE_TGAMMA) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
420 result = tgammaf (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
421 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
422 F77_XFCN (xgamma, XGAMMA, (x, result)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
423 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
424 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
425 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
426 return result; |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
427 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
428 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
429 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
430 lgamma (float x) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
431 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
432 #if defined (HAVE_LGAMMAF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
433 return lgammaf (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
434 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
435 float result; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
436 float sgngam; |
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 if (octave::math::isnan (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
439 result = x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
440 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
441 result = octave::numeric_limits<float>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
442 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
443 F77_XFCN (algams, ALGAMS, (x, result, sgngam)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
444 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
445 return result; |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
446 #endif |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
447 } |
21786
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 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
450 rc_lgamma (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
451 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
452 float result; |
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 defined (HAVE_LGAMMAF_R) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
455 int sgngam; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
456 result = lgammaf_r (x, &sgngam); |
23463
5296657cde44
use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
457 #elif defined (HAVE_LGAMMAF) |
5296657cde44
use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
458 result = lgammaf (x); |
5296657cde44
use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
459 int sgngam = signgam; |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
460 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
461 float sgngam = 0.0f; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
462 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
463 if (octave::math::isnan (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
464 result = x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
465 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
466 result = octave::numeric_limits<float>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
467 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
468 F77_XFCN (algams, ALGAMS, (x, result, sgngam)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
469 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
470 #endif |
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 if (sgngam < 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
473 return result + FloatComplex (0., M_PI); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
474 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
475 return result; |
7638
2df457529cfa
implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents:
7601
diff
changeset
|
476 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
477 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
478 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
479 expm1 (double x) |
10414
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10391
diff
changeset
|
480 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
481 #if defined (HAVE_EXPM1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
482 return ::expm1 (x); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
483 #else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
484 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
485 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
486 double ax = fabs (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
487 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
488 if (ax < 0.1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
489 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
490 ax /= 16; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
491 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
492 // use Taylor series to calculate exp(x)-1. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
493 double t = ax; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
494 double s = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
495 for (int i = 2; i < 7; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
496 s += (t *= ax/i); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
497 s += ax; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
498 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
499 // use the identity (a+1)^2-1 = a*(a+2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
500 double e = s; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
501 for (int i = 0; i < 4; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
502 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
503 s *= e + 2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
504 e *= e + 2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
505 } |
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 retval = (x > 0) ? s : -s / (1+s); |
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 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
510 retval = exp (x) - 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
511 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
512 return retval; |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
513 #endif |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
514 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
515 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
516 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
517 expm1 (const Complex& x) |
3220 | 518 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
519 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
520 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
521 if (std:: abs (x) < 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
522 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
523 double im = x.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
524 double u = expm1 (x.real ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
525 double v = sin (im/2); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
526 v = -2*v*v; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
527 retval = Complex (u*v + u + v, (u+1) * sin (im)); |
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 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
530 retval = std::exp (x) - Complex (1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
531 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
532 return retval; |
3220 | 533 } |
534 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
535 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
536 expm1 (float x) |
3220 | 537 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
538 #if defined (HAVE_EXPM1F) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
539 return expm1f (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
540 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
541 float retval; |
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 float ax = fabs (x); |
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 if (ax < 0.1) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
546 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
547 ax /= 16; |
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 // use Taylor series to calculate exp(x)-1. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
550 float t = ax; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
551 float s = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
552 for (int i = 2; i < 7; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
553 s += (t *= ax/i); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
554 s += ax; |
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 // use the identity (a+1)^2-1 = a*(a+2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
557 float e = s; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
558 for (int i = 0; i < 4; i++) |
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 s *= e + 2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
561 e *= e + 2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
562 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
563 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
564 retval = (x > 0) ? s : -s / (1+s); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
565 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
566 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
567 retval = exp (x) - 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
568 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
569 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
570 #endif |
3220 | 571 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
572 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
573 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
574 expm1 (const FloatComplex& x) |
4911 | 575 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
576 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
577 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
578 if (std:: abs (x) < 1) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
579 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
580 float im = x.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
581 float u = expm1 (x.real ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
582 float v = sin (im/2); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
583 v = -2*v*v; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
584 retval = FloatComplex (u*v + u + v, (u+1) * sin (im)); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
585 } |
3220 | 586 else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
587 retval = std::exp (x) - FloatComplex (1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
588 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
589 return retval; |
3220 | 590 } |
591 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
592 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
593 log1p (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
594 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
595 #if defined (HAVE_LOG1P) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
596 return ::log1p (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
597 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
598 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
599 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
600 double ax = fabs (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
601 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
602 if (ax < 0.2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
603 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
604 // approximation log (1+x) ~ 2*sum ((x/(2+x)).^ii ./ ii), ii = 1:2:2n+1 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
605 double u = x / (2 + x), t = 1, s = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
606 for (int i = 2; i < 12; i += 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
607 s += (t *= u*u) / (i+1); |
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 retval = 2 * (s + 1) * u; |
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 else |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
612 retval = std::log (1 + x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
613 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
614 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
615 #endif |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
618 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
619 log1p (const Complex& x) |
3146 | 620 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
621 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
622 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
623 double r = x.real (), i = x.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
624 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
625 if (fabs (r) < 0.5 && fabs (i) < 0.5) |
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 double u = 2*r + r*r + i*i; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
628 retval = Complex (log1p (u / (1+sqrt (u+1))), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
629 atan2 (1 + r, i)); |
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 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
632 retval = std::log (Complex (1) + x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
633 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
634 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
635 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
636 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
637 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
638 T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
639 xcbrt (T x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
640 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
641 static const T one_third = 0.3333333333333333333f; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
642 if (octave::math::finite (x)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
643 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
644 // Use pow. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
645 T y = std::pow (std::abs (x), one_third) * signum (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
646 // Correct for better accuracy. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
647 return (x / (y*y) + y + y) / 3; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
648 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
649 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
650 return x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
651 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
652 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
653 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
654 cbrt (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
655 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
656 #if defined (HAVE_CBRT) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
657 return ::cbrt (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
658 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
659 return xxcbrt (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
660 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
661 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
662 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
663 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
664 log1p (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
665 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
666 #if defined (HAVE_LOG1PF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
667 return log1pf (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
668 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
669 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
670 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
671 float ax = fabs (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
672 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
673 if (ax < 0.2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
674 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
675 // approximation log (1+x) ~ 2*sum ((x/(2+x)).^ii ./ ii), ii = 1:2:2n+1 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
676 float u = x / (2 + x), t = 1.0f, s = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
677 for (int i = 2; i < 12; i += 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
678 s += (t *= u*u) / (i+1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
679 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
680 retval = 2 * (s + 1.0f) * u; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
681 } |
3220 | 682 else |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
683 retval = std::log (1.0f + x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
684 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
685 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
686 #endif |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
689 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
690 log1p (const FloatComplex& x) |
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 FloatComplex retval; |
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 float r = x.real (), i = x.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
695 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
696 if (fabs (r) < 0.5 && fabs (i) < 0.5) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
697 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
698 float u = 2*r + r*r + i*i; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
699 retval = FloatComplex (log1p (u / (1+sqrt (u+1))), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
700 atan2 (1 + r, i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
701 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
702 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
703 retval = std::log (FloatComplex (1) + x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
704 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
705 return 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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
708 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
709 cbrt (float x) |
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 #if defined (HAVE_CBRTF) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
712 return cbrtf (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
713 #else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
714 return xxcbrt (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
715 #endif |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
716 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
717 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
718 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
719 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
|
720 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
721 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
722 zbesy (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
|
723 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
724 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
725 zbesi (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
|
726 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
727 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
728 zbesk (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
|
729 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
730 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
731 zbesh1 (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
|
732 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
733 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
734 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
|
735 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
736 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
737 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
|
738 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
739 static const Complex inf_val |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
740 = Complex (octave::numeric_limits<double>::Inf (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
741 octave::numeric_limits<double>::Inf ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
742 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
743 static const Complex nan_val |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
744 = Complex (octave::numeric_limits<double>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
745 octave::numeric_limits<double>::NaN ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
746 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
747 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
748 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
749 switch (ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
750 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
751 case 0: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
752 case 3: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
753 retval = val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
754 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
755 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
756 case 2: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
757 retval = inf_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
758 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
759 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
760 default: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
761 retval = nan_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
762 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
763 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
764 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
765 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
766 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
767 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
768 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
769 is_integer_value (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
770 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
771 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
|
772 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
773 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
774 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
775 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
|
776 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
777 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
778 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
779 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
780 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
781 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
782 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
783 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
784 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
785 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
786 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
787 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
788 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
789 F77_FUNC (zbesj, ZBESJ) (zr, zi, alpha, 2, 1, &yr, &yi, 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
|
790 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
791 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
792 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
793 if (kode != 2) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
794 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
795 double expz = exp (std::abs (zi)); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
796 yr *= expz; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
797 yi *= expz; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
798 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
799 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
800 if (zi == 0.0 && zr >= 0.0) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
801 yi = 0.0; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
802 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
803 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
804 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
805 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
806 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
807 // 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
|
808 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
809 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
|
810 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
811 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
812 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
813 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
814 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
815 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
816 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
817 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
818 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
|
819 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
820 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
821 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
822 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
|
823 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
824 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
825 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
826 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
827 retval = Complex (octave::numeric_limits<double>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
828 octave::numeric_limits<double>::NaN ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
829 } |
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 return retval; |
3220 | 832 } |
21786
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 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
835 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
4911 | 836 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
837 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
838 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
839 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
840 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
841 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
842 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
843 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
844 F77_INT nz, t_ierr; |
21786
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 double wr, wi; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
847 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
848 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
849 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
850 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
851 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
852 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
853 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
|
854 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
855 yr = -octave::numeric_limits<double>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
856 yi = 0.0; |
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 else |
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 F77_FUNC (zbesy, ZBESY) (zr, zi, alpha, 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
|
861 &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
|
862 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
863 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
864 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
865 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
866 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
867 double expz = exp (std::abs (zi)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
868 yr *= expz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
869 yi *= expz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
870 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
871 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
872 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
|
873 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
874 } |
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 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
|
877 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
878 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
|
879 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
880 // 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
|
881 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
882 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
|
883 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
|
884 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
885 retval = bessel_return_value (tmp, ierr); |
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 else |
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 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
890 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
891 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
|
892 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
893 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
894 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
895 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
|
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
900 retval = Complex (octave::numeric_limits<double>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
901 octave::numeric_limits<double>::NaN ()); |
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; |
4911 | 905 } |
21786
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 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
908 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 909 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
910 Complex 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) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
913 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
914 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
915 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
916 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
917 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
918 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
919 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
920 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
921 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
922 F77_FUNC (zbesi, ZBESI) (zr, zi, alpha, 2, 1, &yr, &yi, 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
|
923 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
924 ierr = t_ierr; |
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 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
927 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
928 double expz = exp (std::abs (zr)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
929 yr *= expz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
930 yi *= expz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
931 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
932 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
933 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
|
934 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
935 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
936 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
|
937 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
938 else if (is_integer_value (alpha)) |
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 // 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
|
941 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
942 Complex tmp = zbesi (z, alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
943 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
944 } |
3220 | 945 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
946 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
947 alpha = -alpha; |
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 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
|
950 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
951 if (ierr == 0 || ierr == 3) |
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 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
|
954 * zbesk (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 (kode == 2) |
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 // 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
|
959 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
|
960 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
961 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
962 tmp += tmp2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
963 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
964 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
965 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
966 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
967 retval = Complex (octave::numeric_limits<double>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
968 octave::numeric_limits<double>::NaN ()); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
969 } |
3146 | 970 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
971 return retval; |
3146 | 972 } |
21786
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 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
975 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 976 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
977 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
978 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
979 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
980 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
981 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
982 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
983 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
984 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
985 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
986 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
987 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
988 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
989 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
990 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
991 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
|
992 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
993 yr = octave::numeric_limits<double>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
994 yi = 0.0; |
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 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
997 { |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
998 F77_FUNC (zbesk, ZBESK) (zr, zi, alpha, 2, 1, &yr, &yi, nz, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
999 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1000 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1001 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1002 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1003 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1004 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1005 Complex expz = exp (-z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1006 |
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
|
1007 double rexpz = expz.real (); |
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
|
1008 double iexpz = expz.imag (); |
21786
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 double tmp = yr*rexpz - yi*iexpz; |
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 yi = yr*iexpz + yi*rexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1013 yr = tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1014 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1015 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1016 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
|
1017 yi = 0.0; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1018 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
1019 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1020 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
|
1021 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1022 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1023 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1024 Complex tmp = zbesk (z, -alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1025 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1026 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1027 } |
21786
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 return retval; |
3220 | 1030 } |
1031 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1032 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1033 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 1034 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1035 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1036 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1037 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1038 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1039 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1040 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1041 |
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_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1043 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1044 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1045 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1046 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1047 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, 2, 1, 1, &yr, &yi, nz, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1048 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1049 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1050 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1051 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1052 if (kode != 2) |
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 Complex expz = exp (Complex (0.0, 1.0) * z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1055 |
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
|
1056 double rexpz = expz.real (); |
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
|
1057 double iexpz = expz.imag (); |
21786
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 double tmp = yr*rexpz - yi*iexpz; |
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 yi = yr*iexpz + yi*rexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1062 yr = tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1063 } |
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 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1066 } |
3220 | 1067 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1068 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1069 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1070 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1071 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
|
1072 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1073 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
|
1074 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1075 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1076 } |
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 return retval; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1081 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1082 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
|
1083 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1084 Complex retval; |
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 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1087 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1088 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1089 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1090 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1091 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1092 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1093 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1094 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1095 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1096 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, 2, 2, 1, &yr, &yi, nz, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1097 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1098 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1099 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1100 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1101 if (kode != 2) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1102 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1103 Complex expz = exp (-Complex (0.0, 1.0) * z); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1104 |
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
|
1105 double rexpz = expz.real (); |
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
|
1106 double iexpz = expz.imag (); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1107 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1108 double tmp = yr*rexpz - yi*iexpz; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1109 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1110 yi = yr*iexpz + yi*rexpz; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1111 yr = tmp; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1112 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1113 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1114 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
1115 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1116 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1117 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1118 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1119 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1120 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
|
1121 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1122 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
|
1123 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1124 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1125 } |
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 return retval; |
3220 | 1128 } |
3146 | 1129 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1130 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
|
1131 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1132 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1133 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
|
1134 bool scaled, octave_idx_type& ierr) |
3220 | 1135 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1136 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1137 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1138 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
|
1139 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1140 return retval; |
3220 | 1141 } |
3146 | 1142 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1143 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1144 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
|
1145 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 1146 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1147 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1148 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1149 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1150 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1151 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1152 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1153 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1154 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
|
1155 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1156 retval(i,j) = f (x(i,j), alpha, (scaled ? 2 : 1), ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1157 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1158 return retval; |
3146 | 1159 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1160 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1161 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1162 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
|
1163 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 1164 { |
21786
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 ComplexMatrix 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++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1174 retval(i,j) = f (x, alpha(i,j), (scaled ? 2 : 1), ierr(i,j)); |
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; |
3220 | 1177 } |
1178 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1179 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1180 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
|
1181 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
|
1182 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1183 ComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1184 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1185 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
|
1186 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
|
1187 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1188 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
|
1189 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
|
1190 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1191 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
|
1192 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1193 ("%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
|
1194 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1195 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1196 octave_idx_type nc = x_nc; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1197 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1198 retval.resize (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1199 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1200 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1201 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1202 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
|
1203 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1204 retval(i,j) = f (x(i,j), alpha(i,j), (scaled ? 2 : 1), ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1205 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1206 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1207 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1208 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1209 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1210 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
|
1211 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
|
1212 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1213 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1214 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1215 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1216 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1217 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1218 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1219 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
|
1220 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
|
1221 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1222 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1223 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1224 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1225 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1226 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
|
1227 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
|
1228 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1229 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1230 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1231 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1232 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1233 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1234 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1235 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
|
1236 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
|
1237 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1238 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1239 } |
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 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1242 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
|
1243 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
|
1244 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1245 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1246 ComplexNDArray retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1247 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1248 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1249 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1250 ("%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
|
1251 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1252 octave_idx_type nel = dv.numel (); |
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 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1255 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1256 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1257 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
|
1258 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
|
1259 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1260 return retval; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1263 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1264 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
|
1265 const ComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1266 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1267 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1268 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1269 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1270 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1271 ComplexMatrix retval (nr, nc); |
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 ierr.resize (dim_vector (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 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
|
1276 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1277 retval(i,j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1278 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1279 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1280 } |
3146 | 1281 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1282 #define SS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1283 Complex \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1284 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
|
1285 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1286 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
|
1287 } |
3220 | 1288 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1289 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1290 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1291 name (double alpha, const ComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1292 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1293 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1294 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
|
1295 } |
3220 | 1296 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1297 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1298 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1299 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
|
1300 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1301 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1302 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
|
1303 } |
3220 | 1304 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1305 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1306 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1307 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
|
1308 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1309 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1310 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
|
1311 } |
3220 | 1312 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1313 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1314 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1315 name (double alpha, const ComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1316 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1317 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1318 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
|
1319 } |
4844 | 1320 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1321 #define NS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1322 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1323 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
|
1324 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1325 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1326 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
|
1327 } |
4844 | 1328 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1329 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1330 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1331 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
|
1332 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1333 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1334 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
|
1335 } |
4844 | 1336 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1337 #define RC_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1338 ComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1339 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
|
1340 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1341 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1342 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
|
1343 } |
3220 | 1344 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1345 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1346 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1347 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1348 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1349 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1350 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1351 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1352 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1353 RC_BESSEL (name, fcn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1354 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1355 ALL_BESSEL (besselj, zbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1356 ALL_BESSEL (bessely, zbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1357 ALL_BESSEL (besseli, zbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1358 ALL_BESSEL (besselk, zbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1359 ALL_BESSEL (besselh1, zbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1360 ALL_BESSEL (besselh2, zbesh2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1361 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1362 #undef ALL_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1363 #undef SS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1364 #undef SM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1365 #undef MS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1366 #undef MM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1367 #undef SN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1368 #undef NS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1369 #undef NN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1370 #undef RC_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1371 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1372 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1373 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
|
1374 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1375 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1376 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
|
1377 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1378 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1379 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
|
1380 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1381 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1382 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
|
1383 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1384 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1385 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
|
1386 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1387 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1388 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
|
1389 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1390 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1391 bessel_return_value (const FloatComplex& val, octave_idx_type ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1392 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1393 static const FloatComplex inf_val |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1394 = FloatComplex (octave::numeric_limits<float>::Inf (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1395 octave::numeric_limits<float>::Inf ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1396 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1397 static const FloatComplex nan_val |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1398 = FloatComplex (octave::numeric_limits<float>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1399 octave::numeric_limits<float>::NaN ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1400 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1401 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1402 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1403 switch (ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1404 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1405 case 0: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1406 case 3: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1407 retval = val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1408 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1409 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1410 case 2: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1411 retval = inf_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1412 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1413 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1414 default: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1415 retval = nan_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1416 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1417 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1418 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1419 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1420 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1421 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1422 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1423 is_integer_value (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1424 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1425 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
|
1426 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1427 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1428 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1429 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
|
1430 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1431 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1432 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1433 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1434 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1435 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1436 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1437 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1438 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1439 F77_FUNC (cbesj, CBESJ) (F77_CONST_CMPLX_ARG (&z), alpha, 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
|
1440 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
|
1441 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1442 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1443 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1444 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1445 { |
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
|
1446 float expz = exp (std::abs (z.imag ())); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1447 y *= expz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1448 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1449 |
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
|
1450 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
|
1451 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1452 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1453 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1454 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1455 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1456 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1457 // 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
|
1458 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1459 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
|
1460 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1461 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1462 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1463 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1464 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1465 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1466 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1467 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1468 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
|
1469 * cbesj (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1470 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1471 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1472 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1473 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
|
1474 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1475 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1476 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1477 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1478 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1479 retval = FloatComplex (octave::numeric_limits<float>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1480 octave::numeric_limits<float>::NaN ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1481 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1482 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1483 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1484 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1485 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1486 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1487 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
|
1488 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1489 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1490 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1491 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1492 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1493 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1494 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1495 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1496 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1497 FloatComplex w; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1498 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1499 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1500 |
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
|
1501 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
|
1502 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1503 y = FloatComplex (-octave::numeric_limits<float>::Inf (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1504 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1505 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1506 { |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1507 F77_FUNC (cbesy, CBESY) (F77_CONST_CMPLX_ARG (&z), alpha, 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
|
1508 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
|
1509 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
|
1510 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1511 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1512 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1513 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1514 { |
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
|
1515 float expz = exp (std::abs (z.imag ())); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1516 y *= expz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1517 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1518 |
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
|
1519 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
|
1520 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1521 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1522 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1523 return bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1524 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1525 else 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
|
1526 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1527 // 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
|
1528 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1529 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
|
1530 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
|
1531 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1532 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1533 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1534 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1535 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1536 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1537 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1538 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
|
1539 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1540 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1541 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1542 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1543 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
|
1544 * cbesj (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1545 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1546 retval = bessel_return_value (tmp, ierr); |
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 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1549 retval = FloatComplex (octave::numeric_limits<float>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1550 octave::numeric_limits<float>::NaN ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1551 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1552 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1553 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1554 } |
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 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1557 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
|
1558 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1559 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1560 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1561 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1562 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1563 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1564 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1565 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1566 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1567 F77_FUNC (cbesi, CBESI) (F77_CONST_CMPLX_ARG (&z), alpha, 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
|
1568 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
|
1569 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1570 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1571 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1572 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1573 { |
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
|
1574 float expz = exp (std::abs (z.real ())); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1575 y *= expz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1576 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1577 |
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
|
1578 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
|
1579 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1580 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1581 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1582 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1583 else |
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 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1586 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1587 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
|
1588 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1589 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1590 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1591 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
|
1592 * sinf (static_cast<float> (M_PI) * alpha) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1593 * cbesk (z, alpha, kode, ierr); |
21786
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 if (kode == 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1596 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1597 // 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
|
1598 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
|
1599 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1600 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1601 tmp += tmp2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1602 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1603 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1604 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1605 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1606 retval = FloatComplex (octave::numeric_limits<float>::NaN (), |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1607 octave::numeric_limits<float>::NaN ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1608 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1609 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1610 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1611 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1612 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1613 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1614 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
|
1615 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1616 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1617 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1618 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1619 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1620 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1621 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1622 F77_INT nz, t_ierr; |
21786
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 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1625 |
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
|
1626 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
|
1627 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1628 y = FloatComplex (octave::numeric_limits<float>::Inf (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1629 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1630 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1631 { |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1632 F77_FUNC (cbesk, CBESK) (F77_CONST_CMPLX_ARG (&z), alpha, 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
|
1633 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
|
1634 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1635 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1636 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1637 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1638 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1639 FloatComplex expz = exp (-z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1640 |
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
|
1641 float rexpz = expz.real (); |
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
|
1642 float iexpz = expz.imag (); |
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
|
1643 |
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
|
1644 float tmp_r = y.real () * rexpz - y.imag () * iexpz; |
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
|
1645 float tmp_i = y.real () * iexpz + y.imag () * rexpz; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1646 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1647 y = FloatComplex (tmp_r, tmp_i); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1648 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1649 |
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
|
1650 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
|
1651 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1652 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1653 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1654 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1655 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1656 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1657 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1658 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
|
1659 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1660 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1661 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1662 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1663 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1664 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1665 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1666 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1667 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
|
1668 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1669 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1670 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1671 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1672 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1673 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1674 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1675 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1676 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1677 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 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
|
1678 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
|
1679 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1680 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1681 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1682 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1683 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1684 FloatComplex expz = exp (FloatComplex (0.0, 1.0) * z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1685 |
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
|
1686 float rexpz = expz.real (); |
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
|
1687 float iexpz = expz.imag (); |
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
|
1688 |
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
|
1689 float tmp_r = y.real () * rexpz - y.imag () * iexpz; |
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
|
1690 float tmp_i = y.real () * iexpz + y.imag () * rexpz; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1691 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1692 y = FloatComplex (tmp_r, tmp_i); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1693 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1694 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1695 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1696 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1697 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1698 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1699 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1700 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1701 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
|
1702 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1703 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
|
1704 * cbesh1 (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1705 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1706 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1707 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1708 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1709 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1710 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1711 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1712 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1713 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
|
1714 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1715 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1716 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1717 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1718 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1719 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1720 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1721 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1722 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1723 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 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
|
1724 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
|
1725 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1726 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1727 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1728 if (kode != 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1729 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1730 FloatComplex expz = exp (-FloatComplex (0.0, 1.0) * z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1731 |
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
|
1732 float rexpz = expz.real (); |
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
|
1733 float iexpz = expz.imag (); |
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
|
1734 |
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
|
1735 float tmp_r = y.real () * rexpz - y.imag () * iexpz; |
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
|
1736 float tmp_i = y.real () * iexpz + y.imag () * rexpz; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1737 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1738 y = FloatComplex (tmp_r, tmp_i); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1739 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1740 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1741 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1742 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1743 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1744 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1745 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1746 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1747 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
|
1748 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1749 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
|
1750 * cbesh2 (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1751 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1752 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1753 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1754 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1755 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1756 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1757 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1758 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
|
1759 octave_idx_type&); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1760 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1761 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1762 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
|
1763 bool scaled, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1764 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1765 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1766 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1767 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
|
1768 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1769 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1770 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1771 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1772 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1773 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
|
1774 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
|
1775 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1776 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1777 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1778 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1779 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1780 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1781 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1782 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1783 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
|
1784 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1785 retval(i,j) = f (x(i,j), alpha, (scaled ? 2 : 1), ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1786 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1787 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1788 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1789 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1790 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1791 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
|
1792 const FloatComplex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1793 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
|
1794 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1795 octave_idx_type nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1796 octave_idx_type nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1797 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1798 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1799 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1800 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1801 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1802 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
|
1803 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1804 retval(i,j) = f (x, alpha(i,j), (scaled ? 2 : 1), ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1805 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1806 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1807 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1808 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1809 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1810 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
|
1811 const FloatComplexMatrix& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1812 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1813 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1814 FloatComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1815 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1816 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
|
1817 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
|
1818 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1819 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
|
1820 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
|
1821 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1822 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
|
1823 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1824 ("%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
|
1825 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1826 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1827 octave_idx_type nc = x_nc; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1828 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1829 retval.resize (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1830 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1831 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1832 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1833 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
|
1834 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1835 retval(i,j) = f (x(i,j), alpha(i,j), (scaled ? 2 : 1), ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1836 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1837 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1838 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1839 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1840 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1841 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
|
1842 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
|
1843 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1844 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1845 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1846 FloatComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1847 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1848 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1849 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1850 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
|
1851 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
|
1852 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1853 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1854 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1855 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1856 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1857 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
|
1858 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
|
1859 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1860 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1861 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1862 FloatComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1863 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1864 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1865 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1866 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
|
1867 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
|
1868 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1869 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1870 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1871 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1872 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1873 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
|
1874 const FloatComplexNDArray& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1875 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1876 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1877 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1878 FloatComplexNDArray retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1879 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1880 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1881 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1882 ("%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
|
1883 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1884 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1885 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1886 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1887 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1888 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1889 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
|
1890 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
|
1891 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1892 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1893 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1894 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1895 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1896 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
|
1897 const FloatComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1898 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1899 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1900 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1901 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1902 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1903 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1904 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1905 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1906 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1907 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
|
1908 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1909 retval(i,j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1910 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1911 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1912 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1913 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1914 #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
|
1915 FloatComplex \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1916 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
|
1917 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
|
1918 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1919 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
|
1920 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1921 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1922 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1923 FloatComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1924 name (float alpha, const FloatComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1925 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1926 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1927 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
|
1928 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1929 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1930 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1931 FloatComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1932 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
|
1933 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1934 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1935 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
|
1936 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1937 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1938 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1939 FloatComplexMatrix \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1940 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
|
1941 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1942 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1943 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
|
1944 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1945 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1946 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1947 FloatComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1948 name (float alpha, const FloatComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1949 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1950 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1951 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
|
1952 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1953 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1954 #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
|
1955 FloatComplexNDArray \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1956 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
|
1957 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
|
1958 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1959 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
|
1960 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1961 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1962 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1963 FloatComplexNDArray \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1964 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
|
1965 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1966 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1967 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
|
1968 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1969 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1970 #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
|
1971 FloatComplexMatrix \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1972 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
|
1973 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
|
1974 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
|
1975 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1976 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
|
1977 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1978 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1979 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1980 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1981 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1982 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1983 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1984 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1985 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1986 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1987 RC_BESSEL (name, fcn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1988 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1989 ALL_BESSEL (besselj, cbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1990 ALL_BESSEL (bessely, cbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1991 ALL_BESSEL (besseli, cbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1992 ALL_BESSEL (besselk, cbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1993 ALL_BESSEL (besselh1, cbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1994 ALL_BESSEL (besselh2, cbesh2) |
3220 | 1995 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1996 #undef ALL_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1997 #undef SS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1998 #undef SM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1999 #undef MS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2000 #undef MM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2001 #undef SN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2002 #undef NS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2003 #undef NN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2004 #undef RC_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2005 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2006 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2007 airy (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2008 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2009 double ar = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2010 double ai = 0.0; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2011 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2012 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2013 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2014 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
2015 F77_INT id = (deriv ? 1 : 0); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2016 F77_INT 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
|
2017 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2018 F77_FUNC (zairy, ZAIRY) (zr, zi, id, 2, ar, ai, 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
|
2019 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2020 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2021 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2022 if (! scaled) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2023 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2024 Complex expz = exp (- 2.0 / 3.0 * z * sqrt (z)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2025 |
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
|
2026 double rexpz = expz.real (); |
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
|
2027 double iexpz = expz.imag (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2028 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2029 double tmp = ar*rexpz - ai*iexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2030 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2031 ai = ar*iexpz + ai*rexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2032 ar = tmp; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2033 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2034 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2035 if (zi == 0.0 && (! scaled || zr >= 0.0)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2036 ai = 0.0; |
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 return bessel_return_value (Complex (ar, ai), ierr); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2039 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2040 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2041 Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2042 biry (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr) |
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 double ar = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2045 double ai = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2046 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2047 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2048 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2049 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
2050 F77_INT id = (deriv ? 1 : 0); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2051 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
|
2052 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2053 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, 2, ar, ai, t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2054 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2055 ierr = t_ierr; |
21786
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 if (! scaled) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2058 { |
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
|
2059 Complex expz = exp (std::abs (std::real (2.0 / 3.0 * z * sqrt (z)))); |
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
|
2060 |
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
|
2061 double rexpz = expz.real (); |
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
|
2062 double iexpz = expz.imag (); |
21786
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 double tmp = ar*rexpz - ai*iexpz; |
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 ai = ar*iexpz + ai*rexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2067 ar = tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2068 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2069 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2070 if (zi == 0.0 && (! scaled || zr >= 0.0)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2071 ai = 0.0; |
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 return bessel_return_value (Complex (ar, ai), ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2074 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2075 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2076 ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2077 airy (const ComplexMatrix& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2078 Array<octave_idx_type>& ierr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2079 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2080 octave_idx_type nr = z.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2081 octave_idx_type nc = z.cols (); |
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 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2084 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2085 ierr.resize (dim_vector (nr, nc)); |
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 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
|
2088 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2089 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2090 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2091 return retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2092 } |
21786
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 ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2095 biry (const ComplexMatrix& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2096 Array<octave_idx_type>& ierr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2097 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2098 octave_idx_type nr = z.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2099 octave_idx_type nc = z.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2100 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2101 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2102 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2103 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2104 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2105 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
|
2106 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2107 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2108 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2109 return retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2110 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2111 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2112 ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2113 airy (const ComplexNDArray& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2114 Array<octave_idx_type>& ierr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2115 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2116 dim_vector dv = z.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2117 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2118 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2119 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2120 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2121 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2122 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
|
2123 retval(i) = airy (z(i), deriv, scaled, ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2124 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2125 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2126 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2127 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2128 ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2129 biry (const ComplexNDArray& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2130 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2131 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2132 dim_vector dv = z.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2133 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2134 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2135 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2136 ierr.resize (dv); |
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 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
|
2139 retval(i) = biry (z(i), deriv, scaled, ierr(i)); |
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 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2142 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2143 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2144 FloatComplex |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2145 airy (const FloatComplex& z, bool deriv, bool scaled, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2146 octave_idx_type& ierr) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2147 { |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2148 FloatComplex a; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2149 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
2150 F77_INT id = (deriv ? 1 : 0); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2151 F77_INT 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
|
2152 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2153 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, 2, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2154 F77_CMPLX_ARG (&a), 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
|
2155 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2156 ierr = t_ierr; |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2157 |
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2158 float ar = a.real (); |
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2159 float ai = a.imag (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2160 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2161 if (! scaled) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2162 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2163 FloatComplex expz = exp (- 2.0f / 3.0f * z * sqrt (z)); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2164 |
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
|
2165 float rexpz = expz.real (); |
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
|
2166 float iexpz = expz.imag (); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2167 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2168 float tmp = ar*rexpz - ai*iexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2169 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2170 ai = ar*iexpz + ai*rexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2171 ar = tmp; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2172 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2173 |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2174 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0)) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2175 ai = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2176 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2177 return bessel_return_value (FloatComplex (ar, ai), ierr); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2178 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2179 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2180 FloatComplex |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2181 biry (const FloatComplex& z, bool deriv, bool scaled, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2182 octave_idx_type& ierr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2183 { |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2184 FloatComplex a; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2185 |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
2186 F77_INT id = (deriv ? 1 : 0); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2187 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
|
2188 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2189 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, 2, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2190 F77_CMPLX_ARG (&a), t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2191 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2192 ierr = t_ierr; |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2193 |
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2194 float ar = a.real (); |
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2195 float ai = a.imag (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2196 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2197 if (! scaled) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2198 { |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2199 FloatComplex expz |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2200 = exp (std::abs (std::real (2.0f / 3.0f * z * sqrt (z)))); |
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
|
2201 |
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
|
2202 float rexpz = expz.real (); |
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
|
2203 float iexpz = expz.imag (); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2204 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2205 float tmp = ar*rexpz - ai*iexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2206 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2207 ai = ar*iexpz + ai*rexpz; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2208 ar = tmp; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
2209 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2210 |
22135
407c66ae1e20
reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents:
22133
diff
changeset
|
2211 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0)) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2212 ai = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2213 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2214 return bessel_return_value (FloatComplex (ar, ai), ierr); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2215 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2216 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2217 FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2218 airy (const FloatComplexMatrix& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2219 Array<octave_idx_type>& ierr) |
4506 | 2220 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2221 octave_idx_type nr = z.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2222 octave_idx_type nc = z.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2223 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2224 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2225 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2226 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2227 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2228 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
|
2229 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2230 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2231 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2232 return retval; |
4506 | 2233 } |
3220 | 2234 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2235 FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2236 biry (const FloatComplexMatrix& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2237 Array<octave_idx_type>& ierr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2238 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2239 octave_idx_type nr = z.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2240 octave_idx_type nc = z.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2241 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2242 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2243 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2244 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2245 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2246 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
|
2247 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2248 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2249 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2250 return retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2251 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2252 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2253 FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2254 airy (const FloatComplexNDArray& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2255 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2256 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2257 dim_vector dv = z.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2258 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2259 FloatComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2260 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2261 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2262 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2263 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
|
2264 retval(i) = airy (z(i), deriv, scaled, ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2265 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2266 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2267 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2268 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2269 FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2270 biry (const FloatComplexNDArray& z, bool deriv, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2271 Array<octave_idx_type>& ierr) |
4844 | 2272 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2273 dim_vector dv = z.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2274 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2275 FloatComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2276 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2277 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2278 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2279 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
|
2280 retval(i) = biry (z(i), deriv, scaled, ierr(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2281 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2282 return retval; |
4844 | 2283 } |
2284 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2285 OCTAVE_NORETURN static void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2286 err_betainc_nonconformant (const dim_vector& d1, const dim_vector& d2, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2287 const dim_vector& d3) |
4844 | 2288 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2289 std::string d1_str = d1.str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2290 std::string d2_str = d2.str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2291 std::string d3_str = d3.str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2292 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2293 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2294 ("betainc: nonconformant arguments (x is %s, a is %s, b is %s)", |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2295 d1_str.c_str (), d2_str.c_str (), d3_str.c_str ()); |
4844 | 2296 } |
2297 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2298 OCTAVE_NORETURN static void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2299 err_betaincinv_nonconformant (const dim_vector& d1, const dim_vector& d2, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2300 const dim_vector& d3) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2301 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2302 std::string d1_str = d1.str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2303 std::string d2_str = d2.str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2304 std::string d3_str = d3.str (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2305 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2306 (*current_liboctave_error_handler) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2307 ("betaincinv: nonconformant arguments (x is %s, a is %s, b is %s)", |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2308 d1_str.c_str (), d2_str.c_str (), d3_str.c_str ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2309 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2310 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2311 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2312 betainc (double x, double a, double b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2313 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2314 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2315 F77_XFCN (xdbetai, XDBETAI, (x, a, b, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2316 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2317 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2318 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2319 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2320 betainc (double x, double a, const Array<double>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2321 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2322 dim_vector dv = b.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2323 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2324 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2325 Array<double> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2326 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2327 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2328 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2329 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
|
2330 *pretval++ = betainc (x, a, b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2331 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2332 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2333 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2334 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2335 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2336 betainc (double x, const Array<double>& a, double b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2337 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2338 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2339 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2340 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2341 Array<double> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2342 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2343 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2344 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2345 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
|
2346 *pretval++ = betainc (x, a(i), b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2347 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2348 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2349 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2350 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2351 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2352 betainc (double x, const Array<double>& a, const Array<double>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2353 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2354 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2355 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2356 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2357 if (dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2358 err_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2359 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2360 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2361 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2362 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2363 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2364 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2365 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2366 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
|
2367 *pretval++ = betainc (x, a(i), b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2368 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2369 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2370 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2371 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2372 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2373 betainc (const Array<double>& x, double a, double b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2374 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2375 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2376 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2377 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2378 Array<double> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2379 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2380 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2381 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2382 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
|
2383 *pretval++ = betainc (x(i), a, b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2384 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2385 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2386 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2387 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2388 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2389 betainc (const Array<double>& x, double a, const Array<double>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2390 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2391 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2392 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2393 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2394 if (dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2395 err_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2396 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2397 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2398 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2399 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2400 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2401 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2402 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2403 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
|
2404 *pretval++ = betainc (x(i), a, b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2405 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2406 return retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2407 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2408 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2409 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2410 betainc (const Array<double>& x, const Array<double>& a, double b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2411 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2412 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2413 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2414 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2415 if (dv != a.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2416 err_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2417 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2418 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2419 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2420 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2421 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2422 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2423 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2424 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
|
2425 *pretval++ = betainc (x(i), a(i), b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2426 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2427 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2428 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2429 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2430 Array<double> |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2431 betainc (const Array<double>& x, const Array<double>& a, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2432 const Array<double>& b) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2433 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2434 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2435 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2436 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2437 if (dv != a.dims () || dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2438 err_betainc_nonconformant (dv, a.dims (), b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2439 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2440 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2441 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2442 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2443 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2444 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2445 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2446 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
|
2447 *pretval++ = betainc (x(i), a(i), b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2448 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2449 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2450 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2451 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2452 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2453 betainc (float x, float a, float b) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
2454 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2455 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2456 F77_XFCN (xbetai, XBETAI, (x, a, b, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2457 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2458 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2459 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2460 Array<float> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2461 betainc (float x, float a, const Array<float>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2462 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2463 dim_vector dv = b.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2464 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2465 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2466 Array<float> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2467 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2468 float *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2469 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2470 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
|
2471 *pretval++ = betainc (x, a, b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2472 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2473 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2474 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2475 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2476 Array<float> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2477 betainc (float x, const Array<float>& a, float b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2478 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2479 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2480 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2481 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2482 Array<float> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2483 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2484 float *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2485 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2486 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
|
2487 *pretval++ = betainc (x, a(i), b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2488 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2489 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2490 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2491 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2492 Array<float> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2493 betainc (float x, const Array<float>& a, const Array<float>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2494 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2495 Array<float> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2496 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2497 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2498 if (dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2499 err_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2500 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2501 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2502 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2503 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2504 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2505 float *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2506 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2507 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
|
2508 *pretval++ = betainc (x, a(i), b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2509 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2510 return retval; |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
2511 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2512 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2513 Array<float> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2514 betainc (const Array<float>& x, float a, float b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2515 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2516 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2517 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2518 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2519 Array<float> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2520 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2521 float *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2522 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2523 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
|
2524 *pretval++ = betainc (x(i), a, b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2525 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2526 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2527 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2528 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2529 Array<float> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2530 betainc (const Array<float>& x, float a, const Array<float>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2531 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2532 Array<float> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2533 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2534 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2535 if (dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2536 err_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2537 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2538 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2539 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2540 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2541 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2542 float *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2543 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2544 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
|
2545 *pretval++ = betainc (x(i), a, b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2546 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2547 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2548 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2549 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2550 Array<float> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2551 betainc (const Array<float>& x, const Array<float>& a, float b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2552 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2553 Array<float> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2554 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2555 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2556 if (dv != a.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2557 err_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2558 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2559 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2560 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2561 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2562 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2563 float *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2564 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2565 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
|
2566 *pretval++ = betainc (x(i), a(i), b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2567 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2568 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2569 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2570 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2571 Array<float> |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2572 betainc (const Array<float>& x, const Array<float>& a, |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2573 const Array<float>& b) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2574 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2575 Array<float> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2576 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2577 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2578 if (dv != a.dims () || dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2579 err_betainc_nonconformant (dv, a.dims (), b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2580 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2581 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2582 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2583 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2584 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2585 float *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2586 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2587 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
|
2588 *pretval++ = betainc (x(i), a(i), b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2589 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2590 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2591 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2592 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2593 // FIXME: there is still room for improvement here... |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2594 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2595 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2596 gammainc (double x, double a, bool& err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2597 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2598 if (a < 0.0 || x < 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2599 (*current_liboctave_error_handler) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
2600 ("gammainc: A and X must be non-negative"); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2601 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2602 err = false; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2603 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2604 double retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2605 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2606 F77_XFCN (xgammainc, XGAMMAINC, (a, x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2607 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2608 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2609 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2610 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2611 Matrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2612 gammainc (double x, const Matrix& a) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2613 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2614 octave_idx_type nr = a.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2615 octave_idx_type nc = a.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2616 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2617 Matrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2618 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2619 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2620 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2621 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
|
2622 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2623 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2624 retval(i,j) = gammainc (x, a(i,j), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2625 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2626 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2627 return Matrix (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2628 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2629 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2630 return retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2631 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2632 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2633 Matrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2634 gammainc (const Matrix& x, double a) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2635 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2636 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2637 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2638 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2639 Matrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2640 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2641 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2642 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2643 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
|
2644 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2645 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2646 retval(i,j) = gammainc (x(i,j), a, err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2647 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2648 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2649 return Matrix (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2650 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2651 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2652 return retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2653 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
2654 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2655 Matrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2656 gammainc (const Matrix& x, const Matrix& a) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2657 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2658 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2659 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2660 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2661 octave_idx_type a_nr = a.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2662 octave_idx_type a_nc = a.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2663 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2664 if (nr != a_nr || nc != a_nc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2665 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2666 ("gammainc: nonconformant arguments (arg 1 is %dx%d, arg 2 is %dx%d)", |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2667 nr, nc, a_nr, a_nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2668 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2669 Matrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2670 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2671 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2672 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2673 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
|
2674 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2675 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2676 retval(i,j) = gammainc (x(i,j), a(i,j), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2677 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2678 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2679 return Matrix (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2680 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2681 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2682 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2683 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2684 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2685 NDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2686 gammainc (double x, const NDArray& a) |
4844 | 2687 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2688 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2689 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2690 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2691 NDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2692 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2693 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2694 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2695 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
|
2696 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2697 retval(i) = gammainc (x, a(i), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2698 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2699 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2700 return NDArray (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2701 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2702 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2703 return retval; |
4844 | 2704 } |
2705 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2706 NDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2707 gammainc (const NDArray& x, double a) |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
2708 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2709 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2710 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2711 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2712 NDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2713 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2714 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2715 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2716 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
|
2717 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2718 retval(i) = gammainc (x(i), a, err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2719 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2720 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2721 return NDArray (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2722 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2723 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2724 return retval; |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
2725 } |
4844 | 2726 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2727 NDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2728 gammainc (const NDArray& x, const NDArray& a) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2729 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2730 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2731 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2732 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2733 if (dv != a.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2734 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2735 std::string x_str = dv.str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2736 std::string a_str = a.dims ().str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2737 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2738 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2739 ("gammainc: nonconformant arguments (arg 1 is %s, arg 2 is %s)", |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2740 x_str.c_str (), a_str.c_str ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2741 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2742 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2743 NDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2744 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2745 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2746 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2747 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
|
2748 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2749 retval(i) = gammainc (x(i), a(i), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2750 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2751 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2752 return NDArray (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2753 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2754 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2755 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2756 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2757 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2758 float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2759 gammainc (float x, float a, bool& err) |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
2760 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2761 if (a < 0.0 || x < 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2762 (*current_liboctave_error_handler) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
2763 ("gammainc: A and X must be non-negative"); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2764 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2765 err = false; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2766 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2767 float retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2768 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2769 F77_XFCN (xsgammainc, XSGAMMAINC, (a, x, retval)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2770 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2771 return retval; |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
2772 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2773 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2774 FloatMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2775 gammainc (float x, const FloatMatrix& a) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2776 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2777 octave_idx_type nr = a.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2778 octave_idx_type nc = a.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2779 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2780 FloatMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2781 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2782 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2783 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2784 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
|
2785 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2786 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2787 retval(i,j) = gammainc (x, a(i,j), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2788 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2789 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2790 return FloatMatrix (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2791 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2792 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2793 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2794 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2795 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2796 FloatMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2797 gammainc (const FloatMatrix& x, float a) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2798 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2799 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2800 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2801 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2802 FloatMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2803 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2804 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2805 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2806 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
|
2807 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2808 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2809 retval(i,j) = gammainc (x(i,j), a, err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2810 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2811 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2812 return FloatMatrix (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2813 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2814 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2815 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2816 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2817 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2818 FloatMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2819 gammainc (const FloatMatrix& x, const FloatMatrix& a) |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
2820 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2821 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2822 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2823 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2824 octave_idx_type a_nr = a.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2825 octave_idx_type a_nc = a.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2826 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2827 if (nr != a_nr || nc != a_nc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2828 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2829 ("gammainc: nonconformant arguments (arg 1 is %dx%d, arg 2 is %dx%d)", |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2830 nr, nc, a_nr, a_nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2831 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2832 FloatMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2833 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2834 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2835 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2836 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
|
2837 for (octave_idx_type i = 0; i < nr; i++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2838 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2839 retval(i,j) = gammainc (x(i,j), a(i,j), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2840 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2841 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2842 return FloatMatrix (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2843 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2844 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2845 return retval; |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
2846 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2847 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2848 FloatNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2849 gammainc (float x, const FloatNDArray& a) |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
2850 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2851 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2852 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2853 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2854 FloatNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2855 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2856 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2857 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2858 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
|
2859 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2860 retval(i) = gammainc (x, a(i), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2861 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2862 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2863 return FloatNDArray (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2864 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2865 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2866 return retval; |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
2867 } |
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
2868 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2869 FloatNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2870 gammainc (const FloatNDArray& x, float a) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2871 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2872 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2873 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2874 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2875 FloatNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2876 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2877 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2878 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2879 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
|
2880 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2881 retval(i) = gammainc (x(i), a, err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2882 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2883 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2884 return FloatNDArray (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2885 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2886 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2887 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2888 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2889 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2890 FloatNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2891 gammainc (const FloatNDArray& x, const FloatNDArray& a) |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14197
diff
changeset
|
2892 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2893 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2894 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2895 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2896 if (dv != a.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2897 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2898 std::string x_str = dv.str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2899 std::string a_str = a.dims ().str (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2900 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2901 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2902 ("gammainc: nonconformant arguments (arg 1 is %s, arg 2 is %s)", |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2903 x_str.c_str (), a_str.c_str ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2904 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2905 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2906 FloatNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2907 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2908 bool err; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2909 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2910 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
|
2911 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2912 retval(i) = gammainc (x(i), a(i), err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2913 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2914 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2915 return FloatNDArray (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2916 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2917 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2918 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2919 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2920 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2921 Complex rc_log1p (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2922 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2923 const double pi = 3.14159265358979323846; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2924 return (x < -1.0 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2925 ? Complex (std::log (-(1.0 + x)), pi) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2926 : Complex (log1p (x))); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2927 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2928 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2929 FloatComplex rc_log1p (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2930 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2931 const float pi = 3.14159265358979323846f; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2932 return (x < -1.0f |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2933 ? FloatComplex (std::log (-(1.0f + x)), pi) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2934 : FloatComplex (log1p (x))); |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14197
diff
changeset
|
2935 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2936 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2937 // This algorithm is due to P. J. Acklam. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2938 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2939 // See http://home.online.no/~pjacklam/notes/invnorm/ |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2940 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2941 // The rational approximation has relative accuracy 1.15e-9 in the whole |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2942 // region. For doubles, it is refined by a single step of Halley's 3rd |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2943 // order method. For single precision, the accuracy is already OK, so |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2944 // we skip it to get faster evaluation. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2945 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2946 static double do_erfinv (double x, bool refine) |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14197
diff
changeset
|
2947 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2948 // Coefficients of rational approximation. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2949 static const double a[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2950 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2951 -2.806989788730439e+01, 1.562324844726888e+02, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2952 -1.951109208597547e+02, 9.783370457507161e+01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2953 -2.168328665628878e+01, 1.772453852905383e+00 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2954 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2955 static const double b[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2956 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2957 -5.447609879822406e+01, 1.615858368580409e+02, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2958 -1.556989798598866e+02, 6.680131188771972e+01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2959 -1.328068155288572e+01 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2960 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2961 static const double c[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2962 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2963 -5.504751339936943e-03, -2.279687217114118e-01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2964 -1.697592457770869e+00, -1.802933168781950e+00, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2965 3.093354679843505e+00, 2.077595676404383e+00 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2966 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2967 static const double d[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2968 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2969 7.784695709041462e-03, 3.224671290700398e-01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2970 2.445134137142996e+00, 3.754408661907416e+00 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2971 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2972 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2973 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2974 static const double pbreak = 0.95150; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2975 double ax = fabs (x), y; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2976 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2977 // Select case. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2978 if (ax <= pbreak) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2979 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2980 // Middle region. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2981 const double q = 0.5 * x, r = q*q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2982 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2983 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2984 y = yn / yd; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2985 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2986 else if (ax < 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2987 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2988 // Tail region. |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2989 const double q = sqrt (-2*std::log (0.5*(1-ax))); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2990 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2991 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2992 y = yn / yd * octave::math::signum (-x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2993 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2994 else if (ax == 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2995 return octave::numeric_limits<double>::Inf () * octave::math::signum (x); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2996 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2997 return octave::numeric_limits<double>::NaN (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2998 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2999 if (refine) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3000 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3001 // One iteration of Halley's method gives full precision. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3002 double u = (erf (y) - x) * spi2 * exp (y*y); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3003 y -= u / (1 + y*u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3004 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3005 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3006 return y; |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14197
diff
changeset
|
3007 } |
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14197
diff
changeset
|
3008 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3009 double erfinv (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3010 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3011 return do_erfinv (x, true); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3012 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3013 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3014 float erfinv (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3015 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3016 return do_erfinv (x, false); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3017 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3018 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3019 // The algorthim for erfcinv is an adaptation of the erfinv algorithm |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3020 // above from P. J. Acklam. It has been modified to run over the |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3021 // different input domain of erfcinv. See the notes for erfinv for an |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3022 // explanation. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3023 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3024 static double do_erfcinv (double x, bool refine) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3025 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3026 // Coefficients of rational approximation. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3027 static const double a[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3028 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3029 -2.806989788730439e+01, 1.562324844726888e+02, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3030 -1.951109208597547e+02, 9.783370457507161e+01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3031 -2.168328665628878e+01, 1.772453852905383e+00 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3032 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3033 static const double b[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3034 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3035 -5.447609879822406e+01, 1.615858368580409e+02, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3036 -1.556989798598866e+02, 6.680131188771972e+01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3037 -1.328068155288572e+01 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3038 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3039 static const double c[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3040 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3041 -5.504751339936943e-03, -2.279687217114118e-01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3042 -1.697592457770869e+00, -1.802933168781950e+00, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3043 3.093354679843505e+00, 2.077595676404383e+00 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3044 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3045 static const double d[] = |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3046 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3047 7.784695709041462e-03, 3.224671290700398e-01, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3048 2.445134137142996e+00, 3.754408661907416e+00 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3049 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3050 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3051 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3052 static const double pbreak_lo = 0.04850; // 1-pbreak |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3053 static const double pbreak_hi = 1.95150; // 1+pbreak |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3054 double y; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3055 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3056 // Select case. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3057 if (x >= pbreak_lo && x <= pbreak_hi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3058 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3059 // Middle region. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3060 const double q = 0.5*(1-x), r = q*q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3061 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3062 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3063 y = yn / yd; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3064 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3065 else if (x > 0.0 && x < 2.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3066 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3067 // Tail region. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3068 const double q = (x < 1 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3069 ? sqrt (-2*std::log (0.5*x)) |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3070 : sqrt (-2*std::log (0.5*(2-x)))); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3071 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3072 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3073 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3074 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3075 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3076 y = yn / yd; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3077 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3078 if (x < pbreak_lo) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3079 y = -y; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3080 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3081 else if (x == 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3082 return octave::numeric_limits<double>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3083 else if (x == 2.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3084 return -octave::numeric_limits<double>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3085 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3086 return octave::numeric_limits<double>::NaN (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3087 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3088 if (refine) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3089 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3090 // One iteration of Halley's method gives full precision. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3091 double u = (erf (y) - (1-x)) * spi2 * exp (y*y); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3092 y -= u / (1 + y*u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3093 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3094 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3095 return y; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3096 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3097 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3098 double erfcinv (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3099 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3100 return do_erfcinv (x, true); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3101 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3102 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3103 float erfcinv (float x) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3104 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3105 return do_erfcinv (x, false); |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3106 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3107 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3108 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3109 // Incomplete Beta function ratio |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3110 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3111 // Algorithm based on the one by John Burkardt. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3112 // See http://people.sc.fsu.edu/~jburkardt/cpp_src/asa109/asa109.html |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3113 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3114 // The original code is distributed under the GNU LGPL v3 license. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3115 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3116 // Reference: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3117 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3118 // KL Majumder, GP Bhattacharjee, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3119 // Algorithm AS 63: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3120 // The incomplete Beta Integral, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3121 // Applied Statistics, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3122 // Volume 22, Number 3, 1973, pages 409-411. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3123 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3124 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3125 betain (double x, double p, double q, double beta, bool& err) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3126 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3127 double acu = 0.1E-14, ai, cx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3128 bool indx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3129 int ns; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3130 double pp, psq, qq, rx, temp, term, value, xx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3131 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3132 value = x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3133 err = false; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3134 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3135 // Check the input arguments. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3136 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3137 if ((p <= 0.0 || q <= 0.0) || (x < 0.0 || 1.0 < x)) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3138 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3139 err = true; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3140 return value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3141 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3142 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3143 // Special cases. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3144 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3145 if (x == 0.0 || x == 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3146 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3147 return value; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3148 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3149 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3150 // Change tail if necessary and determine S. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3151 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3152 psq = p + q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3153 cx = 1.0 - x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3154 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3155 if (p < psq * x) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3156 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3157 xx = cx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3158 cx = x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3159 pp = q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3160 qq = p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3161 indx = true; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3162 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3163 else |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3164 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3165 xx = x; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3166 pp = p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3167 qq = q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3168 indx = false; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3169 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3170 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3171 term = 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3172 ai = 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3173 value = 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3174 ns = static_cast<int> (qq + cx * psq); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3175 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3176 // Use the Soper reduction formula. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3177 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3178 rx = xx / cx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3179 temp = qq - ai; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3180 if (ns == 0) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3181 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3182 rx = xx; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3183 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3184 |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3185 for ( ; ; ) |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3186 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3187 term *= temp * rx / (pp + ai); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3188 value += term; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3189 temp = fabs (term); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3190 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3191 if (temp <= acu && temp <= acu * value) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3192 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3193 value *= exp (pp * std::log (xx) |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3194 + (qq - 1.0) * std::log (cx) - beta) / pp; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3195 |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3196 if (indx) |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3197 { |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3198 value = 1.0 - value; |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3199 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3200 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3201 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3202 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3203 ai += 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3204 ns -= 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3205 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3206 if (0 <= ns) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3207 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3208 temp = qq - ai; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3209 if (ns == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3210 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3211 rx = xx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3212 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3213 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3214 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3215 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3216 temp = psq; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3217 psq += 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3218 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3219 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3220 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3221 return value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3222 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3223 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3224 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3225 // Inverse of the incomplete Beta function |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3226 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3227 // Algorithm based on the one by John Burkardt. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3228 // See http://people.sc.fsu.edu/~jburkardt/cpp_src/asa109/asa109.html |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3229 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3230 // The original code is distributed under the GNU LGPL v3 license. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3231 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3232 // Reference: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3233 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3234 // GW Cran, KJ Martin, GE Thomas, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3235 // Remark AS R19 and Algorithm AS 109: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3236 // A Remark on Algorithms AS 63: The Incomplete Beta Integral |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3237 // and AS 64: Inverse of the Incomplete Beta Integeral, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3238 // Applied Statistics, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3239 // Volume 26, Number 1, 1977, pages 111-114. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3240 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3241 double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3242 betaincinv (double y, double p, double q) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3243 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3244 double a, acu, adj, fpu, g, h; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3245 int iex; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3246 bool indx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3247 double pp, prev, qq, r, s, sae = -37.0, sq, t, tx, value, w, xin, ycur, yprev; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3248 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3249 double beta = lgamma (p) + lgamma (q) - lgamma (p + q); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3250 bool err = false; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3251 fpu = pow (10.0, sae); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3252 value = y; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3253 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3254 // Test for admissibility of parameters. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3255 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3256 if (p <= 0.0 || q <= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3257 (*current_liboctave_error_handler) ("betaincinv: wrong parameters"); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3258 if (y < 0.0 || 1.0 < y) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3259 (*current_liboctave_error_handler) ("betaincinv: wrong parameter Y"); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3260 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3261 if (y == 0.0 || y == 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3262 return value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3263 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3264 // Change tail if necessary. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3265 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3266 if (0.5 < y) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3267 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3268 a = 1.0 - y; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3269 pp = q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3270 qq = p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3271 indx = true; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3272 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3273 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3274 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3275 a = y; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3276 pp = p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3277 qq = q; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3278 indx = false; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3279 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3280 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3281 // Calculate the initial approximation. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3282 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3283 r = sqrt (- std::log (a * a)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3284 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3285 ycur = r - (2.30753 + 0.27061 * r) / (1.0 + (0.99229 + 0.04481 * r) * r); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3286 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3287 if (1.0 < pp && 1.0 < qq) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3288 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3289 r = (ycur * ycur - 3.0) / 6.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3290 s = 1.0 / (pp + pp - 1.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3291 t = 1.0 / (qq + qq - 1.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3292 h = 2.0 / (s + t); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3293 w = ycur * sqrt (h + r) / h - (t - s) * (r + 5.0 / 6.0 - 2.0 / (3.0 * h)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3294 value = pp / (pp + qq * exp (w + w)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3295 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3296 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3297 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3298 r = qq + qq; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3299 t = 1.0 / (9.0 * qq); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3300 t = r * pow (1.0 - t + ycur * sqrt (t), 3); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3301 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3302 if (t <= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3303 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3304 value = 1.0 - exp ((std::log ((1.0 - a) * qq) + beta) / qq); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3305 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3306 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3307 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3308 t = (4.0 * pp + r - 2.0) / t; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3309 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3310 if (t <= 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3311 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3312 value = exp ((std::log (a * pp) + beta) / pp); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3313 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3314 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3315 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3316 value = 1.0 - 2.0 / (t + 1.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3317 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3318 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3319 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3320 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3321 // Solve for X by a modified Newton-Raphson method, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3322 // using the function BETAIN. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3323 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3324 r = 1.0 - pp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3325 t = 1.0 - qq; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3326 yprev = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3327 sq = 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3328 prev = 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3329 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3330 if (value < 0.0001) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3331 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3332 value = 0.0001; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3333 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3334 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3335 if (0.9999 < value) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3336 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3337 value = 0.9999; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3338 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3339 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3340 iex = std::max (- 5.0 / pp / pp - 1.0 / pow (a, 0.2) - 13.0, sae); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3341 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3342 acu = pow (10.0, iex); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3343 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3344 for ( ; ; ) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3345 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3346 ycur = betain (value, pp, qq, beta, err); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3347 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3348 if (err) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3349 { |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3350 return value; |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3351 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3352 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3353 xin = value; |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3354 ycur = (ycur - a) * exp (beta + r * std::log (xin) |
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3355 + t * std::log (1.0 - xin)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3356 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3357 if (ycur * yprev <= 0.0) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3358 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3359 prev = std::max (sq, fpu); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3360 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3361 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3362 g = 1.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3363 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3364 for ( ; ; ) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3365 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3366 for ( ; ; ) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3367 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3368 adj = g * ycur; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3369 sq = adj * adj; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3370 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3371 if (sq < prev) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3372 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3373 tx = value - adj; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3374 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3375 if (0.0 <= tx && tx <= 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3376 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3377 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3378 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3379 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3380 g /= 3.0; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3381 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3382 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3383 if (prev <= acu) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3384 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3385 if (indx) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3386 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3387 value = 1.0 - value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3388 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3389 return value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3390 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3391 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3392 if (ycur * ycur <= acu) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3393 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3394 if (indx) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3395 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3396 value = 1.0 - value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3397 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3398 return value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3399 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3400 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3401 if (tx != 0.0 && tx != 1.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3402 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3403 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3404 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3405 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3406 g /= 3.0; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3407 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3408 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3409 if (tx == value) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3410 { |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3411 break; |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3412 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3413 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3414 value = tx; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3415 yprev = ycur; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3416 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3417 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3418 if (indx) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3419 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3420 value = 1.0 - value; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3421 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3422 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3423 return value; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3424 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3425 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3426 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3427 betaincinv (double x, double a, const Array<double>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3428 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3429 dim_vector dv = b.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3430 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3431 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3432 Array<double> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3433 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3434 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3435 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3436 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
|
3437 *pretval++ = betaincinv (x, a, b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3438 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3439 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3440 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3441 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3442 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3443 betaincinv (double x, const Array<double>& a, double b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3444 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3445 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3446 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3447 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3448 Array<double> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3449 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3450 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3451 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3452 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
|
3453 *pretval++ = betaincinv (x, a(i), b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3454 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3455 return retval; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3456 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3457 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3458 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3459 betaincinv (double x, const Array<double>& a, const Array<double>& b) |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3460 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3461 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3462 dim_vector dv = a.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3463 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3464 if (dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3465 err_betaincinv_nonconformant (dim_vector (0, 0), dv, b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3466 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3467 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3468 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3469 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3470 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3471 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3472 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3473 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
|
3474 *pretval++ = betaincinv (x, a(i), b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3475 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3476 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3477 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3478 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3479 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3480 betaincinv (const Array<double>& x, double a, double b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3481 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3482 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3483 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3484 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3485 Array<double> retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3486 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3487 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3488 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3489 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
|
3490 *pretval++ = betaincinv (x(i), a, b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3491 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3492 return retval; |
14816
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3493 } |
0a868d90436b
New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14815
diff
changeset
|
3494 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3495 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3496 betaincinv (const Array<double>& x, double a, const Array<double>& b) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3497 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3498 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3499 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3500 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3501 if (dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3502 err_betaincinv_nonconformant (dv, dim_vector (0, 0), b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3503 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3504 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3505 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3506 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3507 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3508 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3509 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3510 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
|
3511 *pretval++ = betaincinv (x(i), a, b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3512 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3513 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3514 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3515 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3516 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3517 betaincinv (const Array<double>& x, const Array<double>& a, double b) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3518 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3519 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3520 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3521 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3522 if (dv != a.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3523 err_betaincinv_nonconformant (dv, a.dims (), dim_vector (0, 0)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3524 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3525 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3526 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3527 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3528 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3529 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3530 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3531 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
|
3532 *pretval++ = betaincinv (x(i), a(i), b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3533 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3534 return retval; |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3535 } |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3536 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3537 Array<double> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3538 betaincinv (const Array<double>& x, const Array<double>& a, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3539 const Array<double>& b) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3540 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3541 Array<double> retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3542 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3543 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3544 if (dv != a.dims () && dv != b.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3545 err_betaincinv_nonconformant (dv, a.dims (), b.dims ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3546 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3547 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3548 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3549 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3550 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3551 double *pretval = retval.fortran_vec (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3552 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3553 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
|
3554 *pretval++ = betaincinv (x(i), a(i), b(i)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3555 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3556 return retval; |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3557 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3558 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3559 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3560 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
|
3561 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3562 static const int Nmax = 16; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3563 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
|
3564 int n, Nn, ii; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3565 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3566 if (m < 0 || m > 1) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3567 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3568 (*current_liboctave_warning_with_id_handler) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
3569 ("Octave:ellipj-invalid-m", |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
3570 "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
|
3571 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3572 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
|
3573 |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3574 return; |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3575 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3576 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3577 double sqrt_eps = sqrt (std::numeric_limits<double>::epsilon ()); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3578 if (m < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3579 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3580 // 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
|
3581 si_u = sin (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3582 co_u = cos (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3583 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
|
3584 sn = si_u - t * co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3585 cn = co_u + t * si_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3586 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
|
3587 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3588 else if ((1 - m) < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3589 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3590 // 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
|
3591 m1 = 1 - m; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3592 si_u = sinh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3593 co_u = cosh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3594 ta_u = tanh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3595 se_u = 1/co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3596 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
|
3597 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
|
3598 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
|
3599 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3600 else |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3601 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3602 // Arithmetic-Geometric Mean (AGM) algorithm |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3603 // (Abramowitz and Stegun, Section 16.4) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3604 a[0] = 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3605 b = sqrt (1 - m); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3606 c[0] = sqrt (m); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3607 for (n = 1; n < Nmax; ++n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3608 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3609 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
|
3610 c[n] = (a[n - 1] - b)/2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3611 b = sqrt (a[n - 1]*b); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3612 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
|
3613 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3614 if (n >= Nmax - 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3615 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3616 err = 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3617 return; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3618 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3619 Nn = n; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3620 for (ii = 1; n > 0; ii = ii*2, --n) ; // ii = pow(2,Nn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3621 phi = ii*a[Nn]*u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3622 for (n = Nn; n > 0; --n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3623 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3624 phi = (asin ((c[n]/a[n])* sin (phi)) + phi)/2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3625 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3626 sn = sin (phi); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3627 cn = cos (phi); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3628 dn = sqrt (1 - m*sn*sn); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3629 } |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3630 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3631 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3632 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3633 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
|
3634 double& err) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3635 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3636 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
|
3637 |
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
|
3638 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
|
3639 if (u.real () == 0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3640 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3641 // 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
|
3642 sn = Complex (0, ss1/cc1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3643 cn = 1/cc1; // cn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3644 dn = dd1/cc1; // dn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3645 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3646 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3647 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3648 // u is generic complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3649 double ss, cc, dd, ddd; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3650 |
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
|
3651 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
|
3652 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
|
3653 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
|
3654 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
|
3655 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
|
3656 } |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3657 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3658 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3659 static const double pi = 3.14159265358979323846; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3660 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3661 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3662 static inline T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3663 xlog (const T& x) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3664 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3665 return log (x); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
3666 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3667 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3668 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3669 inline double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3670 xlog (const double& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3671 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3672 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3673 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3674 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3675 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3676 inline float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3677 xlog (const float& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3678 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3679 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3680 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3681 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3682 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3683 static T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3684 lanczos_approximation_psi (const T zc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3685 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3686 // 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
|
3687 // 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
|
3688 // 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
|
3689 // 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
|
3690 static const T dg_coeff[10] = |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
3691 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3692 -0.83333333333333333e-1, 0.83333333333333333e-2, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3693 -0.39682539682539683e-2, 0.41666666666666667e-2, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3694 -0.75757575757575758e-2, 0.21092796092796093e-1, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3695 -0.83333333333333333e-1, 0.4432598039215686, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3696 -0.3053954330270122e+1, 0.125318899521531e+2 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3697 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3698 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3699 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
|
3700 T overz2k = overz2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3701 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3702 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3703 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
|
3704 p += dg_coeff[k] * overz2k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3705 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
|
3706 return p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3707 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3708 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3709 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3710 T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3711 xpsi (T z) |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3712 { |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
3713 static const double euler_mascheroni = |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
3714 0.577215664901532860606512090082402431042; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3715 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3716 const bool is_int = (octave::math::floor (z) == z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3717 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3718 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3719 if (z <= 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3720 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3721 // limits - zeros of the gamma function |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3722 if (is_int) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3723 p = -octave::numeric_limits<T>::Inf (); // Matlab returns -Inf for psi (0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3724 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3725 // 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
|
3726 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
|
3727 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3728 else if (is_int) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3729 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3730 // 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
|
3731 p = - euler_mascheroni; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3732 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
|
3733 p += 1.0 / k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3734 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3735 else if (octave::math::floor (z + 0.5) == z + 0.5) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3736 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3737 // 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
|
3738 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
|
3739 p += 1.0 / (2 * k - 1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3740 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
3741 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
|
3742 } |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3743 else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3744 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3745 // adapted from XLiFE++ gammaFunctions |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3746 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3747 T zc = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3748 // 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
|
3749 if (z < 10) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3750 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3751 const signed char n = 10 - z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3752 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
|
3753 p -= 1.0 / (k + z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3754 zc += n; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3755 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3756 p += lanczos_approximation_psi (zc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3757 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3758 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3759 return p; |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3760 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3761 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3762 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3763 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
|
3764 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
|
3765 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3766 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3767 std::complex<T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3768 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
|
3769 { |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3770 // adapted from XLiFE++ gammaFunctions |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3771 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3772 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
|
3773 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3774 P z_r = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3775 P z_ra = z_r; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3776 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3777 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
|
3778 if (z.imag () == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3779 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
|
3780 else if (z_r < 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3781 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
|
3782 else |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3783 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3784 // 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
|
3785 std::complex<T> z_m = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3786 if (z_ra < 8) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3787 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3788 unsigned char n = 8 - z_ra; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3789 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
|
3790 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3791 // 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
|
3792 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3793 // 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
|
3794 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
|
3795 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
|
3796 dgam -= P (1.0) / z_p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3797 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3798 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3799 // 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
|
3800 // LogGamma |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3801 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3802 // 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
|
3803 // + 7/1680z^8 - 9/1188z^10 + ... |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3804 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3805 // (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
|
3806 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
|
3807 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3808 return dgam; |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3809 } |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
3810 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3811 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3812 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
|
3813 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
|
3814 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3815 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3816 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
|
3817 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
|
3818 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3819 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3820 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
|
3821 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
|
3822 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
|
3823 { |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22954
diff
changeset
|
3824 F77_INT n = octave::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
|
3825 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
|
3826 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
|
3827 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
|
3828 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3829 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3830 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3831 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3832 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
|
3833 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
|
3834 float& ans, octave_idx_type& ierr) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
3835 { |
22988
cd33c785e80e
put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22954
diff
changeset
|
3836 F77_INT n = octave::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
|
3837 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
|
3838 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
|
3839 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
|
3840 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3841 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3842 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3843 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3844 T |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
3845 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
|
3846 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3847 T ans; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3848 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
|
3849 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
|
3850 if (ierr == 0) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
3851 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3852 // 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
|
3853 // 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
|
3854 // 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
|
3855 if (n > 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3856 // 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
|
3857 // way too fast. |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3858 ans = ans / (pow (-1.0, n + 1) / gamma (double (n+1))); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3859 else if (n == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3860 ans = -ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
3861 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3862 else if (ierr == 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3863 ans = - octave::numeric_limits<T>::Inf (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3864 else // we probably never get here |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3865 ans = octave::numeric_limits<T>::NaN (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3866 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3867 return ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
3868 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3869 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3870 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
|
3871 float psi (octave_idx_type n, float z) { return xpsi (n, z); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3872 } |
20161
65e22ba879f0
psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents:
20156
diff
changeset
|
3873 } |
65e22ba879f0
psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents:
20156
diff
changeset
|
3874 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3875 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3876 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3877 ComplexMatrix besselj (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3878 ComplexMatrix bessely (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3879 ComplexMatrix besseli (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3880 ComplexMatrix besselk (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3881 ComplexMatrix besselh1 (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3882 ComplexMatrix besselh2 (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3883 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3884 ComplexMatrix besselj (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3885 ComplexMatrix bessely (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3886 ComplexMatrix besseli (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3887 ComplexMatrix besselk (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3888 ComplexMatrix besselh1 (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3889 ComplexMatrix besselh2 (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3890 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3891 ComplexMatrix besselj (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3892 ComplexMatrix bessely (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3893 ComplexMatrix besseli (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3894 ComplexMatrix besselk (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3895 ComplexMatrix besselh1 (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3896 ComplexMatrix besselh2 (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3897 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3898 ComplexNDArray besselj (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3899 ComplexNDArray bessely (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3900 ComplexNDArray besseli (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3901 ComplexNDArray besselk (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3902 ComplexNDArray besselh1 (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3903 ComplexNDArray besselh2 (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3904 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3905 ComplexNDArray besselj (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3906 ComplexNDArray bessely (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3907 ComplexNDArray besseli (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3908 ComplexNDArray besselk (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3909 ComplexNDArray besselh1 (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3910 ComplexNDArray besselh2 (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3911 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3912 ComplexNDArray besselj (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3913 ComplexNDArray bessely (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3914 ComplexNDArray besseli (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3915 ComplexNDArray besselk (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3916 ComplexNDArray besselh1 (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3917 ComplexNDArray besselh2 (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3918 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3919 ComplexMatrix besselj (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3920 ComplexMatrix bessely (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3921 ComplexMatrix besseli (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3922 ComplexMatrix besselk (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3923 ComplexMatrix besselh1 (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3924 ComplexMatrix besselh2 (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3925 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3926 FloatComplexMatrix besselj (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3927 FloatComplexMatrix bessely (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3928 FloatComplexMatrix besseli (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3929 FloatComplexMatrix besselk (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3930 FloatComplexMatrix besselh1 (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3931 FloatComplexMatrix besselh2 (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3932 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3933 FloatComplexMatrix besselj (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3934 FloatComplexMatrix bessely (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3935 FloatComplexMatrix besseli (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3936 FloatComplexMatrix besselk (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3937 FloatComplexMatrix besselh1 (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3938 FloatComplexMatrix besselh2 (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3939 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3940 FloatComplexMatrix besselj (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3941 FloatComplexMatrix bessely (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3942 FloatComplexMatrix besseli (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3943 FloatComplexMatrix besselk (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3944 FloatComplexMatrix besselh1 (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3945 FloatComplexMatrix besselh2 (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3946 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3947 FloatComplexNDArray besselj (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3948 FloatComplexNDArray bessely (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3949 FloatComplexNDArray besseli (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3950 FloatComplexNDArray besselk (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3951 FloatComplexNDArray besselh1 (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3952 FloatComplexNDArray besselh2 (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3953 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3954 FloatComplexNDArray besselj (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3955 FloatComplexNDArray bessely (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3956 FloatComplexNDArray besseli (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3957 FloatComplexNDArray besselk (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3958 FloatComplexNDArray besselh1 (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3959 FloatComplexNDArray besselh2 (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3960 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3961 FloatComplexNDArray besselj (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3962 FloatComplexNDArray bessely (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3963 FloatComplexNDArray besseli (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3964 FloatComplexNDArray besselk (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3965 FloatComplexNDArray besselh1 (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3966 FloatComplexNDArray besselh2 (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3967 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3968 FloatComplexMatrix besselj (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3969 FloatComplexMatrix bessely (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3970 FloatComplexMatrix besseli (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3971 FloatComplexMatrix besselk (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3972 FloatComplexMatrix besselh1 (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3973 FloatComplexMatrix besselh2 (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3974 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3975 ComplexMatrix airy (const ComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3976 ComplexMatrix biry (const ComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3977 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3978 ComplexNDArray airy (const ComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3979 ComplexNDArray biry (const ComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3980 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3981 FloatComplexMatrix airy (const FloatComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3982 FloatComplexMatrix biry (const FloatComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3983 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3984 FloatComplexNDArray airy (const FloatComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3985 FloatComplexNDArray biry (const FloatComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3986 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3987 Array<double> betainc (double x, double a, const Array<double>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3988 Array<double> betainc (double x, const Array<double>& a, double b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3989 Array<double> betainc (double x, const Array<double>& a, const Array<double>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3990 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3991 Array<double> betainc (const Array<double>& x, double a, double b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3992 Array<double> betainc (const Array<double>& x, double a, const Array<double>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3993 Array<double> betainc (const Array<double>& x, const Array<double>& a, double b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3994 Array<double> betainc (const Array<double>& x, const Array<double>& a, const Array<double>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3995 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3996 Array<float> betainc (float x, float a, const Array<float>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3997 Array<float> betainc (float x, const Array<float>& a, float b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3998 Array<float> betainc (float x, const Array<float>& a, const Array<float>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
3999 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4000 Array<float> betainc (const Array<float>& x, float a, float b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4001 Array<float> betainc (const Array<float>& x, float a, const Array<float>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4002 Array<float> betainc (const Array<float>& x, const Array<float>& a, float b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4003 Array<float> betainc (const Array<float>& x, const Array<float>& a, const Array<float>& b) { return octave::math::betainc (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4004 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4005 Matrix gammainc (double x, const Matrix& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4006 Matrix gammainc (const Matrix& x, double a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4007 Matrix gammainc (const Matrix& x, const Matrix& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4008 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4009 NDArray gammainc (double x, const NDArray& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4010 NDArray gammainc (const NDArray& x, double a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4011 NDArray gammainc (const NDArray& x, const NDArray& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4012 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4013 FloatMatrix gammainc (float x, const FloatMatrix& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4014 FloatMatrix gammainc (const FloatMatrix& x, float a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4015 FloatMatrix gammainc (const FloatMatrix& x, const FloatMatrix& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4016 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4017 FloatNDArray gammainc (float x, const FloatNDArray& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4018 FloatNDArray gammainc (const FloatNDArray& x, float a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4019 FloatNDArray gammainc (const FloatNDArray& x, const FloatNDArray& a) { return octave::math::gammainc (x, a); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4020 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4021 Array<double> betaincinv (double x, double a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4022 Array<double> betaincinv (double x, const Array<double>& a, double b) { return octave::math::betaincinv (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4023 Array<double> betaincinv (double x, const Array<double>& a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4024 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4025 Array<double> betaincinv (const Array<double>& x, double a, double b) { return octave::math::betaincinv (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4026 Array<double> betaincinv (const Array<double>& x, double a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4027 Array<double> betaincinv (const Array<double>& x, const Array<double>& a, double b) { return octave::math::betaincinv (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4028 Array<double> betaincinv (const Array<double>& x, const Array<double>& a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4029 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
4030 #endif |