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

filter: Statementstmt 0.0% 0 / 518 Branchbran 0.0% 0 / 100 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 0.0% 0 / 79 Podpod 0.0% 0 / 59 totaltotal 0.0% 0 / 797 CC 51 SCAR 22.0
CC
51
Cov
0%
DESTROY
20.0
DESTROY
20.0
DESTROY
20.0
CRAP 9.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::VectorComplex;
8 use base qw(Exporter);
9 use base qw(DynaLoader);
10 package Math::GSL::VectorComplexc;
11 bootstrap Math::GSL::VectorComplex;
12 package Math::GSL::VectorComplex;
13 @EXPORT = qw();
14  
15 # ---------- BASE METHODS -------------
16  
17 package Math::GSL::VectorComplex;
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::VectorComplex;
51  
52 *gsl_error = *Math::GSL::VectorComplexc::gsl_error;
53 *gsl_stream_printf = *Math::GSL::VectorComplexc::gsl_stream_printf;
54 *gsl_strerror = *Math::GSL::VectorComplexc::gsl_strerror;
55 *gsl_set_error_handler = *Math::GSL::VectorComplexc::gsl_set_error_handler;
56 *gsl_set_error_handler_off = *Math::GSL::VectorComplexc::gsl_set_error_handler_off;
57 *gsl_set_stream_handler = *Math::GSL::VectorComplexc::gsl_set_stream_handler;
58 *gsl_set_stream = *Math::GSL::VectorComplexc::gsl_set_stream;
59 *gsl_vector_alloc = *Math::GSL::VectorComplexc::gsl_vector_alloc;
60 *gsl_vector_calloc = *Math::GSL::VectorComplexc::gsl_vector_calloc;
61 *gsl_vector_alloc_from_block = *Math::GSL::VectorComplexc::gsl_vector_alloc_from_block;
62 *gsl_vector_alloc_from_vector = *Math::GSL::VectorComplexc::gsl_vector_alloc_from_vector;
63 *gsl_vector_free = *Math::GSL::VectorComplexc::gsl_vector_free;
64 *gsl_vector_view_array = *Math::GSL::VectorComplexc::gsl_vector_view_array;
65 *gsl_vector_view_array_with_stride = *Math::GSL::VectorComplexc::gsl_vector_view_array_with_stride;
66 *gsl_vector_const_view_array = *Math::GSL::VectorComplexc::gsl_vector_const_view_array;
67 *gsl_vector_const_view_array_with_stride = *Math::GSL::VectorComplexc::gsl_vector_const_view_array_with_stride;
68 *gsl_vector_subvector = *Math::GSL::VectorComplexc::gsl_vector_subvector;
69 *gsl_vector_subvector_with_stride = *Math::GSL::VectorComplexc::gsl_vector_subvector_with_stride;
70 *gsl_vector_const_subvector = *Math::GSL::VectorComplexc::gsl_vector_const_subvector;
71 *gsl_vector_const_subvector_with_stride = *Math::GSL::VectorComplexc::gsl_vector_const_subvector_with_stride;
72 *gsl_vector_set_zero = *Math::GSL::VectorComplexc::gsl_vector_set_zero;
73 *gsl_vector_set_all = *Math::GSL::VectorComplexc::gsl_vector_set_all;
74 *gsl_vector_set_basis = *Math::GSL::VectorComplexc::gsl_vector_set_basis;
75 *gsl_vector_fread = *Math::GSL::VectorComplexc::gsl_vector_fread;
76 *gsl_vector_fwrite = *Math::GSL::VectorComplexc::gsl_vector_fwrite;
77 *gsl_vector_fscanf = *Math::GSL::VectorComplexc::gsl_vector_fscanf;
78 *gsl_vector_fprintf = *Math::GSL::VectorComplexc::gsl_vector_fprintf;
79 *gsl_vector_memcpy = *Math::GSL::VectorComplexc::gsl_vector_memcpy;
80 *gsl_vector_reverse = *Math::GSL::VectorComplexc::gsl_vector_reverse;
81 *gsl_vector_swap = *Math::GSL::VectorComplexc::gsl_vector_swap;
82 *gsl_vector_swap_elements = *Math::GSL::VectorComplexc::gsl_vector_swap_elements;
83 *gsl_vector_max = *Math::GSL::VectorComplexc::gsl_vector_max;
84 *gsl_vector_min = *Math::GSL::VectorComplexc::gsl_vector_min;
85 *gsl_vector_minmax = *Math::GSL::VectorComplexc::gsl_vector_minmax;
86 *gsl_vector_max_index = *Math::GSL::VectorComplexc::gsl_vector_max_index;
87 *gsl_vector_min_index = *Math::GSL::VectorComplexc::gsl_vector_min_index;
88 *gsl_vector_minmax_index = *Math::GSL::VectorComplexc::gsl_vector_minmax_index;
89 *gsl_vector_add = *Math::GSL::VectorComplexc::gsl_vector_add;
90 *gsl_vector_sub = *Math::GSL::VectorComplexc::gsl_vector_sub;
91 *gsl_vector_mul = *Math::GSL::VectorComplexc::gsl_vector_mul;
92 *gsl_vector_div = *Math::GSL::VectorComplexc::gsl_vector_div;
93 *gsl_vector_scale = *Math::GSL::VectorComplexc::gsl_vector_scale;
94 *gsl_vector_add_constant = *Math::GSL::VectorComplexc::gsl_vector_add_constant;
95 *gsl_vector_axpby = *Math::GSL::VectorComplexc::gsl_vector_axpby;
96 *gsl_vector_sum = *Math::GSL::VectorComplexc::gsl_vector_sum;
97 *gsl_vector_equal = *Math::GSL::VectorComplexc::gsl_vector_equal;
98 *gsl_vector_isnull = *Math::GSL::VectorComplexc::gsl_vector_isnull;
99 *gsl_vector_ispos = *Math::GSL::VectorComplexc::gsl_vector_ispos;
100 *gsl_vector_isneg = *Math::GSL::VectorComplexc::gsl_vector_isneg;
101 *gsl_vector_isnonneg = *Math::GSL::VectorComplexc::gsl_vector_isnonneg;
102 *gsl_vector_get = *Math::GSL::VectorComplexc::gsl_vector_get;
103 *gsl_vector_set = *Math::GSL::VectorComplexc::gsl_vector_set;
104 *gsl_vector_ptr = *Math::GSL::VectorComplexc::gsl_vector_ptr;
105 *gsl_vector_const_ptr = *Math::GSL::VectorComplexc::gsl_vector_const_ptr;
106 *gsl_vector_complex_alloc = *Math::GSL::VectorComplexc::gsl_vector_complex_alloc;
107 *gsl_vector_complex_calloc = *Math::GSL::VectorComplexc::gsl_vector_complex_calloc;
108 *gsl_vector_complex_alloc_from_block = *Math::GSL::VectorComplexc::gsl_vector_complex_alloc_from_block;
109 *gsl_vector_complex_alloc_from_vector = *Math::GSL::VectorComplexc::gsl_vector_complex_alloc_from_vector;
110 *gsl_vector_complex_free = *Math::GSL::VectorComplexc::gsl_vector_complex_free;
111 *gsl_vector_complex_view_array = *Math::GSL::VectorComplexc::gsl_vector_complex_view_array;
112 *gsl_vector_complex_view_array_with_stride = *Math::GSL::VectorComplexc::gsl_vector_complex_view_array_with_stride;
113 *gsl_vector_complex_const_view_array = *Math::GSL::VectorComplexc::gsl_vector_complex_const_view_array;
114 *gsl_vector_complex_const_view_array_with_stride = *Math::GSL::VectorComplexc::gsl_vector_complex_const_view_array_with_stride;
115 *gsl_vector_complex_subvector = *Math::GSL::VectorComplexc::gsl_vector_complex_subvector;
116 *gsl_vector_complex_subvector_with_stride = *Math::GSL::VectorComplexc::gsl_vector_complex_subvector_with_stride;
117 *gsl_vector_complex_const_subvector = *Math::GSL::VectorComplexc::gsl_vector_complex_const_subvector;
118 *gsl_vector_complex_const_subvector_with_stride = *Math::GSL::VectorComplexc::gsl_vector_complex_const_subvector_with_stride;
119 *gsl_vector_complex_real = *Math::GSL::VectorComplexc::gsl_vector_complex_real;
120 *gsl_vector_complex_imag = *Math::GSL::VectorComplexc::gsl_vector_complex_imag;
121 *gsl_vector_complex_const_real = *Math::GSL::VectorComplexc::gsl_vector_complex_const_real;
122 *gsl_vector_complex_const_imag = *Math::GSL::VectorComplexc::gsl_vector_complex_const_imag;
123 *gsl_vector_complex_set_zero = *Math::GSL::VectorComplexc::gsl_vector_complex_set_zero;
124 *gsl_vector_complex_set_all = *Math::GSL::VectorComplexc::gsl_vector_complex_set_all;
125 *gsl_vector_complex_set_basis = *Math::GSL::VectorComplexc::gsl_vector_complex_set_basis;
126 *gsl_vector_complex_fread = *Math::GSL::VectorComplexc::gsl_vector_complex_fread;
127 *gsl_vector_complex_fwrite = *Math::GSL::VectorComplexc::gsl_vector_complex_fwrite;
128 *gsl_vector_complex_fscanf = *Math::GSL::VectorComplexc::gsl_vector_complex_fscanf;
129 *gsl_vector_complex_fprintf = *Math::GSL::VectorComplexc::gsl_vector_complex_fprintf;
130 *gsl_vector_complex_memcpy = *Math::GSL::VectorComplexc::gsl_vector_complex_memcpy;
131 *gsl_vector_complex_conj_memcpy = *Math::GSL::VectorComplexc::gsl_vector_complex_conj_memcpy;
132 *gsl_vector_complex_reverse = *Math::GSL::VectorComplexc::gsl_vector_complex_reverse;
133 *gsl_vector_complex_swap = *Math::GSL::VectorComplexc::gsl_vector_complex_swap;
134 *gsl_vector_complex_swap_elements = *Math::GSL::VectorComplexc::gsl_vector_complex_swap_elements;
135 *gsl_vector_complex_equal = *Math::GSL::VectorComplexc::gsl_vector_complex_equal;
136 *gsl_vector_complex_isnull = *Math::GSL::VectorComplexc::gsl_vector_complex_isnull;
137 *gsl_vector_complex_ispos = *Math::GSL::VectorComplexc::gsl_vector_complex_ispos;
138 *gsl_vector_complex_isneg = *Math::GSL::VectorComplexc::gsl_vector_complex_isneg;
139 *gsl_vector_complex_isnonneg = *Math::GSL::VectorComplexc::gsl_vector_complex_isnonneg;
140 *gsl_vector_complex_add = *Math::GSL::VectorComplexc::gsl_vector_complex_add;
141 *gsl_vector_complex_sub = *Math::GSL::VectorComplexc::gsl_vector_complex_sub;
142 *gsl_vector_complex_mul = *Math::GSL::VectorComplexc::gsl_vector_complex_mul;
143 *gsl_vector_complex_div = *Math::GSL::VectorComplexc::gsl_vector_complex_div;
144 *gsl_vector_complex_scale = *Math::GSL::VectorComplexc::gsl_vector_complex_scale;
145 *gsl_vector_complex_add_constant = *Math::GSL::VectorComplexc::gsl_vector_complex_add_constant;
146 *gsl_vector_complex_axpby = *Math::GSL::VectorComplexc::gsl_vector_complex_axpby;
147 *gsl_vector_complex_div_real = *Math::GSL::VectorComplexc::gsl_vector_complex_div_real;
148 *gsl_vector_complex_get = *Math::GSL::VectorComplexc::gsl_vector_complex_get;
149 *gsl_vector_complex_set = *Math::GSL::VectorComplexc::gsl_vector_complex_set;
150 *gsl_vector_complex_ptr = *Math::GSL::VectorComplexc::gsl_vector_complex_ptr;
151 *gsl_vector_complex_const_ptr = *Math::GSL::VectorComplexc::gsl_vector_complex_const_ptr;
152  
153 ############# Class : Math::GSL::VectorComplex::gsl_complex ##############
154  
155 package Math::GSL::VectorComplex::gsl_complex;
156 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
157 @ISA = qw( Math::GSL::VectorComplex );
158 %OWNER = ();
159 %ITERATORS = ();
160 *swig_dat_get = *Math::GSL::VectorComplexc::gsl_complex_dat_get;
161 *swig_dat_set = *Math::GSL::VectorComplexc::gsl_complex_dat_set;
162 sub new {
163 my $pkg = shift;
164 my $self = Math::GSL::VectorComplexc::new_gsl_complex(@_);
165 bless $self, $pkg if defined($self);
166 }
167  
168 sub DESTROY {
169 return unless $_[0]->isa('HASH');
170 my $self = tied(%{$_[0]});
171 return unless defined $self;
172 delete $ITERATORS{$self};
173 if (exists $OWNER{$self}) {
174 Math::GSL::VectorComplexc::delete_gsl_complex($self);
175 delete $OWNER{$self};
176 }
177 }
178  
179 sub DISOWN {
180 my $self = shift;
181 my $ptr = tied(%$self);
182 delete $OWNER{$ptr};
183 }
184  
185 sub ACQUIRE {
186 my $self = shift;
187 my $ptr = tied(%$self);
188 $OWNER{$ptr} = 1;
189 }
190  
191  
192 ############# Class : Math::GSL::VectorComplex::gsl_complex_long_double ##############
193  
194 package Math::GSL::VectorComplex::gsl_complex_long_double;
195 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
196 @ISA = qw( Math::GSL::VectorComplex );
197 %OWNER = ();
198 %ITERATORS = ();
199 *swig_dat_get = *Math::GSL::VectorComplexc::gsl_complex_long_double_dat_get;
200 *swig_dat_set = *Math::GSL::VectorComplexc::gsl_complex_long_double_dat_set;
201 sub new {
202 my $pkg = shift;
203 my $self = Math::GSL::VectorComplexc::new_gsl_complex_long_double(@_);
204 bless $self, $pkg if defined($self);
205 }
206  
207 sub DESTROY {
208 return unless $_[0]->isa('HASH');
209 my $self = tied(%{$_[0]});
210 return unless defined $self;
211 delete $ITERATORS{$self};
212 if (exists $OWNER{$self}) {
213 Math::GSL::VectorComplexc::delete_gsl_complex_long_double($self);
214 delete $OWNER{$self};
215 }
216 }
217  
218 sub DISOWN {
219 my $self = shift;
220 my $ptr = tied(%$self);
221 delete $OWNER{$ptr};
222 }
223  
224 sub ACQUIRE {
225 my $self = shift;
226 my $ptr = tied(%$self);
227 $OWNER{$ptr} = 1;
228 }
229  
230  
231 ############# Class : Math::GSL::VectorComplex::gsl_complex_float ##############
232  
233 package Math::GSL::VectorComplex::gsl_complex_float;
234 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
235 @ISA = qw( Math::GSL::VectorComplex );
236 %OWNER = ();
237 %ITERATORS = ();
238 *swig_dat_get = *Math::GSL::VectorComplexc::gsl_complex_float_dat_get;
239 *swig_dat_set = *Math::GSL::VectorComplexc::gsl_complex_float_dat_set;
240 sub new {
241 my $pkg = shift;
242 my $self = Math::GSL::VectorComplexc::new_gsl_complex_float(@_);
243 bless $self, $pkg if defined($self);
244 }
245  
246 sub DESTROY {
247 return unless $_[0]->isa('HASH');
248 my $self = tied(%{$_[0]});
249 return unless defined $self;
250 delete $ITERATORS{$self};
251 if (exists $OWNER{$self}) {
252 Math::GSL::VectorComplexc::delete_gsl_complex_float($self);
253 delete $OWNER{$self};
254 }
255 }
256  
257 sub DISOWN {
258 my $self = shift;
259 my $ptr = tied(%$self);
260 delete $OWNER{$ptr};
261 }
262  
263 sub ACQUIRE {
264 my $self = shift;
265 my $ptr = tied(%$self);
266 $OWNER{$ptr} = 1;
267 }
268  
269  
270 ############# Class : Math::GSL::VectorComplex::gsl_vector ##############
271  
272 package Math::GSL::VectorComplex::gsl_vector;
273 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
274 @ISA = qw( Math::GSL::VectorComplex );
275 %OWNER = ();
276 %ITERATORS = ();
277 *swig_size_get = *Math::GSL::VectorComplexc::gsl_vector_size_get;
278 *swig_size_set = *Math::GSL::VectorComplexc::gsl_vector_size_set;
279 *swig_stride_get = *Math::GSL::VectorComplexc::gsl_vector_stride_get;
280 *swig_stride_set = *Math::GSL::VectorComplexc::gsl_vector_stride_set;
281 *swig_data_get = *Math::GSL::VectorComplexc::gsl_vector_data_get;
282 *swig_data_set = *Math::GSL::VectorComplexc::gsl_vector_data_set;
283 *swig_block_get = *Math::GSL::VectorComplexc::gsl_vector_block_get;
284 *swig_block_set = *Math::GSL::VectorComplexc::gsl_vector_block_set;
285 *swig_owner_get = *Math::GSL::VectorComplexc::gsl_vector_owner_get;
286 *swig_owner_set = *Math::GSL::VectorComplexc::gsl_vector_owner_set;
287 sub new {
288 my $pkg = shift;
289 my $self = Math::GSL::VectorComplexc::new_gsl_vector(@_);
290 bless $self, $pkg if defined($self);
291 }
292  
293 sub DESTROY {
294 return unless $_[0]->isa('HASH');
295 my $self = tied(%{$_[0]});
296 return unless defined $self;
297 delete $ITERATORS{$self};
298 if (exists $OWNER{$self}) {
299 Math::GSL::VectorComplexc::delete_gsl_vector($self);
300 delete $OWNER{$self};
301 }
302 }
303  
304 sub DISOWN {
305 my $self = shift;
306 my $ptr = tied(%$self);
307 delete $OWNER{$ptr};
308 }
309  
310 sub ACQUIRE {
311 my $self = shift;
312 my $ptr = tied(%$self);
313 $OWNER{$ptr} = 1;
314 }
315  
316  
317 ############# Class : Math::GSL::VectorComplex::_gsl_vector_view ##############
318  
319 package Math::GSL::VectorComplex::_gsl_vector_view;
320 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
321 @ISA = qw( Math::GSL::VectorComplex );
322 %OWNER = ();
323 %ITERATORS = ();
324 *swig_vector_get = *Math::GSL::VectorComplexc::_gsl_vector_view_vector_get;
325 *swig_vector_set = *Math::GSL::VectorComplexc::_gsl_vector_view_vector_set;
326 sub new {
327 my $pkg = shift;
328 my $self = Math::GSL::VectorComplexc::new__gsl_vector_view(@_);
329 bless $self, $pkg if defined($self);
330 }
331  
332 sub DESTROY {
333 return unless $_[0]->isa('HASH');
334 my $self = tied(%{$_[0]});
335 return unless defined $self;
336 delete $ITERATORS{$self};
337 if (exists $OWNER{$self}) {
338 Math::GSL::VectorComplexc::delete__gsl_vector_view($self);
339 delete $OWNER{$self};
340 }
341 }
342  
343 sub DISOWN {
344 my $self = shift;
345 my $ptr = tied(%$self);
346 delete $OWNER{$ptr};
347 }
348  
349 sub ACQUIRE {
350 my $self = shift;
351 my $ptr = tied(%$self);
352 $OWNER{$ptr} = 1;
353 }
354  
355  
356 ############# Class : Math::GSL::VectorComplex::_gsl_vector_const_view ##############
357  
358 package Math::GSL::VectorComplex::_gsl_vector_const_view;
359 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
360 @ISA = qw( Math::GSL::VectorComplex );
361 %OWNER = ();
362 %ITERATORS = ();
363 *swig_vector_get = *Math::GSL::VectorComplexc::_gsl_vector_const_view_vector_get;
364 *swig_vector_set = *Math::GSL::VectorComplexc::_gsl_vector_const_view_vector_set;
365 sub new {
366 my $pkg = shift;
367 my $self = Math::GSL::VectorComplexc::new__gsl_vector_const_view(@_);
368 bless $self, $pkg if defined($self);
369 }
370  
371 sub DESTROY {
372 return unless $_[0]->isa('HASH');
373 my $self = tied(%{$_[0]});
374 return unless defined $self;
375 delete $ITERATORS{$self};
376 if (exists $OWNER{$self}) {
377 Math::GSL::VectorComplexc::delete__gsl_vector_const_view($self);
378 delete $OWNER{$self};
379 }
380 }
381  
382 sub DISOWN {
383 my $self = shift;
384 my $ptr = tied(%$self);
385 delete $OWNER{$ptr};
386 }
387  
388 sub ACQUIRE {
389 my $self = shift;
390 my $ptr = tied(%$self);
391 $OWNER{$ptr} = 1;
392 }
393  
394  
395 ############# Class : Math::GSL::VectorComplex::gsl_vector_complex ##############
396  
397 package Math::GSL::VectorComplex::gsl_vector_complex;
398 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
399 @ISA = qw( Math::GSL::VectorComplex );
400 %OWNER = ();
401 %ITERATORS = ();
402 *swig_size_get = *Math::GSL::VectorComplexc::gsl_vector_complex_size_get;
403 *swig_size_set = *Math::GSL::VectorComplexc::gsl_vector_complex_size_set;
404 *swig_stride_get = *Math::GSL::VectorComplexc::gsl_vector_complex_stride_get;
405 *swig_stride_set = *Math::GSL::VectorComplexc::gsl_vector_complex_stride_set;
406 *swig_data_get = *Math::GSL::VectorComplexc::gsl_vector_complex_data_get;
407 *swig_data_set = *Math::GSL::VectorComplexc::gsl_vector_complex_data_set;
408 *swig_block_get = *Math::GSL::VectorComplexc::gsl_vector_complex_block_get;
409 *swig_block_set = *Math::GSL::VectorComplexc::gsl_vector_complex_block_set;
410 *swig_owner_get = *Math::GSL::VectorComplexc::gsl_vector_complex_owner_get;
411 *swig_owner_set = *Math::GSL::VectorComplexc::gsl_vector_complex_owner_set;
412 sub new {
413 my $pkg = shift;
414 my $self = Math::GSL::VectorComplexc::new_gsl_vector_complex(@_);
415 bless $self, $pkg if defined($self);
416 }
417  
418 sub DESTROY {
419 return unless $_[0]->isa('HASH');
420 my $self = tied(%{$_[0]});
421 return unless defined $self;
422 delete $ITERATORS{$self};
423 if (exists $OWNER{$self}) {
424 Math::GSL::VectorComplexc::delete_gsl_vector_complex($self);
425 delete $OWNER{$self};
426 }
427 }
428  
429 sub DISOWN {
430 my $self = shift;
431 my $ptr = tied(%$self);
432 delete $OWNER{$ptr};
433 }
434  
435 sub ACQUIRE {
436 my $self = shift;
437 my $ptr = tied(%$self);
438 $OWNER{$ptr} = 1;
439 }
440  
441  
442 ############# Class : Math::GSL::VectorComplex::_gsl_vector_complex_view ##############
443  
444 package Math::GSL::VectorComplex::_gsl_vector_complex_view;
445 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
446 @ISA = qw( Math::GSL::VectorComplex );
447 %OWNER = ();
448 %ITERATORS = ();
449 *swig_vector_get = *Math::GSL::VectorComplexc::_gsl_vector_complex_view_vector_get;
450 *swig_vector_set = *Math::GSL::VectorComplexc::_gsl_vector_complex_view_vector_set;
451 sub new {
452 my $pkg = shift;
453 my $self = Math::GSL::VectorComplexc::new__gsl_vector_complex_view(@_);
454 bless $self, $pkg if defined($self);
455 }
456  
457 sub DESTROY {
458 return unless $_[0]->isa('HASH');
459 my $self = tied(%{$_[0]});
460 return unless defined $self;
461 delete $ITERATORS{$self};
462 if (exists $OWNER{$self}) {
463 Math::GSL::VectorComplexc::delete__gsl_vector_complex_view($self);
464 delete $OWNER{$self};
465 }
466 }
467  
468 sub DISOWN {
469 my $self = shift;
470 my $ptr = tied(%$self);
471 delete $OWNER{$ptr};
472 }
473  
474 sub ACQUIRE {
475 my $self = shift;
476 my $ptr = tied(%$self);
477 $OWNER{$ptr} = 1;
478 }
479  
480  
481 ############# Class : Math::GSL::VectorComplex::_gsl_vector_complex_const_view ##############
482  
483 package Math::GSL::VectorComplex::_gsl_vector_complex_const_view;
484 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
485 @ISA = qw( Math::GSL::VectorComplex );
486 %OWNER = ();
487 %ITERATORS = ();
488 *swig_vector_get = *Math::GSL::VectorComplexc::_gsl_vector_complex_const_view_vector_get;
489 *swig_vector_set = *Math::GSL::VectorComplexc::_gsl_vector_complex_const_view_vector_set;
490 sub new {
491 my $pkg = shift;
492 my $self = Math::GSL::VectorComplexc::new__gsl_vector_complex_const_view(@_);
493 bless $self, $pkg if defined($self);
494 }
495  
496 sub DESTROY {
497 return unless $_[0]->isa('HASH');
498 my $self = tied(%{$_[0]});
499 return unless defined $self;
500 delete $ITERATORS{$self};
501 if (exists $OWNER{$self}) {
502 Math::GSL::VectorComplexc::delete__gsl_vector_complex_const_view($self);
503 delete $OWNER{$self};
504 }
505 }
506  
507 sub DISOWN {
508 my $self = shift;
509 my $ptr = tied(%$self);
510 delete $OWNER{$ptr};
511 }
512  
513 sub ACQUIRE {
514 my $self = shift;
515 my $ptr = tied(%$self);
516 $OWNER{$ptr} = 1;
517 }
518  
519  
520 # ------- VARIABLE STUBS --------
521  
522 package Math::GSL::VectorComplex;
523  
524 *GSL_VERSION = *Math::GSL::VectorComplexc::GSL_VERSION;
525 *GSL_MAJOR_VERSION = *Math::GSL::VectorComplexc::GSL_MAJOR_VERSION;
526 *GSL_MINOR_VERSION = *Math::GSL::VectorComplexc::GSL_MINOR_VERSION;
527 *GSL_POSZERO = *Math::GSL::VectorComplexc::GSL_POSZERO;
528 *GSL_NEGZERO = *Math::GSL::VectorComplexc::GSL_NEGZERO;
529 *GSL_SUCCESS = *Math::GSL::VectorComplexc::GSL_SUCCESS;
530 *GSL_FAILURE = *Math::GSL::VectorComplexc::GSL_FAILURE;
531 *GSL_CONTINUE = *Math::GSL::VectorComplexc::GSL_CONTINUE;
532 *GSL_EDOM = *Math::GSL::VectorComplexc::GSL_EDOM;
533 *GSL_ERANGE = *Math::GSL::VectorComplexc::GSL_ERANGE;
534 *GSL_EFAULT = *Math::GSL::VectorComplexc::GSL_EFAULT;
535 *GSL_EINVAL = *Math::GSL::VectorComplexc::GSL_EINVAL;
536 *GSL_EFAILED = *Math::GSL::VectorComplexc::GSL_EFAILED;
537 *GSL_EFACTOR = *Math::GSL::VectorComplexc::GSL_EFACTOR;
538 *GSL_ESANITY = *Math::GSL::VectorComplexc::GSL_ESANITY;
539 *GSL_ENOMEM = *Math::GSL::VectorComplexc::GSL_ENOMEM;
540 *GSL_EBADFUNC = *Math::GSL::VectorComplexc::GSL_EBADFUNC;
541 *GSL_ERUNAWAY = *Math::GSL::VectorComplexc::GSL_ERUNAWAY;
542 *GSL_EMAXITER = *Math::GSL::VectorComplexc::GSL_EMAXITER;
543 *GSL_EZERODIV = *Math::GSL::VectorComplexc::GSL_EZERODIV;
544 *GSL_EBADTOL = *Math::GSL::VectorComplexc::GSL_EBADTOL;
545 *GSL_ETOL = *Math::GSL::VectorComplexc::GSL_ETOL;
546 *GSL_EUNDRFLW = *Math::GSL::VectorComplexc::GSL_EUNDRFLW;
547 *GSL_EOVRFLW = *Math::GSL::VectorComplexc::GSL_EOVRFLW;
548 *GSL_ELOSS = *Math::GSL::VectorComplexc::GSL_ELOSS;
549 *GSL_EROUND = *Math::GSL::VectorComplexc::GSL_EROUND;
550 *GSL_EBADLEN = *Math::GSL::VectorComplexc::GSL_EBADLEN;
551 *GSL_ENOTSQR = *Math::GSL::VectorComplexc::GSL_ENOTSQR;
552 *GSL_ESING = *Math::GSL::VectorComplexc::GSL_ESING;
553 *GSL_EDIVERGE = *Math::GSL::VectorComplexc::GSL_EDIVERGE;
554 *GSL_EUNSUP = *Math::GSL::VectorComplexc::GSL_EUNSUP;
555 *GSL_EUNIMPL = *Math::GSL::VectorComplexc::GSL_EUNIMPL;
556 *GSL_ECACHE = *Math::GSL::VectorComplexc::GSL_ECACHE;
557 *GSL_ETABLE = *Math::GSL::VectorComplexc::GSL_ETABLE;
558 *GSL_ENOPROG = *Math::GSL::VectorComplexc::GSL_ENOPROG;
559 *GSL_ENOPROGJ = *Math::GSL::VectorComplexc::GSL_ENOPROGJ;
560 *GSL_ETOLF = *Math::GSL::VectorComplexc::GSL_ETOLF;
561 *GSL_ETOLX = *Math::GSL::VectorComplexc::GSL_ETOLX;
562 *GSL_ETOLG = *Math::GSL::VectorComplexc::GSL_ETOLG;
563 *GSL_EOF = *Math::GSL::VectorComplexc::GSL_EOF;
564  
565 use Scalar::Util 'blessed';
566 use Data::Dumper;
567 use Carp qw/croak/;
568 use Math::GSL::Errno qw/:all/;
569 use Math::GSL::BLAS qw/gsl_blas_ddot/;
570 use Math::GSL::Complex qw/:all/;
571 use Math::GSL::Test qw/is_status_ok/;
572 use Math::Complex;
573 use overload
574 '*' => \&_multiplication,
575 '+' => \&_addition,
576 '-' => \&_subtract,
577 fallback => 1,
578 ;
579  
580 @EXPORT_all = qw/
581 gsl_vector_complex_alloc gsl_vector_complex_calloc gsl_vector_complex_alloc_from_block gsl_vector_complex_alloc_from_vector
582 gsl_vector_complex_free gsl_vector_complex_view_array gsl_vector_complex_view_array_with_stride gsl_vector_complex_const_view_array
583 gsl_vector_complex_const_view_array_with_stride gsl_vector_complex_subvector gsl_vector_complex_subvector_with_stride
584 gsl_vector_complex_const_subvector gsl_vector_complex_const_subvector_with_stride gsl_vector_complex_real gsl_vector_complex_imag
585 gsl_vector_complex_const_real gsl_vector_complex_const_imag gsl_vector_complex_get gsl_vector_complex_set
586 gsl_vector_complex_ptr gsl_vector_complex_const_ptr gsl_vector_complex_set_zero gsl_vector_complex_set_all
587 gsl_vector_complex_set_basis gsl_vector_complex_fread gsl_vector_complex_fwrite gsl_vector_complex_fscanf
588 gsl_vector_complex_fprintf gsl_vector_complex_memcpy gsl_vector_complex_reverse gsl_vector_complex_swap
589 gsl_vector_complex_swap_elements gsl_vector_complex_isnull gsl_vector_complex_ispos gsl_vector_complex_isneg
590 /;
591 @EXPORT_OK = (@EXPORT_all);
592 %EXPORT_TAGS = ( all => \@EXPORT_all );
593  
594 =encoding utf8
595  
596 =head1 NAME
597  
598 Math::GSL::VectorComplex - Complex Vectors
599  
600 =head1 SYNOPSIS
601  
602 use Math::GSL::VectorComplex qw/:all/;
603 my $vec1 = Math::GSL::VectorComplex->new([1 + 2*i, 7*i, 5, -3 ]);
604 my $vec2 = $vec1 * 5;
605 my $vec3 = Math::GSL::Vector>new(10); # 10 element zero vector
606 my $vec4 = $vec1 + $vec2;
607  
608 # set the element at index 1 to -i
609 # and the element at index 3 to i
610 $vec3->set([ 1, -i ], [ 9, i ]);
611  
612 my @vec = $vec2->as_list; # return elements as Perl list
613  
614 my $dot_product = $vec1 * $vec2;
615 my $length = $vec2->length;
616 my $first = $vec1->get(0);
617  
618  
619 =cut
620  
621 =head1 Objected Oriented Interface to GSL Math::GSL::VectorComplex
622  
623 =head2 new()
624  
625 Creates a new Vector of the given size.
626  
627 my $vector = Math::GSL::VectorComplex->new(3);
628  
629 You can also create and set directly the values of the vector like this :
630  
631 my $vector = Math::GSL::VectorComplex->new([2,4,1]);
632  
633 =cut
634  
635 sub new {
636 my ($class, $values) = @_;
637 my $length = $#$values;
638 my $this = {};
639 my $vector;
640  
641 # we expect $values to have Math::Complex objects
642 @$values = map { gsl_complex_rect(Re($_), Im($_)) } @$values;
643  
644 if ( ref $values eq 'ARRAY' ){
645 die __PACKAGE__.'::new($x) - $x must be a nonempty array reference' if $length == -1;
646 $vector = gsl_vector_complex_alloc($length+1);
647 map { gsl_vector_complex_set($vector, $_, $values->[$_] ) } (0 .. $length);
648 $this->{_length} = $length+1;
649 } elsif ( (int($values) == $values) && ($values > 0)) {
650 $vector = gsl_vector_complex_alloc($values);
651 gsl_vector_complex_set_zero($vector);
652 $this->{_length} = $values;
653 } else {
654 die __PACKAGE__.'::new($x) - $x must be an int or array reference';
655 }
656 $this->{_vector} = $vector;
657 bless $this, $class;
658 }
659  
660  
661 =head2 raw()
662  
663 Get the underlying GSL vector object created by SWIG, useful for using gsl_vector_* functions which do not have an OO counterpart.
664  
665 my $vector = Math::GSL::VectorComplex->new(3);
666 my $gsl_vector = $vector->raw;
667 my $stuff = gsl_vector_get($gsl_vector, 1);
668  
669 =cut
670  
671 sub raw {
672 my $self = shift;
673 return $self->{_vector};
674 }
675  
676 =head2 min()
677  
678 Returns the minimum value contained in the vector.
679  
680 my $vector = Math::GSL::VectorComplex->new([2,4,1]);
681 my $minimum = $vector->min;
682  
683 =cut
684  
685 sub min {
686 my $self=shift;
687 return gsl_vector_min($self->raw);
688 }
689  
690 =head2 max()
691  
692 Returns the minimum value contained in the vector.
693  
694 my $vector = Math::GSL::VectorComplex->new([2,4,1]);
695 my $maximum = $vector->max;
696  
697 =cut
698  
699 sub max {
700 my $self=shift;
701 return gsl_vector_max($self->raw);
702 }
703  
704 =head2 length()
705  
706 Returns the number of elements contained in the vector.
707  
708 my $vector = Math::GSL::VectorComplex->new([2,4,1]);
709 my $length = $vector->length;
710  
711 =cut
712  
713 sub length { my $self=shift; $self->{_length} }
714  
715 =head2 as_list()
716  
717 Gets the content of a Math::GSL::Vector object as a Perl list.
718  
719 my $vector = Math::GSL::VectorComplex->new(3);
720 ...
721 my @values = $vector->as_list;
722 =cut
723  
724 sub as_list {
725 my $self=shift;
726 # this is wrong
727 return map { cplxe( gsl_complex_abs($_), gsl_complex_arg($_) ) } $self->get( [ 0 .. $self->length - 1 ] );
728 }
729  
730 =head2 get()
731  
732 Gets the value of an of a Math::GSL::Vector object.
733  
734 my $vector = Math::GSL::VectorComplex->new(3);
735 ...
736 my @values = $vector->get(2);
737  
738 You can also enter an array of indices to receive their corresponding values:
739  
740 my $vector = Math::GSL::VectorComplex->new(3);
741 ...
742 my @values = $vector->get([0,2]);
743  
744 =cut
745  
746 sub get {
747 my ($self, $indices) = @_;
748 return map { gsl_vector_complex_get($self->raw, $_ ) } @$indices ;
749 }
750  
751 =head2 reverse()
752  
753 Returns the a vector with the elements in reversed order.
754  
755 use Math::Complex;
756 my $v1 = Math::GSL::VectorComplex->new([ 1, 2, 3*i]);
757 my $v2 = $v1->reverse;
758  
759 =cut
760  
761 sub reverse {
762 my $self = shift;
763 my $copy = $self->copy();
764 unless ( is_status_ok( gsl_vector_complex_reverse( $copy->raw )) ) {
765 die( __PACKAGE__.": error reversing vector " . gsl_strerror($status) );
766 }
767 return $copy;
768 }
769  
770 =head2 set()
771  
772 Sets values of an of a Math::GSL::Vector object.
773  
774 my $vector = Math::GSL::VectorComplex->new(3);
775 $vector->set([1,2], [8,23]);
776  
777 This sets the second and third value to 8 and 23.
778  
779 =cut
780  
781 sub set {
782 my ($self, $indices, $values) = @_;
783 die (__PACKAGE__.'::set($indices, $values) - $indices and $values must be array references of the same length')
784 unless ( ref $indices eq 'ARRAY' && ref $values eq 'ARRAY' && $#$indices == $#$values );
785 eval {
786 map { gsl_vector_complex_set($self->{_vector}, $indices->[$_], $values->[$_] ) } (0..$#$indices);
787 };
788 # better error handling?
789 warn $@ if $@;
790 return;
791 }
792  
793 =head2 copy()
794  
795 Returns a copy of the vector, which has the same length and values but resides at a different location in memory.
796  
797 my $vector = Math::GSL::VectorComplex->new([10 .. 20]);
798 my $copy = $vector->copy;
799  
800 =cut
801  
802 sub copy {
803 my $self = shift;
804 my $copy = Math::GSL::VectorComplex->new( $self->length );
805 my $status = gsl_vector_complex_memcpy($copy->raw, $self->raw);
806 if ( $status != $GSL_SUCCESS ) {
807 croak "Math::GSL - error copying memory, aborting. $! status=$status";
808 }
809 return $copy;
810 }
811  
812 =head2 swap()
813  
814 Exchanges the values in the vectors $v with $w by copying.
815  
816 my $v = Math::GSL::VectorComplex->new([1..5]);
817 my $w = Math::GSL::VectorComplex->new([3..7]);
818 $v->swap( $w );
819  
820 =cut
821  
822 sub swap() {
823 my ($self,$other) = @_;
824 croak "Math::GSL::VectorComplex : \$v->swap(\$w) - \$w must be a Math::GSL::VectorComplex"
825 unless ref $other eq 'Math::GSL::VectorComplex';
826 gsl_vector_complex_swap( $self->raw, $other->raw );
827 return $self;
828 }
829  
830 sub _multiplication {
831 my ($left,$right) = @_;
832 my $lcopy = $left->copy;
833  
834 if ( blessed $right && $right->isa(__PACKAGE__) ) {
835 return $lcopy->dot_product($right);
836 } else {
837 # will be in upcoming gsl 1.12
838 # gsl_vector_complex_scale($lcopy->raw, $right);
839 }
840 return $lcopy;
841 }
842  
843 sub _subtract {
844 my ($left, $right, $flip) = @_;
845  
846 if ($flip) {
847 my $lcopy = $left->copy;
848 # will be in upcoming gsl 1.12
849 # gsl_vector_complex_scale($lcopy->raw, -1 );
850 gsl_vector_add_constant($lcopy->raw, $right);
851 return $lcopy;
852 } else {
853 return _addition($left, -1.0*$right);
854 }
855 }
856  
857 sub _addition {
858 my ($left, $right, $flip) = @_;
859 my $lcopy = $left->copy;
860  
861 if ( blessed $right && $right->isa('Math::GSL::Vector') && blessed $left && $left->isa('Math::GSL::Vector') ) {
862 if ( $left->length == $right->length ) {
863 gsl_vector_complex_add($lcopy->raw, $right->raw);
864 } else {
865 croak "Math::GSL - addition of vectors must be called with two objects vectors and must have the same length";
866 }
867 } else {
868 gsl_vector_complex_add_constant($lcopy->raw, $right);
869 }
870 return $lcopy;
871 }
872  
873 sub dot_product_pp {
874 my ($left,$right) = @_;
875 my $sum=0;
876 if ( blessed $right && $right->isa('Math::GSL::Vector') && $left->length == $right->length ) {
877 my @l = $left->as_list;
878 my @r = $right->as_list;
879 map { $sum += $l[$_] * $r[$_] } (0..$#l);
880 return $sum;
881 } else {
882 croak "dot_product() must be called with two vectors";
883 }
884 }
885  
886 sub dot_product {
887 my ($left,$right) = @_;
888  
889 my ($status, $product) = gsl_blas_ddot($left->raw,$right->raw);
890 croak sprintf "Math::GSL::dot_product - %s", gsl_strerror($status) if ($status != $GSL_SUCCESS);
891 return $product;
892 }
893  
894 =head1 AUTHORS
895  
896 Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
897  
898 =head1 COPYRIGHT AND LICENSE
899  
900 Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan
901  
902 This program is free software; you can redistribute it and/or modify it
903 under the same terms as Perl itself.
904  
905 =cut
906  
907 1;