NuMFor 9f2ab49 (2024-04-08)
Numerical (Modern) Fortran. Library for Simple Numerical computing
|
searchsorted: Find index where an element should be inserted in an array to maintain order. More...
Public Member Functions | |
pure integer function | searchsorted_dp (x, elem) |
Search in an array of real(dp) elements. | |
pure integer function | searchsorted_i (x, elem) |
Search in an array of integer elements. | |
pure integer function | searchsorted_idp (x, elem) |
Search the position of a real number in an array of integer elements. | |
pure integer function | searchsorted_dpi (x, elem) |
Search the position of an integer number in an array of real elements. | |
searchsorted: Find index where an element should be inserted in an array to maintain order.
Find the index into an ascending sorted array x
such that, if elem
was inserted after the index, the order of x
would be preserved.
elem
is outside the limits of x
then:Examples:
With real numbers:
will give n = 3
, while
will give n = 0
and
will give n = 6
pure integer function searchsorted_dp | ( | real(dp), dimension(:), intent(in) | x, |
real(dp), intent(in) | elem ) |
Search in an array of real(dp) elements.
[in] | x | Array sorted in ascending order |
[in] | elem | element to insert |
pure integer function searchsorted_dpi | ( | real(dp), dimension(:), intent(in) | x, |
integer, intent(in) | elem ) |
Search the position of an integer number in an array of real elements.
[in] | x | Array sorted in ascending order |
[in] | elem | element to insert |
pure integer function searchsorted_i | ( | integer, dimension(:), intent(in) | x, |
integer, intent(in) | elem ) |
Search in an array of integer elements.
[in] | x | Array sorted in ascending order |
[in] | elem | element to insert |
pure integer function searchsorted_idp | ( | integer, dimension(:), intent(in) | x, |
real(dp), intent(in) | elem ) |
Search the position of a real number in an array of integer elements.
[in] | x | Array sorted in ascending order |
[in] | elem | element to insert |