ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
integration.hpp
Go to the documentation of this file.
1/*
2 * $Id: integration.hpp 293 2012-12-17 20:27:36Z jdl3 $
3 * Copyright (C) 2012, 2019, 2020 John D Lamb
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#ifndef CCGSL_INTEGRATION_HPP
21#define CCGSL_INTEGRATION_HPP
22
23#include<new>
24#include<algorithm>
25#include<gsl/gsl_integration.h>
26#include"exception.hpp"
27#include"function_scl.hpp"
28
29namespace gsl {
33 namespace integration {
37 class workspace {
38 public:
43 ccgsl_pointer = 0;
44 count = 0; // initially nullptr will do
45 }
46 // Refines random access container
47 // Refines assignable
52 explicit workspace( size_t const n ){
53 ccgsl_pointer = gsl_integration_workspace_alloc( n );
54 // just plausibly we could allocate workspace but not count
55 try { count = new size_t; } catch( std::bad_alloc& e ){
56 // try to tidy up before rethrowing
57 gsl_integration_workspace_free( ccgsl_pointer );
58 throw e;
59 }
60 *count = 1; // initially there is just one reference to ccgsl_pointer
61 }
68 explicit workspace( gsl_integration_workspace* v ){
69 ccgsl_pointer = v;
70 // just plausibly we could fail to allocate count: no further action needed.
71 count = new size_t;
72 *count = 1; // initially there is just one reference to ccgsl_pointer
73 }
74 // copy constructor
80 count = v.count; if( count != 0 ) ++*count; }
81 // assignment operator
87 // first, possibly delete anything pointed to by this
88 if( count == 0 or --*count == 0 ){
89 if( ccgsl_pointer != 0 ) gsl_integration_workspace_free( ccgsl_pointer );
90 delete count;
91 } // Then copy
92 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
93 }
94 // destructor
99 if( count == 0 or --*count == 0 ){
100 // could have allocated null pointer
101 if( ccgsl_pointer != 0 ) gsl_integration_workspace_free( ccgsl_pointer );
102 delete count;
103 }
104 }
105#ifdef __GXX_EXPERIMENTAL_CXX0X__
111 std::swap( count, v.count );
112 v.ccgsl_pointer = nullptr;
113 }
120 workspace( std::move( v ) ).swap( *this );
121 return *this;
122 }
123#endif
124 // Refines equality comparable
125 // == operator
132 bool operator==( workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
133 // != operator
140 bool operator!=( workspace const& v ) const { return not operator==( v ); }
141 // Refines forward container
142 // Refines less than comparable
143 // operator<
152 bool operator<( workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
153 // operator>
162 bool operator>( workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
163 // operator<=
172 bool operator<=( workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
173 // operator>=
182 bool operator>=( workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
187 bool empty() const { return ccgsl_pointer == 0; }
188 // swap() --- should work even if sizes don't match
194 void swap( workspace& v ){
195 std::swap( ccgsl_pointer, v.ccgsl_pointer );
196 std::swap( count, v.count );
197 }
198 private:
202 gsl_integration_workspace* ccgsl_pointer;
206 size_t* count;
207 public:
208 // shared reference functions
213 gsl_integration_workspace* get() const { return ccgsl_pointer; }
219 bool unique() const { return count != 0 and *count == 1; }
224 size_t use_count() const { return count == 0 ? 0 : *count; }
230#ifdef __GXX_EXPERIMENTAL_CXX0X__
231 explicit
232#endif
233 operator bool() const { return ccgsl_pointer != 0; }
234 };
239 public:
244 ccgsl_pointer = 0;
245 count = 0; // initially nullptr will do
246 }
247 // Refines random access container
248 // Refines assignable
260 explicit fixed_workspace( const gsl_integration_fixed_type * type, const size_t n,
261 const double a, const double b, const double alpha,
262 const double beta ){
263 ccgsl_pointer = gsl_integration_fixed_alloc( type, n, a, b, alpha, beta );
264 // just plausibly we could allocate workspace but not count
265 try { count = new size_t; } catch( std::bad_alloc& e ){
266 // try to tidy up before rethrowing
267 gsl_integration_fixed_free( ccgsl_pointer );
268 throw e;
269 }
270 *count = 1; // initially there is just one reference to ccgsl_pointer
271 }
278 explicit fixed_workspace( gsl_integration_fixed_workspace* v ){
279 ccgsl_pointer = v;
280 // just plausibly we could fail to allocate count: no further action needed.
281 count = new size_t;
282 *count = 1; // initially there is just one reference to ccgsl_pointer
283 }
284 // copy constructor
290 count = v.count; if( count != 0 ) ++*count; }
291 // assignment operator
297 // first, possibly delete anything pointed to by this
298 if( count == 0 or --*count == 0 ){
299 if( ccgsl_pointer != 0 ) gsl_integration_fixed_free( ccgsl_pointer );
300 delete count;
301 } // Then copy
302 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
303 }
304 // destructor
309 if( count == 0 or --*count == 0 ){
310 // could have allocated null pointer
311 if( ccgsl_pointer != 0 ) gsl_integration_fixed_free( ccgsl_pointer );
312 delete count;
313 }
314 }
315#ifdef __GXX_EXPERIMENTAL_CXX0X__
321 std::swap( count, v.count );
322 v.ccgsl_pointer = nullptr;
323 }
330 fixed_workspace( std::move( v ) ).swap( *this );
331 return *this;
332 }
333#endif
334 // Refines equality comparable
335 // == operator
342 bool operator==( fixed_workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
343 // != operator
350 bool operator!=( fixed_workspace const& v ) const { return not operator==( v ); }
351 // Refines forward container
352 // Refines less than comparable
353 // operator<
362 bool operator<( fixed_workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
363 // operator>
372 bool operator>( fixed_workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
373 // operator<=
382 bool operator<=( fixed_workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
383 // operator>=
392 bool operator>=( fixed_workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
397 bool empty() const { return ccgsl_pointer == 0; }
398 // swap() --- should work even if sizes don't match
405 std::swap( ccgsl_pointer, v.ccgsl_pointer );
406 std::swap( count, v.count );
407 }
408 private:
412 gsl_integration_fixed_workspace* ccgsl_pointer;
416 size_t* count;
417 public:
418 // shared reference functions
423 gsl_integration_fixed_workspace* get() const { return ccgsl_pointer; }
429 bool unique() const { return count != 0 and *count == 1; }
434 size_t use_count() const { return count == 0 ? 0 : *count; }
440#ifdef __GXX_EXPERIMENTAL_CXX0X__
441 explicit
442#endif
443 operator bool() const { return ccgsl_pointer != 0; }
444 };
445
450 public:
455 ccgsl_pointer = 0;
456 count = 0; // initially nullptr will do
457 }
458 // Refines random access container
459 // Refines assignable
469 explicit qaws_table( double const alpha, double const beta, double const mu,
470 double const nu ){
471 ccgsl_pointer = gsl_integration_qaws_table_alloc( alpha, beta, mu, nu );
472 // just plausibly we could allocate qaws_table but not count
473 try { count = new size_t; } catch( std::bad_alloc& e ){
474 // try to tidy up before rethrowing
475 gsl_integration_qaws_table_free( ccgsl_pointer );
476 throw e;
477 }
478 *count = 1; // initially there is just one reference to ccgsl_pointer
479 }
486 explicit qaws_table( gsl_integration_qaws_table* v ){
487 ccgsl_pointer = v;
488 // just plausibly we could fail to allocate count: no further action needed.
489 count = new size_t;
490 *count = 1; // initially there is just one reference to ccgsl_pointer
491 }
492 // copy constructor
498 count = v.count; if( count != 0 ) ++*count; }
499 // assignment operator
505 // first, possibly delete anything pointed to by this
506 if( count == 0 or --*count == 0 ){
507 if( ccgsl_pointer != 0 ) gsl_integration_qaws_table_free( ccgsl_pointer );
508 delete count;
509 } // Then copy
510 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
511 }
512 // destructor
517 if( count == 0 or --*count == 0 ){
518 // could have allocated null pointer
519 if( ccgsl_pointer != 0 ) gsl_integration_qaws_table_free( ccgsl_pointer );
520 delete count;
521 }
522 }
523#ifdef __GXX_EXPERIMENTAL_CXX0X__
529 std::swap( count, v.count );
530 v.ccgsl_pointer = nullptr;
531 }
538 qaws_table( std::move( v ) ).swap( *this );
539 return *this;
540 }
541#endif
542 // Refines equality comparable
543 // == operator
550 bool operator==( qaws_table const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
551 // != operator
558 bool operator!=( qaws_table const& v ) const { return not operator==( v ); }
559 // Refines forward container
560 // Refines less than comparable
561 // operator<
570 bool operator<( qaws_table const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
571 // operator>
580 bool operator>( qaws_table const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
581 // operator<=
590 bool operator<=( qaws_table const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
591 // operator>=
600 bool operator>=( qaws_table const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
605 bool empty() const { return ccgsl_pointer == 0; }
606 // swap() --- should work even if sizes don't match
612 void swap( qaws_table& v ){
613 std::swap( ccgsl_pointer, v.ccgsl_pointer );
614 std::swap( count, v.count );
615 }
616 private:
620 gsl_integration_qaws_table* ccgsl_pointer;
624 size_t* count;
625 public:
626 // shared reference functions
631 gsl_integration_qaws_table* get() const { return ccgsl_pointer; }
637 bool unique() const { return count != 0 and *count == 1; }
642 size_t use_count() const { return count == 0 ? 0 : *count; }
648#ifdef __GXX_EXPERIMENTAL_CXX0X__
649 explicit
650#endif
651 operator bool() const { return ccgsl_pointer != 0; }
652 };
653
663 inline int qaws_table_set( qaws_table& t, double const alpha, double const beta,
664 int const mu, int const nu ){
665 return gsl_integration_qaws_table_set( t.get(), alpha, beta, mu, nu ); }
666
670 enum qawo_enum {
671 SINE = GSL_INTEG_SINE,
672 COSINE = GSL_INTEG_COSINE
673 };
674
679 public:
684 ccgsl_pointer = 0;
685 count = 0; // initially nullptr will do
686 }
687 // Refines random access container
688 // Refines assignable
697 explicit qawo_table( double const omega, double const L,
698 qawo_enum const sine, size_t const n ){
700 = gsl_integration_qawo_table_alloc( omega, L,
701 static_cast<gsl_integration_qawo_enum>( sine ), n );
702 // just plausibly we could allocate qawo_table but not count
703 try { count = new size_t; } catch( std::bad_alloc& e ){
704 // try to tidy up before rethrowing
705 gsl_integration_qawo_table_free( ccgsl_pointer );
706 throw e;
707 }
708 *count = 1; // initially there is just one reference to ccgsl_pointer
709 }
716 explicit qawo_table( gsl_integration_qawo_table* v ){
717 ccgsl_pointer = v;
718 // just plausibly we could fail to allocate count: no further action needed.
719 count = new size_t;
720 *count = 1; // initially there is just one reference to ccgsl_pointer
721 }
722 // copy constructor
728 count = v.count; if( count != 0 ) ++*count; }
729 // assignment operator
735 // first, possibly delete anything pointed to by this
736 if( count == 0 or --*count == 0 ){
737 if( ccgsl_pointer != 0 ) gsl_integration_qawo_table_free( ccgsl_pointer );
738 delete count;
739 } // Then copy
740 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
741 }
742 // destructor
747 if( count == 0 or --*count == 0 ){
748 // could have allocated null pointer
749 if( ccgsl_pointer != 0 ) gsl_integration_qawo_table_free( ccgsl_pointer );
750 delete count;
751 }
752 }
753#ifdef __GXX_EXPERIMENTAL_CXX0X__
759 std::swap( count, v.count );
760 v.ccgsl_pointer = nullptr;
761 }
768 qawo_table( std::move( v ) ).swap( *this );
769 return *this;
770 }
771#endif
772 // Refines equality comparable
773 // == operator
780 bool operator==( qawo_table const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
781 // != operator
788 bool operator!=( qawo_table const& v ) const { return not operator==( v ); }
789 // Refines forward container
790 // Refines less than comparable
791 // operator<
800 bool operator<( qawo_table const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
801 // operator>
810 bool operator>( qawo_table const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
811 // operator<=
820 bool operator<=( qawo_table const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
821 // operator>=
830 bool operator>=( qawo_table const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
835 bool empty() const { return ccgsl_pointer == 0; }
836 // swap() --- should work even if sizes don't match
842 void swap( qawo_table& v ){
843 std::swap( ccgsl_pointer, v.ccgsl_pointer );
844 std::swap( count, v.count );
845 }
846 private:
850 gsl_integration_qawo_table* ccgsl_pointer;
854 size_t* count;
855 public:
856 // shared reference functions
861 gsl_integration_qawo_table* get() const { return ccgsl_pointer; }
867 bool unique() const { return count != 0 and *count == 1; }
872 size_t use_count() const { return count == 0 ? 0 : *count; }
878#ifdef __GXX_EXPERIMENTAL_CXX0X__
879 explicit
880#endif
881 operator bool() const { return ccgsl_pointer != 0; }
882 };
883
892 inline int qawo_table_set( qawo_table& t, double const omega, double const L,
893 qawo_enum const sine ){
894 return gsl_integration_qawo_table_set( t.get(), omega, L,
895 static_cast<gsl_integration_qawo_enum>( sine ) ); }
896
903 inline int qawo_table_set_length( qawo_table& t, double L ){
904 return gsl_integration_qawo_table_set_length( t.get(), L ); }
905
916 inline void qk15( function_scl const& f, double a, double b, double& result, double& abserr,
917 double& resabs, double& resasc ){
918 gsl_integration_qk15( &f, a, b, &result, &abserr, &resabs, &resasc ); }
919
920#ifndef DOXYGEN_SKIP
931 inline void qk15( gsl_function const* f, double a, double b, double* result, double* abserr,
932 double* resabs, double* resasc ){
933 gsl_integration_qk15( f, a, b, result, abserr, resabs, resasc ); }
934#endif /* DOXYGEN_SKIP */
935
946 inline void qk21( function_scl const& f, double a, double b, double& result, double& abserr,
947 double& resabs, double& resasc ){
948 gsl_integration_qk21( &f, a, b, &result, &abserr, &resabs, &resasc ); }
949
950#ifndef DOXYGEN_SKIP
961 inline void qk21( gsl_function const* f, double a, double b, double* result, double* abserr,
962 double* resabs, double* resasc ){
963 gsl_integration_qk21( f, a, b, result, abserr, resabs, resasc ); }
964#endif /* DOXYGEN_SKIP */
965
976 inline void qk31( function_scl const& f, double a, double b, double& result, double& abserr,
977 double& resabs, double& resasc ){
978 gsl_integration_qk31( &f, a, b, &result, &abserr, &resabs, &resasc ); }
979
980#ifndef DOXYGEN_SKIP
991 inline void qk31( gsl_function const* f, double a, double b, double* result, double* abserr,
992 double* resabs, double* resasc ){
993 gsl_integration_qk31( f, a, b, result, abserr, resabs, resasc ); }
994#endif /* DOXYGEN_SKIP */
995
1006 inline void qk41( function_scl const& f, double a, double b, double& result, double& abserr,
1007 double& resabs, double& resasc ){
1008 gsl_integration_qk41( &f, a, b, &result, &abserr, &resabs, &resasc ); }
1009
1010#ifndef DOXYGEN_SKIP
1021 inline void qk41( gsl_function const* f, double a, double b, double* result, double* abserr,
1022 double* resabs, double* resasc ){
1023 gsl_integration_qk41( f, a, b, result, abserr, resabs, resasc ); }
1024#endif /* DOXYGEN_SKIP */
1025
1036 inline void qk51( function_scl const& f, double a, double b, double& result, double& abserr,
1037 double& resabs, double& resasc ){
1038 gsl_integration_qk51( &f, a, b, &result, &abserr, &resabs, &resasc ); }
1039
1040#ifndef DOXYGEN_SKIP
1051 inline void qk51( gsl_function const* f, double a, double b, double* result, double* abserr,
1052 double* resabs, double* resasc ){
1053 gsl_integration_qk51( f, a, b, result, abserr, resabs, resasc ); }
1054#endif /* DOXYGEN_SKIP */
1055
1066 inline void qk61( function_scl const& f, double a, double b, double& result, double& abserr,
1067 double& resabs, double& resasc ){
1068 gsl_integration_qk61( &f, a, b, &result, &abserr, &resabs, &resasc ); }
1069
1070#ifndef DOXYGEN_SKIP
1081 inline void qk61( gsl_function const* f, double a, double b, double* result, double* abserr,
1082 double* resabs, double* resasc ){
1083 gsl_integration_qk61( f, a, b, result, abserr, resabs, resasc ); }
1084#endif /* DOXYGEN_SKIP */
1085
1086#ifndef DOXYGEN_SKIP
1095 inline void qcheb( function_scl& f, double a, double b, double* cheb12, double* cheb24 ){
1096 gsl_integration_qcheb( &f, a, b, cheb12, cheb24 ); }
1097
1106 inline void qcheb( gsl_function* f, double a, double b, double* cheb12, double* cheb24 ){
1107 gsl_integration_qcheb( f, a, b, cheb12, cheb24 ); }
1108#endif /* DOXYGEN_SKIP */
1109
1119 template<typename T>
1120 inline void qcheb( function_scl& f, double a, double b, T& cheb12, T& cheb24 ){
1121#ifndef GSL_RANGE_CHECK_OFF
1122 // Check that vectors are long enough
1123 if( cheb12.size() < 13 ){
1124 gsl_error( "expected cheb12 of length 13 (or more)",
1125 __FILE__, __LINE__, exception::GSL_EFAILED );
1126 return;
1127 }
1128 if( cheb24.size() < 25 ){
1129 gsl_error( "expected cheb24 of length 25 (or more)",
1130 __FILE__, __LINE__, exception::GSL_EFAILED );
1131 return;
1132 }
1133#endif
1134 gsl_integration_qcheb( &f, a, b, cheb12.data(), cheb24.data() );
1135 }
1136
1137#ifndef DOXYGEN_SKIP
1147 template<typename T>
1148 inline void qcheb( gsl_function* f, double a, double b, T& cheb12, T& cheb24 ){
1149#ifndef GSL_RANGE_CHECK_OFF
1150 // Check that vectors are long enough
1151 if( cheb12.size() < 13 ){
1152 gsl_error( "expected cheb12 of length 13 (or more)",
1153 __FILE__, __LINE__, exception::GSL_EFAILED );
1154 return;
1155 }
1156 if( cheb24.size() < 25 ){
1157 gsl_error( "expected cheb24 of length 25 (or more)",
1158 __FILE__, __LINE__, exception::GSL_EFAILED );
1159 return;
1160 }
1161#endif
1162 gsl_integration_qcheb( f, a, b, cheb12.data(), cheb24.data() );
1163 }
1164#endif /* DOXYGEN_SKIP */
1165
1183 inline void qk( int const n, double const xgk[], double const wg[], double const wgk[],
1184 double fv1[], double fv2[], function_scl const& f, double a, double b,
1185 double& result, double& abserr, double& resabs, double& resasc ){
1186 gsl_integration_qk( n, xgk, wg, wgk, fv1, fv2, &f, a, b, &result, &abserr, &resabs, &resasc );
1187 }
1188
1189#ifndef DOXYGEN_SKIP
1207 inline void qk( int const n, double const xgk[], double const wg[], double const wgk[],
1208 double fv1[], double fv2[], gsl_function const* f, double a, double b,
1209 double* result, double* abserr, double* resabs, double* resasc ){
1210 gsl_integration_qk( n, xgk, wg, wgk, fv1, fv2, f, a, b, result, abserr, resabs, resasc );
1211 }
1212#endif /* DOXYGEN_SKIP */
1213
1230 template<typename T>
1231 inline void qk( T const& xgk, T const& wg, T const& wgk,
1232 T& fv1, T& fv2, function_scl const& f, double a, double b,
1233 double& result, double& abserr, double& resabs, double& resasc ){
1234#ifndef GSL_RANGE_CHECK_OFF
1235 size_t const n = xgk.size();
1236 // Check that vectors are same length
1237 if( n == 0 ){ gsl_error( "expected xgk of nonzero size",
1238 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1239 if( wg.size() != n ){ gsl_error( "size mismatch: xgk and wg",
1240 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1241 if( wgk.size() != n ){ gsl_error( "size mismatch: xgk and wgk",
1242 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1243 if( fv1.size() != n ){ gsl_error( "size mismatch: xgk and fv1",
1244 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1245 if( fv2.size() != n ){ gsl_error( "size mismatch: xgk and fv2",
1246 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1247#endif
1248 gsl_integration_qk( n, xgk.data(), wg.data(), wgk.data(), fv1.data(), fv2.data(),
1249 &f, a, b, &result, &abserr, &resabs, &resasc );
1250 }
1251
1252#ifndef DOXYGEN_SKIP
1269 template<typename T>
1270 inline void qk( T const& xgk, T const& wg, T const& wgk,
1271 T& fv1, T& fv2, gsl_function const* f, double a, double b,
1272 double* result, double* abserr, double* resabs, double* resasc ){
1273#ifndef GSL_RANGE_CHECK_OFF
1274 size_t const n = xgk.size();
1275 // Check that vectors are same length
1276 if( n == 0 ){ gsl_error( "expected xgk of nonzero size",
1277 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1278 if( wg.size() != n ){ gsl_error( "size mismatch: xgk and wg",
1279 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1280 if( wgk.size() != n ){ gsl_error( "size mismatch: xgk and wgk",
1281 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1282 if( fv1.size() != n ){ gsl_error( "size mismatch: xgk and fv1",
1283 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1284 if( fv2.size() != n ){ gsl_error( "size mismatch: xgk and fv2",
1285 __FILE__, __LINE__, exception::GSL_EFAILED ); return; }
1286#endif
1287 gsl_integration_qk( n, xgk.data(), wg.data(), wgk.data(), fv1.data(), fv2.data(),
1288 f, a, b, result, abserr, resabs, resasc );
1289 }
1290#endif /* DOXYGEN_SKIP */
1291
1304 inline int qng( function_scl const& f, double a, double b, double epsabs, double epsrel,
1305 double& result, double& abserr, size_t& neval ){
1306 return gsl_integration_qng( &f, a, b, epsabs, epsrel, &result, &abserr, &neval ); }
1307
1308#ifndef DOXYGEN_SKIP
1321 inline int qng( gsl_function const* f, double a, double b, double epsabs, double epsrel,
1322 double* result, double* abserr, size_t* neval ){
1323 return gsl_integration_qng( f, a, b, epsabs, epsrel, result, abserr, neval ); }
1324#endif /* DOXYGEN_SKIP */
1325
1329 enum qag_key {
1335 GAUSS61 = 6
1337
1353 inline int qag( function_scl& f, double const a, double const b, double const epsabs,
1354 double const epsrel, size_t const limit, qag_key const key, workspace& workspace,
1355 double& result, double& abserr ){
1356#ifndef GSL_RANGE_CHECK_OFF
1357 if( limit > (workspace.get() == 0 ? 0 : workspace.get()->limit) ){
1358 gsl_error( "limit must not exceed size of workspace",
1359 __FILE__, __LINE__, exception::GSL_EFAILED );
1360 return GSL_EFAILED; }
1361#endif
1362 return gsl_integration_qag( &f, a, b, epsabs, epsrel, limit, static_cast<int>( key ),
1363 workspace.get(), &result, &abserr ); }
1364
1365#ifndef DOXYGEN_SKIP
1381 inline int qag( gsl_function* f, double const a, double const b, double const epsabs,
1382 double const epsrel, size_t const limit, qag_key const key, workspace& workspace,
1383 double* result, double* abserr ){
1384#ifndef GSL_RANGE_CHECK_OFF
1385 if( limit > (workspace.get() == 0 ? 0 : workspace.get()->limit) ){
1386 gsl_error( "limit must not exceed size of workspace",
1387 __FILE__, __LINE__, exception::GSL_EFAILED );
1388 return GSL_EFAILED; }
1389#endif
1390 return gsl_integration_qag( f, a, b, epsabs, epsrel, limit, static_cast<int>( key ),
1391 workspace.get(), result, abserr ); }
1392#endif /* DOXYGEN_SKIP */
1404 inline int qagi( function_scl& f, double const epsabs, double const epsrel, size_t const limit,
1405 workspace& workspace, double& result, double& abserr ){
1406 return gsl_integration_qagi( &f, epsabs, epsrel, limit, workspace.get(), &result, &abserr ); }
1407
1408#ifndef DOXYGEN_SKIP
1420 inline int qagi( gsl_function* f, double const epsabs, double const epsrel, size_t const limit,
1421 workspace& workspace, double* result, double* abserr ){
1422 return gsl_integration_qagi( f, epsabs, epsrel, limit, workspace.get(), result, abserr ); }
1423
1424#endif /* DOXYGEN_SKIP */
1437 inline int qagiu( function_scl& f, double const a, double const epsabs, double const epsrel,
1438 size_t const limit, workspace& workspace, double& result, double& abserr ){
1439 return gsl_integration_qagiu( &f, a, epsabs, epsrel, limit, workspace.get(), &result, &abserr ); }
1440
1441#ifndef DOXYGEN_SKIP
1454 inline int qagiu( gsl_function* f, double const a, double const epsabs, double const epsrel,
1455 size_t const limit, workspace& workspace, double* result, double* abserr ){
1456 return gsl_integration_qagiu( f, a, epsabs, epsrel, limit, workspace.get(), result, abserr ); }
1457#endif /* DOXYGEN_SKIP */
1458
1471 inline int qagil( function_scl& f, double const b, double const epsabs, double const epsrel,
1472 size_t const limit, workspace& workspace, double& result, double& abserr ){
1473 return gsl_integration_qagil( &f, b, epsabs, epsrel, limit, workspace.get(),
1474 &result, &abserr ); }
1475
1476#ifndef DOXYGEN_SKIP
1489 inline int qagil( gsl_function* f, double const b, double const epsabs, double const epsrel,
1490 size_t const limit, workspace& workspace, double* result, double* abserr ){
1491 return gsl_integration_qagil( f, b, epsabs, epsrel, limit, workspace.get(),
1492 result, abserr ); }
1493#endif /* DOXYGEN_SKIP */
1494
1508 inline int qags( function_scl& f, double const a, double const b, double const epsabs,
1509 double const epsrel, size_t const limit, workspace& workspace, double& result,
1510 double& abserr ){
1511 return gsl_integration_qags( &f, a, b, epsabs, epsrel, limit, workspace.get(),
1512 &result, &abserr ); }
1513
1514#ifndef DOXYGEN_SKIP
1528 inline int qags( gsl_function* f, double const a, double const b, double const epsabs,
1529 double const epsrel, size_t const limit, workspace& workspace, double* result,
1530 double* abserr ){
1531 return gsl_integration_qags( f, a, b, epsabs, epsrel, limit, workspace.get(),
1532 result, abserr ); }
1533#endif /* DOXYGEN_SKIP */
1534
1549 inline int qagp( function_scl& f, double const* pts, size_t const npts, double const epsabs,
1550 double const epsrel,
1551 size_t const limit, workspace& workspace, double& result, double& abserr ){
1552 return gsl_integration_qagp( &f, const_cast<double*>( pts ), npts, epsabs, epsrel, limit,
1553 workspace.get(), &result, &abserr ); }
1554
1555#ifndef DOXYGEN_SKIP
1570 inline int qagp( gsl_function* f, double const* pts, size_t const npts, double const epsabs,
1571 double const epsrel,
1572 size_t const limit, workspace& workspace, double* result, double* abserr ){
1573 return gsl_integration_qagp( f, const_cast<double*>( pts ), npts, epsabs, epsrel, limit,
1574 workspace.get(), result, abserr ); }
1575#endif /* DOXYGEN_SKIP */
1576
1591 template<typename T>
1592 inline int qagp( function_scl& f, T const& pts, double const epsabs, double const epsrel,
1593 size_t const limit, workspace& workspace, double& result, double& abserr ){
1594 size_t const npts = pts.size();
1595#ifndef GSL_RANGE_CHECK_OFF
1596 // Check that vectors are long enough
1597 if( pts.size() < 2 ){
1598 gsl_error( "expected pts of length 2 or greater",
1599 __FILE__, __LINE__, exception::GSL_EFAILED );
1600 return GSL_EFAILED;
1601 }
1602#endif
1603 return gsl_integration_qagp( &f, const_cast<double*>( pts.data() ), npts, epsabs, epsrel,
1604 limit, workspace.get(), &result, &abserr ); }
1605
1606#ifndef DOXYGEN_SKIP
1621 template<typename T>
1622 inline int qagp( gsl_function* f, T const& pts, double const epsabs, double const epsrel,
1623 size_t const limit, workspace& workspace, double* result, double* abserr ){
1624 size_t const npts = pts.size();
1625#ifndef GSL_RANGE_CHECK_OFF
1626 // Check that vectors are long enough
1627 if( pts.size() < 2 ){
1628 gsl_error( "expected pts of length 2 or greater",
1629 __FILE__, __LINE__, exception::GSL_EFAILED );
1630 return GSL_EFAILED;
1631 }
1632#endif
1633 return gsl_integration_qagp( f, const_cast<double*>( pts.data() ), npts, epsabs, epsrel,
1634 limit, workspace.get(), result, abserr ); }
1635#endif /* DOXYGEN_SKIP */
1636
1651 inline int qawc( function_scl& f, double const a, double const b, double const c,
1652 double const epsabs, double const epsrel, size_t const limit,
1653 workspace& workspace, double& result, double& abserr ){
1654 return gsl_integration_qawc( &f, a, b, c, epsabs, epsrel, limit, workspace.get(),
1655 &result, &abserr ); }
1656
1657#ifndef DOXYGEN_SKIP
1672 inline int qawc( gsl_function* f, double const a, double const b, double const c,
1673 double const epsabs, double const epsrel, size_t const limit,
1674 workspace& workspace, double* result, double* abserr ){
1675 return gsl_integration_qawc( f, a, b, c, epsabs, epsrel, limit, workspace.get(),
1676 result, abserr ); }
1677#endif /* DOXYGEN_SKIP */
1678
1693 inline int qaws( function_scl& f, double const a, double const b, qaws_table& t,
1694 double const epsabs, double const epsrel, size_t const limit,
1695 workspace& workspace, double& result, double& abserr ){
1696 return gsl_integration_qaws( &f, a, b, t.get(), epsabs, epsrel, limit,
1697 workspace.get(), &result, &abserr ); }
1698
1699#ifndef DOXYGEN_SKIP
1714 inline int qaws( gsl_function* f, double const a, double const b, qaws_table& t,
1715 double const epsabs, double const epsrel, size_t const limit,
1716 workspace& workspace, double* result, double* abserr ){
1717 return gsl_integration_qaws( f, a, b, t.get(), epsabs, epsrel, limit,
1718 workspace.get(), result, abserr ); }
1719#endif /* DOXYGEN_SKIP */
1720
1734 inline int qawo( function_scl& f, double const a, double const epsabs, double const epsrel,
1735 size_t const limit, workspace& workspace, qawo_table& wf,
1736 double& result, double& abserr ){
1737 return gsl_integration_qawo( &f, a, epsabs, epsrel, limit, workspace.get(), wf.get(),
1738 &result, &abserr ); }
1739
1740#ifndef DOXYGEN_SKIP
1754 inline int qawo( gsl_function* f, double const a, double const epsabs, double const epsrel,
1755 size_t const limit, workspace& workspace, qawo_table& wf,
1756 double* result, double* abserr ){
1757 return gsl_integration_qawo( f, a, epsabs, epsrel, limit, workspace.get(), wf.get(),
1758 result, abserr ); }
1759#endif /* DOXYGEN_SKIP */
1760
1774 inline int qawf( function_scl& f, double const a, double const epsabs, size_t const limit,
1776 qawo_table& wf, double& result, double& abserr ){
1777 return gsl_integration_qawf( &f, a, epsabs, limit, workspace.get(), cycle_workspace.get(),
1778 wf.get(), &result, &abserr ); }
1779
1780#ifndef DOXYGEN_SKIP
1794 inline int qawf( gsl_function* f, double const a, double const epsabs, size_t const limit,
1795 integration::workspace& workspace, integration::workspace& cycle_workspace,
1796 qawo_table& wf, double* result, double* abserr ){
1797 return gsl_integration_qawf( f, a, epsabs, limit, workspace.get(), cycle_workspace.get(),
1798 wf.get(), result, abserr ); }
1799#endif /* DOXYGEN_SKIP */
1800
1805 public:
1810 ccgsl_pointer = 0;
1811 count = 0; // initially nullptr will do
1812 }
1813 // Refines random access container
1814 // Refines assignable
1820 explicit glfixed_table( size_t const n ){
1821 ccgsl_pointer = gsl_integration_glfixed_table_alloc( n );
1822 // just plausibly we could allocate glfixed_table but not count
1823 try { count = new size_t; } catch( std::bad_alloc& e ){
1824 // try to tidy up before rethrowing
1825 gsl_integration_glfixed_table_free( ccgsl_pointer );
1826 throw e;
1827 }
1828 *count = 1; // initially there is just one reference to ccgsl_pointer
1829 }
1836 explicit glfixed_table( gsl_integration_glfixed_table* v ){
1837 ccgsl_pointer = v;
1838 // just plausibly we could fail to allocate count: no further action needed.
1839 count = new size_t;
1840 *count = 1; // initially there is just one reference to ccgsl_pointer
1841 }
1842 // copy constructor
1848 count = v.count; if( count != 0 ) ++*count; }
1849 // assignment operator
1855 // first, possibly delete anything pointed to by this
1856 if( count == 0 or --*count == 0 ){
1857 if( ccgsl_pointer != 0 ) gsl_integration_glfixed_table_free( ccgsl_pointer );
1858 delete count;
1859 } // Then copy
1860 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
1861 }
1862 // destructor
1867 if( count == 0 or --*count == 0 ){
1868 // could have allocated null pointer
1869 if( ccgsl_pointer != 0 ) gsl_integration_glfixed_table_free( ccgsl_pointer );
1870 delete count;
1871 }
1872 }
1873#ifdef __GXX_EXPERIMENTAL_CXX0X__
1879 std::swap( count, v.count );
1880 v.ccgsl_pointer = nullptr;
1881 }
1888 glfixed_table( std::move( v ) ).swap( *this );
1889 return *this;
1890 }
1891#endif
1892 // Refines equality comparable
1893 // == operator
1900 bool operator==( glfixed_table const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
1901 // != operator
1908 bool operator!=( glfixed_table const& v ) const { return not operator==( v ); }
1909 // Refines forward container
1910 // Refines less than comparable
1911 // operator<
1920 bool operator<( glfixed_table const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
1921 // operator>
1930 bool operator>( glfixed_table const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
1931 // operator<=
1940 bool operator<=( glfixed_table const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
1941 // operator>=
1950 bool operator>=( glfixed_table const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
1955 bool empty() const { return ccgsl_pointer == 0; }
1956 // swap() --- should work even if sizes don't match
1963 std::swap( ccgsl_pointer, v.ccgsl_pointer );
1964 std::swap( count, v.count );
1965 }
1966 private:
1970 gsl_integration_glfixed_table* ccgsl_pointer;
1974 size_t* count;
1975 public:
1976 // shared reference functions
1981 gsl_integration_glfixed_table* get() const { return ccgsl_pointer; }
1987 bool unique() const { return count != 0 and *count == 1; }
1992 size_t use_count() const { return count == 0 ? 0 : *count; }
1998#ifdef __GXX_EXPERIMENTAL_CXX0X__
1999 explicit
2000#endif
2001 operator bool() const { return ccgsl_pointer != 0; }
2002 };
2003
2012 inline double glfixed( function_scl const& f, double const a, double const b,
2013 glfixed_table const& t ){
2014 return gsl_integration_glfixed( &f, a, b, t.get() ); }
2015
2016#ifndef DOXYGEN_SKIP
2025 inline double glfixed( gsl_function const* f, double const a, double const b,
2026 glfixed_table const& t ){
2027 return gsl_integration_glfixed( f, a, b, t.get() ); }
2028#endif /* DOXYGEN_SKIP */
2029
2030#ifndef DOXYGEN_SKIP
2041 inline int glfixed_point( double const a, double const b, size_t const i, double* xi, double* wi,
2042 glfixed_table const& t ){
2043 return gsl_integration_glfixed_point( a, b, i, xi, wi, t.get() ); }
2044#endif /* DOXYGEN_SKIP */
2055 inline int glfixed_point( double const a, double const b, size_t const i,
2056 double& xi, double& wi, glfixed_table const& t ){
2057 return gsl_integration_glfixed_point( a, b, i, &xi, &wi, t.get() ); }
2058
2063 public:
2068 ccgsl_pointer = 0;
2069 count = 0; // initially nullptr will do
2070 }
2071 // Refines random access container
2072 // Refines assignable
2077 explicit cquad_workspace( size_t const n ){
2078 ccgsl_pointer = gsl_integration_cquad_workspace_alloc( n );
2079 // just plausibly we could allocate cquad_workspace but not count
2080 try { count = new size_t; } catch( std::bad_alloc& e ){
2081 // try to tidy up before rethrowing
2082 gsl_integration_cquad_workspace_free( ccgsl_pointer );
2083 throw e;
2084 }
2085 *count = 1; // initially there is just one reference to ccgsl_pointer
2086 }
2093 explicit cquad_workspace( gsl_integration_cquad_workspace* v ){
2094 ccgsl_pointer = v;
2095 // just plausibly we could fail to allocate count: no further action needed.
2096 count = new size_t;
2097 *count = 1; // initially there is just one reference to ccgsl_pointer
2098 }
2099 // copy constructor
2105 count = v.count; if( count != 0 ) ++*count; }
2106 // assignment operator
2112 // first, possibly delete anything pointed to by this
2113 if( count == 0 or --*count == 0 ){
2114 if( ccgsl_pointer != 0 ) gsl_integration_cquad_workspace_free( ccgsl_pointer );
2115 delete count;
2116 } // Then copy
2117 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
2118 }
2119 // destructor
2124 if( count == 0 or --*count == 0 ){
2125 // could have allocated null pointer
2126 if( ccgsl_pointer != 0 ) gsl_integration_cquad_workspace_free( ccgsl_pointer );
2127 delete count;
2128 }
2129 }
2130#ifdef __GXX_EXPERIMENTAL_CXX0X__
2136 std::swap( count, v.count );
2137 v.ccgsl_pointer = nullptr;
2138 }
2145 cquad_workspace( std::move( v ) ).swap( *this );
2146 return *this;
2147 }
2148#endif
2149 // Refines equality comparable
2150 // == operator
2157 bool operator==( cquad_workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
2158 // != operator
2165 bool operator!=( cquad_workspace const& v ) const { return not operator==( v ); }
2166 // Refines forward container
2167 // Refines less than comparable
2168 // operator<
2177 bool operator<( cquad_workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
2178 // operator>
2187 bool operator>( cquad_workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
2188 // operator<=
2197 bool operator<=( cquad_workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
2198 // operator>=
2207 bool operator>=( cquad_workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
2212 bool empty() const { return ccgsl_pointer == 0; }
2213 // swap() --- should work even if sizes don't match
2220 std::swap( ccgsl_pointer, v.ccgsl_pointer );
2221 std::swap( count, v.count );
2222 }
2223 private:
2227 gsl_integration_cquad_workspace* ccgsl_pointer;
2231 size_t* count;
2232 public:
2233 // shared reference functions
2238 gsl_integration_cquad_workspace* get() const { return ccgsl_pointer; }
2244 bool unique() const { return count != 0 and *count == 1; }
2249 size_t use_count() const { return count == 0 ? 0 : *count; }
2255#ifdef __GXX_EXPERIMENTAL_CXX0X__
2256 explicit
2257#endif
2258 operator bool() const { return ccgsl_pointer != 0; }
2259 };
2260
2274 inline int cquad( function_scl const& f, double const a, double const b, double const epsabs,
2275 double const epsrel, cquad_workspace& ws,
2276 double& result, double& abserr, size_t& nevals ){
2277 return gsl_integration_cquad( &f, a, b, epsabs, epsrel, ws.get(), &result, &abserr, &nevals ); }
2278
2279#ifndef DOXYGEN_SKIP
2293 inline int cquad( gsl_function const* f, double const a, double const b, double const epsabs,
2294 double const epsrel, cquad_workspace& ws,
2295 double* result, double* abserr, size_t* nevals ){
2296 return gsl_integration_cquad( f, a, b, epsabs, epsrel, ws.get(), result, abserr, nevals ); }
2297#endif /* DOXYGEN_SKIP */
2298
2303 public:
2308 ccgsl_pointer = 0;
2309 count = 0; // initially nullptr will do
2310 }
2311 // Refines random access container
2312 // Refines assignable
2317 explicit romberg_workspace( size_t const n ){
2318 ccgsl_pointer = gsl_integration_romberg_alloc( n );
2319 // just plausibly we could allocate romberg_workspace but not count
2320 try { count = new size_t; } catch( std::bad_alloc& e ){
2321 // try to tidy up before rethrowing
2322 gsl_integration_romberg_free( ccgsl_pointer );
2323 throw e;
2324 }
2325 *count = 1; // initially there is just one reference to ccgsl_pointer
2326 }
2333 explicit romberg_workspace( gsl_integration_romberg_workspace* v ){
2334 ccgsl_pointer = v;
2335 // just plausibly we could fail to allocate count: no further action needed.
2336 count = new size_t;
2337 *count = 1; // initially there is just one reference to ccgsl_pointer
2338 }
2339 // copy constructor
2345 count = v.count; if( count != 0 ) ++*count; }
2346 // assignment operator
2352 // first, possibly delete anything pointed to by this
2353 if( count == 0 or --*count == 0 ){
2354 if( ccgsl_pointer != 0 ) gsl_integration_romberg_free( ccgsl_pointer );
2355 delete count;
2356 } // Then copy
2357 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
2358 }
2359 // destructor
2364 if( count == 0 or --*count == 0 ){
2365 // could have allocated null pointer
2366 if( ccgsl_pointer != 0 ) gsl_integration_romberg_free( ccgsl_pointer );
2367 delete count;
2368 }
2369 }
2370#ifdef __GXX_EXPERIMENTAL_CXX0X__
2376 std::swap( count, v.count );
2377 v.ccgsl_pointer = nullptr;
2378 }
2385 romberg_workspace( std::move( v ) ).swap( *this );
2386 return *this;
2387 }
2388#endif
2389 // Refines equality comparable
2390 // == operator
2397 bool operator==( romberg_workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
2398 // != operator
2405 bool operator!=( romberg_workspace const& v ) const { return not operator==( v ); }
2406 // Refines forward container
2407 // Refines less than comparable
2408 // operator<
2417 bool operator<( romberg_workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
2418 // operator>
2427 bool operator>( romberg_workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
2428 // operator<=
2437 bool operator<=( romberg_workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
2438 // operator>=
2447 bool operator>=( romberg_workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
2452 bool empty() const { return ccgsl_pointer == 0; }
2453 // swap() --- should work even if sizes don't match
2460 std::swap( ccgsl_pointer, v.ccgsl_pointer );
2461 std::swap( count, v.count );
2462 }
2463 private:
2467 gsl_integration_romberg_workspace* ccgsl_pointer;
2471 size_t* count;
2472 public:
2473 // shared reference functions
2478 gsl_integration_romberg_workspace* get() const { return ccgsl_pointer; }
2484 bool unique() const { return count != 0 and *count == 1; }
2489 size_t use_count() const { return count == 0 ? 0 : *count; }
2495#ifdef __GXX_EXPERIMENTAL_CXX0X__
2496 explicit
2497#endif
2498 operator bool() const { return ccgsl_pointer != 0; }
2499 };
2511 inline int romberg( function_scl const& f, double const a, double const b,
2512 double const epsabs, double const epsrel, double& result,
2513 size_t& neval, romberg_workspace& w ){
2514 return gsl_integration_romberg( &f, a, b, epsabs, epsrel, &result, &neval, w.get() ); }
2515#ifndef DOXYGEN_SKIP
2527 inline int romberg( gsl_function const* f, double const a, double const b,
2528 double const epsabs, double const epsrel, double* result,
2529 size_t* neval, romberg_workspace& w ){
2530 return gsl_integration_romberg( f, a, b, epsabs, epsrel, result, neval, w.get() ); }
2531#endif /* DOXYGEN_SKIP */
2537 inline size_t fixed_n( fixed_workspace const& w ){
2538 return gsl_integration_fixed_n( w.get() ); }
2544 inline double* fixed_nodes( fixed_workspace const& w ){
2545 return gsl_integration_fixed_nodes( w.get() ); }
2551 inline double* fixed_weights( fixed_workspace const& w ){
2552 return gsl_integration_fixed_weights( w.get() ); }
2553
2560 inline int fixed( function_scl const& func, double* result, fixed_workspace& w ){
2561 return gsl_integration_fixed( &func, result, w.get() ); }
2562#ifndef DOXYGEN_SKIP
2569 inline int fixed( gsl_function const* func, double* result, fixed_workspace& w ){
2570 return gsl_integration_fixed( func, result, w.get() ); }
2571#endif /* DOXYGEN_SKIP */
2572 }
2573}
2574
2575#endif
2576
@ GSL_EFAILED
generic failure
Definition: exception.hpp:476
Class that extends gsl_function so that it can be constructed from arbitrary function objects.
Workspace for CQUAD quadrature routine.
cquad_workspace(gsl_integration_cquad_workspace *v)
Could construct from a gsl_integration_cquad_workspace.
bool operator<=(cquad_workspace const &v) const
A container needs to define an ordering for sorting.
~cquad_workspace()
The destructor only deletes the pointers if count reaches zero.
bool unique() const
Find if this is the only object sharing the gsl_integration_cquad_workspace.
size_t * count
The shared reference count.
cquad_workspace & operator=(cquad_workspace &&v)
Move operator.
cquad_workspace(size_t const n)
The default constructor creates a new cquad_workspace with space for n intervals.
cquad_workspace()
The default constructor is only really useful for assigning to.
bool empty() const
Find if the cquad_workspace is empty.
bool operator>=(cquad_workspace const &v) const
A container needs to define an ordering for sorting.
bool operator!=(cquad_workspace const &v) const
Two cquad_workspace are different if their elements are not identical.
bool operator==(cquad_workspace const &v) const
Two cquad_workspace are identically equal if their elements are identical.
void swap(cquad_workspace &v)
Swap two cquad_workspace.
size_t use_count() const
Find how many cquad_workspace objects share this pointer.
cquad_workspace & operator=(cquad_workspace const &v)
The assignment operator.
bool operator<(cquad_workspace const &v) const
A container needs to define an ordering for sorting.
bool operator>(cquad_workspace const &v) const
A container needs to define an ordering for sorting.
cquad_workspace(cquad_workspace &&v)
Move constructor.
gsl_integration_cquad_workspace * ccgsl_pointer
The shared pointer.
gsl_integration_cquad_workspace * get() const
Get the gsl_integration_cquad_workspace.
cquad_workspace(cquad_workspace const &v)
The copy constructor.
Workspace for integration_fixed.
gsl_integration_fixed_workspace * get() const
Get the gsl_integration_fixed_workspace.
fixed_workspace(fixed_workspace const &v)
The copy constructor.
bool unique() const
Find if this is the only object sharing the gsl_integration_fixed_workspace.
fixed_workspace(gsl_integration_fixed_workspace *v)
Could construct from a gsl_integration_fixed_workspace.
size_t use_count() const
Find how many fixed_workspace objects share this pointer.
bool operator<(fixed_workspace const &v) const
A container needs to define an ordering for sorting.
size_t * count
The shared reference count.
fixed_workspace()
The default constructor is only really useful for assigning to.
bool empty() const
Find if the workspace is empty.
bool operator==(fixed_workspace const &v) const
Two fixed_workspace are identically equal if their elements are identical.
bool operator>=(fixed_workspace const &v) const
A container needs to define an ordering for sorting.
void swap(fixed_workspace &v)
Swap two workspace.
fixed_workspace(fixed_workspace &&v)
Move constructor.
bool operator<=(fixed_workspace const &v) const
A container needs to define an ordering for sorting.
fixed_workspace & operator=(fixed_workspace &&v)
Move operator.
fixed_workspace & operator=(fixed_workspace const &v)
The assignment operator.
bool operator>(fixed_workspace const &v) const
A container needs to define an ordering for sorting.
fixed_workspace(const gsl_integration_fixed_type *type, const size_t n, const double a, const double b, const double alpha, const double beta)
The default constructor creates a new fixed_workspace with n elements.
~fixed_workspace()
The destructor only deletes the pointers if count reaches zero.
gsl_integration_fixed_workspace * ccgsl_pointer
The shared pointer.
bool operator!=(fixed_workspace const &v) const
Two fixed_workspace are different if their elements are not identical.
Workspace for glfixed_table: used for Gauss–Legendre integration.
glfixed_table()
The default constructor is only really useful for assigning to.
bool operator>=(glfixed_table const &v) const
A container needs to define an ordering for sorting.
glfixed_table(size_t const n)
The default constructor creates a new glfixed_table with n elements.
bool operator<=(glfixed_table const &v) const
A container needs to define an ordering for sorting.
bool operator!=(glfixed_table const &v) const
Two glfixed_table are different if their elements are not identical.
glfixed_table & operator=(glfixed_table &&v)
Move operator.
glfixed_table & operator=(glfixed_table const &v)
The assignment operator.
gsl_integration_glfixed_table * get() const
Get the gsl_integration_glfixed_table.
bool operator>(glfixed_table const &v) const
A container needs to define an ordering for sorting.
size_t use_count() const
Find how many workspace objects share this pointer.
glfixed_table(glfixed_table const &v)
The copy constructor.
glfixed_table(gsl_integration_glfixed_table *v)
Could construct from a gsl_integration_glfixed_table.
glfixed_table(glfixed_table &&v)
Move constructor.
bool operator==(glfixed_table const &v) const
Two glfixed_table are identically equal if their elements are identical.
bool empty() const
Find if the glfixed_table is empty.
bool unique() const
Find if this is the only object sharing the gsl_integration_glfixed_table.
bool operator<(glfixed_table const &v) const
A container needs to define an ordering for sorting.
~glfixed_table()
The destructor only deletes the pointers if count reaches zero.
gsl_integration_glfixed_table * ccgsl_pointer
The shared pointer.
size_t * count
The shared reference count.
void swap(glfixed_table &v)
Swap two glfixed_table.
A precomputed table of Chebychev moments.
bool operator<=(qawo_table const &v) const
A container needs to define an ordering for sorting.
qawo_table(double const omega, double const L, qawo_enum const sine, size_t const n)
The default constructor creates a new qawo_table with sine or cosine weight function or .
qawo_table & operator=(qawo_table const &v)
The assignment operator.
qawo_table(gsl_integration_qawo_table *v)
Could construct from a gsl_integration_qawo_table.
bool empty() const
Find if the qawo_table is empty.
bool unique() const
Find if this is the only object sharing the gsl_integration_qawo_table.
qawo_table()
The default constructor is only really useful for assigning to.
qawo_table(qawo_table const &v)
The copy constructor.
size_t * count
The shared reference count.
size_t use_count() const
Find how many workspace objects share this pointer.
void swap(qawo_table &v)
Swap two qawo_table.
gsl_integration_qawo_table * get() const
Get the gsl_integration_qawo_table.
bool operator<(qawo_table const &v) const
A container needs to define an ordering for sorting.
bool operator>=(qawo_table const &v) const
A container needs to define an ordering for sorting.
bool operator!=(qawo_table const &v) const
Two qawo_table are different if their elements are not identical.
bool operator==(qawo_table const &v) const
Two qawo_table are identically equal if their elements are identical.
qawo_table(qawo_table &&v)
Move constructor.
gsl_integration_qawo_table * ccgsl_pointer
The shared pointer.
bool operator>(qawo_table const &v) const
A container needs to define an ordering for sorting.
~qawo_table()
The destructor only deletes the pointers if count reaches zero.
qawo_table & operator=(qawo_table &&v)
Move operator.
A precomputed table of Chebychev moments.
bool operator<=(qaws_table const &v) const
A container needs to define an ordering for sorting.
qaws_table(gsl_integration_qaws_table *v)
Could construct from a gsl_integration_qaws_table.
void swap(qaws_table &v)
Swap two qaws_table.
bool operator!=(qaws_table const &v) const
Two qaws_table are different if their elements are not identical.
bool empty() const
Find if the qaws_table is empty.
bool unique() const
Find if this is the only object sharing the gsl_integration_qaws_table.
size_t * count
The shared reference count.
gsl_integration_qaws_table * get() const
Get the gsl_integration_qaws_table.
~qaws_table()
The destructor only deletes the pointers if count reaches zero.
bool operator==(qaws_table const &v) const
Two qaws_table are identically equal if their elements are identical.
bool operator<(qaws_table const &v) const
A container needs to define an ordering for sorting.
qaws_table()
The default constructor is only really useful for assigning to.
qaws_table & operator=(qaws_table const &v)
The assignment operator.
size_t use_count() const
Find how many workspace objects share this pointer.
qaws_table(qaws_table &&v)
Move constructor.
qaws_table & operator=(qaws_table &&v)
Move operator.
qaws_table(double const alpha, double const beta, double const mu, double const nu)
The default constructor creates a new qaws_table with singular weight function .
bool operator>(qaws_table const &v) const
A container needs to define an ordering for sorting.
qaws_table(qaws_table const &v)
The copy constructor.
gsl_integration_qaws_table * ccgsl_pointer
The shared pointer.
bool operator>=(qaws_table const &v) const
A container needs to define an ordering for sorting.
Workspace for integration.
romberg_workspace(gsl_integration_romberg_workspace *v)
Could construct from a gsl_integration_romberg_workspace.
size_t use_count() const
Find how many romberg_workspace objects share this pointer.
gsl_integration_romberg_workspace * get() const
Get the gsl_integration_romberg_workspace.
size_t * count
The shared reference count.
romberg_workspace & operator=(romberg_workspace const &v)
The assignment operator.
bool operator<(romberg_workspace const &v) const
A container needs to define an ordering for sorting.
void swap(romberg_workspace &v)
Swap two romberg_workspace.
romberg_workspace(romberg_workspace &&v)
Move constructor.
bool empty() const
Find if the romberg_workspace is empty.
bool unique() const
Find if this is the only object sharing the gsl_integration_romberg_workspace.
~romberg_workspace()
The destructor only deletes the pointers if count reaches zero.
romberg_workspace & operator=(romberg_workspace &&v)
Move operator.
bool operator!=(romberg_workspace const &v) const
Two romberg_workspace are different if their elements are not identical.
bool operator>(romberg_workspace const &v) const
A container needs to define an ordering for sorting.
bool operator==(romberg_workspace const &v) const
Two romberg_workspace are identically equal if their elements are identical.
romberg_workspace(size_t const n)
The default constructor creates a new romberg_workspace with n elements.
gsl_integration_romberg_workspace * ccgsl_pointer
The shared pointer.
bool operator>=(romberg_workspace const &v) const
A container needs to define an ordering for sorting.
romberg_workspace(romberg_workspace const &v)
The copy constructor.
romberg_workspace()
The default constructor is only really useful for assigning to.
bool operator<=(romberg_workspace const &v) const
A container needs to define an ordering for sorting.
Workspace for integration.
Definition: integration.hpp:37
workspace & operator=(workspace const &v)
The assignment operator.
Definition: integration.hpp:86
workspace & operator=(workspace &&v)
Move operator.
bool operator>=(workspace const &v) const
A container needs to define an ordering for sorting.
gsl_integration_workspace * get() const
Get the gsl_integration_workspace.
workspace(workspace &&v)
Move constructor.
bool operator!=(workspace const &v) const
Two workspace are different if their elements are not identical.
bool unique() const
Find if this is the only object sharing the gsl_integration_workspace.
void swap(workspace &v)
Swap two workspace.
bool operator<(workspace const &v) const
A container needs to define an ordering for sorting.
workspace()
The default constructor is only really useful for assigning to.
Definition: integration.hpp:42
size_t use_count() const
Find how many workspace objects share this pointer.
~workspace()
The destructor only deletes the pointers if count reaches zero.
Definition: integration.hpp:98
size_t * count
The shared reference count.
bool operator<=(workspace const &v) const
A container needs to define an ordering for sorting.
workspace(workspace const &v)
The copy constructor.
Definition: integration.hpp:79
workspace(gsl_integration_workspace *v)
Could construct from a gsl_integration_workspace.
Definition: integration.hpp:68
bool operator>(workspace const &v) const
A container needs to define an ordering for sorting.
gsl_integration_workspace * ccgsl_pointer
The shared pointer.
bool empty() const
Find if the workspace is empty.
workspace(size_t const n)
The default constructor creates a new workspace with n elements.
Definition: integration.hpp:52
bool operator==(workspace const &v) const
Two workspace are identically equal if their elements are identical.
int qaws(function_scl &f, double const a, double const b, qaws_table &t, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qaws().
int glfixed_point(double const a, double const b, size_t const i, double &xi, double &wi, glfixed_table const &t)
C++ version of gsl_integration_glfixed_point().
void qk51(function_scl const &f, double a, double b, double &result, double &abserr, double &resabs, double &resasc)
C++ version of gsl_integration_qk51().
void qk21(function_scl const &f, double a, double b, double &result, double &abserr, double &resabs, double &resasc)
C++ version of gsl_integration_qk21().
int qawo(function_scl &f, double const a, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, qawo_table &wf, double &result, double &abserr)
C++ version of gsl_integration_qawo().
int qag(function_scl &f, double const a, double const b, double const epsabs, double const epsrel, size_t const limit, qag_key const key, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qag().
void qk41(function_scl const &f, double a, double b, double &result, double &abserr, double &resabs, double &resasc)
C++ version of gsl_integration_qk41().
qawo_enum
Enumerated type.
@ SINE
use sine function in qawo_table
@ COSINE
use cosine function in qawo_table
int qawc(function_scl &f, double const a, double const b, double const c, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qawc().
int qags(function_scl &f, double const a, double const b, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qags().
int qawo_table_set(qawo_table &t, double const omega, double const L, qawo_enum const sine)
C++ version of gsl_integration_qawo_table_set().
int cquad(function_scl const &f, double const a, double const b, double const epsabs, double const epsrel, cquad_workspace &ws, double &result, double &abserr, size_t &nevals)
C++ version of gsl_integration_cquad().
int fixed(function_scl const &func, double *result, fixed_workspace &w)
C++ version of gsl_integration_fixed().
int romberg(function_scl const &f, double const a, double const b, double const epsabs, double const epsrel, double &result, size_t &neval, romberg_workspace &w)
C++ version of gsl_integration_romberg().
void qcheb(function_scl &f, double a, double b, T &cheb12, T &cheb24)
C++ version of gsl_integration_qcheb().
double * fixed_nodes(fixed_workspace const &w)
Get a pointer to an array of nodes.
int qagil(function_scl &f, double const b, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qagil().
qag_key
Keys used for qaq().
@ GAUSS51
use 51-point Gauss–Konrod rule
@ GAUSS31
use 31-point Gauss–Konrod rule
@ GAUSS21
use 21-point Gauss–Konrod rule
@ GAUSS41
use 41-point Gauss–Konrod rule
@ GAUSS15
use 15-point Gauss–Konrod rule
@ GAUSS61
use 61-point Gauss–Konrod rule
int qawo_table_set_length(qawo_table &t, double L)
C++ version of gsl_integration_qawo_table_set_length().
void qk31(function_scl const &f, double a, double b, double &result, double &abserr, double &resabs, double &resasc)
C++ version of gsl_integration_qk31().
int qagiu(function_scl &f, double const a, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qagiu().
double glfixed(function_scl const &f, double const a, double const b, glfixed_table const &t)
C++ version of gsl_integration_glfixed().
int qaws_table_set(qaws_table &t, double const alpha, double const beta, int const mu, int const nu)
C++ version of gsl_integration_qaws_table_set().
int qagi(function_scl &f, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qagi().
void qk15(function_scl const &f, double a, double b, double &result, double &abserr, double &resabs, double &resasc)
C++ version of gsl_integration_qk15().
size_t fixed_n(fixed_workspace const &w)
Get the number of quadrature nodes and weights.
void qk(int const n, double const xgk[], double const wg[], double const wgk[], double fv1[], double fv2[], function_scl const &f, double a, double b, double &result, double &abserr, double &resabs, double &resasc)
C++ version of gsl_integration_qk().
void qk61(function_scl const &f, double a, double b, double &result, double &abserr, double &resabs, double &resasc)
C++ version of gsl_integration_qk61().
int qng(function_scl const &f, double a, double b, double epsabs, double epsrel, double &result, double &abserr, size_t &neval)
C++ version of gsl_integration_qng().
int qagp(function_scl &f, double const *pts, size_t const npts, double const epsabs, double const epsrel, size_t const limit, workspace &workspace, double &result, double &abserr)
C++ version of gsl_integration_qagp().
int qawf(function_scl &f, double const a, double const epsabs, size_t const limit, integration::workspace &workspace, integration::workspace &cycle_workspace, qawo_table &wf, double &result, double &abserr)
C++ version of gsl_integration_qawf().
double * fixed_weights(fixed_workspace const &w)
Get a pointer to an array of weights.
gsl_multilarge_linear_type type
Typedef for shorthand.
Definition: multilarge.hpp:40
double beta(rng const &r, double const a, double const b)
C++ version of gsl_ran_beta().
Definition: randist.hpp:262
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
Definition: rstat.hpp:299
double func(int const n, double const x)
C++ version of gsl_sf_hermite_func().
Definition: sf_hermite.hpp:154
double b(int order, double qq)
C++ version of gsl_sf_mathieu_b().
Definition: sf_mathieu.hpp:298
double a(int order, double qq)
C++ version of gsl_sf_mathieu_a().
Definition: sf_mathieu.hpp:272
gsl_sf_result result
Typedef for gsl_sf_result.
Definition: sf_result.hpp:30
The gsl package creates an interface to the GNU Scientific Library for C++.
Definition: blas.hpp:34