| Math::GSL::Linalg(3pm) | User Contributed Perl Documentation | Math::GSL::Linalg(3pm) |
Math::GSL::Linalg - Functions for solving linear systems
use Math::GSL::Linalg qw/:all/;
Here is a list of all the functions included in this module :
You have to add the functions you want to use inside the qw /put_funtion_here / with spaces between each function. You can also write use Math::GSL::Complex qw/:all/ to use all available functions of the module.
For more information on the functions, we refer you to the GSL offcial documentation: <http://www.gnu.org/software/gsl/manual/html_node/>
This example shows how to compute the determinant of a matrix with the LU decomposition:
use Math::GSL::Matrix qw/:all/;
use Math::GSL::Permutation qw/:all/;
use Math::GSL::Linalg qw/:all/;
my $Matrix = gsl_matrix_alloc(4,4);
map { gsl_matrix_set($Matrix, 0, $_, $_+1) } (0..3);
gsl_matrix_set($Matrix,1, 0, 2);
gsl_matrix_set($Matrix, 1, 1, 3);
gsl_matrix_set($Matrix, 1, 2, 4);
gsl_matrix_set($Matrix, 1, 3, 1);
gsl_matrix_set($Matrix, 2, 0, 3);
gsl_matrix_set($Matrix, 2, 1, 4);
gsl_matrix_set($Matrix, 2, 2, 1);
gsl_matrix_set($Matrix, 2, 3, 2);
gsl_matrix_set($Matrix, 3, 0, 4);
gsl_matrix_set($Matrix, 3, 1, 1);
gsl_matrix_set($Matrix, 3, 2, 2);
gsl_matrix_set($Matrix, 3, 3, 3);
my $permutation = gsl_permutation_alloc(4);
gsl_permutation_init($permutation);
my ($result, $signum) = gsl_linalg_LU_decomp($Matrix, $permutation);
my $det = gsl_linalg_LU_det($Matrix, $signum);
print "The value of the determinant of the matrix is $det \n";
Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
Copyright (C) 2008-2020 Jonathan "Duke" Leto and Thierry Moisan
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| 2020-11-09 | perl v5.32.0 |