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

filter: Statementstmt 0.0% 0 / 631 Branchbran 0.0% 0 / 124 Conditioncond 0.0% 0 / 72 MC/DCmcdc 0.0% 0 / 38 Subroutinesub 0.0% 0 / 95 Podpod 0.0% 0 / 68 totaltotal 0.0% 0 / 1028 CC 63 SCAR 21.9
CC
63
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::MatrixComplex;
8 use base qw(Exporter);
9 use base qw(DynaLoader);
10 package Math::GSL::MatrixComplexc;
11 bootstrap Math::GSL::MatrixComplex;
12 package Math::GSL::MatrixComplex;
13 @EXPORT = qw();
14  
15 # ---------- BASE METHODS -------------
16  
17 package Math::GSL::MatrixComplex;
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::MatrixComplex;
51  
52 *gsl_error = *Math::GSL::MatrixComplexc::gsl_error;
53 *gsl_stream_printf = *Math::GSL::MatrixComplexc::gsl_stream_printf;
54 *gsl_strerror = *Math::GSL::MatrixComplexc::gsl_strerror;
55 *gsl_set_error_handler = *Math::GSL::MatrixComplexc::gsl_set_error_handler;
56 *gsl_set_error_handler_off = *Math::GSL::MatrixComplexc::gsl_set_error_handler_off;
57 *gsl_set_stream_handler = *Math::GSL::MatrixComplexc::gsl_set_stream_handler;
58 *gsl_set_stream = *Math::GSL::MatrixComplexc::gsl_set_stream;
59 *gsl_vector_alloc = *Math::GSL::MatrixComplexc::gsl_vector_alloc;
60 *gsl_vector_calloc = *Math::GSL::MatrixComplexc::gsl_vector_calloc;
61 *gsl_vector_alloc_from_block = *Math::GSL::MatrixComplexc::gsl_vector_alloc_from_block;
62 *gsl_vector_alloc_from_vector = *Math::GSL::MatrixComplexc::gsl_vector_alloc_from_vector;
63 *gsl_vector_free = *Math::GSL::MatrixComplexc::gsl_vector_free;
64 *gsl_vector_view_array = *Math::GSL::MatrixComplexc::gsl_vector_view_array;
65 *gsl_vector_view_array_with_stride = *Math::GSL::MatrixComplexc::gsl_vector_view_array_with_stride;
66 *gsl_vector_const_view_array = *Math::GSL::MatrixComplexc::gsl_vector_const_view_array;
67 *gsl_vector_const_view_array_with_stride = *Math::GSL::MatrixComplexc::gsl_vector_const_view_array_with_stride;
68 *gsl_vector_subvector = *Math::GSL::MatrixComplexc::gsl_vector_subvector;
69 *gsl_vector_subvector_with_stride = *Math::GSL::MatrixComplexc::gsl_vector_subvector_with_stride;
70 *gsl_vector_const_subvector = *Math::GSL::MatrixComplexc::gsl_vector_const_subvector;
71 *gsl_vector_const_subvector_with_stride = *Math::GSL::MatrixComplexc::gsl_vector_const_subvector_with_stride;
72 *gsl_vector_set_zero = *Math::GSL::MatrixComplexc::gsl_vector_set_zero;
73 *gsl_vector_set_all = *Math::GSL::MatrixComplexc::gsl_vector_set_all;
74 *gsl_vector_set_basis = *Math::GSL::MatrixComplexc::gsl_vector_set_basis;
75 *gsl_vector_fread = *Math::GSL::MatrixComplexc::gsl_vector_fread;
76 *gsl_vector_fwrite = *Math::GSL::MatrixComplexc::gsl_vector_fwrite;
77 *gsl_vector_fscanf = *Math::GSL::MatrixComplexc::gsl_vector_fscanf;
78 *gsl_vector_fprintf = *Math::GSL::MatrixComplexc::gsl_vector_fprintf;
79 *gsl_vector_memcpy = *Math::GSL::MatrixComplexc::gsl_vector_memcpy;
80 *gsl_vector_reverse = *Math::GSL::MatrixComplexc::gsl_vector_reverse;
81 *gsl_vector_swap = *Math::GSL::MatrixComplexc::gsl_vector_swap;
82 *gsl_vector_swap_elements = *Math::GSL::MatrixComplexc::gsl_vector_swap_elements;
83 *gsl_vector_max = *Math::GSL::MatrixComplexc::gsl_vector_max;
84 *gsl_vector_min = *Math::GSL::MatrixComplexc::gsl_vector_min;
85 *gsl_vector_minmax = *Math::GSL::MatrixComplexc::gsl_vector_minmax;
86 *gsl_vector_max_index = *Math::GSL::MatrixComplexc::gsl_vector_max_index;
87 *gsl_vector_min_index = *Math::GSL::MatrixComplexc::gsl_vector_min_index;
88 *gsl_vector_minmax_index = *Math::GSL::MatrixComplexc::gsl_vector_minmax_index;
89 *gsl_vector_add = *Math::GSL::MatrixComplexc::gsl_vector_add;
90 *gsl_vector_sub = *Math::GSL::MatrixComplexc::gsl_vector_sub;
91 *gsl_vector_mul = *Math::GSL::MatrixComplexc::gsl_vector_mul;
92 *gsl_vector_div = *Math::GSL::MatrixComplexc::gsl_vector_div;
93 *gsl_vector_scale = *Math::GSL::MatrixComplexc::gsl_vector_scale;
94 *gsl_vector_add_constant = *Math::GSL::MatrixComplexc::gsl_vector_add_constant;
95 *gsl_vector_axpby = *Math::GSL::MatrixComplexc::gsl_vector_axpby;
96 *gsl_vector_sum = *Math::GSL::MatrixComplexc::gsl_vector_sum;
97 *gsl_vector_equal = *Math::GSL::MatrixComplexc::gsl_vector_equal;
98 *gsl_vector_isnull = *Math::GSL::MatrixComplexc::gsl_vector_isnull;
99 *gsl_vector_ispos = *Math::GSL::MatrixComplexc::gsl_vector_ispos;
100 *gsl_vector_isneg = *Math::GSL::MatrixComplexc::gsl_vector_isneg;
101 *gsl_vector_isnonneg = *Math::GSL::MatrixComplexc::gsl_vector_isnonneg;
102 *gsl_vector_get = *Math::GSL::MatrixComplexc::gsl_vector_get;
103 *gsl_vector_set = *Math::GSL::MatrixComplexc::gsl_vector_set;
104 *gsl_vector_ptr = *Math::GSL::MatrixComplexc::gsl_vector_ptr;
105 *gsl_vector_const_ptr = *Math::GSL::MatrixComplexc::gsl_vector_const_ptr;
106 *gsl_matrix_complex_alloc = *Math::GSL::MatrixComplexc::gsl_matrix_complex_alloc;
107 *gsl_matrix_complex_calloc = *Math::GSL::MatrixComplexc::gsl_matrix_complex_calloc;
108 *gsl_matrix_complex_alloc_from_block = *Math::GSL::MatrixComplexc::gsl_matrix_complex_alloc_from_block;
109 *gsl_matrix_complex_alloc_from_matrix = *Math::GSL::MatrixComplexc::gsl_matrix_complex_alloc_from_matrix;
110 *gsl_vector_complex_alloc_row_from_matrix = *Math::GSL::MatrixComplexc::gsl_vector_complex_alloc_row_from_matrix;
111 *gsl_vector_complex_alloc_col_from_matrix = *Math::GSL::MatrixComplexc::gsl_vector_complex_alloc_col_from_matrix;
112 *gsl_matrix_complex_free = *Math::GSL::MatrixComplexc::gsl_matrix_complex_free;
113 *gsl_matrix_complex_submatrix = *Math::GSL::MatrixComplexc::gsl_matrix_complex_submatrix;
114 *gsl_matrix_complex_row = *Math::GSL::MatrixComplexc::gsl_matrix_complex_row;
115 *gsl_matrix_complex_column = *Math::GSL::MatrixComplexc::gsl_matrix_complex_column;
116 *gsl_matrix_complex_diagonal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_diagonal;
117 *gsl_matrix_complex_subdiagonal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_subdiagonal;
118 *gsl_matrix_complex_superdiagonal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_superdiagonal;
119 *gsl_matrix_complex_subrow = *Math::GSL::MatrixComplexc::gsl_matrix_complex_subrow;
120 *gsl_matrix_complex_subcolumn = *Math::GSL::MatrixComplexc::gsl_matrix_complex_subcolumn;
121 *gsl_matrix_complex_view_array = *Math::GSL::MatrixComplexc::gsl_matrix_complex_view_array;
122 *gsl_matrix_complex_view_array_with_tda = *Math::GSL::MatrixComplexc::gsl_matrix_complex_view_array_with_tda;
123 *gsl_matrix_complex_view_vector = *Math::GSL::MatrixComplexc::gsl_matrix_complex_view_vector;
124 *gsl_matrix_complex_view_vector_with_tda = *Math::GSL::MatrixComplexc::gsl_matrix_complex_view_vector_with_tda;
125 *gsl_matrix_complex_const_submatrix = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_submatrix;
126 *gsl_matrix_complex_const_row = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_row;
127 *gsl_matrix_complex_const_column = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_column;
128 *gsl_matrix_complex_const_diagonal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_diagonal;
129 *gsl_matrix_complex_const_subdiagonal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_subdiagonal;
130 *gsl_matrix_complex_const_superdiagonal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_superdiagonal;
131 *gsl_matrix_complex_const_subrow = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_subrow;
132 *gsl_matrix_complex_const_subcolumn = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_subcolumn;
133 *gsl_matrix_complex_const_view_array = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_view_array;
134 *gsl_matrix_complex_const_view_array_with_tda = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_view_array_with_tda;
135 *gsl_matrix_complex_const_view_vector = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_view_vector;
136 *gsl_matrix_complex_const_view_vector_with_tda = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_view_vector_with_tda;
137 *gsl_matrix_complex_set_zero = *Math::GSL::MatrixComplexc::gsl_matrix_complex_set_zero;
138 *gsl_matrix_complex_set_identity = *Math::GSL::MatrixComplexc::gsl_matrix_complex_set_identity;
139 *gsl_matrix_complex_set_all = *Math::GSL::MatrixComplexc::gsl_matrix_complex_set_all;
140 *gsl_matrix_complex_fread = *Math::GSL::MatrixComplexc::gsl_matrix_complex_fread;
141 *gsl_matrix_complex_fwrite = *Math::GSL::MatrixComplexc::gsl_matrix_complex_fwrite;
142 *gsl_matrix_complex_fscanf = *Math::GSL::MatrixComplexc::gsl_matrix_complex_fscanf;
143 *gsl_matrix_complex_fprintf = *Math::GSL::MatrixComplexc::gsl_matrix_complex_fprintf;
144 *gsl_matrix_complex_memcpy = *Math::GSL::MatrixComplexc::gsl_matrix_complex_memcpy;
145 *gsl_matrix_complex_swap = *Math::GSL::MatrixComplexc::gsl_matrix_complex_swap;
146 *gsl_matrix_complex_tricpy = *Math::GSL::MatrixComplexc::gsl_matrix_complex_tricpy;
147 *gsl_matrix_complex_swap_rows = *Math::GSL::MatrixComplexc::gsl_matrix_complex_swap_rows;
148 *gsl_matrix_complex_swap_columns = *Math::GSL::MatrixComplexc::gsl_matrix_complex_swap_columns;
149 *gsl_matrix_complex_swap_rowcol = *Math::GSL::MatrixComplexc::gsl_matrix_complex_swap_rowcol;
150 *gsl_matrix_complex_transpose = *Math::GSL::MatrixComplexc::gsl_matrix_complex_transpose;
151 *gsl_matrix_complex_transpose_memcpy = *Math::GSL::MatrixComplexc::gsl_matrix_complex_transpose_memcpy;
152 *gsl_matrix_complex_transpose_tricpy = *Math::GSL::MatrixComplexc::gsl_matrix_complex_transpose_tricpy;
153 *gsl_matrix_complex_conjtrans_memcpy = *Math::GSL::MatrixComplexc::gsl_matrix_complex_conjtrans_memcpy;
154 *gsl_matrix_complex_equal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_equal;
155 *gsl_matrix_complex_isnull = *Math::GSL::MatrixComplexc::gsl_matrix_complex_isnull;
156 *gsl_matrix_complex_ispos = *Math::GSL::MatrixComplexc::gsl_matrix_complex_ispos;
157 *gsl_matrix_complex_isneg = *Math::GSL::MatrixComplexc::gsl_matrix_complex_isneg;
158 *gsl_matrix_complex_isnonneg = *Math::GSL::MatrixComplexc::gsl_matrix_complex_isnonneg;
159 *gsl_matrix_complex_add = *Math::GSL::MatrixComplexc::gsl_matrix_complex_add;
160 *gsl_matrix_complex_sub = *Math::GSL::MatrixComplexc::gsl_matrix_complex_sub;
161 *gsl_matrix_complex_mul_elements = *Math::GSL::MatrixComplexc::gsl_matrix_complex_mul_elements;
162 *gsl_matrix_complex_div_elements = *Math::GSL::MatrixComplexc::gsl_matrix_complex_div_elements;
163 *gsl_matrix_complex_scale = *Math::GSL::MatrixComplexc::gsl_matrix_complex_scale;
164 *gsl_matrix_complex_scale_rows = *Math::GSL::MatrixComplexc::gsl_matrix_complex_scale_rows;
165 *gsl_matrix_complex_scale_columns = *Math::GSL::MatrixComplexc::gsl_matrix_complex_scale_columns;
166 *gsl_matrix_complex_add_constant = *Math::GSL::MatrixComplexc::gsl_matrix_complex_add_constant;
167 *gsl_matrix_complex_add_diagonal = *Math::GSL::MatrixComplexc::gsl_matrix_complex_add_diagonal;
168 *gsl_matrix_complex_conjugate = *Math::GSL::MatrixComplexc::gsl_matrix_complex_conjugate;
169 *gsl_matrix_complex_get_row = *Math::GSL::MatrixComplexc::gsl_matrix_complex_get_row;
170 *gsl_matrix_complex_get_col = *Math::GSL::MatrixComplexc::gsl_matrix_complex_get_col;
171 *gsl_matrix_complex_set_row = *Math::GSL::MatrixComplexc::gsl_matrix_complex_set_row;
172 *gsl_matrix_complex_set_col = *Math::GSL::MatrixComplexc::gsl_matrix_complex_set_col;
173 *gsl_matrix_complex_get = *Math::GSL::MatrixComplexc::gsl_matrix_complex_get;
174 *gsl_matrix_complex_set = *Math::GSL::MatrixComplexc::gsl_matrix_complex_set;
175 *gsl_matrix_complex_ptr = *Math::GSL::MatrixComplexc::gsl_matrix_complex_ptr;
176 *gsl_matrix_complex_const_ptr = *Math::GSL::MatrixComplexc::gsl_matrix_complex_const_ptr;
177  
178 ############# Class : Math::GSL::MatrixComplex::gsl_complex ##############
179  
180 package Math::GSL::MatrixComplex::gsl_complex;
181 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
182 @ISA = qw( Math::GSL::MatrixComplex );
183 %OWNER = ();
184 %ITERATORS = ();
185 *swig_dat_get = *Math::GSL::MatrixComplexc::gsl_complex_dat_get;
186 *swig_dat_set = *Math::GSL::MatrixComplexc::gsl_complex_dat_set;
187 sub new {
188 my $pkg = shift;
189 my $self = Math::GSL::MatrixComplexc::new_gsl_complex(@_);
190 bless $self, $pkg if defined($self);
191 }
192  
193 sub DESTROY {
194 return unless $_[0]->isa('HASH');
195 my $self = tied(%{$_[0]});
196 return unless defined $self;
197 delete $ITERATORS{$self};
198 if (exists $OWNER{$self}) {
199 Math::GSL::MatrixComplexc::delete_gsl_complex($self);
200 delete $OWNER{$self};
201 }
202 }
203  
204 sub DISOWN {
205 my $self = shift;
206 my $ptr = tied(%$self);
207 delete $OWNER{$ptr};
208 }
209  
210 sub ACQUIRE {
211 my $self = shift;
212 my $ptr = tied(%$self);
213 $OWNER{$ptr} = 1;
214 }
215  
216  
217 ############# Class : Math::GSL::MatrixComplex::gsl_complex_long_double ##############
218  
219 package Math::GSL::MatrixComplex::gsl_complex_long_double;
220 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
221 @ISA = qw( Math::GSL::MatrixComplex );
222 %OWNER = ();
223 %ITERATORS = ();
224 *swig_dat_get = *Math::GSL::MatrixComplexc::gsl_complex_long_double_dat_get;
225 *swig_dat_set = *Math::GSL::MatrixComplexc::gsl_complex_long_double_dat_set;
226 sub new {
227 my $pkg = shift;
228 my $self = Math::GSL::MatrixComplexc::new_gsl_complex_long_double(@_);
229 bless $self, $pkg if defined($self);
230 }
231  
232 sub DESTROY {
233 return unless $_[0]->isa('HASH');
234 my $self = tied(%{$_[0]});
235 return unless defined $self;
236 delete $ITERATORS{$self};
237 if (exists $OWNER{$self}) {
238 Math::GSL::MatrixComplexc::delete_gsl_complex_long_double($self);
239 delete $OWNER{$self};
240 }
241 }
242  
243 sub DISOWN {
244 my $self = shift;
245 my $ptr = tied(%$self);
246 delete $OWNER{$ptr};
247 }
248  
249 sub ACQUIRE {
250 my $self = shift;
251 my $ptr = tied(%$self);
252 $OWNER{$ptr} = 1;
253 }
254  
255  
256 ############# Class : Math::GSL::MatrixComplex::gsl_complex_float ##############
257  
258 package Math::GSL::MatrixComplex::gsl_complex_float;
259 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
260 @ISA = qw( Math::GSL::MatrixComplex );
261 %OWNER = ();
262 %ITERATORS = ();
263 *swig_dat_get = *Math::GSL::MatrixComplexc::gsl_complex_float_dat_get;
264 *swig_dat_set = *Math::GSL::MatrixComplexc::gsl_complex_float_dat_set;
265 sub new {
266 my $pkg = shift;
267 my $self = Math::GSL::MatrixComplexc::new_gsl_complex_float(@_);
268 bless $self, $pkg if defined($self);
269 }
270  
271 sub DESTROY {
272 return unless $_[0]->isa('HASH');
273 my $self = tied(%{$_[0]});
274 return unless defined $self;
275 delete $ITERATORS{$self};
276 if (exists $OWNER{$self}) {
277 Math::GSL::MatrixComplexc::delete_gsl_complex_float($self);
278 delete $OWNER{$self};
279 }
280 }
281  
282 sub DISOWN {
283 my $self = shift;
284 my $ptr = tied(%$self);
285 delete $OWNER{$ptr};
286 }
287  
288 sub ACQUIRE {
289 my $self = shift;
290 my $ptr = tied(%$self);
291 $OWNER{$ptr} = 1;
292 }
293  
294  
295 ############# Class : Math::GSL::MatrixComplex::gsl_vector ##############
296  
297 package Math::GSL::MatrixComplex::gsl_vector;
298 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
299 @ISA = qw( Math::GSL::MatrixComplex );
300 %OWNER = ();
301 %ITERATORS = ();
302 *swig_size_get = *Math::GSL::MatrixComplexc::gsl_vector_size_get;
303 *swig_size_set = *Math::GSL::MatrixComplexc::gsl_vector_size_set;
304 *swig_stride_get = *Math::GSL::MatrixComplexc::gsl_vector_stride_get;
305 *swig_stride_set = *Math::GSL::MatrixComplexc::gsl_vector_stride_set;
306 *swig_data_get = *Math::GSL::MatrixComplexc::gsl_vector_data_get;
307 *swig_data_set = *Math::GSL::MatrixComplexc::gsl_vector_data_set;
308 *swig_block_get = *Math::GSL::MatrixComplexc::gsl_vector_block_get;
309 *swig_block_set = *Math::GSL::MatrixComplexc::gsl_vector_block_set;
310 *swig_owner_get = *Math::GSL::MatrixComplexc::gsl_vector_owner_get;
311 *swig_owner_set = *Math::GSL::MatrixComplexc::gsl_vector_owner_set;
312 sub new {
313 my $pkg = shift;
314 my $self = Math::GSL::MatrixComplexc::new_gsl_vector(@_);
315 bless $self, $pkg if defined($self);
316 }
317  
318 sub DESTROY {
319 return unless $_[0]->isa('HASH');
320 my $self = tied(%{$_[0]});
321 return unless defined $self;
322 delete $ITERATORS{$self};
323 if (exists $OWNER{$self}) {
324 Math::GSL::MatrixComplexc::delete_gsl_vector($self);
325 delete $OWNER{$self};
326 }
327 }
328  
329 sub DISOWN {
330 my $self = shift;
331 my $ptr = tied(%$self);
332 delete $OWNER{$ptr};
333 }
334  
335 sub ACQUIRE {
336 my $self = shift;
337 my $ptr = tied(%$self);
338 $OWNER{$ptr} = 1;
339 }
340  
341  
342 ############# Class : Math::GSL::MatrixComplex::_gsl_vector_view ##############
343  
344 package Math::GSL::MatrixComplex::_gsl_vector_view;
345 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
346 @ISA = qw( Math::GSL::MatrixComplex );
347 %OWNER = ();
348 %ITERATORS = ();
349 *swig_vector_get = *Math::GSL::MatrixComplexc::_gsl_vector_view_vector_get;
350 *swig_vector_set = *Math::GSL::MatrixComplexc::_gsl_vector_view_vector_set;
351 sub new {
352 my $pkg = shift;
353 my $self = Math::GSL::MatrixComplexc::new__gsl_vector_view(@_);
354 bless $self, $pkg if defined($self);
355 }
356  
357 sub DESTROY {
358 return unless $_[0]->isa('HASH');
359 my $self = tied(%{$_[0]});
360 return unless defined $self;
361 delete $ITERATORS{$self};
362 if (exists $OWNER{$self}) {
363 Math::GSL::MatrixComplexc::delete__gsl_vector_view($self);
364 delete $OWNER{$self};
365 }
366 }
367  
368 sub DISOWN {
369 my $self = shift;
370 my $ptr = tied(%$self);
371 delete $OWNER{$ptr};
372 }
373  
374 sub ACQUIRE {
375 my $self = shift;
376 my $ptr = tied(%$self);
377 $OWNER{$ptr} = 1;
378 }
379  
380  
381 ############# Class : Math::GSL::MatrixComplex::_gsl_vector_const_view ##############
382  
383 package Math::GSL::MatrixComplex::_gsl_vector_const_view;
384 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
385 @ISA = qw( Math::GSL::MatrixComplex );
386 %OWNER = ();
387 %ITERATORS = ();
388 *swig_vector_get = *Math::GSL::MatrixComplexc::_gsl_vector_const_view_vector_get;
389 *swig_vector_set = *Math::GSL::MatrixComplexc::_gsl_vector_const_view_vector_set;
390 sub new {
391 my $pkg = shift;
392 my $self = Math::GSL::MatrixComplexc::new__gsl_vector_const_view(@_);
393 bless $self, $pkg if defined($self);
394 }
395  
396 sub DESTROY {
397 return unless $_[0]->isa('HASH');
398 my $self = tied(%{$_[0]});
399 return unless defined $self;
400 delete $ITERATORS{$self};
401 if (exists $OWNER{$self}) {
402 Math::GSL::MatrixComplexc::delete__gsl_vector_const_view($self);
403 delete $OWNER{$self};
404 }
405 }
406  
407 sub DISOWN {
408 my $self = shift;
409 my $ptr = tied(%$self);
410 delete $OWNER{$ptr};
411 }
412  
413 sub ACQUIRE {
414 my $self = shift;
415 my $ptr = tied(%$self);
416 $OWNER{$ptr} = 1;
417 }
418  
419  
420 ############# Class : Math::GSL::MatrixComplex::gsl_matrix_complex ##############
421  
422 package Math::GSL::MatrixComplex::gsl_matrix_complex;
423 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
424 @ISA = qw( Math::GSL::MatrixComplex );
425 %OWNER = ();
426 %ITERATORS = ();
427 *swig_size1_get = *Math::GSL::MatrixComplexc::gsl_matrix_complex_size1_get;
428 *swig_size1_set = *Math::GSL::MatrixComplexc::gsl_matrix_complex_size1_set;
429 *swig_size2_get = *Math::GSL::MatrixComplexc::gsl_matrix_complex_size2_get;
430 *swig_size2_set = *Math::GSL::MatrixComplexc::gsl_matrix_complex_size2_set;
431 *swig_tda_get = *Math::GSL::MatrixComplexc::gsl_matrix_complex_tda_get;
432 *swig_tda_set = *Math::GSL::MatrixComplexc::gsl_matrix_complex_tda_set;
433 *swig_data_get = *Math::GSL::MatrixComplexc::gsl_matrix_complex_data_get;
434 *swig_data_set = *Math::GSL::MatrixComplexc::gsl_matrix_complex_data_set;
435 *swig_block_get = *Math::GSL::MatrixComplexc::gsl_matrix_complex_block_get;
436 *swig_block_set = *Math::GSL::MatrixComplexc::gsl_matrix_complex_block_set;
437 *swig_owner_get = *Math::GSL::MatrixComplexc::gsl_matrix_complex_owner_get;
438 *swig_owner_set = *Math::GSL::MatrixComplexc::gsl_matrix_complex_owner_set;
439 sub new {
440 my $pkg = shift;
441 my $self = Math::GSL::MatrixComplexc::new_gsl_matrix_complex(@_);
442 bless $self, $pkg if defined($self);
443 }
444  
445 sub DESTROY {
446 return unless $_[0]->isa('HASH');
447 my $self = tied(%{$_[0]});
448 return unless defined $self;
449 delete $ITERATORS{$self};
450 if (exists $OWNER{$self}) {
451 Math::GSL::MatrixComplexc::delete_gsl_matrix_complex($self);
452 delete $OWNER{$self};
453 }
454 }
455  
456 sub DISOWN {
457 my $self = shift;
458 my $ptr = tied(%$self);
459 delete $OWNER{$ptr};
460 }
461  
462 sub ACQUIRE {
463 my $self = shift;
464 my $ptr = tied(%$self);
465 $OWNER{$ptr} = 1;
466 }
467  
468  
469 ############# Class : Math::GSL::MatrixComplex::_gsl_matrix_complex_view ##############
470  
471 package Math::GSL::MatrixComplex::_gsl_matrix_complex_view;
472 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
473 @ISA = qw( Math::GSL::MatrixComplex );
474 %OWNER = ();
475 %ITERATORS = ();
476 *swig_matrix_get = *Math::GSL::MatrixComplexc::_gsl_matrix_complex_view_matrix_get;
477 *swig_matrix_set = *Math::GSL::MatrixComplexc::_gsl_matrix_complex_view_matrix_set;
478 sub new {
479 my $pkg = shift;
480 my $self = Math::GSL::MatrixComplexc::new__gsl_matrix_complex_view(@_);
481 bless $self, $pkg if defined($self);
482 }
483  
484 sub DESTROY {
485 return unless $_[0]->isa('HASH');
486 my $self = tied(%{$_[0]});
487 return unless defined $self;
488 delete $ITERATORS{$self};
489 if (exists $OWNER{$self}) {
490 Math::GSL::MatrixComplexc::delete__gsl_matrix_complex_view($self);
491 delete $OWNER{$self};
492 }
493 }
494  
495 sub DISOWN {
496 my $self = shift;
497 my $ptr = tied(%$self);
498 delete $OWNER{$ptr};
499 }
500  
501 sub ACQUIRE {
502 my $self = shift;
503 my $ptr = tied(%$self);
504 $OWNER{$ptr} = 1;
505 }
506  
507  
508 ############# Class : Math::GSL::MatrixComplex::_gsl_matrix_complex_const_view ##############
509  
510 package Math::GSL::MatrixComplex::_gsl_matrix_complex_const_view;
511 use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
512 @ISA = qw( Math::GSL::MatrixComplex );
513 %OWNER = ();
514 %ITERATORS = ();
515 *swig_matrix_get = *Math::GSL::MatrixComplexc::_gsl_matrix_complex_const_view_matrix_get;
516 *swig_matrix_set = *Math::GSL::MatrixComplexc::_gsl_matrix_complex_const_view_matrix_set;
517 sub new {
518 my $pkg = shift;
519 my $self = Math::GSL::MatrixComplexc::new__gsl_matrix_complex_const_view(@_);
520 bless $self, $pkg if defined($self);
521 }
522  
523 sub DESTROY {
524 return unless $_[0]->isa('HASH');
525 my $self = tied(%{$_[0]});
526 return unless defined $self;
527 delete $ITERATORS{$self};
528 if (exists $OWNER{$self}) {
529 Math::GSL::MatrixComplexc::delete__gsl_matrix_complex_const_view($self);
530 delete $OWNER{$self};
531 }
532 }
533  
534 sub DISOWN {
535 my $self = shift;
536 my $ptr = tied(%$self);
537 delete $OWNER{$ptr};
538 }
539  
540 sub ACQUIRE {
541 my $self = shift;
542 my $ptr = tied(%$self);
543 $OWNER{$ptr} = 1;
544 }
545  
546  
547 # ------- VARIABLE STUBS --------
548  
549 package Math::GSL::MatrixComplex;
550  
551 *GSL_VERSION = *Math::GSL::MatrixComplexc::GSL_VERSION;
552 *GSL_MAJOR_VERSION = *Math::GSL::MatrixComplexc::GSL_MAJOR_VERSION;
553 *GSL_MINOR_VERSION = *Math::GSL::MatrixComplexc::GSL_MINOR_VERSION;
554 *GSL_POSZERO = *Math::GSL::MatrixComplexc::GSL_POSZERO;
555 *GSL_NEGZERO = *Math::GSL::MatrixComplexc::GSL_NEGZERO;
556 *GSL_SUCCESS = *Math::GSL::MatrixComplexc::GSL_SUCCESS;
557 *GSL_FAILURE = *Math::GSL::MatrixComplexc::GSL_FAILURE;
558 *GSL_CONTINUE = *Math::GSL::MatrixComplexc::GSL_CONTINUE;
559 *GSL_EDOM = *Math::GSL::MatrixComplexc::GSL_EDOM;
560 *GSL_ERANGE = *Math::GSL::MatrixComplexc::GSL_ERANGE;
561 *GSL_EFAULT = *Math::GSL::MatrixComplexc::GSL_EFAULT;
562 *GSL_EINVAL = *Math::GSL::MatrixComplexc::GSL_EINVAL;
563 *GSL_EFAILED = *Math::GSL::MatrixComplexc::GSL_EFAILED;
564 *GSL_EFACTOR = *Math::GSL::MatrixComplexc::GSL_EFACTOR;
565 *GSL_ESANITY = *Math::GSL::MatrixComplexc::GSL_ESANITY;
566 *GSL_ENOMEM = *Math::GSL::MatrixComplexc::GSL_ENOMEM;
567 *GSL_EBADFUNC = *Math::GSL::MatrixComplexc::GSL_EBADFUNC;
568 *GSL_ERUNAWAY = *Math::GSL::MatrixComplexc::GSL_ERUNAWAY;
569 *GSL_EMAXITER = *Math::GSL::MatrixComplexc::GSL_EMAXITER;
570 *GSL_EZERODIV = *Math::GSL::MatrixComplexc::GSL_EZERODIV;
571 *GSL_EBADTOL = *Math::GSL::MatrixComplexc::GSL_EBADTOL;
572 *GSL_ETOL = *Math::GSL::MatrixComplexc::GSL_ETOL;
573 *GSL_EUNDRFLW = *Math::GSL::MatrixComplexc::GSL_EUNDRFLW;
574 *GSL_EOVRFLW = *Math::GSL::MatrixComplexc::GSL_EOVRFLW;
575 *GSL_ELOSS = *Math::GSL::MatrixComplexc::GSL_ELOSS;
576 *GSL_EROUND = *Math::GSL::MatrixComplexc::GSL_EROUND;
577 *GSL_EBADLEN = *Math::GSL::MatrixComplexc::GSL_EBADLEN;
578 *GSL_ENOTSQR = *Math::GSL::MatrixComplexc::GSL_ENOTSQR;
579 *GSL_ESING = *Math::GSL::MatrixComplexc::GSL_ESING;
580 *GSL_EDIVERGE = *Math::GSL::MatrixComplexc::GSL_EDIVERGE;
581 *GSL_EUNSUP = *Math::GSL::MatrixComplexc::GSL_EUNSUP;
582 *GSL_EUNIMPL = *Math::GSL::MatrixComplexc::GSL_EUNIMPL;
583 *GSL_ECACHE = *Math::GSL::MatrixComplexc::GSL_ECACHE;
584 *GSL_ETABLE = *Math::GSL::MatrixComplexc::GSL_ETABLE;
585 *GSL_ENOPROG = *Math::GSL::MatrixComplexc::GSL_ENOPROG;
586 *GSL_ENOPROGJ = *Math::GSL::MatrixComplexc::GSL_ENOPROGJ;
587 *GSL_ETOLF = *Math::GSL::MatrixComplexc::GSL_ETOLF;
588 *GSL_ETOLX = *Math::GSL::MatrixComplexc::GSL_ETOLX;
589 *GSL_ETOLG = *Math::GSL::MatrixComplexc::GSL_ETOLG;
590 *GSL_EOF = *Math::GSL::MatrixComplexc::GSL_EOF;
591  
592  
593 use strict;
594 use Carp qw/croak/;
595 use Scalar::Util 'blessed';
596 use Math::Complex;
597 use Data::Dumper;
598  
599 use Math::GSL qw/:all/;
600 use Math::GSL::Errno qw/:all/;
601 use Math::GSL::Eigen qw/:all/;
602 use Math::GSL::Test qw/is_similar/;
603 use Math::GSL::BLAS qw/gsl_blas_zgemm/;
604 use Math::GSL::CBLAS qw/$CblasNoTrans/;
605 use Math::GSL::Complex qw/:all/;
606 use Math::GSL::Permutation;
607 use Math::GSL::VectorComplex qw/:all/;
608  
609 use Math::GSL::Linalg qw/
610 gsl_linalg_complex_LU_decomp
611 gsl_linalg_complex_LU_det
612 gsl_linalg_complex_LU_lndet
613 gsl_linalg_complex_LU_invert
614 /;
615  
616 use overload
617 '*' => \&_multiplication,
618 '+' => \&_addition,
619 '-' => \&_subtract,
620 '==' => \&_equal,
621 '!=' => \&_not_equal,
622 # 'abs' => \&_abs,
623 fallback => 1;
624  
625 our @EXPORT_OK = qw/
626 gsl_matrix_complex_alloc
627 gsl_matrix_complex_calloc
628 gsl_matrix_complex_alloc_from_block
629 gsl_matrix_complex_alloc_from_matrix
630 gsl_vector_complex_alloc_row_from_matrix
631 gsl_vector_complex_alloc_col_from_matrix
632 gsl_matrix_complex_free
633 gsl_matrix_complex_submatrix
634 gsl_matrix_complex_row
635 gsl_matrix_complex_column
636 gsl_matrix_complex_diagonal
637 gsl_matrix_complex_subdiagonal
638 gsl_matrix_complex_superdiagonal
639 gsl_matrix_complex_subrow
640 gsl_matrix_complex_subcolumn
641 gsl_matrix_complex_view_array
642 gsl_matrix_complex_view_array_with_tda
643 gsl_matrix_complex_view_vector
644 gsl_matrix_complex_view_vector_with_tda
645 gsl_matrix_complex_const_submatrix
646 gsl_matrix_complex_const_row
647 gsl_matrix_complex_const_column
648 gsl_matrix_complex_const_diagonal
649 gsl_matrix_complex_const_subdiagonal
650 gsl_matrix_complex_const_superdiagonal
651 gsl_matrix_complex_const_subrow
652 gsl_matrix_complex_const_subcolumn
653 gsl_matrix_complex_const_view_array
654 gsl_matrix_complex_const_view_array_with_tda
655 gsl_matrix_complex_const_view_vector
656 gsl_matrix_complex_const_view_vector_with_tda
657 gsl_matrix_complex_get
658 gsl_matrix_complex_set
659 gsl_matrix_complex_ptr
660 gsl_matrix_complex_const_ptr
661 gsl_matrix_complex_set_zero
662 gsl_matrix_complex_set_identity
663 gsl_matrix_complex_set_all
664 gsl_matrix_complex_fread
665 gsl_matrix_complex_fwrite
666 gsl_matrix_complex_fscanf
667 gsl_matrix_complex_fprintf
668 gsl_matrix_complex_memcpy
669 gsl_matrix_complex_swap
670 gsl_matrix_complex_swap_rows
671 gsl_matrix_complex_swap_columns
672 gsl_matrix_complex_swap_rowcol
673 gsl_matrix_complex_transpose
674 gsl_matrix_complex_transpose_memcpy
675 gsl_matrix_complex_isnull
676 gsl_matrix_complex_ispos
677 gsl_matrix_complex_isneg
678 gsl_matrix_complex_add
679 gsl_matrix_complex_sub
680 gsl_matrix_complex_mul_elements
681 gsl_matrix_complex_div_elements
682 gsl_matrix_complex_scale
683 gsl_matrix_complex_add_constant
684 gsl_matrix_complex_add_diagonal
685 gsl_matrix_complex_get_row
686 gsl_matrix_complex_get_col
687 gsl_matrix_complex_set_row
688 gsl_matrix_complex_set_col
689 /;
690  
691 sub _multiplication {
692 my ($left,$right) = @_;
693 my $lcopy = $left->copy;
694  
695 if ( blessed $right && $right->isa('Math::GSL::MatrixComplex') ) {
696 if ( $left->cols == $right->cols && $left->rows == $right->rows ) {
697 return _dot_product($left,$right);
698 #gsl_matrix_complex_mul_elements($lcopy->raw, $right->raw);
699 } else {
700 croak "Math::GSL::MatrixComplex - multiplication of elements of matrices must be called with two objects matrices and must have the same number of columns and rows";
701 }
702 } else {
703 gsl_matrix_complex_scale($lcopy->raw, $right);
704 }
705 return $lcopy;
706 }
707  
708 sub _dot_product {
709 my ($left,$right) = @_;
710  
711 croak "Math::GSL::Matrix - incompatible matrices in multiplication"
712 unless ( blessed $right && $right->isa('Math::GSL::MatrixComplex') and $left->rows == $right->cols );
713 my $C = Math::GSL::MatrixComplex->new($left->rows, $right->cols);
714 my $complex = gsl_complex_rect(1,0);
715 gsl_blas_zgemm($CblasNoTrans, $CblasNoTrans, $complex, $left->raw, $right->raw, $complex, $C->raw);
716 return $C;
717 }
718  
719 sub _addition {
720 my ($left, $right) = @_;
721  
722 my $lcopy = $left->copy;
723  
724 if ( blessed $right && $right->isa('Math::GSL::MatrixComplex') && blessed $left && $left->isa('Math::GSL::MatrixComplex') ) {
725 if ( $left->cols == $right->cols && $left->rows == $right->rows ) {
726 gsl_matrix_complex_add($lcopy->raw, $right->raw);
727 } else {
728 croak "Math::GSL - addition of matrices must be called with two objects matrices and must have the same number of columns and rows";
729 }
730 } else {
731 gsl_matrix_complex_add_constant($lcopy->raw, $right);
732 }
733 return $lcopy;
734 }
735  
736 sub _subtract {
737 my ($left, $right) = @_;
738  
739 my $lcopy = $left->copy;
740  
741 if ( blessed $right && $right->isa('Math::GSL::MatrixComplex') && blessed $left && $left->isa('Math::GSL::MatrixComplex') ) {
742 if ( $left->cols == $right->cols && $left->rows == $right->rows ) {
743 gsl_matrix_complex_sub($lcopy->raw, $right->raw);
744 } else {
745 croak "Math::GSL - subtraction of matrices must be called with two objects matrices and must have the same number of columns and rows";
746 }
747 } else {
748 gsl_matrix_complex_add_constant($lcopy->raw, $right*-1);
749 }
750 return $lcopy;
751 }
752  
753 sub _equal {
754 my ($left, $right) = @_;
755 return is_similar( [ map { Re $_ } $left->as_list ],
756 [ map { Re $_ } $right->as_list ]) &&
757 is_similar( [ map { Im $_ } $left->as_list ],
758 [ map { Im $_ } $right->as_list ]);
759 }
760  
761 sub _not_equal {
762 my ($left, $right) = @_;
763 return !_equal($left,$right);
764 }
765  
766 sub copy {
767 my $self = shift;
768 my $copy = Math::GSL::MatrixComplex->new( $self->rows, $self->cols );
769 if ( gsl_matrix_complex_memcpy($copy->raw, $self->raw) != $GSL_SUCCESS ) {
770 croak "Math::GSL - error copying memory, aborting";
771 }
772 return $copy;
773 }
774 our %EXPORT_TAGS = ( all => \@EXPORT_OK );
775  
776 =encoding utf8
777  
778 =head1 NAME
779  
780 Math::GSL::MatrixComplex - Complex Matrices
781  
782 =head1 SYNOPSIS
783  
784 use Math::GSL::MatrixComplex qw/:all/;
785 my $matrix1 = Math::GSL::MatrixComplex->new(5,5); # OO interface
786 my $matrix3 = $matrix1 + $matrix1;
787 my $matrix4 = $matrix1 - $matrix1;
788 if($matrix1 == $matrix4) ...
789 if($matrix1 != $matrix3) ...
790  
791 my $matrix2 = gsl_matrix_complex_alloc(5,5); # standard interface
792  
793 =head1 Objected Oriented Interface to GSL Math::GSL::MatrixComplex
794  
795 =head2 new()
796  
797 Creates a new MatrixComplex object of the given size.
798  
799 my $matrix = Math::GSL::MatrixComplex->new(10,10);
800 =cut
801  
802 sub new
803 {
804 my ($class, $rows, $cols) = @_;
805 my $this = {};
806 my $matrix;
807 if ( defined $rows && defined $cols &&
808 $rows > 0 && $cols > 0 &&
809 (int $rows == $rows) && (int $cols == $cols)){
810  
811 $matrix = gsl_matrix_complex_alloc($rows,$cols);
812 } else {
813 croak( __PACKAGE__.'::new($x,$y) - $x and $y must be positive integers');
814 }
815 gsl_matrix_complex_set_zero($matrix);
816 $this->{_matrix} = $matrix;
817 ($this->{_rows}, $this->{_cols}) = ($rows,$cols);
818 bless $this, $class;
819 }
820 =head2 raw()
821  
822 Get the underlying GSL matrix object created by SWIG, useful for using gsl_matrix_* functions which do not have an OO counterpart.
823  
824 my $matrix = Math::GSL::MatrixComplex->new(3,3);
825 my $gsl_matrix = $matrix->raw;
826 my $stuff = gsl_matrix_complex_get($gsl_matrix, 1, 2);
827  
828 =cut
829 sub raw { (shift)->{_matrix} }
830 =head2 rows()
831  
832 Returns the number of rows in the matrix.
833  
834 my $rows = $matrix->rows;
835 =cut
836  
837 sub rows { (shift)->{_rows} }
838  
839 =head2 cols()
840  
841 Returns the number of columns in the matrix.
842  
843 my $cols = $matrix->cols;
844 =cut
845  
846 sub cols { (shift)->{_cols} }
847  
848 =head2 as_vector()
849  
850 Returns a 1xN or Nx1 matrix as a Math::GSL::VectorComplex object. Dies if called on a matrix that is not a single row or column. Useful for turning the output of C<col()> or C<row()> into a vector, like so:
851  
852 my $vector1 = $matrix->col(0)->as_vector;
853 my $vector2 = $matrix->row(1)->as_vector;
854  
855 =cut
856  
857 sub as_vector($)
858 {
859 my ($self) = @_;
860 croak(__PACKAGE__.'::as_vector() - must be a single row or column matrix') unless ($self->cols == 1 or $self->rows == 1);
861  
862 # TODO: there is a faster way to do this
863 return Math::GSL::VectorComplex->new([ $self->as_list ] );
864  
865 }
866  
867 =head2 as_list()
868  
869 Get the contents of a Math::GSL::Matrix object as a Perl list.
870  
871 my $matrix = Math::GSL::MatrixComplex->new(3,3);
872 ...
873 my @matrix = $matrix->as_list;
874 =cut
875  
876 sub as_list($)
877 {
878 my $self = shift;
879 my @matrix;
880 for my $row ( 0 .. $self->rows-1) {
881 push @matrix, map { gsl_matrix_complex_get($self->raw, $row, $_) } (0 .. $self->cols-1 );
882 }
883 return map {
884 Math::Complex->make(
885 gsl_real($_),
886 gsl_imag($_))
887 } @matrix;
888 }
889  
890 =head2 row()
891  
892 Returns a row matrix of the row you enter.
893  
894 my $matrix = Math::GSL::MatrixComplex->new(3,3);
895 ...
896 my $matrix_row = $matrix->row(0);
897  
898 =cut
899  
900 sub row
901 {
902 my ($self, $row) = @_;
903 croak (__PACKAGE__.'::$matrix->row($row) - invalid $row value')
904 unless (($row < $self->rows) and $row >= 0);
905  
906 my $rowmat = Math::GSL::MatrixComplex->new(1,$self->cols);
907  
908 for my $n (0 .. $self->cols-1) {
909 gsl_matrix_complex_set( $rowmat->raw, 0, $n,
910 gsl_matrix_complex_get($self->raw, $row, $n)
911 );
912 }
913  
914 return $rowmat;
915 }
916  
917 =head2 col()
918  
919 Returns a col matrix of the column you enter.
920  
921 my $matrix = Math::GSL::MatrixComplex->new(3,3);
922 ...
923 my $matrix_col = $matrix->col(0);
924  
925 =cut
926  
927 sub col
928 {
929 my ($self, $col) = @_;
930 croak (__PACKAGE__."::\$matrix->col(\$col) - $col not a valid column")
931 unless (defined $col && $col < $self->cols and $col >= 0);
932  
933 my $colmat = Math::GSL::MatrixComplex->new($self->rows, 1);
934  
935 map { gsl_matrix_complex_set($colmat->raw, $_, 0,
936 gsl_matrix_complex_get($self->raw, $_, $col),
937 )
938 } (0 .. $self->rows-1);
939  
940 return $colmat;
941 }
942  
943 =head2 set_row()
944  
945 Sets a the values of a row with the elements of an array.
946  
947 my $matrix = Math::GSL::MatrixComplex->new(3,3);
948 $matrix->set_row(0, [8, 6, 2]);
949  
950 You can also set multiple rows at once with chained calls:
951 my $matrix = Math::GSL::MatrixComplex->new(3,3);
952 $matrix->set_row(0, [8, 6, 2])
953 ->set_row(1, [2, 4, 1]);
954 ...
955  
956 =cut
957  
958 sub set_row {
959 my ($self, $row, $values) = @_;
960 my $length = $#$values;
961 die __PACKAGE__.'::set_row($x, $values) - $values must be a nonempty array reference' if $length == -1;
962 die __PACKAGE__.'::set_row($x, $values) - $x must be a valid row number' if ($row < 0 || $row >= $self->rows);
963 die __PACKAGE__.'::set_row($x, $values) - $values must contains the same number of elements as there is columns in the matrix' if($length != $self->cols-1);
964 # $values may have Math::Complex objects
965 @$values = map { Math::GSL::Complex::gsl_complex_rect(Re($_), Im($_)) } @$values;
966 # warn Dumper [ @$values ];
967 map { gsl_matrix_complex_set($self->raw, $row, $_, $values->[$_]) } (0..$length);
968 return $self;
969 }
970  
971 =head2 set_col()
972  
973 Sets a the values of a column with the elements of an array.
974  
975 my $matrix = Math::GSL::MatrixComplex->new(3,3);
976 $matrix->set_col(0, [8, 6, 2]);
977  
978 You can also set multiple columns at once with chained calls:
979 my $matrix = Math::GSL::MatrixComplex->new(3,3);
980 $matrix->set_col(0, [8, 6, 2])
981 ->set_col(1, [2, 4, 1]);
982 ...
983  
984 =cut
985  
986 sub set_col {
987 my ($self, $col, $values) = @_;
988 my $length = $#$values;
989 die __PACKAGE__.'::set_col($x, $values) - $values must be a nonempty array reference' if $length == -1;
990 die __PACKAGE__.'::set_col($x, $values) - $x must be a valid column number' if ($col < 0 || $col >= $self->cols);
991 die __PACKAGE__.'::set_col($x, $values) - $values must contains the same number of elements as there is rowss in the matrix' if($length != $self->rows-1);
992 # $values may have Math::Complex objects
993 @$values = map { gsl_complex_rect(Re($_), Im($_)) } @$values;
994 map { gsl_matrix_complex_set($self->raw, $_, $col, $values->[$_]) } (0..$length);
995 return $self;
996 }
997  
998 =head2 is_square()
999  
1000 Returns true if a matrix is square, i.e. it has the same number of rows as columns, false otherwise.
1001  
1002 =cut
1003  
1004 sub is_square($)
1005 {
1006 my $self = shift;
1007 return ($self->rows == $self->cols) ? 1 : 0 ;
1008 }
1009  
1010 =head2 det()
1011  
1012 Returns the determinant of a matrix (computed by LU decomposition) or dies if called on a non-square matrix.
1013  
1014 my $det = $matrix->det();
1015  
1016 =cut
1017  
1018 sub det($)
1019 {
1020 my $self = shift;
1021 croak(__PACKAGE__."- determinant only exists for square matrices") unless $self->is_square;
1022  
1023 my $p = Math::GSL::Permutation->new( $self->rows );
1024 my $LU = $self->copy;
1025  
1026 my $s = gsl_linalg_complex_LU_decomp($LU->raw, $p->raw);
1027  
1028 # $z is a gsl_complex
1029 my $z = gsl_linalg_complex_LU_det($LU->raw, $s );
1030 return Math::Complex->make( gsl_real($z), gsl_imag($z) );
1031 }
1032  
1033 =head2 zero()
1034  
1035 Set a matrix to the zero matrix.
1036  
1037 $matrix->zero;
1038  
1039 =cut
1040  
1041 sub zero # brrr!
1042 {
1043 my $self=shift;
1044 gsl_matrix_complex_set_zero($self->raw);
1045 return $self;
1046 }
1047  
1048 =head2 identity()
1049  
1050 Set a matrix to the identity matrix, i.e. one on the diagonal and zero elsewhere.
1051  
1052 my $I = $matrix->identity;
1053  
1054 =cut
1055  
1056 sub identity
1057 {
1058 my $self=shift;
1059 gsl_matrix_complex_set_identity($self->raw);
1060 return $self;
1061 }
1062  
1063 =head2 inverse()
1064  
1065 Returns the inverse of a matrix or dies when called on a non-square matrix.
1066  
1067 my $inverse = $matrix->inverse;
1068  
1069 =cut
1070  
1071 sub inverse($)
1072 {
1073 my $self = shift;
1074 croak(__PACKAGE__."- inverse only exists for square matrices") unless $self->is_square;
1075  
1076 my $p = Math::GSL::Permutation->new( $self->rows );
1077 my $LU = $self->copy;
1078 my $inverse = $self->copy;
1079  
1080 # should check return status
1081 gsl_linalg_complex_LU_decomp($LU->raw, $p->raw);
1082 gsl_linalg_complex_LU_invert($LU->raw, $p->raw,$inverse->raw);
1083  
1084 return $inverse;
1085  
1086 }
1087  
1088 =head2 is_hermitian()
1089  
1090 Returns true if the matrix is hermitian, false otherwise
1091  
1092 my $test = $matrix->is_hermitian;
1093  
1094 =cut
1095  
1096 sub is_hermitian()
1097 {
1098 my ($self) = @_;
1099 my $test = $self->is_square;
1100 my $transpose = $self->copy;
1101 gsl_matrix_complex_transpose($transpose->raw);
1102  
1103 if($test == 1) {
1104 for my $row (0..$self->rows - 1) {
1105 map { gsl_matrix_complex_set($transpose->raw, $row, $_, gsl_complex_conjugate(gsl_matrix_complex_get($transpose->raw, $row, $_))) } (0..$self->cols - 1);
1106 }
1107 if($self != $transpose){
1108 $test = 0;
1109 }
1110 }
1111 return $test;
1112 }
1113 =head2 eigenvalues()
1114  
1115 =cut
1116  
1117  
1118 sub eigenvalues($)
1119 {
1120 my $self=shift;
1121 my ($r,$c) = ($self->rows,$self->cols);
1122 croak "Math::GSL::MatrixComplex : \$matrix->eigenvalues - \$matrix must be square" unless ($r == $c);
1123 my $vector = Math::GSL::Vector->new($r);
1124 my $eigen = gsl_eigen_herm_alloc($r);
1125  
1126  
1127 # GSL has no generalized complex matrix routines
1128 # can only continue if the matrix is hermitian
1129 croak (__PACKAGE__."::eigenvalues : non-hermitian matrices are not currently supported") unless $self->is_hermitian;
1130 gsl_eigen_herm($self->raw, $vector->raw, $eigen);
1131  
1132 return $vector->as_list;
1133 }
1134  
1135 =head2 lndet()
1136  
1137 Returns the natural log of the absolute value of the determinant of a matrix (computed by LU decomposition) or dies if called on a non-square matrix.
1138  
1139 my $lndet = $matrix->lndet();
1140  
1141 =cut
1142  
1143 sub lndet($)
1144 {
1145 my $self = shift;
1146 croak(__PACKAGE__."- log determinant only exists for square matrices") unless $self->is_square;
1147  
1148 my $p = Math::GSL::Permutation->new( $self->rows );
1149 my $LU = $self->copy;
1150  
1151 gsl_linalg_complex_LU_decomp($LU->raw, $p->raw);
1152 return gsl_linalg_complex_LU_lndet($LU->raw);
1153 }
1154 =head1 DESCRIPTION
1155  
1156 =over 1
1157  
1158 =item C<gsl_matrix_complex_alloc >
1159  
1160 =item C<gsl_matrix_complex_calloc >
1161  
1162 =item C<gsl_matrix_complex_alloc_from_block >
1163  
1164 =item C<gsl_matrix_complex_alloc_from_matrix >
1165  
1166 =item C<gsl_vector_complex_alloc_row_from_matrix >
1167  
1168 =item C<gsl_vector_complex_alloc_col_from_matrix >
1169  
1170 =item C<gsl_matrix_complex_free >
1171  
1172 =item C<gsl_matrix_complex_submatrix >
1173  
1174 =item C<gsl_matrix_complex_row >
1175  
1176 =item C<gsl_matrix_complex_column >
1177  
1178 =item C<gsl_matrix_complex_diagonal >
1179  
1180 =item C<gsl_matrix_complex_subdiagonal >
1181  
1182 =item C<gsl_matrix_complex_superdiagonal >
1183  
1184 =item C<gsl_matrix_complex_subrow >
1185  
1186 =item C<gsl_matrix_complex_subcolumn >
1187  
1188 =item C<gsl_matrix_complex_view_array >
1189  
1190 =item C<gsl_matrix_complex_view_array_with_tda >
1191  
1192 =item C<gsl_matrix_complex_view_vector >
1193  
1194 =item C<gsl_matrix_complex_view_vector_with_tda >
1195  
1196 =item C<gsl_matrix_complex_const_submatrix >
1197  
1198 =item C<gsl_matrix_complex_const_row >
1199  
1200 =item C<gsl_matrix_complex_const_column >
1201  
1202 =item C<gsl_matrix_complex_const_diagonal >
1203  
1204 =item C<gsl_matrix_complex_const_subdiagonal >
1205  
1206 =item C<gsl_matrix_complex_const_superdiagonal >
1207  
1208 =item C<gsl_matrix_complex_const_subrow >
1209  
1210 =item C<gsl_matrix_complex_const_subcolumn >
1211  
1212 =item C<gsl_matrix_complex_const_view_array >
1213  
1214 =item C<gsl_matrix_complex_const_view_array_with_tda >
1215  
1216 =item C<gsl_matrix_complex_const_view_vector >
1217  
1218 =item C<gsl_matrix_complex_const_view_vector_with_tda >
1219  
1220 =item C<gsl_matrix_complex_get>
1221  
1222 =item C<gsl_matrix_complex_set>
1223  
1224 =item C<gsl_matrix_complex_ptr>
1225  
1226 =item C<gsl_matrix_complex_const_ptr>
1227  
1228 =item C<gsl_matrix_complex_set_zero >
1229  
1230 =item C<gsl_matrix_complex_set_identity >
1231  
1232 =item C<gsl_matrix_complex_set_all >
1233  
1234 =item C<gsl_matrix_complex_fread >
1235  
1236 =item C<gsl_matrix_complex_fwrite >
1237  
1238 =item C<gsl_matrix_complex_fscanf >
1239  
1240 =item C<gsl_matrix_complex_fprintf >
1241  
1242 =item C<gsl_matrix_complex_memcpy>
1243  
1244 =item C<gsl_matrix_complex_swap>
1245  
1246 =item C<gsl_matrix_complex_swap_rows>
1247  
1248 =item C<gsl_matrix_complex_swap_columns>
1249  
1250 =item C<gsl_matrix_complex_swap_rowcol>
1251  
1252 =item C<gsl_matrix_complex_transpose >
1253  
1254 =item C<gsl_matrix_complex_transpose_memcpy >
1255  
1256 =item C<gsl_matrix_complex_isnull >
1257  
1258 =item C<gsl_matrix_complex_ispos >
1259  
1260 =item C<gsl_matrix_complex_isneg >
1261  
1262 =item C<gsl_matrix_complex_add >
1263  
1264 =item C<gsl_matrix_complex_sub >
1265  
1266 =item C<gsl_matrix_complex_mul_elements >
1267  
1268 =item C<gsl_matrix_complex_div_elements >
1269  
1270 =item C<gsl_matrix_complex_scale >
1271  
1272 =item C<gsl_matrix_complex_add_constant >
1273  
1274 =item C<gsl_matrix_complex_add_diagonal >
1275  
1276 =item C<gsl_matrix_complex_get_row>
1277  
1278 =item C<gsl_matrix_complex_get_col>
1279  
1280 =item C<gsl_matrix_complex_set_row>
1281  
1282 =item C<gsl_matrix_complex_set_col>
1283  
1284 =back
1285  
1286 For more informations on the functions, we refer you to the GSL official documentation
1287 L<http://www.gnu.org/software/gsl/manual/html_node/>
1288  
1289  
1290 =head1 AUTHORS
1291  
1292 Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
1293  
1294 =head1 COPYRIGHT AND LICENSE
1295  
1296 Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan
1297  
1298 This program is free software; you can redistribute it and/or modify it
1299 under the same terms as Perl itself.
1300  
1301 =cut
1302  
1303 1;