Mercurial > octave
annotate liboctave/numeric/lo-specfun.cc @ 27956:2310164737b3 stable
fix many spelling errors (bug #57613)
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 17 Jan 2020 13:15:27 -0600 |
parents | 3d1a335fb9ce |
children | c20b7290c778 |
rev | line source |
---|---|
3146 | 1 /* |
2 | |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25659
diff
changeset
|
3 Copyright (C) 1996-2019 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 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25659
diff
changeset
|
7 Copyright (C) 2016-2019 Carnë Draug |
3146 | 8 |
9 This file is part of Octave. | |
10 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24199
diff
changeset
|
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24199
diff
changeset
|
13 the Free Software Foundation, either version 3 of the License, or |
22755
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 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24199
diff
changeset
|
23 <https://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 | |
23623
4feed155a1f2
Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
31 #include <cmath> |
4feed155a1f2
Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
32 |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
33 #include <algorithm> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
34 #include <limits> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
35 #include <string> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
36 |
3220 | 37 #include "CColVector.h" |
38 #include "CMatrix.h" | |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
39 #include "CNDArray.h" |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
40 #include "Faddeeva.hh" |
3146 | 41 #include "dMatrix.h" |
4844 | 42 #include "dNDArray.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
43 #include "dRowVector.h" |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
44 #include "f77-fcn.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
45 #include "fCColVector.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
46 #include "fCMatrix.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
47 #include "fCNDArray.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
48 #include "fMatrix.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
49 #include "fNDArray.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
50 #include "fRowVector.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
51 #include "lo-amos-proto.h" |
3146 | 52 #include "lo-error.h" |
3220 | 53 #include "lo-ieee.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
54 #include "lo-mappers.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
55 #include "lo-slatec-proto.h" |
3220 | 56 #include "lo-specfun.h" |
3146 | 57 #include "mx-inlines.cc" |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15271
diff
changeset
|
58 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
59 namespace octave |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
60 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
61 namespace math |
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 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
64 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
|
65 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
66 static const Complex inf_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
67 = Complex (numeric_limits<double>::Inf (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
68 numeric_limits<double>::Inf ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
69 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
70 static const Complex nan_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
71 = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
72 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
73 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
74 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
75 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
76 switch (ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
77 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
78 case 0: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
79 case 3: |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
80 case 4: |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
81 retval = val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
82 break; |
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 case 2: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
85 retval = inf_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
86 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
87 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
88 default: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
89 retval = nan_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
90 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
91 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
92 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
93 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
94 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
95 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
96 static inline FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
97 bessel_return_value (const FloatComplex& val, octave_idx_type ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
98 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
99 static const FloatComplex inf_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
100 = FloatComplex (numeric_limits<float>::Inf (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
101 numeric_limits<float>::Inf ()); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
102 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
103 static const FloatComplex nan_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
104 = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
105 numeric_limits<float>::NaN ()); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
106 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
107 FloatComplex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
108 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
109 switch (ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
110 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
111 case 0: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
112 case 3: |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
113 case 4: |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
114 retval = val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
115 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
116 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
117 case 2: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
118 retval = inf_val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
119 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
120 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
121 default: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
122 retval = nan_val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
123 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
124 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
125 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
126 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
127 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
128 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
129 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
130 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
131 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
132 airy (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
133 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
134 double ar = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
135 double ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
136 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
137 double zr = z.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
138 double zi = z.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
139 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
140 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
141 F77_INT nz, t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
142 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
143 F77_FUNC (zairy, ZAIRY) (zr, zi, id, 2, ar, ai, nz, t_ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
144 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
145 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
146 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
147 if (! scaled) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
148 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
149 Complex expz = exp (- 2.0 / 3.0 * z * sqrt (z)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
150 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
151 double rexpz = expz.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
152 double iexpz = expz.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
153 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
154 double tmp = ar*rexpz - ai*iexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
155 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
156 ai = ar*iexpz + ai*rexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
157 ar = tmp; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
158 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
159 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
160 if (zi == 0.0 && (! scaled || zr >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
161 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
162 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
163 return bessel_return_value (Complex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
164 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
165 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
166 ComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
167 airy (const ComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
168 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
169 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
170 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
171 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
172 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
173 ComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
174 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
175 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
176 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
177 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
178 for (octave_idx_type i = 0; i < nr; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
179 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
180 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
181 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
182 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
183 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
184 ComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
185 airy (const ComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
186 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
187 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
188 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
189 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
190 ComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
191 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
192 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
193 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
194 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
195 retval(i) = airy (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
196 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
197 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
198 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
199 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
200 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
201 airy (const FloatComplex& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
202 octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
203 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
204 FloatComplex a; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
205 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
206 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
207 F77_INT nz, t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
208 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
209 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, 2, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
210 F77_CMPLX_ARG (&a), nz, t_ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
211 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
212 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
213 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
214 float ar = a.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
215 float ai = a.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
216 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
217 if (! scaled) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
218 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
219 FloatComplex expz = exp (- 2.0f / 3.0f * z * sqrt (z)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
220 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
221 float rexpz = expz.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
222 float iexpz = expz.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
223 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
224 float tmp = ar*rexpz - ai*iexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
225 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
226 ai = ar*iexpz + ai*rexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
227 ar = tmp; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
228 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
229 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
230 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
231 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
232 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
233 return bessel_return_value (FloatComplex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
234 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
235 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
236 FloatComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
237 airy (const FloatComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
238 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
239 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
240 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
241 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
242 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
243 FloatComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
244 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
245 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
246 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
247 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
248 for (octave_idx_type i = 0; i < nr; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
249 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
250 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
251 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
252 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
253 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
254 FloatComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
255 airy (const FloatComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
256 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
257 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
258 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
259 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
260 FloatComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
261 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
262 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
263 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
264 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
265 retval(i) = airy (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
266 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
267 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
268 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
269 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
270 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
271 is_integer_value (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
272 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
273 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
|
274 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
275 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
276 static inline Complex |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
277 zbesj (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
278 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
279 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
280 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
281 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
282 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
283 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
284 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
285 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
286 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
287 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
288 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
289 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
290 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
291 static inline Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
292 zbesh2 (const Complex& z, double alpha, int kode, octave_idx_type& ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
293 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
294 static inline Complex |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
295 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
|
296 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
297 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
298 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
299 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
300 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
301 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
302 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
303 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
304 F77_INT nz, t_ierr; |
21786
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 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
307 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
308 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
309 F77_FUNC (zbesj, ZBESJ) (zr, zi, alpha, kode, 1, &yr, &yi, nz, t_ierr); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
310 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
311 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
312 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
313 if (zi == 0.0 && zr >= 0.0) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
314 yi = 0.0; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
315 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
316 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
317 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
318 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
319 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
320 // 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
|
321 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
322 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
|
323 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
324 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
325 retval = bessel_return_value (tmp, ierr); |
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 else |
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 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
330 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
331 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
|
332 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
333 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
334 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
335 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
|
336 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
337 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
338 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
339 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
340 retval = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
341 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
342 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
343 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
344 return retval; |
3220 | 345 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
346 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
347 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
348 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
4911 | 349 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
350 Complex retval; |
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 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
353 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
354 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
355 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
356 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
357 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
358 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
359 double wr, wi; |
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 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
362 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
363 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
364 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
365 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
366 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
|
367 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
368 yr = -numeric_limits<double>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
369 yi = 0.0; |
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 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
372 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
373 F77_FUNC (zbesy, ZBESY) (zr, zi, alpha, kode, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
374 &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
|
375 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
376 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
377 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
378 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
|
379 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
380 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
381 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
382 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
|
383 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
384 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
|
385 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
386 // 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
|
387 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
388 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
|
389 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
|
390 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
391 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
392 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
393 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
394 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
395 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
396 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
397 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
|
398 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
399 if (ierr == 0 || ierr == 3) |
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 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
|
402 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
403 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
404 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
405 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
406 retval = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
407 numeric_limits<double>::NaN ()); |
21786
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
410 return retval; |
4911 | 411 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
412 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
413 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
414 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 415 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
416 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
417 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
418 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
419 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
420 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
421 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
422 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
423 F77_INT nz, t_ierr; |
21786
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 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
426 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
427 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
428 F77_FUNC (zbesi, ZBESI) (zr, zi, alpha, kode, 1, &yr, &yi, nz, t_ierr); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
429 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
430 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
431 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
432 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
|
433 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
434 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
435 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
|
436 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
437 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
438 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
439 // 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
|
440 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
441 Complex tmp = zbesi (z, alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
442 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
443 } |
3220 | 444 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
445 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
446 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
447 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
448 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
|
449 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
450 if (ierr == 0 || ierr == 3) |
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 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
|
453 * zbesk (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
454 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
455 if (kode == 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
456 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
457 // 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
|
458 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
|
459 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
460 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
461 tmp += tmp2; |
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 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
464 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
465 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
466 retval = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
467 numeric_limits<double>::NaN ()); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
468 } |
3146 | 469 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
470 return retval; |
3146 | 471 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
472 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
473 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
474 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 475 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
476 Complex retval; |
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 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
479 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
480 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
481 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
482 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
483 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
484 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
485 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
486 double zi = z.imag (); |
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 ierr = 0; |
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 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
|
491 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
492 yr = numeric_limits<double>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
493 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
494 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
495 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
496 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
497 F77_FUNC (zbesk, ZBESK) (zr, zi, alpha, kode, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
498 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
499 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
500 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
501 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
502 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
|
503 yi = 0.0; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
504 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
505 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
506 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
|
507 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
508 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
509 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
510 Complex tmp = zbesk (z, -alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
511 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
512 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
513 } |
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 return retval; |
3220 | 516 } |
517 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
518 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
519 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 520 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
521 Complex retval; |
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 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
524 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
525 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
526 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
527 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
528 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
529 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
530 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
531 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
532 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
533 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, kode, 1, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
534 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
535 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
536 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
537 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
538 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
539 } |
3220 | 540 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
541 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
542 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
543 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
544 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
|
545 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
546 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
|
547 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
548 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
549 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
550 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
551 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
552 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
553 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
554 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
555 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
|
556 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
557 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
558 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
559 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
560 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
561 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
562 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
563 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
564 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
565 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
566 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
567 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
568 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
569 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, kode, 2, 1, &yr, &yi, nz, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
570 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
571 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
572 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
573 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
574 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
575 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
576 else |
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 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
579 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
580 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
|
581 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
582 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
|
583 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
584 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
585 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
586 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
587 return retval; |
3220 | 588 } |
3146 | 589 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
590 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
|
591 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
592 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
593 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
|
594 bool scaled, octave_idx_type& ierr) |
3220 | 595 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
596 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
597 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
598 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
|
599 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
600 return retval; |
3220 | 601 } |
3146 | 602 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
603 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
604 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
|
605 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 606 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
607 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
608 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
609 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
610 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
611 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
612 ierr.resize (dim_vector (nr, nc)); |
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 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
|
615 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
|
616 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
|
617 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
618 return retval; |
3146 | 619 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
620 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
621 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
622 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
|
623 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 624 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
625 octave_idx_type nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
626 octave_idx_type nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
627 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
628 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
629 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
630 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
631 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
632 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
|
633 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
|
634 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
|
635 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
636 return retval; |
3220 | 637 } |
638 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
639 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
640 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
|
641 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
|
642 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
643 ComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
644 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
645 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
|
646 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
|
647 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
648 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
|
649 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
|
650 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
651 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
|
652 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
653 ("%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
|
654 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
655 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
656 octave_idx_type nc = x_nc; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
657 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
658 retval.resize (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
659 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
660 ierr.resize (dim_vector (nr, nc)); |
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 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
|
663 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
|
664 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
|
665 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
666 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
667 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
668 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
669 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
670 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
|
671 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
|
672 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
673 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
674 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
675 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
676 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
677 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
678 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
679 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
|
680 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
|
681 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
682 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
683 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
684 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
685 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
686 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
|
687 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
|
688 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
689 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
690 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
691 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
692 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
693 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
694 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
695 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
|
696 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
|
697 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
698 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
699 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
700 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
701 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
702 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
|
703 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
|
704 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
705 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
706 ComplexNDArray retval; |
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 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
709 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
710 ("%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
|
711 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
712 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
713 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
714 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
715 ierr.resize (dv); |
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 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
|
718 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
|
719 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
720 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
721 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
722 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
723 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
724 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
|
725 const ComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
726 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
727 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
728 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
729 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
730 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
731 ComplexMatrix retval (nr, nc); |
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 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
734 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
735 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
|
736 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
|
737 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
|
738 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
739 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
740 } |
3146 | 741 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
742 #define SS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
743 Complex \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
744 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
|
745 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
746 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
|
747 } |
3220 | 748 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
749 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
750 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
751 name (double alpha, const ComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
752 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
753 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
754 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
|
755 } |
3220 | 756 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
757 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
758 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
759 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
|
760 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
761 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
762 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
|
763 } |
3220 | 764 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
765 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
766 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
767 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
|
768 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
769 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
770 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
|
771 } |
3220 | 772 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
773 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
774 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
775 name (double alpha, const ComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
776 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
777 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
778 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
|
779 } |
4844 | 780 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
781 #define NS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
782 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
783 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
|
784 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
785 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
786 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
|
787 } |
4844 | 788 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
789 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
790 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
791 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
|
792 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
793 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
794 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
|
795 } |
4844 | 796 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
797 #define RC_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
798 ComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
799 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
|
800 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
801 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
802 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
|
803 } |
3220 | 804 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
805 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
806 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
807 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
808 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
809 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
810 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
811 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
812 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
813 RC_BESSEL (name, fcn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
814 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
815 ALL_BESSEL (besselj, zbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
816 ALL_BESSEL (bessely, zbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
817 ALL_BESSEL (besseli, zbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
818 ALL_BESSEL (besselk, zbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
819 ALL_BESSEL (besselh1, zbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
820 ALL_BESSEL (besselh2, zbesh2) |
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 #undef ALL_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
823 #undef SS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
824 #undef SM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
825 #undef MS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
826 #undef MM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
827 #undef SN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
828 #undef NS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
829 #undef NN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
830 #undef RC_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
831 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
832 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
833 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
|
834 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
835 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
836 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
|
837 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
838 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
839 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
|
840 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
841 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
842 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
|
843 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
844 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
845 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
|
846 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
847 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
848 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
|
849 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
850 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
851 is_integer_value (float x) |
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 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
|
854 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
855 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
856 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
857 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
|
858 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
859 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
860 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
861 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
862 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
863 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
864 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
865 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
866 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
867 F77_FUNC (cbesj, CBESJ) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
868 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
|
869 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
870 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
871 |
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
|
872 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
|
873 y = FloatComplex (y.real (), 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 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
876 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
877 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
878 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
879 // 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
|
880 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
881 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
|
882 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
883 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
884 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
885 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
886 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
887 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
888 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
889 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
890 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
|
891 * cbesj (z, alpha, kode, ierr); |
21786
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 -= sinf (static_cast<float> (M_PI) * alpha) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
896 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
897 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
898 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
899 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
900 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
901 retval = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
902 numeric_limits<float>::NaN ()); |
21786
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
905 return retval; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
908 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
909 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
|
910 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
911 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
912 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
913 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
914 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
915 FloatComplex y = 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 FloatComplex w; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
920 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
921 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
922 |
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
|
923 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
|
924 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
925 y = FloatComplex (-numeric_limits<float>::Inf (), 0.0); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
926 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
927 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
928 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
929 F77_FUNC (cbesy, CBESY) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
930 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
|
931 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
|
932 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
933 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
934 |
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
|
935 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
|
936 y = FloatComplex (y.real (), 0.0); |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
939 return bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
940 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
941 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
|
942 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
943 // 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
|
944 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
945 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
|
946 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
|
947 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
948 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
949 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
950 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
951 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
952 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
953 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
954 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
|
955 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
956 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
957 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
958 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
959 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
|
960 * cbesj (z, alpha, kode, ierr); |
21786
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 retval = bessel_return_value (tmp, ierr); |
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 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
965 retval = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
966 numeric_limits<float>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
967 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
968 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
969 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
970 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
971 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
972 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
973 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
|
974 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
975 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
976 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
977 if (alpha >= 0.0) |
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 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
980 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
981 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
982 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
983 F77_FUNC (cbesi, CBESI) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
984 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
|
985 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
986 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
987 |
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
|
988 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
|
989 y = FloatComplex (y.real (), 0.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 retval = bessel_return_value (y, ierr); |
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 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
994 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
995 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
996 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
997 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
|
998 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
999 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1000 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1001 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
|
1002 * sinf (static_cast<float> (M_PI) * alpha) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1003 * cbesk (z, alpha, kode, ierr); |
21786
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 if (kode == 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1006 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1007 // 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
|
1008 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
|
1009 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1010 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1011 tmp += tmp2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1012 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1013 retval = bessel_return_value (tmp, ierr); |
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 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1016 retval = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1017 numeric_limits<float>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1018 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1019 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1020 return retval; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1023 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1024 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
|
1025 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1026 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1027 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1028 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1029 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1030 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1031 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1032 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1033 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1034 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1035 |
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
|
1036 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
|
1037 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1038 y = FloatComplex (numeric_limits<float>::Inf (), 0.0); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1039 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1040 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1041 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1042 F77_FUNC (cbesk, CBESK) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1043 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
|
1044 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1045 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1046 |
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
|
1047 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
|
1048 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1049 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1050 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1051 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1052 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1053 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1054 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1055 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
|
1056 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1057 retval = bessel_return_value (tmp, ierr); |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1060 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1061 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1062 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1063 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1064 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
|
1065 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1066 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1067 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1068 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1069 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1070 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1071 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1072 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1073 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1074 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 1, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1075 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
|
1076 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1077 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1078 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1079 retval = bessel_return_value (y, ierr); |
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 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1082 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1083 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1084 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1085 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
|
1086 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1087 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
|
1088 * cbesh1 (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1089 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1090 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1091 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1092 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1093 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1094 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1095 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1096 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1097 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
|
1098 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1099 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1100 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1101 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1102 { |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1103 FloatComplex y = 0.0;; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1104 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1105 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1106 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1107 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, kode, 2, 1, |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1108 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
|
1109 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1110 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1111 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1112 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1113 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1114 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1115 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1116 alpha = -alpha; |
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 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
|
1119 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1120 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
|
1121 * cbesh2 (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1122 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1123 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1124 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1125 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1126 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1127 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1128 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1129 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
|
1130 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 FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1133 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
|
1134 bool scaled, octave_idx_type& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1135 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1136 FloatComplex 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; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1141 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1142 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1143 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1144 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
|
1145 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
|
1146 { |
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 FloatComplexMatrix 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; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1159 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1160 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1161 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1162 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
|
1163 const FloatComplex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1164 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
|
1165 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1166 octave_idx_type nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1167 octave_idx_type nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1168 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1169 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1170 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1171 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1172 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1173 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
|
1174 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
|
1175 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
|
1176 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1177 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1178 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1179 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1180 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1181 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
|
1182 const FloatComplexMatrix& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1183 Array<octave_idx_type>& ierr) |
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 FloatComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1186 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1187 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
|
1188 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
|
1189 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1190 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
|
1191 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
|
1192 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1193 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
|
1194 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1195 ("%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
|
1196 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1197 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1198 octave_idx_type nc = x_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 retval.resize (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 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1203 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1204 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
|
1205 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
|
1206 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
|
1207 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1208 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1209 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1210 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1211 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1212 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
|
1213 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
|
1214 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1215 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1216 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1217 FloatComplexNDArray retval (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 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1220 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1221 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
|
1222 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
|
1223 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1224 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1225 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1226 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1227 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1228 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
|
1229 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
|
1230 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1231 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1232 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1233 FloatComplexNDArray retval (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 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1236 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1237 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
|
1238 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
|
1239 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1240 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1241 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1242 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1243 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1244 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
|
1245 const FloatComplexNDArray& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1246 Array<octave_idx_type>& ierr) |
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 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1249 FloatComplexNDArray retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1250 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1251 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1252 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1253 ("%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
|
1254 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1255 octave_idx_type nel = dv.numel (); |
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 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1258 ierr.resize (dv); |
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 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
|
1261 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
|
1262 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1263 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1264 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1265 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1266 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1267 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
|
1268 const FloatComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1269 Array<octave_idx_type>& ierr) |
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 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1272 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1273 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1274 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1275 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1276 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1277 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1278 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
|
1279 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
|
1280 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
|
1281 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1282 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1283 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1284 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1285 #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
|
1286 FloatComplex \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1287 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
|
1288 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
|
1289 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1290 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
|
1291 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1292 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1293 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1294 FloatComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1295 name (float alpha, const FloatComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1296 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1297 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1298 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
|
1299 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1300 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1301 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1302 FloatComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1303 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
|
1304 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1305 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1306 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
|
1307 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1308 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1309 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1310 FloatComplexMatrix \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1311 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
|
1312 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1313 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1314 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
|
1315 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1316 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1317 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1318 FloatComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1319 name (float alpha, const FloatComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1320 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1321 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1322 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
|
1323 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1324 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1325 #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
|
1326 FloatComplexNDArray \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1327 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
|
1328 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
|
1329 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1330 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
|
1331 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1332 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1333 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1334 FloatComplexNDArray \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1335 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
|
1336 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1337 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1338 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
|
1339 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1340 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1341 #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
|
1342 FloatComplexMatrix \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1343 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
|
1344 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
|
1345 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
|
1346 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1347 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
|
1348 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1349 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1350 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1351 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1352 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1353 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1354 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1355 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1356 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1357 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1358 RC_BESSEL (name, fcn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1359 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1360 ALL_BESSEL (besselj, cbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1361 ALL_BESSEL (bessely, cbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1362 ALL_BESSEL (besseli, cbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1363 ALL_BESSEL (besselk, cbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1364 ALL_BESSEL (besselh1, cbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1365 ALL_BESSEL (besselh2, cbesh2) |
3220 | 1366 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1367 #undef ALL_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1368 #undef SS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1369 #undef SM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1370 #undef MS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1371 #undef MM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1372 #undef SN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1373 #undef NS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1374 #undef NN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1375 #undef RC_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1376 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1377 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1378 biry (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1379 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1380 double ar = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1381 double ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1382 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1383 double zr = z.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1384 double zi = z.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1385 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1386 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1387 F77_INT t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1388 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1389 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, 2, ar, ai, t_ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1390 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1391 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1392 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1393 if (! scaled) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1394 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1395 Complex expz = exp (std::abs (std::real (2.0 / 3.0 * z * sqrt (z)))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1396 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1397 double rexpz = expz.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1398 double iexpz = expz.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1399 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1400 double tmp = ar*rexpz - ai*iexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1401 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1402 ai = ar*iexpz + ai*rexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1403 ar = tmp; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1404 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1405 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1406 if (zi == 0.0 && (! scaled || zr >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1407 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1408 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1409 return bessel_return_value (Complex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1410 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1411 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1412 ComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1413 biry (const ComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1414 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1415 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1416 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1417 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1418 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1419 ComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1420 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1421 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1422 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1423 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1424 for (octave_idx_type i = 0; i < nr; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1425 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1426 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1427 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1428 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1429 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1430 ComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1431 biry (const ComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1432 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1433 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1434 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1435 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1436 ComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1437 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1438 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1439 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1440 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1441 retval(i) = biry (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1442 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1443 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1444 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1445 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1446 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1447 biry (const FloatComplex& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1448 octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1449 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1450 FloatComplex a; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1451 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1452 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1453 F77_INT t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1454 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1455 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, 2, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1456 F77_CMPLX_ARG (&a), t_ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1457 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1458 ierr = t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1459 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1460 float ar = a.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1461 float ai = a.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1462 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1463 if (! scaled) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1464 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1465 FloatComplex expz |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1466 = exp (std::abs (std::real (2.0f / 3.0f * z * sqrt (z)))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1467 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1468 float rexpz = expz.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1469 float iexpz = expz.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1470 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1471 float tmp = ar*rexpz - ai*iexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1472 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1473 ai = ar*iexpz + ai*rexpz; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1474 ar = tmp; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1475 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1476 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1477 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1478 ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1479 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1480 return bessel_return_value (FloatComplex (ar, ai), ierr); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1481 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1482 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1483 FloatComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1484 biry (const FloatComplexMatrix& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1485 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1486 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1487 octave_idx_type nr = z.rows (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1488 octave_idx_type nc = z.cols (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1489 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1490 FloatComplexMatrix retval (nr, nc); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1491 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1492 ierr.resize (dim_vector (nr, nc)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1493 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1494 for (octave_idx_type j = 0; j < nc; j++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1495 for (octave_idx_type i = 0; i < nr; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1496 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1497 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1498 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1499 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1500 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1501 FloatComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1502 biry (const FloatComplexNDArray& z, bool deriv, bool scaled, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1503 Array<octave_idx_type>& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1504 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1505 dim_vector dv = z.dims (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1506 octave_idx_type nel = dv.numel (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1507 FloatComplexNDArray retval (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1508 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1509 ierr.resize (dv); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1510 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1511 for (octave_idx_type i = 0; i < nel; i++) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1512 retval(i) = biry (z(i), deriv, scaled, ierr(i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1513 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1514 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1515 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1516 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1517 // Real and complex Dawson function (= scaled erfi) from Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1518 double dawson (double x) { return Faddeeva::Dawson (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1519 float dawson (float x) { return Faddeeva::Dawson (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1520 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1521 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1522 dawson (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1523 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1524 return Faddeeva::Dawson (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1525 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1526 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1527 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1528 dawson (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1529 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1530 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1531 Complex ret; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1532 ret = Faddeeva::Dawson (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1533 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1534 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1535 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1536 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1537 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
|
1538 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1539 static const int Nmax = 16; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1540 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
|
1541 int n, Nn, ii; |
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 if (m < 0 || m > 1) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1544 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1545 (*current_liboctave_warning_with_id_handler) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1546 ("Octave:ellipj-invalid-m", |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1547 "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
|
1548 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1549 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
|
1550 |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1551 return; |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1552 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1553 |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1554 double sqrt_eps = std::sqrt (std::numeric_limits<double>::epsilon ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1555 if (m < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1556 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1557 // 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
|
1558 si_u = sin (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1559 co_u = cos (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1560 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
|
1561 sn = si_u - t * co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1562 cn = co_u + t * si_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1563 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
|
1564 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1565 else if ((1 - m) < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1566 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1567 // 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
|
1568 m1 = 1 - m; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1569 si_u = sinh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1570 co_u = cosh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1571 ta_u = tanh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1572 se_u = 1/co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1573 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
|
1574 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
|
1575 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
|
1576 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1577 else |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1578 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1579 // Arithmetic-Geometric Mean (AGM) algorithm |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1580 // (Abramowitz and Stegun, Section 16.4) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1581 a[0] = 1; |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1582 b = std::sqrt (1 - m); |
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1583 c[0] = std::sqrt (m); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1584 for (n = 1; n < Nmax; ++n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1585 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1586 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
|
1587 c[n] = (a[n - 1] - b)/2; |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1588 b = std::sqrt (a[n - 1]*b); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1589 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
|
1590 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1591 if (n >= Nmax - 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1592 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1593 err = 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1594 return; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1595 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1596 Nn = n; |
26442
3d1a335fb9ce
lo-specfun.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
1597 for (ii = 1; n > 0; ii *= 2, --n) {} // ii = pow(2,Nn) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1598 phi = ii*a[Nn]*u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1599 for (n = Nn; n > 0; --n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1600 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23668
diff
changeset
|
1601 phi = (std::asin ((c[n]/a[n])* sin (phi)) + phi)/2; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1602 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1603 sn = sin (phi); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1604 cn = cos (phi); |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1605 dn = std::sqrt (1 - m*sn*sn); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1606 } |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1607 } |
21786
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 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1610 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
|
1611 double& err) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1612 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1613 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
|
1614 |
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
|
1615 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
|
1616 if (u.real () == 0) |
21786
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 // 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
|
1619 sn = Complex (0, ss1/cc1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1620 cn = 1/cc1; // cn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1621 dn = dd1/cc1; // dn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1622 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1623 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1624 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1625 // u is generic complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1626 double ss, cc, dd, ddd; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1627 |
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
|
1628 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
|
1629 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
|
1630 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
|
1631 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
|
1632 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
|
1633 } |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1634 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1635 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1636 // Complex error function from the Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1637 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1638 erf (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1639 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1640 return Faddeeva::erf (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1641 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1642 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1643 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1644 erf (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1645 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1646 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1647 Complex ret = Faddeeva::erf (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1648 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1649 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1650 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1651 // Complex complementary error function from the Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1652 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1653 erfc (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1654 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1655 return Faddeeva::erfc (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1656 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1657 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1658 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1659 erfc (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1660 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1661 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1662 Complex ret = Faddeeva::erfc (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1663 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1664 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1665 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1666 // The algorithm for erfcinv is an adaptation of the erfinv algorithm |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1667 // above from P. J. Acklam. It has been modified to run over the |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1668 // different input domain of erfcinv. See the notes for erfinv for an |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1669 // explanation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1670 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1671 static double do_erfcinv (double x, bool refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1672 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1673 // Coefficients of rational approximation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1674 static const double a[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1675 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1676 -2.806989788730439e+01, 1.562324844726888e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1677 -1.951109208597547e+02, 9.783370457507161e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1678 -2.168328665628878e+01, 1.772453852905383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1679 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1680 static const double b[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1681 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1682 -5.447609879822406e+01, 1.615858368580409e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1683 -1.556989798598866e+02, 6.680131188771972e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1684 -1.328068155288572e+01 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1685 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1686 static const double c[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1687 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1688 -5.504751339936943e-03, -2.279687217114118e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1689 -1.697592457770869e+00, -1.802933168781950e+00, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1690 3.093354679843505e+00, 2.077595676404383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1691 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1692 static const double d[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1693 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1694 7.784695709041462e-03, 3.224671290700398e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1695 2.445134137142996e+00, 3.754408661907416e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1696 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1697 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1698 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1699 static const double pbreak_lo = 0.04850; // 1-pbreak |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1700 static const double pbreak_hi = 1.95150; // 1+pbreak |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1701 double y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1702 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1703 // Select case. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1704 if (x >= pbreak_lo && x <= pbreak_hi) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1705 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1706 // Middle region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1707 const double q = 0.5*(1-x), r = q*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1708 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1709 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1710 y = yn / yd; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1711 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1712 else if (x > 0.0 && x < 2.0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1713 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1714 // Tail region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1715 const double q = (x < 1 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1716 ? std::sqrt (-2*std::log (0.5*x)) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1717 : std::sqrt (-2*std::log (0.5*(2-x)))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1718 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1719 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1720 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1721 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1722 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1723 y = yn / yd; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1724 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1725 if (x < pbreak_lo) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1726 y = -y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1727 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1728 else if (x == 0.0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1729 return numeric_limits<double>::Inf (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1730 else if (x == 2.0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1731 return -numeric_limits<double>::Inf (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1732 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1733 return numeric_limits<double>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1734 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1735 if (refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1736 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1737 // One iteration of Halley's method gives full precision. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1738 double u = (erf (y) - (1-x)) * spi2 * exp (y*y); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1739 y -= u / (1 + y*u); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1740 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1741 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1742 return y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1743 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1744 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1745 double erfcinv (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1746 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1747 return do_erfcinv (x, true); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1748 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1749 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1750 float erfcinv (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1751 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1752 return do_erfcinv (x, false); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1753 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1754 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1755 // Real and complex scaled complementary error function from Faddeeva pkg. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1756 double erfcx (double x) { return Faddeeva::erfcx (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1757 float erfcx (float x) { return Faddeeva::erfcx (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1758 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1759 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1760 erfcx (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1761 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1762 return Faddeeva::erfcx (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1763 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1764 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1765 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1766 erfcx (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1767 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1768 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1769 Complex ret; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1770 ret = Faddeeva::erfcx (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1771 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1772 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1773 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1774 // Real and complex imaginary error function from Faddeeva package |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1775 double erfi (double x) { return Faddeeva::erfi (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1776 float erfi (float x) { return Faddeeva::erfi (x); } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1777 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1778 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1779 erfi (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1780 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1781 return Faddeeva::erfi (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1782 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1783 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1784 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1785 erfi (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1786 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1787 Complex xd (x.real (), x.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1788 Complex ret = Faddeeva::erfi (xd, std::numeric_limits<float>::epsilon ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1789 return FloatComplex (ret.real (), ret.imag ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1790 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1791 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1792 // This algorithm is due to P. J. Acklam. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1793 // |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1794 // See http://home.online.no/~pjacklam/notes/invnorm/ |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1795 // |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1796 // The rational approximation has relative accuracy 1.15e-9 in the whole |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1797 // region. For doubles, it is refined by a single step of Halley's 3rd |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1798 // order method. For single precision, the accuracy is already OK, so |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1799 // we skip it to get faster evaluation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1800 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1801 static double do_erfinv (double x, bool refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1802 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1803 // Coefficients of rational approximation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1804 static const double a[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1805 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1806 -2.806989788730439e+01, 1.562324844726888e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1807 -1.951109208597547e+02, 9.783370457507161e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1808 -2.168328665628878e+01, 1.772453852905383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1809 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1810 static const double b[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1811 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1812 -5.447609879822406e+01, 1.615858368580409e+02, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1813 -1.556989798598866e+02, 6.680131188771972e+01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1814 -1.328068155288572e+01 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1815 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1816 static const double c[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1817 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1818 -5.504751339936943e-03, -2.279687217114118e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1819 -1.697592457770869e+00, -1.802933168781950e+00, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1820 3.093354679843505e+00, 2.077595676404383e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1821 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1822 static const double d[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1823 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1824 7.784695709041462e-03, 3.224671290700398e-01, |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1825 2.445134137142996e+00, 3.754408661907416e+00 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1826 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1827 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1828 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1829 static const double pbreak = 0.95150; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1830 double ax = fabs (x), y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1831 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1832 // Select case. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1833 if (ax <= pbreak) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1834 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1835 // Middle region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1836 const double q = 0.5 * x, r = q*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1837 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1838 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1839 y = yn / yd; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1840 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1841 else if (ax < 1.0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1842 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1843 // Tail region. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1844 const double q = std::sqrt (-2*std::log (0.5*(1-ax))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1845 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1846 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1847 y = yn / yd * math::signum (-x); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1848 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1849 else if (ax == 1.0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1850 return numeric_limits<double>::Inf () * math::signum (x); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1851 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1852 return numeric_limits<double>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1853 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1854 if (refine) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1855 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1856 // One iteration of Halley's method gives full precision. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1857 double u = (erf (y) - x) * spi2 * exp (y*y); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1858 y -= u / (1 + y*u); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1859 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1860 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1861 return y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1862 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1863 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1864 double erfinv (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1865 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1866 return do_erfinv (x, true); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1867 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1868 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1869 float erfinv (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1870 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1871 return do_erfinv (x, false); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1872 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1873 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1874 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1875 expm1 (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1876 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1877 Complex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1878 |
24199
2ac103974d00
Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents:
23761
diff
changeset
|
1879 if (std::abs (x) < 1) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1880 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1881 double im = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1882 double u = expm1 (x.real ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1883 double v = sin (im/2); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1884 v = -2*v*v; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1885 retval = Complex (u*v + u + v, (u+1) * sin (im)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1886 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1887 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1888 retval = std::exp (x) - Complex (1); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1889 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1890 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1891 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1892 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1893 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1894 expm1 (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1895 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1896 FloatComplex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1897 |
24199
2ac103974d00
Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents:
23761
diff
changeset
|
1898 if (std::abs (x) < 1) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1899 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1900 float im = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1901 float u = expm1 (x.real ()); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1902 float v = sin (im/2); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1903 v = -2*v*v; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1904 retval = FloatComplex (u*v + u + v, (u+1) * sin (im)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1905 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1906 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1907 retval = std::exp (x) - FloatComplex (1); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1908 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1909 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1910 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1911 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1912 double |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1913 gamma (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1914 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1915 double result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1916 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1917 // Special cases for (near) compatibility with Matlab instead of tgamma. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1918 // Matlab does not have -0. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1919 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1920 if (x == 0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1921 result = (math::negative_sign (x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1922 ? -numeric_limits<double>::Inf () |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1923 : numeric_limits<double>::Inf ()); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1924 else if ((x < 0 && math::x_nint (x) == x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1925 || math::isinf (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1926 result = numeric_limits<double>::Inf (); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1927 else if (math::isnan (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1928 result = numeric_limits<double>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1929 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1930 result = std::tgamma (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1931 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1932 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1933 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1934 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1935 float |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1936 gamma (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1937 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1938 float result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1939 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1940 // Special cases for (near) compatibility with Matlab instead of tgamma. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1941 // Matlab does not have -0. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1942 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1943 if (x == 0) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1944 result = (math::negative_sign (x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1945 ? -numeric_limits<float>::Inf () |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1946 : numeric_limits<float>::Inf ()); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1947 else if ((x < 0 && math::x_nint (x) == x) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1948 || math::isinf (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1949 result = numeric_limits<float>::Inf (); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1950 else if (math::isnan (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1951 result = numeric_limits<float>::NaN (); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1952 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1953 result = std::tgammaf (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1954 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1955 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1956 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1957 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1958 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1959 log1p (const Complex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1960 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1961 Complex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1962 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1963 double r = x.real (), i = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1964 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1965 if (fabs (r) < 0.5 && fabs (i) < 0.5) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1966 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1967 double u = 2*r + r*r + i*i; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1968 retval = Complex (log1p (u / (1+std::sqrt (u+1))), |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1969 atan2 (1 + r, i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1970 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1971 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1972 retval = std::log (Complex (1) + x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1973 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1974 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1975 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1976 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1977 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1978 log1p (const FloatComplex& x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1979 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1980 FloatComplex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1981 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1982 float r = x.real (), i = x.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1983 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1984 if (fabs (r) < 0.5 && fabs (i) < 0.5) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1985 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1986 float u = 2*r + r*r + i*i; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1987 retval = FloatComplex (log1p (u / (1+std::sqrt (u+1))), |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1988 atan2 (1 + r, i)); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1989 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1990 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1991 retval = std::log (FloatComplex (1) + x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1992 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1993 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1994 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1995 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1996 static const double pi = 3.14159265358979323846; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1997 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1998 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1999 static inline T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2000 xlog (const T& x) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
2001 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2002 return log (x); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
2003 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2004 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2005 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2006 inline double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2007 xlog (const double& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2008 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2009 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2010 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2011 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2012 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2013 inline float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2014 xlog (const float& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2015 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2016 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2017 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2018 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2019 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2020 static T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2021 lanczos_approximation_psi (const T zc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2022 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2023 // 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
|
2024 // 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
|
2025 // 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
|
2026 // 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
|
2027 static const T dg_coeff[10] = |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
2028 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2029 -0.83333333333333333e-1, 0.83333333333333333e-2, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2030 -0.39682539682539683e-2, 0.41666666666666667e-2, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2031 -0.75757575757575758e-2, 0.21092796092796093e-1, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2032 -0.83333333333333333e-1, 0.4432598039215686, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2033 -0.3053954330270122e+1, 0.125318899521531e+2 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2034 }; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2035 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2036 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
|
2037 T overz2k = overz2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2038 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2039 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2040 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
|
2041 p += dg_coeff[k] * overz2k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2042 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
|
2043 return p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2044 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2045 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2046 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2047 T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2048 xpsi (T z) |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2049 { |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
2050 static const double euler_mascheroni = |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
2051 0.577215664901532860606512090082402431042; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2052 |
23726
1147e5c912aa
Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
2053 const bool is_int = (std::floor (z) == z); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2054 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2055 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2056 if (z <= 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2057 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2058 // limits - zeros of the gamma function |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2059 if (is_int) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2060 p = -numeric_limits<T>::Inf (); // Matlab returns -Inf for psi (0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2061 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2062 // 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
|
2063 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
|
2064 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2065 else if (is_int) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2066 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2067 // 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
|
2068 p = - euler_mascheroni; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2069 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
|
2070 p += 1.0 / k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2071 } |
23726
1147e5c912aa
Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
2072 else if (std::floor (z + 0.5) == z + 0.5) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2073 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2074 // 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
|
2075 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
|
2076 p += 1.0 / (2 * k - 1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2077 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2078 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
|
2079 } |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2080 else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2081 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2082 // adapted from XLiFE++ gammaFunctions |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2083 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2084 T zc = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2085 // 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
|
2086 if (z < 10) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2087 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2088 const signed char n = 10 - z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2089 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
|
2090 p -= 1.0 / (k + z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2091 zc += n; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2092 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2093 p += lanczos_approximation_psi (zc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2094 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2095 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2096 return p; |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2097 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2098 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2099 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2100 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
|
2101 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
|
2102 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2103 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2104 std::complex<T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2105 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
|
2106 { |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2107 // adapted from XLiFE++ gammaFunctions |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2108 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2109 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
|
2110 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2111 P z_r = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2112 P z_ra = z_r; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2113 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2114 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
|
2115 if (z.imag () == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2116 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
|
2117 else if (z_r < 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2118 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
|
2119 else |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2120 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2121 // 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
|
2122 std::complex<T> z_m = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2123 if (z_ra < 8) |
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 unsigned char n = 8 - z_ra; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2126 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
|
2127 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2128 // 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
|
2129 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2130 // 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
|
2131 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
|
2132 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
|
2133 dgam -= P (1.0) / z_p; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2134 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2135 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2136 // 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
|
2137 // LogGamma |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2138 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2139 // 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
|
2140 // + 7/1680z^8 - 9/1188z^10 + ... |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2141 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2142 // (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
|
2143 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
|
2144 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2145 return dgam; |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2146 } |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2147 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2148 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2149 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
|
2150 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
|
2151 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2152 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2153 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
|
2154 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
|
2155 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2156 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2157 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
|
2158 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
|
2159 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
|
2160 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2161 F77_INT n = to_f77_int (n_arg); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2162 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
|
2163 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
|
2164 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
|
2165 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2166 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2167 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2168 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2169 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
|
2170 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
|
2171 float& ans, octave_idx_type& ierr) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2172 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2173 F77_INT n = to_f77_int (n_arg); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2174 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
|
2175 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
|
2176 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
|
2177 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2178 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2179 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2180 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2181 T |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2182 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
|
2183 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2184 T ans; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2185 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
|
2186 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
|
2187 if (ierr == 0) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2188 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2189 // 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
|
2190 // 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
|
2191 // 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
|
2192 if (n > 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2193 // 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
|
2194 // way too fast. |
23639 | 2195 ans = ans / (std::pow (-1.0, n + 1) / gamma (double (n+1))); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2196 else if (n == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2197 ans = -ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2198 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2199 else if (ierr == 2) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2200 ans = - numeric_limits<T>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2201 else // we probably never get here |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2202 ans = numeric_limits<T>::NaN (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2203 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2204 return ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2205 } |
21786
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 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
|
2208 float psi (octave_idx_type n, float z) { return xpsi (n, z); } |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2209 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2210 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2211 rc_lgamma (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2212 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2213 double result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2214 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2215 #if defined (HAVE_LGAMMA_R) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2216 int sgngam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2217 result = lgamma_r (x, &sgngam); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2218 #else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2219 result = std::lgamma (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2220 int sgngam = signgam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2221 #endif |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2222 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2223 if (sgngam < 0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2224 return result + Complex (0., M_PI); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2225 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2226 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2227 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2228 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2229 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2230 rc_lgamma (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2231 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2232 float result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2233 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2234 #if defined (HAVE_LGAMMAF_R) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2235 int sgngam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2236 result = lgammaf_r (x, &sgngam); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2237 #else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2238 result = std::lgammaf (x); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2239 int sgngam = signgam; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2240 #endif |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2241 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2242 if (sgngam < 0) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2243 return result + FloatComplex (0., M_PI); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2244 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2245 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2246 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2247 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2248 Complex rc_log1p (double x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2249 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2250 return (x < -1.0 |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23726
diff
changeset
|
2251 ? Complex (std::log (-(1.0 + x)), M_PI) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2252 : Complex (log1p (x))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2253 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2254 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2255 FloatComplex rc_log1p (float x) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2256 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2257 return (x < -1.0f |
23761
102049c83e7c
Use constexpr rather than just const to provide hint to compiler.
Rik <rik@octave.org>
parents:
23726
diff
changeset
|
2258 ? FloatComplex (std::log (-(1.0f + x)), M_PI) |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2259 : FloatComplex (log1p (x))); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2260 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2261 } |
20161
65e22ba879f0
psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents:
20156
diff
changeset
|
2262 } |