argSelect Interface

public interface argSelect

Use an indirect introspection sort on an array of numbers

Example usage

program argSortTest
use variableKind
use m_strings, only: str
use m_random, only: rngInteger,rngNormal
use m_arrays, only: isSorted
use m_Sort, only: argSort
real(r64),allocatable :: d1D(:)
integer(i32),allocatable :: i1D(:)
integer(i32),allocatable :: indx(:)
integer(i32) :: i, k, N
N = 10000
call allocate(indx,N)
call arange(indx, 1, N)
call allocate(d1D,N)
call rngNormal(d1D)
k = (size(d1D)+1)/2
call argSelect(d1D, indx, k)
write(*,'(a)') 'Double array is indirectly sorted? '//str(isSorted(d1D(indx)))

call arange(indx, 1, N)
call allocate(i1D,N)
call rngInteger(i1D)
call argSelectt(i1D, indx, k)
write(*,'(a)') 'Integer array is indirectly sorted? '//str(isSorted(i1D(indx)))
end program


Subroutines

public subroutine argQuickSelect_i1D(this, indx, k, res, left, right)

Interfaced with argSelect()

Arguments

Type IntentOptional AttributesName
integer(kind=i32), intent(in) :: this(:)

1D array

integer(kind=i32), intent(inout) :: indx(:)

Index to choose kth smallest from

integer(kind=i32), intent(in) :: k

kth smallest element

integer(kind=i32) :: res

Index of the kth smallest element

integer(kind=i32), intent(in), optional :: left

Select over the region left:right

integer(kind=i32), intent(in), optional :: right

Select over the region left:right

public subroutine argQuickSelect_id1D(this, indx, k, res, left, right)

Interfaced with argSelect()

Arguments

Type IntentOptional AttributesName
integer(kind=i64), intent(in) :: this(:)

1D array

integer(kind=i32), intent(inout) :: indx(:)

Index to choose kth smallest from

integer(kind=i32), intent(in) :: k

kth smallest element

integer(kind=i32) :: res

Index of the kth smallest element

integer(kind=i32), intent(in), optional :: left

Select over the region left:right

integer(kind=i32), intent(in), optional :: right

Select over the region left:right

public subroutine argQuickSelect_r1D(this, indx, k, res, left, right)

Interfaced with argSelect()

Arguments

Type IntentOptional AttributesName
real(kind=r32), intent(in) :: this(:)

1D array

integer(kind=i32), intent(inout) :: indx(:)

Index to choose kth smallest from

integer(kind=i32), intent(in) :: k

kth smallest element

integer(kind=i32) :: res

Index of the kth smallest element

integer(kind=i32), intent(in), optional :: left

Select over the region left:right

integer(kind=i32), intent(in), optional :: right

Select over the region left:right

public subroutine argQuickSelect_d1D(this, indx, k, res, left, right)

Interfaced with argSelect()

Arguments

Type IntentOptional AttributesName
real(kind=r64), intent(in) :: this(:)

1D array

integer(kind=i32), intent(inout) :: indx(:)

Index to choose kth smallest from

integer(kind=i32), intent(in) :: k

kth smallest element

integer(kind=i32) :: res

Index of the kth smallest element

integer(kind=i32), intent(in), optional :: left

Select over the region left:right

integer(kind=i32), intent(in), optional :: right

Select over the region left:right


allocate allocate_test appendString arange argInsertionsort argMedianOf3 argPartition argSelect argSort array1D_test binarySearch checkIsOpen closeFile compact compare compare_d1 copy copy_test countEntries crossproduct cumprod cumsum dArgDynamicArray dArgDynamicArray_test daysInMonth daysInYear dDynamicArray dDynamicArray_test deallocate debug debug_s deleteFile diff eMsg fastTwoDiff fastTwoSum fErr fileExists fileIO_test geometricMean getExtension getFileSize getNFileLines getRandomSeed hasExtension hasNentries iachar1D iArgDynamicArray iArgDynamicArray_test idArgDynamicArray idArgDynamicArray_test idDynamicArray idDynamicArray_test iDynamicArray iDynamicArray_test ind2sub indexing_test insertionsort integerBin intervalSearch isLeapYear isOpen isSorted isString KdTree KdTree_test lowerCase maths_test mean median medianOf3 mErr msg norm1 normI openBinaryFile openFile partition partition3way partition3way_d1D prependString Prng Prng_test ProgressBar project random_test rArgDynamicArray rArgDynamicArray_test rDynamicArray rDynamicArray_test read1Dble read1Integer readline readline reallocate reallocate_test removeComments repeat replacedelim rngExponential rngExponential_d1 rngExponential_d1D rngExponential_d2D rngExponential_d3D rngExponential_unscaled_d1 rngInteger rngInteger_i1 rngInteger_i1D rngInteger_i2D rngInteger_i3D rngNormal rngNormal_d1 rngNormal_d1D rngNormal_d2D rngNormal_d3D rngUniform rngUniform_d1 rngUniform_d1D rngUniform_d2D rngUniform_d3D rngUniform_xorshift rngWeibull rngWeibull_d1 rngWeibull_d1D rngWeibull_d2D rngWeibull_d3D secondsToHMS select select_test setPrng setPrng_withSeed setPrng_WOseed shuffle simpleSearch skipFileLines sort sorting_test std str strings_test sub2ind swap test tester time_test timeInSeconds timeToInteger trimExtension trimmedmean twoDiff twoSum upperCase variance wMsg writeline