annotate liboctave/numeric/lo-specfun.cc @ 23662:bd77ab816e43

eliminate obsolete file lo-math.h * lo-math.h: Delete. * liboctave/util/module.mk: Update. * configure.ac: Delete check for obsolete file sunmath.h. * mk-opts.pl: Emit #include <cmath>, not #include "lo-math.h". Change all uses to include <cmath> instead of "lo-math.h".
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jun 2017 18:26:15 -0400
parents 7b187892a25a
children a6eef0626b2b
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"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
55 #include "lo-slatec-proto.h"
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
56 #include "lo-specfun.h"
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
57 #include "mx-inlines.cc"
15696
2fac72a256ce Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents: 15271
diff changeset
58
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
59 namespace octave
21231
5f318c8ec634 eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
60 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
61 namespace math
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
62 {
23623
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
63 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
64
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
65 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
66
23650
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
67 Complex acosh (const Complex& x) { return std::acosh (x); }
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
68
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
69 FloatComplex acosh (const FloatComplex& x) { return std::acosh (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
70
23623
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
71 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
72
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
73 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
74
23650
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
75 Complex asinh (const Complex& x) { return std::asinh (x); }
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
76
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
77 FloatComplex asinh (const FloatComplex& x) { return std::asinh (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
78
23623
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
79 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
80
4feed155a1f2 Use acosh, acoshf, asinh, asinhf, atanh, atanhf from C++ std library.
Rik <rik@octave.org>
parents: 23564
diff changeset
81 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
82
23650
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
83 Complex atanh (const Complex& x) { return std::atanh (x); }
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
84
7b187892a25a Use trig functions for complex inputs from C++ std library.
Rik <rik@octave.org>
parents: 23649
diff changeset
85 FloatComplex atanh (const FloatComplex& x) { return std::atanh (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
86
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
87 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
88
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
89 float erf (float x) { return std::erff (x); }
6969
0a64abe792f4 [project @ 2007-10-06 14:15:19 by jwe]
jwe
parents: 6961
diff changeset
90
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
91 // 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
92 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
93 erf (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
94 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
95 return Faddeeva::erf (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
96 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
97
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
98 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
99 erf (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
100 {
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
101 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
102 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
103 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
104 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
105
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
106 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
107
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
108 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
109
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
110 // 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
111 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
112 erfc (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
113 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
114 return Faddeeva::erfc (x);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
117 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
118 erfc (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
119 {
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
120 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
121 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
122 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
123 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
124
23634
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
125 // 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
126 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
127 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
128
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
129 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
130 erfcx (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
131 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
132 return Faddeeva::erfcx (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
133 }
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 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
136 erfcx (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
137 {
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
138 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
139 Complex ret;
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
140 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
141 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
142 }
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 // 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
145 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
146 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
147
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
148 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
149 erfi (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
150 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
151 return Faddeeva::erfi (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
152 }
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 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
155 erfi (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
156 {
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
157 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
158 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
159 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
160 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
161
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
162 // 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
163 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
164 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
165
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
166 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
167 dawson (const Complex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
168 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
169 return Faddeeva::Dawson (x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
170 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
171
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
172 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
173 dawson (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
174 {
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
175 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
176 Complex ret;
ff68c9d024b8 Use erf, erff, erfc, erfcf from C++ std library.
Rik <rik@octave.org>
parents: 23624
diff changeset
177 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
178 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
179 }
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 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
182 gamma (double x)
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 double result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
185
23646
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
186 // Special cases for (near) compatibility with Matlab instead of tgamma.
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
187 // Matlab does not have -0.
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
188
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
189 if (x == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
190 result = (octave::math::negative_sign (x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
191 ? -octave::numeric_limits<double>::Inf ()
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
192 : octave::numeric_limits<double>::Inf ());
23646
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
193 else if ((x < 0 && octave::math::x_nint (x) == x)
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
194 || octave::math::isinf (x))
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
195 result = octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
196 else if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
197 result = octave::numeric_limits<double>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
198 else
23646
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
199 result = std::tgamma (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
200
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
201 return result;
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
23648
864ac8dabeff Use lgamma, lgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23646
diff changeset
204 double lgamma (double x) { return std::lgamma (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
205
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
206 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
207 rc_lgamma (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
208 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
209 double result;
7601
8a939b217863 Treat negative values to lgamma and beta correctly
David Bateman <dbateman@free.fr>
parents: 7176
diff changeset
210
8a939b217863 Treat negative values to lgamma and beta correctly
David Bateman <dbateman@free.fr>
parents: 7176
diff changeset
211 #if defined (HAVE_LGAMMA_R)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
212 int sgngam;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
213 result = lgamma_r (x, &sgngam);
23648
864ac8dabeff Use lgamma, lgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23646
diff changeset
214 #else
864ac8dabeff Use lgamma, lgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23646
diff changeset
215 result = std::lgamma (x);
23463
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
216 int sgngam = signgam;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
217 #endif
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
218
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
219 if (sgngam < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
220 return result + Complex (0., M_PI);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
221 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
222 return result;
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
223 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
224
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
225 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
226 gamma (float x)
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
227 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
228 float result;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
229
23646
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
230 // Special cases for (near) compatibility with Matlab instead of tgamma.
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
231 // Matlab does not have -0.
21786
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 if (x == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
234 result = (octave::math::negative_sign (x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
235 ? -octave::numeric_limits<float>::Inf ()
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
236 : octave::numeric_limits<float>::Inf ());
23646
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
237 else if ((x < 0 && octave::math::x_nint (x) == x)
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
238 || octave::math::isinf (x))
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
239 result = octave::numeric_limits<float>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
240 else if (octave::math::isnan (x))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
241 result = octave::numeric_limits<float>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
242 else
23646
0a5c6836c499 Use tgamma, tgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23642
diff changeset
243 result = std::tgammaf (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
244
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
245 return result;
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
246 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
247
23648
864ac8dabeff Use lgamma, lgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23646
diff changeset
248 float lgamma (float x) { return std::lgammaf (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
249
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
250 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
251 rc_lgamma (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
252 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
253 float result;
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 #if defined (HAVE_LGAMMAF_R)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
256 int sgngam;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
257 result = lgammaf_r (x, &sgngam);
23648
864ac8dabeff Use lgamma, lgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23646
diff changeset
258 #else
864ac8dabeff Use lgamma, lgammaf from C++ std library.
Rik <rik@octave.org>
parents: 23646
diff changeset
259 result = std::lgammaf (x);
23463
5296657cde44 use lgamma if lgamma_r is not available (bug #50919)
John W. Eaton <jwe@octave.org>
parents: 23450
diff changeset
260 int sgngam = signgam;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
261 #endif
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
262
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
263 if (sgngam < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
264 return result + FloatComplex (0., M_PI);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
265 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
266 return result;
7638
2df457529cfa implement expm1 and log1p functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7601
diff changeset
267 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
268
23638
799833716c7b Use expm1, expm1f from C++ std library.
Rik <rik@octave.org>
parents: 23634
diff changeset
269 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
270
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
271 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
272 expm1 (const Complex& x)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
273 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
274 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
275
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
276 if (std:: abs (x) < 1)
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 double im = x.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
279 double u = expm1 (x.real ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
280 double v = sin (im/2);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
281 v = -2*v*v;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
282 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
283 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
284 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
285 retval = std::exp (x) - Complex (1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
286
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
287 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
288 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
289
23638
799833716c7b Use expm1, expm1f from C++ std library.
Rik <rik@octave.org>
parents: 23634
diff changeset
290 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
291
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
292 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
293 expm1 (const FloatComplex& x)
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
294 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
295 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
296
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
297 if (std:: abs (x) < 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
298 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
299 float im = x.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
300 float u = expm1 (x.real ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
301 float v = sin (im/2);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
302 v = -2*v*v;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
303 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
304 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
305 else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
306 retval = std::exp (x) - FloatComplex (1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
307
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
308 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
309 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
310
23642
18ae8d3c745b Use log1p, log1pf from C++ std library.
Rik <rik@octave.org>
parents: 23639
diff changeset
311 double log1p (double x) { return std::log1p (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
312
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
313 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
314 log1p (const Complex& x)
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
315 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
316 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
317
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
318 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
319
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
320 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
321 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
322 double u = 2*r + r*r + i*i;
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
323 retval = Complex (log1p (u / (1+std::sqrt (u+1))),
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
324 atan2 (1 + r, i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
325 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
326 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
327 retval = std::log (Complex (1) + x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
328
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
329 return retval;
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
23624
65e5ddf6d059 Use cbrt, cbrtf from C++ std library.
Rik <rik@octave.org>
parents: 23623
diff changeset
332 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
333
23642
18ae8d3c745b Use log1p, log1pf from C++ std library.
Rik <rik@octave.org>
parents: 23639
diff changeset
334 float log1p (float x) { return std::log1pf (x); }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
335
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
336 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
337 log1p (const FloatComplex& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
338 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
339 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
340
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
341 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
342
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
343 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
344 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
345 float u = 2*r + r*r + i*i;
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
346 retval = FloatComplex (log1p (u / (1+std::sqrt (u+1))),
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
347 atan2 (1 + r, i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
348 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
349 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
350 retval = std::log (FloatComplex (1) + x);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
351
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
352 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
353 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
354
23624
65e5ddf6d059 Use cbrt, cbrtf from C++ std library.
Rik <rik@octave.org>
parents: 23623
diff changeset
355 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
356
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
357 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
358 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
359
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
360 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
361 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
362
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
363 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
364 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
365
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
366 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
367 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
368
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
369 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
370 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
371
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
372 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
373 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
374
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
375 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
376 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
377 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
378 static const Complex inf_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
379 = Complex (octave::numeric_limits<double>::Inf (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
380 octave::numeric_limits<double>::Inf ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
381
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
382 static const Complex nan_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
383 = Complex (octave::numeric_limits<double>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
384 octave::numeric_limits<double>::NaN ());
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 retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
387
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
388 switch (ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
389 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
390 case 0:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
391 case 3:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
392 retval = val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
393 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
394
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
395 case 2:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
396 retval = inf_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
397 break;
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 default:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
400 retval = nan_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
401 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
402 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
403
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
404 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
405 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
406
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
407 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
408 is_integer_value (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
409 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
410 return 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
411 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
412
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
413 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
414 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
415 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
416 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
417
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
418 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
419 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
420 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
421 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
422
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
423 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
424
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
425 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
426 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
427
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
428 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
429
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
430 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
431
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
432 if (kode != 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
433 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
434 double expz = exp (std::abs (zi));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
435 yr *= expz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
436 yi *= expz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
437 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
438
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
439 if (zi == 0.0 && zr >= 0.0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
440 yi = 0.0;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
441
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
442 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
443 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
444 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
445 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
446 // 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
447 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
448 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
449 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
450 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
451 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
452 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
453 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
454 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
455 alpha = -alpha;
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 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
458
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
459 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
460 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
461 tmp -= 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
462
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
463 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
464 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
465 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
466 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
467 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
468 }
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 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
471 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
472
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
473 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
474 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
475 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
476 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
477
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
478 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
479 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
480 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
481 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
482
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
483 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
484
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
485 double wr, wi;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
486
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
487 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
488 double zi = z.imag ();
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 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
491
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
492 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
493 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
494 yr = -octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
495 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
496 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
497 else
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 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
500 &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
501
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
502 ierr = t_ierr;
21786
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 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
505 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
506 double expz = exp (std::abs (zi));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
507 yr *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
508 yi *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
509 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
510
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
511 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
512 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
513 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
514
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
515 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
516 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
517 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
518 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
519 // 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
520 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
521 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
522 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
523 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
524 retval = bessel_return_value (tmp, 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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
527 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
528 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
529
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
530 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
531
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
532 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
533 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
534 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
535
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
536 retval = bessel_return_value (tmp, 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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
539 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
540 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
541 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
542
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
543 return retval;
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
544 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
545
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
546 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
547 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
548 {
21786
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 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
552 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
553 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
554 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
555
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
556 F77_INT nz, t_ierr;
21786
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 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
559 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
560
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
561 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
562
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
563 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
564
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
565 if (kode != 2)
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 double expz = exp (std::abs (zr));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
568 yr *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
569 yi *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
570 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
571
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
572 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
573 yi = 0.0;
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 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
576 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
577 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
578 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
579 // 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
580 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
581 Complex tmp = zbesi (z, alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
582 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
583 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
584 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
585 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
586 alpha = -alpha;
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 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
589
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
590 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
591 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
592 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
593 * zbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
594
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
595 if (kode == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
596 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
597 // 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
598 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
599 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
600
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
601 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
602
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
603 retval = bessel_return_value (tmp, ierr);
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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
606 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
607 octave::numeric_limits<double>::NaN ());
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
608 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
609
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
610 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
611 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
612
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
613 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
614 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
615 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
616 Complex retval;
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 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
619 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
620 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
621 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
622
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
623 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
624
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
625 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
626 double zi = z.imag ();
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 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
629
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
630 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
631 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
632 yr = octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
633 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
634 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
635 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
636 {
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
637 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
638 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
639
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
640 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
641
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
642 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
643 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
644 Complex expz = exp (-z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
645
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
646 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
647 double iexpz = expz.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
648
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
649 double tmp = yr*rexpz - yi*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
650
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
651 yi = yr*iexpz + yi*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
652 yr = tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
653 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
654
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
655 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
656 yi = 0.0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
657 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
658
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
659 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
660 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
661 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
662 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
663 Complex tmp = zbesk (z, -alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
664
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
665 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
666 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
667
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
668 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
669 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
670
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
671 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
672 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
673 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
674 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
675
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
676 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
677 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
678 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
679 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
680
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
681 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
682
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
683 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
684 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
685
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
686 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
687 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
688
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
689 ierr = t_ierr;
21786
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 if (kode != 2)
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 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
694
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
695 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
696 double iexpz = expz.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
697
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
698 double tmp = yr*rexpz - yi*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
699
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
700 yi = yr*iexpz + yi*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
701 yr = tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
702 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
703
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
704 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
705 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
706 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
707 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
708 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
709
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
710 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
711
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
712 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
713
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
714 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
715 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
716
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
717 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
718 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
719
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
720 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
721 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
722 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
723 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
724
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
725 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
726 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
727 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
728 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
729
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
730 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
731
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
732 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
733 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
734
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
735 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
736 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
737
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
738 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
739
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
740 if (kode != 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
741 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
742 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
743
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
744 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
745 double iexpz = expz.imag ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
746
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
747 double tmp = yr*rexpz - yi*iexpz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
748
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
749 yi = yr*iexpz + yi*rexpz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
750 yr = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
751 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
752
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
753 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
754 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
755 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
756 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
757 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
758
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
759 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
760
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
761 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
762
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
763 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
764 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
765
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
766 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
767 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
768
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
769 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
770
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
771 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
772 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
773 bool scaled, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
774 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
775 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
776
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
777 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
778
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
779 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
780 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
781
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
782 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
783 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
784 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
785 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
786 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
787 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
788
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
789 ComplexMatrix retval (nr, nc);
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.resize (dim_vector (nr, nc));
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 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
794 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
795 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
796
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
797 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
798 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
799
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
800 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
801 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
802 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
803 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
804 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
805 octave_idx_type nc = alpha.cols ();
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 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
808
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
809 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
810
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
811 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
812 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
813 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
814
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
815 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
816 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
817
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
818 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
819 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
820 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
821 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
822 ComplexMatrix retval;
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 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
825 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
826
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
827 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
828 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
829
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
830 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
831 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
832 ("%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
833
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
834 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
835 octave_idx_type nc = x_nc;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
836
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
837 retval.resize (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
840
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
841 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
842 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
843 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
844
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
845 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
846 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
847
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
848 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
849 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
850 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
851 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
852 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
853 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
854 ComplexNDArray retval (dv);
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 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
857
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
858 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
859 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
860
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
861 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
864 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
865 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
866 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
867 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
868 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
869 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
870 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
871
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
872 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
873
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
874 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
875 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
876
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
877 return retval;
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 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
881 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
882 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
883 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
884 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
885 ComplexNDArray retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
886
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
887 if (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
888 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
889 ("%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
890
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
891 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
892
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
893 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
894 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
895
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
896 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
897 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
898
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
899 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
900 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
901
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
902 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
903 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
904 const ComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
905 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
906 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
907 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
908 octave_idx_type nc = alpha.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
909
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
910 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
911
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
912 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
913
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
914 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
915 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
916 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
917
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
918 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
919 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
920
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
921 #define SS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
922 Complex \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
923 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
924 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
925 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
926 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
927
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
928 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
929 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
930 name (double alpha, const ComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
931 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
932 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
933 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
934 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
935
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
936 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
937 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
938 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
939 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
940 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
941 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
942 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
943
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
944 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
945 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
946 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
947 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
948 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
949 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
950 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
951
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
952 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
953 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
954 name (double alpha, const ComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
955 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
956 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
957 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
958 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
959
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
960 #define NS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
961 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
962 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
963 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
964 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
965 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
966 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
967
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
968 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
969 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
970 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
971 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
972 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
973 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
974 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
975
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
976 #define RC_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
977 ComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
978 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
979 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
980 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
981 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
982 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
983
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
984 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
985 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
986 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
987 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
988 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
989 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
990 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
991 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
992 RC_BESSEL (name, fcn)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
993
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
994 ALL_BESSEL (besselj, zbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
995 ALL_BESSEL (bessely, zbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
996 ALL_BESSEL (besseli, zbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
997 ALL_BESSEL (besselk, zbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
998 ALL_BESSEL (besselh1, zbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
999 ALL_BESSEL (besselh2, zbesh2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1000
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1001 #undef ALL_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1002 #undef SS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1003 #undef SM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1004 #undef MS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1005 #undef MM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1006 #undef SN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1007 #undef NS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1008 #undef NN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1009 #undef RC_BESSEL
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 FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1012 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
1013
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1014 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1015 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
1016
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1017 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1018 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
1019
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1020 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1021 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
1022
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1023 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1024 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
1025
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1026 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1027 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
1028
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1029 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1030 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
1031 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1032 static const FloatComplex inf_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1033 = FloatComplex (octave::numeric_limits<float>::Inf (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1034 octave::numeric_limits<float>::Inf ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1035
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1036 static const FloatComplex nan_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1037 = FloatComplex (octave::numeric_limits<float>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1038 octave::numeric_limits<float>::NaN ());
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 FloatComplex 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 switch (ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1043 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1044 case 0:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1045 case 3:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1046 retval = val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1047 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1048
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1049 case 2:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1050 retval = inf_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1051 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1052
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1053 default:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1054 retval = nan_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1055 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1056 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1057
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1058 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1059 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1060
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1061 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1062 is_integer_value (float x)
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 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
1065 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1066
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1067 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1068 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
1069 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1070 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1071
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1072 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1073 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1074 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1075
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1076 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1077
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1078 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
1079 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
1080
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1081 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1082
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1083 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1084 {
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
1085 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
1086 y *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1087 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1088
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
1089 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
1090 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1091
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1092 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1093 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1094 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1095 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1096 // 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
1097 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1098 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
1099 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1100 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1101 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1102 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1103 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1104 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1105 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1106
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1107 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
1108 * cbesj (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1109
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1110 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1111 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1112 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
1113 * cbesy (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1114
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1115 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1116 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1117 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1118 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
1119 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1120 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1121
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1122 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1123 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1124
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1125 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1126 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
1127 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1128 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1129
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1130 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1131 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1132 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1133
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1134 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1135
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1136 FloatComplex w;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1137
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1138 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1139
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
1140 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
1141 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1142 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
1143 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1144 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1145 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1146 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
1147 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
1148 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
1149
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1150 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1151
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1152 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1153 {
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
1154 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
1155 y *= expz;
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
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
1158 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
1159 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1160 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1161
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1162 return bessel_return_value (y, ierr);
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 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
1165 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1166 // 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
1167 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1168 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
1169 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
1170 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1171 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1172 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1173 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1174 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1175 alpha = -alpha;
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 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
1178 * cbesy (z, alpha, kode, ierr);
21786
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 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1181 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1182 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
1183 * cbesj (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1184
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1185 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1186 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1187 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1188 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
1189 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1190 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1191
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1192 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1193 }
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 inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1196 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
1197 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1198 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1199
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1200 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1201 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1202 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1203
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1204 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1205
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1206 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
1207 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
1208
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1209 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1210
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1211 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1212 {
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
1213 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
1214 y *= expz;
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
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
1217 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
1218 y = FloatComplex (y.real (), 0.0);
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 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1221 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1222 else
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 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1225
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1226 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
1227
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1228 if (ierr == 0 || ierr == 3)
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 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
1231 * sinf (static_cast<float> (M_PI) * alpha)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1232 * cbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1233
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1234 if (kode == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1235 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1236 // 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
1237 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
1238 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1239
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1240 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1241
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1242 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1243 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1244 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1245 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
1246 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1247 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1248
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1249 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1250 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1251
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1252 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1253 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
1254 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1255 FloatComplex retval;
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 if (alpha >= 0.0)
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 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1260
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1261 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1262
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1263 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1264
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
1265 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
1266 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1267 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
1268 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1269 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1270 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1271 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
1272 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
1273
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1274 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1275
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1276 if (kode != 2)
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 FloatComplex expz = exp (-z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1279
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
1280 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
1281 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
1282
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
1283 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
1284 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
1285
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1286 y = FloatComplex (tmp_r, tmp_i);
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
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
1289 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
1290 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1291 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1292
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1293 retval = bessel_return_value (y, ierr);
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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1296 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1297 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
1298
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1299 retval = bessel_return_value (tmp, ierr);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1302 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1303 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1304
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1305 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1306 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
1307 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1308 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1309
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1310 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1311 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1312 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1313
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1314 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1315
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1316 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
1317 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
1318
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1319 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1320
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1321 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1322 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1323 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
1324
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
1325 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
1326 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
1327
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
1328 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
1329 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
1330
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1331 y = FloatComplex (tmp_r, tmp_i);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1332 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1333
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1334 retval = bessel_return_value (y, 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 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
1341
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1342 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
1343 * cbesh1 (z, alpha, kode, ierr);
21786
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 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1346 }
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 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1351 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1352 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
1353 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1354 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1355
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1356 if (alpha >= 0.0)
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 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1359
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1360 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1361
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1362 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
1363 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
1364
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1365 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1366
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1367 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1368 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1369 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
1370
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
1371 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
1372 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
1373
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
1374 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
1375 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
1376
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1377 y = FloatComplex (tmp_r, tmp_i);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1380 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1381 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1382 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1383 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1384 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1385
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1386 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
1387
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1388 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
1389 * cbesh2 (z, alpha, kode, ierr);
21786
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 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1392 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1393
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1394 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1395 }
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 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
1398 octave_idx_type&);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1399
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1400 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1401 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
1402 bool scaled, octave_idx_type& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1403 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1404 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1405
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1406 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
1407
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1408 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1409 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1410
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1411 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1412 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
1413 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
1414 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1415 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1416 octave_idx_type nc = x.cols ();
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 FloatComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
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 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
1423 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
1424 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
1425
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1426 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1427 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1428
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1429 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1430 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
1431 const FloatComplex& x,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1432 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
1433 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1434 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1435 octave_idx_type nc = alpha.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1436
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1437 FloatComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
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 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
1442 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
1443 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
1444
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1445 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1446 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1447
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1448 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1449 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
1450 const FloatComplexMatrix& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1451 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1452 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1453 FloatComplexMatrix retval;
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 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
1456 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
1457
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1458 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
1459 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
1460
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1461 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
1462 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1463 ("%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
1464
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1465 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1466 octave_idx_type nc = x_nc;
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 retval.resize (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1469
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1470 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1471
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1472 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
1473 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
1474 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
1475
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1476 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1477 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1478
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1479 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1480 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
1481 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
1482 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1483 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1484 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1485 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1486
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1487 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1488
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1489 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
1490 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
1491
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1492 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1495 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1496 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
1497 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
1498 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1499 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1500 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1501 FloatComplexNDArray retval (dv);
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 ierr.resize (dv);
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 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
1506 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
1507
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1508 return retval;
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 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1512 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
1513 const FloatComplexNDArray& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1514 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1515 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1516 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1517 FloatComplexNDArray 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 (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1520 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1521 ("%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
1522
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1523 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1524
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1525 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1526 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1527
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1528 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
1529 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
1530
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1531 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1532 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1533
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1534 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1535 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
1536 const FloatComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1537 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1538 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1539 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1540 octave_idx_type nc = alpha.numel ();
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 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1543
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1544 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1545
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1546 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
1547 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
1548 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
1549
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1550 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1551 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1552
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1553 #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
1554 FloatComplex \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1555 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
1556 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
1557 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1558 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
1559 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1560
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1561 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1562 FloatComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1563 name (float alpha, const FloatComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1564 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1565 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1566 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
1567 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1568
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1569 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1570 FloatComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1571 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
1572 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1573 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1574 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
1575 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1576
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1577 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1578 FloatComplexMatrix \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1579 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
1580 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1581 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1582 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
1583 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1584
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1585 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1586 FloatComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1587 name (float alpha, const FloatComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1588 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1589 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1590 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
1591 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1592
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1593 #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
1594 FloatComplexNDArray \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1595 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
1596 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
1597 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1598 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
1599 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1600
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1601 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1602 FloatComplexNDArray \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1603 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
1604 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1605 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1606 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
1607 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1608
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1609 #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
1610 FloatComplexMatrix \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1611 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
1612 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
1613 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
1614 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1615 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
1616 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1617
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1618 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1619 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1620 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1621 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1622 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1623 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1624 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1625 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1626 RC_BESSEL (name, fcn)
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 ALL_BESSEL (besselj, cbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1629 ALL_BESSEL (bessely, cbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1630 ALL_BESSEL (besseli, cbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1631 ALL_BESSEL (besselk, cbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1632 ALL_BESSEL (besselh1, cbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1633 ALL_BESSEL (besselh2, cbesh2)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1634
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1635 #undef ALL_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1636 #undef SS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1637 #undef SM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1638 #undef MS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1639 #undef MM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1640 #undef SN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1641 #undef NS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1642 #undef NN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1643 #undef RC_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1644
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1645 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1646 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
1647 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1648 double ar = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1649 double ai = 0.0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1650
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1651 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1652 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1653
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1654 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
1655 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
1656
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1657 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
1658
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1659 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1660
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1661 if (! scaled)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1662 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1663 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
1664
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
1665 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
1666 double iexpz = expz.imag ();
21786
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 double tmp = ar*rexpz - ai*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1669
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1670 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1671 ar = tmp;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1672 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1673
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1674 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
1675 ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1676
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1677 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
1678 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1679
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1680 Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1681 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
1682 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1683 double ar = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1684 double ai = 0.0;
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 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1687 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1688
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1689 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
1690 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
1691
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1692 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
1693
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1694 ierr = t_ierr;
21786
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 if (! scaled)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1697 {
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
1698 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
1699
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
1700 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
1701 double iexpz = expz.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1702
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1703 double tmp = ar*rexpz - ai*iexpz;
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 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1706 ar = tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1707 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1708
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1709 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
1710 ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1711
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1712 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
1713 }
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 ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1716 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
1717 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1718 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1719 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1720 octave_idx_type nc = z.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1721
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1722 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1723
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1724 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1725
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1726 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
1727 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
1728 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
1729
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1730 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1731 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1732
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1733 ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1734 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
1735 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1736 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1737 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1738 octave_idx_type nc = z.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1739
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1740 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1741
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1742 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1743
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1744 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
1745 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
1746 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
1747
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1748 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1749 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1750
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1751 ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1752 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
1753 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1754 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1755 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1756 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1757 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1758
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1759 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1760
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1761 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
1762 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
1763
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1764 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1765 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1766
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1767 ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1768 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
1769 Array<octave_idx_type>& ierr)
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 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1772 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1773 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1774
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1775 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1776
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1777 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
1778 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
1779
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1780 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1781 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1782
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1783 FloatComplex
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1784 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
1785 octave_idx_type& ierr)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1786 {
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1787 FloatComplex a;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1788
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1789 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
1790 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
1791
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1792 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
1793 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
1794
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1795 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
1796
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1797 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
1798 float ai = a.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1799
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1800 if (! scaled)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1801 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1802 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
1803
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
1804 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
1805 float iexpz = expz.imag ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1806
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1807 float tmp = ar*rexpz - ai*iexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1808
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1809 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1810 ar = tmp;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1811 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1812
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1813 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
1814 ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1815
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1816 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
1817 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1818
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1819 FloatComplex
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1820 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
1821 octave_idx_type& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1822 {
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1823 FloatComplex a;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1824
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23220
diff changeset
1825 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
1826 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
1827
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1828 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
1829 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
1830
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1831 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
1832
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1833 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
1834 float ai = a.imag ();
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1835
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1836 if (! scaled)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1837 {
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1838 FloatComplex expz
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1839 = 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
1840
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
1841 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
1842 float iexpz = expz.imag ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1843
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1844 float tmp = ar*rexpz - ai*iexpz;
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 ai = ar*iexpz + ai*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1847 ar = tmp;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
1848 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1849
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1850 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
1851 ai = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1852
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1853 return bessel_return_value (FloatComplex (ar, ai), ierr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1854 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1855
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1856 FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1857 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
1858 Array<octave_idx_type>& ierr)
4506
3c82fc8f822c [project @ 2003-09-10 13:56:57 by jwe]
jwe
parents: 4497
diff changeset
1859 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1860 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1861 octave_idx_type nc = z.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1862
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1863 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1864
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1865 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1866
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1867 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
1868 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
1869 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
1870
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1871 return retval;
4506
3c82fc8f822c [project @ 2003-09-10 13:56:57 by jwe]
jwe
parents: 4497
diff changeset
1872 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1873
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1874 FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1875 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
1876 Array<octave_idx_type>& ierr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1877 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1878 octave_idx_type nr = z.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1879 octave_idx_type nc = z.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1880
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1881 FloatComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1882
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1883 ierr.resize (dim_vector (nr, nc));
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 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
1886 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
1887 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
1888
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1889 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1890 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1891
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1892 FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1893 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
1894 Array<octave_idx_type>& ierr)
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 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1897 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1898 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1899
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1900 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1901
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1902 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
1903 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
1904
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1905 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1908 FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1909 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
1910 Array<octave_idx_type>& ierr)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1911 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1912 dim_vector dv = z.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1913 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1914 FloatComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1915
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1916 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1917
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1918 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
1919 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
1920
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1921 return retval;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1922 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1923
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1924 OCTAVE_NORETURN static void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1925 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
1926 const dim_vector& d3)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1927 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1928 std::string d1_str = d1.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1929 std::string d2_str = d2.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1930 std::string d3_str = d3.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1931
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1932 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1933 ("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
1934 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
1935 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1936
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1937 OCTAVE_NORETURN static void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1938 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
1939 const dim_vector& d3)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1940 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1941 std::string d1_str = d1.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1942 std::string d2_str = d2.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1943 std::string d3_str = d3.str ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1944
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1945 (*current_liboctave_error_handler)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1946 ("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
1947 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
1948 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1949
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1950 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1951 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
1952 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1953 double retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1954 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
1955 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1956 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1957
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1958 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1959 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
1960 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1961 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1962 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1963
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1964 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1965
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1966 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1967
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1968 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
1969 *pretval++ = betainc (x, a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1970
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1971 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1972 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1973
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1974 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1975 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
1976 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1977 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1978 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1979
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1980 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1981
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1982 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1983
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1984 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
1985 *pretval++ = betainc (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1986
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1987 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1988 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1989
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1990 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1991 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
1992 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1993 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1994 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1995
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1996 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1997 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
1998
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1999 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2000
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2001 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2002
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2003 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2004
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2005 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
2006 *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
2007
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2008 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2009 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2010
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2011 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2012 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
2013 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2014 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2015 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2016
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2017 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2018
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2019 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2020
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2021 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
2022 *pretval++ = betainc (x(i), a, b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2023
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2024 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2027 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2028 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
2029 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2030 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2031 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2032
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2033 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2034 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
2035
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2036 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2037
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2038 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2039
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2040 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2041
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2042 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
2043 *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
2044
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2045 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2046 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2047
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2048 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2049 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
2050 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2051 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2052 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2053
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2054 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2055 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
2056
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2057 octave_idx_type nel = dv.numel ();
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 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2060
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2061 double *pretval = retval.fortran_vec ();
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 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
2064 *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
2065
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2066 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2069 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
2070 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
2071 const Array<double>& b)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2072 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2073 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2074 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2075
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2076 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
2077 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
2078
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2079 octave_idx_type nel = dv.numel ();
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 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2082
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2083 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2084
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2085 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
2086 *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
2087
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2088 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2089 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2090
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2091 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2092 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
2093 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2094 float retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2095 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
2096 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2097 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2098
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2099 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2100 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
2101 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2102 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2103 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2104
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2105 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2106
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2107 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2108
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2109 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
2110 *pretval++ = betainc (x, a, b(i));
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2113 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2114
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2115 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2116 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
2117 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2118 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2119 octave_idx_type nel = dv.numel ();
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<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2122
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2123 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2124
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2125 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
2126 *pretval++ = betainc (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2127
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2128 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2129 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2130
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2131 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2132 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
2133 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2134 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2135 dim_vector dv = a.dims ();
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 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2138 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
2139
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2140 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2141
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2142 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2143
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2144 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2145
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2146 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
2147 *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
2148
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2149 return retval;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21118
diff changeset
2150 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2151
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2152 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2153 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
2154 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2155 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2156 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2157
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2158 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2159
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2160 float *pretval = retval.fortran_vec ();
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 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
2163 *pretval++ = betainc (x(i), a, b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2164
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2165 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2166 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2167
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2168 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2169 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
2170 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2171 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2172 dim_vector dv = x.dims ();
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 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2175 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
2176
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2177 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2178
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2179 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2180
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2181 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2182
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2183 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
2184 *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
2185
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2186 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2187 }
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 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2190 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
2191 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2192 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2193 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2194
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2195 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2196 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
2197
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2198 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2199
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2200 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2201
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2202 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2203
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2204 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
2205 *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
2206
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2207 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2208 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2209
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2210 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
2211 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
2212 const Array<float>& b)
21786
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<float> 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 () || dv != b.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 (), b.dims ());
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 float *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(i));
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 // 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
2233
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2234 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2235 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
2236 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2237 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
2238 (*current_liboctave_error_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
2239 ("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
2240
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2241 err = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2242
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2243 double retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2244
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2245 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
2246
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2247 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2248 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2249
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2250 Matrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2251 gammainc (double x, const Matrix& a)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2252 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2253 octave_idx_type nr = a.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2254 octave_idx_type nc = a.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2255
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2256 Matrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2257
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2258 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2259
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2260 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
2261 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
2262 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2263 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
2264
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2265 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2266 return Matrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2267 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2268
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2269 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2270 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2271
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2272 Matrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2273 gammainc (const Matrix& x, double a)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2274 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2275 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2276 octave_idx_type nc = x.cols ();
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 Matrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2279
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2280 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2281
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2282 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
2283 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
2284 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2285 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
2286
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2287 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2288 return Matrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2289 }
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;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2292 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
2293
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2294 Matrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2295 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
2296 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2297 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2298 octave_idx_type nc = x.cols ();
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 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
2301 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
2302
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2303 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
2304 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2305 ("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
2306 nr, nc, a_nr, a_nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2307
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2308 Matrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2309
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2310 bool err;
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 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
2313 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
2314 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2315 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
2316
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2317 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2318 return Matrix ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2319 }
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 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2324 NDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2325 gammainc (double x, const NDArray& a)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2326 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2327 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2328 octave_idx_type nel = dv.numel ();
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 NDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2331
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2332 bool err;
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 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
2335 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2336 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
2337
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2338 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2339 return NDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2340 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2341
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2342 return retval;
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2343 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2344
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2345 NDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2346 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
2347 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2348 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2349 octave_idx_type nel = dv.numel ();
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 NDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2352
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2353 bool err;
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 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
2356 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2357 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
2358
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2359 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2360 return NDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2361 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2362
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2363 return retval;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21118
diff changeset
2364 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
2365
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2366 NDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2367 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
2368 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2369 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2370 octave_idx_type nel = dv.numel ();
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 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2373 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2374 std::string x_str = dv.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2375 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
2376
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2377 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2378 ("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
2379 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
2380 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2381
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2382 NDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2383
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2384 bool err;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2385
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2386 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
2387 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2388 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
2389
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2390 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2391 return NDArray ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2392 }
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2395 }
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 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2398 gammainc (float x, float a, bool& err)
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2399 {
21786
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 float 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 (xsgammainc, XSGAMMAINC, (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;
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2411 }
21786
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 FloatMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2414 gammainc (float x, const FloatMatrix& a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2415 {
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 FloatMatrix 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 FloatMatrix ();
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;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2433 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2434
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2435 FloatMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2436 gammainc (const FloatMatrix& x, float a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2437 {
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 FloatMatrix 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 FloatMatrix ();
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;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2455 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2456
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2457 FloatMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2458 gammainc (const FloatMatrix& x, const FloatMatrix& a)
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2459 {
21786
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 FloatMatrix 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 FloatMatrix ();
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;
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2485 }
21786
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 FloatNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2488 gammainc (float x, const FloatNDArray& a)
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
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 FloatNDArray 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 FloatNDArray ();
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;
9835
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2506 }
1bb1ed717d2f implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents: 9812
diff changeset
2507
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2508 FloatNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2509 gammainc (const FloatNDArray& x, float a)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2510 {
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 FloatNDArray 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 FloatNDArray ();
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;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2527 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2528
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2529 FloatNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2530 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
2531 {
21786
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 FloatNDArray 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 FloatNDArray ();
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 Complex rc_log1p (double x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2561 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2562 const double pi = 3.14159265358979323846;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2563 return (x < -1.0
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2564 ? 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
2565 : Complex (log1p (x)));
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2568 FloatComplex rc_log1p (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2569 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2570 const float pi = 3.14159265358979323846f;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2571 return (x < -1.0f
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2572 ? 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
2573 : FloatComplex (log1p (x)));
14770
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
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 // 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
2577 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2578 // 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
2579 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2580 // 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
2581 // 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
2582 // 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
2583 // 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
2584
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2585 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
2586 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2587 // Coefficients of rational approximation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2588 static const double a[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2589 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2590 -2.806989788730439e+01, 1.562324844726888e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2591 -1.951109208597547e+02, 9.783370457507161e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2592 -2.168328665628878e+01, 1.772453852905383e+00
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 static const double b[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2595 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2596 -5.447609879822406e+01, 1.615858368580409e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2597 -1.556989798598866e+02, 6.680131188771972e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2598 -1.328068155288572e+01
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2599 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2600 static const double c[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2601 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2602 -5.504751339936943e-03, -2.279687217114118e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2603 -1.697592457770869e+00, -1.802933168781950e+00,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2604 3.093354679843505e+00, 2.077595676404383e+00
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 static const double d[] =
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 7.784695709041462e-03, 3.224671290700398e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2609 2.445134137142996e+00, 3.754408661907416e+00
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2612 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
2613 static const double pbreak = 0.95150;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2614 double ax = fabs (x), y;
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 // Select case.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2617 if (ax <= pbreak)
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 // Middle region.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2620 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
2621 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
2622 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
2623 y = yn / yd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2624 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2625 else if (ax < 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2626 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2627 // Tail region.
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2628 const double q = std::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
2629 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
2630 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
2631 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
2632 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2633 else if (ax == 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2634 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
2635 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2636 return octave::numeric_limits<double>::NaN ();
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 if (refine)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2639 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2640 // 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
2641 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
2642 y -= u / (1 + y*u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2643 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2644
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2645 return y;
14770
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
diff changeset
2646 }
cb85e836d035 New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14197
diff changeset
2647
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2648 double erfinv (double x)
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 return do_erfinv (x, true);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2651 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2652
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2653 float erfinv (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2654 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2655 return do_erfinv (x, false);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2656 }
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 // 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
2659 // 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
2660 // 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
2661 // explanation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2662
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2663 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
2664 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2665 // Coefficients of rational approximation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2666 static const double a[] =
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 -2.806989788730439e+01, 1.562324844726888e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2669 -1.951109208597547e+02, 9.783370457507161e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2670 -2.168328665628878e+01, 1.772453852905383e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2671 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2672 static const double b[] =
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 -5.447609879822406e+01, 1.615858368580409e+02,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2675 -1.556989798598866e+02, 6.680131188771972e+01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2676 -1.328068155288572e+01
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2677 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2678 static const double c[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2679 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2680 -5.504751339936943e-03, -2.279687217114118e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2681 -1.697592457770869e+00, -1.802933168781950e+00,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2682 3.093354679843505e+00, 2.077595676404383e+00
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2683 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2684 static const double d[] =
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2685 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2686 7.784695709041462e-03, 3.224671290700398e-01,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2687 2.445134137142996e+00, 3.754408661907416e+00
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2690 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
2691 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
2692 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
2693 double y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2694
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2695 // Select case.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2696 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
2697 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2698 // Middle region.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2699 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
2700 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
2701 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
2702 y = yn / yd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2703 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2704 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
2705 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2706 // Tail region.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2707 const double q = (x < 1
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2708 ? std::sqrt (-2*std::log (0.5*x))
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2709 : std::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
2710
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2711 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
2712
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2713 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
2714
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2715 y = yn / yd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2716
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2717 if (x < pbreak_lo)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2718 y = -y;
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 else if (x == 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2721 return octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2722 else if (x == 2.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2723 return -octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2724 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2725 return octave::numeric_limits<double>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2726
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2727 if (refine)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2728 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2729 // 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
2730 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
2731 y -= u / (1 + y*u);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2734 return y;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2735 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2736
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2737 double erfcinv (double x)
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 return do_erfcinv (x, true);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2742 float erfcinv (float x)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2743 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2744 return do_erfcinv (x, false);
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2745 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2746
21786
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 // Incomplete Beta function ratio
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2749 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2750 // 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
2751 // 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
2752 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2753 // 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
2754 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2755 // Reference:
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 // KL Majumder, GP Bhattacharjee,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2758 // Algorithm AS 63:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2759 // The incomplete Beta Integral,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2760 // Applied Statistics,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2761 // 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
2762 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2763 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2764 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
2765 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2766 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
2767 bool indx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2768 int ns;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2769 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
2770
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2771 value = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2772 err = false;
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 // Check the input arguments.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2775
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2776 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
2777 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2778 err = true;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2779 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2780 }
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 // Special cases.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2783
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2784 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
2785 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2786 return value;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2787 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2788
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2789 // 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
2790
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2791 psq = p + q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2792 cx = 1.0 - x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2793
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2794 if (p < psq * x)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2795 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2796 xx = cx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2797 cx = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2798 pp = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2799 qq = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2800 indx = true;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2801 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2802 else
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2803 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2804 xx = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2805 pp = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2806 qq = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2807 indx = false;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2808 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2809
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2810 term = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2811 ai = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2812 value = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2813 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
2814
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2815 // Use the Soper reduction formula.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2816
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2817 rx = xx / cx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2818 temp = qq - ai;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2819 if (ns == 0)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2820 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2821 rx = xx;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2822 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2823
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2824 for ( ; ; )
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2825 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2826 term *= temp * rx / (pp + ai);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2827 value += term;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2828 temp = fabs (term);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2829
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2830 if (temp <= acu && temp <= acu * value)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2831 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2832 value *= exp (pp * std::log (xx)
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2833 + (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
2834
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2835 if (indx)
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2836 {
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2837 value = 1.0 - value;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2838 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2839 break;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2842 ai += 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2843 ns -= 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2844
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2845 if (0 <= ns)
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 temp = qq - ai;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2848 if (ns == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2849 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2850 rx = xx;
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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2854 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2855 temp = psq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2856 psq += 1.0;
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 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2859
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2860 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2861 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2862
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2863 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2864 // Inverse of the incomplete Beta function
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2865 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2866 // 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
2867 // 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
2868 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2869 // 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
2870 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2871 // Reference:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2872 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2873 // GW Cran, KJ Martin, GE Thomas,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2874 // 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
2875 // 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
2876 // 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
2877 // Applied Statistics,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2878 // 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
2879 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2880 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2881 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
2882 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2883 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
2884 int iex;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2885 bool indx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2886 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
2887
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2888 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
2889 bool err = false;
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
2890 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
2891 value = y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2892
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2893 // Test for admissibility of parameters.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2894
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2895 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
2896 (*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
2897 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
2898 (*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
2899
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2900 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
2901 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2902
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2903 // Change tail if necessary.
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 if (0.5 < y)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2906 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2907 a = 1.0 - y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2908 pp = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2909 qq = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2910 indx = true;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2911 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2912 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2913 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2914 a = y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2915 pp = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2916 qq = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2917 indx = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2918 }
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 // Calculate the initial approximation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2921
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2922 r = std::sqrt (- std::log (a * a));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2923
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2924 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
2925
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2926 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
2927 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2928 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
2929 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
2930 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
2931 h = 2.0 / (s + t);
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2932 w = ycur * std::sqrt (h + r) / h - (t - s) * (r + 5.0 / 6.0 - 2.0 / (3.0 * h));
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2933 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
2934 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2935 else
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 r = qq + qq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2938 t = 1.0 / (9.0 * qq);
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2939 t = r * std::pow (1.0 - t + ycur * std::sqrt (t), 3);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2940
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2941 if (t <= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2942 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2943 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
2944 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2945 else
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 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
2948
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2949 if (t <= 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2950 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2951 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
2952 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2953 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2954 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2955 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
2956 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2957 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2958 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2959
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2960 // 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
2961 // using the function BETAIN.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2962
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2963 r = 1.0 - pp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2964 t = 1.0 - qq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2965 yprev = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2966 sq = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2967 prev = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2968
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2969 if (value < 0.0001)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2970 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2971 value = 0.0001;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2974 if (0.9999 < value)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2975 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2976 value = 0.9999;
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
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
2979 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
2980
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
2981 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
2982
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2983 for ( ; ; )
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2984 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2985 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
2986
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2987 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2988 {
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2989 return value;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2990 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2991
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2992 xin = value;
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2993 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
2994 + 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
2995
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2996 if (ycur * yprev <= 0.0)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2997 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2998 prev = std::max (sq, fpu);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2999 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3000
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3001 g = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3002
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3003 for ( ; ; )
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 for ( ; ; )
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3006 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3007 adj = g * ycur;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3008 sq = adj * adj;
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 if (sq < prev)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3011 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3012 tx = value - adj;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3013
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3014 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
3015 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3016 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3017 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3018 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3019 g /= 3.0;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3020 }
21786
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 if (prev <= acu)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3023 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3024 if (indx)
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 value = 1.0 - value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3027 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3028 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3029 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3030
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3031 if (ycur * ycur <= acu)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3032 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3033 if (indx)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3034 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3035 value = 1.0 - value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3036 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3037 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3038 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3039
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3040 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
3041 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3042 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3043 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3044
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3045 g /= 3.0;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3046 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3047
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3048 if (tx == value)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3049 {
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3050 break;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3051 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3052
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3053 value = tx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3054 yprev = ycur;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3055 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3056
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3057 if (indx)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3058 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3059 value = 1.0 - value;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3060 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3061
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3062 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3063 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3064
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3065 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3066 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
3067 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3068 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3069 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3070
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3071 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3072
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3073 double *pretval = retval.fortran_vec ();
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 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
3076 *pretval++ = betaincinv (x, a, b(i));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3077
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3078 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3079 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3080
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3081 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3082 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
3083 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3084 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3085 octave_idx_type nel = dv.numel ();
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 Array<double> retval (dv);
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 double *pretval = retval.fortran_vec ();
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 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
3092 *pretval++ = betaincinv (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3093
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3094 return retval;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3095 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3096
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3097 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3098 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
3099 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3100 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3101 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3102
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3103 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3104 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
3105
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3106 octave_idx_type nel = dv.numel ();
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 retval.resize (dv);
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 double *pretval = retval.fortran_vec ();
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 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
3113 *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
3114
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3115 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3116 }
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 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3119 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
3120 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3121 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3122 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3123
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3124 Array<double> retval (dv);
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 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3127
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3128 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
3129 *pretval++ = betaincinv (x(i), a, b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3130
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3131 return retval;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3132 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
3133
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3134 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3135 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
3136 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3137 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3138 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3139
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3140 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3141 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
3142
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3143 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3144
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3145 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3146
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3147 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3148
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3149 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
3150 *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
3151
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3152 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3153 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3154
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3155 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3156 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
3157 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3158 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3159 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3160
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3161 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3162 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
3163
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3164 octave_idx_type nel = dv.numel ();
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 retval.resize (dv);
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 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3169
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3170 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
3171 *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
3172
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3173 return retval;
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3174 }
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3175
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3176 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3177 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
3178 const Array<double>& b)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3179 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3180 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3181 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3182
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3183 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
3184 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
3185
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3186 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3187
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3188 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3189
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3190 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3191
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3192 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
3193 *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
3194
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3195 return retval;
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3196 }
21786
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 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3199 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
3200 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3201 static const int Nmax = 16;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3202 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
3203 int n, Nn, ii;
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 if (m < 0 || m > 1)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3206 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3207 (*current_liboctave_warning_with_id_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3208 ("Octave:ellipj-invalid-m",
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3209 "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
3210
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3211 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
3212
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3213 return;
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3214 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3215
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
3216 double sqrt_eps = std::sqrt (std::numeric_limits<double>::epsilon ());
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3217 if (m < sqrt_eps)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3218 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3219 // 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
3220 si_u = sin (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3221 co_u = cos (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3222 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
3223 sn = si_u - t * co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3224 cn = co_u + t * si_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3225 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
3226 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3227 else if ((1 - m) < sqrt_eps)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3228 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3229 // 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
3230 m1 = 1 - m;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3231 si_u = sinh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3232 co_u = cosh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3233 ta_u = tanh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3234 se_u = 1/co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3235 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
3236 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
3237 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
3238 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3239 else
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3240 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3241 // Arithmetic-Geometric Mean (AGM) algorithm
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3242 // (Abramowitz and Stegun, Section 16.4)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3243 a[0] = 1;
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
3244 b = std::sqrt (1 - m);
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
3245 c[0] = std::sqrt (m);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3246 for (n = 1; n < Nmax; ++n)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3247 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3248 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
3249 c[n] = (a[n - 1] - b)/2;
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
3250 b = std::sqrt (a[n - 1]*b);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3251 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
3252 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3253 if (n >= Nmax - 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3254 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3255 err = 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3256 return;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3257 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3258 Nn = n;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3259 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
3260 phi = ii*a[Nn]*u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3261 for (n = Nn; n > 0; --n)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3262 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3263 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
3264 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3265 sn = sin (phi);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3266 cn = cos (phi);
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
3267 dn = std::sqrt (1 - m*sn*sn);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3268 }
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3269 }
21786
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 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3272 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
3273 double& err)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3274 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3275 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
3276
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
3277 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
3278 if (u.real () == 0)
21786
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 // 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
3281 sn = Complex (0, ss1/cc1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3282 cn = 1/cc1; // cn.imag = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3283 dn = dd1/cc1; // dn.imag = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3284 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3285 else
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 // u is generic complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3288 double ss, cc, dd, ddd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3289
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
3290 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
3291 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
3292 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
3293 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
3294 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
3295 }
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3296 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3297
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3298 static const double pi = 3.14159265358979323846;
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 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3301 static inline T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3302 xlog (const T& x)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3303 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3304 return log (x);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3305 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3306
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3307 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3308 inline double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3309 xlog (const double& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3310 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3311 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3312 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3313
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3314 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3315 inline float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3316 xlog (const float& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3317 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3318 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3319 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3320
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3321 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3322 static T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3323 lanczos_approximation_psi (const T zc)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3324 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3325 // 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
3326 // 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
3327 // 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
3328 // 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
3329 static const T dg_coeff[10] =
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3330 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3331 -0.83333333333333333e-1, 0.83333333333333333e-2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3332 -0.39682539682539683e-2, 0.41666666666666667e-2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3333 -0.75757575757575758e-2, 0.21092796092796093e-1,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3334 -0.83333333333333333e-1, 0.4432598039215686,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3335 -0.3053954330270122e+1, 0.125318899521531e+2
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3336 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3337
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3338 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
3339 T overz2k = overz2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3340
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3341 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3342 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
3343 p += dg_coeff[k] * overz2k;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3344 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
3345 return p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3346 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3347
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3348 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3349 T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3350 xpsi (T z)
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3351 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3352 static const double euler_mascheroni =
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3353 0.577215664901532860606512090082402431042;
21786
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 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
3356
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3357 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3358 if (z <= 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3359 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3360 // limits - zeros of the gamma function
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3361 if (is_int)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3362 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
3363 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3364 // 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
3365 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
3366 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3367 else if (is_int)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3368 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3369 // 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
3370 p = - euler_mascheroni;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3371 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
3372 p += 1.0 / k;
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 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
3375 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3376 // 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
3377 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
3378 p += 1.0 / (2 * k - 1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3379
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3380 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
3381 }
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3382 else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3383 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3384 // adapted from XLiFE++ gammaFunctions
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3385
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3386 T zc = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3387 // 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
3388 if (z < 10)
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 const signed char n = 10 - z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3391 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
3392 p -= 1.0 / (k + z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3393 zc += n;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3394 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3395 p += lanczos_approximation_psi (zc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3396 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3397
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3398 return p;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3399 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3400
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3401 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3402 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
3403 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
3404
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3405 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3406 std::complex<T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3407 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
3408 {
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3409 // adapted from XLiFE++ gammaFunctions
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3410
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3411 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
3412
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3413 P z_r = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3414 P z_ra = z_r;
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 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
3417 if (z.imag () == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3418 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
3419 else if (z_r < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3420 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
3421 else
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3422 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3423 // 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
3424 std::complex<T> z_m = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3425 if (z_ra < 8)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3426 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3427 unsigned char n = 8 - z_ra;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3428 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
3429
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3430 // 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
3431 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3432 // 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
3433 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
3434 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
3435 dgam -= P (1.0) / z_p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3436 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3437
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3438 // 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
3439 // LogGamma
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3440 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3441 // 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
3442 // + 7/1680z^8 - 9/1188z^10 + ...
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3443 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3444 // (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
3445 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
3446 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3447 return dgam;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3448 }
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3449
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3450 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3451 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
3452 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
3453
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3454 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3455 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
3456 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
3457
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3458 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3459 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
3460 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
3461 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
3462 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22954
diff changeset
3463 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
3464 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
3465 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
3466 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
3467 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3468 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3469
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 void
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
3472 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
3473 float& ans, octave_idx_type& ierr)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3474 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22954
diff changeset
3475 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
3476 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
3477 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
3478 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
3479 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3480 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3481
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3482 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3483 T
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
3484 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
3485 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3486 T ans;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3487 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
3488 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
3489 if (ierr == 0)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3490 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3491 // 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
3492 // 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
3493 // 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
3494 if (n > 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3495 // 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
3496 // way too fast.
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3497 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
3498 else if (n == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3499 ans = -ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3500 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3501 else if (ierr == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3502 ans = - octave::numeric_limits<T>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3503 else // we probably never get here
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3504 ans = octave::numeric_limits<T>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3505
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3506 return ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3507 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3508
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3509 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
3510 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
3511 }
20161
65e22ba879f0 psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents: 20156
diff changeset
3512 }
65e22ba879f0 psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents: 20156
diff changeset
3513
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3514 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3515
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3516 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
3517 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
3518 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
3519 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
3520 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
3521 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
3522
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3523 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
3524 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
3525 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
3526 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
3527 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
3528 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
3529
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3530 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
3531 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
3532 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
3533 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
3534 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
3535 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
3536
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3537 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
3538 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
3539 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
3540 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
3541 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
3542 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
3543
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3544 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
3545 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
3546 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
3547 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
3548 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
3549 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
3550
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3551 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
3552 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
3553 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
3554 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
3555 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
3556 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
3557
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3558 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
3559 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
3560 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
3561 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
3562 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
3563 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
3564
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3565 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
3566 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
3567 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
3568 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
3569 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
3570 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
3571
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3572 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
3573 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
3574 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
3575 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
3576 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
3577 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
3578
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3579 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
3580 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
3581 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
3582 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
3583 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
3584 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
3585
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3586 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
3587 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
3588 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
3589 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
3590 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
3591 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
3592
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3593 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
3594 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
3595 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
3596 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
3597 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
3598 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
3599
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3600 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
3601 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
3602 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
3603 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
3604 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
3605 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
3606
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3607 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
3608 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
3609 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
3610 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
3611 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
3612 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
3613
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3614 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
3615 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
3616
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3617 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
3618 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
3619
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3620 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
3621 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
3622
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3623 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
3624 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
3625
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3626 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
3627 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
3628 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
3629
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3630 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
3631 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
3632 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
3633 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
3634
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3635 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
3636 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
3637 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
3638
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3639 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
3640 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
3641 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
3642 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
3643
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3644 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
3645 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
3646 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
3647
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3648 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
3649 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
3650 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
3651
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3652 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
3653 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
3654 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
3655
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3656 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
3657 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
3658 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
3659
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3660 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
3661 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
3662 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
3663
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3664 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
3665 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
3666 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
3667 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
3668
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3669 #endif