1%perlcode %{ 2@EXPORT_OK = qw/ 3 gsl_spmatrix_alloc 4 gsl_spmatrix_get 5 gsl_spmatrix_set 6 gsl_spmatrix_free 7 gsl_spmatrix_transpose 8 gsl_spmatrix_transpose2 9 gsl_spmatrix_transpose_memcpy 10 gsl_spmatrix_set_zero 11 gsl_spmatrix_add 12 gsl_spmatrix_nnz 13 gsl_spmatrix_scale 14 gsl_spmatrix_d2sp 15 gsl_spmatrix_sp2d 16 gsl_spmatrix_minmax 17 gsl_spmatrix_ccs 18 gsl_spmatrix_crs 19 gsl_spmatrix_memcpy 20 gsl_spmatrix_ptr 21 gsl_spmatrix_fwrite 22 gsl_spmatrix_fread 23 gsl_spmatrix_fprintf 24 gsl_spmatrix_fscanf 25 /; 26%EXPORT_TAGS = ( all => [ @EXPORT_OK ] ); 27 28__END__ 29 30=encoding utf8 31 32=head1 NAME 33 34Math::GSL::SparseMatrix - Sparse Matrices 35 36=head1 SYNOPSIS 37 38 use Math::GSL::SparseMatrix qw/:all/; 39 use Math::GSL::Matrix qw/gsl_matrix_alloc/; 40 my $sparse = gsl_spmatrix_alloc(100,100); 41 my $status = gsl_spmatrix_set($sparse,50,50,42.42); 42 my $value = gsl_spmatrix_get($sparse,50,50); 43 44 # multiply every element by 5 45 $status = gsl_spmatrix_scale($sparse, 5); 46 47 # get the number of non-zero elements 48 my $nnz = gsl_spmatrix_nnz($sparse); 49 50 # fine min and max values, other than zero elements 51 ($status, $min, $max) = gsl_spmatrix_minmax($sparse); 52 53 # set all elements to zero 54 $status = gsl_spmatrix_set_zero($sparse); 55 56 my $dense = gsl_matrix_alloc(100,100); 57 # convert a sparse matrix to a dense matrix 58 $status = gsl_spmatrix_sp2d($dense, $sparse); 59 60 # convert a dense matrix to a sparse matrix 61 $status = gsl_spmatrix_d2sp($sparse, $dense); 62 63=head1 DESCRIPTION 64 65NOTE: This module requires GSL 2.0 or higher. 66 67For more informations on the functions, we refer you to the GSL official 68documentation: L<http://www.gnu.org/software/gsl/manual/html_node/> 69 70=head1 AUTHORS 71 72Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com> 73 74=head1 COPYRIGHT AND LICENSE 75 76Copyright (C) 2008-2021 Jonathan "Duke" Leto and Thierry Moisan 77 78This program is free software; you can redistribute it and/or modify it 79under the same terms as Perl itself. 80 81=cut 82 83 84%} 85