Skip to content

Locations of N largest values in a 1D array #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Beliavsky opened this issue Apr 8, 2021 · 3 comments
Open

Locations of N largest values in a 1D array #378

Beliavsky opened this issue Apr 8, 2021 · 3 comments
Labels
topic: algorithms searching and sorting, merging, ...

Comments

@Beliavsky
Copy link

Often when I sort data, what I really want are the N largest values. I think a function

function maxloc_n(x,n) result(imax)
real, intent(in) :: x(:)
integer, intent(in) :: n
integer :: imax(n) ! positions of n largest values of x(:)
end function maxloc_n

would be widely used if implemented.

@arjenmarkus
Copy link
Member

arjenmarkus commented Apr 8, 2021 via email

@epagone
Copy link

epagone commented Apr 8, 2021

I have not checked it, but my guess is that the ORDERPACK library contains such routines - http://www.fortran-2000.com/rank/ Op do 8 apr. 2021 om 04:41 schreef Beliavsky @.***>:

Yep. ORDERPACK does that and much more (I use it from time to time).

@Beliavsky
Copy link
Author

Does the existence of "partial ranking" in ORDERPACK mean that it should not be stdlib, because it is already available, or that it should be in stdlib, because it is something commonly needed and an implementation is available? This is a general question I have about stdlib. When some algorithm can be implemented in Fortran, when should it be in stdlib and ultimately in the Fortran standard, as opposed to being available to Fortranners who want it, perhaps via FPM?

@awvwgk awvwgk added the topic: algorithms searching and sorting, merging, ... label Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: algorithms searching and sorting, merging, ...
Projects
None yet
Development

No branches or pull requests

4 participants