ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
sf_mathieu.hpp
Go to the documentation of this file.
1/*
2 * $Id: sf_mathieu.hpp 293 2012-12-17 20:27:36Z jdl3 $
3 * Copyright (C) 2010, 2011 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_SF_MATHIEU_HPP
21#define CCGSL_SF_MATHIEU_HPP
22
23#include<gsl/gsl_sf_mathieu.h>
24
25#include<new>
26#include<algorithm>
27#include"mode.hpp"
28#include"sf_result.hpp"
29
30namespace gsl {
31 namespace sf {
35 namespace mathieu {
39 class workspace {
40 public:
45 ccgsl_pointer = 0;
46 count = 0; // initially nullptr will do
47 }
48 // Refines random access container
49 // Refines assignable
55 explicit workspace( size_t const nn, double const qq ){
56 ccgsl_pointer = gsl_sf_mathieu_alloc( nn, qq );
57 // just plausibly we could allocate mathieu_workspace but not count
58 try { count = new size_t; } catch( std::bad_alloc& e ){
59 // try to tidy up before rethrowing
60 gsl_sf_mathieu_free( ccgsl_pointer );
61 throw e;
62 }
63 *count = 1; // initially there is just one reference to ccgsl_pointer
64 }
70 explicit workspace( gsl_sf_mathieu_workspace* v ){
71 ccgsl_pointer = v;
72 // just plausibly we could fail to allocate count: no further action needed.
73 count = new size_t;
74 *count = 1; // initially there is just one reference to ccgsl_pointer
75 }
76 // copy constructor
82 count = v.count; if( count != 0 ) ++*count; }
83 // assignment operator
89 // first, possibly delete anything pointed to by this
90 if( count == 0 or --*count == 0 ){
91 if( ccgsl_pointer != 0 ) gsl_sf_mathieu_free( ccgsl_pointer );
92 delete count;
93 } // Then copy
94 ccgsl_pointer = v.ccgsl_pointer; count = v.count; if( count != 0 ) ++*count; return *this;
95 }
96 // destructor
101 if( count == 0 or --*count == 0 ){
102 // could have allocated null pointer
103 if( ccgsl_pointer != 0 ) gsl_sf_mathieu_free( ccgsl_pointer );
104 delete count;
105 }
106 }
107#ifdef __GXX_EXPERIMENTAL_CXX0X__
113 std::swap( count, v.count );
114 v.ccgsl_pointer = nullptr;
115 }
122 workspace( std::move( v ) ).swap( *this );
123 return *this;
124 }
125#endif
126 // Refines equality comparable
127 // == operator
134 bool operator==( workspace const& v ) const { return ccgsl_pointer == v.ccgsl_pointer; }
135 // != operator
142 bool operator!=( workspace const& v ) const { return not operator==( v ); }
143 // Refines forward container
144 // Refines less than comparable
145 // operator<
154 bool operator<( workspace const& v ) const { return ccgsl_pointer < v.ccgsl_pointer; }
155 // operator>
164 bool operator>( workspace const& v ) const { return ccgsl_pointer > v.ccgsl_pointer; }
165 // operator<=
174 bool operator<=( workspace const& v ) const { return ccgsl_pointer <= v.ccgsl_pointer; }
175 // operator>=
184 bool operator>=( workspace const& v ) const { return ccgsl_pointer >= v.ccgsl_pointer; }
189 bool empty() const { return ccgsl_pointer == 0; }
190 // swap() --- should work even if sizes don't match
196 void swap( workspace& v ){
197 std::swap( ccgsl_pointer, v.ccgsl_pointer );
198 std::swap( count, v.count );
199 }
204 size_t size() const { return ccgsl_pointer == 0 ? 0 : ccgsl_pointer->size; }
205 private:
209 gsl_sf_mathieu_workspace* ccgsl_pointer;
213 size_t* count;
214 public:
215 // shared reference functions
220 gsl_sf_mathieu_workspace* get() const { return ccgsl_pointer; }
226 bool unique() const { return count != 0 and *count == 1; }
231 size_t use_count() const { return count == 0 ? 0 : *count; }
237#ifdef __GXX_EXPERIMENTAL_CXX0X__
238 explicit
239#endif
240 operator bool() const { return ccgsl_pointer != 0; }
241 };
251 inline int a_array( int order_min, int order_max, double qq,
252 workspace& work, double result_array[] ){
253 return gsl_sf_mathieu_a_array( order_min, order_max, qq, work.get(), result_array ); }
263 inline int b_array( int order_min, int order_max, double qq,
264 workspace& work, double result_array[] ){
265 return gsl_sf_mathieu_b_array( order_min, order_max, qq, work.get(), result_array ); }
272 inline double a( int order, double qq ){
273 return gsl_sf_mathieu_a( order, qq ); }
281 inline int a_e( int order, double qq, result& result ){
282 return gsl_sf_mathieu_a_e( order, qq, &result ); }
290 inline int b_e( int order, double qq, result& result ){
291 return gsl_sf_mathieu_b_e( order, qq, &result ); }
298 inline double b( int order, double qq ){
299 return gsl_sf_mathieu_b( order, qq ); }
308 inline int a_coeff( int order, double qq, double aa, double coeff[] ){
309 return gsl_sf_mathieu_a_coeff( order, qq, aa, coeff ); }
318 inline int b_coeff( int order, double qq, double aa, double coeff[] ){
319 return gsl_sf_mathieu_b_coeff( order, qq, aa, coeff ); }
327 inline double ce( int order, double qq, double zz ){
328 return gsl_sf_mathieu_ce( order, qq, zz ); }
337 inline int ce_e( int order, double qq, double zz, result& result ){
338 return gsl_sf_mathieu_ce_e( order, qq, zz, &result ); }
347 inline int se_e( int order, double qq, double zz, result& result ){
348 return gsl_sf_mathieu_se_e( order, qq, zz, &result ); }
356 inline double se( int order, double qq, double zz ){
357 return gsl_sf_mathieu_se( order, qq, zz ); }
368 inline int ce_array( int nmin, int nmax, double qq, double zz,
369 workspace& work, double result_array[] ){
370 return gsl_sf_mathieu_ce_array( nmin, nmax, qq, zz, work.get(), result_array ); }
381 inline int se_array( int nmin, int nmax, double qq, double zz,
382 workspace& work, double result_array[] ){
383 return gsl_sf_mathieu_se_array( nmin, nmax, qq, zz, work.get(), result_array ); }
392 inline double Mc( int kind, int order, double qq, double zz ){
393 return gsl_sf_mathieu_Mc( kind, order, qq, zz ); }
403 inline int Mc_e( int kind, int order, double qq, double zz, result& result ){
404 return gsl_sf_mathieu_Mc_e( kind, order, qq, zz, &result ); }
413 inline double Ms( int kind, int order, double qq, double zz ){
414 return gsl_sf_mathieu_Ms( kind, order, qq, zz ); }
424 inline int Ms_e( int kind, int order, double qq, double zz, result& result ){
425 return gsl_sf_mathieu_Ms_e( kind, order, qq, zz, &result ); }
437 inline int Mc_array( int kind, int nmin, int nmax, double qq, double zz,
438 workspace& work, double result_array[] ){
439 return gsl_sf_mathieu_Mc_array( kind, nmin, nmax, qq, zz, work.get(), result_array ); }
451 inline int Ms_array( int kind, int nmin, int nmax, double qq, double zz,
452 workspace& work, double result_array[] ){
453 return gsl_sf_mathieu_Ms_array( kind, nmin, nmax, qq, zz, work.get(), result_array ); }
454 }
455 }
456}
457
458#endif
Workspace for general matrices.
Definition: sf_mathieu.hpp:39
size_t size() const
The size of the workspace.
Definition: sf_mathieu.hpp:204
bool operator==(workspace const &v) const
Two workspace are identically equal if their elements are identical.
Definition: sf_mathieu.hpp:134
bool operator!=(workspace const &v) const
Two workspace are different equal if their elements are not identical.
Definition: sf_mathieu.hpp:142
bool operator>(workspace const &v) const
A container needs to define an ordering for sorting.
Definition: sf_mathieu.hpp:164
size_t * count
The shared reference count.
Definition: sf_mathieu.hpp:213
workspace & operator=(workspace const &v)
The assignment operator.
Definition: sf_mathieu.hpp:88
~workspace()
The destructor only deletes the pointers if count reaches zero.
Definition: sf_mathieu.hpp:100
workspace & operator=(workspace &&v)
Move operator.
Definition: sf_mathieu.hpp:121
gsl_sf_mathieu_workspace * get() const
Get the gsl_sf_mathieu_workspace.
Definition: sf_mathieu.hpp:220
workspace(workspace &&v)
Move constructor.
Definition: sf_mathieu.hpp:112
gsl_sf_mathieu_workspace * ccgsl_pointer
The shared pointer.
Definition: sf_mathieu.hpp:209
workspace(size_t const nn, double const qq)
The default constructor creates a new workspace with n elements.
Definition: sf_mathieu.hpp:55
bool operator>=(workspace const &v) const
A container needs to define an ordering for sorting.
Definition: sf_mathieu.hpp:184
workspace(workspace const &v)
The copy constructor.
Definition: sf_mathieu.hpp:81
workspace(gsl_sf_mathieu_workspace *v)
Could construct from a gsl_sf_mathieu_workspace.
Definition: sf_mathieu.hpp:70
bool empty() const
Find if the workspace is empty.
Definition: sf_mathieu.hpp:189
bool unique() const
Find if this is the only object sharing the gsl_sf_mathieu_workspace.
Definition: sf_mathieu.hpp:226
bool operator<=(workspace const &v) const
A container needs to define an ordering for sorting.
Definition: sf_mathieu.hpp:174
void swap(workspace &v)
Swap two workspace.
Definition: sf_mathieu.hpp:196
bool operator<(workspace const &v) const
A container needs to define an ordering for sorting.
Definition: sf_mathieu.hpp:154
size_t use_count() const
Find how many workspace objects share this pointer.
Definition: sf_mathieu.hpp:231
workspace()
The default constructor is only really useful for assigning to.
Definition: sf_mathieu.hpp:44
size_t order(workspace &w)
C++ version of gsl_bspline_order().
Definition: bspline.hpp:255
double Ms(int kind, int order, double qq, double zz)
C++ version of gsl_sf_mathieu_Ms().
Definition: sf_mathieu.hpp:413
double se(int order, double qq, double zz)
C++ version of gsl_sf_mathieu_se().
Definition: sf_mathieu.hpp:356
int b_e(int order, double qq, result &result)
C++ version of gsl_sf_mathieu_b_e().
Definition: sf_mathieu.hpp:290
int a_coeff(int order, double qq, double aa, double coeff[])
C++ version of gsl_sf_mathieu_a_coeff().
Definition: sf_mathieu.hpp:308
int ce_array(int nmin, int nmax, double qq, double zz, workspace &work, double result_array[])
C++ version of gsl_sf_mathieu_ce_array().
Definition: sf_mathieu.hpp:368
int a_array(int order_min, int order_max, double qq, workspace &work, double result_array[])
C++ version of gsl_sf_mathieu_a_array().
Definition: sf_mathieu.hpp:251
int Mc_e(int kind, int order, double qq, double zz, result &result)
C++ version of gsl_sf_mathieu_Mc_e().
Definition: sf_mathieu.hpp:403
double ce(int order, double qq, double zz)
C++ version of gsl_sf_mathieu_ce().
Definition: sf_mathieu.hpp:327
int b_array(int order_min, int order_max, double qq, workspace &work, double result_array[])
C++ version of gsl_sf_mathieu_b_array().
Definition: sf_mathieu.hpp:263
int a_e(int order, double qq, result &result)
C++ version of gsl_sf_mathieu_a_e().
Definition: sf_mathieu.hpp:281
int ce_e(int order, double qq, double zz, result &result)
C++ version of gsl_sf_mathieu_ce_e().
Definition: sf_mathieu.hpp:337
int Mc_array(int kind, int nmin, int nmax, double qq, double zz, workspace &work, double result_array[])
C++ version of gsl_sf_mathieu_Mc_array().
Definition: sf_mathieu.hpp:437
double b(int order, double qq)
C++ version of gsl_sf_mathieu_b().
Definition: sf_mathieu.hpp:298
int se_array(int nmin, int nmax, double qq, double zz, workspace &work, double result_array[])
C++ version of gsl_sf_mathieu_se_array().
Definition: sf_mathieu.hpp:381
int Ms_array(int kind, int nmin, int nmax, double qq, double zz, workspace &work, double result_array[])
C++ version of gsl_sf_mathieu_Ms_array().
Definition: sf_mathieu.hpp:451
int se_e(int order, double qq, double zz, result &result)
C++ version of gsl_sf_mathieu_se_e().
Definition: sf_mathieu.hpp:347
int b_coeff(int order, double qq, double aa, double coeff[])
C++ version of gsl_sf_mathieu_b_coeff().
Definition: sf_mathieu.hpp:318
double Mc(int kind, int order, double qq, double zz)
C++ version of gsl_sf_mathieu_Mc().
Definition: sf_mathieu.hpp:392
double a(int order, double qq)
C++ version of gsl_sf_mathieu_a().
Definition: sf_mathieu.hpp:272
int Ms_e(int kind, int order, double qq, double zz, result &result)
C++ version of gsl_sf_mathieu_Ms_e().
Definition: sf_mathieu.hpp:424
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