annotate liboctave/numeric/lo-specfun.cc @ 23668:a6eef0626b2b

Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h. * lo-specfun.cc (acosh, asinh, atanh, erf, erfc, lgamma, expm1, log1p, cbrt): Delete functions. * lo-specfun.cc: Alphabetize list of special functions. * lo-specfun.cc (acosh, asinh, atanh, erf, erfc, lgamma, expm1, log1p, cbrt): New inline functions that forward to std library. * lo-specfun.h: Alphabetize list of special functions.
author Rik <rik@octave.org>
date Wed, 21 Jun 2017 09:53:49 -0700
parents bd77ab816e43
children 6fe13cd3543c
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 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
63 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
64 bessel_return_value (const Complex& val, octave_idx_type ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
65 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
66 static const Complex inf_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
67 = Complex (octave::numeric_limits<double>::Inf (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
68 octave::numeric_limits<double>::Inf ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
69
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
70 static const Complex nan_val
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
71 = Complex (octave::numeric_limits<double>::NaN (),
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
72 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
73
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
74 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
75
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
76 switch (ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
77 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
78 case 0:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
79 case 3:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
80 retval = val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
81 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
82
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
83 case 2:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
84 retval = inf_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
85 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
86
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
87 default:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
88 retval = nan_val;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
89 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
90 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
91
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
92 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
93 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
94
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
95 static inline FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
96 bessel_return_value (const FloatComplex& val, octave_idx_type ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
97 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
98 static const FloatComplex inf_val
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
99 = FloatComplex (octave::numeric_limits<float>::Inf (),
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
100 octave::numeric_limits<float>::Inf ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
101
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
102 static const FloatComplex nan_val
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
103 = FloatComplex (octave::numeric_limits<float>::NaN (),
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
104 octave::numeric_limits<float>::NaN ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
105
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
106 FloatComplex retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
107
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
108 switch (ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
109 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
110 case 0:
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
111 case 3:
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
112 retval = val;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
113 break;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
114
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
115 case 2:
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
116 retval = inf_val;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
117 break;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
118
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
119 default:
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
120 retval = nan_val;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
121 break;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
122 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
123
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
124 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
125 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
126
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
127
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
128
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
129 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
130 airy (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
131 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
132 double ar = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
133 double ai = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
134
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
135 double zr = z.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
136 double zi = z.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
137
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
138 F77_INT id = (deriv ? 1 : 0);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
139 F77_INT nz, t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
140
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
141 F77_FUNC (zairy, ZAIRY) (zr, zi, id, 2, ar, ai, nz, t_ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
142
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
143 ierr = t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
144
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
145 if (! scaled)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
146 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
147 Complex expz = exp (- 2.0 / 3.0 * z * sqrt (z));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
148
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
149 double rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
150 double iexpz = expz.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
151
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
152 double tmp = ar*rexpz - ai*iexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
153
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
154 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
155 ar = tmp;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
156 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
157
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
158 if (zi == 0.0 && (! scaled || zr >= 0.0))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
159 ai = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
160
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
161 return bessel_return_value (Complex (ar, ai), ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
162 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
163
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
164 ComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
165 airy (const ComplexMatrix& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
166 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
167 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
168 octave_idx_type nr = z.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
169 octave_idx_type nc = z.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
170
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
171 ComplexMatrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
172
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
173 ierr.resize (dim_vector (nr, nc));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
174
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
175 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
176 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
177 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
178
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
179 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
180 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
181
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
182 ComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
183 airy (const ComplexNDArray& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
184 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
185 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
186 dim_vector dv = z.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
187 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
188 ComplexNDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
189
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
190 ierr.resize (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
191
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
192 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
193 retval(i) = airy (z(i), deriv, scaled, ierr(i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
194
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
195 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
196 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
197
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
198 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
199 airy (const FloatComplex& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
200 octave_idx_type& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
201 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
202 FloatComplex a;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
203
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
204 F77_INT id = (deriv ? 1 : 0);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
205 F77_INT nz, t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
206
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
207 F77_FUNC (cairy, CAIRY) (F77_CONST_CMPLX_ARG (&z), id, 2,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
208 F77_CMPLX_ARG (&a), nz, t_ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
209
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
210 ierr = t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
211
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
212 float ar = a.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
213 float ai = a.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
214
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
215 if (! scaled)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
216 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
217 FloatComplex expz = exp (- 2.0f / 3.0f * z * sqrt (z));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
218
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
219 float rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
220 float iexpz = expz.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
221
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
222 float tmp = ar*rexpz - ai*iexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
223
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
224 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
225 ar = tmp;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
226 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
227
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
228 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
229 ai = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
230
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
231 return bessel_return_value (FloatComplex (ar, ai), ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
232 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
233
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
234 FloatComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
235 airy (const FloatComplexMatrix& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
236 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
237 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
238 octave_idx_type nr = z.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
239 octave_idx_type nc = z.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
240
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
241 FloatComplexMatrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
242
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
243 ierr.resize (dim_vector (nr, nc));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
244
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
245 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
246 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
247 retval(i,j) = airy (z(i,j), deriv, scaled, ierr(i,j));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
248
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
249 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
250 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
251
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
252 FloatComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
253 airy (const FloatComplexNDArray& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
254 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
255 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
256 dim_vector dv = z.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
257 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
258 FloatComplexNDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
259
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
260 ierr.resize (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
261
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
262 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
263 retval(i) = airy (z(i), deriv, scaled, ierr(i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
264
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
265 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
266 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
267
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
268 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
269 is_integer_value (double x)
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 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
272 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
273
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
274 static inline Complex
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
275 zbesj (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
276
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
277 static inline Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
278 zbesy (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
279
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
280 static inline Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
281 zbesi (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
282
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
283 static inline Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
284 zbesk (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
285
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
286 static inline Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
287 zbesh1 (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
288
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
289 static inline Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
290 zbesh2 (const Complex& z, double alpha, int kode, octave_idx_type& ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
291
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
292 static inline Complex
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
293 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
294 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
295 Complex 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 (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
298 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
299 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
300 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
301
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
302 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
303
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
304 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
305 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
306
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
307 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
308
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
309 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
310
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
311 if (kode != 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
312 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
313 double expz = exp (std::abs (zi));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
314 yr *= expz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
315 yi *= expz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
316 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
317
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
318 if (zi == 0.0 && zr >= 0.0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
319 yi = 0.0;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
320
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
321 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
322 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
323 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
324 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
325 // 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
326 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
327 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
328 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
329 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
330 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
331 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
332 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
333 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
334 alpha = -alpha;
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 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
337
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
338 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
339 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
340 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
341
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
342 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
343 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
344 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
345 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
346 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
347 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
348
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
349 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
350 }
21786
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 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
353 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
354 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
355 Complex retval;
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 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
358 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
359 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
360 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
361
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
362 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
363
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
364 double wr, wi;
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 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
367 double zi = z.imag ();
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 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
370
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
371 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
372 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
373 yr = -octave::numeric_limits<double>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
374 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
375 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
376 else
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 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
379 &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
380
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
381 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
382
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
383 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
384 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
385 double expz = exp (std::abs (zi));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
386 yr *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
387 yi *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
388 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
389
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
390 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
391 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
392 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
393
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
394 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
395 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
396 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
397 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
398 // 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
399 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
400 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
401 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
402 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
403 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
404 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
405 else
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 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
408
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
409 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
410
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
411 if (ierr == 0 || ierr == 3)
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 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
414
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
415 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
416 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
417 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
418 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
419 octave::numeric_limits<double>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
420 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
421
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
422 return retval;
4911
14027e0bafa4 [project @ 2004-07-22 19:58:06 by jwe]
jwe
parents: 4844
diff changeset
423 }
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 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
426 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
427 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
428 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
429
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
430 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
431 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
432 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
433 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
434
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
435 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
436
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
437 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
438 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
439
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
440 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
441
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
442 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
443
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
444 if (kode != 2)
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 double expz = exp (std::abs (zr));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
447 yr *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
448 yi *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
449 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
450
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
451 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
452 yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
453
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
454 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
455 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
456 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
457 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
458 // 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
459 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
460 Complex tmp = zbesi (z, alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
461 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
462 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
463 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
464 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
465 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
466
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
467 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
468
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
469 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
470 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
471 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
472 * zbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
473
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
474 if (kode == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
475 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
476 // 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
477 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
478 }
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 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
481
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
482 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
483 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
484 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
485 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
486 octave::numeric_limits<double>::NaN ());
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
487 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
488
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
489 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
490 }
21786
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 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
493 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
494 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
495 Complex retval;
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 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
498 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
499 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
500 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
501
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
502 F77_INT nz, 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 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
505 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
506
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
507 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
508
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
509 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
510 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
511 yr = octave::numeric_limits<double>::Inf ();
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 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
515 {
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
516 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
517 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
518
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
519 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
520
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
521 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
522 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
523 Complex expz = exp (-z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
524
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
525 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
526 double iexpz = expz.imag ();
21786
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 double tmp = yr*rexpz - yi*iexpz;
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 yi = yr*iexpz + yi*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
531 yr = tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
532 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
533
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
534 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
535 yi = 0.0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
536 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
537
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
538 retval = bessel_return_value (Complex (yr, yi), ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
539 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
540 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
541 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
542 Complex tmp = zbesk (z, -alpha, kode, ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
543
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
544 retval = bessel_return_value (tmp, ierr);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
545 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
546
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
547 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
548 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
549
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
550 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
551 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
552 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
553 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
554
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
555 if (alpha >= 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
556 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
557 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
558 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
559
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
560 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
561
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
562 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
563 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
564
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
565 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
566 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
567
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
568 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
569
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
570 if (kode != 2)
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 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
573
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
574 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
575 double iexpz = expz.imag ();
21786
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 double tmp = yr*rexpz - yi*iexpz;
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 yi = yr*iexpz + yi*rexpz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
580 yr = tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
581 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
582
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
583 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
584 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
585 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
586 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
587 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
588
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
589 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
590
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
591 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
592
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
593 retval = bessel_return_value (tmp, ierr);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
596 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
597 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
598
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
599 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
600 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
601 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
602 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
603
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
604 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
605 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
606 double yr = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
607 double yi = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
608
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
609 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
610
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
611 double zr = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
612 double zi = z.imag ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
613
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
614 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
615 t_ierr);
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
616
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
617 ierr = t_ierr;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
618
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
619 if (kode != 2)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
620 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
621 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
622
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
623 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
624 double iexpz = expz.imag ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
625
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
626 double tmp = yr*rexpz - yi*iexpz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
627
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
628 yi = yr*iexpz + yi*rexpz;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
629 yr = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
630 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
631
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
632 retval = bessel_return_value (Complex (yr, yi), ierr);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10258
diff changeset
633 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
634 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
635 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
636 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
637
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
638 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
639
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
640 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
641
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
642 retval = bessel_return_value (tmp, ierr);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
645 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
646 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
647
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
648 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
649
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
650 static inline Complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
651 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
652 bool scaled, octave_idx_type& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
653 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
654 Complex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
655
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
656 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
657
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
658 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
659 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
660
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
661 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
662 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
663 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
664 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
665 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
666 octave_idx_type nc = x.cols ();
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 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
669
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
670 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
671
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
672 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
673 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
674 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
675
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
676 return retval;
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
677 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
678
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
679 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
680 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
681 bool scaled, Array<octave_idx_type>& ierr)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
682 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
683 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
684 octave_idx_type nc = alpha.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
685
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
686 ComplexMatrix retval (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
687
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
688 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
689
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
690 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
691 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
692 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
693
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
694 return retval;
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
695 }
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
696
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
697 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
698 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
699 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
700 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
701 ComplexMatrix retval;
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 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
704 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
705
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
706 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
707 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
708
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
709 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
710 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
711 ("%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
712
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
713 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
714 octave_idx_type nc = x_nc;
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 retval.resize (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
717
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
718 ierr.resize (dim_vector (nr, nc));
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 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
721 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
722 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
723
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
724 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
725 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
726
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
727 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
728 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
729 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
730 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
731 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
732 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
733 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
734
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
735 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
736
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
737 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
738 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
739
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
740 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
741 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
742
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
743 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
744 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
745 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
746 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
747 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
748 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
749 ComplexNDArray retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
750
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
751 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
752
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
753 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
754 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
755
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
756 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
757 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
758
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
759 static inline ComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
760 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
761 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
762 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
763 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
764 ComplexNDArray retval;
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 if (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
767 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
768 ("%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
769
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
770 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
771
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
772 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
773 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
774
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
775 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
776 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
777
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
778 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
779 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
780
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
781 static inline ComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
782 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
783 const ComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
784 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
785 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
786 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
787 octave_idx_type nc = alpha.numel ();
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), 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
796
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
797 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
798 }
3146
3d5aefef14e2 [project @ 1998-02-05 20:58:44 by jwe]
jwe
parents:
diff changeset
799
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
800 #define SS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
801 Complex \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
802 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
803 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
804 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
805 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
806
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
807 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
808 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
809 name (double alpha, const ComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
810 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
811 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
812 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
813 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
814
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
815 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
816 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
817 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
818 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
819 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
820 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
821 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
822
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
823 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
824 ComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
825 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
826 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
827 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
828 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
829 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
830
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
831 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
832 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
833 name (double alpha, const ComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
834 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
835 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
836 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
837 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
838
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
839 #define NS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
840 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
841 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
842 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
843 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
844 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
845 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
846
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
847 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
848 ComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
849 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
850 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
851 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
852 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
853 }
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
854
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
855 #define RC_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
856 ComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
857 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
858 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
859 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
860 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
861 }
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
862
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
863 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
864 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
865 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
866 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
867 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
868 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
869 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
870 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
871 RC_BESSEL (name, fcn)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
872
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
873 ALL_BESSEL (besselj, zbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
874 ALL_BESSEL (bessely, zbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
875 ALL_BESSEL (besseli, zbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
876 ALL_BESSEL (besselk, zbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
877 ALL_BESSEL (besselh1, zbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
878 ALL_BESSEL (besselh2, zbesh2)
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 #undef ALL_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
881 #undef SS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
882 #undef SM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
883 #undef MS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
884 #undef MM_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
885 #undef SN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
886 #undef NS_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
887 #undef NN_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
888 #undef RC_BESSEL
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
889
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
890 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
891 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
892
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
893 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
894 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
895
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
896 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
897 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
898
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
899 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
900 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
901
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
902 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
903 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
904
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
905 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
906 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
907
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
908 static inline bool
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
909 is_integer_value (float x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
910 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
911 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
912 }
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 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
915 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
916 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
917 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
918
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
919 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
920 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
921 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
922
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
923 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
924
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
925 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
926 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
927
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
928 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
929
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
930 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
931 {
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
932 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
933 y *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
934 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
935
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
936 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
937 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
938
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
939 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
940 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
941 else if (is_integer_value (alpha))
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
942 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
943 // zbesy can overflow as z->0, and cause troubles for generic case below
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
944 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
945 FloatComplex tmp = cbesj (z, alpha, kode, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
946 if ((static_cast<long> (alpha)) & 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
947 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
948 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
949 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
950 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
951 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
952 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
953
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
954 FloatComplex tmp = cosf (static_cast<float> (M_PI) * alpha)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
955 * cbesj (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
956
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
957 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
958 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
959 tmp -= sinf (static_cast<float> (M_PI) * alpha)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
960 * cbesy (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
961
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
962 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
963 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
964 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
965 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
966 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
967 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
968
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
969 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
970 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
971
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
972 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
973 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
974 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
975 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
976
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
977 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
978 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
979 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
980
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
981 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
982
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
983 FloatComplex w;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
984
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
985 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
986
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
987 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
988 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
989 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
990 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
991 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
992 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
993 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
994 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
995 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
996
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
997 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
998
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
999 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1000 {
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
1001 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
1002 y *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1003 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1004
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
1005 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
1006 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1007 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1008
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1009 return bessel_return_value (y, ierr);
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 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
1012 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1013 // 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
1014 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1015 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
1016 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
1017 tmp = - tmp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1018 retval = bessel_return_value (tmp, 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 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1021 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1022 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1023
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1024 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
1025 * cbesy (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1026
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1027 if (ierr == 0 || ierr == 3)
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 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
1030 * cbesj (z, alpha, kode, ierr);
21786
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 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1033 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1034 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1035 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
1036 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1037 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1038
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1039 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1040 }
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 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1043 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
1044 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1045 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1046
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1047 if (alpha >= 0.0)
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 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1050
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1051 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1052
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1053 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
1054 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
1055
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1056 ierr = t_ierr;
21786
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 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1059 {
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
1060 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
1061 y *= expz;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1062 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1063
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
1064 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
1065 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1066
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1067 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1068 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1069 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1070 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1071 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1072
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1073 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
1074
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1075 if (ierr == 0 || ierr == 3)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1076 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1077 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
1078 * sinf (static_cast<float> (M_PI) * alpha)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1079 * cbesk (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1080
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1081 if (kode == 2)
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 // 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
1084 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
1085 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1086
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1087 tmp += tmp2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1088
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1089 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1090 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1091 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1092 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
1093 octave::numeric_limits<float>::NaN ());
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1094 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1095
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1096 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1097 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1098
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1099 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1100 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
1101 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1102 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1103
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1104 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1105 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1106 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1107
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1108 F77_INT nz, t_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 ierr = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1111
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
1112 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
1113 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1114 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
1115 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1116 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1117 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1118 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
1119 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
1120
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1121 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1122
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1123 if (kode != 2)
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 FloatComplex expz = exp (-z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1126
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
1127 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
1128 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
1129
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
1130 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
1131 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
1132
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1133 y = FloatComplex (tmp_r, tmp_i);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1134 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1135
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
1136 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
1137 y = FloatComplex (y.real (), 0.0);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1138 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1139
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1140 retval = bessel_return_value (y, ierr);
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 else
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 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
1145
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1146 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1147 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1148
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1149 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1150 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1151
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1152 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1153 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
1154 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1155 FloatComplex retval;
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 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1158 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1159 FloatComplex y = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1160
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1161 F77_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1162
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1163 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
1164 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
1165
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1166 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1167
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1168 if (kode != 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1169 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1170 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
1171
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
1172 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
1173 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
1174
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
1175 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
1176 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
1177
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1178 y = FloatComplex (tmp_r, tmp_i);
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1181 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1182 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1183 else
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 alpha = -alpha;
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 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
1188
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1189 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
1190 * cbesh1 (z, alpha, kode, ierr);
21786
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 retval = bessel_return_value (tmp, ierr);
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1196 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1197
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1198 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1199 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
1200 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1201 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1202
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1203 if (alpha >= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1204 {
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
1205 FloatComplex y = 0.0;;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1206
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_INT nz, t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1208
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
1209 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
1210 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
1211
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1212 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1213
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1214 if (kode != 2)
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 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
1217
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
1218 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
1219 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
1220
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
1221 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
1222 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
1223
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1224 y = FloatComplex (tmp_r, tmp_i);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1225 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1226
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1227 retval = bessel_return_value (y, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1228 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1229 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1230 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1231 alpha = -alpha;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1232
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1233 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
1234
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1235 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
1236 * cbesh2 (z, alpha, kode, ierr);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1237
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1238 retval = bessel_return_value (tmp, ierr);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1239 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1240
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1241 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1242 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1243
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1244 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
1245 octave_idx_type&);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1246
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1247 static inline FloatComplex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1248 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
1249 bool scaled, octave_idx_type& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1250 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1251 FloatComplex retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1252
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1253 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
1254
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1255 return 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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1258 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1259 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
1260 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
1261 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1262 octave_idx_type nr = x.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1263 octave_idx_type nc = x.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1264
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1265 FloatComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
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 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
1270 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
1271 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
1272
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1273 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1274 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1275
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1276 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1277 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
1278 const FloatComplex& x,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1279 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
1280 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1281 octave_idx_type nr = alpha.rows ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1282 octave_idx_type nc = alpha.cols ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1283
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1284 FloatComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
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 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
1289 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
1290 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
1291
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1292 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1293 }
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 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1296 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
1297 const FloatComplexMatrix& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1298 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1299 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1300 FloatComplexMatrix retval;
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 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
1303 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
1304
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1305 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
1306 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
1307
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1308 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
1309 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1310 ("%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
1311
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1312 octave_idx_type nr = x_nr;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1313 octave_idx_type nc = x_nc;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1314
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1315 retval.resize (nr, nc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1316
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1317 ierr.resize (dim_vector (nr, nc));
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1318
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1319 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
1320 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
1321 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
1322
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1323 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1324 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1325
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1326 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1327 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
1328 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
1329 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1330 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1331 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1332 FloatComplexNDArray retval (dv);
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 ierr.resize (dv);
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 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
1337 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
1338
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1339 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1340 }
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 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1343 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
1344 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
1345 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1346 dim_vector dv = alpha.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1347 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1348 FloatComplexNDArray retval (dv);
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 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1351
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1352 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
1353 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
1354
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1355 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1356 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1357
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1358 static inline FloatComplexNDArray
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1359 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
1360 const FloatComplexNDArray& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1361 Array<octave_idx_type>& ierr)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1362 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1363 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1364 FloatComplexNDArray retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1365
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1366 if (dv != alpha.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1367 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1368 ("%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
1369
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1370 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1371
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1372 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1373 ierr.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1374
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1375 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
1376 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
1377
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1378 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1381 static inline FloatComplexMatrix
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1382 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
1383 const FloatComplexColumnVector& x, bool scaled,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1384 Array<octave_idx_type>& ierr)
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 octave_idx_type nr = x.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1387 octave_idx_type nc = alpha.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1388
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1389 FloatComplexMatrix retval (nr, nc);
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 ierr.resize (dim_vector (nr, nc));
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 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
1394 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
1395 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
1396
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1397 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1398 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1399
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1400 #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
1401 FloatComplex \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1402 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
1403 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
1404 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1405 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
1406 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1407
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1408 #define SM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1409 FloatComplexMatrix \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1410 name (float alpha, const FloatComplexMatrix& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1411 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1412 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1413 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
1414 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1415
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1416 #define MS_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1417 FloatComplexMatrix \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1418 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
1419 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1420 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1421 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
1422 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1423
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1424 #define MM_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1425 FloatComplexMatrix \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1426 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
1427 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1428 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1429 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
1430 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1431
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1432 #define SN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1433 FloatComplexNDArray \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1434 name (float alpha, const FloatComplexNDArray& x, bool scaled, \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1435 Array<octave_idx_type>& ierr) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1436 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1437 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
1438 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1439
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1440 #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
1441 FloatComplexNDArray \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1442 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
1443 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
1444 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1445 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
1446 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1447
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1448 #define NN_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1449 FloatComplexNDArray \
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1450 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
1451 bool scaled, Array<octave_idx_type>& ierr) \
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1452 { \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1453 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
1454 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1455
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1456 #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
1457 FloatComplexMatrix \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1458 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
1459 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
1460 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
1461 { \
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1462 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
1463 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1464
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1465 #define ALL_BESSEL(name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1466 SS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1467 SM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1468 MS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1469 MM_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1470 SN_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1471 NS_BESSEL (name, fcn) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
1472 NN_BESSEL (name, fcn) \
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1473 RC_BESSEL (name, fcn)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1474
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1475 ALL_BESSEL (besselj, cbesj)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1476 ALL_BESSEL (bessely, cbesy)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1477 ALL_BESSEL (besseli, cbesi)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1478 ALL_BESSEL (besselk, cbesk)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1479 ALL_BESSEL (besselh1, cbesh1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1480 ALL_BESSEL (besselh2, cbesh2)
3220
3deb1105fbc1 [project @ 1998-11-19 00:06:30 by jwe]
jwe
parents: 3164
diff changeset
1481
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1482 #undef ALL_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1483 #undef SS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1484 #undef SM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1485 #undef MS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1486 #undef MM_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1487 #undef SN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1488 #undef NS_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1489 #undef NN_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1490 #undef RC_BESSEL
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1491
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1492 OCTAVE_NORETURN static void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1493 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
1494 const dim_vector& d3)
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1495 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1496 std::string d1_str = d1.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1497 std::string d2_str = d2.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1498 std::string d3_str = d3.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1499
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1500 (*current_liboctave_error_handler)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1501 ("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
1502 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
1503 }
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4552
diff changeset
1504
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1505 OCTAVE_NORETURN static void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1506 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
1507 const dim_vector& d3)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1508 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1509 std::string d1_str = d1.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1510 std::string d2_str = d2.str ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1511 std::string d3_str = d3.str ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1512
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1513 (*current_liboctave_error_handler)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1514 ("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
1515 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
1516 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1517
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1518 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1519 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
1520 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1521 double retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1522 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
1523 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1526 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1527 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
1528 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1529 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1530 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1531
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1532 Array<double> retval (dv);
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 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1535
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1536 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
1537 *pretval++ = betainc (x, a, b(i));
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1540 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1541
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1542 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1543 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
1544 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1545 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1546 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1547
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1548 Array<double> retval (dv);
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 double *pretval = retval.fortran_vec ();
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 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
1553 *pretval++ = betainc (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1554
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1555 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1556 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1557
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1558 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1559 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
1560 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1561 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1562 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1563
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1564 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1565 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
1566
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1567 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1568
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1569 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1570
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1571 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1572
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1573 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
1574 *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
1575
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1576 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1577 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1578
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1579 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1580 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
1581 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1582 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1583 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1584
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1585 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1586
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1587 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1588
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1589 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
1590 *pretval++ = betainc (x(i), a, b);
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1593 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1594
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1595 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1596 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
1597 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1598 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1599 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1600
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1601 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1602 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
1603
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1604 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1605
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1606 retval.resize (dv);
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 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1609
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1610 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
1611 *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
1612
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1613 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1614 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1615
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1616 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1617 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
1618 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1619 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1620 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1621
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1622 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1623 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
1624
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1625 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1626
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1627 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1628
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1629 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1630
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1631 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
1632 *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
1633
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1634 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1635 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1636
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1637 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
1638 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
1639 const Array<double>& b)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1640 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1641 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1642 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1643
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1644 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
1645 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
1646
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1647 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1648
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1649 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1650
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1651 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1652
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1653 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
1654 *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
1655
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1656 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1657 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1658
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1659 float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1660 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
1661 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1662 float retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1663 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
1664 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1665 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1666
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1667 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1668 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
1669 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1670 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1671 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1672
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1673 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1674
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1675 float *pretval = retval.fortran_vec ();
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 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
1678 *pretval++ = betainc (x, a, b(i));
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1681 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1682
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1683 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1684 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
1685 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1686 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1687 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1688
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1689 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1690
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1691 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1692
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1693 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
1694 *pretval++ = betainc (x, a(i), b);
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1697 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1698
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1699 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1700 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
1701 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1702 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1703 dim_vector dv = a.dims ();
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 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1706 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
1707
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1708 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1709
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1710 retval.resize (dv);
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 float *pretval = retval.fortran_vec ();
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 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
1715 *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
1716
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1717 return retval;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21118
diff changeset
1718 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7638
diff changeset
1719
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1720 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1721 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
1722 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1723 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1724 octave_idx_type nel = dv.numel ();
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 Array<float> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1727
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1728 float *pretval = retval.fortran_vec ();
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 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
1731 *pretval++ = betainc (x(i), a, b);
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1734 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1735
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1736 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1737 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
1738 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1739 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1740 dim_vector dv = x.dims ();
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 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1743 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
1744
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1745 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1746
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1747 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1748
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1749 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1750
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1751 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
1752 *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
1753
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1754 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1755 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1756
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1757 Array<float>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1758 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
1759 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1760 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1761 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1762
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1763 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1764 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
1765
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1766 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1767
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1768 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1769
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1770 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1771
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1772 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
1773 *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
1774
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1775 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1778 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
1779 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
1780 const Array<float>& b)
21786
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 Array<float> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1783 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1784
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1785 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
1786 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
1787
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1788 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1789
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1790 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1791
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1792 float *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1793
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1794 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
1795 *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
1796
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1797 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1798 }
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 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1801 // Incomplete Beta function ratio
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1802 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1803 // 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
1804 // 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
1805 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1806 // 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
1807 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1808 // Reference:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1809 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1810 // KL Majumder, GP Bhattacharjee,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1811 // Algorithm AS 63:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1812 // The incomplete Beta Integral,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1813 // Applied Statistics,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1814 // 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
1815 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1816 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1817 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
1818 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1819 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
1820 bool indx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1821 int ns;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1822 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
1823
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1824 value = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1825 err = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1826
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1827 // Check the input arguments.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1828
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1829 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
1830 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1831 err = true;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1832 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1833 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1834
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1835 // Special cases.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1836
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1837 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
1838 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1839 return value;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1840 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1841
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1842 // 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
1843
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1844 psq = p + q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1845 cx = 1.0 - x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1846
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1847 if (p < psq * x)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1848 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1849 xx = cx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1850 cx = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1851 pp = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1852 qq = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1853 indx = true;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1854 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1855 else
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1856 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1857 xx = x;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1858 pp = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1859 qq = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1860 indx = false;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1861 }
21786
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 term = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1864 ai = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1865 value = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1866 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
1867
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1868 // Use the Soper reduction formula.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1869
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1870 rx = xx / cx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1871 temp = qq - ai;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1872 if (ns == 0)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1873 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1874 rx = xx;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1875 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1876
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1877 for ( ; ; )
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1878 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1879 term *= temp * rx / (pp + ai);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1880 value += term;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1881 temp = fabs (term);
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 if (temp <= acu && temp <= acu * value)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1884 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
1885 value *= exp (pp * std::log (xx)
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
1886 + (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
1887
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1888 if (indx)
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1889 {
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1890 value = 1.0 - value;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
1891 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1892 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1893 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1894
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1895 ai += 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1896 ns -= 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1897
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1898 if (0 <= ns)
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 temp = qq - ai;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1901 if (ns == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1902 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1903 rx = xx;
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 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1906 else
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 temp = psq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1909 psq += 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1910 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1911 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1912
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1913 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1914 }
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 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1917 // Inverse of the incomplete Beta function
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1918 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1919 // 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
1920 // 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
1921 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1922 // 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
1923 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1924 // Reference:
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1925 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1926 // GW Cran, KJ Martin, GE Thomas,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1927 // 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
1928 // 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
1929 // 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
1930 // Applied Statistics,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1931 // 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
1932 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1933 double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1934 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
1935 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1936 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
1937 int iex;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1938 bool indx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1939 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
1940
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1941 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
1942 bool err = false;
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
1943 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
1944 value = y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1945
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1946 // Test for admissibility of parameters.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1947
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1948 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
1949 (*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
1950 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
1951 (*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
1952
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1953 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
1954 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1955
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1956 // Change tail if necessary.
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 if (0.5 < y)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1959 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1960 a = 1.0 - y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1961 pp = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1962 qq = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1963 indx = true;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1964 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1965 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1966 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1967 a = y;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1968 pp = p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1969 qq = q;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1970 indx = false;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1971 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1972
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1973 // Calculate the initial approximation.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1974
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
1975 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
1976
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1977 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
1978
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1979 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
1980 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1981 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
1982 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
1983 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
1984 h = 2.0 / (s + t);
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
1985 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
1986 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
1987 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1988 else
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 r = qq + qq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1991 t = 1.0 / (9.0 * qq);
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
1992 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
1993
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1994 if (t <= 0.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1995 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
1996 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
1997 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1998 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
1999 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2000 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
2001
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2002 if (t <= 1.0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2003 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2004 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
2005 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2006 else
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 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
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 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2012
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2013 // 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
2014 // using the function BETAIN.
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2015
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2016 r = 1.0 - pp;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2017 t = 1.0 - qq;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2018 yprev = 0.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2019 sq = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2020 prev = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2021
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2022 if (value < 0.0001)
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 value = 0.0001;
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 if (0.9999 < value)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2028 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2029 value = 0.9999;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2030 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2031
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
2032 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
2033
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
2034 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
2035
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2036 for ( ; ; )
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 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
2039
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2040 if (err)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2041 {
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2042 return value;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2043 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2044
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2045 xin = value;
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
2046 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
2047 + 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
2048
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2049 if (ycur * yprev <= 0.0)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2050 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2051 prev = std::max (sq, fpu);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2052 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2053
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2054 g = 1.0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2055
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2056 for ( ; ; )
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2057 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2058 for ( ; ; )
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2059 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2060 adj = g * ycur;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2061 sq = adj * adj;
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 if (sq < prev)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2064 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2065 tx = value - adj;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2066
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2067 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
2068 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2069 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2070 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2071 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2072 g /= 3.0;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2073 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2074
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2075 if (prev <= acu)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2076 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2077 if (indx)
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 value = 1.0 - value;
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 return value;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2084 if (ycur * ycur <= acu)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2085 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2086 if (indx)
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 value = 1.0 - value;
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 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2091 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2092
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2093 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
2094 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2095 break;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2096 }
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 g /= 3.0;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2099 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2100
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2101 if (tx == value)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2102 {
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2103 break;
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2104 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2105
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2106 value = tx;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2107 yprev = ycur;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2108 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2109
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2110 if (indx)
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2111 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2112 value = 1.0 - value;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2113 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2114
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2115 return value;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2116 }
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 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2119 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
2120 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2121 dim_vector dv = b.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2122 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2123
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2124 Array<double> retval (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2125
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2126 double *pretval = retval.fortran_vec ();
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 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
2129 *pretval++ = betaincinv (x, a, b(i));
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 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2132 }
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<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2135 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
2136 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2137 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2138 octave_idx_type nel = dv.numel ();
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 Array<double> retval (dv);
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 double *pretval = retval.fortran_vec ();
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 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
2145 *pretval++ = betaincinv (x, a(i), b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2146
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2147 return retval;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2148 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2149
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2150 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2151 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
2152 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2153 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2154 dim_vector dv = a.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2155
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2156 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2157 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
2158
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2159 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2160
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2161 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2162
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2163 double *pretval = retval.fortran_vec ();
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 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
2166 *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
2167
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2168 return retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2169 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2170
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2171 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2172 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
2173 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2174 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2175 octave_idx_type nel = dv.numel ();
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 Array<double> retval (dv);
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 double *pretval = retval.fortran_vec ();
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 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
2182 *pretval++ = betaincinv (x(i), a, b);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2183
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2184 return retval;
14816
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2185 }
0a868d90436b New function: betaincinv (bug #34364)
Axel Mathéi <axel.mathei@gmail.com>
parents: 14815
diff changeset
2186
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2187 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2188 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
2189 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2190 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2191 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2192
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2193 if (dv != b.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2194 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
2195
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2196 octave_idx_type nel = dv.numel ();
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 retval.resize (dv);
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 double *pretval = retval.fortran_vec ();
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 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
2203 *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
2204
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2205 return retval;
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2208 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2209 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
2210 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2211 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2212 dim_vector dv = x.dims ();
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 if (dv != a.dims ())
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2215 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
2216
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2217 octave_idx_type nel = dv.numel ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2218
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2219 retval.resize (dv);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2220
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2221 double *pretval = retval.fortran_vec ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2222
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2223 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
2224 *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
2225
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2226 return retval;
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2227 }
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2228
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2229 Array<double>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2230 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
2231 const Array<double>& b)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2232 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2233 Array<double> retval;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2234 dim_vector dv = x.dims ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2235
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2236 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
2237 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
2238
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2239 octave_idx_type nel = dv.numel ();
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 retval.resize (dv);
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 *pretval = retval.fortran_vec ();
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 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
2246 *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
2247
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2248 return retval;
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2249 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2250
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2251 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2252 biry (const Complex& z, bool deriv, bool scaled, octave_idx_type& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2253 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2254 double ar = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2255 double ai = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2256
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2257 double zr = z.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2258 double zi = z.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2259
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2260 F77_INT id = (deriv ? 1 : 0);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2261 F77_INT t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2262
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2263 F77_FUNC (zbiry, ZBIRY) (zr, zi, id, 2, ar, ai, t_ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2264
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2265 ierr = t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2266
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2267 if (! scaled)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2268 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2269 Complex expz = exp (std::abs (std::real (2.0 / 3.0 * z * sqrt (z))));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2270
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2271 double rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2272 double iexpz = expz.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2273
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2274 double tmp = ar*rexpz - ai*iexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2275
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2276 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2277 ar = tmp;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2278 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2279
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2280 if (zi == 0.0 && (! scaled || zr >= 0.0))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2281 ai = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2282
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2283 return bessel_return_value (Complex (ar, ai), ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2284 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2285
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2286 ComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2287 biry (const ComplexMatrix& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2288 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2289 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2290 octave_idx_type nr = z.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2291 octave_idx_type nc = z.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2292
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2293 ComplexMatrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2294
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2295 ierr.resize (dim_vector (nr, nc));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2296
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2297 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2298 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2299 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2300
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2301 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2302 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2303
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2304 ComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2305 biry (const ComplexNDArray& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2306 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2307 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2308 dim_vector dv = z.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2309 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2310 ComplexNDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2311
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2312 ierr.resize (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2313
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2314 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2315 retval(i) = biry (z(i), deriv, scaled, ierr(i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2316
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2317 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2318 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2319
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2320 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2321 biry (const FloatComplex& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2322 octave_idx_type& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2323 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2324 FloatComplex a;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2325
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2326 F77_INT id = (deriv ? 1 : 0);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2327 F77_INT t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2328
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2329 F77_FUNC (cbiry, CBIRY) (F77_CONST_CMPLX_ARG (&z), id, 2,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2330 F77_CMPLX_ARG (&a), t_ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2331
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2332 ierr = t_ierr;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2333
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2334 float ar = a.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2335 float ai = a.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2336
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2337 if (! scaled)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2338 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2339 FloatComplex expz
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2340 = exp (std::abs (std::real (2.0f / 3.0f * z * sqrt (z))));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2341
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2342 float rexpz = expz.real ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2343 float iexpz = expz.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2344
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2345 float tmp = ar*rexpz - ai*iexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2346
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2347 ai = ar*iexpz + ai*rexpz;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2348 ar = tmp;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2349 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2350
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2351 if (z.imag () == 0.0 && (! scaled || z.real () >= 0.0))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2352 ai = 0.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2353
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2354 return bessel_return_value (FloatComplex (ar, ai), ierr);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2355 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2356
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2357 FloatComplexMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2358 biry (const FloatComplexMatrix& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2359 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2360 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2361 octave_idx_type nr = z.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2362 octave_idx_type nc = z.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2363
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2364 FloatComplexMatrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2365
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2366 ierr.resize (dim_vector (nr, nc));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2367
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2368 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2369 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2370 retval(i,j) = biry (z(i,j), deriv, scaled, ierr(i,j));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2371
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2372 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2373 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2374
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2375 FloatComplexNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2376 biry (const FloatComplexNDArray& z, bool deriv, bool scaled,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2377 Array<octave_idx_type>& ierr)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2378 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2379 dim_vector dv = z.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2380 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2381 FloatComplexNDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2382
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2383 ierr.resize (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2384
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2385 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2386 retval(i) = biry (z(i), deriv, scaled, ierr(i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2387
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2388 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2389 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2390
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2391 // Real and complex Dawson function (= scaled erfi) from Faddeeva package
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2392 double dawson (double x) { return Faddeeva::Dawson (x); }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2393 float dawson (float x) { return Faddeeva::Dawson (x); }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2394
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2395 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2396 dawson (const Complex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2397 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2398 return Faddeeva::Dawson (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2399 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2400
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2401 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2402 dawson (const FloatComplex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2403 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2404 Complex xd (x.real (), x.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2405 Complex ret;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2406 ret = Faddeeva::Dawson (xd, std::numeric_limits<float>::epsilon ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2407 return FloatComplex (ret.real (), ret.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2408 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2409
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2410 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2411 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
2412 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2413 static const int Nmax = 16;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2414 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
2415 int n, Nn, ii;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2416
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2417 if (m < 0 || m > 1)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2418 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2419 (*current_liboctave_warning_with_id_handler)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
2420 ("Octave:ellipj-invalid-m",
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
2421 "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
2422
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2423 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
2424
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2425 return;
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2426 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2427
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2428 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
2429 if (m < sqrt_eps)
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 // 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
2432 si_u = sin (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2433 co_u = cos (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2434 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
2435 sn = si_u - t * co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2436 cn = co_u + t * si_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2437 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
2438 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2439 else if ((1 - m) < sqrt_eps)
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 // 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
2442 m1 = 1 - m;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2443 si_u = sinh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2444 co_u = cosh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2445 ta_u = tanh (u);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2446 se_u = 1/co_u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2447 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
2448 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
2449 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
2450 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2451 else
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2452 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2453 // Arithmetic-Geometric Mean (AGM) algorithm
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2454 // (Abramowitz and Stegun, Section 16.4)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2455 a[0] = 1;
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2456 b = std::sqrt (1 - m);
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2457 c[0] = std::sqrt (m);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2458 for (n = 1; n < Nmax; ++n)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2459 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2460 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
2461 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
2462 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
2463 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
2464 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2465 if (n >= Nmax - 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2466 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2467 err = 1;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2468 return;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2469 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2470 Nn = n;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2471 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
2472 phi = ii*a[Nn]*u;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2473 for (n = Nn; n > 0; --n)
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 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
2476 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2477 sn = sin (phi);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2478 cn = cos (phi);
23649
aabf6cd222ac Use sqrt from C++ std library in liboctave.
Rik <rik@octave.org>
parents: 23648
diff changeset
2479 dn = std::sqrt (1 - m*sn*sn);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2480 }
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2481 }
21786
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 void
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2484 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
2485 double& err)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2486 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2487 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
2488
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
2489 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
2490 if (u.real () == 0)
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2491 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2492 // 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
2493 sn = Complex (0, ss1/cc1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2494 cn = 1/cc1; // cn.imag = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2495 dn = dd1/cc1; // dn.imag = 0;
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 else
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 // u is generic complex
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2500 double ss, cc, dd, ddd;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2501
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
2502 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
2503 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
2504 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
2505 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
2506 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
2507 }
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
2508 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
2509
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2510 // Complex error function from the Faddeeva package
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2511 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2512 erf (const Complex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2513 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2514 return Faddeeva::erf (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2515 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2516
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2517 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2518 erf (const FloatComplex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2519 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2520 Complex xd (x.real (), x.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2521 Complex ret = Faddeeva::erf (xd, std::numeric_limits<float>::epsilon ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2522 return FloatComplex (ret.real (), ret.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2523 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2524
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2525 // Complex complementary error function from the Faddeeva package
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2526 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2527 erfc (const Complex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2528 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2529 return Faddeeva::erfc (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2530 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2531
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2532 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2533 erfc (const FloatComplex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2534 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2535 Complex xd (x.real (), x.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2536 Complex ret = Faddeeva::erfc (xd, std::numeric_limits<float>::epsilon ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2537 return FloatComplex (ret.real (), ret.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2538 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2539
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2540 // The algorthim for erfcinv is an adaptation of the erfinv algorithm
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2541 // above from P. J. Acklam. It has been modified to run over the
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2542 // different input domain of erfcinv. See the notes for erfinv for an
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2543 // explanation.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2544
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2545 static double do_erfcinv (double x, bool refine)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2546 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2547 // Coefficients of rational approximation.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2548 static const double a[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2549 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2550 -2.806989788730439e+01, 1.562324844726888e+02,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2551 -1.951109208597547e+02, 9.783370457507161e+01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2552 -2.168328665628878e+01, 1.772453852905383e+00
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2553 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2554 static const double b[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2555 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2556 -5.447609879822406e+01, 1.615858368580409e+02,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2557 -1.556989798598866e+02, 6.680131188771972e+01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2558 -1.328068155288572e+01
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2559 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2560 static const double c[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2561 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2562 -5.504751339936943e-03, -2.279687217114118e-01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2563 -1.697592457770869e+00, -1.802933168781950e+00,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2564 3.093354679843505e+00, 2.077595676404383e+00
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2565 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2566 static const double d[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2567 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2568 7.784695709041462e-03, 3.224671290700398e-01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2569 2.445134137142996e+00, 3.754408661907416e+00
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2570 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2571
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2572 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2573 static const double pbreak_lo = 0.04850; // 1-pbreak
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2574 static const double pbreak_hi = 1.95150; // 1+pbreak
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2575 double y;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2576
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2577 // Select case.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2578 if (x >= pbreak_lo && x <= pbreak_hi)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2579 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2580 // Middle region.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2581 const double q = 0.5*(1-x), r = q*q;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2582 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2583 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2584 y = yn / yd;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2585 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2586 else if (x > 0.0 && x < 2.0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2587 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2588 // Tail region.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2589 const double q = (x < 1
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2590 ? std::sqrt (-2*std::log (0.5*x))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2591 : std::sqrt (-2*std::log (0.5*(2-x))));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2592
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2593 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5];
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2594
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2595 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2596
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2597 y = yn / yd;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2598
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2599 if (x < pbreak_lo)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2600 y = -y;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2601 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2602 else if (x == 0.0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2603 return octave::numeric_limits<double>::Inf ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2604 else if (x == 2.0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2605 return -octave::numeric_limits<double>::Inf ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2606 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2607 return octave::numeric_limits<double>::NaN ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2608
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2609 if (refine)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2610 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2611 // One iteration of Halley's method gives full precision.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2612 double u = (erf (y) - (1-x)) * spi2 * exp (y*y);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2613 y -= u / (1 + y*u);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2614 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2615
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2616 return y;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2617 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2618
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2619 double erfcinv (double x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2620 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2621 return do_erfcinv (x, true);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2622 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2623
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2624 float erfcinv (float x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2625 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2626 return do_erfcinv (x, false);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2627 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2628
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2629 // Real and complex scaled complementary error function from Faddeeva pkg.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2630 double erfcx (double x) { return Faddeeva::erfcx (x); }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2631 float erfcx (float x) { return Faddeeva::erfcx (x); }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2632
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2633 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2634 erfcx (const Complex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2635 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2636 return Faddeeva::erfcx (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2637 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2638
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2639 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2640 erfcx (const FloatComplex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2641 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2642 Complex xd (x.real (), x.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2643 Complex ret;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2644 ret = Faddeeva::erfcx (xd, std::numeric_limits<float>::epsilon ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2645 return FloatComplex (ret.real (), ret.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2646 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2647
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2648 // Real and complex imaginary error function from Faddeeva package
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2649 double erfi (double x) { return Faddeeva::erfi (x); }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2650 float erfi (float x) { return Faddeeva::erfi (x); }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2651
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2652 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2653 erfi (const Complex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2654 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2655 return Faddeeva::erfi (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2656 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2657
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2658 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2659 erfi (const FloatComplex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2660 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2661 Complex xd (x.real (), x.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2662 Complex ret = Faddeeva::erfi (xd, std::numeric_limits<float>::epsilon ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2663 return FloatComplex (ret.real (), ret.imag ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2664 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2665
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2666 // This algorithm is due to P. J. Acklam.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2667 //
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2668 // See http://home.online.no/~pjacklam/notes/invnorm/
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2669 //
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2670 // The rational approximation has relative accuracy 1.15e-9 in the whole
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2671 // region. For doubles, it is refined by a single step of Halley's 3rd
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2672 // order method. For single precision, the accuracy is already OK, so
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2673 // we skip it to get faster evaluation.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2674
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2675 static double do_erfinv (double x, bool refine)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2676 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2677 // Coefficients of rational approximation.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2678 static const double a[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2679 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2680 -2.806989788730439e+01, 1.562324844726888e+02,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2681 -1.951109208597547e+02, 9.783370457507161e+01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2682 -2.168328665628878e+01, 1.772453852905383e+00
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2683 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2684 static const double b[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2685 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2686 -5.447609879822406e+01, 1.615858368580409e+02,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2687 -1.556989798598866e+02, 6.680131188771972e+01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2688 -1.328068155288572e+01
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2689 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2690 static const double c[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2691 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2692 -5.504751339936943e-03, -2.279687217114118e-01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2693 -1.697592457770869e+00, -1.802933168781950e+00,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2694 3.093354679843505e+00, 2.077595676404383e+00
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2695 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2696 static const double d[] =
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2697 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2698 7.784695709041462e-03, 3.224671290700398e-01,
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2699 2.445134137142996e+00, 3.754408661907416e+00
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2700 };
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2701
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2702 static const double spi2 = 8.862269254527579e-01; // sqrt(pi)/2.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2703 static const double pbreak = 0.95150;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2704 double ax = fabs (x), y;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2705
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2706 // Select case.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2707 if (ax <= pbreak)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2708 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2709 // Middle region.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2710 const double q = 0.5 * x, r = q*q;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2711 const double yn = (((((a[0]*r + a[1])*r + a[2])*r + a[3])*r + a[4])*r + a[5])*q;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2712 const double yd = ((((b[0]*r + b[1])*r + b[2])*r + b[3])*r + b[4])*r + 1.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2713 y = yn / yd;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2714 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2715 else if (ax < 1.0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2716 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2717 // Tail region.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2718 const double q = std::sqrt (-2*std::log (0.5*(1-ax)));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2719 const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5];
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2720 const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2721 y = yn / yd * octave::math::signum (-x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2722 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2723 else if (ax == 1.0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2724 return octave::numeric_limits<double>::Inf () * octave::math::signum (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2725 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2726 return octave::numeric_limits<double>::NaN ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2727
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2728 if (refine)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2729 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2730 // One iteration of Halley's method gives full precision.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2731 double u = (erf (y) - x) * spi2 * exp (y*y);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2732 y -= u / (1 + y*u);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2733 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2734
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2735 return y;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2736 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2737
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2738 double erfinv (double x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2739 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2740 return do_erfinv (x, true);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2741 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2742
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2743 float erfinv (float x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2744 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2745 return do_erfinv (x, false);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2746 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2747
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2748 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2749 expm1 (const Complex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2750 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2751 Complex retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2752
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2753 if (std:: abs (x) < 1)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2754 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2755 double im = x.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2756 double u = expm1 (x.real ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2757 double v = sin (im/2);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2758 v = -2*v*v;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2759 retval = Complex (u*v + u + v, (u+1) * sin (im));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2760 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2761 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2762 retval = std::exp (x) - Complex (1);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2763
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2764 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2765 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2766
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2767 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2768 expm1 (const FloatComplex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2769 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2770 FloatComplex retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2771
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2772 if (std:: abs (x) < 1)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2773 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2774 float im = x.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2775 float u = expm1 (x.real ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2776 float v = sin (im/2);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2777 v = -2*v*v;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2778 retval = FloatComplex (u*v + u + v, (u+1) * sin (im));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2779 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2780 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2781 retval = std::exp (x) - FloatComplex (1);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2782
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2783 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2784 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2785
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2786 double
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2787 gamma (double x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2788 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2789 double result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2790
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2791 // Special cases for (near) compatibility with Matlab instead of tgamma.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2792 // Matlab does not have -0.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2793
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2794 if (x == 0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2795 result = (octave::math::negative_sign (x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2796 ? -octave::numeric_limits<double>::Inf ()
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2797 : octave::numeric_limits<double>::Inf ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2798 else if ((x < 0 && octave::math::x_nint (x) == x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2799 || octave::math::isinf (x))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2800 result = octave::numeric_limits<double>::Inf ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2801 else if (octave::math::isnan (x))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2802 result = octave::numeric_limits<double>::NaN ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2803 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2804 result = std::tgamma (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2805
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2806 return result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2807 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2808
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2809 float
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2810 gamma (float x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2811 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2812 float result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2813
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2814 // Special cases for (near) compatibility with Matlab instead of tgamma.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2815 // Matlab does not have -0.
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2816
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2817 if (x == 0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2818 result = (octave::math::negative_sign (x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2819 ? -octave::numeric_limits<float>::Inf ()
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2820 : octave::numeric_limits<float>::Inf ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2821 else if ((x < 0 && octave::math::x_nint (x) == x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2822 || octave::math::isinf (x))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2823 result = octave::numeric_limits<float>::Inf ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2824 else if (octave::math::isnan (x))
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2825 result = octave::numeric_limits<float>::NaN ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2826 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2827 result = std::tgammaf (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2828
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2829 return result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2830 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2831
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2832 // FIXME: there is still room for improvement here...
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2833
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2834 double
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2835 gammainc (double x, double a, bool& err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2836 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2837 if (a < 0.0 || x < 0.0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2838 (*current_liboctave_error_handler)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2839 ("gammainc: A and X must be non-negative");
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2840
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2841 err = false;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2842
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2843 double retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2844
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2845 F77_XFCN (xgammainc, XGAMMAINC, (a, x, retval));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2846
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2847 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2848 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2849
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2850 Matrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2851 gammainc (double x, const Matrix& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2852 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2853 octave_idx_type nr = a.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2854 octave_idx_type nc = a.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2855
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2856 Matrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2857
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2858 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2859
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2860 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2861 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2862 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2863 retval(i,j) = gammainc (x, a(i,j), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2864
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2865 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2866 return Matrix ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2867 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2868
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2869 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2870 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2871
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2872 Matrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2873 gammainc (const Matrix& x, double a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2874 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2875 octave_idx_type nr = x.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2876 octave_idx_type nc = x.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2877
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2878 Matrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2879
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2880 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2881
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2882 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2883 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2884 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2885 retval(i,j) = gammainc (x(i,j), a, err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2886
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2887 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2888 return Matrix ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2889 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2890
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2891 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2892 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2893
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2894 Matrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2895 gammainc (const Matrix& x, const Matrix& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2896 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2897 octave_idx_type nr = x.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2898 octave_idx_type nc = x.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2899
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2900 octave_idx_type a_nr = a.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2901 octave_idx_type a_nc = a.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2902
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2903 if (nr != a_nr || nc != a_nc)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2904 (*current_liboctave_error_handler)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2905 ("gammainc: nonconformant arguments (arg 1 is %dx%d, arg 2 is %dx%d)",
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2906 nr, nc, a_nr, a_nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2907
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2908 Matrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2909
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2910 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2911
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2912 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2913 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2914 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2915 retval(i,j) = gammainc (x(i,j), a(i,j), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2916
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2917 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2918 return Matrix ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2919 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2920
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2921 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2922 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2923
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2924 NDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2925 gammainc (double x, const NDArray& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2926 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2927 dim_vector dv = a.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2928 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2929
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2930 NDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2931
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2932 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2933
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2934 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2935 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2936 retval(i) = gammainc (x, a(i), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2937
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2938 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2939 return NDArray ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2940 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2941
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2942 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2943 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2944
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2945 NDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2946 gammainc (const NDArray& x, double a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2947 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2948 dim_vector dv = x.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2949 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2950
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2951 NDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2952
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2953 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2954
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2955 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2956 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2957 retval(i) = gammainc (x(i), a, err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2958
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2959 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2960 return NDArray ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2961 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2962
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2963 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2964 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2965
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2966 NDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2967 gammainc (const NDArray& x, const NDArray& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2968 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2969 dim_vector dv = x.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2970 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2971
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2972 if (dv != a.dims ())
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2973 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2974 std::string x_str = dv.str ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2975 std::string a_str = a.dims ().str ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2976
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2977 (*current_liboctave_error_handler)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2978 ("gammainc: nonconformant arguments (arg 1 is %s, arg 2 is %s)",
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2979 x_str.c_str (), a_str.c_str ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2980 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2981
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2982 NDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2983
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2984 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2985
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2986 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2987 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2988 retval(i) = gammainc (x(i), a(i), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2989
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2990 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2991 return NDArray ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2992 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2993
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2994 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2995 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2996
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2997 float
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2998 gammainc (float x, float a, bool& err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
2999 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3000 if (a < 0.0 || x < 0.0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3001 (*current_liboctave_error_handler)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3002 ("gammainc: A and X must be non-negative");
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3003
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3004 err = false;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3005
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3006 float retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3007
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3008 F77_XFCN (xsgammainc, XSGAMMAINC, (a, x, retval));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3009
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3010 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3011 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3012
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3013 FloatMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3014 gammainc (float x, const FloatMatrix& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3015 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3016 octave_idx_type nr = a.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3017 octave_idx_type nc = a.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3018
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3019 FloatMatrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3020
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3021 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3022
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3023 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3024 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3025 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3026 retval(i,j) = gammainc (x, a(i,j), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3027
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3028 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3029 return FloatMatrix ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3030 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3031
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3032 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3033 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3034
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3035 FloatMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3036 gammainc (const FloatMatrix& x, float a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3037 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3038 octave_idx_type nr = x.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3039 octave_idx_type nc = x.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3040
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3041 FloatMatrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3042
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3043 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3044
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3045 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3046 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3047 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3048 retval(i,j) = gammainc (x(i,j), a, err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3049
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3050 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3051 return FloatMatrix ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3052 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3053
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3054 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3055 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3056
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3057 FloatMatrix
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3058 gammainc (const FloatMatrix& x, const FloatMatrix& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3059 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3060 octave_idx_type nr = x.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3061 octave_idx_type nc = x.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3062
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3063 octave_idx_type a_nr = a.rows ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3064 octave_idx_type a_nc = a.cols ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3065
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3066 if (nr != a_nr || nc != a_nc)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3067 (*current_liboctave_error_handler)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3068 ("gammainc: nonconformant arguments (arg 1 is %dx%d, arg 2 is %dx%d)",
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3069 nr, nc, a_nr, a_nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3070
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3071 FloatMatrix retval (nr, nc);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3072
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3073 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3074
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3075 for (octave_idx_type j = 0; j < nc; j++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3076 for (octave_idx_type i = 0; i < nr; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3077 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3078 retval(i,j) = gammainc (x(i,j), a(i,j), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3079
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3080 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3081 return FloatMatrix ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3082 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3083
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3084 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3085 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3086
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3087 FloatNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3088 gammainc (float x, const FloatNDArray& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3089 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3090 dim_vector dv = a.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3091 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3092
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3093 FloatNDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3094
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3095 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3096
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3097 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3098 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3099 retval(i) = gammainc (x, a(i), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3100
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3101 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3102 return FloatNDArray ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3103 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3104
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3105 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3106 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3107
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3108 FloatNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3109 gammainc (const FloatNDArray& x, float a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3110 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3111 dim_vector dv = x.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3112 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3113
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3114 FloatNDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3115
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3116 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3117
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3118 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3119 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3120 retval(i) = gammainc (x(i), a, err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3121
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3122 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3123 return FloatNDArray ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3124 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3125
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3126 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3127 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3128
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3129 FloatNDArray
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3130 gammainc (const FloatNDArray& x, const FloatNDArray& a)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3131 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3132 dim_vector dv = x.dims ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3133 octave_idx_type nel = dv.numel ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3134
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3135 if (dv != a.dims ())
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3136 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3137 std::string x_str = dv.str ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3138 std::string a_str = a.dims ().str ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3139
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3140 (*current_liboctave_error_handler)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3141 ("gammainc: nonconformant arguments (arg 1 is %s, arg 2 is %s)",
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3142 x_str.c_str (), a_str.c_str ());
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3143 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3144
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3145 FloatNDArray retval (dv);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3146
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3147 bool err;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3148
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3149 for (octave_idx_type i = 0; i < nel; i++)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3150 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3151 retval(i) = gammainc (x(i), a(i), err);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3152
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3153 if (err)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3154 return FloatNDArray ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3155 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3156
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3157 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3158 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3159
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3160 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3161 log1p (const Complex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3162 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3163 Complex retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3164
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3165 double r = x.real (), i = x.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3166
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3167 if (fabs (r) < 0.5 && fabs (i) < 0.5)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3168 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3169 double u = 2*r + r*r + i*i;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3170 retval = Complex (log1p (u / (1+std::sqrt (u+1))),
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3171 atan2 (1 + r, i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3172 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3173 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3174 retval = std::log (Complex (1) + x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3175
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3176 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3177 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3178
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3179 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3180 log1p (const FloatComplex& x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3181 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3182 FloatComplex retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3183
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3184 float r = x.real (), i = x.imag ();
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3185
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3186 if (fabs (r) < 0.5 && fabs (i) < 0.5)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3187 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3188 float u = 2*r + r*r + i*i;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3189 retval = FloatComplex (log1p (u / (1+std::sqrt (u+1))),
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3190 atan2 (1 + r, i));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3191 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3192 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3193 retval = std::log (FloatComplex (1) + x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3194
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3195 return retval;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3196 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3197
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3198 static const double pi = 3.14159265358979323846;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3199
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3200 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3201 static inline T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3202 xlog (const T& x)
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3203 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3204 return log (x);
17502
578805a293e5 ellipj: Move numerical code into liboctave
Mike Miller <mtmiller@ieee.org>
parents: 15852
diff changeset
3205 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3206
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3207 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3208 inline double
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3209 xlog (const double& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3210 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3211 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3212 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3213
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3214 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3215 inline float
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3216 xlog (const float& x)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3217 {
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3218 return std::log (x);
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3219 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3220
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3221 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3222 static T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3223 lanczos_approximation_psi (const T zc)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3224 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3225 // 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
3226 // 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
3227 // 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
3228 // 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
3229 static const T dg_coeff[10] =
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3230 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3231 -0.83333333333333333e-1, 0.83333333333333333e-2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3232 -0.39682539682539683e-2, 0.41666666666666667e-2,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3233 -0.75757575757575758e-2, 0.21092796092796093e-1,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3234 -0.83333333333333333e-1, 0.4432598039215686,
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3235 -0.3053954330270122e+1, 0.125318899521531e+2
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3236 };
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3237
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3238 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
3239 T overz2k = overz2;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3240
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3241 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3242 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
3243 p += dg_coeff[k] * overz2k;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3244 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
3245 return p;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3246 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3247
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3248 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3249 T
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3250 xpsi (T z)
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3251 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3252 static const double euler_mascheroni =
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
3253 0.577215664901532860606512090082402431042;
21786
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 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
3256
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3257 T p = 0;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3258 if (z <= 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3259 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3260 // limits - zeros of the gamma function
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3261 if (is_int)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3262 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
3263 else
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3264 // 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
3265 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
3266 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3267 else if (is_int)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3268 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3269 // 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
3270 p = - euler_mascheroni;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3271 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
3272 p += 1.0 / k;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3273 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3274 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
3275 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3276 // 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
3277 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
3278 p += 1.0 / (2 * k - 1);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3279
21942
aab79a1885cc limit gnulib headers to liboctave/wrappers directory
John W. Eaton <jwe@octave.org>
parents: 21786
diff changeset
3280 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
3281 }
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3282 else
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3283 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3284 // adapted from XLiFE++ gammaFunctions
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3285
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3286 T zc = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3287 // 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
3288 if (z < 10)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3289 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3290 const signed char n = 10 - z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3291 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
3292 p -= 1.0 / (k + z);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3293 zc += n;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3294 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3295 p += lanczos_approximation_psi (zc);
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3296 }
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 return p;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3299 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3300
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3301 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3302 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
3303 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
3304
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3305 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3306 std::complex<T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3307 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
3308 {
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3309 // adapted from XLiFE++ gammaFunctions
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3310
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3311 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
3312
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3313 P z_r = z.real ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3314 P z_ra = z_r;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3315
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3316 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
3317 if (z.imag () == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3318 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
3319 else if (z_r < 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3320 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
3321 else
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3322 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3323 // 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
3324 std::complex<T> z_m = z;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3325 if (z_ra < 8)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3326 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3327 unsigned char n = 8 - z_ra;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3328 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
3329
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3330 // 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
3331 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3332 // 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
3333 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
3334 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
3335 dgam -= P (1.0) / z_p;
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 // 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
3339 // LogGamma
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 // 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
3342 // + 7/1680z^8 - 9/1188z^10 + ...
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3343 //
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3344 // (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
3345 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
3346 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3347 return dgam;
20154
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3348 }
45565ecec019 New function psi to compute the digamma function.
Carnë Draug <carandraug@octave.org>
parents: 19739
diff changeset
3349
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3350 // explicit instantiations
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3351 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
3352 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
3353
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3354 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3355 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
3356 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
3357
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3358 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3359 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
3360 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
3361 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
3362 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22954
diff changeset
3363 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
3364 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
3365 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
3366 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
3367 ierr = t_ierr;
21786
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
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3370 template <>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3371 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
3372 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
3373 float& ans, octave_idx_type& ierr)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3374 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22954
diff changeset
3375 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
3376 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
3377 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
3378 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
3379 ierr = t_ierr;
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3380 }
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3381
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3382 template <typename T>
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3383 T
22954
6cd3e9acf443 * lo-specfun.cc: Use F77_INT in calls to Fortran subroutines.
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
3384 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
3385 {
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3386 T ans;
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3387 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
3388 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
3389 if (ierr == 0)
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3390 {
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3391 // 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
3392 // 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
3393 // 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
3394 if (n > 1)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3395 // 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
3396 // way too fast.
23639
b488e958d024 Use modf, pow from C++ std library.
Rik <rik@octave.org>
parents: 23638
diff changeset
3397 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
3398 else if (n == 0)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3399 ans = -ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3400 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3401 else if (ierr == 2)
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3402 ans = - octave::numeric_limits<T>::Inf ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3403 else // we probably never get here
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3404 ans = octave::numeric_limits<T>::NaN ();
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3405
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3406 return ans;
20155
1fae49e34a1a psi: add support for complex numbers.
Carnë Draug <carandraug@octave.org>
parents: 20154
diff changeset
3407 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3408
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3409 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
3410 float psi (octave_idx_type n, float z) { return xpsi (n, z); }
23668
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3411
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3412 Complex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3413 rc_lgamma (double x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3414 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3415 double result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3416
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3417 #if defined (HAVE_LGAMMA_R)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3418 int sgngam;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3419 result = lgamma_r (x, &sgngam);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3420 #else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3421 result = std::lgamma (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3422 int sgngam = signgam;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3423 #endif
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3424
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3425 if (sgngam < 0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3426 return result + Complex (0., M_PI);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3427 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3428 return result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3429 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3430
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3431 FloatComplex
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3432 rc_lgamma (float x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3433 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3434 float result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3435
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3436 #if defined (HAVE_LGAMMAF_R)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3437 int sgngam;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3438 result = lgammaf_r (x, &sgngam);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3439 #else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3440 result = std::lgammaf (x);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3441 int sgngam = signgam;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3442 #endif
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3443
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3444 if (sgngam < 0)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3445 return result + FloatComplex (0., M_PI);
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3446 else
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3447 return result;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3448 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3449
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3450 Complex rc_log1p (double x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3451 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3452 const double pi = 3.14159265358979323846;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3453 return (x < -1.0
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3454 ? Complex (std::log (-(1.0 + x)), pi)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3455 : Complex (log1p (x)));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3456 }
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3457
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3458 FloatComplex rc_log1p (float x)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3459 {
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3460 const float pi = 3.14159265358979323846f;
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3461 return (x < -1.0f
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3462 ? FloatComplex (std::log (-(1.0f + x)), pi)
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3463 : FloatComplex (log1p (x)));
a6eef0626b2b Promote simple functions from lo-specfun.cc to inline versions in lo-specfun.h.
Rik <rik@octave.org>
parents: 23662
diff changeset
3464 }
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3465 }
20161
65e22ba879f0 psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents: 20156
diff changeset
3466 }
65e22ba879f0 psi: add support to compute the polygamma function (kth-derivative).
Carnë Draug <carandraug@octave.org>
parents: 20156
diff changeset
3467
21786
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3468 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
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 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
3471 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
3472 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
3473 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
3474 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
3475 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
3476
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3477 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
3478 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
3479 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
3480 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
3481 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
3482 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
3483
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3484 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
3485 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
3486 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
3487 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
3488 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
3489 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
3490
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3491 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
3492 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
3493 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
3494 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
3495 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
3496 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
3497
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3498 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
3499 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
3500 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
3501 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
3502 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
3503 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
3504
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3505 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
3506 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
3507 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
3508 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
3509 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
3510 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
3511
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3512 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
3513 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
3514 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
3515 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
3516 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
3517 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
3518
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3519 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
3520 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
3521 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
3522 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
3523 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
3524 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
3525
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3526 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
3527 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
3528 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
3529 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
3530 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
3531 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
3532
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3533 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
3534 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
3535 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
3536 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
3537 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
3538 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
3539
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3540 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
3541 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
3542 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
3543 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
3544 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
3545 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
3546
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3547 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
3548 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
3549 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
3550 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
3551 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
3552 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
3553
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3554 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
3555 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
3556 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
3557 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
3558 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
3559 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
3560
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3561 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
3562 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
3563 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
3564 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
3565 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
3566 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
3567
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3568 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
3569 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
3570
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3571 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
3572 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
3573
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3574 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
3575 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
3576
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3577 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
3578 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
3579
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3580 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
3581 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
3582 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
3583
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3584 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
3585 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
3586 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
3587 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
3588
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3589 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
3590 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
3591 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
3592
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3593 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
3594 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
3595 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
3596 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
3597
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3598 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
3599 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
3600 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
3601
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3602 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
3603 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
3604 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
3605
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3606 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
3607 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
3608 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
3609
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3610 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
3611 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
3612 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
3613
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3614 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
3615 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
3616 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
3617
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3618 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
3619 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
3620 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
3621 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
3622
df064166f180 use namespace for lo-specfun.h functions
John W. Eaton <jwe@octave.org>
parents: 21782
diff changeset
3623 #endif