1# This file was automatically generated by SWIG (http://www.swig.org). 2# Version 4.0.1 3# 4# Do not make changes to this file unless you know what you are doing--modify 5# the SWIG interface file instead. 6 7package Math::GSL::SparseMatrix; 8use base qw(Exporter); 9use base qw(DynaLoader); 10package Math::GSL::SparseMatrixc; 11bootstrap Math::GSL::SparseMatrix; 12package Math::GSL::SparseMatrix; 13@EXPORT = qw(); 14 15# ---------- BASE METHODS ------------- 16 17package Math::GSL::SparseMatrix; 18 19sub TIEHASH { 20 my ($classname,$obj) = @_; 21 return bless $obj, $classname; 22} 23 24sub CLEAR { } 25 26sub FIRSTKEY { } 27 28sub NEXTKEY { } 29 30sub FETCH { 31 my ($self,$field) = @_; 32 my $member_func = "swig_${field}_get"; 33 $self->$member_func(); 34} 35 36sub STORE { 37 my ($self,$field,$newval) = @_; 38 my $member_func = "swig_${field}_set"; 39 $self->$member_func($newval); 40} 41 42sub this { 43 my $ptr = shift; 44 return tied(%$ptr); 45} 46 47 48# ------- FUNCTION WRAPPERS -------- 49 50package Math::GSL::SparseMatrix; 51 52*gsl_error = *Math::GSL::SparseMatrixc::gsl_error; 53*gsl_stream_printf = *Math::GSL::SparseMatrixc::gsl_stream_printf; 54*gsl_strerror = *Math::GSL::SparseMatrixc::gsl_strerror; 55*gsl_set_error_handler = *Math::GSL::SparseMatrixc::gsl_set_error_handler; 56*gsl_set_error_handler_off = *Math::GSL::SparseMatrixc::gsl_set_error_handler_off; 57*gsl_set_stream_handler = *Math::GSL::SparseMatrixc::gsl_set_stream_handler; 58*gsl_set_stream = *Math::GSL::SparseMatrixc::gsl_set_stream; 59*gsl_spmatrix_alloc = *Math::GSL::SparseMatrixc::gsl_spmatrix_alloc; 60*gsl_spmatrix_alloc_nzmax = *Math::GSL::SparseMatrixc::gsl_spmatrix_alloc_nzmax; 61*gsl_spmatrix_free = *Math::GSL::SparseMatrixc::gsl_spmatrix_free; 62*gsl_spmatrix_realloc = *Math::GSL::SparseMatrixc::gsl_spmatrix_realloc; 63*gsl_spmatrix_set_zero = *Math::GSL::SparseMatrixc::gsl_spmatrix_set_zero; 64*gsl_spmatrix_nnz = *Math::GSL::SparseMatrixc::gsl_spmatrix_nnz; 65*gsl_spmatrix_compare_idx = *Math::GSL::SparseMatrixc::gsl_spmatrix_compare_idx; 66*gsl_spmatrix_tree_rebuild = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_rebuild; 67*gsl_spmatrix_memcpy = *Math::GSL::SparseMatrixc::gsl_spmatrix_memcpy; 68*gsl_spmatrix_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_get; 69*gsl_spmatrix_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_set; 70*gsl_spmatrix_ptr = *Math::GSL::SparseMatrixc::gsl_spmatrix_ptr; 71*gsl_spmatrix_compcol = *Math::GSL::SparseMatrixc::gsl_spmatrix_compcol; 72*gsl_spmatrix_ccs = *Math::GSL::SparseMatrixc::gsl_spmatrix_ccs; 73*gsl_spmatrix_crs = *Math::GSL::SparseMatrixc::gsl_spmatrix_crs; 74*gsl_spmatrix_cumsum = *Math::GSL::SparseMatrixc::gsl_spmatrix_cumsum; 75*gsl_spmatrix_fprintf = *Math::GSL::SparseMatrixc::gsl_spmatrix_fprintf; 76*gsl_spmatrix_fscanf = *Math::GSL::SparseMatrixc::gsl_spmatrix_fscanf; 77*gsl_spmatrix_fwrite = *Math::GSL::SparseMatrixc::gsl_spmatrix_fwrite; 78*gsl_spmatrix_fread = *Math::GSL::SparseMatrixc::gsl_spmatrix_fread; 79*gsl_spmatrix_scale = *Math::GSL::SparseMatrixc::gsl_spmatrix_scale; 80*gsl_spmatrix_minmax = *Math::GSL::SparseMatrixc::gsl_spmatrix_minmax; 81*gsl_spmatrix_add = *Math::GSL::SparseMatrixc::gsl_spmatrix_add; 82*gsl_spmatrix_d2sp = *Math::GSL::SparseMatrixc::gsl_spmatrix_d2sp; 83*gsl_spmatrix_sp2d = *Math::GSL::SparseMatrixc::gsl_spmatrix_sp2d; 84*gsl_spmatrix_equal = *Math::GSL::SparseMatrixc::gsl_spmatrix_equal; 85*gsl_spmatrix_transpose = *Math::GSL::SparseMatrixc::gsl_spmatrix_transpose; 86*gsl_spmatrix_transpose2 = *Math::GSL::SparseMatrixc::gsl_spmatrix_transpose2; 87*gsl_spmatrix_transpose_memcpy = *Math::GSL::SparseMatrixc::gsl_spmatrix_transpose_memcpy; 88 89############# Class : Math::GSL::SparseMatrix::gsl_spmatrix_tree ############## 90 91package Math::GSL::SparseMatrix::gsl_spmatrix_tree; 92use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); 93@ISA = qw( Math::GSL::SparseMatrix ); 94%OWNER = (); 95%ITERATORS = (); 96*swig_tree_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_tree_get; 97*swig_tree_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_tree_set; 98*swig_node_array_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_node_array_get; 99*swig_node_array_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_node_array_set; 100*swig_n_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_n_get; 101*swig_n_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_n_set; 102sub new { 103 my $pkg = shift; 104 my $self = Math::GSL::SparseMatrixc::new_gsl_spmatrix_tree(@_); 105 bless $self, $pkg if defined($self); 106} 107 108sub DESTROY { 109 return unless $_[0]->isa('HASH'); 110 my $self = tied(%{$_[0]}); 111 return unless defined $self; 112 delete $ITERATORS{$self}; 113 if (exists $OWNER{$self}) { 114 Math::GSL::SparseMatrixc::delete_gsl_spmatrix_tree($self); 115 delete $OWNER{$self}; 116 } 117} 118 119sub DISOWN { 120 my $self = shift; 121 my $ptr = tied(%$self); 122 delete $OWNER{$ptr}; 123} 124 125sub ACQUIRE { 126 my $self = shift; 127 my $ptr = tied(%$self); 128 $OWNER{$ptr} = 1; 129} 130 131 132############# Class : Math::GSL::SparseMatrix::gsl_spmatrix ############## 133 134package Math::GSL::SparseMatrix::gsl_spmatrix; 135use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS); 136@ISA = qw( Math::GSL::SparseMatrix ); 137%OWNER = (); 138%ITERATORS = (); 139*swig_size1_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_size1_get; 140*swig_size1_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_size1_set; 141*swig_size2_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_size2_get; 142*swig_size2_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_size2_set; 143*swig_i_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_i_get; 144*swig_i_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_i_set; 145*swig_data_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_data_get; 146*swig_data_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_data_set; 147*swig_p_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_p_get; 148*swig_p_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_p_set; 149*swig_nzmax_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_nzmax_get; 150*swig_nzmax_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_nzmax_set; 151*swig_nz_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_nz_get; 152*swig_nz_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_nz_set; 153*swig_tree_data_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_data_get; 154*swig_tree_data_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_tree_data_set; 155*swig_work_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_work_get; 156*swig_work_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_work_set; 157*swig_sptype_get = *Math::GSL::SparseMatrixc::gsl_spmatrix_sptype_get; 158*swig_sptype_set = *Math::GSL::SparseMatrixc::gsl_spmatrix_sptype_set; 159sub new { 160 my $pkg = shift; 161 my $self = Math::GSL::SparseMatrixc::new_gsl_spmatrix(@_); 162 bless $self, $pkg if defined($self); 163} 164 165sub DESTROY { 166 return unless $_[0]->isa('HASH'); 167 my $self = tied(%{$_[0]}); 168 return unless defined $self; 169 delete $ITERATORS{$self}; 170 if (exists $OWNER{$self}) { 171 Math::GSL::SparseMatrixc::delete_gsl_spmatrix($self); 172 delete $OWNER{$self}; 173 } 174} 175 176sub DISOWN { 177 my $self = shift; 178 my $ptr = tied(%$self); 179 delete $OWNER{$ptr}; 180} 181 182sub ACQUIRE { 183 my $self = shift; 184 my $ptr = tied(%$self); 185 $OWNER{$ptr} = 1; 186} 187 188 189# ------- VARIABLE STUBS -------- 190 191package Math::GSL::SparseMatrix; 192 193*GSL_VERSION = *Math::GSL::SparseMatrixc::GSL_VERSION; 194*GSL_MAJOR_VERSION = *Math::GSL::SparseMatrixc::GSL_MAJOR_VERSION; 195*GSL_MINOR_VERSION = *Math::GSL::SparseMatrixc::GSL_MINOR_VERSION; 196*GSL_POSZERO = *Math::GSL::SparseMatrixc::GSL_POSZERO; 197*GSL_NEGZERO = *Math::GSL::SparseMatrixc::GSL_NEGZERO; 198*GSL_SUCCESS = *Math::GSL::SparseMatrixc::GSL_SUCCESS; 199*GSL_FAILURE = *Math::GSL::SparseMatrixc::GSL_FAILURE; 200*GSL_CONTINUE = *Math::GSL::SparseMatrixc::GSL_CONTINUE; 201*GSL_EDOM = *Math::GSL::SparseMatrixc::GSL_EDOM; 202*GSL_ERANGE = *Math::GSL::SparseMatrixc::GSL_ERANGE; 203*GSL_EFAULT = *Math::GSL::SparseMatrixc::GSL_EFAULT; 204*GSL_EINVAL = *Math::GSL::SparseMatrixc::GSL_EINVAL; 205*GSL_EFAILED = *Math::GSL::SparseMatrixc::GSL_EFAILED; 206*GSL_EFACTOR = *Math::GSL::SparseMatrixc::GSL_EFACTOR; 207*GSL_ESANITY = *Math::GSL::SparseMatrixc::GSL_ESANITY; 208*GSL_ENOMEM = *Math::GSL::SparseMatrixc::GSL_ENOMEM; 209*GSL_EBADFUNC = *Math::GSL::SparseMatrixc::GSL_EBADFUNC; 210*GSL_ERUNAWAY = *Math::GSL::SparseMatrixc::GSL_ERUNAWAY; 211*GSL_EMAXITER = *Math::GSL::SparseMatrixc::GSL_EMAXITER; 212*GSL_EZERODIV = *Math::GSL::SparseMatrixc::GSL_EZERODIV; 213*GSL_EBADTOL = *Math::GSL::SparseMatrixc::GSL_EBADTOL; 214*GSL_ETOL = *Math::GSL::SparseMatrixc::GSL_ETOL; 215*GSL_EUNDRFLW = *Math::GSL::SparseMatrixc::GSL_EUNDRFLW; 216*GSL_EOVRFLW = *Math::GSL::SparseMatrixc::GSL_EOVRFLW; 217*GSL_ELOSS = *Math::GSL::SparseMatrixc::GSL_ELOSS; 218*GSL_EROUND = *Math::GSL::SparseMatrixc::GSL_EROUND; 219*GSL_EBADLEN = *Math::GSL::SparseMatrixc::GSL_EBADLEN; 220*GSL_ENOTSQR = *Math::GSL::SparseMatrixc::GSL_ENOTSQR; 221*GSL_ESING = *Math::GSL::SparseMatrixc::GSL_ESING; 222*GSL_EDIVERGE = *Math::GSL::SparseMatrixc::GSL_EDIVERGE; 223*GSL_EUNSUP = *Math::GSL::SparseMatrixc::GSL_EUNSUP; 224*GSL_EUNIMPL = *Math::GSL::SparseMatrixc::GSL_EUNIMPL; 225*GSL_ECACHE = *Math::GSL::SparseMatrixc::GSL_ECACHE; 226*GSL_ETABLE = *Math::GSL::SparseMatrixc::GSL_ETABLE; 227*GSL_ENOPROG = *Math::GSL::SparseMatrixc::GSL_ENOPROG; 228*GSL_ENOPROGJ = *Math::GSL::SparseMatrixc::GSL_ENOPROGJ; 229*GSL_ETOLF = *Math::GSL::SparseMatrixc::GSL_ETOLF; 230*GSL_ETOLX = *Math::GSL::SparseMatrixc::GSL_ETOLX; 231*GSL_ETOLG = *Math::GSL::SparseMatrixc::GSL_ETOLG; 232*GSL_EOF = *Math::GSL::SparseMatrixc::GSL_EOF; 233*GSL_SPMATRIX_TRIPLET = *Math::GSL::SparseMatrixc::GSL_SPMATRIX_TRIPLET; 234*GSL_SPMATRIX_CCS = *Math::GSL::SparseMatrixc::GSL_SPMATRIX_CCS; 235*GSL_SPMATRIX_CRS = *Math::GSL::SparseMatrixc::GSL_SPMATRIX_CRS; 236 237@EXPORT_OK = qw/ 238 gsl_spmatrix_alloc 239 gsl_spmatrix_get 240 gsl_spmatrix_set 241 gsl_spmatrix_free 242 gsl_spmatrix_transpose 243 gsl_spmatrix_transpose2 244 gsl_spmatrix_transpose_memcpy 245 gsl_spmatrix_set_zero 246 gsl_spmatrix_add 247 gsl_spmatrix_nnz 248 gsl_spmatrix_scale 249 gsl_spmatrix_d2sp 250 gsl_spmatrix_sp2d 251 gsl_spmatrix_minmax 252 gsl_spmatrix_ccs 253 gsl_spmatrix_crs 254 gsl_spmatrix_memcpy 255 gsl_spmatrix_ptr 256 gsl_spmatrix_fwrite 257 gsl_spmatrix_fread 258 gsl_spmatrix_fprintf 259 gsl_spmatrix_fscanf 260 /; 261%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); 262 263__END__ 264 265=encoding utf8 266 267=head1 NAME 268 269Math::GSL::SparseMatrix - Sparse Matrices 270 271=head1 SYNOPSIS 272 273 use Math::GSL::SparseMatrix qw/:all/; 274 use Math::GSL::Matrix qw/gsl_matrix_alloc/; 275 my $sparse = gsl_spmatrix_alloc(100,100); 276 my $status = gsl_spmatrix_set($sparse,50,50,42.42); 277 my $value = gsl_spmatrix_get($sparse,50,50); 278 279 # multiply every element by 5 280 $status = gsl_spmatrix_scale($sparse, 5); 281 282 # get the number of non-zero elements 283 my $nnz = gsl_spmatrix_nnz($sparse); 284 285 # fine min and max values, other than zero elements 286 ($status, $min, $max) = gsl_spmatrix_minmax($sparse); 287 288 # set all elements to zero 289 $status = gsl_spmatrix_set_zero($sparse); 290 291 my $dense = gsl_matrix_alloc(100,100); 292 # convert a sparse matrix to a dense matrix 293 $status = gsl_spmatrix_sp2d($dense, $sparse); 294 295 # convert a dense matrix to a sparse matrix 296 $status = gsl_spmatrix_d2sp($sparse, $dense); 297 298=head1 DESCRIPTION 299 300NOTE: This module requires GSL 2.0 or higher. 301 302For more informations on the functions, we refer you to the GSL official 303documentation: L<http://www.gnu.org/software/gsl/manual/html_node/> 304 305=head1 AUTHORS 306 307Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> 308 309=head1 COPYRIGHT AND LICENSE 310 311Copyright (C) 2008-2021 Jonathan "Duke" Leto and Thierry Moisan 312 313This program is free software; you can redistribute it and/or modify it 314under the same terms as Perl itself. 315 316=cut 317 318 3191; 320