annotate liboctave/numeric/lo-specfun.cc @ 23639:b488e958d024

Use modf, pow from C++ std library. These functions are guaranteed to be part of C++11 standard library. * configure.ac: Remove AC_CHECK_FUNCS for modf, pow. * data.cc, graphics.cc, graphics.in.h, lo-specfun.cc, mx-inlines.cc, oct-inttypes.cc: Delegate to std::modf or std::pow.
author Rik <rik@octave.org>
date Sun, 18 Jun 2017 18:09:53 -0700
parents 799833716c7b
children 18ae8d3c745b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
1 /*
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1996-2017 John W. Eaton
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
4 Copyright (C) 2007-2010 D. Martin
10391
59e34bcdff13 implement built-in erfcx
Jaroslav Hajek <highegg@gmail.com>
parents: 10352
diff changeset
5 Copyright (C) 2010 Jaroslav Hajek
10521
4d1fc073fbb7 add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents: 10414
diff changeset
6 Copyright (C) 2010 VZLU Prague
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22322
diff changeset
7 Copyright (C) 2016 Carnë Draug
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
8
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
9 This file is part of Octave.
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
10
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
11 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
13 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 (at your option) any later version.
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
19 GNU General Public License for more details.
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
20
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
21 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6969
diff changeset
22 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6969
diff changeset
23 <http://www.gnu.org/licenses/>.
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
24
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
25 */
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21723
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21231
diff changeset
28 # include "config.h"
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
29 #endif
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
30
23623
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
31 #include <cmath>
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
32
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
33 #include <algorithm>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
34 #include <limits>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
35 #include <string>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
36
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
37 #include "CColVector.h"
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
38 #include "CMatrix.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
39 #include "CNDArray.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
40 #include "Faddeeva.hh"
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
41 #include "dMatrix.h"
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
42 #include "dNDArray.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
43 #include "dRowVector.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
44 #include "f77-fcn.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
45 #include "fCColVector.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
46 #include "fCMatrix.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
47 #include "fCNDArray.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
48 #include "fMatrix.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
49 #include "fNDArray.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
50 #include "fRowVector.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
51 #include "lo-amos-proto.h"
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
52 #include "lo-error.h"
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
53 #include "lo-ieee.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
54 #include "lo-mappers.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23463
diff changeset
55 #include "lo-math.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
56 #include "lo-slatec-proto.h"
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
57 #include "lo-specfun.h"
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
58 #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
59
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
60 namespace octave
21231
5f318c8ec634 eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
61 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
62 namespace math
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
63 {
23623
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
64 double acosh (double x) { return std::acosh (x); }
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
65
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
66 float acosh (float x) { return std::acoshf (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
67
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
68 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
69 acosh (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
70 {
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
71 #if defined (HAVE_COMPLEX_STD_ACOSH)
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
72 return std::acosh (x);
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
73 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
74 return log (x + sqrt (x + 1.0) * sqrt (x - 1.0));
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
75 #endif
21786
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
78 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
79 acosh (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
80 {
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
81 #if defined (HAVE_COMPLEX_STD_ACOSH)
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
82 return std::acosh (x);
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
83 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
84 return log (x + sqrt (x + 1.0f) * sqrt (x - 1.0f));
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
85 #endif
21786
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
23623
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
88 double asinh (double x) { return std::asinh (x); }
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
89
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
90 float asinh (float x) { return std::asinhf (x); }
21786
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 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
93 asinh (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
94 {
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
95 #if defined (HAVE_COMPLEX_STD_ASINH)
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
96 return std::asinh (x);
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
97 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
98 return log (x + sqrt (x*x + 1.0));
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
99 #endif
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
100 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
101
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
102 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
103 asinh (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
104 {
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
105 #if defined (HAVE_COMPLEX_STD_ASINH)
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
106 return std::asinh (x);
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
107 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
108 return log (x + sqrt (x*x + 1.0f));
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
109 #endif
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
110 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
111
23623
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
112 double atanh (double x) { return std::atanh (x); }
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
113
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
114 float atanh (float x) { return std::atanhf (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
115
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
116 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
117 atanh (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
118 {
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
119 #if defined (HAVE_COMPLEX_STD_ATANH)
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
120 return std::atanh (x);
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
121 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
122 return log ((1.0 + x) / (1.0 - x)) / 2.0;
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
123 #endif
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
124 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
125
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
126 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
127 atanh (const FloatComplex& x)
17708
f10b7a578e2c Correct return values of gamma() (see Numerical, item 3 on Projects page).
Craig Hudson <c_hudson_phd@hotmail.com>
parents: 17502
diff changeset
128 {
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
129 #if defined (HAVE_COMPLEX_STD_ATANH)
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
130 return std::atanh (x);
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
131 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
132 return log ((1.0f + x) / (1.0f - x)) / 2.0f;
21945
e9765b62d4e8 Use C++11 standard complex trig functions when available (bug #44310, bug #45507)
Mike Miller <mtmiller@octave.org>
parents: 21942
diff changeset
133 #endif
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
134 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
135
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
136 double erf (double x) { return std::erf (x); }
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
137
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
138 float erf (float x) { return std::erff (x); }
6969
0a64abe792f4 [project @ 2007-10-06 14:15:19 by jwe]
jwe
parents: 6961
diff changeset
139
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
140 // Complex error function from the Faddeeva package
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
141 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
142 erf (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
143 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
144 return Faddeeva::erf (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
145 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
146
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
147 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
148 erf (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
149 {
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
150 Complex xd (x.real (), x.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
151 Complex ret = Faddeeva::erf (xd, std::numeric_limits<float>::epsilon ());
22274
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
152 return FloatComplex (ret.real (), ret.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
153 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
154
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
155 double erfc (double x) { return std::erfc (x); }
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
156
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
157 float erfc (float x) { return std::erfcf (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
158
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
159 // Complex complementary error function from the Faddeeva package
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
160 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
161 erfc (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
162 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
163 return Faddeeva::erfc (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
164 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
165
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
166 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
167 erfc (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
168 {
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
169 Complex xd (x.real (), x.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
170 Complex ret = Faddeeva::erfc (xd, std::numeric_limits<float>::epsilon ());
22274
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
171 return FloatComplex (ret.real (), ret.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
172 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
173
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
174 // Real and complex scaled complementary error function from Faddeeva pkg.
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
175 float erfcx (float x) { return Faddeeva::erfcx(x); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
176 double erfcx (double x) { return Faddeeva::erfcx(x); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
177
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
178 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
179 erfcx (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
180 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
181 return Faddeeva::erfcx (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
182 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
183
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
184 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
185 erfcx (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
186 {
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
187 Complex xd (x.real (), x.imag ());
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
188 Complex ret;
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
189 ret = Faddeeva::erfcx (xd, std::numeric_limits<float>::epsilon ());
22274
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
190 return FloatComplex (ret.real (), ret.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
191 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
192
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
193 // Real and complex imaginary error function from Faddeeva package
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
194 float erfi (float x) { return Faddeeva::erfi(x); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
195 double erfi (double x) { return Faddeeva::erfi(x); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
196
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
197 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
198 erfi (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
199 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
200 return Faddeeva::erfi (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
201 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
202
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
203 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
204 erfi (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
205 {
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
206 Complex xd (x.real (), x.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
207 Complex ret = Faddeeva::erfi (xd, std::numeric_limits<float>::epsilon ());
22274
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
208 return FloatComplex (ret.real (), ret.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
209 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
210
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
211 // Real and complex Dawson function (= scaled erfi) from Faddeeva package
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
212 float dawson (float x) { return Faddeeva::Dawson(x); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
213 double dawson (double x) { return Faddeeva::Dawson(x); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
214
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
215 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
216 dawson (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
217 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
218 return Faddeeva::Dawson (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
219 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
220
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
221 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
222 dawson (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
223 {
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
224 Complex xd (x.real (), x.imag ());
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
225 Complex ret;
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
226 ret = Faddeeva::Dawson (xd, std::numeric_limits<float>::epsilon ());
22274
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
227 return FloatComplex (ret.real (), ret.imag ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
228 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
229
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
230 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
231 gamma (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
232 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
233 double result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
234
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
235 // Special cases for (near) compatibility with Matlab instead of
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
236 // tgamma. Matlab does not have -0.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
237
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
238 if (x == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
239 result = (octave::math::negative_sign (x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
240 ? -octave::numeric_limits<double>::Inf ()
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
241 : octave::numeric_limits<double>::Inf ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
242 else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
243 result = octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
244 else if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
245 result = octave::numeric_limits<double>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
246 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
247 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
248 #if defined (HAVE_TGAMMA)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
249 result = tgamma (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
250 #else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
251 F77_XFCN (xdgamma, XDGAMMA, (x, result));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
252 #endif
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
253 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
254
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
255 return result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
256 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
257
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
258 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
259 lgamma (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
260 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
261 #if defined (HAVE_LGAMMA)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
262 return ::lgamma (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
263 #else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
264 double result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
265 double sgngam;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
266
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
267 if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
268 result = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
269 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
270 result = octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
271 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
272 F77_XFCN (dlgams, DLGAMS, (x, result, sgngam));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
273
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
274 return result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
275 #endif
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
278 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
279 rc_lgamma (double x)
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 result;
7601
8a939b217863 Treat negative values to lgamma and beta correctly
David Bateman <dbateman@free.fr>
parents: 7176
diff changeset
282
8a939b217863 Treat negative values to lgamma and beta correctly
David Bateman <dbateman@free.fr>
parents: 7176
diff changeset
283 #if defined (HAVE_LGAMMA_R)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
284 int sgngam;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
285 result = lgamma_r (x, &sgngam);
23463
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
286 #elif defined (HAVE_LGAMMA)
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
287 result = lgamma (x);
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
288 int sgngam = signgam;
11327
ef0e995f8c0f correctly compute gamma for negative integer values when tgamma is available
Marco Atzeri <marco_atzeri@yahoo.it>
parents: 10902
diff changeset
289 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
290 double sgngam = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
291
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
292 if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
293 result = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
294 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
295 result = octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
296 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
297 F77_XFCN (dlgams, DLGAMS, (x, result, sgngam));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
298
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
299 #endif
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
300
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
301 if (sgngam < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
302 return result + Complex (0., M_PI);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
303 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
304 return result;
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
305 }
21786
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 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
308 gamma (float x)
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
309 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
310 float result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
311
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
312 // Special cases for (near) compatibility with Matlab instead of
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
313 // tgamma. Matlab does not have -0.
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 if (x == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
316 result = (octave::math::negative_sign (x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
317 ? -octave::numeric_limits<float>::Inf ()
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
318 : octave::numeric_limits<float>::Inf ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
319 else if ((x < 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
320 result = octave::numeric_limits<float>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
321 else if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
322 result = octave::numeric_limits<float>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
323 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
324 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
325 #if defined (HAVE_TGAMMA)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
326 result = tgammaf (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
327 #else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
328 F77_XFCN (xgamma, XGAMMA, (x, result));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
329 #endif
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
330 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
331
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
332 return result;
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
333 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
334
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
335 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
336 lgamma (float x)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
337 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
338 #if defined (HAVE_LGAMMAF)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
339 return lgammaf (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
340 #else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
341 float result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
342 float sgngam;
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 if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
345 result = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
346 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
347 result = octave::numeric_limits<float>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
348 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
349 F77_XFCN (algams, ALGAMS, (x, result, sgngam));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
350
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
351 return result;
21231
5f318c8ec634 eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
352 #endif
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
353 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
354
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
355 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
356 rc_lgamma (float x)
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 float result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
359
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
360 #if defined (HAVE_LGAMMAF_R)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
361 int sgngam;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
362 result = lgammaf_r (x, &sgngam);
23463
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
363 #elif defined (HAVE_LGAMMAF)
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
364 result = lgammaf (x);
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
365 int sgngam = signgam;
21231
5f318c8ec634 eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
366 #else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
367 float sgngam = 0.0f;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
368
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
369 if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
370 result = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
371 else if ((x <= 0 && octave::math::x_nint (x) == x) || octave::math::isinf (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
372 result = octave::numeric_limits<float>::Inf ();
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 F77_XFCN (algams, ALGAMS, (x, result, sgngam));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
375
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
376 #endif
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
377
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
378 if (sgngam < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
379 return result + FloatComplex (0., M_PI);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
380 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
381 return result;
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
382 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
383
23638
799833716c7b Use expm1, expm1f from C++ std library.
Rik <rik@octave.org>
parents: 23634
diff changeset
384 double expm1 (double x) { return std::expm1 (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
385
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
386 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
387 expm1 (const Complex& x)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
388 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
389 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
390
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
391 if (std:: abs (x) < 1)
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 double im = x.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
394 double u = expm1 (x.real ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
395 double v = sin (im/2);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
396 v = -2*v*v;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
397 retval = Complex (u*v + u + v, (u+1) * sin (im));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
398 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
399 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
400 retval = std::exp (x) - Complex (1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
401
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
402 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
403 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
404
23638
799833716c7b Use expm1, expm1f from C++ std library.
Rik <rik@octave.org>
parents: 23634
diff changeset
405 float expm1 (float x) { return std::expm1f (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
406
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
407 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
408 expm1 (const FloatComplex& x)
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
409 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
410 FloatComplex retval;
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 (std:: abs (x) < 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
413 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
414 float im = x.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
415 float u = expm1 (x.real ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
416 float v = sin (im/2);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
417 v = -2*v*v;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
418 retval = FloatComplex (u*v + u + v, (u+1) * sin (im));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
419 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
420 else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
421 retval = std::exp (x) - FloatComplex (1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
422
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
423 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
424 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
425
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
426 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
427 log1p (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
428 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
429 #if defined (HAVE_LOG1P)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
430 return ::log1p (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
431 #else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
432 double retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
433
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
434 double ax = fabs (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
435
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
436 if (ax < 0.2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
437 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
438 // approximation log (1+x) ~ 2*sum ((x/(2+x)).^ii ./ ii), ii = 1:2:2n+1
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
439 double u = x / (2 + x), t = 1, s = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
440 for (int i = 2; i < 12; i += 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
441 s += (t *= u*u) / (i+1);
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 = 2 * (s + 1) * u;
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
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
446 retval = std::log (1 + x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
447
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
448 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
449 #endif
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
450 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
451
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
452 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
453 log1p (const Complex& x)
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
454 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
455 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
456
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
457 double r = x.real (), i = x.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
458
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
459 if (fabs (r) < 0.5 && fabs (i) < 0.5)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
460 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
461 double u = 2*r + r*r + i*i;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
462 retval = Complex (log1p (u / (1+sqrt (u+1))),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
463 atan2 (1 + r, i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
464 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
465 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
466 retval = std::log (Complex (1) + x);
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 return retval;
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
23624
65e5ddf6d059 Use cbrt, cbrtf from C++ std library.
Rik <rik@octave.org>
parents: 23623
diff changeset
471 double cbrt (double x) { return std::cbrt (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
472
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
473 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
474 log1p (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
475 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
476 #if defined (HAVE_LOG1PF)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
477 return log1pf (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
478 #else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
479 float retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
480
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
481 float ax = fabs (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
482
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
483 if (ax < 0.2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
484 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
485 // approximation log (1+x) ~ 2*sum ((x/(2+x)).^ii ./ ii), ii = 1:2:2n+1
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
486 float u = x / (2 + x), t = 1.0f, s = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
487 for (int i = 2; i < 12; i += 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
488 s += (t *= u*u) / (i+1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
489
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
490 retval = 2 * (s + 1.0f) * u;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
491 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
492 else
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
493 retval = std::log (1.0f + x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
494
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
495 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
496 #endif
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
497 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
498
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
499 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
500 log1p (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
501 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
502 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
503
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
504 float r = x.real (), i = x.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
505
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
506 if (fabs (r) < 0.5 && fabs (i) < 0.5)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
507 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
508 float u = 2*r + r*r + i*i;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
509 retval = FloatComplex (log1p (u / (1+sqrt (u+1))),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
510 atan2 (1 + r, i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
511 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
512 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
513 retval = std::log (FloatComplex (1) + x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
514
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
515 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
516 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
517
23624
65e5ddf6d059 Use cbrt, cbrtf from C++ std library.
Rik <rik@octave.org>
parents: 23623
diff changeset
518 float cbrt (float x) { return std::cbrtf (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
519
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
520 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
521 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
522
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
523 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
524 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
525
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
526 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
527 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
528
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
529 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
530 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
531
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
532 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
533 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
534
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
535 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
536 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
537
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
538 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
539 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
540 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
541 static const Complex inf_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
542 = Complex (octave::numeric_limits<double>::Inf (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
543 octave::numeric_limits<double>::Inf ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
544
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
545 static const Complex nan_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
546 = Complex (octave::numeric_limits<double>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
547 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
548
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
549 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
550
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
551 switch (ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
552 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
553 case 0:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
554 case 3:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
555 retval = val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
556 break;
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 case 2:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
559 retval = inf_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
560 break;
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 default:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
563 retval = nan_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
564 break;
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;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
568 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
569
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
570 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
571 is_integer_value (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
572 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
573 return 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
574 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
575
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
576 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
577 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
578 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
579 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
580
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
581 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
582 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
583 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
584 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
585
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
586 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
587
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
588 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
589 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
590
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
591 F77_FUNC (zbesj, ZBESJ) (zr, zi, alpha, 2, 1, &yr, &yi, nz, t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
592
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
593 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
594
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
595 if (kode != 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
596 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
597 double expz = exp (std::abs (zi));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
598 yr *= expz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
599 yi *= expz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
600 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
601
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
602 if (zi == 0.0 && zr >= 0.0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
603 yi = 0.0;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
604
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
605 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
606 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
607 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
608 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
609 // 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
610 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
611 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
612 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
613 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
614 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
615 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
616 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
617 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
618 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
619
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
620 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
621
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
622 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
623 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
624 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
625
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
626 retval = bessel_return_value (tmp, ierr);
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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
629 retval = Complex (octave::numeric_limits<double>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
630 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
631 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
632
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
633 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
634 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
635
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
636 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
637 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
638 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
639 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
640
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
641 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
642 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
643 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
644 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
645
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
646 F77_INT nz, t_ierr;
21786
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 double wr, wi;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
649
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
650 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
651 double zi = z.imag ();
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 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
654
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
655 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
656 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
657 yr = -octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
658 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
659 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
660 else
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 F77_FUNC (zbesy, ZBESY) (zr, zi, alpha, 2, 1, &yr, &yi, nz,
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
663 &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
664
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
665 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
666
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
667 if (kode != 2)
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 double expz = exp (std::abs (zi));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
670 yr *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
671 yi *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
672 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
673
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
674 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
675 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
676 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
677
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
678 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
679 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
680 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
681 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
682 // 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
683 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
684 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
685 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
686 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
687 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
688 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
689 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
690 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
691 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
692
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
693 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
694
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
695 if (ierr == 0 || ierr == 3)
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 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
698
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
699 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
700 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
701 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
702 retval = Complex (octave::numeric_limits<double>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
703 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
704 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
705
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
706 return retval;
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
707 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
708
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
709 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
710 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
711 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
712 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
713
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
714 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
715 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
716 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
717 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
718
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
719 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
720
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
721 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
722 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
723
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
724 F77_FUNC (zbesi, ZBESI) (zr, zi, alpha, 2, 1, &yr, &yi, nz, t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
725
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
726 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
727
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
728 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
729 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
730 double expz = exp (std::abs (zr));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
731 yr *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
732 yi *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
733 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
734
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
735 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
736 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
737
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
738 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
739 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
740 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
741 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
742 // 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
743 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
744 Complex tmp = zbesi (z, alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
745 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
746 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
747 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
748 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
749 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
750
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
751 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
752
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
753 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
754 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
755 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
756 * zbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
757
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
758 if (kode == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
759 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
760 // 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
761 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
762 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
763
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
764 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
765
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
766 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
767 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
768 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
769 retval = Complex (octave::numeric_limits<double>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
770 octave::numeric_limits<double>::NaN ());
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
771 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
772
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
773 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
774 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
775
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
776 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
777 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
778 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
779 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
780
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
781 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
782 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
783 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
784 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
785
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
786 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
787
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
788 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
789 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
790
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
791 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
792
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
793 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
794 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
795 yr = octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
796 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
797 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
798 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
799 {
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
800 F77_FUNC (zbesk, ZBESK) (zr, zi, alpha, 2, 1, &yr, &yi, nz,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
801 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
802
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
803 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
804
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
805 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
806 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
807 Complex expz = exp (-z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
808
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
809 double rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
810 double iexpz = expz.imag ();
21786
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 double tmp = yr*rexpz - yi*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
813
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
814 yi = yr*iexpz + yi*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
815 yr = tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
816 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
817
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
818 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
819 yi = 0.0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
820 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
821
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
822 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
823 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
824 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
825 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
826 Complex tmp = zbesk (z, -alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
827
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
828 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
829 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
830
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
831 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
832 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
833
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
834 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
835 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
836 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
837 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
838
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
839 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
840 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
841 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
842 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
843
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
844 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
845
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
846 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
847 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
848
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
849 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, 2, 1, 1, &yr, &yi, nz,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
850 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
851
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
852 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
853
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
854 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
855 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
856 Complex expz = exp (Complex (0.0, 1.0) * z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
857
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
858 double rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
859 double iexpz = expz.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
860
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
861 double tmp = yr*rexpz - yi*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
862
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
863 yi = yr*iexpz + yi*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
864 yr = tmp;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
867 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
868 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
869 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
870 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
871 alpha = -alpha;
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 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
874
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
875 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
876
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
877 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
878 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
879
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
880 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
881 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
882
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
883 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
884 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
885 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
886 Complex retval;
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 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
889 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
890 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
891 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
892
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
893 F77_INT nz, t_ierr;
21786
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 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
896 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
897
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
898 F77_FUNC (zbesh, ZBESH) (zr, zi, alpha, 2, 2, 1, &yr, &yi, nz,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
899 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
900
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
901 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
902
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
903 if (kode != 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
904 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
905 Complex expz = exp (-Complex (0.0, 1.0) * z);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
906
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
907 double rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
908 double iexpz = expz.imag ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
909
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
910 double tmp = yr*rexpz - yi*iexpz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
911
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
912 yi = yr*iexpz + yi*rexpz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
913 yr = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
914 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
915
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
916 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
917 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
918 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
919 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
920 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
921
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
922 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
923
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
924 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
925
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
926 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
927 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
928
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
929 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
930 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
931
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
932 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
933
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
934 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
935 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
936 bool scaled, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
937 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
938 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
939
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
940 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
941
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
942 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
943 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
944
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
945 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
946 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
947 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
948 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
949 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
950 octave_idx_type nc = x.cols ();
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 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
953
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
954 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
955
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
956 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
957 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
958 retval(i,j) = f (x(i,j), alpha, (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
959
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
960 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
961 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
962
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
963 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
964 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
965 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
966 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
967 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
968 octave_idx_type nc = alpha.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
969
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
970 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
971
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
972 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
973
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
974 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
975 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
976 retval(i,j) = f (x, alpha(i,j), (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
977
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
978 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
979 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
980
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
981 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
982 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
983 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
984 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
985 ComplexMatrix retval;
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 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
988 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
989
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
990 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
991 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
992
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
993 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
994 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
995 ("%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
996
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
997 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
998 octave_idx_type nc = x_nc;
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 retval.resize (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1003
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1004 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
1005 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1006 retval(i,j) = f (x(i,j), alpha(i,j), (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1007
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1008 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1009 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1010
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1011 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1012 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
1013 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
1014 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1015 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1016 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1017 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1018
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1019 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1020
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1021 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
1022 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
1023
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1024 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1025 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1026
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1027 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1028 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
1029 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
1030 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1031 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1032 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1033 ComplexNDArray retval (dv);
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 ierr.resize (dv);
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 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
1038 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
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 ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1044 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
1045 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
1046 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1047 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1048 ComplexNDArray retval;
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 if (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1051 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1052 ("%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
1053
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1054 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1055
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1056 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1057 ierr.resize (dv);
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 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
1060 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
1061
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1062 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1063 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1064
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1065 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1066 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
1067 const ComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1068 Array<octave_idx_type>& ierr)
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 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1071 octave_idx_type nc = alpha.numel ();
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 ComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1076
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1077 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
1078 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1079 retval(i,j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1080
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1081 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1082 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
1083
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1084 #define SS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1085 Complex \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1086 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
1087 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1088 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
1089 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1090
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1091 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1092 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1093 name (double alpha, const ComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1094 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1095 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1096 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
1097 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1098
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1099 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1100 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1101 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
1102 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1103 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1104 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
1105 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1106
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1107 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1108 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1109 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
1110 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1111 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1112 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
1113 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1114
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1115 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1116 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1117 name (double alpha, const ComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1118 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1119 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1120 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
1121 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1122
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1123 #define NS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1124 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1125 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
1126 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1127 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1128 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
1129 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1130
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1131 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1132 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1133 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
1134 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1135 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1136 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
1137 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1138
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1139 #define RC_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1140 ComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1141 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
1142 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1143 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1144 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
1145 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1146
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1147 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1148 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1149 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1150 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1151 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1152 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1153 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1154 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1155 RC_BESSEL (name, fcn)
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 ALL_BESSEL (besselj, zbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1158 ALL_BESSEL (bessely, zbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1159 ALL_BESSEL (besseli, zbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1160 ALL_BESSEL (besselk, zbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1161 ALL_BESSEL (besselh1, zbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1162 ALL_BESSEL (besselh2, zbesh2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1163
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1164 #undef ALL_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1165 #undef SS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1166 #undef SM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1167 #undef MS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1168 #undef MM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1169 #undef SN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1170 #undef NS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1171 #undef NN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1172 #undef RC_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1173
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1174 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1175 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
1176
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1177 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1178 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
1179
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1180 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1181 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
1182
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1183 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1184 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
1185
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1186 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1187 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
1188
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1189 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1190 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
1191
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1192 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1193 bessel_return_value (const FloatComplex& val, octave_idx_type ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1194 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1195 static const FloatComplex inf_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1196 = FloatComplex (octave::numeric_limits<float>::Inf (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1197 octave::numeric_limits<float>::Inf ());
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 static const FloatComplex nan_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1200 = FloatComplex (octave::numeric_limits<float>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1201 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1202
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1203 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1204
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1205 switch (ierr)
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 case 0:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1208 case 3:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1209 retval = val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1210 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1211
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1212 case 2:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1213 retval = inf_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1214 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1215
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1216 default:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1217 retval = nan_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1218 break;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1221 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1224 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1225 is_integer_value (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1226 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1227 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
1228 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1229
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1230 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1231 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
1232 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1233 FloatComplex retval;
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 if (alpha >= 0.0)
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 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1238
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1239 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1240
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1241 F77_FUNC (cbesj, CBESJ) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 1,
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1242 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
1243
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1244 ierr = t_ierr;
21786
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 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1247 {
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
1248 float expz = exp (std::abs (z.imag ()));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1249 y *= expz;
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
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
1252 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
1253 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1254
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1255 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1256 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1257 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1258 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1259 // 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
1260 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1261 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
1262 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1263 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1264 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1265 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1266 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1267 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1268 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1269
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1270 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
1271 * cbesj (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1272
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1273 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1274 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1275 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
1276 * cbesy (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1277
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1278 retval = bessel_return_value (tmp, ierr);
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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1281 retval = FloatComplex (octave::numeric_limits<float>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1282 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1283 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1284
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1285 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1286 }
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 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1289 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
1290 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1291 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1292
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1293 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1294 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1295 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1296
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1297 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1298
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1299 FloatComplex w;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1300
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1301 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1302
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
1303 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
1304 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1305 y = FloatComplex (-octave::numeric_limits<float>::Inf (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1306 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1307 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1308 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1309 F77_FUNC (cbesy, CBESY) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 1,
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1310 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
1311 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
1312
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1313 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1314
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1315 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1316 {
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
1317 float expz = exp (std::abs (z.imag ()));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1318 y *= expz;
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
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
1321 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
1322 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1323 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1324
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1325 return bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1326 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1327 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
1328 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1329 // 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
1330 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1331 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
1332 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
1333 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1334 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1335 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1336 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1337 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1338 alpha = -alpha;
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 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
1341 * cbesy (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1342
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1343 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1344 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1345 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
1346 * cbesj (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1347
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1348 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1349 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1350 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1351 retval = FloatComplex (octave::numeric_limits<float>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1352 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1353 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1354
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1355 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1356 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1357
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1358 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1359 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
1360 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1361 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1362
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1363 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1364 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1365 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1366
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1367 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1368
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1369 F77_FUNC (cbesi, CBESI) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 1,
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1370 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
1371
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1372 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1373
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1374 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1375 {
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
1376 float expz = exp (std::abs (z.real ()));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1377 y *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1378 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1379
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
1380 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
1381 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1382
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1383 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1384 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1385 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1386 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1387 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1388
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1389 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
1390
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1391 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1392 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1393 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
1394 * sinf (static_cast<float> (M_PI) * alpha)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1395 * cbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1396
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1397 if (kode == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1398 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1399 // 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
1400 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
1401 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1402
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1403 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1404
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1405 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1406 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1407 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1408 retval = FloatComplex (octave::numeric_limits<float>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1409 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1410 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1411
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1412 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1413 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1414
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1415 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1416 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
1417 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1418 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1419
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1420 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1421 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1422 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1423
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1424 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1425
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1426 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1427
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
1428 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
1429 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1430 y = FloatComplex (octave::numeric_limits<float>::Inf (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1431 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1432 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1433 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1434 F77_FUNC (cbesk, CBESK) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 1,
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1435 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
1436
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1437 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1438
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1439 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1440 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1441 FloatComplex expz = exp (-z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1442
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
1443 float rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1444 float iexpz = expz.imag ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1445
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1446 float tmp_r = y.real () * rexpz - y.imag () * iexpz;
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1447 float tmp_i = y.real () * iexpz + y.imag () * rexpz;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1448
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1449 y = FloatComplex (tmp_r, tmp_i);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1450 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1451
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
1452 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
1453 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1454 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1455
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1456 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1457 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1458 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1459 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1460 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
1461
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1462 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1463 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1464
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1465 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1466 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1467
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1468 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1469 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
1470 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1471 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1472
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1473 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1474 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1475 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1476
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1477 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1478
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1479 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 1, 1,
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1480 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
1481
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1482 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1483
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1484 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1485 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1486 FloatComplex expz = exp (FloatComplex (0.0, 1.0) * z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1487
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
1488 float rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1489 float iexpz = expz.imag ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1490
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
1491 float tmp_r = y.real () * rexpz - y.imag () * iexpz;
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1492 float tmp_i = y.real () * iexpz + y.imag () * rexpz;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1493
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1494 y = FloatComplex (tmp_r, tmp_i);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1495 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1496
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1497 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1498 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1499 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1500 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1501 alpha = -alpha;
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 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
1504
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1505 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
1506 * cbesh1 (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1507
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1508 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1509 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1510
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1511 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1512 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1513
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1514 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1515 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
1516 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1517 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1518
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1519 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1520 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1521 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1522
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1523 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1524
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1525 F77_FUNC (cbesh, CBESH) (F77_CONST_CMPLX_ARG (&z), alpha, 2, 2, 1,
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1526 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
1527
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1528 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1529
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1530 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1531 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1532 FloatComplex expz = exp (-FloatComplex (0.0, 1.0) * z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1533
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
1534 float rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1535 float iexpz = expz.imag ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1536
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
1537 float tmp_r = y.real () * rexpz - y.imag () * iexpz;
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1538 float tmp_i = y.real () * iexpz + y.imag () * rexpz;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1539
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1540 y = FloatComplex (tmp_r, tmp_i);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1541 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1542
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1543 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1544 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1545 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1546 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1547 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1548
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1549 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
1550
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1551 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
1552 * cbesh2 (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1553
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1554 retval = bessel_return_value (tmp, ierr);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1557 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1558 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1559
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1560 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
1561 octave_idx_type&);
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 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1564 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
1565 bool scaled, octave_idx_type& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1566 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1567 FloatComplex retval;
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 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
1570
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1571 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1572 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1573
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1574 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1575 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
1576 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
1577 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1578 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1579 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1580
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1581 FloatComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
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 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
1586 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1587 retval(i,j) = f (x(i,j), alpha, (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1588
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1589 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1590 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1591
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1592 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1593 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
1594 const FloatComplex& x,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1595 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
1596 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1597 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1598 octave_idx_type nc = alpha.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1599
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1600 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1601
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1602 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1603
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1604 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
1605 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1606 retval(i,j) = f (x, alpha(i,j), (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1607
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1608 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1609 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1610
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1611 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1612 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
1613 const FloatComplexMatrix& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1614 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1615 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1616 FloatComplexMatrix retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1617
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1618 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
1619 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
1620
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1621 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
1622 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
1623
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1624 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
1625 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1626 ("%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
1627
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1628 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1629 octave_idx_type nc = x_nc;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1630
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1631 retval.resize (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1632
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1633 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1634
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1635 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
1636 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1637 retval(i,j) = f (x(i,j), alpha(i,j), (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1638
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1639 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1640 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1641
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1642 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1643 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
1644 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
1645 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1646 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1647 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1648 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1649
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1650 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1651
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1652 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
1653 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
1654
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1655 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1656 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1657
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1658 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1659 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
1660 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
1661 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1662 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1663 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1664 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1665
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1666 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1667
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1668 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
1669 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
1670
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1671 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1672 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1673
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1674 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1675 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
1676 const FloatComplexNDArray& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1677 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1678 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1679 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1680 FloatComplexNDArray retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1681
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1682 if (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1683 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1684 ("%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
1685
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1686 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1687
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1688 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1689 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1690
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1691 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
1692 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
1693
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1694 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1695 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1696
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1697 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1698 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
1699 const FloatComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1700 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1701 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1702 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1703 octave_idx_type nc = alpha.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1704
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1705 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1706
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1707 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1708
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1709 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
1710 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1711 retval(i,j) = f (x(i), alpha(j), (scaled ? 2 : 1), ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1712
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1713 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1714 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1715
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1716 #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
1717 FloatComplex \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1718 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
1719 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
1720 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1721 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
1722 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1723
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1724 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1725 FloatComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1726 name (float alpha, const FloatComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1727 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1728 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1729 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
1730 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1731
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1732 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1733 FloatComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1734 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
1735 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1736 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1737 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
1738 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1739
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1740 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1741 FloatComplexMatrix \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1742 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
1743 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1744 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1745 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
1746 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1747
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1748 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1749 FloatComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1750 name (float alpha, const FloatComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1751 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1752 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1753 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
1754 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1755
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1756 #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
1757 FloatComplexNDArray \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1758 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
1759 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
1760 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1761 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
1762 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1763
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1764 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1765 FloatComplexNDArray \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1766 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
1767 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1768 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1769 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
1770 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1771
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1772 #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
1773 FloatComplexMatrix \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1774 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
1775 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
1776 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
1777 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1778 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
1779 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1780
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1781 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1782 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1783 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1784 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1785 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1786 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1787 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1788 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1789 RC_BESSEL (name, fcn)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1790
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1791 ALL_BESSEL (besselj, cbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1792 ALL_BESSEL (bessely, cbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1793 ALL_BESSEL (besseli, cbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1794 ALL_BESSEL (besselk, cbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1795 ALL_BESSEL (besselh1, cbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1796 ALL_BESSEL (besselh2, cbesh2)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1797
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1798 #undef ALL_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1799 #undef SS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1800 #undef SM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1801 #undef MS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1802 #undef MM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1803 #undef SN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1804 #undef NS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1805 #undef NN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1806 #undef RC_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1807
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1808 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1809 airy (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1810 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1811 double ar = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1812 double ai = 0.0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1813
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1814 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1815 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1816
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1817 F77_INT id = (deriv ? 1 : 0);
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1818 F77_INT nz, t_ierr;
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1819
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1820 F77_FUNC (zairy, ZAIRY) (zr, zi, id, 2, ar, ai, nz, t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1821
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1822 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1823
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1824 if (! scaled)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1825 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1826 Complex expz = exp (- 2.0 / 3.0 * z * sqrt (z));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1827
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
1828 double rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1829 double iexpz = expz.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1830
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1831 double tmp = ar*rexpz - ai*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1832
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1833 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1834 ar = tmp;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1835 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1836
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1837 if (zi == 0.0 && (! scaled || zr >= 0.0))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1838 ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1839
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1840 return bessel_return_value (Complex (ar, ai), ierr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1841 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1842
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1843 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1844 biry (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1845 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1846 double ar = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1847 double ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1848
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1849 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1850 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1851
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1852 F77_INT id = (deriv ? 1 : 0);
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1853 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
1854
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1855 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, 2, ar, ai, t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1856
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1857 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1858
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1859 if (! scaled)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1860 {
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
1861 Complex expz = exp (std::abs (std::real (2.0 / 3.0 * z * sqrt (z))));
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1862
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
1863 double rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1864 double iexpz = expz.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1865
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1866 double tmp = ar*rexpz - ai*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1867
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1868 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1869 ar = tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1870 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1871
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1872 if (zi == 0.0 && (! scaled || zr >= 0.0))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1873 ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1874
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1875 return bessel_return_value (Complex (ar, ai), ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1876 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1877
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1878 ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1879 airy (const ComplexMatrix& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1880 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1881 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1882 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1883 octave_idx_type nc = z.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1884
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1885 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1886
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1887 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1888
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1889 for (octave_idx_type j = 0; j < nc; j++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1890 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1891 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1892
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1893 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1894 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1895
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1896 ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1897 biry (const ComplexMatrix& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1898 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1899 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1900 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1901 octave_idx_type nc = z.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1902
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1903 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1904
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1905 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1906
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1907 for (octave_idx_type j = 0; j < nc; j++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1908 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1909 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1910
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1911 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1912 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1913
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1914 ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1915 airy (const ComplexNDArray& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1916 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1917 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1918 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1919 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1920 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1921
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1922 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1923
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1924 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
1925 retval(i) = airy (z(i), deriv, scaled, ierr(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1926
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1927 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1928 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1929
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1930 ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1931 biry (const ComplexNDArray& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1932 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1933 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1934 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1935 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1936 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1937
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1938 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1939
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1940 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
1941 retval(i) = biry (z(i), deriv, scaled, ierr(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1942
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1943 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1944 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1945
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1946 FloatComplex
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1947 airy (const FloatComplex& z, bool deriv, bool scaled,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1948 octave_idx_type& ierr)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1949 {
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1950 FloatComplex a;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1951
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1952 F77_INT id = (deriv ? 1 : 0);
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1953 F77_INT nz, t_ierr;
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1955 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, 2,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1956 F77_CMPLX_ARG (&a), nz, t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1957
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1958 ierr = t_ierr;
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1959
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1960 float ar = a.real ();
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1961 float ai = a.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1962
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1963 if (! scaled)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1964 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1965 FloatComplex expz = exp (- 2.0f / 3.0f * z * sqrt (z));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1966
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
1967 float rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
1968 float iexpz = expz.imag ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1969
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1970 float tmp = ar*rexpz - ai*iexpz;
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 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1973 ar = tmp;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1974 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1975
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1976 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0))
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1977 ai = 0.0;
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 return bessel_return_value (FloatComplex (ar, ai), ierr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1980 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1981
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1982 FloatComplex
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1983 biry (const FloatComplex& z, bool deriv, bool scaled,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1984 octave_idx_type& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1985 {
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1986 FloatComplex a;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1987
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1988 F77_INT id = (deriv ? 1 : 0);
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1989 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
1990
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1991 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, 2,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1992 F77_CMPLX_ARG (&a), t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1993
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1994 ierr = t_ierr;
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1995
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1996 float ar = a.real ();
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1997 float ai = a.imag ();
21786
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 if (! scaled)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
2000 {
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2001 FloatComplex expz
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2002 = exp (std::abs (std::real (2.0f / 3.0f * z * sqrt (z))));
22274
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
2003
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
2004 float rexpz = expz.real ();
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22197
diff changeset
2005 float iexpz = expz.imag ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
2006
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2007 float tmp = ar*rexpz - ai*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2008
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2009 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2010 ar = tmp;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
2011 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2012
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
2013 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0))
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2014 ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2015
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2016 return bessel_return_value (FloatComplex (ar, ai), ierr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2017 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2018
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2019 FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2020 airy (const FloatComplexMatrix& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2021 Array<octave_idx_type>& ierr)
4506
3c82fc8f822c [project @ 2003-09-10 13:56:57 by jwe]
jwe
parents: 4497
diff changeset
2022 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2023 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2024 octave_idx_type nc = z.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2025
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2026 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2027
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2028 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2029
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2030 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
2031 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2032 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2033
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2034 return retval;
4506
3c82fc8f822c [project @ 2003-09-10 13:56:57 by jwe]
jwe
parents: 4497
diff changeset
2035 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
2036
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2037 FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2038 biry (const FloatComplexMatrix& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2039 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2040 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2041 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2042 octave_idx_type nc = z.cols ();
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 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2045
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2046 ierr.resize (dim_vector (nr, nc));
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 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
2049 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2050 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2051
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2052 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2053 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2054
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2055 FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2056 airy (const FloatComplexNDArray& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2057 Array<octave_idx_type>& ierr)
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 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2060 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2061 FloatComplexNDArray retval (dv);
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 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2064
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2065 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
2066 retval(i) = airy (z(i), deriv, scaled, ierr(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2067
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2068 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2069 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2070
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2071 FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2072 biry (const FloatComplexNDArray& z, bool deriv, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2073 Array<octave_idx_type>& ierr)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2074 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2075 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2076 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2077 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2078
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2079 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2080
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2081 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
2082 retval(i) = biry (z(i), deriv, scaled, ierr(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2083
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2084 return retval;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2085 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2086
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2087 OCTAVE_NORETURN static void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2088 err_betainc_nonconformant (const dim_vector& d1, const dim_vector& d2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2089 const dim_vector& d3)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2090 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2091 std::string d1_str = d1.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2092 std::string d2_str = d2.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2093 std::string d3_str = d3.str ();
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 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2096 ("betainc: nonconformant arguments (x is %s, a is %s, b is %s)",
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2097 d1_str.c_str (), d2_str.c_str (), d3_str.c_str ());
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2098 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2099
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2100 OCTAVE_NORETURN static void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2101 err_betaincinv_nonconformant (const dim_vector& d1, const dim_vector& d2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2102 const dim_vector& d3)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2103 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2104 std::string d1_str = d1.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2105 std::string d2_str = d2.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2106 std::string d3_str = d3.str ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2107
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2108 (*current_liboctave_error_handler)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2109 ("betaincinv: nonconformant arguments (x is %s, a is %s, b is %s)",
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2110 d1_str.c_str (), d2_str.c_str (), d3_str.c_str ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2111 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2112
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2113 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2114 betainc (double x, double a, double b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2115 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2116 double retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2117 F77_XFCN (xdbetai, XDBETAI, (x, a, b, retval));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2118 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2119 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2120
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2121 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2122 betainc (double x, double a, const Array<double>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2123 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2124 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2125 octave_idx_type nel = dv.numel ();
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 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2128
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2129 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2130
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2131 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
2132 *pretval++ = betainc (x, a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2133
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2134 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2135 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2136
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2137 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2138 betainc (double x, const Array<double>& a, double b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2139 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2140 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2141 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2142
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2143 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2144
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2145 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2146
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2147 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
2148 *pretval++ = betainc (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2149
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2150 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2151 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2152
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2153 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2154 betainc (double x, const Array<double>& a, const Array<double>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2155 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2156 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2157 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2158
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2159 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2160 err_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2161
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2162 octave_idx_type nel = dv.numel ();
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 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2165
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2166 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2167
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2168 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
2169 *pretval++ = betainc (x, a(i), b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2170
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2171 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2172 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2173
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2174 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2175 betainc (const Array<double>& x, double a, double b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2176 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2177 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2178 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2179
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2180 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2181
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2182 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2183
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2184 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
2185 *pretval++ = betainc (x(i), a, b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2186
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2187 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2188 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2189
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2190 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2191 betainc (const Array<double>& x, double a, const Array<double>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2192 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2193 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2194 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2195
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2196 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2197 err_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2198
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2199 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2200
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2201 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2202
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2203 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2204
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2205 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
2206 *pretval++ = betainc (x(i), a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2207
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2208 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2209 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2210
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2211 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2212 betainc (const Array<double>& x, const Array<double>& a, double b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2213 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2214 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2215 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2216
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2217 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2218 err_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2219
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2220 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2221
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2222 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2223
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2224 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2225
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2226 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
2227 *pretval++ = betainc (x(i), a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2228
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2229 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2230 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2231
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2232 Array<double>
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2233 betainc (const Array<double>& x, const Array<double>& a,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2234 const Array<double>& b)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2235 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2236 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2237 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2238
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2239 if (dv != a.dims () || dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2240 err_betainc_nonconformant (dv, a.dims (), b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2241
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2242 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2243
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2244 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2245
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2246 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2247
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2248 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
2249 *pretval++ = betainc (x(i), a(i), b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2250
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2251 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2252 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2253
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2254 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2255 betainc (float x, float a, float b)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21118
diff changeset
2256 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2257 float retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2258 F77_XFCN (xbetai, XBETAI, (x, a, b, retval));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2259 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2260 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2261
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2262 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2263 betainc (float x, float a, const Array<float>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2264 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2265 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2266 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2267
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2268 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2269
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2270 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2271
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2272 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
2273 *pretval++ = betainc (x, a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2274
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2275 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2276 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2277
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2278 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2279 betainc (float x, const Array<float>& a, float b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2280 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2281 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2282 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2283
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2284 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2285
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2286 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2287
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2288 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
2289 *pretval++ = betainc (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2290
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2291 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2292 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2293
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2294 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2295 betainc (float x, const Array<float>& a, const Array<float>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2296 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2297 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2298 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2299
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2300 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2301 err_betainc_nonconformant (dim_vector (0, 0), dv, b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2302
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2303 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2304
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2305 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2306
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2307 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2308
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2309 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
2310 *pretval++ = betainc (x, a(i), b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2311
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2312 return retval;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21118
diff changeset
2313 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2314
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2315 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2316 betainc (const Array<float>& x, float a, float b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2317 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2318 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2319 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2320
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2321 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2322
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2323 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2324
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2325 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
2326 *pretval++ = betainc (x(i), a, b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2327
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2328 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2329 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2330
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2331 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2332 betainc (const Array<float>& x, float a, const Array<float>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2333 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2334 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2335 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2336
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2337 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2338 err_betainc_nonconformant (dv, dim_vector (0, 0), b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2339
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2340 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2341
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2342 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2343
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2344 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2345
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2346 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
2347 *pretval++ = betainc (x(i), a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2348
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2349 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2350 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2351
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2352 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2353 betainc (const Array<float>& x, const Array<float>& a, float b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2354 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2355 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2356 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2357
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2358 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2359 err_betainc_nonconformant (dv, a.dims (), dim_vector (0, 0));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2360
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2361 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2362
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2363 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2364
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2365 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2366
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2367 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
2368 *pretval++ = betainc (x(i), a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2369
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2370 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2371 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2372
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2373 Array<float>
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2374 betainc (const Array<float>& x, const Array<float>& a,
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
2375 const Array<float>& b)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2376 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2377 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2378 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2379
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2380 if (dv != a.dims () || dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2381 err_betainc_nonconformant (dv, a.dims (), b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2382
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2383 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2384
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2385 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2386
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2387 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2388
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2389 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
2390 *pretval++ = betainc (x(i), a(i), b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2391
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2392 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2393 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2394
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2395 // FIXME: there is still room for improvement here...
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2396
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2397 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2398 gammainc (double x, double a, bool& err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2399 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2400 if (a < 0.0 || x < 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2401 (*current_liboctave_error_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
2402 ("gammainc: A and X must be non-negative");
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2403
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2404 err = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2405
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2406 double retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2407
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2408 F77_XFCN (xgammainc, XGAMMAINC, (a, x, retval));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2409
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2410 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2411 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2412
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2413 Matrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2414 gammainc (double x, const Matrix& a)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2415 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2416 octave_idx_type nr = a.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2417 octave_idx_type nc = a.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2418
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2419 Matrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2420
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2421 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2422
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2423 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
2424 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2425 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2426 retval(i,j) = gammainc (x, a(i,j), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2427
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2428 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2429 return Matrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2430 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2431
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2432 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2433 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2434
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2435 Matrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2436 gammainc (const Matrix& x, double a)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2437 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2438 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2439 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2440
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2441 Matrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2442
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2443 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2444
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2445 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
2446 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2447 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2448 retval(i,j) = gammainc (x(i,j), a, err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2449
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2450 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2451 return Matrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2452 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2453
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2454 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2455 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2456
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2457 Matrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2458 gammainc (const Matrix& x, const Matrix& a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2459 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2460 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2461 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2462
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2463 octave_idx_type a_nr = a.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2464 octave_idx_type a_nc = a.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2465
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2466 if (nr != a_nr || nc != a_nc)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2467 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2468 ("gammainc: nonconformant arguments (arg 1 is %dx%d, arg 2 is %dx%d)",
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2469 nr, nc, a_nr, a_nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2470
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2471 Matrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2472
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2473 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2474
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2475 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
2476 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2477 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2478 retval(i,j) = gammainc (x(i,j), a(i,j), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2479
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2480 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2481 return Matrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2482 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2483
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2484 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2485 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2486
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2487 NDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2488 gammainc (double x, const NDArray& a)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2489 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2490 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2491 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2492
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2493 NDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2494
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2495 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2496
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2497 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
2498 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2499 retval(i) = gammainc (x, a(i), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2500
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2501 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2502 return NDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2503 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2504
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2505 return retval;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2506 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2507
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2508 NDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2509 gammainc (const NDArray& x, double a)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21118
diff changeset
2510 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2511 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2512 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2513
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2514 NDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2515
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2516 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2517
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2518 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
2519 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2520 retval(i) = gammainc (x(i), a, err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2521
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2522 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2523 return NDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2524 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2525
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2526 return retval;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21118
diff changeset
2527 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2528
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2529 NDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2530 gammainc (const NDArray& x, const NDArray& a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2531 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2532 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2533 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2534
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2535 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2536 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2537 std::string x_str = dv.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2538 std::string a_str = a.dims ().str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2539
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2540 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2541 ("gammainc: nonconformant arguments (arg 1 is %s, arg 2 is %s)",
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2542 x_str.c_str (), a_str.c_str ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2543 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2544
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2545 NDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2546
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2547 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2548
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2549 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
2550 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2551 retval(i) = gammainc (x(i), a(i), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2552
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2553 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2554 return NDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2555 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2556
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2557 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2558 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2559
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2560 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2561 gammainc (float x, float a, bool& err)
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2562 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2563 if (a < 0.0 || x < 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2564 (*current_liboctave_error_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
2565 ("gammainc: A and X must be non-negative");
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2566
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2567 err = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2568
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2569 float retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2570
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2571 F77_XFCN (xsgammainc, XSGAMMAINC, (a, x, retval));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2572
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2573 return retval;
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2574 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2575
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2576 FloatMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2577 gammainc (float x, const FloatMatrix& a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2578 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2579 octave_idx_type nr = a.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2580 octave_idx_type nc = a.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2581
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2582 FloatMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2583
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2584 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2585
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2586 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
2587 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2588 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2589 retval(i,j) = gammainc (x, a(i,j), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2590
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2591 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2592 return FloatMatrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2593 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2594
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2595 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2596 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2597
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2598 FloatMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2599 gammainc (const FloatMatrix& x, float a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2600 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2601 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2602 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2603
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2604 FloatMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2605
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2606 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2607
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2608 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
2609 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2610 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2611 retval(i,j) = gammainc (x(i,j), a, err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2612
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2613 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2614 return FloatMatrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2615 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2616
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2617 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2618 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2619
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2620 FloatMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2621 gammainc (const FloatMatrix& x, const FloatMatrix& a)
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2622 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2623 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2624 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2625
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2626 octave_idx_type a_nr = a.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2627 octave_idx_type a_nc = a.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2628
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2629 if (nr != a_nr || nc != a_nc)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2630 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2631 ("gammainc: nonconformant arguments (arg 1 is %dx%d, arg 2 is %dx%d)",
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2632 nr, nc, a_nr, a_nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2633
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2634 FloatMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2635
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2636 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2637
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2638 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
2639 for (octave_idx_type i = 0; i < nr; i++)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2640 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2641 retval(i,j) = gammainc (x(i,j), a(i,j), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2642
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2643 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2644 return FloatMatrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2645 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2646
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2647 return retval;
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2648 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2649
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2650 FloatNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2651 gammainc (float x, const FloatNDArray& a)
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2652 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2653 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2654 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2655
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2656 FloatNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2657
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2658 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2659
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2660 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
2661 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2662 retval(i) = gammainc (x, a(i), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2663
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2664 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2665 return FloatNDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2666 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2667
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2668 return retval;
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2669 }
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2670
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2671 FloatNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2672 gammainc (const FloatNDArray& x, float a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2673 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2674 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2675 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2676
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2677 FloatNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2678
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2679 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2680
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2681 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
2682 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2683 retval(i) = gammainc (x(i), a, err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2684
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2685 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2686 return FloatNDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2687 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2688
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2689 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2690 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2691
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2692 FloatNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2693 gammainc (const FloatNDArray& x, const FloatNDArray& a)
14770
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
diff changeset
2694 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2695 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2696 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2697
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2698 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2699 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2700 std::string x_str = dv.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2701 std::string a_str = a.dims ().str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2702
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2703 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2704 ("gammainc: nonconformant arguments (arg 1 is %s, arg 2 is %s)",
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2705 x_str.c_str (), a_str.c_str ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2706 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2707
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2708 FloatNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2709
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2710 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2711
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2712 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
2713 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2714 retval(i) = gammainc (x(i), a(i), err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2715
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2716 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2717 return FloatNDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2718 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2719
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2720 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2721 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2722
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2723 Complex rc_log1p (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2724 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2725 const double pi = 3.14159265358979323846;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2726 return (x < -1.0
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2727 ? Complex (std::log (-(1.0 + x)), pi)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2728 : Complex (log1p (x)));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2729 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2730
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2731 FloatComplex rc_log1p (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2732 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2733 const float pi = 3.14159265358979323846f;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2734 return (x < -1.0f
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2735 ? FloatComplex (std::log (-(1.0f + x)), pi)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2736 : FloatComplex (log1p (x)));
14770
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
diff changeset
2737 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2738
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2739 // This algorithm is due to P. J. Acklam.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2740 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2741 // See http://home.online.no/~pjacklam/notes/invnorm/
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2742 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2743 // The rational approximation has relative accuracy 1.15e-9 in the whole
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2744 // region. For doubles, it is refined by a single step of Halley's 3rd
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2745 // order method. For single precision, the accuracy is already OK, so
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2746 // we skip it to get faster evaluation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2747
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2748 static double do_erfinv (double x, bool refine)
14770
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
diff changeset
2749 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2750 // Coefficients of rational approximation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2751 static const double a[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2752 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2753 -2.806989788730439e+01, 1.562324844726888e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2754 -1.951109208597547e+02, 9.783370457507161e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2755 -2.168328665628878e+01, 1.772453852905383e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2756 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2757 static const double b[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2758 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2759 -5.447609879822406e+01, 1.615858368580409e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2760 -1.556989798598866e+02, 6.680131188771972e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2761 -1.328068155288572e+01
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2762 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2763 static const double c[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2764 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2765 -5.504751339936943e-03, -2.279687217114118e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2766 -1.697592457770869e+00, -1.802933168781950e+00,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2767 3.093354679843505e+00, 2.077595676404383e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2768 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2769 static const double d[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2770 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2771 7.784695709041462e-03, 3.224671290700398e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2772 2.445134137142996e+00, 3.754408661907416e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2773 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2774
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2775 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2776 static const double pbreak = 0.95150;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2777 double ax = fabs (x), y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2778
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2779 // Select case.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2780 if (ax <= pbreak)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2781 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2782 // Middle region.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2783 const double q = 0.5 * x, r = q*q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2784 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2785 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2786 y = yn / yd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2787 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2788 else if (ax < 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2789 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2790 // Tail region.
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2791 const double q = sqrt (-2*std::log (0.5*(1-ax)));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2792 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5];
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2793 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2794 y = yn / yd * octave::math::signum (-x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2795 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2796 else if (ax == 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2797 return octave::numeric_limits<double>::Inf () * octave::math::signum (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2798 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2799 return octave::numeric_limits<double>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2800
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2801 if (refine)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2802 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2803 // One iteration of Halley's method gives full precision.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2804 double u = (erf (y) - x) * spi2 * exp (y*y);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2805 y -= u / (1 + y*u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2806 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2807
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2808 return y;
14770
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
diff changeset
2809 }
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
diff changeset
2810
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2811 double erfinv (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2812 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2813 return do_erfinv (x, true);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2814 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2815
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2816 float erfinv (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2817 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2818 return do_erfinv (x, false);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2819 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2820
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2821 // The algorthim for erfcinv is an adaptation of the erfinv algorithm
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2822 // above from P. J. Acklam. It has been modified to run over the
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2823 // different input domain of erfcinv. See the notes for erfinv for an
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2824 // explanation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2825
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2826 static double do_erfcinv (double x, bool refine)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2827 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2828 // Coefficients of rational approximation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2829 static const double a[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2830 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2831 -2.806989788730439e+01, 1.562324844726888e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2832 -1.951109208597547e+02, 9.783370457507161e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2833 -2.168328665628878e+01, 1.772453852905383e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2834 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2835 static const double b[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2836 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2837 -5.447609879822406e+01, 1.615858368580409e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2838 -1.556989798598866e+02, 6.680131188771972e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2839 -1.328068155288572e+01
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2840 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2841 static const double c[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2842 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2843 -5.504751339936943e-03, -2.279687217114118e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2844 -1.697592457770869e+00, -1.802933168781950e+00,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2845 3.093354679843505e+00, 2.077595676404383e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2846 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2847 static const double d[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2848 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2849 7.784695709041462e-03, 3.224671290700398e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2850 2.445134137142996e+00, 3.754408661907416e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2851 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2852
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2853 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2854 static const double pbreak_lo = 0.04850; // 1-pbreak
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2855 static const double pbreak_hi = 1.95150; // 1+pbreak
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2856 double y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2857
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2858 // Select case.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2859 if (x >= pbreak_lo && x <= pbreak_hi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2860 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2861 // Middle region.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2862 const double q = 0.5*(1-x), r = q*q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2863 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2864 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2865 y = yn / yd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2866 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2867 else if (x > 0.0 && x < 2.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2868 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2869 // Tail region.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2870 const double q = (x < 1
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2871 ? sqrt (-2*std::log (0.5*x))
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2872 : sqrt (-2*std::log (0.5*(2-x))));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2873
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2874 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5];
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2875
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2876 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2877
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2878 y = yn / yd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2879
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2880 if (x < pbreak_lo)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2881 y = -y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2882 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2883 else if (x == 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2884 return octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2885 else if (x == 2.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2886 return -octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2887 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2888 return octave::numeric_limits<double>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2889
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2890 if (refine)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2891 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2892 // One iteration of Halley's method gives full precision.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2893 double u = (erf (y) - (1-x)) * spi2 * exp (y*y);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2894 y -= u / (1 + y*u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2895 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2896
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2897 return y;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2898 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2899
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2900 double erfcinv (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2901 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2902 return do_erfcinv (x, true);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2903 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2904
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2905 float erfcinv (float x)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2906 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2907 return do_erfcinv (x, false);
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2908 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2909
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2910 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2911 // Incomplete Beta function ratio
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2912 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2913 // Algorithm based on the one by John Burkardt.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2914 // See http://people.sc.fsu.edu/~jburkardt/cpp_src/asa109/asa109.html
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2915 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2916 // The original code is distributed under the GNU LGPL v3 license.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2917 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2918 // Reference:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2919 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2920 // KL Majumder, GP Bhattacharjee,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2921 // Algorithm AS 63:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2922 // The incomplete Beta Integral,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2923 // Applied Statistics,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2924 // Volume 22, Number 3, 1973, pages 409-411.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2925 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2926 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2927 betain (double x, double p, double q, double beta, bool& err)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2928 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2929 double acu = 0.1E-14, ai, cx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2930 bool indx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2931 int ns;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2932 double pp, psq, qq, rx, temp, term, value, xx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2933
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2934 value = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2935 err = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2936
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2937 // Check the input arguments.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2938
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2939 if ((p <= 0.0 || q <= 0.0) || (x < 0.0 || 1.0 < x))
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2940 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2941 err = true;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2942 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2943 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2944
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2945 // Special cases.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2946
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2947 if (x == 0.0 || x == 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2948 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2949 return value;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2950 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2951
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2952 // Change tail if necessary and determine S.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2953
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2954 psq = p + q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2955 cx = 1.0 - x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2956
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2957 if (p < psq * x)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2958 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2959 xx = cx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2960 cx = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2961 pp = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2962 qq = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2963 indx = true;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2964 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2965 else
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2966 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2967 xx = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2968 pp = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2969 qq = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2970 indx = false;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2971 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2972
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2973 term = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2974 ai = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2975 value = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2976 ns = static_cast<int> (qq + cx * psq);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2977
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2978 // Use the Soper reduction formula.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2979
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2980 rx = xx / cx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2981 temp = qq - ai;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2982 if (ns == 0)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2983 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2984 rx = xx;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2985 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2986
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2987 for ( ; ; )
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2988 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2989 term *= temp * rx / (pp + ai);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2990 value += term;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2991 temp = fabs (term);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2992
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2993 if (temp <= acu && temp <= acu * value)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2994 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2995 value *= exp (pp * std::log (xx)
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2996 + (qq - 1.0) * std::log (cx) - beta) / pp;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2997
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2998 if (indx)
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2999 {
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3000 value = 1.0 - value;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3001 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3002 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3003 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3004
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3005 ai += 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3006 ns -= 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3007
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3008 if (0 <= ns)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3009 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3010 temp = qq - ai;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3011 if (ns == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3012 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3013 rx = xx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3014 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3015 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3016 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3017 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3018 temp = psq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3019 psq += 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3020 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3021 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3022
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3023 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3024 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3025
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3026 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3027 // Inverse of the incomplete Beta function
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3028 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3029 // Algorithm based on the one by John Burkardt.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3030 // See http://people.sc.fsu.edu/~jburkardt/cpp_src/asa109/asa109.html
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3031 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3032 // The original code is distributed under the GNU LGPL v3 license.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3033 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3034 // Reference:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3035 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3036 // GW Cran, KJ Martin, GE Thomas,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3037 // Remark AS R19 and Algorithm AS 109:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3038 // A Remark on Algorithms AS 63: The Incomplete Beta Integral
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3039 // and AS 64: Inverse of the Incomplete Beta Integeral,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3040 // Applied Statistics,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3041 // Volume 26, Number 1, 1977, pages 111-114.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3042 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3043 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3044 betaincinv (double y, double p, double q)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3045 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3046 double a, acu, adj, fpu, g, h;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3047 int iex;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3048 bool indx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3049 double pp, prev, qq, r, s, sae = -37.0, sq, t, tx, value, w, xin, ycur, yprev;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3050
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3051 double beta = lgamma (p) + lgamma (q) - lgamma (p + q);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3052 bool err = false;
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3053 fpu = std::pow (10.0, sae);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3054 value = y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3055
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3056 // Test for admissibility of parameters.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3057
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3058 if (p <= 0.0 || q <= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3059 (*current_liboctave_error_handler) ("betaincinv: wrong parameters");
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3060 if (y < 0.0 || 1.0 < y)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3061 (*current_liboctave_error_handler) ("betaincinv: wrong parameter Y");
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3062
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3063 if (y == 0.0 || y == 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3064 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3065
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3066 // Change tail if necessary.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3067
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3068 if (0.5 < y)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3069 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3070 a = 1.0 - y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3071 pp = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3072 qq = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3073 indx = true;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3074 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3075 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3076 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3077 a = y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3078 pp = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3079 qq = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3080 indx = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3081 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3082
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3083 // Calculate the initial approximation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3084
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3085 r = sqrt (- std::log (a * a));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3086
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3087 ycur = r - (2.30753 + 0.27061 * r) / (1.0 + (0.99229 + 0.04481 * r) * r);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3088
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3089 if (1.0 < pp && 1.0 < qq)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3090 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3091 r = (ycur * ycur - 3.0) / 6.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3092 s = 1.0 / (pp + pp - 1.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3093 t = 1.0 / (qq + qq - 1.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3094 h = 2.0 / (s + t);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3095 w = ycur * sqrt (h + r) / h - (t - s) * (r + 5.0 / 6.0 - 2.0 / (3.0 * h));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3096 value = pp / (pp + qq * exp (w + w));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3097 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3098 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3099 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3100 r = qq + qq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3101 t = 1.0 / (9.0 * qq);
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3102 t = r * std::pow (1.0 - t + ycur * sqrt (t), 3);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3103
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3104 if (t <= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3105 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3106 value = 1.0 - exp ((std::log ((1.0 - a) * qq) + beta) / qq);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3107 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3108 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3109 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3110 t = (4.0 * pp + r - 2.0) / t;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3111
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3112 if (t <= 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3113 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3114 value = exp ((std::log (a * pp) + beta) / pp);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3115 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3116 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3117 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3118 value = 1.0 - 2.0 / (t + 1.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3119 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3120 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3121 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3122
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3123 // Solve for X by a modified Newton-Raphson method,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3124 // using the function BETAIN.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3125
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3126 r = 1.0 - pp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3127 t = 1.0 - qq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3128 yprev = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3129 sq = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3130 prev = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3131
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3132 if (value < 0.0001)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3133 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3134 value = 0.0001;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3135 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3136
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3137 if (0.9999 < value)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3138 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3139 value = 0.9999;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3140 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3141
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3142 iex = std::max (- 5.0 / pp / pp - 1.0 / std::pow (a, 0.2) - 13.0, sae);
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3143
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3144 acu = std::pow (10.0, iex);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3145
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3146 for ( ; ; )
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3147 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3148 ycur = betain (value, pp, qq, beta, err);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3149
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3150 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3151 {
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3152 return value;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3153 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3154
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3155 xin = value;
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3156 ycur = (ycur - a) * exp (beta + r * std::log (xin)
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3157 + t * std::log (1.0 - xin));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3158
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3159 if (ycur * yprev <= 0.0)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3160 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3161 prev = std::max (sq, fpu);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3162 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3163
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3164 g = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3165
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3166 for ( ; ; )
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3167 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3168 for ( ; ; )
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3169 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3170 adj = g * ycur;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3171 sq = adj * adj;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3172
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3173 if (sq < prev)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3174 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3175 tx = value - adj;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3176
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3177 if (0.0 <= tx && tx <= 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3178 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3179 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3180 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3181 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3182 g /= 3.0;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3183 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3184
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3185 if (prev <= acu)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3186 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3187 if (indx)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3188 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3189 value = 1.0 - value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3190 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3191 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3192 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3193
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3194 if (ycur * ycur <= acu)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3195 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3196 if (indx)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3197 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3198 value = 1.0 - value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3199 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3200 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3201 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3202
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3203 if (tx != 0.0 && tx != 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3204 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3205 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3206 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3207
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3208 g /= 3.0;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3209 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3210
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3211 if (tx == value)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3212 {
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3213 break;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3214 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3215
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3216 value = tx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3217 yprev = ycur;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3218 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3219
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3220 if (indx)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3221 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3222 value = 1.0 - value;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3223 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3224
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3225 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3226 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3227
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3228 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3229 betaincinv (double x, double a, const Array<double>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3230 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3231 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3232 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3233
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3234 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3235
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3236 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3237
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3238 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
3239 *pretval++ = betaincinv (x, a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3240
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3241 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3242 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3243
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3244 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3245 betaincinv (double x, const Array<double>& a, double b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3246 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3247 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3248 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3249
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3250 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3251
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3252 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3253
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3254 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
3255 *pretval++ = betaincinv (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3256
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3257 return retval;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3258 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3259
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3260 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3261 betaincinv (double x, const Array<double>& a, const Array<double>& b)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3262 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3263 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3264 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3265
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3266 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3267 err_betaincinv_nonconformant (dim_vector (0, 0), dv, b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3268
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3269 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3270
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3271 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3272
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3273 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3274
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3275 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
3276 *pretval++ = betaincinv (x, a(i), b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3277
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3278 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3279 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3280
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3281 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3282 betaincinv (const Array<double>& x, double a, double b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3283 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3284 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3285 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3286
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3287 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3288
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3289 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3290
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3291 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
3292 *pretval++ = betaincinv (x(i), a, b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3293
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3294 return retval;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3295 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3296
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3297 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3298 betaincinv (const Array<double>& x, double a, const Array<double>& b)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3299 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3300 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3301 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3302
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3303 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3304 err_betaincinv_nonconformant (dv, dim_vector (0, 0), b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3305
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3306 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3307
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3308 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3309
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3310 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3311
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3312 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
3313 *pretval++ = betaincinv (x(i), a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3314
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3315 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3316 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3317
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3318 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3319 betaincinv (const Array<double>& x, const Array<double>& a, double b)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3320 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3321 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3322 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3323
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3324 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3325 err_betaincinv_nonconformant (dv, a.dims (), dim_vector (0, 0));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3326
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3327 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3328
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3329 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3330
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3331 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3332
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3333 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
3334 *pretval++ = betaincinv (x(i), a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3335
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3336 return retval;
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3337 }
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3338
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3339 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3340 betaincinv (const Array<double>& x, const Array<double>& a,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3341 const Array<double>& b)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3342 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3343 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3344 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3345
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3346 if (dv != a.dims () && dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3347 err_betaincinv_nonconformant (dv, a.dims (), b.dims ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3348
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3349 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3350
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3351 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3352
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3353 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3354
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3355 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
3356 *pretval++ = betaincinv (x(i), a(i), b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3357
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3358 return retval;
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3359 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3360
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3361 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3362 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
3363 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3364 static const int Nmax = 16;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3365 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
3366 int n, Nn, ii;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3367
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3368 if (m < 0 || m > 1)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3369 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3370 (*current_liboctave_warning_with_id_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3371 ("Octave:ellipj-invalid-m",
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3372 "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
3373
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3374 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
3375
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3376 return;
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3377 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3378
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3379 double sqrt_eps = sqrt (std::numeric_limits<double>::epsilon ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3380 if (m < sqrt_eps)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3381 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3382 // 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
3383 si_u = sin (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3384 co_u = cos (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3385 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
3386 sn = si_u - t * co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3387 cn = co_u + t * si_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3388 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
3389 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3390 else if ((1 - m) < sqrt_eps)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3391 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3392 // 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
3393 m1 = 1 - m;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3394 si_u = sinh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3395 co_u = cosh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3396 ta_u = tanh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3397 se_u = 1/co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3398 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
3399 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
3400 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
3401 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3402 else
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3403 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3404 // Arithmetic-Geometric Mean (AGM) algorithm
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3405 // (Abramowitz and Stegun, Section 16.4)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3406 a[0] = 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3407 b = sqrt (1 - m);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3408 c[0] = sqrt (m);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3409 for (n = 1; n < Nmax; ++n)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3410 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3411 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
3412 c[n] = (a[n - 1] - b)/2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3413 b = sqrt (a[n - 1]*b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3414 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
3415 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3416 if (n >= Nmax - 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3417 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3418 err = 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3419 return;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3420 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3421 Nn = n;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3422 for (ii = 1; n > 0; ii = ii*2, --n) ; // ii = pow(2,Nn)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3423 phi = ii*a[Nn]*u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3424 for (n = Nn; n > 0; --n)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3425 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3426 phi = (asin ((c[n]/a[n])* sin (phi)) + phi)/2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3427 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3428 sn = sin (phi);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3429 cn = cos (phi);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3430 dn = sqrt (1 - m*sn*sn);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3431 }
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3432 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3433
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3434 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3435 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
3436 double& err)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3437 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3438 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
3439
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
3440 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
3441 if (u.real () == 0)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3442 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3443 // 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
3444 sn = Complex (0, ss1/cc1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3445 cn = 1/cc1; // cn.imag = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3446 dn = dd1/cc1; // dn.imag = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3447 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3448 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3449 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3450 // u is generic complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3451 double ss, cc, dd, ddd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3452
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
3453 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
3454 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
3455 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
3456 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
3457 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
3458 }
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3459 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3460
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3461 static const double pi = 3.14159265358979323846;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3462
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3463 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3464 static inline T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3465 xlog (const T& x)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3466 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3467 return log (x);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3468 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3469
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3470 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3471 inline double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3472 xlog (const double& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3473 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3474 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3475 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3476
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3477 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3478 inline float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3479 xlog (const float& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3480 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3481 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3482 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3483
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3484 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3485 static T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3486 lanczos_approximation_psi (const T zc)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3487 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3488 // 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
3489 // 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
3490 // 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
3491 // 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
3492 static const T dg_coeff[10] =
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3493 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3494 -0.83333333333333333e-1, 0.83333333333333333e-2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3495 -0.39682539682539683e-2, 0.41666666666666667e-2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3496 -0.75757575757575758e-2, 0.21092796092796093e-1,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3497 -0.83333333333333333e-1, 0.4432598039215686,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3498 -0.3053954330270122e+1, 0.125318899521531e+2
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3499 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3500
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3501 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
3502 T overz2k = overz2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3503
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3504 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3505 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
3506 p += dg_coeff[k] * overz2k;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3507 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
3508 return p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3509 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3510
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3511 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3512 T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3513 xpsi (T z)
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3514 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3515 static const double euler_mascheroni =
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3516 0.577215664901532860606512090082402431042;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3517
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3518 const bool is_int = (octave::math::floor (z) == z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3519
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3520 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3521 if (z <= 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3522 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3523 // limits - zeros of the gamma function
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3524 if (is_int)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3525 p = -octave::numeric_limits<T>::Inf (); // Matlab returns -Inf for psi (0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3526 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3527 // 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
3528 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
3529 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3530 else if (is_int)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3531 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3532 // 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
3533 p = - euler_mascheroni;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3534 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
3535 p += 1.0 / k;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3536 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3537 else if (octave::math::floor (z + 0.5) == z + 0.5)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3538 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3539 // 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
3540 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
3541 p += 1.0 / (2 * k - 1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3542
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3543 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
3544 }
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3545 else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3546 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3547 // adapted from XLiFE++ gammaFunctions
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3548
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3549 T zc = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3550 // 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
3551 if (z < 10)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3552 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3553 const signed char n = 10 - z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3554 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
3555 p -= 1.0 / (k + z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3556 zc += n;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3557 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3558 p += lanczos_approximation_psi (zc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3559 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3560
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3561 return p;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3562 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3563
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3564 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3565 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
3566 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
3567
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3568 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3569 std::complex<T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3570 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
3571 {
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3572 // adapted from XLiFE++ gammaFunctions
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3573
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3574 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
3575
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3576 P z_r = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3577 P z_ra = z_r;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3578
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3579 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
3580 if (z.imag () == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3581 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
3582 else if (z_r < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3583 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
3584 else
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3585 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3586 // 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
3587 std::complex<T> z_m = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3588 if (z_ra < 8)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3589 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3590 unsigned char n = 8 - z_ra;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3591 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
3592
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3593 // 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
3594 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3595 // 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
3596 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
3597 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
3598 dgam -= P (1.0) / z_p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3599 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3600
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3601 // 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
3602 // LogGamma
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3603 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3604 // 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
3605 // + 7/1680z^8 - 9/1188z^10 + ...
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3606 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3607 // (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
3608 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
3609 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3610 return dgam;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3611 }
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3612
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3613 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3614 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
3615 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
3616
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3617 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3618 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
3619 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
3620
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3621 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3622 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
3623 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
3624 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
3625 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22954
diff changeset
3626 F77_INT n = octave::to_f77_int (n_arg);
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
3627 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
3628 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
3629 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
3630 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3631 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3632
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3633 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3634 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
3635 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
3636 float& ans, octave_idx_type& ierr)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3637 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22954
diff changeset
3638 F77_INT n = octave::to_f77_int (n_arg);
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
3639 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
3640 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
3641 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
3642 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3643 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3644
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3645 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3646 T
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
3647 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
3648 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3649 T ans;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3650 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
3651 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
3652 if (ierr == 0)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3653 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3654 // 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
3655 // 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
3656 // 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
3657 if (n > 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3658 // 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
3659 // way too fast.
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3660 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
3661 else if (n == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3662 ans = -ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3663 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3664 else if (ierr == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3665 ans = - octave::numeric_limits<T>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3666 else // we probably never get here
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3667 ans = octave::numeric_limits<T>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3668
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3669 return ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3670 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3671
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3672 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
3673 float psi (octave_idx_type n, float z) { return xpsi (n, z); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3674 }
20161
65e22ba879f0 psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents: 20156
diff changeset
3675 }
65e22ba879f0 psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents: 20156
diff changeset
3676
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3677 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3678
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3679 ComplexMatrix besselj (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3680 ComplexMatrix bessely (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3681 ComplexMatrix besseli (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3682 ComplexMatrix besselk (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3683 ComplexMatrix besselh1 (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3684 ComplexMatrix besselh2 (double alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3685
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3686 ComplexMatrix besselj (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3687 ComplexMatrix bessely (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3688 ComplexMatrix besseli (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3689 ComplexMatrix besselk (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3690 ComplexMatrix besselh1 (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3691 ComplexMatrix besselh2 (const Matrix& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3692
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3693 ComplexMatrix besselj (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3694 ComplexMatrix bessely (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3695 ComplexMatrix besseli (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3696 ComplexMatrix besselk (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3697 ComplexMatrix besselh1 (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3698 ComplexMatrix besselh2 (const Matrix& alpha, const ComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3699
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3700 ComplexNDArray besselj (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3701 ComplexNDArray bessely (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3702 ComplexNDArray besseli (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3703 ComplexNDArray besselk (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3704 ComplexNDArray besselh1 (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3705 ComplexNDArray besselh2 (double alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3706
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3707 ComplexNDArray besselj (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3708 ComplexNDArray bessely (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3709 ComplexNDArray besseli (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3710 ComplexNDArray besselk (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3711 ComplexNDArray besselh1 (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3712 ComplexNDArray besselh2 (const NDArray& alpha, const Complex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3713
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3714 ComplexNDArray besselj (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3715 ComplexNDArray bessely (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3716 ComplexNDArray besseli (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3717 ComplexNDArray besselk (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3718 ComplexNDArray besselh1 (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3719 ComplexNDArray besselh2 (const NDArray& alpha, const ComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3720
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3721 ComplexMatrix besselj (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3722 ComplexMatrix bessely (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3723 ComplexMatrix besseli (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3724 ComplexMatrix besselk (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3725 ComplexMatrix besselh1 (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3726 ComplexMatrix besselh2 (const RowVector& alpha, const ComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3727
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3728 FloatComplexMatrix besselj (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3729 FloatComplexMatrix bessely (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3730 FloatComplexMatrix besseli (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3731 FloatComplexMatrix besselk (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3732 FloatComplexMatrix besselh1 (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3733 FloatComplexMatrix besselh2 (float alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3734
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3735 FloatComplexMatrix besselj (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3736 FloatComplexMatrix bessely (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3737 FloatComplexMatrix besseli (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3738 FloatComplexMatrix besselk (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3739 FloatComplexMatrix besselh1 (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3740 FloatComplexMatrix besselh2 (const FloatMatrix& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3741
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3742 FloatComplexMatrix besselj (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3743 FloatComplexMatrix bessely (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3744 FloatComplexMatrix besseli (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3745 FloatComplexMatrix besselk (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3746 FloatComplexMatrix besselh1 (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3747 FloatComplexMatrix besselh2 (const FloatMatrix& alpha, const FloatComplexMatrix& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3748
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3749 FloatComplexNDArray besselj (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3750 FloatComplexNDArray bessely (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3751 FloatComplexNDArray besseli (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3752 FloatComplexNDArray besselk (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3753 FloatComplexNDArray besselh1 (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3754 FloatComplexNDArray besselh2 (float alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3755
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3756 FloatComplexNDArray besselj (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3757 FloatComplexNDArray bessely (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3758 FloatComplexNDArray besseli (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3759 FloatComplexNDArray besselk (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3760 FloatComplexNDArray besselh1 (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3761 FloatComplexNDArray besselh2 (const FloatNDArray& alpha, const FloatComplex& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3762
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3763 FloatComplexNDArray besselj (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3764 FloatComplexNDArray bessely (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3765 FloatComplexNDArray besseli (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3766 FloatComplexNDArray besselk (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3767 FloatComplexNDArray besselh1 (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3768 FloatComplexNDArray besselh2 (const FloatNDArray& alpha, const FloatComplexNDArray& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3769
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3770 FloatComplexMatrix besselj (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselj (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3771 FloatComplexMatrix bessely (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::bessely (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3772 FloatComplexMatrix besseli (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besseli (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3773 FloatComplexMatrix besselk (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselk (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3774 FloatComplexMatrix besselh1 (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh1 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3775 FloatComplexMatrix besselh2 (const FloatRowVector& alpha, const FloatComplexColumnVector& x, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::besselh2 (alpha, x, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3776
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3777 ComplexMatrix airy (const ComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3778 ComplexMatrix biry (const ComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3779
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3780 ComplexNDArray airy (const ComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3781 ComplexNDArray biry (const ComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3782
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3783 FloatComplexMatrix airy (const FloatComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3784 FloatComplexMatrix biry (const FloatComplexMatrix& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3785
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3786 FloatComplexNDArray airy (const FloatComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::airy (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3787 FloatComplexNDArray biry (const FloatComplexNDArray& z, bool deriv, bool scaled, Array<octave_idx_type>& ierr) { return octave::math::biry (z, deriv, scaled, ierr); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3788
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3789 Array<double> betainc (double x, double a, const Array<double>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3790 Array<double> betainc (double x, const Array<double>& a, double b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3791 Array<double> betainc (double x, const Array<double>& a, const Array<double>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3792
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3793 Array<double> betainc (const Array<double>& x, double a, double b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3794 Array<double> betainc (const Array<double>& x, double a, const Array<double>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3795 Array<double> betainc (const Array<double>& x, const Array<double>& a, double b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3796 Array<double> betainc (const Array<double>& x, const Array<double>& a, const Array<double>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3797
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3798 Array<float> betainc (float x, float a, const Array<float>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3799 Array<float> betainc (float x, const Array<float>& a, float b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3800 Array<float> betainc (float x, const Array<float>& a, const Array<float>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3801
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3802 Array<float> betainc (const Array<float>& x, float a, float b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3803 Array<float> betainc (const Array<float>& x, float a, const Array<float>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3804 Array<float> betainc (const Array<float>& x, const Array<float>& a, float b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3805 Array<float> betainc (const Array<float>& x, const Array<float>& a, const Array<float>& b) { return octave::math::betainc (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3806
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3807 Matrix gammainc (double x, const Matrix& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3808 Matrix gammainc (const Matrix& x, double a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3809 Matrix gammainc (const Matrix& x, const Matrix& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3810
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3811 NDArray gammainc (double x, const NDArray& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3812 NDArray gammainc (const NDArray& x, double a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3813 NDArray gammainc (const NDArray& x, const NDArray& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3814
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3815 FloatMatrix gammainc (float x, const FloatMatrix& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3816 FloatMatrix gammainc (const FloatMatrix& x, float a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3817 FloatMatrix gammainc (const FloatMatrix& x, const FloatMatrix& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3818
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3819 FloatNDArray gammainc (float x, const FloatNDArray& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3820 FloatNDArray gammainc (const FloatNDArray& x, float a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3821 FloatNDArray gammainc (const FloatNDArray& x, const FloatNDArray& a) { return octave::math::gammainc (x, a); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3822
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3823 Array<double> betaincinv (double x, double a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3824 Array<double> betaincinv (double x, const Array<double>& a, double b) { return octave::math::betaincinv (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3825 Array<double> betaincinv (double x, const Array<double>& a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3826
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3827 Array<double> betaincinv (const Array<double>& x, double a, double b) { return octave::math::betaincinv (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3828 Array<double> betaincinv (const Array<double>& x, double a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3829 Array<double> betaincinv (const Array<double>& x, const Array<double>& a, double b) { return octave::math::betaincinv (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3830 Array<double> betaincinv (const Array<double>& x, const Array<double>& a, const Array<double>& b) { return octave::math::betaincinv (x, a, b); }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3831
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3832 #endif