!-*-f90-*- ! ! API: Sorting ! !> \page "Comments on sorting" !> Please go to api/sort.finc for the API documentation. subroutine fgsl_heapsort(array, count, size, compare) type(c_ptr) :: array integer(fgsl_size_t), intent(in) :: count, size interface function compare(x, y) bind(c) import type(c_ptr), value :: x, y integer(c_int) :: compare end function compare end interface ! type(c_funptr) :: fp fp = c_funloc(compare) call gsl_heapsort(array, count, size, fp) end subroutine fgsl_heapsort function fgsl_heapsort_index(p, array, count, size, compare) integer(fgsl_size_t), intent(in) :: count, size integer(fgsl_size_t), intent(out), target :: p(count) type(c_ptr) :: array interface function compare(x, y) bind(c) import type(c_ptr), value :: x, y integer(c_int) :: compare end function compare end interface integer(fgsl_int) :: fgsl_heapsort_index ! type(c_funptr) :: fp fp = c_funloc(compare) fgsl_heapsort_index = gsl_heapsort_index(c_loc(p), array, count, size, fp) end function fgsl_heapsort_index subroutine fgsl_sort_double(data, stride, n) real(fgsl_double), intent(inout), target, contiguous :: data(:) integer(fgsl_size_t), intent(in) :: stride, n call gsl_sort(c_loc(data), stride, n) end subroutine fgsl_sort_double subroutine fgsl_sort2_double(data1, stride1, data2, stride2, n) real(fgsl_double), intent(inout), target, contiguous :: data1(:), data2(:) integer(fgsl_size_t), intent(in) :: stride1, stride2, n call gsl_sort2(c_loc(data1), stride1, c_loc(data2), stride2, n) end subroutine fgsl_sort2_double subroutine fgsl_sort_double_index(p, data, stride, n) integer(fgsl_size_t), intent(out), target, contiguous :: p(:) real(fgsl_double), intent(in), target, contiguous :: data(:) integer(fgsl_size_t), intent(in) :: stride, n call gsl_sort_index(c_loc(p), c_loc(data), stride, n) end subroutine fgsl_sort_double_index function fgsl_sort_double_smallest(dest, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n real(fgsl_double), intent(out), target :: dest(k) real(fgsl_double), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_double_smallest fgsl_sort_double_smallest = gsl_sort_smallest(c_loc(dest), k, c_loc(src), stride, n) end function fgsl_sort_double_smallest function fgsl_sort_double_smallest_index(p, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n integer(fgsl_size_t), intent(out), target :: p(k) real(fgsl_double), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_double_smallest_index fgsl_sort_double_smallest_index = gsl_sort_smallest_index(c_loc(p), k, & c_loc(src), stride, n) end function fgsl_sort_double_smallest_index function fgsl_sort_double_largest(dest, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n real(fgsl_double), intent(out), target :: dest(k) real(fgsl_double), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_double_largest fgsl_sort_double_largest = gsl_sort_largest(c_loc(dest), k, c_loc(src), stride, n) end function fgsl_sort_double_largest function fgsl_sort_double_largest_index(p, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n integer(fgsl_size_t), intent(out), target :: p(k) real(fgsl_double), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_double_largest_index fgsl_sort_double_largest_index = gsl_sort_largest_index(c_loc(p), k, & c_loc(src), stride, n) end function fgsl_sort_double_largest_index subroutine fgsl_sort_long(data, stride, n) integer(fgsl_long), intent(inout), target, contiguous :: data(:) integer(fgsl_size_t), intent(in) :: stride, n call gsl_sort_long(c_loc(data), stride, n) end subroutine fgsl_sort_long subroutine fgsl_sort_long_index(p, data, stride, n) integer(fgsl_size_t), intent(out), target, contiguous :: p(:) integer(fgsl_long), intent(in), target, contiguous :: data(:) integer(fgsl_size_t), intent(in) :: stride, n call gsl_sort_long_index(c_loc(p), c_loc(data), stride, n) end subroutine fgsl_sort_long_index function fgsl_sort_long_smallest(dest, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n integer(fgsl_long), intent(out), target :: dest(k) integer(fgsl_long), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_long_smallest fgsl_sort_long_smallest = gsl_sort_long_smallest(c_loc(dest), k, c_loc(src), stride, n) end function fgsl_sort_long_smallest function fgsl_sort_long_smallest_index(p, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n integer(fgsl_size_t), intent(out), target :: p(k) integer(fgsl_long), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_long_smallest_index fgsl_sort_long_smallest_index = gsl_sort_long_smallest_index(c_loc(p), k, & c_loc(src), stride, n) end function fgsl_sort_long_smallest_index function fgsl_sort_long_largest(dest, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n integer(fgsl_long), intent(out), target :: dest(k) integer(fgsl_long), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_long_largest fgsl_sort_long_largest = gsl_sort_long_largest(c_loc(dest), k, c_loc(src), stride, n) end function fgsl_sort_long_largest function fgsl_sort_long_largest_index(p, k, src, stride, n) integer(fgsl_size_t), intent(in) :: k, stride, n integer(fgsl_size_t), intent(out), target :: p(k) integer(fgsl_long), intent(in), target, contiguous :: src(:) integer(fgsl_int) :: fgsl_sort_long_largest_index fgsl_sort_long_largest_index = gsl_sort_long_largest_index(c_loc(p), k, & c_loc(src), stride, n) end function fgsl_sort_long_largest_index subroutine fgsl_sort_vector(v) type(fgsl_vector), intent(inout) :: v call gsl_sort_vector(v%gsl_vector) end subroutine fgsl_sort_vector subroutine fgsl_sort_vector2(v1, v2) type(fgsl_vector), intent(inout) :: v1, v2 call gsl_sort_vector2(v1%gsl_vector, v2%gsl_vector) end subroutine fgsl_sort_vector2 subroutine fgsl_sort_vector_index(p,v) type(fgsl_permutation), intent(inout) :: p type(fgsl_vector), intent(in) :: v integer(fgsl_int) :: status status = gsl_sort_vector_index(p%gsl_permutation,v%gsl_vector) end subroutine fgsl_sort_vector_index function fgsl_sort_vector_smallest(dest, k, v) integer(fgsl_int) :: fgsl_sort_vector_smallest integer(fgsl_size_t), intent(in) :: k real(fgsl_double), intent(out) :: dest(k) type(fgsl_vector), intent(inout) :: v fgsl_sort_vector_smallest = gsl_sort_vector_smallest(dest, k, v%gsl_vector) end function fgsl_sort_vector_smallest function fgsl_sort_vector_largest(dest, k, v) integer(fgsl_int) :: fgsl_sort_vector_largest integer(fgsl_size_t), intent(in) :: k real(fgsl_double), intent(out) :: dest(k) type(fgsl_vector), intent(inout) :: v fgsl_sort_vector_largest = gsl_sort_vector_largest(dest, k, v%gsl_vector) end function fgsl_sort_vector_largest function fgsl_sort_vector_smallest_index(p, k, v) integer(fgsl_int) :: fgsl_sort_vector_smallest_index integer(fgsl_size_t), intent(in) :: k integer(fgsl_size_t), intent(out) :: p(k) type(fgsl_vector), intent(inout) :: v fgsl_sort_vector_smallest_index = gsl_sort_vector_smallest_index(p, k, v%gsl_vector) end function fgsl_sort_vector_smallest_index function fgsl_sort_vector_largest_index(p, k, v) integer(fgsl_int) :: fgsl_sort_vector_largest_index integer(fgsl_size_t), intent(in) :: k integer(fgsl_size_t), intent(out) :: p(k) type(fgsl_vector), intent(inout) :: v fgsl_sort_vector_largest_index = gsl_sort_vector_largest_index(p, k, v%gsl_vector) end function fgsl_sort_vector_largest_index