Mercurial > hg > octave-nkf
annotate liboctave/Quad.cc @ 10396:a0b51ac0f88a
optimize accumdim with summation
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 05 Mar 2010 12:31:30 +0100 |
parents | 12884915a8e4 |
children | 141b3fb5cef7 |
rev | line source |
---|---|
3 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2002, 2003, |
8920 | 4 2004, 2005, 2006, 2007, 2008 John W. Eaton |
3 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
3 | 21 |
22 */ | |
23 | |
238 | 24 #ifdef HAVE_CONFIG_H |
1192 | 25 #include <config.h> |
3 | 26 #endif |
27 | |
28 #include "Quad.h" | |
1847 | 29 #include "f77-fcn.h" |
2292 | 30 #include "lo-error.h" |
4180 | 31 #include "quit.h" |
3 | 32 #include "sun-utils.h" |
33 | |
34 static integrand_fcn user_fcn; | |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
35 static float_integrand_fcn float_user_fcn; |
3 | 36 |
5775 | 37 // FIXME -- would be nice to not have to have this global |
260 | 38 // variable. |
39 // Nonzero means an error occurred in the calculation of the integrand | |
40 // function, and the user wants us to quit. | |
41 int quad_integration_error = 0; | |
42 | |
5275 | 43 typedef octave_idx_type (*quad_fcn_ptr) (double*, int&, double*); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
44 typedef octave_idx_type (*quad_float_fcn_ptr) (float*, int&, float*); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
45 |
3 | 46 extern "C" |
4552 | 47 { |
48 F77_RET_T | |
49 F77_FUNC (dqagp, DQAGP) (quad_fcn_ptr, const double&, const double&, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
50 const octave_idx_type&, const double*, const double&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
51 const double&, double&, double&, octave_idx_type&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
52 octave_idx_type&, const octave_idx_type&, const octave_idx_type&, octave_idx_type&, octave_idx_type*, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
53 double*); |
3 | 54 |
4552 | 55 F77_RET_T |
5275 | 56 F77_FUNC (dqagi, DQAGI) (quad_fcn_ptr, const double&, const octave_idx_type&, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
57 const double&, const double&, double&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
58 double&, octave_idx_type&, octave_idx_type&, const octave_idx_type&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
59 const octave_idx_type&, octave_idx_type&, octave_idx_type*, double*); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
60 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
61 F77_RET_T |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
62 F77_FUNC (qagp, QAGP) (quad_float_fcn_ptr, const float&, const float&, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
63 const octave_idx_type&, const float*, const float&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
64 const float&, float&, float&, octave_idx_type&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
65 octave_idx_type&, const octave_idx_type&, const octave_idx_type&, octave_idx_type&, octave_idx_type*, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
66 float*); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
67 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
68 F77_RET_T |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
69 F77_FUNC (qagi, QAGI) (quad_float_fcn_ptr, const float&, const octave_idx_type&, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
70 const float&, const float&, float&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
71 float&, octave_idx_type&, octave_idx_type&, const octave_idx_type&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
72 const octave_idx_type&, octave_idx_type&, octave_idx_type*, float*); |
4552 | 73 } |
3 | 74 |
5275 | 75 static octave_idx_type |
3136 | 76 user_function (double *x, int& ierr, double *result) |
3 | 77 { |
4180 | 78 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
79 | |
9179
5be2e6696772
use access_double and assign_double on sparc only
Carsten Clark <tantumquantum+gnuoctave@gmail.com>
parents:
9169
diff
changeset
|
80 #if defined (__sparc) && defined (__GNUC__) |
3 | 81 double xx = access_double (x); |
82 #else | |
83 double xx = *x; | |
84 #endif | |
85 | |
260 | 86 quad_integration_error = 0; |
87 | |
3136 | 88 double xresult = (*user_fcn) (xx); |
89 | |
9179
5be2e6696772
use access_double and assign_double on sparc only
Carsten Clark <tantumquantum+gnuoctave@gmail.com>
parents:
9169
diff
changeset
|
90 #if defined (__sparc) && defined (__GNUC__) |
3136 | 91 assign_double (result, xresult); |
92 #else | |
93 *result = xresult; | |
94 #endif | |
260 | 95 |
96 if (quad_integration_error) | |
1251 | 97 ierr = -1; |
260 | 98 |
4180 | 99 END_INTERRUPT_WITH_EXCEPTIONS; |
100 | |
3136 | 101 return 0; |
3 | 102 } |
103 | |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
104 static octave_idx_type |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
105 float_user_function (float *x, int& ierr, float *result) |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
106 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
107 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
108 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
109 quad_integration_error = 0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
110 |
9169
b1e82cc8a9f3
eliminate broken special case for copying floats on Sun systems
Carsten Clark <tantumquantum+gnuoctave@gmail.com>
parents:
8920
diff
changeset
|
111 *result = (*float_user_fcn) (*x); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
112 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
113 if (quad_integration_error) |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
114 ierr = -1; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
115 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
116 END_INTERRUPT_WITH_EXCEPTIONS; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
117 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
118 return 0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
119 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
120 |
3 | 121 double |
5275 | 122 DefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr) |
3 | 123 { |
5275 | 124 octave_idx_type npts = singularities.capacity () + 2; |
3 | 125 double *points = singularities.fortran_vec (); |
126 double result = 0.0; | |
1935 | 127 |
5275 | 128 octave_idx_type leniw = 183*npts - 122; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
129 Array<octave_idx_type> iwork (leniw, 1); |
5275 | 130 octave_idx_type *piwork = iwork.fortran_vec (); |
1935 | 131 |
5275 | 132 octave_idx_type lenw = 2*leniw - npts; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
133 Array<double> work (lenw, 1); |
1935 | 134 double *pwork = work.fortran_vec (); |
135 | |
3 | 136 user_fcn = f; |
5275 | 137 octave_idx_type last; |
3 | 138 |
289 | 139 double abs_tol = absolute_tolerance (); |
140 double rel_tol = relative_tolerance (); | |
141 | |
1935 | 142 F77_XFCN (dqagp, DQAGP, (user_function, lower_limit, upper_limit, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
143 npts, points, abs_tol, rel_tol, result, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
144 abserr, neval, ier, leniw, lenw, last, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
145 piwork, pwork)); |
3 | 146 |
147 return result; | |
148 } | |
149 | |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
150 float |
7924 | 151 DefQuad::do_integrate (octave_idx_type&, octave_idx_type&, float&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
152 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
153 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
154 return 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
155 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
156 |
3 | 157 double |
5275 | 158 IndefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, double& abserr) |
3 | 159 { |
160 double result = 0.0; | |
1935 | 161 |
5275 | 162 octave_idx_type leniw = 128; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
163 Array<octave_idx_type> iwork (leniw, 1); |
5275 | 164 octave_idx_type *piwork = iwork.fortran_vec (); |
1935 | 165 |
5275 | 166 octave_idx_type lenw = 8*leniw; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
167 Array<double> work (lenw, 1); |
1935 | 168 double *pwork = work.fortran_vec (); |
169 | |
3 | 170 user_fcn = f; |
5275 | 171 octave_idx_type last; |
3 | 172 |
5275 | 173 octave_idx_type inf; |
3 | 174 switch (type) |
175 { | |
176 case bound_to_inf: | |
177 inf = 1; | |
178 break; | |
1360 | 179 |
3 | 180 case neg_inf_to_bound: |
181 inf = -1; | |
182 break; | |
1360 | 183 |
3 | 184 case doubly_infinite: |
185 inf = 2; | |
186 break; | |
1360 | 187 |
3 | 188 default: |
189 assert (0); | |
190 break; | |
191 } | |
192 | |
289 | 193 double abs_tol = absolute_tolerance (); |
194 double rel_tol = relative_tolerance (); | |
195 | |
1935 | 196 F77_XFCN (dqagi, DQAGI, (user_function, bound, inf, abs_tol, rel_tol, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
197 result, abserr, neval, ier, leniw, lenw, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
198 last, piwork, pwork)); |
3 | 199 |
200 return result; | |
201 } | |
202 | |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
203 float |
7924 | 204 IndefQuad::do_integrate (octave_idx_type&, octave_idx_type&, float&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
205 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
206 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
207 return 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
208 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
209 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
210 double |
7924 | 211 FloatDefQuad::do_integrate (octave_idx_type&, octave_idx_type&, double&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
212 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
213 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
214 return 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
215 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
216 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
217 float |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
218 FloatDefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr) |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
219 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
220 octave_idx_type npts = singularities.capacity () + 2; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
221 float *points = singularities.fortran_vec (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
222 float result = 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
223 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
224 octave_idx_type leniw = 183*npts - 122; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
225 Array<octave_idx_type> iwork (leniw, 1); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
226 octave_idx_type *piwork = iwork.fortran_vec (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
227 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
228 octave_idx_type lenw = 2*leniw - npts; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
229 Array<float> work (lenw, 1); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
230 float *pwork = work.fortran_vec (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
231 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
232 float_user_fcn = ff; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
233 octave_idx_type last; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
234 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
235 float abs_tol = single_precision_absolute_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
236 float rel_tol = single_precision_relative_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
237 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
238 F77_XFCN (qagp, QAGP, (float_user_function, lower_limit, upper_limit, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
239 npts, points, abs_tol, rel_tol, result, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
240 abserr, neval, ier, leniw, lenw, last, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
241 piwork, pwork)); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
242 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
243 return result; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
244 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
245 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
246 double |
7924 | 247 FloatIndefQuad::do_integrate (octave_idx_type&, octave_idx_type&, double&) |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
248 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
249 (*current_liboctave_error_handler) ("incorrect integration function called"); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
250 return 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
251 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
252 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
253 float |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
254 FloatIndefQuad::do_integrate (octave_idx_type& ier, octave_idx_type& neval, float& abserr) |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
255 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
256 float result = 0.0; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
257 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
258 octave_idx_type leniw = 128; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
259 Array<octave_idx_type> iwork (leniw, 1); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
260 octave_idx_type *piwork = iwork.fortran_vec (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
261 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
262 octave_idx_type lenw = 8*leniw; |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
263 Array<float> work (lenw, 1); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
264 float *pwork = work.fortran_vec (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
265 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
266 float_user_fcn = ff; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
267 octave_idx_type last; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
268 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
269 octave_idx_type inf; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
270 switch (type) |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
271 { |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
272 case bound_to_inf: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
273 inf = 1; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
274 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
275 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
276 case neg_inf_to_bound: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
277 inf = -1; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
278 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
279 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
280 case doubly_infinite: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
281 inf = 2; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
282 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
283 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
284 default: |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
285 assert (0); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
286 break; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
287 } |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
288 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
289 float abs_tol = single_precision_absolute_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
290 float rel_tol = single_precision_relative_tolerance (); |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
291 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
292 F77_XFCN (qagi, QAGI, (float_user_function, bound, inf, abs_tol, rel_tol, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
293 result, abserr, neval, ier, leniw, lenw, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
294 last, piwork, pwork)); |
7805
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
295 |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
296 return result; |
62affb34e648
Make quad work with single precision
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
297 } |