blib/lib/Math/GSL/Multiset.pm untested

filter: Statementstmt 0.0% 0 / 144 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 26 Podpod 0.0% 0 / 22 totaltotal 0.0% 0 / 214 CC 7 SCAR 16.1
CC
7
Cov
0%
DESTROY
20.0
new
6.0
new
6.0
CRAP 5.0
1 # This file was automatically generated by SWIG (https://www.swig.org).
2 # Version 4.2.0
3 #
4 # Do not make changes to this file unless you know what you are doing - modify
5 # the SWIG interface file instead.
6  
7 package Math::GSL::Multiset;
8 use base qw(Exporter);
9 use base qw(DynaLoader);
10 package Math::GSL::Multisetc;
11 bootstrap Math::GSL::Multiset;
12 package Math::GSL::Multiset;
13 @EXPORT = qw();
14  
15 # ---------- BASE METHODS -------------
16  
17 package Math::GSL::Multiset;
18  
19 sub TIEHASH {
20 my ($classname,$obj) = @_;
21 return bless $obj, $classname;
22 }
23  
24 sub CLEAR { }
25  
26 sub FIRSTKEY { }
27  
28 sub NEXTKEY { }
29  
30 sub FETCH {
31 my ($self,$field) = @_;
32 my $member_func = "swig_${field}_get";
33 $self->$member_func();
34 }
35  
36 sub STORE {
37 my ($self,$field,$newval) = @_;
38 my $member_func = "swig_${field}_set";
39 $self->$member_func($newval);
40 }
41  
42 sub this {
43 my $ptr = shift;
44 return tied(%$ptr);
45 }
46  
47  
48 # ------- FUNCTION WRAPPERS --------
49  
50 package Math::GSL::Multiset;
51  
52 *gsl_error = *Math::GSL::Multisetc::gsl_error;
53 *gsl_stream_printf = *Math::GSL::Multisetc::gsl_stream_printf;
54 *gsl_strerror = *Math::GSL::Multisetc::gsl_strerror;
55 *gsl_set_error_handler = *Math::GSL::Multisetc::gsl_set_error_handler;
56 *gsl_set_error_handler_off = *Math::GSL::Multisetc::gsl_set_error_handler_off;
57 *gsl_set_stream_handler = *Math::GSL::Multisetc::gsl_set_stream_handler;
58 *gsl_set_stream = *Math::GSL::Multisetc::gsl_set_stream;
59 *gsl_multiset_alloc = *Math::GSL::Multisetc::gsl_multiset_alloc;
60 *gsl_multiset_calloc = *Math::GSL::Multisetc::gsl_multiset_calloc;
61 *gsl_multiset_init_first = *Math::GSL::Multisetc::gsl_multiset_init_first;
62 *gsl_multiset_init_last = *Math::GSL::Multisetc::gsl_multiset_init_last;
63 *gsl_multiset_free = *Math::GSL::Multisetc::gsl_multiset_free;
64 *gsl_multiset_memcpy = *Math::GSL::Multisetc::gsl_multiset_memcpy;
65 *gsl_multiset_fread = *Math::GSL::Multisetc::gsl_multiset_fread;
66 *gsl_multiset_fwrite = *Math::GSL::Multisetc::gsl_multiset_fwrite;
67 *gsl_multiset_fscanf = *Math::GSL::Multisetc::gsl_multiset_fscanf;
68 *gsl_multiset_fprintf = *Math::GSL::Multisetc::gsl_multiset_fprintf;
69 *gsl_multiset_n = *Math::GSL::Multisetc::gsl_multiset_n;
70 *gsl_multiset_k = *Math::GSL::Multisetc::gsl_multiset_k;
71 *gsl_multiset_data = *Math::GSL::Multisetc::gsl_multiset_data;
72 *gsl_multiset_valid = *Math::GSL::Multisetc::gsl_multiset_valid;
73 *gsl_multiset_next = *Math::GSL::Multisetc::gsl_multiset_next;
74 *gsl_multiset_prev = *Math::GSL::Multisetc::gsl_multiset_prev;
75 *gsl_multiset_get = *Math::GSL::Multisetc::gsl_multiset_get;
76  
77 ############# Class : Math::GSL::Multiset::gsl_multiset_struct ##############
78  
79 package Math::GSL::Multiset::gsl_multiset_struct;
80 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
81 @ISA = qw( Math::GSL::Multiset );
82 %OWNER = ();
83 %ITERATORS = ();
84 *swig_n_get = *Math::GSL::Multisetc::gsl_multiset_struct_n_get;
85 *swig_n_set = *Math::GSL::Multisetc::gsl_multiset_struct_n_set;
86 *swig_k_get = *Math::GSL::Multisetc::gsl_multiset_struct_k_get;
87 *swig_k_set = *Math::GSL::Multisetc::gsl_multiset_struct_k_set;
88 *swig_data_get = *Math::GSL::Multisetc::gsl_multiset_struct_data_get;
89 *swig_data_set = *Math::GSL::Multisetc::gsl_multiset_struct_data_set;
90 sub new {
91 my $pkg = shift;
92 my $self = Math::GSL::Multisetc::new_gsl_multiset_struct(@_);
93 bless $self, $pkg if defined($self);
94 }
95  
96 sub DESTROY {
97 return unless $_[0]->isa('HASH');
98 my $self = tied(%{$_[0]});
99 return unless defined $self;
100 delete $ITERATORS{$self};
101 if (exists $OWNER{$self}) {
102 Math::GSL::Multisetc::delete_gsl_multiset_struct($self);
103 delete $OWNER{$self};
104 }
105 }
106  
107 sub DISOWN {
108 my $self = shift;
109 my $ptr = tied(%$self);
110 delete $OWNER{$ptr};
111 }
112  
113 sub ACQUIRE {
114 my $self = shift;
115 my $ptr = tied(%$self);
116 $OWNER{$ptr} = 1;
117 }
118  
119  
120 # ------- VARIABLE STUBS --------
121  
122 package Math::GSL::Multiset;
123  
124 *GSL_VERSION = *Math::GSL::Multisetc::GSL_VERSION;
125 *GSL_MAJOR_VERSION = *Math::GSL::Multisetc::GSL_MAJOR_VERSION;
126 *GSL_MINOR_VERSION = *Math::GSL::Multisetc::GSL_MINOR_VERSION;
127 *GSL_POSZERO = *Math::GSL::Multisetc::GSL_POSZERO;
128 *GSL_NEGZERO = *Math::GSL::Multisetc::GSL_NEGZERO;
129 *GSL_SUCCESS = *Math::GSL::Multisetc::GSL_SUCCESS;
130 *GSL_FAILURE = *Math::GSL::Multisetc::GSL_FAILURE;
131 *GSL_CONTINUE = *Math::GSL::Multisetc::GSL_CONTINUE;
132 *GSL_EDOM = *Math::GSL::Multisetc::GSL_EDOM;
133 *GSL_ERANGE = *Math::GSL::Multisetc::GSL_ERANGE;
134 *GSL_EFAULT = *Math::GSL::Multisetc::GSL_EFAULT;
135 *GSL_EINVAL = *Math::GSL::Multisetc::GSL_EINVAL;
136 *GSL_EFAILED = *Math::GSL::Multisetc::GSL_EFAILED;
137 *GSL_EFACTOR = *Math::GSL::Multisetc::GSL_EFACTOR;
138 *GSL_ESANITY = *Math::GSL::Multisetc::GSL_ESANITY;
139 *GSL_ENOMEM = *Math::GSL::Multisetc::GSL_ENOMEM;
140 *GSL_EBADFUNC = *Math::GSL::Multisetc::GSL_EBADFUNC;
141 *GSL_ERUNAWAY = *Math::GSL::Multisetc::GSL_ERUNAWAY;
142 *GSL_EMAXITER = *Math::GSL::Multisetc::GSL_EMAXITER;
143 *GSL_EZERODIV = *Math::GSL::Multisetc::GSL_EZERODIV;
144 *GSL_EBADTOL = *Math::GSL::Multisetc::GSL_EBADTOL;
145 *GSL_ETOL = *Math::GSL::Multisetc::GSL_ETOL;
146 *GSL_EUNDRFLW = *Math::GSL::Multisetc::GSL_EUNDRFLW;
147 *GSL_EOVRFLW = *Math::GSL::Multisetc::GSL_EOVRFLW;
148 *GSL_ELOSS = *Math::GSL::Multisetc::GSL_ELOSS;
149 *GSL_EROUND = *Math::GSL::Multisetc::GSL_EROUND;
150 *GSL_EBADLEN = *Math::GSL::Multisetc::GSL_EBADLEN;
151 *GSL_ENOTSQR = *Math::GSL::Multisetc::GSL_ENOTSQR;
152 *GSL_ESING = *Math::GSL::Multisetc::GSL_ESING;
153 *GSL_EDIVERGE = *Math::GSL::Multisetc::GSL_EDIVERGE;
154 *GSL_EUNSUP = *Math::GSL::Multisetc::GSL_EUNSUP;
155 *GSL_EUNIMPL = *Math::GSL::Multisetc::GSL_EUNIMPL;
156 *GSL_ECACHE = *Math::GSL::Multisetc::GSL_ECACHE;
157 *GSL_ETABLE = *Math::GSL::Multisetc::GSL_ETABLE;
158 *GSL_ENOPROG = *Math::GSL::Multisetc::GSL_ENOPROG;
159 *GSL_ENOPROGJ = *Math::GSL::Multisetc::GSL_ENOPROGJ;
160 *GSL_ETOLF = *Math::GSL::Multisetc::GSL_ETOLF;
161 *GSL_ETOLX = *Math::GSL::Multisetc::GSL_ETOLX;
162 *GSL_ETOLG = *Math::GSL::Multisetc::GSL_ETOLG;
163 *GSL_EOF = *Math::GSL::Multisetc::GSL_EOF;
164  
165  
166 use Math::GSL qw/gsl_version/;
167  
168 @EXPORT_OK = qw/
169 gsl_multiset_calloc gsl_multiset_alloc
170 gsl_multiset_init_first gsl_multiset_init_last
171 gsl_multiset_free gsl_multiset_memcpy
172 gsl_multiset_get gsl_multiset_n gsl_multiset_k
173 gsl_multiset_data
174 gsl_multiset_valid
175 gsl_multiset_next gsl_multiset_prev
176 gsl_multiset_fwrite
177 gsl_multiset_fread
178 gsl_multiset_fprintf
179 gsl_multiset_fscanf
180 /;
181  
182  
183 %EXPORT_TAGS = ( all => [ @EXPORT_OK ] );
184  
185 sub new {
186 my ($class, $n, $k) = @_;
187  
188 if (gsl_version() < v1.16 && $k > $n) {
189 die __PACKAGE__.": This version of GSL doesn't support k > n"
190 }
191  
192 my $self = { k => $k, n => $n, multiset => gsl_multiset_calloc($n, $k)};
193  
194 return bless $self, $class;
195 }
196  
197 sub init_first {
198 my ($self) = @_;
199 gsl_multiset_init_first($self->{multiset});
200 }
201  
202 sub init_last {
203 my ($self) = @_;
204 gsl_multiset_init_last($self->{multiset});
205 }
206  
207  
208 sub get {
209 my ($self, $i) = @_;
210 die __PACKAGE__.": element $i is out of range (0 <= i < $self->{k})"
211 unless $i >= 0 && $i < $self->{k};
212 return gsl_multiset_get($self->{multiset}, $i);
213 }
214  
215 sub k { $_[0]->{k} }
216 sub n { $_[0]->{n} }
217  
218 sub clone {
219 my $self = shift;
220 my $other = ref($self)->new($self->n, $self->k);
221 gsl_multiset_memcpy($other->{multiset}, $self->{multiset});
222 return $other;
223 }
224  
225 sub next {
226 my $self=shift;
227 return gsl_multiset_next($self->{multiset});
228 }
229  
230 sub prev {
231 my $self=shift;
232 return gsl_multiset_prev($self->{multiset});
233 }
234  
235 sub to_list {
236 my $self = shift;
237 return map { $self->get($_) } (0..$self->k-1);
238 }
239  
240 sub DESTROY {
241 my $self = shift;
242 gsl_multiset_free($self->{multiset});
243 }
244  
245 __END__