Mercurial > octave
annotate liboctave/numeric/lo-specfun.cc @ 30942:84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Co-author: Zoïs Moitier <zois.moitier@kit.edu>
lo-specfun.cc: The external Fortran library functions ZAIRY, CAIRY, ZBIRY, and
CBIRY can already scale or unscale their respective results depending on
whether an input parameter KODE is set to 1 or to 2. This changeset removes
the duplication of that scaling functionality in lo-specfun.cc, and calls the
library functions with the appropriate value of KODE.
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Mon, 18 Apr 2022 09:32:12 -0400 |
parents | d041ca628d99 |
children | 1f7fcac1fac9 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30394
diff
changeset
|
3 // Copyright (C) 1996-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
3146 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21723
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21231
diff
changeset
|
27 # include "config.h" |
3146 | 28 #endif |
29 | |
23623
4feed155a1f2
Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
30 #include <cmath> |
4feed155a1f2
Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents:
23564
diff
changeset
|
31 |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
32 #include <algorithm> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
33 #include <limits> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
34 #include <string> |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
35 |
3220 | 36 #include "CColVector.h" |
37 #include "CMatrix.h" | |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
38 #include "CNDArray.h" |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
39 #include "Faddeeva.hh" |
3146 | 40 #include "dMatrix.h" |
4844 | 41 #include "dNDArray.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
42 #include "dRowVector.h" |
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
43 #include "f77-fcn.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
44 #include "fCColVector.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
45 #include "fCMatrix.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
46 #include "fCNDArray.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
47 #include "fMatrix.h" |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
48 #include "fNDArray.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
49 #include "fRowVector.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
50 #include "lo-amos-proto.h" |
3146 | 51 #include "lo-error.h" |
3220 | 52 #include "lo-ieee.h" |
23475
d691ed308237
maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents:
23463
diff
changeset
|
53 #include "lo-mappers.h" |
22322
93b3cdd36854
move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
54 #include "lo-slatec-proto.h" |
3220 | 55 #include "lo-specfun.h" |
3146 | 56 #include "mx-inlines.cc" |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15271
diff
changeset
|
57 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
58 namespace octave |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
59 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
60 namespace math |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
61 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
62 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
63 bessel_return_value (const Complex& val, octave_idx_type ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
64 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
65 static const Complex inf_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
66 = Complex (numeric_limits<double>::Inf (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
67 numeric_limits<double>::Inf ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
68 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
69 static const Complex nan_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
70 = Complex (numeric_limits<double>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
71 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
72 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
73 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
74 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
75 switch (ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
76 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
77 case 0: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
78 case 3: |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
79 case 4: |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
80 retval = val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
81 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
82 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
83 case 2: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
84 retval = inf_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
85 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
86 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
87 default: |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
88 retval = nan_val; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
89 break; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
90 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
91 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
92 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
93 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
94 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
95 static inline FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
96 bessel_return_value (const FloatComplex& val, octave_idx_type ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
97 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
98 static const FloatComplex inf_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
99 = FloatComplex (numeric_limits<float>::Inf (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
100 numeric_limits<float>::Inf ()); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
101 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
102 static const FloatComplex nan_val |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
103 = FloatComplex (numeric_limits<float>::NaN (), |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
104 numeric_limits<float>::NaN ()); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
105 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
106 FloatComplex retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
107 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
108 switch (ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
109 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
110 case 0: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
111 case 3: |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
112 case 4: |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
113 retval = val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
114 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
115 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
116 case 2: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
117 retval = inf_val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
118 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
119 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
120 default: |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
121 retval = nan_val; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
122 break; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
123 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
124 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
125 return retval; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
126 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
127 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
128 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
129 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
130 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
131 airy (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr) |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
132 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
133 double ar = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
134 double ai = 0.0; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
135 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
136 double zr = z.real (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
137 double zi = z.imag (); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
138 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
139 F77_INT id = (deriv ? 1 : 0); |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
140 F77_INT nz, t_ierr; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
141 |
30942
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
142 if (scaled) |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
143 F77_FUNC (zairy, ZAIRY) (zr, zi, id, 2, ar, ai, nz, t_ierr); |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
144 else |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
145 F77_FUNC (zairy, ZAIRY) (zr, zi, id, 1, ar, ai, nz, t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
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 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
|
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 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
|
150 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
|
151 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
152 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
155 ComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
156 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
|
157 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
|
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 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
|
160 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
|
161 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
162 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
|
163 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
164 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
|
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 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
|
167 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
168 retval(i, j) = airy (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
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 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
|
171 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
172 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
173 ComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
174 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
|
175 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
|
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 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
|
178 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
|
179 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
|
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 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
|
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 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
|
184 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
|
185 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
186 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
189 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
190 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
|
191 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
|
192 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
193 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
|
194 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
195 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
|
196 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
|
197 |
30942
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
198 if (scaled) |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
199 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, 2, |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
200 F77_CMPLX_ARG (&a), nz, t_ierr); |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
201 else |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
202 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, 1, |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
203 F77_CMPLX_ARG (&a), nz, t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
204 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
205 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
|
206 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
207 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
|
208 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
|
209 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
210 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
|
211 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
|
212 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
213 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
|
214 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
215 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
216 FloatComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
217 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
|
218 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
|
219 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
220 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
|
221 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
|
222 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
223 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
|
224 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
225 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
|
226 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
227 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
|
228 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
229 retval(i, j) = airy (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
230 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
231 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
234 FloatComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
235 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
|
236 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
|
237 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
238 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
|
239 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
|
240 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
|
241 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
242 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
|
243 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
244 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
|
245 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
|
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 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
|
248 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
249 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
250 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
251 is_integer_value (double x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
252 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
253 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
|
254 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
255 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
256 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
|
257 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
|
258 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
259 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
|
260 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
|
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 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
|
263 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
|
264 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
265 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
|
266 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
|
267 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
268 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
|
269 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
|
270 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
271 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
|
272 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
|
273 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
274 static inline Complex |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
275 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
|
276 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
277 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
278 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
279 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
280 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
281 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
282 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
283 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
284 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
285 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
286 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
287 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
288 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
289 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
|
290 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
291 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
292 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
293 if (zi == 0.0 && zr >= 0.0) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
294 yi = 0.0; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
295 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
296 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
297 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
298 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
299 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
300 // 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
|
301 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
302 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
|
303 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
304 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
305 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
306 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
307 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
308 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
309 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
310 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
311 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
|
312 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
313 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
314 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
315 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
|
316 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
317 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
318 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
319 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
320 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
|
321 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
322 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
323 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
324 return retval; |
3220 | 325 } |
21786
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 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
328 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
4911 | 329 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
330 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
331 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
332 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
333 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
334 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
335 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
336 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
337 F77_INT nz, t_ierr; |
21786
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 double wr, wi; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
340 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
341 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
342 double zi = z.imag (); |
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 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
345 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
346 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
|
347 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
348 yr = -numeric_limits<double>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
349 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
350 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
351 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
352 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
353 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
|
354 &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
|
355 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
356 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
357 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
358 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
|
359 yi = 0.0; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
362 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
|
363 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
364 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
|
365 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
366 // 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
|
367 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
368 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
|
369 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
|
370 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
371 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
372 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
373 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
374 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
375 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
376 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
377 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
|
378 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
379 if (ierr == 0 || ierr == 3) |
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 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
|
382 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
383 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
384 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
385 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
386 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
|
387 numeric_limits<double>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
388 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
389 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
390 return retval; |
4911 | 391 } |
21786
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 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
394 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 395 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
396 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
397 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
398 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
399 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
400 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
401 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
402 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
403 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
404 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
405 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
406 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
407 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
408 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
|
409 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
410 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
411 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
412 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
|
413 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
414 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
415 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
|
416 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
417 else if (is_integer_value (alpha)) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
418 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
419 // 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
|
420 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
421 Complex tmp = zbesi (z, alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
422 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
423 } |
3220 | 424 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
425 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
426 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
427 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
428 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
|
429 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
430 if (ierr == 0 || ierr == 3) |
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 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
|
433 * zbesk (z, alpha, kode, ierr); |
21786
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 if (kode == 2) |
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 // 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
|
438 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
|
439 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
440 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
441 tmp += tmp2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
442 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
443 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
444 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
445 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
446 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
|
447 numeric_limits<double>::NaN ()); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
448 } |
3146 | 449 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
450 return retval; |
3146 | 451 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
452 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
453 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
454 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 455 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
456 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
457 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
458 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
459 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
460 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
461 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
462 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
463 F77_INT nz, t_ierr; |
21786
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 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
466 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
467 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
468 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
469 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
470 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
|
471 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
472 yr = numeric_limits<double>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
473 yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
474 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
475 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
476 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
477 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
|
478 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
479 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
480 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
481 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
482 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
|
483 yi = 0.0; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
484 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11574
diff
changeset
|
485 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
486 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
|
487 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
488 else |
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 Complex tmp = zbesk (z, -alpha, kode, ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
491 |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
492 retval = bessel_return_value (tmp, ierr); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
493 } |
21786
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 return retval; |
3220 | 496 } |
497 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
498 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
499 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr) |
3220 | 500 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
501 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
502 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
503 if (alpha >= 0.0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
504 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
505 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
506 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
507 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
508 F77_INT nz, t_ierr; |
21786
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 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
511 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
512 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
513 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
|
514 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
515 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
516 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
517 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
518 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
519 } |
3220 | 520 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
521 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
522 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
523 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
524 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
|
525 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
526 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
|
527 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
528 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
529 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
530 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
531 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
532 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
533 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
534 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
535 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
|
536 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
537 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
538 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
539 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
540 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
541 double yr = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
542 double yi = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
543 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
544 F77_INT nz, t_ierr; |
21786
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 double zr = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
547 double zi = z.imag (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
548 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
549 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
|
550 t_ierr); |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
551 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
552 ierr = t_ierr; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
553 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
554 retval = bessel_return_value (Complex (yr, yi), ierr); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10258
diff
changeset
|
555 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
556 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
557 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
558 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
559 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
560 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
|
561 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
562 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
|
563 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
564 retval = bessel_return_value (tmp, ierr); |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
567 return retval; |
3220 | 568 } |
3146 | 569 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
570 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
|
571 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
572 static inline Complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
573 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
|
574 bool scaled, octave_idx_type& ierr) |
3220 | 575 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
576 Complex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
577 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
578 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
|
579 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
580 return retval; |
3220 | 581 } |
3146 | 582 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
583 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
584 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
|
585 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 586 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
587 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
588 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
589 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
590 ComplexMatrix retval (nr, nc); |
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 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
593 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
594 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
|
595 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
596 retval(i, j) = f (x(i, j), alpha, (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
597 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
598 return retval; |
3146 | 599 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
600 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
601 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
602 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
|
603 bool scaled, Array<octave_idx_type>& ierr) |
3220 | 604 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
605 octave_idx_type nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
606 octave_idx_type nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
607 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
608 ComplexMatrix retval (nr, nc); |
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 ierr.resize (dim_vector (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 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
|
613 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
614 retval(i, j) = f (x, alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
615 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
616 return retval; |
3220 | 617 } |
618 | |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
619 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
620 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
|
621 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
|
622 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
623 ComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
624 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
625 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
|
626 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
|
627 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
628 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
|
629 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
|
630 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
631 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
|
632 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
633 ("%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
|
634 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
635 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
636 octave_idx_type nc = x_nc; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
637 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
638 retval.resize (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
639 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
640 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
641 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
642 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
|
643 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
644 retval(i, j) = f (x(i, j), alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
645 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
646 return retval; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
649 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
650 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
|
651 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
|
652 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
653 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
654 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
655 ComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
656 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
657 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
658 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
659 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
|
660 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
|
661 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
662 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
663 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
664 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
665 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
666 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
|
667 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
|
668 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
669 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
670 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
671 ComplexNDArray retval (dv); |
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 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
674 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
675 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
|
676 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
|
677 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
678 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
679 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
680 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
681 static inline ComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
682 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
|
683 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
|
684 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
685 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
686 ComplexNDArray retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
687 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
688 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
689 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
690 ("%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
|
691 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
692 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
693 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
694 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
695 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
696 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
697 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
|
698 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
|
699 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
700 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
701 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
702 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
703 static inline ComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
704 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
|
705 const ComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
706 Array<octave_idx_type>& ierr) |
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 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
709 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
710 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
711 ComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
712 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
713 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
714 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
715 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
|
716 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
717 retval(i, j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
718 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
719 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
720 } |
3146 | 721 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
722 #define SS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
723 Complex \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
724 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
|
725 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
726 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
|
727 } |
3220 | 728 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
729 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
730 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
731 name (double alpha, const ComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
732 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
733 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
734 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
|
735 } |
3220 | 736 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
737 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
738 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
739 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
|
740 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
741 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
742 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
|
743 } |
3220 | 744 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
745 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
746 ComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
747 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
|
748 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
749 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
750 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
|
751 } |
3220 | 752 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
753 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
754 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
755 name (double alpha, const ComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
756 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
757 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
758 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
|
759 } |
4844 | 760 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
761 #define NS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
762 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
763 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
|
764 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
765 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
766 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
|
767 } |
4844 | 768 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
769 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
770 ComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
771 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
|
772 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
773 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
774 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
|
775 } |
4844 | 776 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
777 #define RC_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
778 ComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
779 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
|
780 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
781 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
782 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
|
783 } |
3220 | 784 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
785 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
786 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
787 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
788 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
789 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
790 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
791 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
792 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
793 RC_BESSEL (name, fcn) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
794 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
795 ALL_BESSEL (besselj, zbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
796 ALL_BESSEL (bessely, zbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
797 ALL_BESSEL (besseli, zbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
798 ALL_BESSEL (besselk, zbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
799 ALL_BESSEL (besselh1, zbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
800 ALL_BESSEL (besselh2, zbesh2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
801 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
802 #undef ALL_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
803 #undef SS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
804 #undef SM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
805 #undef MS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
806 #undef MM_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
807 #undef SN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
808 #undef NS_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
809 #undef NN_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
810 #undef RC_BESSEL |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
811 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
812 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
813 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
|
814 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
815 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
816 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
|
817 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
818 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
819 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
|
820 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
821 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
822 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
|
823 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
824 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
825 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
|
826 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
827 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
828 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
|
829 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
830 static inline bool |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
831 is_integer_value (float x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
832 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
833 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
|
834 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
835 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
836 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
837 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
|
838 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
839 FloatComplex retval; |
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 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
842 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
843 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
844 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
845 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
846 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
847 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
|
848 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
|
849 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
850 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
851 |
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
|
852 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
|
853 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
854 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
855 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
856 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
857 else if (is_integer_value (alpha)) |
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 // 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
|
860 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
861 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
|
862 if ((static_cast<long> (alpha)) & 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
863 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
864 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
865 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
866 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
867 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
868 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
869 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
870 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
|
871 * cbesj (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
872 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
873 if (ierr == 0 || ierr == 3) |
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 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
|
876 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
877 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
878 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
879 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
880 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
881 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
|
882 numeric_limits<float>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
883 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
884 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
885 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
886 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
887 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
888 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
889 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
|
890 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
891 FloatComplex retval; |
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 (alpha >= 0.0) |
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 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
896 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
897 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
898 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
899 FloatComplex w; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
900 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
901 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
902 |
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
|
903 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
|
904 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
905 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
|
906 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
907 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
908 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
909 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
|
910 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
|
911 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
|
912 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
913 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
914 |
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
|
915 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
|
916 y = FloatComplex (y.real (), 0.0); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
917 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
918 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
919 return bessel_return_value (y, ierr); |
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 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
|
922 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
923 // 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
|
924 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
925 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
|
926 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
|
927 tmp = - tmp; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
928 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
929 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
930 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
931 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
932 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
933 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
934 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
|
935 * cbesy (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
936 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
937 if (ierr == 0 || ierr == 3) |
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 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
|
940 * cbesj (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
941 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
942 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
943 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
944 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
945 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
|
946 numeric_limits<float>::NaN ()); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
947 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
948 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
949 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
950 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
951 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
952 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
953 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
|
954 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
955 FloatComplex retval; |
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 (alpha >= 0.0) |
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 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
960 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
961 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
962 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
963 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
|
964 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
|
965 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
966 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
967 |
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
|
968 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
|
969 y = FloatComplex (y.real (), 0.0); |
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 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
972 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
973 else |
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 alpha = -alpha; |
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 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
|
978 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
979 if (ierr == 0 || ierr == 3) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
980 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
981 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
|
982 * sinf (static_cast<float> (M_PI) * alpha) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
983 * cbesk (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
984 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
985 if (kode == 2) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
986 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
987 // 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
|
988 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
|
989 } |
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 tmp += tmp2; |
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 retval = bessel_return_value (tmp, ierr); |
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 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
996 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
|
997 numeric_limits<float>::NaN ()); |
21786
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1000 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1001 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1002 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1003 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1004 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
|
1005 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1006 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1007 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1008 if (alpha >= 0.0) |
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 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1011 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1012 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1013 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1014 ierr = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1015 |
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
|
1016 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
|
1017 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1018 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
|
1019 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1020 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1021 { |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1022 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
|
1023 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
|
1024 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1025 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1026 |
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
|
1027 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
|
1028 y = FloatComplex (y.real (), 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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1031 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1032 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1033 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1034 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1035 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
|
1036 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1037 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1038 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1039 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1040 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1041 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1042 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1043 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1044 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
|
1045 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1046 FloatComplex retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1047 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1048 if (alpha >= 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 FloatComplex y = 0.0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1051 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1052 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1053 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1054 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
|
1055 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
|
1056 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1057 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1058 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1059 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1060 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1061 else |
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 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1064 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1065 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
|
1066 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1067 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
|
1068 * cbesh1 (z, alpha, kode, ierr); |
21786
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 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1071 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1072 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1073 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1074 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1075 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1076 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1077 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
|
1078 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1079 FloatComplex retval; |
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 if (alpha >= 0.0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1082 { |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1083 FloatComplex y = 0.0;; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1084 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1085 F77_INT nz, t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1086 |
24906
451f4f291f46
Modified Bessel functions to compute the output with any input
Michele Ginesi <michele.ginesi@gmail.com>
parents:
24904
diff
changeset
|
1087 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
|
1088 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
|
1089 |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1090 ierr = t_ierr; |
21786
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 retval = bessel_return_value (y, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1093 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1094 else |
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 alpha = -alpha; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1097 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1098 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
|
1099 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1100 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
|
1101 * cbesh2 (z, alpha, kode, ierr); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1102 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1103 retval = bessel_return_value (tmp, ierr); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1104 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1105 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1106 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1107 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1108 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1109 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
|
1110 octave_idx_type&); |
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 static inline FloatComplex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1113 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
|
1114 bool scaled, octave_idx_type& ierr) |
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 FloatComplex retval; |
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 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
|
1119 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1120 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1121 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1122 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1123 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1124 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
|
1125 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
|
1126 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1127 octave_idx_type nr = x.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1128 octave_idx_type nc = x.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1129 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1130 FloatComplexMatrix retval (nr, nc); |
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 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1133 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1134 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
|
1135 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1136 retval(i, j) = f (x(i, j), alpha, (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1137 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1138 return retval; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1141 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1142 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
|
1143 const FloatComplex& x, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1144 bool scaled, Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1145 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1146 octave_idx_type nr = alpha.rows (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1147 octave_idx_type nc = alpha.cols (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1148 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1149 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1150 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1151 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1152 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1153 for (octave_idx_type j = 0; j < nc; j++) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1154 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1155 retval(i, j) = f (x, alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1156 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1157 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1158 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1159 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1160 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1161 do_bessel (fptr f, const char *fn, const FloatMatrix& alpha, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1162 const FloatComplexMatrix& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1163 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1164 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1165 FloatComplexMatrix retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1166 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1167 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
|
1168 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
|
1169 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1170 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
|
1171 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
|
1172 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1173 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
|
1174 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1175 ("%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
|
1176 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1177 octave_idx_type nr = x_nr; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1178 octave_idx_type nc = x_nc; |
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 retval.resize (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1181 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1182 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1183 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1184 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
|
1185 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1186 retval(i, j) = f (x(i, j), alpha(i, j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1187 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1188 return retval; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1191 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1192 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
|
1193 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
|
1194 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1195 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1196 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1197 FloatComplexNDArray retval (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1198 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1199 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1200 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1201 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
|
1202 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
|
1203 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1204 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1205 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1206 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1207 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1208 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
|
1209 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
|
1210 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1211 dim_vector dv = alpha.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1212 octave_idx_type nel = dv.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1213 FloatComplexNDArray retval (dv); |
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 ierr.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1216 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1217 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
|
1218 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
|
1219 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1220 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1221 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1222 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1223 static inline FloatComplexNDArray |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1224 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
|
1225 const FloatComplexNDArray& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1226 Array<octave_idx_type>& ierr) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1227 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1228 dim_vector dv = x.dims (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1229 FloatComplexNDArray retval; |
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 if (dv != alpha.dims ()) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1232 (*current_liboctave_error_handler) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1233 ("%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
|
1234 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1235 octave_idx_type nel = dv.numel (); |
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 retval.resize (dv); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1238 ierr.resize (dv); |
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 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
|
1241 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
|
1242 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1243 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1244 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1245 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1246 static inline FloatComplexMatrix |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1247 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
|
1248 const FloatComplexColumnVector& x, bool scaled, |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1249 Array<octave_idx_type>& ierr) |
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 octave_idx_type nr = x.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1252 octave_idx_type nc = alpha.numel (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1253 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1254 FloatComplexMatrix retval (nr, nc); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1255 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1256 ierr.resize (dim_vector (nr, nc)); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1257 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1258 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
|
1259 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1260 retval(i, j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i, j)); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1261 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1262 return retval; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1263 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1264 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1265 #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
|
1266 FloatComplex \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1267 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
|
1268 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
|
1269 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1270 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
|
1271 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1272 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1273 #define SM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1274 FloatComplexMatrix \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1275 name (float alpha, const FloatComplexMatrix& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1276 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1277 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1278 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
|
1279 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1280 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1281 #define MS_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1282 FloatComplexMatrix \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1283 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
|
1284 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1285 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1286 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1287 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1288 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1289 #define MM_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1290 FloatComplexMatrix \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1291 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
|
1292 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1293 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1294 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1295 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1296 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1297 #define SN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1298 FloatComplexNDArray \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1299 name (float alpha, const FloatComplexNDArray& x, bool scaled, \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1300 Array<octave_idx_type>& ierr) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1301 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1302 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1303 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1304 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1305 #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
|
1306 FloatComplexNDArray \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1307 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
|
1308 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
|
1309 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1310 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1311 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1312 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1313 #define NN_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1314 FloatComplexNDArray \ |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1315 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
|
1316 bool scaled, Array<octave_idx_type>& ierr) \ |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1317 { \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1318 return do_bessel (fcn, #name, alpha, x, scaled, ierr); \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1319 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1320 |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1321 #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
|
1322 FloatComplexMatrix \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1323 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
|
1324 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
|
1325 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
|
1326 { \ |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
1327 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
|
1328 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1329 |
22197
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1330 #define ALL_BESSEL(name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1331 SS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1332 SM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1333 MS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1334 MM_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1335 SN_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1336 NS_BESSEL (name, fcn) \ |
e43d83253e28
refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents:
22135
diff
changeset
|
1337 NN_BESSEL (name, fcn) \ |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1338 RC_BESSEL (name, fcn) |
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 ALL_BESSEL (besselj, cbesj) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1341 ALL_BESSEL (bessely, cbesy) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1342 ALL_BESSEL (besseli, cbesi) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1343 ALL_BESSEL (besselk, cbesk) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1344 ALL_BESSEL (besselh1, cbesh1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1345 ALL_BESSEL (besselh2, cbesh2) |
3220 | 1346 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1347 #undef ALL_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1348 #undef SS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1349 #undef SM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1350 #undef MS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1351 #undef MM_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1352 #undef SN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1353 #undef NS_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1354 #undef NN_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1355 #undef RC_BESSEL |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
1356 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1357 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1358 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
|
1359 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1360 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
|
1361 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
|
1362 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1363 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
|
1364 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
|
1365 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1366 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
|
1367 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
|
1368 |
30942
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1369 if (scaled) |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1370 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, 2, ar, ai, t_ierr); |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1371 else |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1372 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, 1, ar, ai, t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1373 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1374 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
|
1375 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1376 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
|
1377 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
|
1378 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1379 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
|
1380 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1381 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1382 ComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1383 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
|
1384 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
|
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 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
|
1387 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
|
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 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
|
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.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
|
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 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
|
1394 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1395 retval(i, j) = biry (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
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 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
|
1398 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1399 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1400 ComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1401 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
|
1402 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
|
1403 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1404 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
|
1405 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
|
1406 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
|
1407 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1408 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
|
1409 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1410 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
|
1411 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
|
1412 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1413 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
|
1414 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1415 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1416 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1417 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
|
1418 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
|
1419 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1420 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
|
1421 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1422 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
|
1423 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
|
1424 |
30942
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1425 if (scaled) |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1426 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, 2, |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1427 F77_CMPLX_ARG (&a), t_ierr); |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1428 else |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1429 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, 1, |
84e7222b6b5c
lo-specfun.cc: Remove code duplication for airy and biry functions (bug #62321)
Arun Giridhar <arungiridhar@gmail.com>
parents:
30781
diff
changeset
|
1430 F77_CMPLX_ARG (&a), t_ierr); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1431 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1432 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
|
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 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
|
1435 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
|
1436 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1437 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
|
1438 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
|
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 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
|
1441 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1442 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1443 FloatComplexMatrix |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1444 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
|
1445 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
|
1446 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1447 octave_idx_type 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
|
1448 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
|
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 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
|
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 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
|
1453 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1454 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
|
1455 for (octave_idx_type i = 0; i < nr; i++) |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
1456 retval(i, j) = biry (z(i, j), deriv, scaled, ierr(i, j)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
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 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1461 FloatComplexNDArray |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1462 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
|
1463 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
|
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 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
|
1466 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
|
1467 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
|
1468 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1469 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
|
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 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
|
1472 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
|
1473 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1474 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
|
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 // 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
|
1478 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
|
1479 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
|
1480 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1481 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1482 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
|
1483 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1484 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
|
1485 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1486 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1487 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1488 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
|
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 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
|
1491 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
|
1492 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
|
1493 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
|
1494 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1495 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1496 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1497 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
|
1498 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1499 static const int Nmax = 16; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1500 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
|
1501 int n, Nn, ii; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1502 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1503 if (m < 0 || m > 1) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1504 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1505 (*current_liboctave_warning_with_id_handler) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1506 ("Octave:ellipj-invalid-m", |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
1507 "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
|
1508 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1509 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
|
1510 |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1511 return; |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1512 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1513 |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1514 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
|
1515 if (m < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1516 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1517 // 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
|
1518 si_u = sin (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1519 co_u = cos (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1520 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
|
1521 sn = si_u - t * co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1522 cn = co_u + t * si_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1523 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
|
1524 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1525 else if ((1 - m) < sqrt_eps) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1526 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1527 // 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
|
1528 m1 = 1 - m; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1529 si_u = sinh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1530 co_u = cosh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1531 ta_u = tanh (u); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1532 se_u = 1/co_u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1533 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
|
1534 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
|
1535 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
|
1536 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1537 else |
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 // Arithmetic-Geometric Mean (AGM) algorithm |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1540 // (Abramowitz and Stegun, Section 16.4) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1541 a[0] = 1; |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1542 b = std::sqrt (1 - m); |
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1543 c[0] = std::sqrt (m); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1544 for (n = 1; n < Nmax; ++n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1545 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1546 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
|
1547 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
|
1548 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
|
1549 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
|
1550 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1551 if (n >= Nmax - 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1552 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1553 err = 1; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1554 return; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1555 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1556 Nn = n; |
26442
3d1a335fb9ce
lo-specfun.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
1557 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
|
1558 phi = ii*a[Nn]*u; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1559 for (n = Nn; n > 0; --n) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1560 { |
23682
6fe13cd3543c
Clean up lo-mappers.h, lo-mappers.cc.
Rik <rik@octave.org>
parents:
23668
diff
changeset
|
1561 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
|
1562 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1563 sn = sin (phi); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1564 cn = cos (phi); |
23649
aabf6cd222ac
Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents:
23648
diff
changeset
|
1565 dn = std::sqrt (1 - m*sn*sn); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1566 } |
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1567 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1568 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1569 void |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1570 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
|
1571 double& err) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1572 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1573 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
|
1574 |
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
|
1575 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
|
1576 if (u.real () == 0) |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1577 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1578 // 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
|
1579 sn = Complex (0, ss1/cc1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1580 cn = 1/cc1; // cn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1581 dn = dd1/cc1; // dn.imag = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1582 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1583 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1584 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1585 // u is generic complex |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1586 double ss, cc, dd, ddd; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1587 |
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
|
1588 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
|
1589 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
|
1590 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
|
1591 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
|
1592 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
|
1593 } |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1594 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1595 |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1596 // 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
|
1597 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1598 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
|
1599 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1600 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
|
1601 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1602 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1603 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1604 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
|
1605 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1606 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
|
1607 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
|
1608 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
|
1609 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1610 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1611 // 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
|
1612 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1613 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
|
1614 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1615 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
|
1616 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1617 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1618 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1619 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
|
1620 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1621 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
|
1622 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
|
1623 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
|
1624 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1625 |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1626 // 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
|
1627 // 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
|
1628 // 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
|
1629 // explanation. |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1630 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1631 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
|
1632 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1633 // 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
|
1634 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
|
1635 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1636 -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
|
1637 -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
|
1638 -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
|
1639 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1640 static const double b[] = |
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 -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
|
1643 -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
|
1644 -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
|
1645 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1646 static const double c[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1647 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1648 -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
|
1649 -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
|
1650 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
|
1651 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1652 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
|
1653 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1654 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
|
1655 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
|
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 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
|
1659 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
|
1660 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
|
1661 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
|
1662 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1663 // 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
|
1664 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
|
1665 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1666 // 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
|
1667 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
|
1668 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
|
1669 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
|
1670 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
|
1671 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1672 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
|
1673 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1674 // 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
|
1675 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
|
1676 ? 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
|
1677 : 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
|
1678 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1679 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
|
1680 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1681 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
|
1682 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1683 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
|
1684 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1685 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
|
1686 y = -y; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1687 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1688 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
|
1689 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
|
1690 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
|
1691 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
|
1692 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1693 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
|
1694 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1695 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
|
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 // 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
|
1698 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
|
1699 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
|
1700 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1701 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1702 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
|
1703 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1704 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1705 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
|
1706 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1707 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
|
1708 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1709 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1710 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
|
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 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1715 // 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
|
1716 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
|
1717 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
|
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 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1720 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
|
1721 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1722 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
|
1723 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1724 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1725 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1726 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
|
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 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
|
1729 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
|
1730 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
|
1731 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
|
1732 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1733 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1734 // 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
|
1735 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
|
1736 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
|
1737 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1738 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1739 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
|
1740 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1741 return 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
|
1742 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1743 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1744 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1745 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
|
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 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
|
1748 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
|
1749 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
|
1750 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1751 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1752 // 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
|
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 // 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
|
1755 // |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1756 // 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
|
1757 // 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
|
1758 // 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
|
1759 // 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
|
1760 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1761 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
|
1762 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1763 // 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
|
1764 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
|
1765 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1766 -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
|
1767 -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
|
1768 -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
|
1769 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1770 static const double b[] = |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1771 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1772 -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
|
1773 -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
|
1774 -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
|
1775 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1776 static const double c[] = |
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 -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
|
1779 -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
|
1780 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
|
1781 }; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1782 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
|
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 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
|
1785 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1788 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
|
1789 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
|
1790 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
|
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 // 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
|
1793 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
|
1794 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1795 // 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
|
1796 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
|
1797 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
|
1798 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
|
1799 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
|
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 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
|
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 // 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
|
1804 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
|
1805 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
|
1806 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
|
1807 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
|
1808 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1809 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
|
1810 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
|
1811 else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1812 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
|
1813 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1814 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
|
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 // 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
|
1817 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
|
1818 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
|
1819 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1820 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1821 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
|
1822 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1823 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1824 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
|
1825 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1826 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1829 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
|
1830 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1831 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
|
1832 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1833 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1834 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1835 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
|
1836 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1837 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
|
1838 |
24199
2ac103974d00
Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents:
23761
diff
changeset
|
1839 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
|
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 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
|
1842 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
|
1843 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
|
1844 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
|
1845 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
|
1846 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1847 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1848 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
|
1849 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1850 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
|
1851 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1852 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1853 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1854 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
|
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 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
|
1857 |
24199
2ac103974d00
Remove extra space between scope operator '::' and function.
Rik <rik@octave.org>
parents:
23761
diff
changeset
|
1858 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
|
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 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
|
1861 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
|
1862 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
|
1863 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
|
1864 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
|
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 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1867 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
|
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 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1872 double |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1873 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
|
1874 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1875 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
|
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 // 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
|
1878 // 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
|
1879 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1880 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
|
1881 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
|
1882 ? -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
|
1883 : 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
|
1884 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
|
1885 || math::isinf (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1886 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
|
1887 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
|
1888 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
|
1889 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1890 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
|
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 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
|
1893 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1894 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1895 float |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1896 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
|
1897 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1898 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
|
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 // 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
|
1901 // 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
|
1902 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1903 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
|
1904 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
|
1905 ? -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
|
1906 : 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
|
1907 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
|
1908 || math::isinf (x)) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
1909 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
|
1910 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
|
1911 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
|
1912 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1913 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
|
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 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
|
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 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1918 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1919 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
|
1920 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1921 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
|
1922 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1923 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
|
1924 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1925 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
|
1926 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1927 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
|
1928 retval = Complex (log1p (u / (1+std::sqrt (u+1))), |
30781
d041ca628d99
log1p: Correct order of arguments for atan2 (bug #62094).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
1929 atan2 (i, 1 + r)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1930 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1931 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1932 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
|
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 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
|
1935 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1936 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1937 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1938 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
|
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 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
|
1941 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1942 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
|
1943 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1944 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
|
1945 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1946 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
|
1947 retval = FloatComplex (log1p (u / (1+std::sqrt (u+1))), |
30781
d041ca628d99
log1p: Correct order of arguments for atan2 (bug #62094).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
1948 atan2 (i, 1 + r)); |
23668
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1949 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1950 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1951 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
|
1952 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
1953 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
|
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 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1956 static const double pi = 3.14159265358979323846; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1957 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1958 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1959 static inline T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1960 xlog (const T& x) |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1961 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1962 return log (x); |
17502
578805a293e5
ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents:
15852
diff
changeset
|
1963 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1964 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1965 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1966 inline double |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1967 xlog (const double& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1968 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
1969 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1970 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1971 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1972 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1973 inline float |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1974 xlog (const float& x) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1975 { |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
1976 return std::log (x); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1977 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1978 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1979 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1980 static T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1981 lanczos_approximation_psi (const T zc) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1982 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1983 // 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
|
1984 // 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
|
1985 // 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
|
1986 // 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
|
1987 static const T dg_coeff[10] = |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1988 { |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1989 -0.83333333333333333e-1, 0.83333333333333333e-2, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1990 -0.39682539682539683e-2, 0.41666666666666667e-2, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1991 -0.75757575757575758e-2, 0.21092796092796093e-1, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1992 -0.83333333333333333e-1, 0.4432598039215686, |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1993 -0.3053954330270122e+1, 0.125318899521531e+2 |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
1994 }; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1995 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1996 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
|
1997 T overz2k = overz2; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1998 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
1999 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2000 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
|
2001 p += dg_coeff[k] * overz2k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2002 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
|
2003 return p; |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2006 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2007 T |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2008 xpsi (T z) |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2009 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
2010 static const double euler_mascheroni |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26442
diff
changeset
|
2011 = 0.577215664901532860606512090082402431042; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2012 |
23726
1147e5c912aa
Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
2013 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
|
2014 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2015 T p = 0; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2016 if (z <= 0) |
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 // limits - zeros of the gamma function |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2019 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
|
2020 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
|
2021 else |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2022 // 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
|
2023 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
|
2024 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2025 else if (is_int) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2026 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2027 // 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
|
2028 p = - euler_mascheroni; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2029 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
|
2030 p += 1.0 / k; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2031 } |
23726
1147e5c912aa
Remove unnecessary octave::math::(ceil,trunc,floor) declarations.
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
2032 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
|
2033 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2034 // 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
|
2035 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
|
2036 p += 1.0 / (2 * k - 1); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2037 |
21942
aab79a1885cc
limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents:
21786
diff
changeset
|
2038 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
|
2039 } |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2040 else |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2041 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2042 // adapted from XLiFE++ gammaFunctions |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2043 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2044 T zc = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2045 // 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
|
2046 if (z < 10) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2047 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2048 const signed char n = 10 - z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2049 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
|
2050 p -= 1.0 / (k + z); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2051 zc += n; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2052 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2053 p += lanczos_approximation_psi (zc); |
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2056 return p; |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2057 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2058 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2059 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2060 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
|
2061 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
|
2062 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2063 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2064 std::complex<T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2065 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
|
2066 { |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2067 // adapted from XLiFE++ gammaFunctions |
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2068 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2069 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
|
2070 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2071 P z_r = z.real (); |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2072 P z_ra = z_r; |
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 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
|
2075 if (z.imag () == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2076 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
|
2077 else if (z_r < 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2078 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
|
2079 else |
20154
45565ecec019
New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents:
19739
diff
changeset
|
2080 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2081 // 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
|
2082 std::complex<T> z_m = z; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2083 if (z_ra < 8) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2084 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2085 unsigned char n = 8 - z_ra; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2086 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
|
2087 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2088 // 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
|
2089 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2090 // 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
|
2091 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
|
2092 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
|
2093 dgam -= P (1.0) / z_p; |
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 // 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
|
2097 // LogGamma |
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 // 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
|
2100 // + 7/1680z^8 - 9/1188z^10 + ... |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2101 // |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2102 // (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
|
2103 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
|
2104 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2105 return dgam; |
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 |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2108 // explicit instantiations |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2109 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
|
2110 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
|
2111 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2112 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2113 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
|
2114 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
|
2115 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2116 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2117 inline void |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2118 fortran_psifn<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
|
2119 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
|
2120 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2121 F77_INT n = to_f77_int (n_arg); |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2122 F77_INT flag = 0; |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2123 F77_INT t_ierr; |
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2124 F77_XFCN (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
|
2125 ierr = t_ierr; |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2126 } |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2127 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2128 template <> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2129 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
|
2130 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
|
2131 float& ans, octave_idx_type& ierr) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2132 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23682
diff
changeset
|
2133 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
|
2134 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
|
2135 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
|
2136 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
|
2137 ierr = t_ierr; |
21786
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 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2140 template <typename T> |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2141 T |
22954
6cd3e9acf443
* lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
2142 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
|
2143 { |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2144 T ans; |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2145 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
|
2146 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
|
2147 if (ierr == 0) |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2148 { |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2149 // 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
|
2150 // 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
|
2151 // 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
|
2152 if (n > 1) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2153 // 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
|
2154 // way too fast. |
23639 | 2155 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
|
2156 else if (n == 0) |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2157 ans = -ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2158 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2159 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
|
2160 ans = - numeric_limits<T>::Inf (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2161 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
|
2162 ans = numeric_limits<T>::NaN (); |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2163 |
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2164 return ans; |
20155
1fae49e34a1a
psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents:
20154
diff
changeset
|
2165 } |
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 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
|
2168 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
|
2169 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2170 Complex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2171 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
|
2172 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2173 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
|
2174 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2175 #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
|
2176 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
|
2177 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
|
2178 #else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2179 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
|
2180 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
|
2181 #endif |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2182 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2183 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
|
2184 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
|
2185 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2186 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
|
2187 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2188 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2189 FloatComplex |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2190 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
|
2191 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2192 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
|
2193 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2194 #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
|
2195 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
|
2196 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
|
2197 #else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2198 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
|
2199 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
|
2200 #endif |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2201 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2202 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
|
2203 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
|
2204 else |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2205 return result; |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2206 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2207 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2208 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
|
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 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
|
2211 ? 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
|
2212 : 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
|
2213 } |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2214 |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2215 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
|
2216 { |
a6eef0626b2b
Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents:
23662
diff
changeset
|
2217 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
|
2218 ? 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
|
2219 : 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
|
2220 } |
21786
df064166f180
use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents:
21782
diff
changeset
|
2221 } |
20161
65e22ba879f0
psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents:
20156
diff
changeset
|
2222 } |