Math::GSL::Sort(3pm) User Contributed Perl Documentation Math::GSL::Sort(3pm)

Math::GSL::Sort - Functions for sorting data

    use Math::GSL::Sort qw/:all/;
    my $x       = [ 2**15, 1.67, 20e5, -17, 6900, 1/3 , 42e-10 ];
    my $sorted  = gsl_sort($x, 1, $#$x+1 );
    my $numbers = [ map { rand(100) } (1..100) ];
    my ($status, $smallest10) = gsl_sort_smallest($array, 10, $x, 1, $#$x+1);

 Here is a complete list of all tags for this module :

For more information on the functions, we refer you to the GSL official documentation: <http://www.gnu.org/software/gsl/manual/html_node/>

In the source code of Math::GSL, the file "examples/benchmark/sort" compares the performance of gsl_sort() to Perl's builtin sort() function. Its first argument is the number of iterations and the second is the size of the array of numbers to sort. For example, to see a benchmark of 1000 iterations for arrays of size 50000 you would type

    ./examples/benchmark/sort 1000 50000

Initial benchmarks indicate just slightly above a 2x performance increase over sort() for arrays of between 5000 and 50000 elements. This may mostly be due to the fact that gsl_sort() takes and returns a reference while sort() takes and returns a plain list.

Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>

Copyright (C) 2008-2024 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.

2024-10-15 perl v5.40.0